~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/tilinglayout.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/********************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
Copyright (C) 2009 Nikhil Marathe <nsm.nikhil@gmail.com>
 
6
 
 
7
This program is free software; you can redistribute it and/or modify
 
8
it under the terms of the GNU General Public License as published by
 
9
the Free Software Foundation; either version 2 of the License, or
 
10
(at your option) any later version.
 
11
 
 
12
This program is distributed in the hope that it will be useful,
 
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
GNU General Public License for more details.
 
16
 
 
17
You should have received a copy of the GNU General Public License
 
18
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
*********************************************************************/
 
20
 
 
21
#ifndef KWIN_TILINGLAYOUT_H
 
22
#define KWIN_TILINGLAYOUT_H
 
23
 
 
24
#include <QRect>
 
25
#include <QList>
 
26
 
 
27
#include <kdecoration.h>
 
28
 
 
29
namespace KWin
 
30
{
 
31
 
 
32
class Workspace;
 
33
class Client;
 
34
class Tile;
 
35
 
 
36
class TilingLayout
 
37
{
 
38
public:
 
39
    TilingLayout(Workspace *w);
 
40
    virtual ~TilingLayout();
 
41
 
 
42
    /**
 
43
     * Reimplement this to decide how the client(s) should
 
44
     * be resized.
 
45
     * Return true if an actual resize was attempted, false if not ( for whatever reason )
 
46
     */
 
47
    virtual bool clientResized(Client *c, const QRect &moveResizeGeom, const QRect &orig);
 
48
    void clientMoved(Client *c, const QRect &moveResizeGeom, const QRect &orig);
 
49
    void clientMinimizeToggled(Client *c);
 
50
 
 
51
    void commit();
 
52
 
 
53
    void setLayoutType(int t);
 
54
    int layoutType() const;
 
55
 
 
56
    void addTile(Tile *t);
 
57
    void addTile(Client *c);
 
58
    void removeTile(Tile *t);
 
59
    void removeTile(Client *c);
 
60
    void toggleFloatTile(Client *c);
 
61
    void swapTiles(Tile *a, Tile *b);
 
62
    void reconfigureTiling();
 
63
 
 
64
    /**
 
65
     * All tiling layouts do not allow the user to manually
 
66
     * resize clients. This method will be called when the user
 
67
     * attempts a resize. Return any valid position to allow
 
68
     * resizing in that direction. currentMode will be the direction
 
69
     * of resize attempted by the user. You do not have to return the same value.
 
70
     * If you do not want to allow resizing at all, or you do not
 
71
     * want to allow resizing for this client, then return KDecorationDefines::PositionCenter.
 
72
     */
 
73
    virtual KDecorationDefines::Position resizeMode(Client *c, KDecorationDefines::Position currentMode) const;
 
74
 
 
75
    const QList<Tile *>& tiles() const;
 
76
    Tile* findTile(Client *c) const;
 
77
 
 
78
protected:
 
79
    /**
 
80
     * Get a pointer to the Workspace.
 
81
     */
 
82
    Workspace * workspace() const;
 
83
    /**
 
84
     * Get a area in which the Tile can be placed.
 
85
     */
 
86
    const QRect layoutArea(Tile *t) const;
 
87
    /**
 
88
     * Hooks called after a tile is added to
 
89
     * layout and before it is removed.
 
90
     */
 
91
    // currently only required by floating layout
 
92
    virtual void postAddTile(Tile *t);
 
93
    virtual void preRemoveTile(Tile *t);
 
94
 
 
95
private:
 
96
    int findTilePos(Client *c) const;
 
97
    virtual void arrange(QRect wgeom) = 0;
 
98
 
 
99
    void addTileNoArrange(Tile *t);
 
100
    void removeTileNoArrange(Tile *t);
 
101
 
 
102
    Tile* findTileBelowPoint(const QPoint &p) const;
 
103
 
 
104
 
 
105
    QList<Tile *> m_tiles;
 
106
    int m_layoutType;
 
107
    Workspace *m_workspace;
 
108
 
 
109
 
 
110
    friend class TilingLayoutFactory;
 
111
};
 
112
 
 
113
inline void TilingLayout::setLayoutType(int t)
 
114
{
 
115
    m_layoutType = t;
 
116
}
 
117
 
 
118
inline int TilingLayout::layoutType() const
 
119
{
 
120
    return m_layoutType;
 
121
}
 
122
 
 
123
inline const QList<Tile *>& TilingLayout::tiles() const
 
124
{
 
125
    return m_tiles;
 
126
}
 
127
 
 
128
inline Workspace* TilingLayout::workspace() const
 
129
{
 
130
    return m_workspace;
 
131
}
 
132
 
 
133
inline void TilingLayout::postAddTile(Tile *t)
 
134
{
 
135
    Q_UNUSED(t)
 
136
}
 
137
 
 
138
inline void TilingLayout::preRemoveTile(Tile *t)
 
139
{
 
140
    Q_UNUSED(t)
 
141
}
 
142
 
 
143
} // end namespace
 
144
 
 
145
#endif