~muktupavels/compiz/gwd-theme-style-window

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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
/*
 * Copyright © 2008 Dennis Kasprzyk
 * Copyright © 2007 Novell, Inc.
 *
 * Permission to use, copy, modify, distribute, and sell this software
 * and its documentation for any purpose is hereby granted without
 * fee, provided that the above copyright notice appear in all copies
 * and that both that copyright notice and this permission notice
 * appear in supporting documentation, and that the name of
 * Dennis Kasprzyk not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * Dennis Kasprzyk makes no representations about the suitability of this
 * software for any purpose. It is provided "as is" without express or
 * implied warranty.
 *
 * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 *
 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
 *          David Reveman <davidr@novell.com>
 */

#ifndef _PRIVATEWINDOW_H
#define _PRIVATEWINDOW_H

#include <core/core.h>
#include <core/window.h>
#include <core/point.h>
#include <core/timer.h>

#include <boost/shared_ptr.hpp>

#include <core/configurerequestbuffer.h>

#include "syncserverwindow.h"
#include "asyncserverwindow.h"

#define XWINDOWCHANGES_INIT {0, 0, 0, 0, 0, None, 0}

namespace compiz {namespace X11
{
class PendingEvent {
public:
    PendingEvent (Display *, Window);
    virtual ~PendingEvent ();

    virtual bool match (XEvent *);
    unsigned int serial () { return mSerial; } // HACK: will be removed
    virtual void dump ();

    typedef boost::shared_ptr<PendingEvent> Ptr;

protected:

    virtual Window getEventWindow (XEvent *);

    unsigned int mSerial;
    Window       mWindow;
};

class PendingConfigureEvent :
    public PendingEvent
{
public:
    PendingConfigureEvent (Display *, Window, unsigned int, XWindowChanges *);
    virtual ~PendingConfigureEvent ();

    virtual bool match (XEvent *);
    bool matchVM (unsigned int valueMask);
    bool matchRequest (XWindowChanges &xwc, unsigned int);
    virtual void dump ();

    typedef boost::shared_ptr<PendingConfigureEvent> Ptr;

protected:

    virtual Window getEventWindow (XEvent *);

private:
    unsigned int mValueMask;
    XWindowChanges mXwc;
};

class PendingEventQueue
{
public:

    PendingEventQueue (Display *);
    virtual ~PendingEventQueue ();

    void add (PendingEvent::Ptr p);
    bool match (XEvent *);
    bool pending ();
    bool forEachIf (boost::function <bool (compiz::X11::PendingEvent::Ptr)>);
    void clear () { mEvents.clear (); } // HACK will be removed
    void dump ();

protected:
    bool removeIfMatching (const PendingEvent::Ptr &p, XEvent *);

private:
    std::list <PendingEvent::Ptr> mEvents;
};

}}
struct CompGroup;

typedef CompWindowExtents CompFullscreenMonitorSet;

class X11SyncServerWindow :
    public compiz::window::SyncServerWindow
{
    public:

	X11SyncServerWindow (Display      *dpy,
			     const Window *w,
			     const Window *frame);

	bool queryAttributes (XWindowAttributes &attrib);
	bool queryFrameAttributes (XWindowAttributes &attrib);
	XRectangle * queryShapeRectangles(int kind, int *count, int *ordering);

    private:

	Display      *mDpy;
	const Window *mWindow;
	const Window *mFrame;
};

class PrivateWindow :
    public compiz::window::SyncServerWindow,
    public compiz::window::AsyncServerWindow
{

    public:
	PrivateWindow ();
	~PrivateWindow ();

	bool queryAttributes (XWindowAttributes &attrib);
	bool queryFrameAttributes (XWindowAttributes &attrib);
	XRectangle * queryShapeRectangles (int kind, int *count, int *ordering);
	int  requestConfigureOnClient (const XWindowChanges &xwc,
				       unsigned int valueMask);
	int  requestConfigureOnWrapper (const XWindowChanges &xwc,
					unsigned int valueMask);
	int  requestConfigureOnFrame (const XWindowChanges &xwc,
				      unsigned int valueMask);
	void sendSyntheticConfigureNotify ();
	bool hasCustomShape () const;

	void recalcNormalHints ();

	bool updateFrameWindow ();

	void setWindowMatrix ();

	bool restack (Window aboveId);

	bool initializeSyncCounter ();

	bool isGroupTransient (Window clientLeader);

	bool isInvisible() const;

	static bool stackLayerCheck (CompWindow       *w,
				     Window           clientLeader,
				     CompWindow       *below,
				     const ServerLock &lock);

	static bool avoidStackingRelativeTo (CompWindow *w, const ServerLock &lock);

	static CompWindow * findSiblingBelow (CompWindow       *w,
					      bool             aboveFs,
					      const ServerLock &lock);

	static CompWindow * findLowestSiblingBelow (CompWindow       *w,
						    const ServerLock &lock);

	static bool validSiblingBelow (CompWindow       *w,
				       CompWindow       *sibling,
				       const ServerLock &lock);

	void saveGeometry (int mask);

	int restoreGeometry (XWindowChanges *xwc, int mask);

	void reconfigureXWindow (unsigned int   valueMask,
				 XWindowChanges *xwc);

	static bool stackDocks (CompWindow       *w,
				CompWindowList   &updateList,
				XWindowChanges   *xwc,
				unsigned int     *mask,
				const ServerLock &lock);

	static bool stackTransients (CompWindow       *w,
				     CompWindow       *avoid,
				     XWindowChanges   *xwc,
				     CompWindowList   &updateList,
				     const ServerLock &lock);

	static void stackAncestors (CompWindow       *w,
				    XWindowChanges   *xwc,
				    CompWindowList   &updateList,
				    const ServerLock &lock);

	static bool isAncestorTo (CompWindow *transient,
				  CompWindow *ancestor);

	Window getClientLeaderOfAncestor ();

	CompWindow * getModalTransient ();

	int addWindowSizeChanges (XWindowChanges *xwc,
				  CompWindow::Geometry old);

	int addWindowStackChanges (XWindowChanges   *xwc,
				   CompWindow       *sibling,
				   const ServerLock &lock);

	static CompWindow * findValidStackSiblingBelow (CompWindow *w,
							CompWindow *sibling,
							const ServerLock &lock);

	void ensureWindowVisibility ();

	void reveal ();

	static void revealAncestors (CompWindow *w,
				     CompWindow *transient);

	static void minimizeTransients (CompWindow *w,
					CompWindow *ancestor);

	static void unminimizeTransients (CompWindow *w,
					  CompWindow *ancestor);

	bool getUsageTimestamp (Time& timestamp);

	bool isWindowFocusAllowed (Time timestamp);

	static void handleDamageRect (CompWindow *w,
				      int         x,
				      int         y,
				      int         width,
				      int         height);

	bool reparent ();
	void unreparent ();
	void manageFrameWindowSeparately ();

	void hide ();

	void show ();

	void withdraw ();

	bool handlePingTimeout (unsigned int lastPing);

	void handlePing (int lastPing);

	void applyStartupProperties (CompStartupSequence *s);

	void updateNormalHints ();

	void updateWmHints ();

	void updateClassHints ();

	void updateTransientHint ();

	void updateIconGeometry ();

	void updateClientFrame ();

	Window getClientLeader ();

	char * getStartupId ();

	CompRegion
	rectsToRegion (unsigned int, XRectangle *);

	void updateRegion ();

	bool handleSyncAlarm ();

	void move (int dx, int dy, bool sync);
	bool resize (int dx, int dy, int dwidth, int dheight, int dborder);
	bool resize (const CompWindow::Geometry &g);
	bool resize (const XWindowAttributes &attrib);

	void configure (XConfigureEvent *ce);

	void configureFrame (XConfigureEvent *ce);

	void circulate (XCirculateEvent *ce);

	unsigned int adjustConfigureRequestForGravity (XWindowChanges *xwc,
						       unsigned int   xwcm,
						       int            gravity,
						       int	      direction);

	bool updateSize ();

	bool getUserTime (Time& time);
	void setUserTime (Time time);

	bool allowWindowFocus (unsigned int noFocusMask,
			       Time         timestamp);

	void freeIcons ();

	void updateMwmHints ();

	void updateStartupId ();

	void processMap ();

	void updatePassiveButtonGrabs ();

	void setFullscreenMonitors (CompFullscreenMonitorSet *monitors);

	static unsigned int windowTypeFromString (const char *str);

	static int compareWindowActiveness (CompWindow *w1,
					    CompWindow *w2);

	void setOverrideRedirect (bool overrideRedirect);

	void readIconHint ();

	bool checkClear ();

	static CompWindow* createCompWindow (Window aboveId, Window aboveServerId, XWindowAttributes &wa, Window id);
    public:

	PrivateWindow *priv;

	CompWindow *window;

	int                  refcnt;
	Window               serverId;
	Window	             id;
	Window               serverFrame;
	Window	             frame;
	Window               wrapper;
	unsigned int         mapNum;
	unsigned int         activeNum;

	/* Don't use this for determining
	 * the window geometry because we
	 * read into this out of sync with
	 * ConfigureNotify events to determine
	 * the class and override redirect state
	 */
	XWindowAttributes    attrib;
	CompWindow::Geometry geometry;
	CompWindow::Geometry serverGeometry;
	CompWindow::Geometry frameGeometry;
	CompWindow::Geometry serverFrameGeometry;
	Window               transientFor;
	Window               clientLeader;
	XSizeHints	     sizeHints;
	XWMHints             *hints;

	bool       inputHint;
	bool       alpha;
	CompRegion region;
	CompRegion inputRegion;
	CompRegion frameRegion;

	unsigned int wmType;
	unsigned int type;
	unsigned int state;
	unsigned int actions;
	unsigned int protocols;
	unsigned int mwmDecor;
	unsigned int mwmFunc;
	bool         invisible;
	bool         destroyed;
	bool         managed;
	bool	     unmanaging;

	int destroyRefCnt;
	int unmapRefCnt;

	CompPoint initialViewport;

	Time initialTimestamp;
	bool initialTimestampSet;

	bool     fullscreenMonitorsSet;
	CompRect fullscreenMonitorRect;

	bool placed;
	bool minimized;
	bool inShowDesktopMode;
	bool shaded;
	bool hidden;
	bool grabbed;
	bool alreadyDecorated;

	unsigned int desktop;

	int pendingUnmaps;
	int pendingMaps;

	typedef std::pair <XWindowChanges, unsigned int> XWCValueMask;

	compiz::X11::PendingEventQueue pendingConfigures;
	bool receivedMapRequestAndAwaitingMap;

	char *startupId;
	char *resName;
	char *resClass;

	CompGroup *group;

	unsigned int lastPong;
	bool         alive;

	bool moved;

	CompWindowExtents input;
	CompWindowExtents serverInput;
	CompWindowExtents lastServerInput;
	CompWindowExtents border;
	CompWindowExtents output;
	CompWindowExtents clientFrame;

	CompStruts *struts;

	std::vector<CompIcon *> icons;
	bool noIcons;

	CompRect   iconGeometry;

	XWindowChanges saveWc;
	int		   saveMask;

	XSyncCounter  syncCounter;
	XSyncValue    syncValue;
	XSyncAlarm    syncAlarm;
	CompTimer     syncWaitTimer;

	bool                 syncWait;
	CompWindow::Geometry syncGeometry;

	int closeRequests;
	Time lastCloseRequestTime;

	bool nextMoveImmediate;

	X11SyncServerWindow                            syncServerWindow;
	compiz::window::configure_buffers::Buffer::Ptr configureBuffer;
};

#endif