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

« back to all changes in this revision

Viewing changes to kwin/clientgroup.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 Jorge Mata <matamax123@gmail.com>
 
6
Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com>
 
7
 
 
8
This program is free software: you can redistribute it and/or modify
 
9
it under the terms of the GNU General Public License as published by
 
10
the Free Software Foundation, either version 2 of the License, or
 
11
(at your option) any later version.
 
12
 
 
13
This program is distributed in the hope that it will be useful,
 
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
GNU General Public License for more details.
 
17
 
 
18
You should have received a copy of the GNU General Public License
 
19
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
*******************************************************************************/
 
21
 
 
22
#ifndef KWIN_CLIENTGROUP_H
 
23
#define KWIN_CLIENTGROUP_H
 
24
 
 
25
#include <QObject>
 
26
 
 
27
#include "kdecoration.h"
 
28
#include "utils.h"
 
29
 
 
30
namespace KWin
 
31
{
 
32
 
 
33
class Client;
 
34
 
 
35
/**
 
36
 * This class represents a group of clients for use in window tabbing. All
 
37
 * clients in the group share the same geometry and state information; I.e if
 
38
 * one client changes then all others should also be changed.
 
39
 *
 
40
 * Workspace::clientGroups is a list of all currently-existing client groups.
 
41
 *
 
42
 * A group MUST contain at least one client and MUST NOT contain multiple
 
43
 * copies of the same client. A client MUST NOT be in two groups at the same
 
44
 * time. All decorated clients SHOULD be in a group, even if it's a group of
 
45
 * one client.
 
46
 *
 
47
 * rohanp: Had to convert this object to a QObject to make it easier for adding
 
48
 * scripting interface to ClientGroup.
 
49
 *
 
50
 * If a group contains multiple clients then only one will ever be mapped at
 
51
 * any given time.
 
52
 */
 
53
class ClientGroup : public QObject
 
54
{
 
55
    Q_OBJECT
 
56
public:
 
57
    /**
 
58
     * Creates a new group containing \p c.
 
59
     */
 
60
    ClientGroup(Client* c);
 
61
    ~ClientGroup();
 
62
 
 
63
    /**
 
64
     * Adds \p c to the group before \p before in the list. If \p becomeVisible is \i true then
 
65
     * the added client will become also the visible client.
 
66
     */
 
67
    void add(Client* c, int before = -1, bool becomeVisible = false);
 
68
    /**
 
69
     * Remove the client at index \p index from the group. If \p newGeom is set then the client
 
70
     * will move and resize to the specified geometry, otherwise it will stay where the group
 
71
     * is located. If \p toNullGroup is not true then the client will be added to a new group
 
72
     * of its own.
 
73
     */
 
74
    void remove(int index, const QRect& newGeom = QRect(), bool toNullGroup = false);
 
75
    /**
 
76
     * Remove \p c from the group. If \p newGeom is set then the client will move and resize to
 
77
     * the specified geometry, otherwise it will stay where the group is located. If
 
78
     * \p toNullGroup is not true then the client will be added to a new group of its own.
 
79
     */
 
80
    void remove(Client* c, const QRect& newGeom = QRect(), bool toNullGroup = false);
 
81
    /**
 
82
     * Remove all clients from this group. Results in all clients except the first being moved
 
83
       to a group of their own.
 
84
     */
 
85
    void removeAll();
 
86
    /**
 
87
     * Close all clients in this group.
 
88
     */
 
89
    void closeAll();
 
90
    /**
 
91
     * Move the client at index \p index to the position before the client at index \p before
 
92
     * in the list.
 
93
     */
 
94
    void move(int index, int before);
 
95
    /**
 
96
     * Move \p c to the position before \p before in the list.
 
97
     */
 
98
    void move(Client* c, Client* before);
 
99
    /**
 
100
     * Display the right-click client menu belonging to the client at index \p index at the
 
101
     * global coordinates specified by \p pos.
 
102
     */
 
103
    void displayClientMenu(int index, const QPoint& pos);
 
104
    /**
 
105
     * Display the right-click client menu belonging to \p c at the global coordinates
 
106
     * specified by \p pos.
 
107
     */
 
108
    void displayClientMenu(Client* c, const QPoint& pos);
 
109
 
 
110
    /**
 
111
     * Returns the list index of \p c.
 
112
     */
 
113
    int indexOfClient(Client* c);
 
114
    /**
 
115
     * Returns the list index of the currently visible client in the group.
 
116
     */
 
117
    int indexOfVisibleClient();
 
118
    /**
 
119
     * Returns whether or not this group contains \p c.
 
120
     */
 
121
    bool contains(Client* c);
 
122
    /**
 
123
     * Returns whether or not this group contains the active client.
 
124
     */
 
125
    bool containsActiveClient();
 
126
 
 
127
    /**
 
128
     * Returns the list of all the clients contained in this group in their current order.
 
129
     */
 
130
    ClientList clients() const;
 
131
    /**
 
132
     * Returns a list of the captions and icons of all the clients contained in this group
 
133
     * in their current order.
 
134
     */
 
135
    QList< ClientGroupItem > items() const;
 
136
 
 
137
    /**
 
138
     * Returns the currently visible client.
 
139
     */
 
140
    Client* visible();
 
141
    /**
 
142
     * Makes the client at index \p index the visible one in the group.
 
143
     */
 
144
    void setVisible(int index);
 
145
    /**
 
146
     * Makes \p c the visible client in the group.
 
147
     */
 
148
    void setVisible(Client* c);
 
149
 
 
150
    /**
 
151
     * Returns combined minimum size of all clients in the group.
 
152
     */
 
153
    QSize minSize() const;
 
154
    /**
 
155
     * Returns combined maximum size of all clients in the group.
 
156
     */
 
157
    QSize maxSize() const;
 
158
 
 
159
    /**
 
160
     * Ensures that all the clients in the group have identical geometries and states using
 
161
     * \p main as the primary client to copy the settings off. If \p only is set then only
 
162
     * that client is updated to match \p main.
 
163
     */
 
164
    void updateStates(Client* main, Client* only = NULL);
 
165
 
 
166
private:
 
167
    /**
 
168
     * Regenerate the list of client captions and icons.
 
169
     */
 
170
    void updateItems();
 
171
    /**
 
172
     * Determine the combined minimum and maximum sizes of all clients in the group.
 
173
     */
 
174
    void updateMinMaxSize();
 
175
 
 
176
    ClientList clients_;
 
177
    QList< ClientGroupItem > items_;
 
178
    int visible_;
 
179
 
 
180
    QSize minSize_;
 
181
    QSize maxSize_;
 
182
 
 
183
    friend class Client;
 
184
};
 
185
 
 
186
inline int ClientGroup::indexOfClient(Client* c)
 
187
{
 
188
    return clients_.indexOf(c);
 
189
}
 
190
 
 
191
inline int ClientGroup::indexOfVisibleClient()
 
192
{
 
193
    return visible_;
 
194
}
 
195
 
 
196
inline bool ClientGroup::contains(Client* c)
 
197
{
 
198
    return clients_.contains(c);
 
199
}
 
200
 
 
201
inline ClientList ClientGroup::clients() const
 
202
{
 
203
    return clients_;
 
204
}
 
205
 
 
206
inline QList< ClientGroupItem > ClientGroup::items() const
 
207
{
 
208
    return items_;
 
209
}
 
210
 
 
211
inline Client* ClientGroup::visible()
 
212
{
 
213
    return clients_[visible_];
 
214
}
 
215
 
 
216
inline QSize ClientGroup::minSize() const
 
217
{
 
218
    return minSize_;
 
219
}
 
220
 
 
221
inline QSize ClientGroup::maxSize() const
 
222
{
 
223
    return maxSize_;
 
224
}
 
225
 
 
226
}
 
227
 
 
228
#endif