summaryrefslogtreecommitdiff
path: root/include/compdisplay.h
blob: 7add2e5a3e6ba47142bd4a57eeac3dd1e384c886 (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
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
#ifndef _COMPDISPLAY_H
#define _COMPDISPLAY_H

#include <list>
#include "wrapable.h"

class CompDisplay;
class CompScreen;
class PrivateDisplay;

#define GET_CORE_DISPLAY(object) (dynamic_cast<CompDisplay *> (object))
#define CORE_DISPLAY(object) CompDisplay *d = GET_CORE_DISPLAY (object)

class DisplayInterface : public WrapableInterface<CompDisplay> {
    public:
	DisplayInterface ();

    WRAPABLE_DEF(void, handleEvent, XEvent *event);
    WRAPABLE_DEF(void, handleCompizEvent, const char *,
		 const char *, CompOption *, int nOption);

    WRAPABLE_DEF(bool, fileToImage, const char *, const char *,
		 int *, int *, int *, void **data);
    WRAPABLE_DEF(bool, imageToFile, const char *, const char *,
		 const char *, int, int, int, void *);

	
    WRAPABLE_DEF(void, matchInitExp, CompMatchExp *, const char *);
    WRAPABLE_DEF(void, matchExpHandlerChanged)
    WRAPABLE_DEF(void, matchPropertyChanged, CompWindow *)

    WRAPABLE_DEF(void, logMessage, const char *, CompLogLevel, const char*)
};

class CompDisplay : public WrapableHandler<DisplayInterface>, public CompObject {

    public:
	CompDisplay *next;

	class Atoms {
	    public:
		Atom supported;
		Atom supportingWmCheck;

		Atom utf8String;

		Atom wmName;

		Atom winType;
		Atom winTypeDesktop;
		Atom winTypeDock;
		Atom winTypeToolbar;
		Atom winTypeMenu;
		Atom winTypeUtil;
		Atom winTypeSplash;
		Atom winTypeDialog;
		Atom winTypeNormal;
		Atom winTypeDropdownMenu;
		Atom winTypePopupMenu;
		Atom winTypeTooltip;
		Atom winTypeNotification;
		Atom winTypeCombo;
		Atom winTypeDnd;

		Atom winOpacity;
		Atom winBrightness;
		Atom winSaturation;
		Atom winActive;
		Atom winDesktop;

		Atom workarea;

		Atom desktopViewport;
		Atom desktopGeometry;
		Atom currentDesktop;
		Atom numberOfDesktops;

		Atom winState;
		Atom winStateModal;
		Atom winStateSticky;
		Atom winStateMaximizedVert;
		Atom winStateMaximizedHorz;
		Atom winStateShaded;
		Atom winStateSkipTaskbar;
		Atom winStateSkipPager;
		Atom winStateHidden;
		Atom winStateFullscreen;
		Atom winStateAbove;
		Atom winStateBelow;
		Atom winStateDemandsAttention;
		Atom winStateDisplayModal;

		Atom winActionMove;
		Atom winActionResize;
		Atom winActionStick;
		Atom winActionMinimize;
		Atom winActionMaximizeHorz;
		Atom winActionMaximizeVert;
		Atom winActionFullscreen;
		Atom winActionClose;
		Atom winActionShade;
		Atom winActionChangeDesktop;
		Atom winActionAbove;
		Atom winActionBelow;

		Atom wmAllowedActions;

		Atom wmStrut;
		Atom wmStrutPartial;

		Atom wmUserTime;

		Atom wmIcon;
		Atom wmIconGeometry;

		Atom clientList;
		Atom clientListStacking;

		Atom frameExtents;
		Atom frameWindow;

		Atom wmState;
		Atom wmChangeState;
		Atom wmProtocols;
		Atom wmClientLeader;

		Atom wmDeleteWindow;
		Atom wmTakeFocus;
		Atom wmPing;
		Atom wmSyncRequest;

		Atom wmSyncRequestCounter;

		Atom closeWindow;
		Atom wmMoveResize;
		Atom moveResizeWindow;
		Atom restackWindow;

		Atom showingDesktop;

		Atom xBackground[2];

		Atom toolkitAction;
		Atom toolkitActionMainMenu;
		Atom toolkitActionRunDialog;
		Atom toolkitActionWindowMenu;
		Atom toolkitActionForceQuitDialog;

		Atom mwmHints;

		Atom xdndAware;
		Atom xdndEnter;
		Atom xdndLeave;
		Atom xdndPosition;
		Atom xdndStatus;
		Atom xdndDrop;

		Atom manager;
		Atom targets;
		Atom multiple;
		Atom timestamp;
		Atom version;
		Atom atomPair;

		Atom startupId;
	};
	
    public:
	// functions
	CompDisplay ();
	~CompDisplay ();

	CompString name ();

	bool
	init (const char *name);

	bool
	addScreen (int screenNum);

	void
	removeScreen (CompScreen *);

	Atoms
	atoms();
	
	Display *
	dpy();
	
	CompScreen *
	screens();

	GLenum
	textureFilter ();

	CompOption *
	getOption (const char *);

	bool
	setOption (const char      *name,
		   CompOptionValue *value);

	std::vector<XineramaScreenInfo> &
	screenInfo ();

	bool
	XRandr ();
	
	bool
	XShape ();

	SnDisplay *
	snDisplay ();

	Window
	below ();
	
	Window
	activeWindow ();
	
	Window
	autoRaiseWindow ();

	XModifierKeymap *
	modMap ();
	
	unsigned int
	ignoredModMask ();

	const char *
	displayString ();

	unsigned int
	lastPing ();

	CompWatchFdHandle
	getWatchFdHandle ();

	void
	setWatchFdHandle (CompWatchFdHandle);
	
	void
	processEvents ();

	void
	updateModifierMappings ();

	unsigned int
	virtualToRealModMask (unsigned int modMask);

	unsigned int
	keycodeToModifiers (int keycode);

	CompScreen *
	findScreen (Window root);

	void
	forEachWindow (ForEachWindowProc proc,
		       void	         *closure);

	CompWindow *
	findWindow (Window id);

	CompWindow *
	findTopLevelWindow (Window id);


	void
	clearTargetOutput (unsigned int mask);

	bool
	readImageFromFile (const char  *name,
			   int	       *width,
			   int	       *height,
			   void	       **data);

	bool
	writeImageToFile (const char  *path,
			  const char  *name,
			  const char  *format,
			  int	      width,
			  int	      height,
			  void	      *data);

	void
	updateScreenInfo ();

	Window
	getActiveWindow (Window root);

	int
	getWmState (Window id);

	void
	setWmState (int state, Window id);

	unsigned int
	windowStateMask (Atom state);


	static unsigned int
	windowStateFromString (const char *str);

	unsigned int
	getWindowState (Window id);

	void
	setWindowState (unsigned int state, Window id);

	unsigned int
	getWindowType (Window id);

	void
	getMwmHints (Window	  id,
		     unsigned int *func,
		     unsigned int *decor);


	unsigned int
	getProtocols (Window      id);


	unsigned int
	getWindowProp (Window	    id,
		       Atom	    property,
		       unsigned int defaultValue);


	void
	setWindowProp (Window       id,
		       Atom	    property,
		       unsigned int value);


	bool
	readWindowProp32 (Window	 id,
			  Atom		 property,
			  unsigned short *returnValue);


	unsigned short
	getWindowProp32 (Window		id,
			 Atom		property,
			 unsigned short defaultValue);


	void
	setWindowProp32 (Window         id,
			 Atom		property,
			 unsigned short value);

	void
	addScreenActions (CompScreen *s);

	static int allocPrivateIndex ();
	static void freePrivateIndex (int index);
	
	// wrapable interface
	WRAPABLE_HND(void, handleEvent, XEvent *event)
	WRAPABLE_HND(void, handleCompizEvent, const char *,
		     const char *, CompOption *, int nOption)

	WRAPABLE_HND(bool, fileToImage, const char *, const char *,
		     int *, int *, int *, void **data)
	WRAPABLE_HND(bool, imageToFile, const char *, const char *,
		     const char *, int, int, int, void *)

	
	WRAPABLE_HND(void, matchInitExp, CompMatchExp *, const char *);
	WRAPABLE_HND(void, matchExpHandlerChanged)
	WRAPABLE_HND(void, matchPropertyChanged, CompWindow *)

	WRAPABLE_HND(void, logMessage, const char *, CompLogLevel, const char*)

    public:
	Region mTmpRegion;
	Region mOutputRegion;

    private:

	PrivateDisplay *priv;

    public:

	static bool
	runCommandDispatch (CompDisplay     *d,
			    CompAction      *action,
			    CompActionState state,
			    CompOption      *option,
			    int		    nOption);

	static bool
	runCommandScreenshot (CompDisplay     *d,
			      CompAction      *action,
			      CompActionState state,
			      CompOption      *option,
			      int	      nOption);

	static bool
	runCommandWindowScreenshot (CompDisplay     *d,
				    CompAction      *action,
				    CompActionState state,
				    CompOption      *option,
				    int	            nOption);

	static bool
	runCommandTerminal (CompDisplay     *d,
			    CompAction      *action,
			    CompActionState state,
			    CompOption      *option,
			    int	            nOption);

	static CompOption *
	getDisplayOptions (CompObject  *object,
			   int	       *count);
};

extern Bool inHandleEvent;

extern CompScreen *targetScreen;
extern CompOutput *targetOutput;

#endif