2
* Copyright © 2008 Dennis Kasprzyk
3
* Copyright © 2007 Novell, Inc.
5
* Permission to use, copy, modify, distribute, and sell this software
6
* and its documentation for any purpose is hereby granted without
7
* fee, provided that the above copyright notice appear in all copies
8
* and that both that copyright notice and this permission notice
9
* appear in supporting documentation, and that the name of
10
* Dennis Kasprzyk not be used in advertising or publicity pertaining to
11
* distribution of the software without specific, written prior permission.
12
* Dennis Kasprzyk makes no representations about the suitability of this
13
* software for any purpose. It is provided "as is" without express or
16
* DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
18
* NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
21
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
22
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24
* Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
25
* David Reveman <davidr@novell.com>
31
#include <boost/function.hpp>
33
#include <X11/Xlib-xcb.h>
34
#include <X11/Xutil.h>
35
#include <X11/Xregion.h>
36
#include <X11/extensions/Xdamage.h>
37
#include <X11/extensions/sync.h>
39
#include <core/action.h>
40
#include <core/pluginclasses.h>
41
#include <core/size.h>
42
#include <core/point.h>
43
#include <core/region.h>
45
#include <core/wrapsystem.h>
52
struct CompStartupSequence;
54
#define ROOTPARENT(x) (((x)->frame ()) ? (x)->frame () : (x)->id ())
56
#define CompWindowProtocolDeleteMask (1 << 0)
57
#define CompWindowProtocolTakeFocusMask (1 << 1)
58
#define CompWindowProtocolPingMask (1 << 2)
59
#define CompWindowProtocolSyncRequestMask (1 << 3)
61
#define CompWindowTypeDesktopMask (1 << 0)
62
#define CompWindowTypeDockMask (1 << 1)
63
#define CompWindowTypeToolbarMask (1 << 2)
64
#define CompWindowTypeMenuMask (1 << 3)
65
#define CompWindowTypeUtilMask (1 << 4)
66
#define CompWindowTypeSplashMask (1 << 5)
67
#define CompWindowTypeDialogMask (1 << 6)
68
#define CompWindowTypeNormalMask (1 << 7)
69
#define CompWindowTypeDropdownMenuMask (1 << 8)
70
#define CompWindowTypePopupMenuMask (1 << 9)
71
#define CompWindowTypeTooltipMask (1 << 10)
72
#define CompWindowTypeNotificationMask (1 << 11)
73
#define CompWindowTypeComboMask (1 << 12)
74
#define CompWindowTypeDndMask (1 << 13)
75
#define CompWindowTypeModalDialogMask (1 << 14)
76
#define CompWindowTypeFullscreenMask (1 << 15)
77
#define CompWindowTypeUnknownMask (1 << 16)
79
#define NO_FOCUS_MASK (CompWindowTypeDesktopMask | \
80
CompWindowTypeDockMask | \
81
CompWindowTypeSplashMask)
83
#define CompWindowStateModalMask (1 << 0)
84
#define CompWindowStateStickyMask (1 << 1)
85
#define CompWindowStateMaximizedVertMask (1 << 2)
86
#define CompWindowStateMaximizedHorzMask (1 << 3)
87
#define CompWindowStateShadedMask (1 << 4)
88
#define CompWindowStateSkipTaskbarMask (1 << 5)
89
#define CompWindowStateSkipPagerMask (1 << 6)
90
#define CompWindowStateHiddenMask (1 << 7)
91
#define CompWindowStateFullscreenMask (1 << 8)
92
#define CompWindowStateAboveMask (1 << 9)
93
#define CompWindowStateBelowMask (1 << 10)
94
#define CompWindowStateDemandsAttentionMask (1 << 11)
95
#define CompWindowStateDisplayModalMask (1 << 12)
97
#define MAXIMIZE_STATE (CompWindowStateMaximizedHorzMask | \
98
CompWindowStateMaximizedVertMask)
100
#define CompWindowActionMoveMask (1 << 0)
101
#define CompWindowActionResizeMask (1 << 1)
102
#define CompWindowActionStickMask (1 << 2)
103
#define CompWindowActionMinimizeMask (1 << 3)
104
#define CompWindowActionMaximizeHorzMask (1 << 4)
105
#define CompWindowActionMaximizeVertMask (1 << 5)
106
#define CompWindowActionFullscreenMask (1 << 6)
107
#define CompWindowActionCloseMask (1 << 7)
108
#define CompWindowActionShadeMask (1 << 8)
109
#define CompWindowActionChangeDesktopMask (1 << 9)
110
#define CompWindowActionAboveMask (1 << 10)
111
#define CompWindowActionBelowMask (1 << 11)
113
#define MwmFuncAll (1L << 0)
114
#define MwmFuncResize (1L << 1)
115
#define MwmFuncMove (1L << 2)
116
#define MwmFuncIconify (1L << 3)
117
#define MwmFuncMaximize (1L << 4)
118
#define MwmFuncClose (1L << 5)
120
#define MwmDecorHandle (1L << 2)
121
#define MwmDecorTitle (1L << 3)
122
#define MwmDecorMenu (1L << 4)
123
#define MwmDecorMinimize (1L << 5)
124
#define MwmDecorMaximize (1L << 6)
126
#define MwmDecorAll (1L << 0)
127
#define MwmDecorBorder (1L << 1)
128
#define MwmDecorHandle (1L << 2)
129
#define MwmDecorTitle (1L << 3)
130
#define MwmDecorMenu (1L << 4)
131
#define MwmDecorMinimize (1L << 5)
132
#define MwmDecorMaximize (1L << 6)
134
#define WmMoveResizeSizeTopLeft 0
135
#define WmMoveResizeSizeTop 1
136
#define WmMoveResizeSizeTopRight 2
137
#define WmMoveResizeSizeRight 3
138
#define WmMoveResizeSizeBottomRight 4
139
#define WmMoveResizeSizeBottom 5
140
#define WmMoveResizeSizeBottomLeft 6
141
#define WmMoveResizeSizeLeft 7
142
#define WmMoveResizeMove 8
143
#define WmMoveResizeSizeKeyboard 9
144
#define WmMoveResizeMoveKeyboard 10
145
#define WmMoveResizeCancel 11
147
/* EWMH source indication client types */
148
#define ClientTypeUnknown 0
149
#define ClientTypeApplication 1
150
#define ClientTypePager 2
152
#define CompWindowGrabKeyMask (1 << 0)
153
#define CompWindowGrabButtonMask (1 << 1)
154
#define CompWindowGrabMoveMask (1 << 2)
155
#define CompWindowGrabResizeMask (1 << 3)
156
#define CompWindowGrabExternalAppMask (1 << 4)
159
* Enumeration value which represents
160
* how a window will be stacked by compiz
162
enum CompStackingUpdateMode {
163
CompStackingUpdateModeNone = 0,
164
CompStackingUpdateModeNormal,
165
CompStackingUpdateModeAboveFullscreen,
166
CompStackingUpdateModeInitialMap,
167
CompStackingUpdateModeInitialMapDeniedFocus
171
* Enumeration value used by CompWindow::windowNotify
172
* which specifies the type of event that occured.
174
enum CompWindowNotify {
176
CompWindowNotifyUnmap,
177
CompWindowNotifyRestack,
178
CompWindowNotifyHide,
179
CompWindowNotifyShow,
180
CompWindowNotifyAliveChanged,
181
CompWindowNotifySyncAlarm,
182
CompWindowNotifyReparent,
183
CompWindowNotifyUnreparent,
184
CompWindowNotifyFrameUpdate,
185
CompWindowNotifyFocusChange,
186
CompWindowNotifyBeforeUnmap,
187
CompWindowNotifyBeforeDestroy,
188
CompWindowNotifyClose,
189
CompWindowNotifyMinimize,
190
CompWindowNotifyUnminimize,
191
CompWindowNotifyShade,
192
CompWindowNotifyUnshade,
193
CompWindowNotifyEnterShowDesktopMode,
194
CompWindowNotifyLeaveShowDesktopMode,
195
CompWindowNotifyBeforeMap
199
* Specifies the left, right, top and bottom positions of a window's
202
struct CompWindowExtents {
210
* Specifies the area of the screen taken up by strut windows
220
* Wrappable core window functions. Derive from this class
221
* and overload these functions in order to have your function called
222
* after a core CompWindow function is called with the same name.
224
class WindowInterface : public WrapableInterface<CompWindow, WindowInterface>
227
virtual void getOutputExtents (CompWindowExtents& output);
229
virtual void getAllowedActions (unsigned int &setActions,
230
unsigned int &clearActions);
232
virtual bool focus ();
233
virtual void activate ();
234
virtual bool place (CompPoint &pos);
236
virtual void validateResizeRequest (unsigned int &mask,
238
unsigned int source);
240
virtual void resizeNotify (int dx, int dy, int dwidth, int dheight);
241
virtual void moveNotify (int dx, int dy, bool immediate);
242
virtual void windowNotify (CompWindowNotify n);
244
virtual void grabNotify (int x, int y,
245
unsigned int state, unsigned int mask);
246
virtual void ungrabNotify ();
248
virtual void stateChangeNotify (unsigned int lastState);
250
virtual void updateFrameRegion (CompRegion ®ion);
252
virtual void minimize ();
253
virtual void unminimize ();
254
virtual bool minimized ();
256
virtual bool alpha ();
257
virtual bool isFocussable ();
258
virtual bool managed ();
262
* An Window object that wraps an X window. This handles snychronization of
263
* window state, geometry, etc. between Compiz and the X server.
266
public WrapableHandler<WindowInterface, 19>,
267
public PluginClassStorage
272
* A mutable object about the dimensions and location of a CompWindow.
274
class Geometry : public CompRect
278
Geometry (int, int, int, int, int);
282
void set (int, int, int, int, int);
283
void setBorder (int);
289
typedef boost::function<void (CompWindow *)> ForEach;
290
typedef std::map<Window, CompWindow *> Map;
297
CompWindow (Window id,
302
* Geometry retrieved from the
303
* last ConfigureNotify event received
305
Geometry & geometry () const;
309
CompPoint pos () const;
314
CompSize size () const;
317
* Geometry last sent to the server
319
Geometry & serverGeometry () const;
321
int serverX () const;
322
int serverY () const;
323
CompPoint serverPos () const;
326
int serverWidth () const;
327
int serverHeight () const;
328
const CompSize serverSize () const;
330
/* includes decorations */
331
CompRect inputRect () const;
332
CompRect serverInputRect () const;
334
/* includes decorations and shadows */
335
CompRect outputRect () const;
336
CompRect serverOutputRect () const;
341
CompString resName ();
343
const CompRegion & region () const;
345
const CompRegion & frameRegion () const;
347
void updateFrameRegion ();
348
void setWindowFrameExtents (CompWindowExtents *input);
350
unsigned int & wmType ();
352
unsigned int type ();
354
unsigned int & state ();
356
unsigned int actions ();
358
unsigned int & protocols ();
360
void close (Time serverTime);
362
bool inShowDesktopMode ();
364
void setShowDesktopMode (bool);
370
unsigned int activeNum ();
374
CompStruts * struts ();
378
XWindowChanges & saveWc ();
380
void moveToViewportPosition (int x, int y, bool sync);
384
unsigned int desktop ();
386
Window clientLeader (bool checkAncestor = false);
388
void changeState (unsigned int newState);
390
void recalcActions ();
394
void updateWindowOutputExtents ();
398
void sendConfigureNotify ();
400
void sendSyncRequest ();
402
XSyncAlarm syncAlarm ();
408
void incrementUnmapReference ();
410
void incrementDestroyReference ();
412
bool hasUnmapReference ();
414
bool resize (XWindowAttributes);
416
bool resize (Geometry);
418
bool resize (int x, int y, int width, int height,
421
void move (int dx, int dy, bool immediate = true);
423
void syncPosition ();
425
void moveInputFocusTo ();
427
void moveInputFocusToOtherWindow ();
429
/* wraps XConfigureWindow and updates serverGeometry */
430
void configureXWindow (unsigned int valueMask,
431
XWindowChanges *xwc);
433
void moveResize (XWindowChanges *xwc,
436
unsigned int source);
442
void restackAbove (CompWindow *sibling);
444
void restackBelow (CompWindow *sibling);
446
void updateAttributes (CompStackingUpdateMode stackingMode);
452
void maximize (unsigned int state = 0);
454
CompPoint defaultViewport ();
456
CompPoint & initialViewport () const;
458
CompIcon * getIcon (int width, int height);
460
const CompRect & iconGeometry () const;
464
void setDesktop (unsigned int desktop);
466
bool onCurrentDesktop ();
468
bool onAllViewports ();
470
CompPoint getMovementForOffset (CompPoint offset);
472
Window transientFor ();
474
int pendingUnmaps ();
480
CompWindowExtents & input () const;
482
CompWindowExtents & output () const;
484
XSizeHints & sizeHints () const;
494
bool overrideRedirect ();
496
bool isMapped () const;
497
bool isViewable () const;
501
unsigned int depth ();
503
unsigned int mwmDecor ();
504
unsigned int mwmFunc ();
506
bool constrainNewWindowSize (int width,
511
static unsigned int constrainWindowState (unsigned int state,
512
unsigned int actions);
514
static unsigned int allocPluginClassIndex ();
515
static void freePluginClassIndex (unsigned int index);
517
bool updateStruts ();
519
WRAPABLE_HND (0, WindowInterface, void, getOutputExtents,
521
WRAPABLE_HND (1, WindowInterface, void, getAllowedActions,
522
unsigned int &, unsigned int &);
524
WRAPABLE_HND (2, WindowInterface, bool, focus);
525
WRAPABLE_HND (3, WindowInterface, void, activate);
526
WRAPABLE_HND (4, WindowInterface, bool, place, CompPoint &);
527
WRAPABLE_HND (5, WindowInterface, void, validateResizeRequest,
528
unsigned int &, XWindowChanges *, unsigned int);
530
WRAPABLE_HND (6, WindowInterface, void, resizeNotify,
532
WRAPABLE_HND (7, WindowInterface, void, moveNotify, int, int, bool);
533
WRAPABLE_HND (8, WindowInterface, void, windowNotify, CompWindowNotify);
534
WRAPABLE_HND (9, WindowInterface, void, grabNotify, int, int,
535
unsigned int, unsigned int);
536
WRAPABLE_HND (10, WindowInterface, void, ungrabNotify);
537
WRAPABLE_HND (11, WindowInterface, void, stateChangeNotify,
540
WRAPABLE_HND (12, WindowInterface, void, updateFrameRegion,
543
WRAPABLE_HND (13, WindowInterface, void, minimize);
544
WRAPABLE_HND (14, WindowInterface, void, unminimize);
545
WRAPABLE_HND (15, WindowInterface, bool, minimized);
547
WRAPABLE_HND (16, WindowInterface, bool, alpha);
548
WRAPABLE_HND (17, WindowInterface, bool, isFocussable);
549
WRAPABLE_HND (18, WindowInterface, bool, managed);
551
friend class PrivateWindow;
552
friend class CompScreen;
553
friend class PrivateScreen;
554
friend class ModifierHandler;
555
friend class SpewScreen;
556
friend class SpewWindow;