aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_netwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_netwm.c')
-rw-r--r--libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_netwm.c1575
1 files changed, 0 insertions, 1575 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_netwm.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_netwm.c
deleted file mode 100644
index b1e0622..0000000
--- a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_netwm.c
+++ /dev/null
@@ -1,1575 +0,0 @@
1#include "ecore_xcb_private.h"
2
3/* local function prototypes */
4/* static void _ecore_xcb_netwm_startup_info_free(void *data); */
5static Ecore_X_Atom _ecore_xcb_netwm_window_type_atom_get(Ecore_X_Window_Type type);
6static Ecore_X_Window_Type _ecore_xcb_netwm_window_type_type_get(Ecore_X_Atom atom);
7static Ecore_X_Atom _ecore_xcb_netwm_window_state_atom_get(Ecore_X_Window_State state);
8static Ecore_X_Atom _ecore_xcb_netwm_action_atom_get(Ecore_X_Action action);
9
10/* local variables */
11//static Eina_Hash *_startup_info = NULL;
12
13/* local structures */
14typedef struct _Ecore_Xcb_Startup_Info Ecore_Xcb_Startup_Info;
15struct _Ecore_Xcb_Startup_Info
16{
17 Ecore_X_Window win;
18 int init, size;
19 char *buffer;
20 int length;
21
22 /* sequence info fields */
23 char *id, *name;
24 int screen;
25 char *bin, *icon;
26 int desktop, timestamp;
27 char *description, *wmclass;
28 int silent;
29};
30
31EAPI void
32ecore_x_netwm_init(void)
33{
34 LOGFN(__FILE__, __LINE__, __FUNCTION__);
35
36// _startup_info =
37// eina_hash_string_superfast_new(_ecore_xcb_netwm_startup_info_free);
38}
39
40EAPI void
41ecore_x_netwm_shutdown(void)
42{
43 LOGFN(__FILE__, __LINE__, __FUNCTION__);
44
45// if (_startup_info) eina_hash_free(_startup_info);
46// _startup_info = NULL;
47}
48
49EAPI Eina_Bool
50ecore_x_netwm_pid_get(Ecore_X_Window win,
51 int *pid)
52{
53 uint32_t tmp;
54
55 LOGFN(__FILE__, __LINE__, __FUNCTION__);
56
57 if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_PID, &tmp, 1))
58 return EINA_FALSE;
59
60 if (pid) *pid = tmp;
61
62 return EINA_TRUE;
63}
64
65EAPI void
66ecore_x_netwm_pid_set(Ecore_X_Window win,
67 int pid)
68{
69 unsigned int tmp;
70
71 LOGFN(__FILE__, __LINE__, __FUNCTION__);
72
73 tmp = pid;
74 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_PID, &tmp, 1);
75}
76
77EAPI Eina_Bool
78ecore_x_netwm_window_type_get(Ecore_X_Window win,
79 Ecore_X_Window_Type *type)
80{
81 Ecore_X_Atom *atoms;
82 int num = 0;
83
84 LOGFN(__FILE__, __LINE__, __FUNCTION__);
85
86 if (type) *type = ECORE_X_WINDOW_TYPE_NORMAL;
87
88 num =
89 ecore_x_window_prop_atom_list_get(win,
90 ECORE_X_ATOM_NET_WM_WINDOW_TYPE, &atoms);
91 if ((type) && (num >= 1) && (atoms))
92 *type = _ecore_xcb_netwm_window_type_type_get(atoms[0]);
93
94 if (atoms) free(atoms);
95
96 if (num >= 1) return EINA_TRUE;
97 return EINA_FALSE;
98}
99
100EAPI void
101ecore_x_netwm_window_type_set(Ecore_X_Window win,
102 Ecore_X_Window_Type type)
103{
104 Ecore_X_Atom atom;
105
106 LOGFN(__FILE__, __LINE__, __FUNCTION__);
107
108 atom = _ecore_xcb_netwm_window_type_atom_get(type);
109 ecore_x_window_prop_atom_set(win, ECORE_X_ATOM_NET_WM_WINDOW_TYPE, &atom, 1);
110}
111
112EAPI int
113ecore_x_netwm_window_types_get(Ecore_X_Window win,
114 Ecore_X_Window_Type **types)
115{
116 int num = 0, i = 0;
117 Ecore_X_Atom *atoms = NULL;
118 Ecore_X_Window_Type *atoms2 = NULL;
119
120 LOGFN(__FILE__, __LINE__, __FUNCTION__);
121
122 if (types) *types = NULL;
123 num =
124 ecore_x_window_prop_atom_list_get(win, ECORE_X_ATOM_NET_WM_WINDOW_TYPE,
125 &atoms);
126 if ((num <= 0) || (!atoms))
127 {
128 if (atoms) free(atoms);
129 return 0;
130 }
131
132 atoms2 = malloc(num * sizeof(Ecore_X_Window_Type));
133 if (!atoms2)
134 {
135 if (atoms) free(atoms);
136 return 0;
137 }
138
139 for (i = 0; i < num; i++)
140 atoms2[i] = _ecore_xcb_netwm_window_type_type_get(atoms[i]);
141 if (atoms) free(atoms);
142
143 if (types)
144 *types = atoms2;
145 else
146 free(atoms2);
147
148 return num;
149}
150
151EAPI int
152ecore_x_netwm_name_get(Ecore_X_Window win,
153 char **name)
154{
155 LOGFN(__FILE__, __LINE__, __FUNCTION__);
156
157 if (name)
158 *name = ecore_x_window_prop_string_get(win, ECORE_X_ATOM_NET_WM_NAME);
159 return 1;
160}
161
162EAPI void
163ecore_x_netwm_name_set(Ecore_X_Window win,
164 const char *name)
165{
166 LOGFN(__FILE__, __LINE__, __FUNCTION__);
167
168 ecore_x_window_prop_string_set(win, ECORE_X_ATOM_NET_WM_NAME, name);
169}
170
171EAPI void
172ecore_x_netwm_opacity_set(Ecore_X_Window win,
173 unsigned int opacity)
174{
175 LOGFN(__FILE__, __LINE__, __FUNCTION__);
176
177 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_WINDOW_OPACITY,
178 &opacity, 1);
179}
180
181EAPI Eina_Bool
182ecore_x_netwm_opacity_get(Ecore_X_Window win,
183 unsigned int *opacity)
184{
185 unsigned int tmp = 0;
186
187 LOGFN(__FILE__, __LINE__, __FUNCTION__);
188
189 if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_WINDOW_OPACITY,
190 &tmp, 1))
191 return EINA_FALSE;
192
193 if (opacity) *opacity = tmp;
194
195 return EINA_TRUE;
196}
197
198EAPI void
199ecore_x_netwm_wm_identify(Ecore_X_Window root,
200 Ecore_X_Window check,
201 const char *wm_name)
202{
203 LOGFN(__FILE__, __LINE__, __FUNCTION__);
204
205 ecore_x_window_prop_window_set(root, ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK,
206 &check, 1);
207 ecore_x_window_prop_window_set(check, ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK,
208 &check, 1);
209 ecore_x_window_prop_string_set(check, ECORE_X_ATOM_NET_WM_NAME, wm_name);
210 ecore_x_window_prop_string_set(root, ECORE_X_ATOM_NET_WM_NAME, wm_name);
211}
212
213EAPI void
214ecore_x_netwm_supported_set(Ecore_X_Window root,
215 Ecore_X_Atom *supported,
216 int num)
217{
218 LOGFN(__FILE__, __LINE__, __FUNCTION__);
219
220 ecore_x_window_prop_atom_set(root, ECORE_X_ATOM_NET_SUPPORTED,
221 supported, num);
222}
223
224EAPI Eina_Bool
225ecore_x_netwm_supported_get(Ecore_X_Window root,
226 Ecore_X_Atom **supported,
227 int *num)
228{
229 int num_ret = 0;
230
231 LOGFN(__FILE__, __LINE__, __FUNCTION__);
232
233 if (num) *num = 0;
234 if (supported) *supported = NULL;
235
236 num_ret =
237 ecore_x_window_prop_atom_list_get(root, ECORE_X_ATOM_NET_SUPPORTED,
238 supported);
239 if (num_ret <= 0) return EINA_FALSE;
240 if (num) *num = num_ret;
241
242 return EINA_TRUE;
243}
244
245EAPI void
246ecore_x_netwm_desk_count_set(Ecore_X_Window root,
247 unsigned int n_desks)
248{
249 LOGFN(__FILE__, __LINE__, __FUNCTION__);
250
251 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_NUMBER_OF_DESKTOPS,
252 &n_desks, 1);
253}
254
255EAPI void
256ecore_x_netwm_desk_roots_set(Ecore_X_Window root,
257 Ecore_X_Window *vroots,
258 unsigned int n_desks)
259{
260 LOGFN(__FILE__, __LINE__, __FUNCTION__);
261
262 ecore_x_window_prop_window_set(root, ECORE_X_ATOM_NET_VIRTUAL_ROOTS,
263 vroots, n_desks);
264}
265
266EAPI void
267ecore_x_netwm_desk_names_set(Ecore_X_Window root,
268 const char **names,
269 unsigned int n_desks)
270{
271 char ss[32], *buf = NULL, *t = NULL;
272 const char *s;
273 uint32_t len = 0, i, l;
274
275 LOGFN(__FILE__, __LINE__, __FUNCTION__);
276 CHECK_XCB_CONN;
277
278 for (i = 0; i < n_desks; i++)
279 {
280 s = ((names) ? names[i] : NULL);
281 if (!s)
282 {
283 /* Default to "Desk-<number>" */
284 sprintf(ss, "Desk-%d", i);
285 s = ss;
286 }
287
288 l = strlen(s) + 1;
289 t = realloc(buf, len + 1);
290 if (t)
291 {
292 buf = t;
293 memcpy(buf + len, s, l);
294 }
295 len += l;
296 }
297
298 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, root,
299 ECORE_X_ATOM_NET_DESKTOP_NAMES,
300 ECORE_X_ATOM_UTF8_STRING, 8, len, (const void *)buf);
301// ecore_x_flush();
302 free(buf);
303}
304
305EAPI void
306ecore_x_netwm_desk_size_set(Ecore_X_Window root,
307 unsigned int width,
308 unsigned int height)
309{
310 uint32_t size[2];
311
312 LOGFN(__FILE__, __LINE__, __FUNCTION__);
313
314 size[0] = width;
315 size[1] = height;
316 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_DESKTOP_GEOMETRY,
317 size, 2);
318}
319
320EAPI void
321ecore_x_netwm_desk_viewports_set(Ecore_X_Window root,
322 unsigned int *origins,
323 unsigned int n_desks)
324{
325 LOGFN(__FILE__, __LINE__, __FUNCTION__);
326
327 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_DESKTOP_VIEWPORT,
328 origins, (2 * n_desks));
329}
330
331EAPI void
332ecore_x_netwm_desk_layout_set(Ecore_X_Window root,
333 int orientation,
334 int columns,
335 int rows,
336 int starting_corner)
337{
338 unsigned int layout[4];
339
340 LOGFN(__FILE__, __LINE__, __FUNCTION__);
341
342 layout[0] = orientation;
343 layout[1] = columns;
344 layout[2] = rows;
345 layout[3] = starting_corner;
346 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_DESKTOP_LAYOUT,
347 layout, 4);
348}
349
350EAPI void
351ecore_x_netwm_desk_workareas_set(Ecore_X_Window root,
352 unsigned int *areas,
353 unsigned int n_desks)
354{
355 LOGFN(__FILE__, __LINE__, __FUNCTION__);
356
357 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_WORKAREA, areas,
358 4 * n_desks);
359}
360
361EAPI unsigned int *
362ecore_x_netwm_desk_workareas_get(Ecore_X_Window root, unsigned int *n_desks)
363{
364 int ret;
365 unsigned int *areas = NULL;
366
367 if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
368
369 ret = ecore_x_window_prop_card32_list_get(root, ECORE_X_ATOM_NET_WORKAREA,
370 &areas);
371 if (!areas)
372 {
373 if (n_desks) *n_desks = 0;
374 return 0;
375 }
376 if (n_desks) *n_desks = ret / 4;
377 return areas;
378}
379
380EAPI void
381ecore_x_netwm_desk_current_set(Ecore_X_Window root,
382 unsigned int desk)
383{
384 LOGFN(__FILE__, __LINE__, __FUNCTION__);
385
386 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_CURRENT_DESKTOP,
387 &desk, 1);
388}
389
390EAPI void
391ecore_x_netwm_showing_desktop_set(Ecore_X_Window root,
392 Eina_Bool on)
393{
394 unsigned int val = 0;
395
396 LOGFN(__FILE__, __LINE__, __FUNCTION__);
397
398 val = ((on) ? 1 : 0);
399 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_SHOWING_DESKTOP,
400 &val, 1);
401}
402
403EAPI int
404ecore_x_netwm_startup_id_get(Ecore_X_Window win,
405 char **id)
406{
407 LOGFN(__FILE__, __LINE__, __FUNCTION__);
408
409 if (id)
410 {
411 *id =
412 ecore_x_window_prop_string_get(win, ECORE_X_ATOM_NET_STARTUP_ID);
413 }
414
415 return 1;
416}
417
418EAPI void
419ecore_x_netwm_startup_id_set(Ecore_X_Window win,
420 const char *id)
421{
422 LOGFN(__FILE__, __LINE__, __FUNCTION__);
423
424 ecore_x_window_prop_string_set(win, ECORE_X_ATOM_NET_STARTUP_ID, id);
425}
426
427EAPI void
428ecore_x_netwm_state_request_send(Ecore_X_Window win,
429 Ecore_X_Window root,
430 Ecore_X_Window_State s1,
431 Ecore_X_Window_State s2,
432 Eina_Bool set)
433{
434 xcb_client_message_event_t ev;
435
436 LOGFN(__FILE__, __LINE__, __FUNCTION__);
437 CHECK_XCB_CONN;
438
439 if (!win) return;
440 if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
441
442 ev.response_type = XCB_CLIENT_MESSAGE;
443 ev.format = 32;
444 ev.window = win;
445 ev.type = ECORE_X_ATOM_NET_WM_STATE;
446 ev.data.data32[0] = !!set;
447 ev.data.data32[1] = _ecore_xcb_netwm_window_state_atom_get(s1);
448 ev.data.data32[2] = _ecore_xcb_netwm_window_state_atom_get(s2);
449 /* 1 == normal client, if used in a pager this should be 2 */
450 ev.data.data32[3] = 1;
451 ev.data.data32[4] = 0;
452
453 xcb_send_event(_ecore_xcb_conn, 0, root,
454 (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
455 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY), (const char *)&ev);
456// ecore_x_flush();
457}
458
459EAPI void
460ecore_x_netwm_window_state_set(Ecore_X_Window win,
461 Ecore_X_Window_State *state,
462 unsigned int num)
463{
464 Ecore_X_Atom *set;
465 unsigned int i = 0;
466
467 LOGFN(__FILE__, __LINE__, __FUNCTION__);
468
469 if (!num)
470 {
471 ecore_x_window_prop_property_del(win, ECORE_X_ATOM_NET_WM_STATE);
472 return;
473 }
474
475 set = malloc(num * sizeof(Ecore_X_Atom));
476 if (!set) return;
477
478 for (i = 0; i < num; i++)
479 set[i] = _ecore_xcb_netwm_window_state_atom_get(state[i]);
480
481 ecore_x_window_prop_atom_set(win, ECORE_X_ATOM_NET_WM_STATE, set, num);
482 free(set);
483}
484
485EAPI Eina_Bool
486ecore_x_netwm_window_state_get(Ecore_X_Window win,
487 Ecore_X_Window_State **state,
488 unsigned int *num)
489{
490 Ecore_X_Atom *atoms;
491 int ret = 0;
492
493 LOGFN(__FILE__, __LINE__, __FUNCTION__);
494
495 if (num) *num = 0;
496 if (state) *state = NULL;
497
498 ret =
499 ecore_x_window_prop_atom_list_get(win, ECORE_X_ATOM_NET_WM_STATE, &atoms);
500
501 if (ret <= 0) return EINA_FALSE;
502
503 if (state)
504 {
505 *state = malloc(ret * sizeof(Ecore_X_Window_State));
506 if (*state)
507 {
508 int i = 0;
509
510 for (i = 0; i < ret; i++)
511 (*state)[i] = _ecore_xcb_netwm_window_state_get(atoms[i]);
512 if (num) *num = ret;
513 }
514 }
515
516 free(atoms);
517
518 return EINA_TRUE;
519}
520
521EAPI void
522ecore_x_netwm_client_active_set(Ecore_X_Window root,
523 Ecore_X_Window win)
524{
525 LOGFN(__FILE__, __LINE__, __FUNCTION__);
526
527 ecore_x_window_prop_window_set(root,
528 ECORE_X_ATOM_NET_ACTIVE_WINDOW, &win, 1);
529}
530
531EAPI void
532ecore_x_netwm_client_active_request(Ecore_X_Window root,
533 Ecore_X_Window win,
534 int type,
535 Ecore_X_Window current_win)
536{
537 xcb_client_message_event_t ev;
538
539 LOGFN(__FILE__, __LINE__, __FUNCTION__);
540 CHECK_XCB_CONN;
541
542 if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
543
544 ev.response_type = XCB_CLIENT_MESSAGE;
545 ev.format = 32;
546 ev.window = win;
547 ev.type = ECORE_X_ATOM_NET_ACTIVE_WINDOW;
548 ev.data.data32[0] = type;
549 ev.data.data32[1] = XCB_CURRENT_TIME;
550 ev.data.data32[2] = current_win;
551 ev.data.data32[3] = 0;
552 ev.data.data32[4] = 0;
553
554 xcb_send_event(_ecore_xcb_conn, 0, root,
555 (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
556 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY), (const char *)&ev);
557// ecore_x_flush();
558}
559
560EAPI void
561ecore_x_netwm_client_list_set(Ecore_X_Window root,
562 Ecore_X_Window *p_clients,
563 unsigned int n_clients)
564{
565 LOGFN(__FILE__, __LINE__, __FUNCTION__);
566
567 ecore_x_window_prop_window_set(root, ECORE_X_ATOM_NET_CLIENT_LIST,
568 p_clients, n_clients);
569}
570
571EAPI void
572ecore_x_netwm_client_list_stacking_set(Ecore_X_Window root,
573 Ecore_X_Window *p_clients,
574 unsigned int n_clients)
575{
576 LOGFN(__FILE__, __LINE__, __FUNCTION__);
577
578 ecore_x_window_prop_window_set(root, ECORE_X_ATOM_NET_CLIENT_LIST_STACKING,
579 p_clients, n_clients);
580}
581
582EAPI Eina_Bool
583ecore_x_screen_is_composited(int screen)
584{
585 char buff[32];
586 xcb_get_selection_owner_cookie_t ocookie;
587 xcb_get_selection_owner_reply_t *oreply;
588 Ecore_X_Window win;
589 static Ecore_X_Atom atom = XCB_NONE;
590
591 LOGFN(__FILE__, __LINE__, __FUNCTION__);
592 CHECK_XCB_CONN;
593
594 snprintf(buff, sizeof(buff), "_NET_WM_CM_S%i", screen);
595
596 if (atom == XCB_NONE)
597 {
598 xcb_intern_atom_cookie_t acookie;
599 xcb_intern_atom_reply_t *areply;
600
601 acookie =
602 xcb_intern_atom_unchecked(_ecore_xcb_conn, 0, strlen(buff), buff);
603 areply = xcb_intern_atom_reply(_ecore_xcb_conn, acookie, NULL);
604 if (!areply) return EINA_FALSE;
605 atom = areply->atom;
606 free(areply);
607 }
608 if (atom == XCB_NONE) return EINA_FALSE;
609
610 ocookie = xcb_get_selection_owner_unchecked(_ecore_xcb_conn, atom);
611 oreply = xcb_get_selection_owner_reply(_ecore_xcb_conn, ocookie, NULL);
612 if (!oreply) return EINA_FALSE;
613 win = oreply->owner;
614 free(oreply);
615
616 return (win != XCB_NONE) ? EINA_TRUE : EINA_FALSE;
617}
618
619EAPI void
620ecore_x_screen_is_composited_set(int screen,
621 Ecore_X_Window win)
622{
623 static Ecore_X_Atom atom = XCB_NONE;
624 char buff[32];
625
626 LOGFN(__FILE__, __LINE__, __FUNCTION__);
627 CHECK_XCB_CONN;
628
629 snprintf(buff, sizeof(buff), "_NET_WM_CM_S%i", screen);
630 if (atom == XCB_NONE)
631 {
632 xcb_intern_atom_cookie_t acookie;
633 xcb_intern_atom_reply_t *areply;
634
635 acookie =
636 xcb_intern_atom_unchecked(_ecore_xcb_conn, 0, strlen(buff), buff);
637 areply = xcb_intern_atom_reply(_ecore_xcb_conn, acookie, NULL);
638 if (!areply) return;
639 atom = areply->atom;
640 free(areply);
641 }
642 if (atom == XCB_NONE) return;
643 xcb_set_selection_owner(_ecore_xcb_conn, win, atom,
644 _ecore_xcb_events_last_time_get());
645}
646
647EAPI void
648ecore_x_netwm_ping_send(Ecore_X_Window win)
649{
650 xcb_client_message_event_t ev;
651
652 LOGFN(__FILE__, __LINE__, __FUNCTION__);
653 CHECK_XCB_CONN;
654
655 if (!win) return;
656
657 ev.response_type = XCB_CLIENT_MESSAGE;
658 ev.format = 32;
659 ev.window = win;
660 ev.type = ECORE_X_ATOM_WM_PROTOCOLS;
661 ev.data.data32[0] = ECORE_X_ATOM_NET_WM_PING;
662 ev.data.data32[1] = ecore_x_current_time_get();
663 ev.data.data32[2] = win;
664 ev.data.data32[3] = 0;
665 ev.data.data32[4] = 0;
666
667 xcb_send_event(_ecore_xcb_conn, 0, win,
668 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
669// ecore_x_flush();
670}
671
672EAPI void
673ecore_x_netwm_frame_size_set(Ecore_X_Window win,
674 int fl,
675 int fr,
676 int ft,
677 int fb)
678{
679 uint32_t frames[4];
680
681 LOGFN(__FILE__, __LINE__, __FUNCTION__);
682
683 frames[0] = fl;
684 frames[1] = fr;
685 frames[2] = ft;
686 frames[3] = fb;
687 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_FRAME_EXTENTS,
688 frames, 4);
689}
690
691EAPI Eina_Bool
692ecore_x_netwm_frame_size_get(Ecore_X_Window win,
693 int *fl,
694 int *fr,
695 int *ft,
696 int *fb)
697{
698 int ret = 0;
699 unsigned int frames[4];
700
701 LOGFN(__FILE__, __LINE__, __FUNCTION__);
702
703 ret = ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_FRAME_EXTENTS,
704 frames, 4);
705 if (ret != 4) return EINA_FALSE;
706
707 if (fl) *fl = frames[0];
708 if (fr) *fr = frames[1];
709 if (ft) *ft = frames[2];
710 if (fb) *fb = frames[3];
711
712 return EINA_TRUE;
713}
714
715EAPI void
716ecore_x_netwm_sync_request_send(Ecore_X_Window win,
717 unsigned int serial)
718{
719 xcb_client_message_event_t ev;
720
721 LOGFN(__FILE__, __LINE__, __FUNCTION__);
722 CHECK_XCB_CONN;
723
724 if (!win) return;
725
726 /* FIXME: Maybe need XSyncIntToValue ?? */
727 memset(&ev, 0, sizeof(xcb_client_message_event_t));
728
729 ev.response_type = XCB_CLIENT_MESSAGE;
730 ev.format = 32;
731 ev.window = win;
732 ev.type = ECORE_X_ATOM_WM_PROTOCOLS;
733 ev.data.data32[0] = ECORE_X_ATOM_NET_WM_SYNC_REQUEST;
734 ev.data.data32[1] = _ecore_xcb_events_last_time_get();
735 ev.data.data32[2] = serial;
736 ev.data.data32[3] = 0;
737 ev.data.data32[4] = 0;
738
739 xcb_send_event(_ecore_xcb_conn, 0, win,
740 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
741// ecore_x_flush();
742}
743
744EAPI void
745ecore_x_netwm_desktop_set(Ecore_X_Window win,
746 unsigned int desk)
747{
748 LOGFN(__FILE__, __LINE__, __FUNCTION__);
749
750 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_DESKTOP, &desk, 1);
751}
752
753EAPI Eina_Bool
754ecore_x_netwm_desktop_get(Ecore_X_Window win,
755 unsigned int *desk)
756{
757 unsigned int tmp = 0;
758
759 LOGFN(__FILE__, __LINE__, __FUNCTION__);
760
761 if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_DESKTOP,
762 &tmp, 1))
763 return EINA_FALSE;
764
765 if (desk) *desk = tmp;
766
767 return EINA_TRUE;
768}
769
770EAPI void
771ecore_x_netwm_desktop_request_send(Ecore_X_Window win,
772 Ecore_X_Window root,
773 unsigned int desktop)
774{
775 xcb_client_message_event_t ev;
776
777 LOGFN(__FILE__, __LINE__, __FUNCTION__);
778 CHECK_XCB_CONN;
779
780 if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
781
782 memset(&ev, 0, sizeof(xcb_client_message_event_t));
783
784 ev.response_type = XCB_CLIENT_MESSAGE;
785 ev.format = 32;
786 ev.window = win;
787 ev.type = ECORE_X_ATOM_NET_WM_DESKTOP;
788 ev.data.data32[0] = desktop;
789
790 xcb_send_event(_ecore_xcb_conn, 0, root,
791 (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
792 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY), (const char *)&ev);
793// ecore_x_flush();
794}
795
796EAPI void
797ecore_x_netwm_handled_icons_set(Ecore_X_Window win)
798{
799 LOGFN(__FILE__, __LINE__, __FUNCTION__);
800
801 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_HANDLED_ICONS,
802 NULL, 0);
803}
804
805EAPI Eina_Bool
806ecore_x_netwm_handled_icons_get(Ecore_X_Window win)
807{
808 LOGFN(__FILE__, __LINE__, __FUNCTION__);
809
810 if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_HANDLED_ICONS,
811 NULL, 0))
812 return EINA_FALSE;
813
814 return EINA_TRUE;
815}
816
817EAPI int
818ecore_x_netwm_icon_name_get(Ecore_X_Window win,
819 char **name)
820{
821 LOGFN(__FILE__, __LINE__, __FUNCTION__);
822
823 if (name)
824 {
825 *name =
826 ecore_x_window_prop_string_get(win, ECORE_X_ATOM_NET_WM_ICON_NAME);
827 }
828
829 return 1;
830}
831
832EAPI void
833ecore_x_netwm_icon_name_set(Ecore_X_Window win,
834 const char *name)
835{
836 LOGFN(__FILE__, __LINE__, __FUNCTION__);
837
838 ecore_x_window_prop_string_set(win, ECORE_X_ATOM_NET_WM_ICON_NAME, name);
839}
840
841EAPI void
842ecore_x_netwm_icons_set(Ecore_X_Window win,
843 Ecore_X_Icon *icon,
844 int num)
845{
846 unsigned int *data, *p, *p2;
847 unsigned int i, size, x, y;
848
849 LOGFN(__FILE__, __LINE__, __FUNCTION__);
850 size = 0;
851 for (i = 0; i < (unsigned int)num; i++)
852 {
853 size += 2 + (icon[i].width * icon[i].height);
854 }
855 data = malloc(size * sizeof(unsigned int));
856 if (!data) return;
857 p = data;
858 for (i = 0; i < (unsigned int)num; i++)
859 {
860 p[0] = icon[i].width;
861 p[1] = icon[i].height;
862 p += 2;
863 p2 = icon[i].data;
864 for (y = 0; y < icon[i].height; y++)
865 {
866 for (x = 0; x < icon[i].width; x++)
867 {
868 unsigned int r, g, b, a;
869
870 a = (*p2 >> 24) & 0xff;
871 r = (*p2 >> 16) & 0xff;
872 g = (*p2 >> 8 ) & 0xff;
873 b = (*p2 ) & 0xff;
874 if ((a > 0) && (a < 255))
875 {
876 r = (r * 255) / a;
877 g = (g * 255) / a;
878 b = (b * 255) / a;
879 }
880 *p = (a << 24) | (r << 16) | (g << 8) | b;
881 p++;
882 p2++;
883 }
884 }
885 }
886 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_ICON,
887 data, size);
888 free(data);
889}
890
891EAPI Eina_Bool
892ecore_x_netwm_icons_get(Ecore_X_Window win,
893 Ecore_X_Icon **icon,
894 int *num)
895{
896 int num_ret = 0;
897 unsigned int i = 0, len = 0, icons = 0;
898 unsigned int *data, *p, *src;
899
900 LOGFN(__FILE__, __LINE__, __FUNCTION__);
901
902 if (num) *num = 0;
903 if (icon) *icon = NULL;
904
905 num_ret =
906 ecore_x_window_prop_card32_list_get(win, ECORE_X_ATOM_NET_WM_ICON, &data);
907
908 if ((num_ret <= 0) || (!data))
909 {
910 if (data) free(data);
911 return EINA_FALSE;
912 }
913 if (num_ret < 2)
914 {
915 if (data) free(data);
916 return EINA_FALSE;
917 }
918
919 icons = 0;
920 p = data;
921 while (p)
922 {
923 len = (p[0] * p[1]);
924 p += (len + 2);
925 if ((p - data) > num_ret)
926 {
927 if (data) free(data);
928 return EINA_FALSE;
929 }
930 icons++;
931 if ((p - data) == num_ret) p = NULL;
932 }
933 if (num) *num = icons;
934 if (!icon)
935 {
936 if (data) free(data);
937 return EINA_TRUE;
938 }
939
940 *icon = malloc(icons * sizeof(Ecore_X_Icon));
941 if (!(*icon))
942 {
943 if (data) free(data);
944 return EINA_FALSE;
945 }
946
947 /* Fetch the icons */
948 p = data;
949 for (i = 0; i < icons; i++)
950 {
951 unsigned int *ps, *pd, *pe;
952
953 len = p[0] * p[1];
954 ((*icon)[i]).width = p[0];
955 ((*icon)[i]).height = p[1];
956 src = &(p[2]);
957 ((*icon)[i]).data = malloc(len * sizeof(unsigned int));
958 if (!((*icon)[i]).data)
959 {
960 while (i)
961 free(((*icon)[--i]).data);
962 free(*icon);
963 free(data);
964 return EINA_FALSE;
965 }
966
967 pd = ((*icon)[i]).data;
968 ps = src;
969 pe = ps + len;
970 for (; ps < pe; ps++)
971 {
972 unsigned int r, g, b, a;
973
974 a = (*ps >> 24) & 0xff;
975 r = (((*ps >> 16) & 0xff) * a) / 255;
976 g = (((*ps >> 8) & 0xff) * a) / 255;
977 b = (((*ps) & 0xff) * a) / 255;
978 *pd = (a << 24) | (r << 16) | (g << 8) | (b);
979 pd++;
980 }
981 p += (len + 2);
982 }
983
984 if (data) free(data);
985 return EINA_TRUE;
986}
987
988EAPI void
989ecore_x_netwm_icon_geometry_set(Ecore_X_Window win,
990 int x,
991 int y,
992 int w,
993 int h)
994{
995 unsigned int geom[4];
996
997 LOGFN(__FILE__, __LINE__, __FUNCTION__);
998
999 geom[0] = x;
1000 geom[1] = y;
1001 geom[2] = w;
1002 geom[3] = h;
1003 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_ICON_GEOMETRY,
1004 geom, 4);
1005}
1006
1007EAPI Eina_Bool
1008ecore_x_netwm_icon_geometry_get(Ecore_X_Window win,
1009 int *x,
1010 int *y,
1011 int *w,
1012 int *h)
1013{
1014 int ret = 0;
1015 unsigned int geom[4];
1016
1017 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1018
1019 ret =
1020 ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_ICON_GEOMETRY,
1021 geom, 4);
1022 if (ret != 4) return EINA_FALSE;
1023 if (x) *x = geom[0];
1024 if (y) *y = geom[1];
1025 if (w) *w = geom[2];
1026 if (h) *h = geom[3];
1027
1028 return EINA_TRUE;
1029}
1030
1031EAPI void
1032ecore_x_netwm_strut_set(Ecore_X_Window win,
1033 int l,
1034 int r,
1035 int t,
1036 int b)
1037{
1038 unsigned int strut[4];
1039
1040 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1041
1042 strut[0] = l;
1043 strut[1] = r;
1044 strut[2] = t;
1045 strut[3] = b;
1046 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_STRUT, strut, 4);
1047}
1048
1049EAPI Eina_Bool
1050ecore_x_netwm_strut_get(Ecore_X_Window win,
1051 int *l,
1052 int *r,
1053 int *t,
1054 int *b)
1055{
1056 unsigned int strut[4];
1057 int ret = 0;
1058
1059 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1060
1061 ret =
1062 ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_STRUT, strut, 4);
1063 if (ret != 4) return EINA_FALSE;
1064
1065 if (l) *l = strut[0];
1066 if (r) *r = strut[1];
1067 if (t) *t = strut[2];
1068 if (b) *b = strut[3];
1069
1070 return EINA_TRUE;
1071}
1072
1073EAPI void
1074ecore_x_netwm_strut_partial_set(Ecore_X_Window win,
1075 int left,
1076 int right,
1077 int top,
1078 int bottom,
1079 int left_start_y,
1080 int left_end_y,
1081 int right_start_y,
1082 int right_end_y,
1083 int top_start_x,
1084 int top_end_x,
1085 int bottom_start_x,
1086 int bottom_end_x)
1087{
1088 unsigned int strut[12];
1089
1090 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1091
1092 strut[0] = left;
1093 strut[1] = right;
1094 strut[2] = top;
1095 strut[3] = bottom;
1096 strut[4] = left_start_y;
1097 strut[5] = left_end_y;
1098 strut[6] = right_start_y;
1099 strut[7] = right_end_y;
1100 strut[8] = top_start_x;
1101 strut[9] = top_end_x;
1102 strut[10] = bottom_start_x;
1103 strut[11] = bottom_end_x;
1104 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_STRUT_PARTIAL,
1105 strut, 12);
1106}
1107
1108EAPI Eina_Bool
1109ecore_x_netwm_strut_partial_get(Ecore_X_Window win,
1110 int *left,
1111 int *right,
1112 int *top,
1113 int *bottom,
1114 int *left_start_y,
1115 int *left_end_y,
1116 int *right_start_y,
1117 int *right_end_y,
1118 int *top_start_x,
1119 int *top_end_x,
1120 int *bottom_start_x,
1121 int *bottom_end_x)
1122{
1123 unsigned int strut[12];
1124 int ret = 0;
1125
1126 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1127
1128 ret =
1129 ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_STRUT_PARTIAL,
1130 strut, 12);
1131 if (ret != 12) return EINA_FALSE;
1132
1133 if (left) *left = strut[0];
1134 if (right) *right = strut[1];
1135 if (top) *top = strut[2];
1136 if (bottom) *bottom = strut[3];
1137 if (left_start_y) *left_start_y = strut[4];
1138 if (left_end_y) *left_end_y = strut[5];
1139 if (right_start_y) *right_start_y = strut[6];
1140 if (right_end_y) *right_end_y = strut[7];
1141 if (top_start_x) *top_start_x = strut[8];
1142 if (top_end_x) *top_end_x = strut[9];
1143 if (bottom_start_x) *bottom_start_x = strut[10];
1144 if (bottom_end_x) *bottom_end_x = strut[11];
1145
1146 return EINA_TRUE;
1147}
1148
1149EAPI void
1150ecore_x_netwm_user_time_set(Ecore_X_Window win,
1151 unsigned int t)
1152{
1153 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1154
1155 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_USER_TIME, &t, 1);
1156}
1157
1158EAPI Eina_Bool
1159ecore_x_netwm_user_time_get(Ecore_X_Window win,
1160 unsigned int *t)
1161{
1162 unsigned int tmp;
1163
1164 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1165
1166 if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_USER_TIME,
1167 &tmp, 1))
1168 return EINA_FALSE;
1169
1170 if (t) *t = tmp;
1171
1172 return EINA_TRUE;
1173}
1174
1175EAPI void
1176ecore_x_netwm_visible_name_set(Ecore_X_Window win,
1177 const char *name)
1178{
1179 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1180
1181 ecore_x_window_prop_string_set(win, ECORE_X_ATOM_NET_WM_VISIBLE_NAME,
1182 name);
1183}
1184
1185EAPI int
1186ecore_x_netwm_visible_name_get(Ecore_X_Window win,
1187 char **name)
1188{
1189 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1190
1191 if (name)
1192 *name = ecore_x_window_prop_string_get(win,
1193 ECORE_X_ATOM_NET_WM_VISIBLE_NAME);
1194 return 1;
1195}
1196
1197EAPI void
1198ecore_x_netwm_visible_icon_name_set(Ecore_X_Window win,
1199 const char *name)
1200{
1201 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1202
1203 ecore_x_window_prop_string_set(win, ECORE_X_ATOM_NET_WM_VISIBLE_ICON_NAME,
1204 name);
1205}
1206
1207EAPI int
1208ecore_x_netwm_visible_icon_name_get(Ecore_X_Window win,
1209 char **name)
1210{
1211 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1212
1213 if (name)
1214 {
1215 *name =
1216 ecore_x_window_prop_string_get(win,
1217 ECORE_X_ATOM_NET_WM_VISIBLE_ICON_NAME);
1218 }
1219
1220 return 1;
1221}
1222
1223EAPI Eina_Bool
1224ecore_x_netwm_sync_counter_get(Ecore_X_Window win,
1225 Ecore_X_Sync_Counter *counter)
1226{
1227 unsigned int tmp;
1228
1229 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1230
1231 if (!ecore_x_window_prop_card32_get(win,
1232 ECORE_X_ATOM_NET_WM_SYNC_REQUEST_COUNTER,
1233 &tmp, 1))
1234 return EINA_FALSE;
1235
1236 if (counter) *counter = tmp;
1237
1238 return EINA_TRUE;
1239}
1240
1241EAPI Eina_Bool
1242ecore_x_netwm_allowed_action_isset(Ecore_X_Window win,
1243 Ecore_X_Action action)
1244{
1245 int num = 0, i = 0;
1246 Ecore_X_Atom *atoms, atom;
1247 Eina_Bool ret = EINA_FALSE;
1248
1249 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1250
1251 num =
1252 ecore_x_window_prop_atom_list_get(win, ECORE_X_ATOM_NET_WM_WINDOW_TYPE,
1253 &atoms);
1254 if (num <= 0) return EINA_FALSE;
1255
1256 atom = _ecore_xcb_netwm_action_atom_get(action);
1257 for (i = 0; i < num; i++)
1258 {
1259 if (atoms[i] == atom)
1260 {
1261 ret = EINA_TRUE;
1262 break;
1263 }
1264 }
1265
1266 if (atoms) free(atoms);
1267 return ret;
1268}
1269
1270EAPI Eina_Bool
1271ecore_x_netwm_allowed_action_get(Ecore_X_Window win,
1272 Ecore_X_Action **action,
1273 unsigned int *num)
1274{
1275 Ecore_X_Atom *atoms;
1276 int num_ret = 0;
1277
1278 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1279
1280 if (num) *num = 0;
1281 if (action) *action = NULL;
1282
1283 num_ret =
1284 ecore_x_window_prop_atom_list_get(win, ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS,
1285 &atoms);
1286 if (num_ret <= 0) return EINA_FALSE;
1287 if (action)
1288 {
1289 *action = malloc(num_ret * sizeof(Ecore_X_Action));
1290 if (*action)
1291 {
1292 int i = 0;
1293
1294 for (i = 0; i < num_ret; i++)
1295 (*action)[i] = _ecore_xcb_netwm_action_atom_get(atoms[i]);
1296 }
1297 if (num) *num = num_ret;
1298 }
1299 free(atoms);
1300 return EINA_TRUE;
1301}
1302
1303EAPI void
1304ecore_x_netwm_allowed_action_set(Ecore_X_Window win,
1305 Ecore_X_Action *action,
1306 unsigned int num)
1307{
1308 Ecore_X_Atom *set;
1309 unsigned int i = 0;
1310
1311 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1312
1313 if (!num)
1314 {
1315 ecore_x_window_prop_property_del(win,
1316 ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS);
1317 return;
1318 }
1319
1320 set = malloc(num * sizeof(Ecore_X_Atom));
1321 if (!set) return;
1322
1323 for (i = 0; i < num; i++)
1324 set[i] = _ecore_xcb_netwm_action_atom_get(action[i]);
1325
1326 ecore_x_window_prop_atom_set(win, ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS,
1327 set, num);
1328 free(set);
1329}
1330
1331/* local functions */
1332int
1333_ecore_xcb_netwm_startup_info_begin(Ecore_X_Window win __UNUSED__,
1334 uint8_t data __UNUSED__)
1335{
1336 // TODO: TBD
1337 return 1;
1338}
1339
1340int
1341_ecore_xcb_netwm_startup_info(Ecore_X_Window win __UNUSED__,
1342 uint8_t data __UNUSED__)
1343{
1344 // TODO: TBD
1345 return 1;
1346}
1347
1348/* static void */
1349/* _ecore_xcb_netwm_startup_info_free(void *data) */
1350/* { */
1351/* Ecore_Xcb_Startup_Info *info; */
1352
1353/* LOGFN(__FILE__, __LINE__, __FUNCTION__); */
1354
1355/* if (!(info = data)) return; */
1356/* if (info->buffer) free(info->buffer); */
1357/* if (info->id) free(info->id); */
1358/* if (info->name) free(info->name); */
1359/* if (info->bin) free(info->bin); */
1360/* if (info->icon) free(info->icon); */
1361/* if (info->description) free(info->description); */
1362/* if (info->wmclass) free(info->wmclass); */
1363/* free(info); */
1364/* } */
1365
1366static Ecore_X_Atom
1367_ecore_xcb_netwm_window_type_atom_get(Ecore_X_Window_Type type)
1368{
1369 switch (type)
1370 {
1371 case ECORE_X_WINDOW_TYPE_DESKTOP:
1372 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DESKTOP;
1373
1374 case ECORE_X_WINDOW_TYPE_DOCK:
1375 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DOCK;
1376
1377 case ECORE_X_WINDOW_TYPE_TOOLBAR:
1378 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLBAR;
1379
1380 case ECORE_X_WINDOW_TYPE_MENU:
1381 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_MENU;
1382
1383 case ECORE_X_WINDOW_TYPE_UTILITY:
1384 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_UTILITY;
1385
1386 case ECORE_X_WINDOW_TYPE_SPLASH:
1387 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_SPLASH;
1388
1389 case ECORE_X_WINDOW_TYPE_DIALOG:
1390 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DIALOG;
1391
1392 case ECORE_X_WINDOW_TYPE_NORMAL:
1393 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NORMAL;
1394
1395 case ECORE_X_WINDOW_TYPE_DROPDOWN_MENU:
1396 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DROPDOWN_MENU;
1397
1398 case ECORE_X_WINDOW_TYPE_POPUP_MENU:
1399 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_POPUP_MENU;
1400
1401 case ECORE_X_WINDOW_TYPE_TOOLTIP:
1402 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLTIP;
1403
1404 case ECORE_X_WINDOW_TYPE_NOTIFICATION:
1405 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NOTIFICATION;
1406
1407 case ECORE_X_WINDOW_TYPE_COMBO:
1408 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_COMBO;
1409
1410 case ECORE_X_WINDOW_TYPE_DND:
1411 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DND;
1412
1413 default:
1414 return 0;
1415 }
1416}
1417
1418static Ecore_X_Window_Type
1419_ecore_xcb_netwm_window_type_type_get(Ecore_X_Atom atom)
1420{
1421 if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DESKTOP)
1422 return ECORE_X_WINDOW_TYPE_DESKTOP;
1423 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DOCK)
1424 return ECORE_X_WINDOW_TYPE_DOCK;
1425 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLBAR)
1426 return ECORE_X_WINDOW_TYPE_TOOLBAR;
1427 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_MENU)
1428 return ECORE_X_WINDOW_TYPE_MENU;
1429 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_UTILITY)
1430 return ECORE_X_WINDOW_TYPE_UTILITY;
1431 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_SPLASH)
1432 return ECORE_X_WINDOW_TYPE_SPLASH;
1433 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DIALOG)
1434 return ECORE_X_WINDOW_TYPE_DIALOG;
1435 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NORMAL)
1436 return ECORE_X_WINDOW_TYPE_NORMAL;
1437 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DROPDOWN_MENU)
1438 return ECORE_X_WINDOW_TYPE_DROPDOWN_MENU;
1439 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_POPUP_MENU)
1440 return ECORE_X_WINDOW_TYPE_POPUP_MENU;
1441 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLTIP)
1442 return ECORE_X_WINDOW_TYPE_TOOLTIP;
1443 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NOTIFICATION)
1444 return ECORE_X_WINDOW_TYPE_NOTIFICATION;
1445 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_COMBO)
1446 return ECORE_X_WINDOW_TYPE_COMBO;
1447 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DND)
1448 return ECORE_X_WINDOW_TYPE_DND;
1449 else
1450 return ECORE_X_WINDOW_TYPE_UNKNOWN;
1451}
1452
1453static Ecore_X_Atom
1454_ecore_xcb_netwm_window_state_atom_get(Ecore_X_Window_State state)
1455{
1456 switch (state)
1457 {
1458 case ECORE_X_WINDOW_STATE_MODAL:
1459 return ECORE_X_ATOM_NET_WM_STATE_MODAL;
1460
1461 case ECORE_X_WINDOW_STATE_STICKY:
1462 return ECORE_X_ATOM_NET_WM_STATE_STICKY;
1463
1464 case ECORE_X_WINDOW_STATE_MAXIMIZED_VERT:
1465 return ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT;
1466
1467 case ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ:
1468 return ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ;
1469
1470 case ECORE_X_WINDOW_STATE_SHADED:
1471 return ECORE_X_ATOM_NET_WM_STATE_SHADED;
1472
1473 case ECORE_X_WINDOW_STATE_SKIP_TASKBAR:
1474 return ECORE_X_ATOM_NET_WM_STATE_SKIP_TASKBAR;
1475
1476 case ECORE_X_WINDOW_STATE_SKIP_PAGER:
1477 return ECORE_X_ATOM_NET_WM_STATE_SKIP_PAGER;
1478
1479 case ECORE_X_WINDOW_STATE_HIDDEN:
1480 return ECORE_X_ATOM_NET_WM_STATE_HIDDEN;
1481
1482 case ECORE_X_WINDOW_STATE_FULLSCREEN:
1483 return ECORE_X_ATOM_NET_WM_STATE_FULLSCREEN;
1484
1485 case ECORE_X_WINDOW_STATE_ABOVE:
1486 return ECORE_X_ATOM_NET_WM_STATE_ABOVE;
1487
1488 case ECORE_X_WINDOW_STATE_BELOW:
1489 return ECORE_X_ATOM_NET_WM_STATE_BELOW;
1490
1491 case ECORE_X_WINDOW_STATE_DEMANDS_ATTENTION:
1492 return ECORE_X_ATOM_NET_WM_STATE_DEMANDS_ATTENTION;
1493
1494 default:
1495 return 0;
1496 }
1497}
1498
1499Ecore_X_Window_State
1500_ecore_xcb_netwm_window_state_get(Ecore_X_Atom atom)
1501{
1502 if (atom == ECORE_X_ATOM_NET_WM_STATE_MODAL)
1503 return ECORE_X_WINDOW_STATE_MODAL;
1504 else if (atom == ECORE_X_ATOM_NET_WM_STATE_STICKY)
1505 return ECORE_X_WINDOW_STATE_STICKY;
1506 else if (atom == ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT)
1507 return ECORE_X_WINDOW_STATE_MAXIMIZED_VERT;
1508 else if (atom == ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ)
1509 return ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ;
1510 else if (atom == ECORE_X_ATOM_NET_WM_STATE_SHADED)
1511 return ECORE_X_WINDOW_STATE_SHADED;
1512 else if (atom == ECORE_X_ATOM_NET_WM_STATE_SKIP_TASKBAR)
1513 return ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
1514 else if (atom == ECORE_X_ATOM_NET_WM_STATE_SKIP_PAGER)
1515 return ECORE_X_WINDOW_STATE_SKIP_PAGER;
1516 else if (atom == ECORE_X_ATOM_NET_WM_STATE_HIDDEN)
1517 return ECORE_X_WINDOW_STATE_HIDDEN;
1518 else if (atom == ECORE_X_ATOM_NET_WM_STATE_FULLSCREEN)
1519 return ECORE_X_WINDOW_STATE_FULLSCREEN;
1520 else if (atom == ECORE_X_ATOM_NET_WM_STATE_ABOVE)
1521 return ECORE_X_WINDOW_STATE_ABOVE;
1522 else if (atom == ECORE_X_ATOM_NET_WM_STATE_BELOW)
1523 return ECORE_X_WINDOW_STATE_BELOW;
1524 else if (atom == ECORE_X_ATOM_NET_WM_STATE_DEMANDS_ATTENTION)
1525 return ECORE_X_WINDOW_STATE_DEMANDS_ATTENTION;
1526 else
1527 return ECORE_X_WINDOW_STATE_UNKNOWN;
1528}
1529
1530static Ecore_X_Atom
1531_ecore_xcb_netwm_action_atom_get(Ecore_X_Action action)
1532{
1533 switch (action)
1534 {
1535 case ECORE_X_ACTION_MOVE:
1536 return ECORE_X_ATOM_NET_WM_ACTION_MOVE;
1537
1538 case ECORE_X_ACTION_RESIZE:
1539 return ECORE_X_ATOM_NET_WM_ACTION_RESIZE;
1540
1541 case ECORE_X_ACTION_MINIMIZE:
1542 return ECORE_X_ATOM_NET_WM_ACTION_MINIMIZE;
1543
1544 case ECORE_X_ACTION_SHADE:
1545 return ECORE_X_ATOM_NET_WM_ACTION_SHADE;
1546
1547 case ECORE_X_ACTION_STICK:
1548 return ECORE_X_ATOM_NET_WM_ACTION_STICK;
1549
1550 case ECORE_X_ACTION_MAXIMIZE_HORZ:
1551 return ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_HORZ;
1552
1553 case ECORE_X_ACTION_MAXIMIZE_VERT:
1554 return ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_VERT;
1555
1556 case ECORE_X_ACTION_FULLSCREEN:
1557 return ECORE_X_ATOM_NET_WM_ACTION_FULLSCREEN;
1558
1559 case ECORE_X_ACTION_CHANGE_DESKTOP:
1560 return ECORE_X_ATOM_NET_WM_ACTION_CHANGE_DESKTOP;
1561
1562 case ECORE_X_ACTION_CLOSE:
1563 return ECORE_X_ATOM_NET_WM_ACTION_CLOSE;
1564
1565 case ECORE_X_ACTION_ABOVE:
1566 return ECORE_X_ATOM_NET_WM_ACTION_ABOVE;
1567
1568 case ECORE_X_ACTION_BELOW:
1569 return ECORE_X_ATOM_NET_WM_ACTION_BELOW;
1570
1571 default:
1572 return 0;
1573 }
1574}
1575