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
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
|
#ifndef __XCB_EWMH_H__
#define __XCB_EWMH_H__
/*
* Copyright (C) 2009 Arnaud Fontaine <arnau@debian.org>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the names of the authors or
* their institutions shall not be used in advertising or otherwise to
* promote the sale, use or other dealings in this Software without
* prior written authorization from the authors.
*/
/**
* @defgroup xcb__ewmh_t XCB EWMH Functions
*
* These functions allow easy handling of the protocol described in
* the Extended Window Manager Hints specification. The list of Atoms
* is stored as an M4 file (atomlist.m4) where each Atom is stored as
* a variable defined in the header.
*
* Replies of requests generating a list of pointers (such as list of
* windows, atoms and UTF-8 strings) are simply stored as a structure
* holding the XCB reply which should (usually) never be accessed
* directly and has to be wipe afterwards. This structure provides a
* convenient access to the list given in the reply itself.
*
* \todo Add missing prototypes but asks for advices on XCB mailing
* list before.
*
* @{
*/
#include <xcb/xcb.h>
#ifdef __cplusplus
extern "C" {
#endif
/** All the Atoms XIDs */
define(`DO', `ifelse(`$1', , , `extern xcb_atom_t $1;
DO(shift($@))')')dnl
include(atomlist.m4)dnl
/**
* @brief Hold a GetProperty reply containing a list of Atoms
*/
typedef struct {
/** The number of Atoms */
uint32_t atoms_len;
/** The list of Atoms */
xcb_atom_t *atoms;
/** The actual GetProperty reply */
xcb_get_property_reply_t *_reply;
} xcb_ewmh_get_atoms_reply_t;
/**
* @brief Hold a GetProperty reply containing a list of Windows
*/
typedef struct {
/** The number of Windows */
uint32_t windows_len;
/** The list of Windows */
xcb_window_t *windows;
/** The actual GetProperty reply */
xcb_get_property_reply_t *_reply;
} xcb_ewmh_get_windows_reply_t;
/**
* @brief Hold a GetProperty reply containg a list of UTF-8 strings
*/
typedef struct {
/** The number of UTF-8 strings */
uint32_t strings_len;
/** The list of UTF-8 strings */
char *strings;
/** The actual GetProperty reply */
xcb_get_property_reply_t *_reply;
} xcb_ewmh_get_utf8_strings_reply_t;
/**
* @brief Property values as coordinates
*/
typedef struct {
/** The x coordinate */
uint32_t x;
/** The y coordinate */
uint32_t y;
} xcb_ewmh_coordinates_t;
/**
* @brief Hold reply of _NET_DESKTOP_VIEWPORT GetProperty
*/
typedef struct {
/** The number of desktop viewports */
uint32_t desktop_viewport_len;
/** The desktop viewports */
xcb_ewmh_coordinates_t *desktop_viewport;
/** The actual GetProperty reply */
xcb_get_property_reply_t *_reply;
} xcb_ewmh_get_desktop_viewport_reply_t;
/**
* @brief Property values as a geometry
*/
typedef struct {
/** The x coordinate */
uint32_t x;
/** The y coordinate */
uint32_t y;
/** The width */
uint32_t width;
/** The height */
uint32_t height;
} xcb_ewmh_geometry_t;
/**
* @brief Hold reply of a _NET_WORKAREA GetProperty
*/
typedef struct {
/** The number of desktop workarea */
uint32_t workarea_len;
/** The list of desktop workarea */
xcb_ewmh_geometry_t *workarea;
/** The actual GetProperty reply */
xcb_get_property_reply_t *_reply;
} xcb_ewmh_get_workarea_reply_t;
/**
* @brief Source indication in requests
*/
typedef enum {
/** No source at all (for clients supporting an older version of
EWMH specification) */
XCB_EWMH_CLIENT_SOURCE_TYPE_NONE = 0,
/** Normal application */
XCB_EWMH_CLIENT_SOURCE_TYPE_NORMAL = 1,
/** Pagers and other clients that represent direct user actions */
XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER = 2
} xcb_ewmh_client_source_type_t;
/**
* @brief _NET_DESKTOP_LAYOUT orientation
*/
typedef enum {
/** Horizontal orientation (desktops laid out in rows) */
XCB_EWMH_WM_ORIENTATION_HORZ = 0,
/** Vertical orientation (desktops laid out in columns) */
XCB_EWMH_WM_ORIENTATION_VERT = 1
} xcb_ewmh_desktop_layout_orientation_t;
/**
* @brief _NET_DESKTOP_LAYOUT starting corner
*/
typedef enum {
/** Starting corner on the top left */
XCB_EWMH_WM_TOPLEFT = 0,
/** Starting corner on the top right */
XCB_EWMH_WM_TOPRIGHT = 1,
/** Starting corner on the bottom right */
XCB_EWMH_WM_BOTTOMRIGHT = 2,
/** Starting corner on the bottom left */
XCB_EWMH_WM_BOTTOMLEFT = 3
} xcb_ewmh_desktop_layout_starting_corner_t;
/**
* @brief Hold reply of a _NET_DESKTOP_LAYOUT GetProperty
* @see xcb_ewmh_desktop_layout_orientation_t
* @see xcb_ewmh_desktop_layout_starting_corner_t
*/
typedef struct {
/** The desktops orientation */
uint32_t orientation;
/** The number of columns */
uint32_t columns;
/** The number of rows */
uint32_t rows;
/** The desktops starting corner */
uint32_t starting_corner;
} xcb_ewmh_get_desktop_layout_reply_t;
/**
* @brief _NET_WM_MOVERESIZE value when moving via keyboard
* @see xcb_ewmh_moveresize_direction_t
*/
typedef enum {
/** The window x coordinate */
XCB_EWMH_MOVERESIZE_WINDOW_X = (1 << 8),
/** The window y coordinate */
XCB_EWMH_MOVERESIZE_WINDOW_Y = (1 << 9),
/** The window width */
XCB_EWMH_MOVERESIZE_WINDOW_WIDTH = (1 << 10),
/** The window height */
XCB_EWMH_MOVERESIZE_WINDOW_HEIGHT = (1 << 11)
} xcb_ewmh_moveresize_window_opt_flags_t;
/**
* @brief _NET_WM_MOVERESIZE window movement or resizing
*/
typedef enum {
/** Resizing applied on the top left edge */
XCB_EWMH_WM_MOVERESIZE_SIZE_TOPLEFT = 0,
/** Resizing applied on the top edge */
XCB_EWMH_WM_MOVERESIZE_SIZE_TOP = 1,
/** Resizing applied on the top right edge */
XCB_EWMH_WM_MOVERESIZE_SIZE_TOPRIGHT = 2,
/** Resizing applied on the right edge */
XCB_EWMH_WM_MOVERESIZE_SIZE_RIGHT = 3,
/** Resizing applied on the bottom right edge */
XCB_EWMH_WM_MOVERESIZE_SIZE_BOTTOMRIGHT = 4,
/** Resizing applied on the bottom edge */
XCB_EWMH_WM_MOVERESIZE_SIZE_BOTTOM = 5,
/** Resizing applied on the bottom left edge */
XCB_EWMH_WM_MOVERESIZE_SIZE_BOTTOMLEFT = 6,
/** Resizing applied on the left edge */
XCB_EWMH_WM_MOVERESIZE_SIZE_LEFT = 7,
/* Movement only */
XCB_EWMH_WM_MOVERESIZE_MOVE = 8,
/* Size via keyboard */
XCB_EWMH_WM_MOVERESIZE_SIZE_KEYBOARD = 9,
/* Move via keyboard */
XCB_EWMH_WM_MOVERESIZE_MOVE_KEYBOARD = 10,
/* Cancel operation */
XCB_EWMH_WM_MOVERESIZE_CANCEL = 11
} xcb_ewmh_moveresize_direction_t;
/**
* @brief Action on the _NET_WM_STATE property
*/
typedef enum {
/* Remove/unset property */
XCB_EWMH_WM_STATE_REMOVE = 0,
/* Add/set property */
XCB_EWMH_WM_STATE_ADD = 1,
/* Toggle property */
XCB_EWMH_WM_STATE_TOGGLE = 2
} xcb_ewmh_wm_state_action_t;
/**
* @brief Hold reply of _NET_WM_STRUT_PARTIAL GetProperty
*/
typedef struct {
/** Reserved space on the left border of the screen */
uint32_t left;
/** Reserved space on the right border of the screen */
uint32_t right;
/** Reserved space on the top border of the screen */
uint32_t top;
/** Reserved space on the bottom border of the screen */
uint32_t bottom;
/** Beginning y coordinate of the left strut */
uint32_t left_start_y;
/** Ending y coordinate of the left strut */
uint32_t left_end_y;
/** Beginning y coordinate of the right strut */
uint32_t right_start_y;
/** Ending y coordinate of the right strut */
uint32_t right_end_y;
/** Beginning x coordinate of the top strut */
uint32_t top_start_x;
/** Ending x coordinate of the top strut */
uint32_t top_end_x;
/** Beginning x coordinate of the bottom strut */
uint32_t bottom_start_x;
/** Ending x coordinate of the bottom strut */
uint32_t bottom_end_x;
} xcb_ewmh_wm_strut_t;
/**
* @brief Hold reply of _NET_WM_ICON GetProperty
*/
typedef struct {
/** Icon width */
uint32_t width;
/** Icon height */
uint32_t height;
/** Rows, left to right and top to bottom of the CARDINAL ARGB */
uint32_t *data;
/** The actual GetProperty reply */
xcb_get_property_reply_t *_reply;
} xcb_ewmh_get_wm_icon_reply_t;
/**
* @brief Hold reply of _NET_REQUEST_FRAME_EXTENTS GetProperty
*/
typedef struct {
/** Width of the left border */
uint32_t left;
/** Width of the right border */
uint32_t right;
/** Width of the top border */
uint32_t top;
/** Width of the bottom border */
uint32_t bottom;
} xcb_ewmh_get_frame_extents_reply_t;
/**
* @brief Hold reply of _NET_WM_FULLSCREEN_MONITORS GetProperty
*/
typedef struct {
/** Monitor whose top edge defines the top edge of the fullscreen
window */
uint32_t top;
/** Monitor whose bottom edge defines the bottom edge of the
fullscreen window */
uint32_t bottom;
/** Monitor whose left edge defines the left edge of the fullscreen
window */
uint32_t left;
/** Monitor whose right edge defines the right edge of the
fullscreen window */
uint32_t right;
} xcb_ewmh_get_wm_fullscreen_monitors_reply_t;
/**
* @brief Send InternAtom requests for the EWMH atoms and its required atoms.
* @param c The connection to the X server.
* @param screen_nbr The screen number.
*/
void xcb_ewmh_init_atoms_list(xcb_connection_t *c,
const int screen_nbr);
/**
* @brief Process the replies previously sent
* @param c The connection to the X server.
* @param e Error if any.
* @return Return 1 on success, 0 otherwise.
*/
uint8_t xcb_ewmh_init_atoms_list_replies(xcb_connection_t *c,
xcb_generic_error_t **e);
/**
* @brief Wipe the Atoms list reply.
*
* This function must be called to free the memory allocated for atoms
* when the reply is requested in '_reply' functions.
*
* @param data The X reply to be freed.
*/
void xcb_ewmh_get_atoms_reply_wipe(xcb_ewmh_get_atoms_reply_t *data);
/**
* @brief Wipe the Windows list reply.
*
* This function must be called to the free the memory allocated for
* windows when the reply is requested in '_reply' functions.
*
* @param data The X reply to be freed.
*/
void xcb_ewmh_get_windows_reply_wipe(xcb_ewmh_get_windows_reply_t *data);
/**
* @brief Send GetProperty request to get _NET_SUPPORTED root window
* property
*
* _NET_SUPPORTED, ATOM[]/32
*
* This property MUST be set by the Window Manager to indicate which
* hints it supports. For example: considering _NET_WM_STATE both this
* atom and all supported states e.g. _NET_WM_STATE_MODAL,
* _NET_WM_STATE_STICKY, would be listed. This assumes that backwards
* incompatible changes will not be made to the hints (without being
* renamed).
*
* This form can be used only if the request will cause a reply to be
* generated. Any returned error will be placed in the event queue.
*
* @param c The connection to the X server.
* @return The _NET_SUPPORTED cookie of the GetProperty request.
*/
xcb_get_property_cookie_t xcb_ewmh_get_supported_unchecked(xcb_connection_t *c);
/**
* @brief Send GetProperty request to get _NET_SUPPORTED root window
* property
*
* @see xcb_ewmh_get_supported_unchecked
* @param c The connection to the X server.
* @return The _NET_SUPPORTED cookie of the GetProperty request.
*/
xcb_get_property_cookie_t xcb_ewmh_get_supported(xcb_connection_t *c);
/**
* @brief Get reply from the GetProperty _NET_SUPPORTED cookie
*
* The parameter e supplied to this function must be NULL if
* xcb_get_window_supported_unchecked() is used. Otherwise, it stores
* the error if any.
*
* @param c The connection to the X server.
* @param cookie The _NET_SUPPORTED GetProperty request cookie.
* @param supported The reply to be filled.
* @param The xcb_generic_error_t supplied.
* @return Return 1 on success, 0 otherwise.
*/
uint8_t xcb_ewmh_get_supported_reply(xcb_connection_t *c,
xcb_get_property_cookie_t cookie,
xcb_ewmh_get_atoms_reply_t *supported,
xcb_generic_error_t **e);
/**
* @brief Send GetProperty request to get _NET_CLIENT_LIST root window
* property
*
* This array contains all X Windows managed by the Window
* Manager. _NET_CLIENT_LIST has initial mapping order, starting with
* the oldest window. This property SHOULD be set and updated by the
* Window Manager.
*
* @param c The connection to the X server.
* @return The _NET_CLIENT_LIST cookie of the GetProperty request.
*/
xcb_get_property_cookie_t xcb_ewmh_get_client_list_unchecked(xcb_connection_t *c);
/**
* @brief Send GetProperty request to get _NET_CLIENT_LIST root window
* property
*
* @see xcb_ewmh_get_client_list_unchecked
* @param c The connection to the X server.
* @return The _NET_CLIENT_LIST cookie of the GetProperty request.
*/
xcb_get_property_cookie_t xcb_ewmh_get_client_list(xcb_connection_t *c);
/**
* @brief Get reply from the GetProperty _NET_CLIENT_LIST cookie
*
* The parameter e supplied to this function must be NULL if
* xcb_get_window_client_list_unchecked() is used. Otherwise, it
* stores the error if any.
*
* @param c The connection to the X server.
* @param cookie The _NET_CLIENT_LIST GetProperty request cookie.
* @param clients The list of clients to be filled.
* @param The xcb_generic_error_t supplied.
* @return Return 1 on success, 0 otherwise.
*/
uint8_t xcb_ewmh_get_client_list_reply(xcb_connection_t *c,
xcb_get_property_cookie_t cookie,
xcb_ewmh_get_windows_reply_t *clients,
xcb_generic_error_t **e);
/**
* @brief Send GetProperty request to get _NET_ACTIVE_WINDOW root
* window property
*
* The window ID of the currently active window or None if no window
* has the focus. This is a read-only property set by the Window
* Manager. This property SHOULD be set and updated by the Window
* Manager.
*
* This form can be used only if the request will cause a reply to be
* generated. Any returned error will be placed in the event queue.
*
* @param c The connection to the X server.
* @return The _NET_ACTIVE_WINDOW cookie of the GetProperty request.
*/
xcb_get_property_cookie_t xcb_ewmh_get_active_window_unchecked(xcb_connection_t *c);
/**
* @brief Send GetProperty request to get _NET_ACTIVE_WINDOW root
* window property
*
* @see xcb_ewmh_get_active_window_unchecked
* @param c The connection to the X server.
* @return The _NET_ACTIVE_WINDOW cookie of the GetProperty request.
*/
xcb_get_property_cookie_t xcb_ewmh_get_active_window(xcb_connection_t *c);
/**
* @brief Get reply from the GetProperty _NET_ACTIVE_WINDOW cookie
*
* The parameter e supplied to this function must be NULL if
* xcb_get_active_window_unchecked() is used. Otherwise, it stores
* the error if any.
*
* @param c The connection to the X server.
* @param cookie The _NET_ACTIVE_WINDOW GetProperty request cookie.
* @param active_window The reply to be filled.
* @param The xcb_generic_error_t supplied.
* @return Return 1 on success, 0 otherwise.
*/
uint8_t xcb_ewmh_get_active_window_reply(xcb_connection_t *c,
xcb_get_property_cookie_t cookie,
xcb_window_t *active_window,
xcb_generic_error_t **e);
/**
* @brief Send ClientMessage requesting to change the _NET_ACTIVE_WINDOW
*
* The window ID of the currently active window or None if no window
* has the focus. This is a read-only property set by the Window
* Manager. If a Client wants to activate another window, it MUST send
* a _NET_ACTIVE_WINDOW client message to the root window. The
* timestamp is Client's last user activity timestamp at the time of
* the request, and the currently active window is the Client's active
* toplevel window, if any (the Window Manager may be e.g. more likely
* to obey the request if it will mean transferring focus from one
* active window to another).
*
* @see xcb_ewmh_client_source_type_t
* @param c The connection to the X server.
* @param window_to_active The window ID to activate.
* @param source_indication The source indication.
* @param timestamp The client's last user activity timestamp.
* @param current_active_window The currently active window or None
*/
void xcb_ewmh_request_change_active_window(xcb_connection_t *c,
xcb_window_t window_to_activate,
xcb_ewmh_client_source_type_t source_indication,
xcb_timestamp_t timestamp,
xcb_window_t current_active_window);
/**
* @brief Send GetSelectOwner request to get the owner of
* _NET_WM_CM_Sn root window property
*
* @param c The connection to the X server.
* @return The _NET_WM_CM_Sn cookie of the GetSelectionOwner request.
*/
xcb_get_selection_owner_cookie_t xcb_ewmh_get_wm_cm_owner_unchecked(xcb_connection_t *c);
/**
* @brief Send GetSelectOwner request to get the owner of
* _NET_WM_CM_Sn root window property
*
* @see xcb_ewmh_get_wm_cm_owner_unchecked
* @param c The connection to the X server.
* @return The _NET_WM_CM_Sn cookie of the GetSelectionOwner request.
*/
xcb_get_selection_owner_cookie_t xcb_ewmh_get_wm_cm_owner(xcb_connection_t *c);
/**
* @brief Get reply from the GetProperty _NET_CLIENT_LIST cookie
*
* The parameter e supplied to this function must be NULL if
* xcb_get_window_client_list_unchecked() is used. Otherwise, it
* stores the error if any.
*
* @param c The connection to the X server.
* @param cookie The _NET_WM_CM_Sn GetSelectionOwner request cookie.
* @param owner The window ID which owns the selection or None.
* @param The xcb_generic_error_t supplied.
* @return Return 1 on success, 0 otherwise.
*/
uint8_t xcb_ewmh_get_wm_cm_owner_reply(xcb_connection_t *c,
xcb_get_selection_owner_cookie_t cookie,
xcb_window_t *owner,
xcb_generic_error_t **e);
/**
* @brief Set _NET_WM_CM_Sn ownership to the given window
*
* For each screen they manage, compositing manager MUST acquire
* ownership of a selection named _NET_WM_CM_Sn, where n is the screen
* number.
*
* @param c The connection to the X server.
* @param owner The new owner of _NET_WM_CM_Sn selection.
* @param timestamp The client's last user activity timestamp.
* @param selection_data1 Optional data described by ICCCM
* @param selection_data2 Optional data described by ICCCM
*/
void xcb_ewmh_set_wm_cm_owner(xcb_connection_t *c,
xcb_window_t owner,
xcb_timestamp_t timestamp,
uint32_t selection_data1,
uint32_t selection_data2);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* __XCB_EWMH_H__ */
|