diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_netwm.c | 1525 |
1 files changed, 1525 insertions, 0 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 new file mode 100644 index 0000000..0a523b9 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_netwm.c | |||
@@ -0,0 +1,1525 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | |||
3 | /* local function prototypes */ | ||
4 | /* static void _ecore_xcb_netwm_startup_info_free(void *data); */ | ||
5 | static Ecore_X_Atom _ecore_xcb_netwm_window_type_atom_get(Ecore_X_Window_Type type); | ||
6 | static Ecore_X_Window_Type _ecore_xcb_netwm_window_type_type_get(Ecore_X_Atom atom); | ||
7 | static Ecore_X_Atom _ecore_xcb_netwm_window_state_atom_get(Ecore_X_Window_State state); | ||
8 | static 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 */ | ||
14 | typedef struct _Ecore_Xcb_Startup_Info Ecore_Xcb_Startup_Info; | ||
15 | struct _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 | |||
31 | EAPI void | ||
32 | ecore_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 | |||
40 | EAPI void | ||
41 | ecore_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 | |||
49 | EAPI Eina_Bool | ||
50 | ecore_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 | |||
65 | EAPI void | ||
66 | ecore_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 | |||
77 | EAPI Eina_Bool | ||
78 | ecore_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 | |||
100 | EAPI void | ||
101 | ecore_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 | |||
112 | EAPI int | ||
113 | ecore_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 | |||
151 | EAPI int | ||
152 | ecore_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 | |||
162 | EAPI void | ||
163 | ecore_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 | |||
171 | EAPI void | ||
172 | ecore_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 | |||
181 | EAPI Eina_Bool | ||
182 | ecore_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 | |||
198 | EAPI void | ||
199 | ecore_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 | |||
213 | EAPI void | ||
214 | ecore_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 | |||
224 | EAPI Eina_Bool | ||
225 | ecore_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 | |||
245 | EAPI void | ||
246 | ecore_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 | |||
255 | EAPI void | ||
256 | ecore_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 | |||
266 | EAPI void | ||
267 | ecore_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 | |||
305 | EAPI void | ||
306 | ecore_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 | |||
320 | EAPI void | ||
321 | ecore_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 | |||
331 | EAPI void | ||
332 | ecore_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 | |||
350 | EAPI void | ||
351 | ecore_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 | |||
361 | EAPI unsigned int * | ||
362 | ecore_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 | |||
380 | EAPI void | ||
381 | ecore_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 | |||
390 | EAPI void | ||
391 | ecore_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 | |||
403 | EAPI int | ||
404 | ecore_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 | |||
418 | EAPI void | ||
419 | ecore_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 | |||
427 | EAPI void | ||
428 | ecore_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 | |||
459 | EAPI void | ||
460 | ecore_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 | |||
485 | EAPI Eina_Bool | ||
486 | ecore_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 | |||
521 | EAPI void | ||
522 | ecore_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 | |||
531 | EAPI void | ||
532 | ecore_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 | |||
560 | EAPI void | ||
561 | ecore_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 | |||
571 | EAPI void | ||
572 | ecore_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 | |||
582 | EAPI Eina_Bool | ||
583 | ecore_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 | |||
619 | EAPI void | ||
620 | ecore_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 | |||
647 | EAPI void | ||
648 | ecore_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 | |||
672 | EAPI void | ||
673 | ecore_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 | |||
691 | EAPI Eina_Bool | ||
692 | ecore_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 | |||
715 | EAPI void | ||
716 | ecore_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 | |||
744 | EAPI void | ||
745 | ecore_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 | |||
753 | EAPI Eina_Bool | ||
754 | ecore_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 | |||
770 | EAPI void | ||
771 | ecore_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 | |||
796 | EAPI void | ||
797 | ecore_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 | |||
805 | EAPI Eina_Bool | ||
806 | ecore_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 | |||
817 | EAPI int | ||
818 | ecore_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 | |||
832 | EAPI void | ||
833 | ecore_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 | |||
841 | EAPI Eina_Bool | ||
842 | ecore_x_netwm_icons_get(Ecore_X_Window win, | ||
843 | Ecore_X_Icon **icon, | ||
844 | int *num) | ||
845 | { | ||
846 | int num_ret = 0; | ||
847 | unsigned int i = 0, len = 0, icons = 0; | ||
848 | unsigned int *data, *p, *src; | ||
849 | |||
850 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
851 | |||
852 | if (num) *num = 0; | ||
853 | if (icon) *icon = NULL; | ||
854 | |||
855 | num_ret = | ||
856 | ecore_x_window_prop_card32_list_get(win, ECORE_X_ATOM_NET_WM_ICON, &data); | ||
857 | |||
858 | if ((num_ret <= 0) || (!data)) | ||
859 | { | ||
860 | if (data) free(data); | ||
861 | return EINA_FALSE; | ||
862 | } | ||
863 | if (num_ret < 2) | ||
864 | { | ||
865 | if (data) free(data); | ||
866 | return EINA_FALSE; | ||
867 | } | ||
868 | |||
869 | icons = 0; | ||
870 | p = data; | ||
871 | while (p) | ||
872 | { | ||
873 | len = (p[0] * p[1]); | ||
874 | p += (len + 2); | ||
875 | if ((p - data) > num_ret) | ||
876 | { | ||
877 | if (data) free(data); | ||
878 | return EINA_FALSE; | ||
879 | } | ||
880 | icons++; | ||
881 | if ((p - data) == num_ret) p = NULL; | ||
882 | } | ||
883 | if (num) *num = icons; | ||
884 | if (!icon) | ||
885 | { | ||
886 | if (data) free(data); | ||
887 | return EINA_TRUE; | ||
888 | } | ||
889 | |||
890 | *icon = malloc(icons * sizeof(Ecore_X_Icon)); | ||
891 | if (!(*icon)) | ||
892 | { | ||
893 | if (data) free(data); | ||
894 | return EINA_FALSE; | ||
895 | } | ||
896 | |||
897 | /* Fetch the icons */ | ||
898 | p = data; | ||
899 | for (i = 0; i < icons; i++) | ||
900 | { | ||
901 | unsigned int *ps, *pd, *pe; | ||
902 | |||
903 | len = p[0] * p[1]; | ||
904 | ((*icon)[i]).width = p[0]; | ||
905 | ((*icon)[i]).height = p[1]; | ||
906 | src = &(p[2]); | ||
907 | ((*icon)[i]).data = malloc(len * sizeof(unsigned int)); | ||
908 | if (!((*icon)[i]).data) | ||
909 | { | ||
910 | while (i) | ||
911 | free(((*icon)[--i]).data); | ||
912 | free(*icon); | ||
913 | free(data); | ||
914 | return EINA_FALSE; | ||
915 | } | ||
916 | |||
917 | pd = ((*icon)[i]).data; | ||
918 | ps = src; | ||
919 | pe = ps + len; | ||
920 | for (; ps < pe; ps++) | ||
921 | { | ||
922 | unsigned int r, g, b, a; | ||
923 | |||
924 | a = (*ps >> 24) & 0xff; | ||
925 | r = (((*ps >> 16) & 0xff) * a) / 255; | ||
926 | g = (((*ps >> 8) & 0xff) * a) / 255; | ||
927 | b = (((*ps) & 0xff) * a) / 255; | ||
928 | *pd = (a << 24) | (r << 16) | (g << 8) | (b); | ||
929 | pd++; | ||
930 | } | ||
931 | p += (len + 2); | ||
932 | } | ||
933 | |||
934 | if (data) free(data); | ||
935 | return EINA_TRUE; | ||
936 | } | ||
937 | |||
938 | EAPI void | ||
939 | ecore_x_netwm_icon_geometry_set(Ecore_X_Window win, | ||
940 | int x, | ||
941 | int y, | ||
942 | int w, | ||
943 | int h) | ||
944 | { | ||
945 | unsigned int geom[4]; | ||
946 | |||
947 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
948 | |||
949 | geom[0] = x; | ||
950 | geom[1] = y; | ||
951 | geom[2] = w; | ||
952 | geom[3] = h; | ||
953 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_ICON_GEOMETRY, | ||
954 | geom, 4); | ||
955 | } | ||
956 | |||
957 | EAPI Eina_Bool | ||
958 | ecore_x_netwm_icon_geometry_get(Ecore_X_Window win, | ||
959 | int *x, | ||
960 | int *y, | ||
961 | int *w, | ||
962 | int *h) | ||
963 | { | ||
964 | int ret = 0; | ||
965 | unsigned int geom[4]; | ||
966 | |||
967 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
968 | |||
969 | ret = | ||
970 | ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_ICON_GEOMETRY, | ||
971 | geom, 4); | ||
972 | if (ret != 4) return EINA_FALSE; | ||
973 | if (x) *x = geom[0]; | ||
974 | if (y) *y = geom[1]; | ||
975 | if (w) *w = geom[2]; | ||
976 | if (h) *h = geom[3]; | ||
977 | |||
978 | return EINA_TRUE; | ||
979 | } | ||
980 | |||
981 | EAPI void | ||
982 | ecore_x_netwm_strut_set(Ecore_X_Window win, | ||
983 | int l, | ||
984 | int r, | ||
985 | int t, | ||
986 | int b) | ||
987 | { | ||
988 | unsigned int strut[4]; | ||
989 | |||
990 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
991 | |||
992 | strut[0] = l; | ||
993 | strut[1] = r; | ||
994 | strut[2] = t; | ||
995 | strut[3] = b; | ||
996 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_STRUT, strut, 4); | ||
997 | } | ||
998 | |||
999 | EAPI Eina_Bool | ||
1000 | ecore_x_netwm_strut_get(Ecore_X_Window win, | ||
1001 | int *l, | ||
1002 | int *r, | ||
1003 | int *t, | ||
1004 | int *b) | ||
1005 | { | ||
1006 | unsigned int strut[4]; | ||
1007 | int ret = 0; | ||
1008 | |||
1009 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1010 | |||
1011 | ret = | ||
1012 | ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_STRUT, strut, 4); | ||
1013 | if (ret != 4) return EINA_FALSE; | ||
1014 | |||
1015 | if (l) *l = strut[0]; | ||
1016 | if (r) *r = strut[1]; | ||
1017 | if (t) *t = strut[2]; | ||
1018 | if (b) *b = strut[3]; | ||
1019 | |||
1020 | return EINA_TRUE; | ||
1021 | } | ||
1022 | |||
1023 | EAPI void | ||
1024 | ecore_x_netwm_strut_partial_set(Ecore_X_Window win, | ||
1025 | int left, | ||
1026 | int right, | ||
1027 | int top, | ||
1028 | int bottom, | ||
1029 | int left_start_y, | ||
1030 | int left_end_y, | ||
1031 | int right_start_y, | ||
1032 | int right_end_y, | ||
1033 | int top_start_x, | ||
1034 | int top_end_x, | ||
1035 | int bottom_start_x, | ||
1036 | int bottom_end_x) | ||
1037 | { | ||
1038 | unsigned int strut[12]; | ||
1039 | |||
1040 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1041 | |||
1042 | strut[0] = left; | ||
1043 | strut[1] = right; | ||
1044 | strut[2] = top; | ||
1045 | strut[3] = bottom; | ||
1046 | strut[4] = left_start_y; | ||
1047 | strut[5] = left_end_y; | ||
1048 | strut[6] = right_start_y; | ||
1049 | strut[7] = right_end_y; | ||
1050 | strut[8] = top_start_x; | ||
1051 | strut[9] = top_end_x; | ||
1052 | strut[10] = bottom_start_x; | ||
1053 | strut[11] = bottom_end_x; | ||
1054 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_STRUT_PARTIAL, | ||
1055 | strut, 12); | ||
1056 | } | ||
1057 | |||
1058 | EAPI Eina_Bool | ||
1059 | ecore_x_netwm_strut_partial_get(Ecore_X_Window win, | ||
1060 | int *left, | ||
1061 | int *right, | ||
1062 | int *top, | ||
1063 | int *bottom, | ||
1064 | int *left_start_y, | ||
1065 | int *left_end_y, | ||
1066 | int *right_start_y, | ||
1067 | int *right_end_y, | ||
1068 | int *top_start_x, | ||
1069 | int *top_end_x, | ||
1070 | int *bottom_start_x, | ||
1071 | int *bottom_end_x) | ||
1072 | { | ||
1073 | unsigned int strut[12]; | ||
1074 | int ret = 0; | ||
1075 | |||
1076 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1077 | |||
1078 | ret = | ||
1079 | ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_STRUT_PARTIAL, | ||
1080 | strut, 12); | ||
1081 | if (ret != 12) return EINA_FALSE; | ||
1082 | |||
1083 | if (left) *left = strut[0]; | ||
1084 | if (right) *right = strut[1]; | ||
1085 | if (top) *top = strut[2]; | ||
1086 | if (bottom) *bottom = strut[3]; | ||
1087 | if (left_start_y) *left_start_y = strut[4]; | ||
1088 | if (left_end_y) *left_end_y = strut[5]; | ||
1089 | if (right_start_y) *right_start_y = strut[6]; | ||
1090 | if (right_end_y) *right_end_y = strut[7]; | ||
1091 | if (top_start_x) *top_start_x = strut[8]; | ||
1092 | if (top_end_x) *top_end_x = strut[9]; | ||
1093 | if (bottom_start_x) *bottom_start_x = strut[10]; | ||
1094 | if (bottom_end_x) *bottom_end_x = strut[11]; | ||
1095 | |||
1096 | return EINA_TRUE; | ||
1097 | } | ||
1098 | |||
1099 | EAPI void | ||
1100 | ecore_x_netwm_user_time_set(Ecore_X_Window win, | ||
1101 | unsigned int t) | ||
1102 | { | ||
1103 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1104 | |||
1105 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_USER_TIME, &t, 1); | ||
1106 | } | ||
1107 | |||
1108 | EAPI Eina_Bool | ||
1109 | ecore_x_netwm_user_time_get(Ecore_X_Window win, | ||
1110 | unsigned int *t) | ||
1111 | { | ||
1112 | unsigned int tmp; | ||
1113 | |||
1114 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1115 | |||
1116 | if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_USER_TIME, | ||
1117 | &tmp, 1)) | ||
1118 | return EINA_FALSE; | ||
1119 | |||
1120 | if (t) *t = tmp; | ||
1121 | |||
1122 | return EINA_TRUE; | ||
1123 | } | ||
1124 | |||
1125 | EAPI void | ||
1126 | ecore_x_netwm_visible_name_set(Ecore_X_Window win, | ||
1127 | const char *name) | ||
1128 | { | ||
1129 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1130 | |||
1131 | ecore_x_window_prop_string_set(win, ECORE_X_ATOM_NET_WM_VISIBLE_NAME, | ||
1132 | name); | ||
1133 | } | ||
1134 | |||
1135 | EAPI int | ||
1136 | ecore_x_netwm_visible_name_get(Ecore_X_Window win, | ||
1137 | char **name) | ||
1138 | { | ||
1139 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1140 | |||
1141 | if (name) | ||
1142 | *name = ecore_x_window_prop_string_get(win, | ||
1143 | ECORE_X_ATOM_NET_WM_VISIBLE_NAME); | ||
1144 | return 1; | ||
1145 | } | ||
1146 | |||
1147 | EAPI void | ||
1148 | ecore_x_netwm_visible_icon_name_set(Ecore_X_Window win, | ||
1149 | const char *name) | ||
1150 | { | ||
1151 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1152 | |||
1153 | ecore_x_window_prop_string_set(win, ECORE_X_ATOM_NET_WM_VISIBLE_ICON_NAME, | ||
1154 | name); | ||
1155 | } | ||
1156 | |||
1157 | EAPI int | ||
1158 | ecore_x_netwm_visible_icon_name_get(Ecore_X_Window win, | ||
1159 | char **name) | ||
1160 | { | ||
1161 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1162 | |||
1163 | if (name) | ||
1164 | { | ||
1165 | *name = | ||
1166 | ecore_x_window_prop_string_get(win, | ||
1167 | ECORE_X_ATOM_NET_WM_VISIBLE_ICON_NAME); | ||
1168 | } | ||
1169 | |||
1170 | return 1; | ||
1171 | } | ||
1172 | |||
1173 | EAPI Eina_Bool | ||
1174 | ecore_x_netwm_sync_counter_get(Ecore_X_Window win, | ||
1175 | Ecore_X_Sync_Counter *counter) | ||
1176 | { | ||
1177 | unsigned int tmp; | ||
1178 | |||
1179 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1180 | |||
1181 | if (!ecore_x_window_prop_card32_get(win, | ||
1182 | ECORE_X_ATOM_NET_WM_SYNC_REQUEST_COUNTER, | ||
1183 | &tmp, 1)) | ||
1184 | return EINA_FALSE; | ||
1185 | |||
1186 | if (counter) *counter = tmp; | ||
1187 | |||
1188 | return EINA_TRUE; | ||
1189 | } | ||
1190 | |||
1191 | EAPI Eina_Bool | ||
1192 | ecore_x_netwm_allowed_action_isset(Ecore_X_Window win, | ||
1193 | Ecore_X_Action action) | ||
1194 | { | ||
1195 | int num = 0, i = 0; | ||
1196 | Ecore_X_Atom *atoms, atom; | ||
1197 | Eina_Bool ret = EINA_FALSE; | ||
1198 | |||
1199 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1200 | |||
1201 | num = | ||
1202 | ecore_x_window_prop_atom_list_get(win, ECORE_X_ATOM_NET_WM_WINDOW_TYPE, | ||
1203 | &atoms); | ||
1204 | if (num <= 0) return EINA_FALSE; | ||
1205 | |||
1206 | atom = _ecore_xcb_netwm_action_atom_get(action); | ||
1207 | for (i = 0; i < num; i++) | ||
1208 | { | ||
1209 | if (atoms[i] == atom) | ||
1210 | { | ||
1211 | ret = EINA_TRUE; | ||
1212 | break; | ||
1213 | } | ||
1214 | } | ||
1215 | |||
1216 | if (atoms) free(atoms); | ||
1217 | return ret; | ||
1218 | } | ||
1219 | |||
1220 | EAPI Eina_Bool | ||
1221 | ecore_x_netwm_allowed_action_get(Ecore_X_Window win, | ||
1222 | Ecore_X_Action **action, | ||
1223 | unsigned int *num) | ||
1224 | { | ||
1225 | Ecore_X_Atom *atoms; | ||
1226 | int num_ret = 0; | ||
1227 | |||
1228 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1229 | |||
1230 | if (num) *num = 0; | ||
1231 | if (action) *action = NULL; | ||
1232 | |||
1233 | num_ret = | ||
1234 | ecore_x_window_prop_atom_list_get(win, ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS, | ||
1235 | &atoms); | ||
1236 | if (num_ret <= 0) return EINA_FALSE; | ||
1237 | if (action) | ||
1238 | { | ||
1239 | *action = malloc(num_ret * sizeof(Ecore_X_Action)); | ||
1240 | if (*action) | ||
1241 | { | ||
1242 | int i = 0; | ||
1243 | |||
1244 | for (i = 0; i < num_ret; i++) | ||
1245 | (*action)[i] = _ecore_xcb_netwm_action_atom_get(atoms[i]); | ||
1246 | } | ||
1247 | if (num) *num = num_ret; | ||
1248 | } | ||
1249 | free(atoms); | ||
1250 | return EINA_TRUE; | ||
1251 | } | ||
1252 | |||
1253 | EAPI void | ||
1254 | ecore_x_netwm_allowed_action_set(Ecore_X_Window win, | ||
1255 | Ecore_X_Action *action, | ||
1256 | unsigned int num) | ||
1257 | { | ||
1258 | Ecore_X_Atom *set; | ||
1259 | unsigned int i = 0; | ||
1260 | |||
1261 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1262 | |||
1263 | if (!num) | ||
1264 | { | ||
1265 | ecore_x_window_prop_property_del(win, | ||
1266 | ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS); | ||
1267 | return; | ||
1268 | } | ||
1269 | |||
1270 | set = malloc(num * sizeof(Ecore_X_Atom)); | ||
1271 | if (!set) return; | ||
1272 | |||
1273 | for (i = 0; i < num; i++) | ||
1274 | set[i] = _ecore_xcb_netwm_action_atom_get(action[i]); | ||
1275 | |||
1276 | ecore_x_window_prop_atom_set(win, ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS, | ||
1277 | set, num); | ||
1278 | free(set); | ||
1279 | } | ||
1280 | |||
1281 | /* local functions */ | ||
1282 | int | ||
1283 | _ecore_xcb_netwm_startup_info_begin(Ecore_X_Window win __UNUSED__, | ||
1284 | uint8_t data __UNUSED__) | ||
1285 | { | ||
1286 | // TODO: TBD | ||
1287 | return 1; | ||
1288 | } | ||
1289 | |||
1290 | int | ||
1291 | _ecore_xcb_netwm_startup_info(Ecore_X_Window win __UNUSED__, | ||
1292 | uint8_t data __UNUSED__) | ||
1293 | { | ||
1294 | // TODO: TBD | ||
1295 | return 1; | ||
1296 | } | ||
1297 | |||
1298 | /* static void */ | ||
1299 | /* _ecore_xcb_netwm_startup_info_free(void *data) */ | ||
1300 | /* { */ | ||
1301 | /* Ecore_Xcb_Startup_Info *info; */ | ||
1302 | |||
1303 | /* LOGFN(__FILE__, __LINE__, __FUNCTION__); */ | ||
1304 | |||
1305 | /* if (!(info = data)) return; */ | ||
1306 | /* if (info->buffer) free(info->buffer); */ | ||
1307 | /* if (info->id) free(info->id); */ | ||
1308 | /* if (info->name) free(info->name); */ | ||
1309 | /* if (info->bin) free(info->bin); */ | ||
1310 | /* if (info->icon) free(info->icon); */ | ||
1311 | /* if (info->description) free(info->description); */ | ||
1312 | /* if (info->wmclass) free(info->wmclass); */ | ||
1313 | /* free(info); */ | ||
1314 | /* } */ | ||
1315 | |||
1316 | static Ecore_X_Atom | ||
1317 | _ecore_xcb_netwm_window_type_atom_get(Ecore_X_Window_Type type) | ||
1318 | { | ||
1319 | switch (type) | ||
1320 | { | ||
1321 | case ECORE_X_WINDOW_TYPE_DESKTOP: | ||
1322 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DESKTOP; | ||
1323 | |||
1324 | case ECORE_X_WINDOW_TYPE_DOCK: | ||
1325 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DOCK; | ||
1326 | |||
1327 | case ECORE_X_WINDOW_TYPE_TOOLBAR: | ||
1328 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLBAR; | ||
1329 | |||
1330 | case ECORE_X_WINDOW_TYPE_MENU: | ||
1331 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_MENU; | ||
1332 | |||
1333 | case ECORE_X_WINDOW_TYPE_UTILITY: | ||
1334 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_UTILITY; | ||
1335 | |||
1336 | case ECORE_X_WINDOW_TYPE_SPLASH: | ||
1337 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_SPLASH; | ||
1338 | |||
1339 | case ECORE_X_WINDOW_TYPE_DIALOG: | ||
1340 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DIALOG; | ||
1341 | |||
1342 | case ECORE_X_WINDOW_TYPE_NORMAL: | ||
1343 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NORMAL; | ||
1344 | |||
1345 | case ECORE_X_WINDOW_TYPE_DROPDOWN_MENU: | ||
1346 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DROPDOWN_MENU; | ||
1347 | |||
1348 | case ECORE_X_WINDOW_TYPE_POPUP_MENU: | ||
1349 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_POPUP_MENU; | ||
1350 | |||
1351 | case ECORE_X_WINDOW_TYPE_TOOLTIP: | ||
1352 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLTIP; | ||
1353 | |||
1354 | case ECORE_X_WINDOW_TYPE_NOTIFICATION: | ||
1355 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NOTIFICATION; | ||
1356 | |||
1357 | case ECORE_X_WINDOW_TYPE_COMBO: | ||
1358 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_COMBO; | ||
1359 | |||
1360 | case ECORE_X_WINDOW_TYPE_DND: | ||
1361 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DND; | ||
1362 | |||
1363 | default: | ||
1364 | return 0; | ||
1365 | } | ||
1366 | } | ||
1367 | |||
1368 | static Ecore_X_Window_Type | ||
1369 | _ecore_xcb_netwm_window_type_type_get(Ecore_X_Atom atom) | ||
1370 | { | ||
1371 | if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DESKTOP) | ||
1372 | return ECORE_X_WINDOW_TYPE_DESKTOP; | ||
1373 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DOCK) | ||
1374 | return ECORE_X_WINDOW_TYPE_DOCK; | ||
1375 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLBAR) | ||
1376 | return ECORE_X_WINDOW_TYPE_TOOLBAR; | ||
1377 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_MENU) | ||
1378 | return ECORE_X_WINDOW_TYPE_MENU; | ||
1379 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_UTILITY) | ||
1380 | return ECORE_X_WINDOW_TYPE_UTILITY; | ||
1381 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_SPLASH) | ||
1382 | return ECORE_X_WINDOW_TYPE_SPLASH; | ||
1383 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DIALOG) | ||
1384 | return ECORE_X_WINDOW_TYPE_DIALOG; | ||
1385 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NORMAL) | ||
1386 | return ECORE_X_WINDOW_TYPE_NORMAL; | ||
1387 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DROPDOWN_MENU) | ||
1388 | return ECORE_X_WINDOW_TYPE_DROPDOWN_MENU; | ||
1389 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_POPUP_MENU) | ||
1390 | return ECORE_X_WINDOW_TYPE_POPUP_MENU; | ||
1391 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLTIP) | ||
1392 | return ECORE_X_WINDOW_TYPE_TOOLTIP; | ||
1393 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NOTIFICATION) | ||
1394 | return ECORE_X_WINDOW_TYPE_NOTIFICATION; | ||
1395 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_COMBO) | ||
1396 | return ECORE_X_WINDOW_TYPE_COMBO; | ||
1397 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DND) | ||
1398 | return ECORE_X_WINDOW_TYPE_DND; | ||
1399 | else | ||
1400 | return ECORE_X_WINDOW_TYPE_UNKNOWN; | ||
1401 | } | ||
1402 | |||
1403 | static Ecore_X_Atom | ||
1404 | _ecore_xcb_netwm_window_state_atom_get(Ecore_X_Window_State state) | ||
1405 | { | ||
1406 | switch (state) | ||
1407 | { | ||
1408 | case ECORE_X_WINDOW_STATE_MODAL: | ||
1409 | return ECORE_X_ATOM_NET_WM_STATE_MODAL; | ||
1410 | |||
1411 | case ECORE_X_WINDOW_STATE_STICKY: | ||
1412 | return ECORE_X_ATOM_NET_WM_STATE_STICKY; | ||
1413 | |||
1414 | case ECORE_X_WINDOW_STATE_MAXIMIZED_VERT: | ||
1415 | return ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT; | ||
1416 | |||
1417 | case ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ: | ||
1418 | return ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ; | ||
1419 | |||
1420 | case ECORE_X_WINDOW_STATE_SHADED: | ||
1421 | return ECORE_X_ATOM_NET_WM_STATE_SHADED; | ||
1422 | |||
1423 | case ECORE_X_WINDOW_STATE_SKIP_TASKBAR: | ||
1424 | return ECORE_X_ATOM_NET_WM_STATE_SKIP_TASKBAR; | ||
1425 | |||
1426 | case ECORE_X_WINDOW_STATE_SKIP_PAGER: | ||
1427 | return ECORE_X_ATOM_NET_WM_STATE_SKIP_PAGER; | ||
1428 | |||
1429 | case ECORE_X_WINDOW_STATE_HIDDEN: | ||
1430 | return ECORE_X_ATOM_NET_WM_STATE_HIDDEN; | ||
1431 | |||
1432 | case ECORE_X_WINDOW_STATE_FULLSCREEN: | ||
1433 | return ECORE_X_ATOM_NET_WM_STATE_FULLSCREEN; | ||
1434 | |||
1435 | case ECORE_X_WINDOW_STATE_ABOVE: | ||
1436 | return ECORE_X_ATOM_NET_WM_STATE_ABOVE; | ||
1437 | |||
1438 | case ECORE_X_WINDOW_STATE_BELOW: | ||
1439 | return ECORE_X_ATOM_NET_WM_STATE_BELOW; | ||
1440 | |||
1441 | case ECORE_X_WINDOW_STATE_DEMANDS_ATTENTION: | ||
1442 | return ECORE_X_ATOM_NET_WM_STATE_DEMANDS_ATTENTION; | ||
1443 | |||
1444 | default: | ||
1445 | return 0; | ||
1446 | } | ||
1447 | } | ||
1448 | |||
1449 | Ecore_X_Window_State | ||
1450 | _ecore_xcb_netwm_window_state_get(Ecore_X_Atom atom) | ||
1451 | { | ||
1452 | if (atom == ECORE_X_ATOM_NET_WM_STATE_MODAL) | ||
1453 | return ECORE_X_WINDOW_STATE_MODAL; | ||
1454 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_STICKY) | ||
1455 | return ECORE_X_WINDOW_STATE_STICKY; | ||
1456 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT) | ||
1457 | return ECORE_X_WINDOW_STATE_MAXIMIZED_VERT; | ||
1458 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ) | ||
1459 | return ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ; | ||
1460 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_SHADED) | ||
1461 | return ECORE_X_WINDOW_STATE_SHADED; | ||
1462 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_SKIP_TASKBAR) | ||
1463 | return ECORE_X_WINDOW_STATE_SKIP_TASKBAR; | ||
1464 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_SKIP_PAGER) | ||
1465 | return ECORE_X_WINDOW_STATE_SKIP_PAGER; | ||
1466 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_HIDDEN) | ||
1467 | return ECORE_X_WINDOW_STATE_HIDDEN; | ||
1468 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_FULLSCREEN) | ||
1469 | return ECORE_X_WINDOW_STATE_FULLSCREEN; | ||
1470 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_ABOVE) | ||
1471 | return ECORE_X_WINDOW_STATE_ABOVE; | ||
1472 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_BELOW) | ||
1473 | return ECORE_X_WINDOW_STATE_BELOW; | ||
1474 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_DEMANDS_ATTENTION) | ||
1475 | return ECORE_X_WINDOW_STATE_DEMANDS_ATTENTION; | ||
1476 | else | ||
1477 | return ECORE_X_WINDOW_STATE_UNKNOWN; | ||
1478 | } | ||
1479 | |||
1480 | static Ecore_X_Atom | ||
1481 | _ecore_xcb_netwm_action_atom_get(Ecore_X_Action action) | ||
1482 | { | ||
1483 | switch (action) | ||
1484 | { | ||
1485 | case ECORE_X_ACTION_MOVE: | ||
1486 | return ECORE_X_ATOM_NET_WM_ACTION_MOVE; | ||
1487 | |||
1488 | case ECORE_X_ACTION_RESIZE: | ||
1489 | return ECORE_X_ATOM_NET_WM_ACTION_RESIZE; | ||
1490 | |||
1491 | case ECORE_X_ACTION_MINIMIZE: | ||
1492 | return ECORE_X_ATOM_NET_WM_ACTION_MINIMIZE; | ||
1493 | |||
1494 | case ECORE_X_ACTION_SHADE: | ||
1495 | return ECORE_X_ATOM_NET_WM_ACTION_SHADE; | ||
1496 | |||
1497 | case ECORE_X_ACTION_STICK: | ||
1498 | return ECORE_X_ATOM_NET_WM_ACTION_STICK; | ||
1499 | |||
1500 | case ECORE_X_ACTION_MAXIMIZE_HORZ: | ||
1501 | return ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_HORZ; | ||
1502 | |||
1503 | case ECORE_X_ACTION_MAXIMIZE_VERT: | ||
1504 | return ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_VERT; | ||
1505 | |||
1506 | case ECORE_X_ACTION_FULLSCREEN: | ||
1507 | return ECORE_X_ATOM_NET_WM_ACTION_FULLSCREEN; | ||
1508 | |||
1509 | case ECORE_X_ACTION_CHANGE_DESKTOP: | ||
1510 | return ECORE_X_ATOM_NET_WM_ACTION_CHANGE_DESKTOP; | ||
1511 | |||
1512 | case ECORE_X_ACTION_CLOSE: | ||
1513 | return ECORE_X_ATOM_NET_WM_ACTION_CLOSE; | ||
1514 | |||
1515 | case ECORE_X_ACTION_ABOVE: | ||
1516 | return ECORE_X_ATOM_NET_WM_ACTION_ABOVE; | ||
1517 | |||
1518 | case ECORE_X_ACTION_BELOW: | ||
1519 | return ECORE_X_ATOM_NET_WM_ACTION_BELOW; | ||
1520 | |||
1521 | default: | ||
1522 | return 0; | ||
1523 | } | ||
1524 | } | ||
1525 | |||