summaryrefslogtreecommitdiffstats
path: root/tdecore/kwinmodule.h
blob: afde0259791f12cbd2bd9443b3574f764d7aa743 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
/* This file is part of the KDE libraries
    Copyright (C) 1999 Matthias Ettrich (ettrich@kde.org)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/
/*
 * twinmodule.h. Part of the KDE project.
 */

#ifndef KWINMODULE_H
#define KWINMODULE_H

#include <tqobject.h>
#include <tqvaluelist.h>
#include "kdelibs_export.h"

#ifdef Q_MOC_RUN
#define Q_OS_UNIX
#endif // Q_MOC_RUN

#ifdef Q_OS_UNIX

class KWinModulePrivate;

/**
 *
 * The class KWinModule provides information about the state of the
 * window manager as required by windowmanager modules. It informs a
 * module about all currently managed windows and changes to them (via
 * Qt signals).
 *
 * KWinModule uses NETRootInfo internally. Modules written with this
 * class will work fine under any window manager that implements the
 * NET_WM protocol.
 *
 * There are no methods to manipulate windows. Those are defined in
 * the classes KWin, NETWinInfo and NETRootInfo.
 *
 *
 * @short Base class for KDE Window Manager modules.
 * @author Matthias Ettrich (ettrich@kde.org)
 */
class TDECORE_EXPORT KWinModule : public TQObject
{
    Q_OBJECT

public:

    enum { INFO_DESKTOP=1,
           INFO_WINDOWS=2,
           INFO_ALL=32767 };
    /**
     * Creates a KWinModule object and connects to the window
     * manager.
     * @param parent the parent for the QObject
     * @param what The information you are interested in:
     *   INFO_DESKTOP:  currentDesktop, 
     *                  numberOfDesktops, 
     *                  desktopName, 
     *                  currentDesktopChanged, 
     *                  numberOfDesktopsChanged, 
     *                  desktopNameChanged,
     *                  activeWindow,
     *                  activeWindowChanged,
     *                  workArea(int desktop),
     *                  workAreaChanged
     *
     *   INFO_WINDOWS:  windows,
     *                  windowAdded,
     *                  windowRemoved,
     *                  stackingOrder,
     *                  systemTrayWindows,
     *                  systemTrayWindowAdded,
     *                  systemTrayWindowRemoved,
     *                  windowChanged,
     *                  strutChanged,
     *                  workArea(const TQValueList<WId> &excludes, int desktop)
     **/
    KWinModule( TQObject* parent, int what );
    /**
     * Creates a KWinModule object and connects to the window
     * manager.
     * @param parent the parent for the QObject
     **/
    KWinModule( TQObject* parent = 0 );

    /**
     * Destructor. Internal cleanup, nothing fancy.
     **/
    ~KWinModule();

    /**
     * Returns the list of all toplevel windows currently managed by the
     * window manager in the order of creation. Please do not rely on
     * indexes of this list: Whenever you enter Qt's event loop in your
     * application, it may happen that entries are removed or added.
     * Your module should perhaps work on a copy of this list and verify a
     * window with hasWId() before any operations.
     *
     * Iteration over this list can be done easily with
     * \code
     *  TQValueList<WId>::ConstIterator it;
     *  for ( it = module->windows().begin();
     *        it != modules->windows().end(); ++it ) {
     *     ... do something here,  (*it) is the current WId.
     *       }
     * \endcode
     * @return the list of all toplevel windows
     */
    const TQValueList<WId>& windows() const;

    /**
     * Returns the list of all toplevel windows currently managed by the
     * window manager in the current stacking order (from lower to
     * higher). May be useful for pagers.
     * @return the list of all toplevel windows in stacking order
     */
    const TQValueList<WId>& stackingOrder() const;

    /**
     * Test to see if @p id still managed at present.
     * @param id the window id to test
     * @return true if the window id is still managed
     **/
    bool hasWId(WId id) const;

    /**
     * Returns a list of the system tray windows.
     * @return a list of all system tray windows
     **/
    const TQValueList<WId>& systemTrayWindows() const;

    /**
     * Returns the current virtual desktop.
     * @return the current virtual desktop
     **/
    int currentDesktop() const;

    /**
     * Returns the number of virtual desktops.
     * @return the number of virtual desktops
     **/
    int numberOfDesktops() const;

    /**
     * Returns the number of viewports in x and y direction
     * on the virtual desktop.
     * @return the number of virtual desktops
     * @since 3.5.5
     **/
    TQSize numberOfViewports(int desktop) const;

    /**
     * Returns the current viewport on the given virtual desktop
     * @return the number of virtual desktops
     * @since 3.5.5
     **/
    TQPoint currentViewport(int desktop) const;

    /**
     * Returns the currently active window, or 0 if no window is active.
     * @return the window id of the active window, or 0 if no window is 
     *  active
     **/
    WId activeWindow() const;

    /**
     * Returns the workarea for the specified desktop, or the current
     * work area if no desktop has been specified.
     * @param desktop the number of the desktop to check, -1 for the
     *        current desktop
     * @return the size and position of the desktop
     **/
    TQRect workArea( int desktop = - 1 ) const;


    /**
     * Returns the workarea for the specified desktop, or the current
     * work area if no desktop has been specified. Excludes struts of
     * clients in the exclude List.
     *
     * @param excludes the list of clients whose struts will be excluded
     * @param desktop the number of the desktop to check, -1 for the
     *        current desktop
     * @return the size and position of the desktop
     **/
    TQRect workArea( const TQValueList<WId> &excludes, int desktop = -1) const;

    /**
     * Returns the name of the specified desktop.
     * @param desktop the number of the desktop
     * @return the name of the desktop
     **/
    TQString desktopName( int desktop ) const;

    /**
     * Sets the name of the specified desktop.
     * @param desktop the number of the desktop
     * @param name the new name for the desktop
     **/
    void setDesktopName( int desktop, const TQString& name );

    /**
     * Returns the state of showing the desktop.
     * @since 3.5
     */
    bool showingDesktop() const;

    /**
     * Informs twin via dcop to not manage a window with the
     * specified @p title.
     *
     * Useful for swallowing legacy applications, for example java
     * applets.
     *
     * @param title the title of the window
     */
    void doNotManage( const TQString& title );


signals:

    /**
     * Switched to another virtual desktop.
     * @param desktop the number of the new desktop
     */
    void currentDesktopChanged( int desktop);

    /**
     * A window has been added.
     * @param id the id of the the window 
     */
    void windowAdded(WId id);

    /**
     * A window has been removed.
     * @param id the id of the window that has been removed
     */
    void windowRemoved(WId id);

    /**
     * Hint that \<Window> is active (= has focus) now.
     * @param id the id of the window that is active
     */
    void activeWindowChanged(WId id);

    /**
     * Desktops have been renamed.
     */
    void desktopNamesChanged();

    /**
     * The number of desktops changed.
     * @param num the new number of desktops
     */
    void numberOfDesktopsChanged(int num);

    /**
     * Emitted when a dock window has been added.
     * @param id the id of the new system tray window
     */
    void systemTrayWindowAdded(WId id);

    /**
     * Emitted when a dock window has been removed.
     * @param id the id of the former system tray window
     */
    void systemTrayWindowRemoved(WId id);

    /**
     * The workarea has changed.
     */
    void workAreaChanged();

    /** 
     * Something changed with the struts, may or may not have changed
     * the work area. Usually just using the workAreaChanged() signal
     * is sufficient.
     */
    void strutChanged();
    
    /**
     * Emitted when the stacking order of the window changed. The new order
     * can be obtained with stackingOrder().
     */
    void stackingOrderChanged();


    /**
     * The window changed.
     *
     * The properties parameter contains the NET properties that
     * were modified (see netwm_def.h). First element are NET::Property
     * values, second element are NET::Property2 values (i.e. the format
     * is the same like for the NETWinInfo class constructor).
     * @param id the id of the window
     * @param properties the properties that were modified
     */
    void windowChanged(WId id, const unsigned long* properties );

    /**
     * @deprecated
     * The window changed.
     *
     * The unsigned int parameter contains the NET properties that
     * were modified (see netwm_def.h).
     * @param id the id of the window
     * @param properties the properties that were modified
     */
    void windowChanged(WId id, unsigned int properties);

    /**
     * The window changed somehow.
     * @param id the id of the window
     */
    void windowChanged(WId id);

    /**
     * The state of showing the desktop has changed.
     * @since 3.5
     */
    void showingDesktopChanged( bool showing );

    /**
     * The state of showing the desktop has changed.
     * @since 3.5.5
     */
    void desktopGeometryChanged(int desktop);

    /**
     * The viewport position has changed
     * @since 3.5
     */
    void currentDesktopViewportChanged(int desktop, const TQPoint& viewport);

protected:
    virtual void connectNotify( const char* signal );

private:
    void init(int);

    KWinModulePrivate* d;

    friend class KWinModulePrivate;
};

#endif //Q_OS_UNIX

#endif