2 * Various ICCCM related functions.
4 * This is ALL the code involving anything ICCCM related, for both WM and
12 #include <xcb/xcb_icccm.h>
14 #include "ecore_xcb_private.h"
15 #include "Ecore_X_Atoms.h"
18 * @defgroup Ecore_X_ICCCM_Group ICCCM related functions.
20 * Functions related to ICCCM.
23 static int _ecore_x_icccm_size_hints_get (const void *reply,
24 Ecore_X_Atom property,
25 xcb_size_hints_t *hints)
35 if ((((xcb_get_property_reply_t *)reply)->type != ECORE_X_ATOM_WM_SIZE_HINTS) &&
36 ((((xcb_get_property_reply_t *)reply)->format != 8) ||
37 (((xcb_get_property_reply_t *)reply)->format != 16) ||
38 (((xcb_get_property_reply_t *)reply)->format != 32)) &&
39 (((xcb_get_property_reply_t *)reply)->value_len < 15)) /* OldNumPropSizeElements = 15 (pre-ICCCM) */
43 xcb_get_property_value((xcb_get_property_reply_t *)reply),
44 ((xcb_get_property_reply_t *)reply)->value_len);
46 s = (XCB_SIZE_HINT_US_POSITION | XCB_SIZE_HINT_US_SIZE |
47 XCB_SIZE_HINT_P_POSITION | XCB_SIZE_HINT_P_SIZE |
48 XCB_SIZE_HINT_P_MIN_SIZE | XCB_SIZE_HINT_P_MAX_SIZE |
49 XCB_SIZE_HINT_P_RESIZE_INC | XCB_SIZE_HINT_P_ASPECT);
51 if (((xcb_get_property_reply_t *)reply)->value_len >= 18) /* NumPropSizeElements = 18 (ICCCM version 1) */
52 s |= (XCB_SIZE_HINT_BASE_SIZE | XCB_SIZE_HINT_P_WIN_GRAVITY);
55 xcb_size_hints_set_base_size(hints, 0, 0);
56 xcb_size_hints_set_win_gravity(hints, 0);
59 /* FIXME: is it necessary ? */
60 /* hints->flags &= s; */ /* get rid of unwanted bits */
63 } /* _ecore_x_icccm_size_hints_get */
66 * Sets the state of a window.
67 * @param window The window.
68 * @param state The state.
69 * @ingroup Ecore_X_ICCCM_Group
72 ecore_x_icccm_state_set(Ecore_X_Window window,
73 Ecore_X_Window_State_Hint state)
77 if (state == ECORE_X_WINDOW_STATE_HINT_WITHDRAWN)
78 c[0] = XCB_WM_STATE_WITHDRAWN;
79 else if (state == ECORE_X_WINDOW_STATE_HINT_NORMAL)
80 c[0] = XCB_WM_STATE_NORMAL;
81 else if (state == ECORE_X_WINDOW_STATE_HINT_ICONIC)
82 c[0] = XCB_WM_STATE_ICONIC;
85 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
86 ECORE_X_ATOM_WM_STATE, ECORE_X_ATOM_WM_STATE, 32,
88 } /* ecore_x_icccm_state_set */
91 * Sends the GetProperty request.
92 * @ingroup Ecore_X_ICCCM_Group
95 ecore_x_icccm_state_get_prefetch(Ecore_X_Window window)
97 xcb_get_property_cookie_t cookie;
99 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
100 ECORE_X_ATOM_WM_STATE,
101 ECORE_X_ATOM_WM_STATE,
103 _ecore_xcb_cookie_cache(cookie.sequence);
104 } /* ecore_x_icccm_state_get_prefetch */
107 * Gets the reply of the GetProperty request sent by ecore_x_icccm_state_get_prefetch().
108 * @ingroup Ecore_X_ICCCM_Group
111 ecore_x_icccm_state_get_fetch(void)
113 xcb_get_property_cookie_t cookie;
114 xcb_get_property_reply_t *reply;
116 cookie.sequence = _ecore_xcb_cookie_get();
117 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
118 _ecore_xcb_reply_cache(reply);
119 } /* ecore_x_icccm_state_get_fetch */
122 * Gets the state of a window.
123 * @param window The window.
124 * @return The state of the window
126 * To use this function, you must call before, and in order,
127 * ecore_x_icccm_state_get_prefetch(), which sends the GetProperty request,
128 * then ecore_x_icccm_state_get_fetch(), which gets the reply.
129 * @ingroup Ecore_X_ICCCM_Group
131 EAPI Ecore_X_Window_State_Hint
132 ecore_x_icccm_state_get(Ecore_X_Window window __UNUSED__)
134 xcb_get_property_reply_t *reply;
136 Ecore_X_Window_State_Hint hint = ECORE_X_WINDOW_STATE_HINT_NONE;
138 reply = _ecore_xcb_reply_get();
142 if ((reply->type == 0) ||
143 (reply->format != 8) ||
144 (reply->value_len != 2))
147 prop = (uint8_t *)xcb_get_property_value(reply);
149 case XCB_WM_STATE_WITHDRAWN:
150 hint = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN;
153 case XCB_WM_STATE_NORMAL:
154 hint = ECORE_X_WINDOW_STATE_HINT_NORMAL;
157 case XCB_WM_STATE_ICONIC:
158 hint = ECORE_X_WINDOW_STATE_HINT_ICONIC;
162 hint = ECORE_X_WINDOW_STATE_HINT_NONE;
167 } /* ecore_x_icccm_state_get */
170 * Sends the ClientMessage event with the DeleteWindow property.
171 * @param window The window.
172 * @param time The time.
173 * @ingroup Ecore_X_ICCCM_Group
176 ecore_x_icccm_delete_window_send(Ecore_X_Window window,
179 ecore_x_client_message32_send(window, ECORE_X_ATOM_WM_PROTOCOLS,
180 ECORE_X_EVENT_MASK_NONE,
181 ECORE_X_ATOM_WM_DELETE_WINDOW,
183 } /* ecore_x_icccm_delete_window_send */
186 * Sends the ClientMessage event with the TakeFocus property.
187 * @param window The window.
188 * @param time The time.
189 * @ingroup Ecore_X_ICCCM_Group
192 ecore_x_icccm_take_focus_send(Ecore_X_Window window,
195 ecore_x_client_message32_send(window, ECORE_X_ATOM_WM_PROTOCOLS,
196 ECORE_X_EVENT_MASK_NONE,
197 ECORE_X_ATOM_WM_TAKE_FOCUS,
199 } /* ecore_x_icccm_take_focus_send */
202 * Sends the ClientMessage event with the SaveYourself property.
203 * @param window The window.
204 * @param time The time.
205 * @ingroup Ecore_X_ICCCM_Group
208 ecore_x_icccm_save_yourself_send(Ecore_X_Window window,
211 ecore_x_client_message32_send(window, ECORE_X_ATOM_WM_PROTOCOLS,
212 ECORE_X_EVENT_MASK_NONE,
213 ECORE_X_ATOM_WM_SAVE_YOURSELF,
215 } /* ecore_x_icccm_save_yourself_send */
218 * Sends the ConfigureNotify event with the StructureNotify property.
219 * @param window The window.
220 * @param x The X coordinate.
221 * @param y The Y coordinate.
222 * @param width The width.
223 * @param height The height.
224 * @ingroup Ecore_X_ICCCM_Group
227 ecore_x_icccm_move_resize_send(Ecore_X_Window window,
233 xcb_configure_notify_event_t ev;
235 ev.response_type = XCB_CONFIGURE_NOTIFY | 0x80;
240 ev.above_sibling = 0;
246 ev.override_redirect = 0;
247 xcb_send_event(_ecore_xcb_conn, 0, window,
248 XCB_EVENT_MASK_STRUCTURE_NOTIFY, (const char *)&ev);
249 } /* ecore_x_icccm_move_resize_send */
252 * Sets the hints of a window.
253 * @param window The window.
254 * @param accepts_focus AcceptFocus hint
255 * @param initial_state Initial state flags.
256 * @param icon_pixmap Icon pixmap.
257 * @param icon_mask Icon mask.
258 * @param icon_window Icon window.
259 * @param window_group Group window.
260 * @param is_urgent IsUrgent flag.
261 * @ingroup Ecore_X_ICCCM_Group
264 ecore_x_icccm_hints_set(Ecore_X_Window window,
266 Ecore_X_Window_State_Hint initial_state,
267 Ecore_X_Pixmap icon_pixmap,
268 Ecore_X_Pixmap icon_mask,
269 Ecore_X_Window icon_window,
270 Ecore_X_Window window_group,
273 xcb_wm_hints_t hints;
275 memset(&hints, 0, sizeof(hints));
276 xcb_wm_hints_set_input(&hints, accepts_focus);
277 if (initial_state == ECORE_X_WINDOW_STATE_HINT_WITHDRAWN)
278 xcb_wm_hints_set_withdrawn(&hints);
279 else if (initial_state == ECORE_X_WINDOW_STATE_HINT_NORMAL)
280 xcb_wm_hints_set_normal(&hints);
281 else if (initial_state == ECORE_X_WINDOW_STATE_HINT_ICONIC)
282 xcb_wm_hints_set_iconic(&hints);
284 if (icon_pixmap != 0)
285 xcb_wm_hints_set_icon_pixmap(&hints, icon_pixmap);
288 xcb_wm_hints_set_icon_mask(&hints, icon_mask);
290 if (icon_window != 0)
291 xcb_wm_hints_set_icon_window(&hints, icon_window);
293 if (window_group != 0)
294 xcb_wm_hints_set_window_group(&hints, window_group);
297 xcb_wm_hints_set_urgency(&hints);
299 xcb_set_wm_hints(_ecore_xcb_conn, window, &hints);
300 } /* ecore_x_icccm_hints_set */
303 * Sends the GetProperty request.
304 * @ingroup Ecore_X_ICCCM_Group
307 ecore_x_icccm_hints_get_prefetch(Ecore_X_Window window)
309 xcb_get_property_cookie_t cookie;
311 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
312 ECORE_X_ATOM_WM_HINTS,
313 ECORE_X_ATOM_WM_HINTS,
314 0L, XCB_NUM_WM_HINTS_ELEMENTS);
315 _ecore_xcb_cookie_cache(cookie.sequence);
316 } /* ecore_x_icccm_hints_get_prefetch */
319 * Gets the reply of the GetProperty request sent by ecore_x_icccm_hints_get_prefetch().
320 * @ingroup Ecore_X_ICCCM_Group
323 ecore_x_icccm_hints_get_fetch(void)
325 xcb_get_property_cookie_t cookie;
326 xcb_get_property_reply_t *reply;
328 cookie.sequence = _ecore_xcb_cookie_get();
329 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
330 _ecore_xcb_reply_cache(reply);
331 } /* ecore_x_icccm_hints_get_fetch */
334 * Gets the hints of a window.
335 * @param window The window.
336 * @param accepts_focus AcceptFocus hint
337 * @param initial_state Initial state flags.
338 * @param icon_pixmap Icon pixmap.
339 * @param icon_mask Icon mask.
340 * @param icon_window Icon window.
341 * @param window_group Group window.
342 * @param is_urgent IsUrgent flag.
343 * @return 1 on success, 0 otherwise.
345 * To use this function, you must call before, and in order,
346 * ecore_x_icccm_hints_get_prefetch(), which sends the GetProperty request,
347 * then ecore_x_icccm_hints_get_fetch(), which gets the reply.
348 * @ingroup Ecore_X_ICCCM_Group
351 ecore_x_icccm_hints_get(Ecore_X_Window window __UNUSED__,
353 Ecore_X_Window_State_Hint *initial_state,
354 Ecore_X_Pixmap *icon_pixmap,
355 Ecore_X_Pixmap *icon_mask,
356 Ecore_X_Window *icon_window,
357 Ecore_X_Window *window_group,
360 xcb_wm_hints_t hints;
361 xcb_get_property_reply_t *reply;
363 uint32_t hints_input;
364 int32_t hints_initial_state;
365 xcb_pixmap_t hints_icon_pixmap;
366 xcb_pixmap_t hints_icon_mask;
367 xcb_window_t hints_icon_window;
368 xcb_window_t hints_window_group;
374 *initial_state = ECORE_X_WINDOW_STATE_HINT_NORMAL;
391 reply = _ecore_xcb_reply_get();
395 if ((reply->type != ECORE_X_ATOM_WM_HINTS) ||
396 (reply->value_len < (XCB_NUM_WM_HINTS_ELEMENTS - 1)) ||
397 (reply->format != 32))
400 memcpy(&hints, xcb_get_property_value(reply), reply->value_len);
401 hints_flags = hints.flags;
402 hints_input = hints.input;
403 hints_initial_state = hints.initial_state;
404 hints_icon_pixmap = hints.icon_pixmap;
405 hints_icon_mask = hints.icon_mask;
406 hints_icon_window = hints.icon_window;
407 hints_window_group = hints.window_group;
409 if ((hints_flags & XCB_WM_HINT_INPUT) && (accepts_focus))
417 if ((hints_flags & XCB_WM_HINT_STATE) && (initial_state))
419 if (hints_initial_state == XCB_WM_STATE_WITHDRAWN)
420 *initial_state = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN;
421 else if (hints_initial_state == XCB_WM_STATE_NORMAL)
422 *initial_state = ECORE_X_WINDOW_STATE_HINT_NORMAL;
423 else if (hints_initial_state == XCB_WM_STATE_ICONIC)
424 *initial_state = ECORE_X_WINDOW_STATE_HINT_ICONIC;
427 if ((hints_flags & XCB_WM_HINT_ICON_PIXMAP) && (icon_pixmap))
429 *icon_pixmap = hints_icon_pixmap;
432 if ((hints_flags & XCB_WM_HINT_ICON_MASK) && (icon_mask))
434 *icon_mask = hints_icon_mask;
437 if ((hints_flags & XCB_WM_HINT_ICON_WINDOW) && (icon_window))
439 *icon_window = hints_icon_window;
442 if ((hints_flags & XCB_WM_HINT_WINDOW_GROUP) && (window_group))
444 if (reply->value_len < XCB_NUM_WM_HINTS_ELEMENTS)
447 *window_group = hints_window_group;
450 if ((hints_flags & XCB_WM_HINT_X_URGENCY) && (is_urgent))
456 } /* ecore_x_icccm_hints_get */
459 * Sends the GetProperty request.
460 * @ingroup Ecore_X_ICCCM_Group
463 ecore_x_icccm_size_pos_hints_get_prefetch(Ecore_X_Window window)
465 xcb_get_property_cookie_t cookie;
467 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
468 ECORE_X_ATOM_WM_NORMAL_HINTS,
469 ECORE_X_ATOM_WM_SIZE_HINTS,
471 _ecore_xcb_cookie_cache(cookie.sequence);
472 } /* ecore_x_icccm_size_pos_hints_get_prefetch */
475 * Gets the reply of the GetProperty request sent by ecore_x_icccm_size_pos_hints_get_prefetch().
476 * @ingroup Ecore_X_ICCCM_Group
479 ecore_x_icccm_size_pos_hints_get_fetch(void)
481 xcb_get_property_cookie_t cookie;
482 xcb_get_property_reply_t *reply;
484 cookie.sequence = _ecore_xcb_cookie_get();
485 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
486 _ecore_xcb_reply_cache(reply);
487 } /* ecore_x_icccm_size_pos_hints_get_fetch */
490 * Sets the hints of a window.
491 * @param window The window.
492 * @param request_pos Request position flag.
493 * @param gravity Gravity.
494 * @param min_w Minimum width.
495 * @param min_h Minimum height.
496 * @param max_w Maximum width.
497 * @param max_h Maximum height.
498 * @param base_w Base width
499 * @param base_h Base height
500 * @param step_x X step coordinate.
501 * @param step_y Y step coordinate.
502 * @param min_aspect Minimum aspect ratio.
503 * @param max_aspect Maximum aspect ratio.
505 * To use this function, you must call before, and in order,
506 * ecore_x_icccm_size_pos_hints_get_prefetch(), which sends the GetProperty request,
507 * then ecore_x_icccm_size_pos_hints_get_fetch(), which gets the reply.
508 * @ingroup Ecore_X_ICCCM_Group
511 ecore_x_icccm_size_pos_hints_set(Ecore_X_Window window,
513 Ecore_X_Gravity gravity,
525 xcb_size_hints_t hint;
526 xcb_get_property_reply_t *reply;
528 reply = _ecore_xcb_reply_get();
530 (reply->type != ECORE_X_ATOM_WM_SIZE_HINTS) ||
531 ((reply->format != 8) &&
532 (reply->format != 16) &&
533 (reply->format != 32)) ||
534 (reply->value_len < 15))
540 hint.flags = XCB_SIZE_HINT_US_POSITION;
543 if (gravity != ECORE_X_GRAVITY_NW)
545 hint.win_gravity = (uint8_t)gravity;
548 if ((min_w > 0) || (min_h > 0))
550 hint.min_width = min_w;
551 hint.min_height = min_h;
554 if ((max_w > 0) || (max_h > 0))
556 hint.max_width = max_w;
557 hint.max_height = max_h;
560 if ((base_w > 0) || (base_h > 0))
562 hint.base_width = base_w;
563 hint.base_height = base_h;
566 if ((step_x > 1) || (step_y > 1))
568 hint.width_inc = step_x;
569 hint.height_inc = step_y;
572 if ((min_aspect > 0.0) || (max_aspect > 0.0))
574 xcb_size_hints_set_aspect(&hint,
575 (int32_t)(min_aspect * 10000),
577 (int32_t)(max_aspect * 10000),
581 xcb_set_wm_normal_hints(_ecore_xcb_conn, window, &hint);
582 } /* ecore_x_icccm_size_pos_hints_set */
585 * Gets the hints of a window.
586 * @param window The window.
587 * @param request_pos Request position flag.
588 * @param gravity Gravity.
589 * @param min_w Minimum width.
590 * @param min_h Minimum height.
591 * @param max_w Maximum width.
592 * @param max_h Maximum height.
593 * @param base_w Base width
594 * @param base_h Base height
595 * @param step_x X step coordinate.
596 * @param step_y Y step coordinate.
597 * @param min_aspect Minimum aspect ratio.
598 * @param max_aspect M
599 * @return 1 on success, 0 otherwise.
601 * To use this function, you must call before, and in order,
602 * ecore_x_icccm_size_pos_hints_get_prefetch(), which sends the GetProperty request,
603 * then ecore_x_icccm_size_pos_hints_get_fetch(), which gets the reply.
604 * @ingroup Ecore_X_ICCCM_Group
607 ecore_x_icccm_size_pos_hints_get(Ecore_X_Window window __UNUSED__,
609 Ecore_X_Gravity *gravity,
621 xcb_size_hints_t hint;
622 xcb_get_property_reply_t *reply;
626 int32_t maxw = 32767;
627 int32_t maxh = 32767;
639 *gravity = ECORE_X_GRAVITY_NW;
671 reply = _ecore_xcb_reply_get();
675 if (!_ecore_x_icccm_size_hints_get(reply, ECORE_X_ATOM_WM_NORMAL_HINTS, &hint))
679 if ((flags & XCB_SIZE_HINT_US_POSITION) || (flags & XCB_SIZE_HINT_P_POSITION))
685 if (flags & XCB_SIZE_HINT_P_WIN_GRAVITY)
688 *gravity = hint.win_gravity;
691 if (flags & XCB_SIZE_HINT_P_MIN_SIZE)
693 minw = hint.min_width;
694 minh = hint.min_height;
697 if (flags & XCB_SIZE_HINT_P_MAX_SIZE)
699 maxw = hint.max_width;
700 maxh = hint.max_height;
708 if (flags & XCB_SIZE_HINT_BASE_SIZE)
710 basew = hint.base_width;
711 baseh = hint.base_height;
719 if (flags & XCB_SIZE_HINT_P_RESIZE_INC)
721 stepx = hint.width_inc;
722 stepy = hint.height_inc;
730 if (flags & XCB_SIZE_HINT_P_ASPECT)
732 if (hint.min_aspect_den > 0)
733 mina = ((double)hint.min_aspect_num) / ((double)hint.min_aspect_den);
735 if (hint.max_aspect_den > 0)
736 maxa = ((double)hint.max_aspect_num) / ((double)hint.max_aspect_den);
770 } /* ecore_x_icccm_size_pos_hints_get */
773 * Set the title of a window
774 * @param window The window.
775 * @param title The title.
776 * @ingroup Ecore_X_ICCCM_Group
779 ecore_x_icccm_title_set(Ecore_X_Window window,
785 /* FIXME: to do: utf8 */
787 /* xprop.value = NULL; */
788 /* #ifdef X_HAVE_UTF8_STRING */
789 /* list[0] = strdup(t); */
791 /* Xutf8TextListToTextProperty(_ecore_xcb_conn, list, 1, XUTF8StringStyle, */
794 /* list[0] = strdup(t); */
796 /* XmbTextListToTextProperty(_ecore_xcb_conn, list, 1, XStdICCTextStyle, */
800 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
801 ECORE_X_ATOM_WM_NAME, ECORE_X_ATOM_STRING, 8,
802 strlen(title), title);
803 } /* ecore_x_icccm_title_set */
806 * Sends the GetProperty request.
807 * @ingroup Ecore_X_ICCCM_Group
810 ecore_x_icccm_title_get_prefetch(Ecore_X_Window window)
812 xcb_get_property_cookie_t cookie;
814 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
815 ECORE_X_ATOM_WM_NAME,
816 XCB_GET_PROPERTY_TYPE_ANY,
818 _ecore_xcb_cookie_cache(cookie.sequence);
819 } /* ecore_x_icccm_title_get_prefetch */
822 * Gets the reply of the GetProperty request sent by ecore_x_icccm_title_get_prefetch().
823 * @ingroup Ecore_X_ICCCM_Group
826 ecore_x_icccm_title_get_fetch(void)
828 xcb_get_property_cookie_t cookie;
829 xcb_get_property_reply_t *reply;
831 cookie.sequence = _ecore_xcb_cookie_get();
832 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
833 _ecore_xcb_reply_cache(reply);
834 } /* ecore_x_icccm_title_get_fetch */
837 * Gets the title of a window.
838 * @param window The window (Unused).
839 * @return The title of the window
841 * To use this function, you must call before, and in order,
842 * ecore_x_icccm_title_get_prefetch(), which sends the GetProperty request,
843 * then ecore_x_icccm_title_get_fetch(), which gets the reply.
844 * @ingroup Ecore_X_ICCCM_Group
847 ecore_x_icccm_title_get(Ecore_X_Window window __UNUSED__)
850 xcb_get_property_reply_t *reply;
852 reply = _ecore_xcb_reply_get();
856 if (reply->type == ECORE_X_ATOM_UTF8_STRING)
860 /* FIXME: verify the value of length */
861 length = (reply->value_len * reply->format) / 8;
862 title = (char *)malloc((length + 1) * sizeof(char));
863 memcpy(title, xcb_get_property_value(reply), length);
864 title[length] = '\0';
866 /* not in UTF8, so we convert */
869 /* convert to utf8 */
871 /* FIXME: to do... */
873 /* #ifdef X_HAVE_UTF8_STRING */
874 /* ret = Xutf8TextPropertyToTextList(_ecore_xcb_conn, &xprop, */
877 /* ret = XmbTextPropertyToTextList(_ecore_xcb_conn, &xprop, */
881 /* if ((ret == XLocaleNotSupported) || */
882 /* (ret == XNoMemory) || (ret == XConverterNotFound)) */
884 /* t = strdup((char *)xprop.value); */
886 /* else if ((ret >= Success) && (num > 0)) */
888 /* t = strdup(list[0]); */
891 /* XFreeStringList(list); */
894 /* if (xprop.value) XFree(xprop.value); */
898 } /* ecore_x_icccm_title_get */
901 * Sends the GetProperty request.
902 * @ingroup Ecore_X_ICCCM_Group
905 ecore_x_icccm_protocol_get_prefetch(Ecore_X_Window window)
907 xcb_get_property_cookie_t cookie;
909 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
910 ECORE_X_ATOM_WM_PROTOCOLS,
911 ECORE_X_ATOM_ATOM, 0, 1000000L);
912 _ecore_xcb_cookie_cache(cookie.sequence);
913 } /* ecore_x_icccm_protocol_get_prefetch */
916 * Gets the reply of the GetProperty request sent by ecore_x_icccm_protocol_get_prefetch().
917 * @ingroup Ecore_X_ICCCM_Group
920 ecore_x_icccm_protocol_get_fetch(void)
922 xcb_get_property_cookie_t cookie;
923 xcb_get_property_reply_t *reply;
925 cookie.sequence = _ecore_xcb_cookie_get();
926 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
927 _ecore_xcb_reply_cache(reply);
928 } /* ecore_x_icccm_protocol_get_fetch */
931 * Set or unset a wm protocol property.
932 * @param window The Window
933 * @param protocol The protocol to enable/disable
936 * To use this function, you must call before, and in order,
937 * ecore_x_icccm_protocol_get_prefetch(), which sends the GetProperty request,
938 * then ecore_x_icccm_protocol_get_fetch(), which gets the reply.
939 * @ingroup Ecore_X_ICCCM_Group
942 ecore_x_icccm_protocol_set(Ecore_X_Window window,
943 Ecore_X_WM_Protocol protocol,
946 xcb_get_property_reply_t *reply;
947 Ecore_X_Atom *protos = NULL;
949 uint32_t protos_count = 0;
950 uint8_t already_set = 0;
952 /* Check for invalid values */
953 if (protocol >= ECORE_X_WM_PROTOCOL_NUM)
956 proto = _ecore_xcb_atoms_wm_protocols[protocol];
958 reply = _ecore_xcb_reply_get();
962 if ((reply->type == ECORE_X_ATOM_ATOM) && (reply->format == 32))
966 protos_count = reply->value_len / sizeof(Ecore_X_Atom);
967 protos = (Ecore_X_Atom *)xcb_get_property_value(reply);
968 for (i = 0; i < protos_count; i++)
970 if (protos[i] == proto)
980 Ecore_X_Atom *new_protos = NULL;
985 new_protos = (Ecore_X_Atom *)malloc((protos_count + 1) * sizeof(Ecore_X_Atom));
989 memcpy(new_protos, protos, reply->value_len);
990 new_protos[protos_count] = proto;
991 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
992 ECORE_X_ATOM_WM_PROTOCOLS,
993 ECORE_X_ATOM_ATOM, 32,
994 protos_count + 1, new_protos);
1004 for (i = 0; i < protos_count; i++)
1006 if (protos[i] == proto)
1010 for (j = i + 1; j < protos_count; j++)
1011 protos[j - 1] = protos[j];
1012 if (protos_count > 1)
1013 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
1014 ECORE_X_ATOM_WM_PROTOCOLS,
1015 ECORE_X_ATOM_ATOM, 32,
1016 protos_count - 1, protos);
1018 xcb_delete_property(_ecore_xcb_conn, window,
1019 ECORE_X_ATOM_WM_PROTOCOLS);
1025 } /* ecore_x_icccm_protocol_set */
1028 * Determines whether a protocol is set for a window.
1029 * @param window The Window (Unused).
1030 * @param protocol The protocol to query.
1031 * @return 1 if the protocol is set, else 0.
1033 * To use this function, you must call before, and in order,
1034 * ecore_x_icccm_protocol_get_prefetch(), which sends the GetProperty request,
1035 * then ecore_x_icccm_protocol_get_fetch(), which gets the reply.
1036 * @ingroup Ecore_X_ICCCM_Group
1039 ecore_x_icccm_protocol_isset(Ecore_X_Window window __UNUSED__,
1040 Ecore_X_WM_Protocol protocol)
1042 xcb_get_property_reply_t *reply;
1043 Ecore_X_Atom *protos = NULL;
1048 /* check for invalid values */
1049 if (protocol >= ECORE_X_WM_PROTOCOL_NUM)
1052 proto = _ecore_xcb_atoms_wm_protocols[protocol];
1054 reply = _ecore_xcb_reply_get();
1055 if (!reply || (reply->type != ECORE_X_ATOM_ATOM) || (reply->format != 32))
1060 protos = (Ecore_X_Atom *)xcb_get_property_value(reply);
1061 for (i = 0; i < reply->value_len; i++)
1062 if (protos[i] == proto)
1069 } /* ecore_x_icccm_protocol_isset */
1072 * Set a window name & class.
1073 * @param window The window
1074 * @param name The name string
1075 * @param class The class string
1077 * Set the name and class of @p window to respectively @p name and @p class.
1078 * @ingroup Ecore_X_ICCCM_Group
1081 ecore_x_icccm_name_class_set(Ecore_X_Window window,
1090 length_name = strlen(name);
1091 length_class = strlen(class);
1092 class_string = (char *)malloc(sizeof(char) * (length_name + length_class + 2));
1100 s += length_name + 1;
1110 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
1111 ECORE_X_ATOM_WM_CLASS, ECORE_X_ATOM_STRING, 8,
1112 length_name + length_class + 2, (void *)class_string);
1114 } /* ecore_x_icccm_name_class_set */
1117 * Sends the GetProperty request.
1118 * @ingroup Ecore_X_ICCCM_Group
1121 ecore_x_icccm_name_class_get_prefetch(Ecore_X_Window window)
1123 xcb_get_property_cookie_t cookie;
1125 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
1126 ECORE_X_ATOM_WM_CLASS,
1127 ECORE_X_ATOM_STRING,
1129 _ecore_xcb_cookie_cache(cookie.sequence);
1130 } /* ecore_x_icccm_name_class_get_prefetch */
1133 * Gets the reply of the GetProperty request sent by ecore_x_icccm_name_class_get_prefetch().
1134 * @ingroup Ecore_X_ICCCM_Group
1137 ecore_x_icccm_name_class_get_fetch(void)
1139 xcb_get_property_cookie_t cookie;
1140 xcb_get_property_reply_t *reply;
1142 cookie.sequence = _ecore_xcb_cookie_get();
1143 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1144 _ecore_xcb_reply_cache(reply);
1145 } /* ecore_x_icccm_name_class_get_fetch */
1148 * Get a window name and class.
1149 * @param window The window (Unused).
1150 * @param name The name string.
1151 * @param class The class string.
1153 * Store the name and class of @p window into respectively @p name and
1156 * To use this function, you must call before, and in order,
1157 * ecore_x_icccm_name_class_get_prefetch(), which sends the GetProperty request,
1158 * then ecore_x_icccm_name_class_get_fetch(), which gets the reply.
1159 * @ingroup Ecore_X_ICCCM_Group
1162 ecore_x_icccm_name_class_get(Ecore_X_Window window __UNUSED__,
1166 xcb_get_property_reply_t *reply;
1180 reply = _ecore_xcb_reply_get();
1184 if ((reply->type != ECORE_X_ATOM_STRING) ||
1185 (reply->format != 8))
1188 length = reply->value_len;
1189 data = xcb_get_property_value(reply);
1190 /* data contains the name string and the class string */
1191 /* separated by the NULL character. data is not NULL-terminated */
1192 length_name = strlen(data);
1193 n = (char *)malloc(sizeof(char) * (length_name + 1));
1197 length_class = length - length_name - 1;
1198 c = (char *)malloc(sizeof(char) * (length_class + 1));
1205 memcpy(n, data, length_name);
1206 n[length_name] = '\0';
1207 length_class = length - length_name - 1;
1208 data += length_name + 1;
1209 memcpy(c, data, length_class);
1210 c[length_class] = '\0';
1217 } /* ecore_x_icccm_name_class_get */
1220 * Sends the GetProperty request.
1221 * @ingroup Ecore_X_ICCCM_Group
1224 ecore_x_icccm_client_machine_get_prefetch(Ecore_X_Window window)
1226 xcb_get_property_cookie_t cookie;
1228 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0,
1229 window ? window : ((xcb_screen_t *)_ecore_xcb_screen)->root,
1230 ECORE_X_ATOM_WM_CLIENT_MACHINE,
1231 XCB_GET_PROPERTY_TYPE_ANY,
1233 _ecore_xcb_cookie_cache(cookie.sequence);
1234 } /* ecore_x_icccm_client_machine_get_prefetch */
1237 * Gets the reply of the GetProperty request sent by ecore_x_icccm_client_machine_get_prefetch().
1238 * @ingroup Ecore_X_ICCCM_Group
1241 ecore_x_icccm_client_machine_get_fetch(void)
1243 xcb_get_property_cookie_t cookie;
1244 xcb_get_property_reply_t *reply;
1246 cookie.sequence = _ecore_xcb_cookie_get();
1247 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1248 _ecore_xcb_reply_cache(reply);
1249 } /* ecore_x_icccm_client_machine_get_fetch */
1252 * Get a window client machine string.
1253 * @param window The window
1254 * @return The windows client machine string
1256 * Return the client machine of a window. String must be free'd when done with.
1258 * To use this function, you must call before, and in order,
1259 * ecore_x_icccm_client_machine_get_prefetch(), which sends the GetProperty request,
1260 * then ecore_x_icccm_client_machine_get_fetch(), which gets the reply.
1261 * @ingroup Ecore_X_ICCCM_Group
1264 ecore_x_icccm_client_machine_get(Ecore_X_Window window)
1268 name = ecore_x_window_prop_string_get(window, ECORE_X_ATOM_WM_CLIENT_MACHINE);
1270 } /* ecore_x_icccm_client_machine_get */
1273 * Sets the WM_COMMAND property for @a win.
1275 * @param window The window.
1276 * @param argc Number of arguments.
1277 * @param argv Arguments.
1278 * @ingroup Ecore_X_ICCCM_Group
1281 ecore_x_icccm_command_set(Ecore_X_Window window,
1290 for (i = 0, nbytes = 0; i < argc; i++)
1292 nbytes += strlen(argv[i]) + 1;
1294 buf = malloc(sizeof(char) * nbytes);
1299 for (i = 0; i < argc; i++)
1304 b += strlen(argv[i]) + 1;
1309 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
1310 ECORE_X_ATOM_WM_COMMAND, ECORE_X_ATOM_STRING, 8,
1313 } /* ecore_x_icccm_command_set */
1316 * Sends the GetProperty request.
1317 * @ingroup Ecore_X_ICCCM_Group
1320 ecore_x_icccm_command_get_prefetch(Ecore_X_Window window)
1322 xcb_get_property_cookie_t cookie;
1324 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
1325 ECORE_X_ATOM_WM_COMMAND,
1326 XCB_GET_PROPERTY_TYPE_ANY,
1328 _ecore_xcb_cookie_cache(cookie.sequence);
1329 } /* ecore_x_icccm_command_get_prefetch */
1332 * Gets the reply of the GetProperty request sent by ecore_x_icccm_command_get_prefetch().
1333 * @ingroup Ecore_X_ICCCM_Group
1336 ecore_x_icccm_command_get_fetch(void)
1338 xcb_get_property_cookie_t cookie;
1339 xcb_get_property_reply_t *reply;
1341 cookie.sequence = _ecore_xcb_cookie_get();
1342 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1343 _ecore_xcb_reply_cache(reply);
1344 } /* ecore_x_icccm_command_get_fetch */
1347 * Get the WM_COMMAND property for a window.
1349 * @param win The window.
1350 * @param argc Number of arguments.
1351 * @param argv Arguments.
1353 * Return the command of @p window and store it in @p argv. @p argc
1354 * contains the number of arguments. String must be free'd when done with.
1356 * To use this function, you must call before, and in order,
1357 * ecore_x_icccm_command_get_prefetch(), which sends the GetProperty request,
1358 * then ecore_x_icccm_command_get_fetch(), which gets the reply.
1359 * @ingroup Ecore_X_ICCCM_Group
1362 ecore_x_icccm_command_get(Ecore_X_Window window __UNUSED__,
1366 xcb_get_property_reply_t *reply;
1382 reply = _ecore_xcb_reply_get();
1386 if ((reply->type != ECORE_X_ATOM_STRING) ||
1387 (reply->format != 8))
1390 value_len = reply->value_len;
1391 data = (char *)xcb_get_property_value(reply);
1392 if (value_len && (data[value_len - 1] == '\0'))
1396 for (cp = (char *)data, i = value_len; i > 0; cp++, i--)
1401 v = (char **)malloc((c + 1) * sizeof(char *));
1405 start = (char *)malloc((value_len + 1) * sizeof(char));
1412 memcpy (start, (char *)data, value_len);
1413 start[value_len] = '\0';
1414 for (cp = start, i = value_len + 1, j = 0; i > 0; cp++, i--) {
1434 (*argv) = malloc(c * sizeof(char *));
1444 for (i = 0; i < c; i++)
1447 (*argv)[i] = strdup(v[i]);
1449 (*argv)[i] = strdup("");
1454 } /* ecore_x_icccm_command_get */
1457 * Set a window icon name.
1458 * @param window The window.
1459 * @param title The icon name string.
1461 * Set @p window icon name.
1462 * @ingroup Ecore_X_ICCCM_Group
1465 ecore_x_icccm_icon_name_set(Ecore_X_Window window,
1468 /* FIXME: do the UTF8 conversion... */
1470 /* #ifdef X_HAVE_UTF8_STRING */
1471 /* list[0] = strdup(t); */
1472 /* ret = Xutf8TextListToTextProperty(_ecore_xcb_conn, list, 1, */
1473 /* XUTF8StringStyle, &xprop); */
1475 /* list[0] = strdup(t); */
1476 /* ret = XmbTextListToTextProperty(_ecore_xcb_conn, list, 1, */
1477 /* XStdICCTextStyle, &xprop); */
1480 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
1481 ECORE_X_ATOM_WM_ICON_NAME, ECORE_X_ATOM_WM_ICON_NAME,
1482 8, strlen(title), title);
1483 } /* ecore_x_icccm_icon_name_set */
1486 * Sends the GetProperty request.
1487 * @ingroup Ecore_X_ICCCM_Group
1490 ecore_x_icccm_icon_name_get_prefetch(Ecore_X_Window window)
1492 xcb_get_property_cookie_t cookie;
1494 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
1495 ECORE_X_ATOM_WM_ICON_NAME,
1496 XCB_GET_PROPERTY_TYPE_ANY,
1498 _ecore_xcb_cookie_cache(cookie.sequence);
1499 } /* ecore_x_icccm_icon_name_get_prefetch */
1502 * Gets the reply of the GetProperty request sent by ecore_x_icccm_icon_name_get_prefetch().
1503 * @ingroup Ecore_X_ICCCM_Group
1506 ecore_x_icccm_icon_name_get_fetch(void)
1508 xcb_get_property_cookie_t cookie;
1509 xcb_get_property_reply_t *reply;
1511 cookie.sequence = _ecore_xcb_cookie_get();
1512 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1513 _ecore_xcb_reply_cache(reply);
1514 } /* ecore_x_icccm_icon_name_get_fetch */
1517 * Get a window icon name.
1518 * @param window The window.
1519 * @return The windows icon name string.
1521 * Return the icon name of @p window. String must be free'd when done with.
1523 * To use this function, you must call before, and in order,
1524 * ecore_x_icccm_icon_name_get_prefetch(), which sends the GetProperty request,
1525 * then ecore_x_icccm_icon_name_get_fetch(), which gets the reply.
1526 * @ingroup Ecore_X_ICCCM_Group
1529 ecore_x_icccm_icon_name_get(Ecore_X_Window window __UNUSED__)
1531 xcb_get_property_reply_t *reply;
1534 reply = _ecore_xcb_reply_get();
1538 ERR("reply->bytes_afer (should be 0): %d", ((xcb_get_property_reply_t *)reply)->bytes_after);
1540 if (reply->type == ECORE_X_ATOM_UTF8_STRING)
1544 /* FIXME: verify the value of length */
1545 length = reply->value_len * reply->format / 8;
1546 title = (char *)malloc((length + 1) * sizeof(char));
1547 memcpy(title, xcb_get_property_value(reply), length);
1548 title[length] = '\0';
1550 /* not in UTF8, so we convert */
1553 /* FIXME: do the UTF8... */
1555 /* convert to utf8 */
1556 /* #ifdef X_HAVE_UTF8_STRING */
1557 /* ret = Xutf8TextPropertyToTextList(_ecore_xcb_conn, &xprop, */
1560 /* ret = XmbTextPropertyToTextList(_ecore_xcb_conn, &xprop, */
1564 /* if ((ret == XLocaleNotSupported) || */
1565 /* (ret == XNoMemory) || (ret == XConverterNotFound)) */
1567 /* t = strdup((char *)xprop.value); */
1569 /* else if (ret >= Success) */
1571 /* if ((num >= 1) && (list)) */
1573 /* t = strdup(list[0]); */
1576 /* XFreeStringList(list); */
1580 /* if (xprop.value) XFree(xprop.value); */
1584 } /* ecore_x_icccm_icon_name_get */
1587 * Sends the GetProperty request.
1588 * @ingroup Ecore_X_ICCCM_Group
1591 ecore_x_icccm_colormap_window_get_prefetch(Ecore_X_Window window)
1593 xcb_get_property_cookie_t cookie;
1595 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0,
1596 window ? ((xcb_screen_t *)_ecore_xcb_screen)->root : window,
1597 ECORE_X_ATOM_WM_COLORMAP_WINDOWS,
1598 ECORE_X_ATOM_WINDOW,
1600 _ecore_xcb_cookie_cache(cookie.sequence);
1601 } /* ecore_x_icccm_colormap_window_get_prefetch */
1604 * Gets the reply of the GetProperty request sent by ecore_x_icccm_colormap_window_get_prefetch().
1605 * @ingroup Ecore_X_ICCCM_Group
1608 ecore_x_icccm_colormap_window_get_fetch(void)
1610 xcb_get_property_cookie_t cookie;
1611 xcb_get_property_reply_t *reply;
1613 cookie.sequence = _ecore_xcb_cookie_get();
1614 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1615 _ecore_xcb_reply_cache(reply);
1616 } /* ecore_x_icccm_colormap_window_get_fetch */
1619 * Add a subwindow to the list of windows that need a different colormap installed.
1620 * @param window The toplevel window
1621 * @param sub_window The subwindow to be added to the colormap windows list
1623 * Add @p sub_window to the list of windows that need a different
1624 * colormap installed.
1626 * To use this function, you must call before, and in order,
1627 * ecore_x_icccm_colormap_window_get_prefetch(), which sends the GetProperty request,
1628 * then ecore_x_icccm_colormap_window_get_fetch(), which gets the reply.
1629 * @ingroup Ecore_X_ICCCM_Group
1632 ecore_x_icccm_colormap_window_set(Ecore_X_Window window,
1633 Ecore_X_Window sub_window)
1636 xcb_get_property_reply_t *reply;
1640 window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1642 reply = _ecore_xcb_reply_get();
1643 if (!reply || (reply->format != 32) || (reply->value_len == 0))
1645 data = calloc(1, sizeof(Ecore_X_Window));
1658 Ecore_X_Window *newset = NULL;
1659 Ecore_X_Window *oldset = NULL;
1662 num = reply->value_len;
1663 data = calloc(num + 1, sizeof(Ecore_X_Window));
1667 newset = (Ecore_X_Window *)data;
1668 oldset = (Ecore_X_Window *)xcb_get_property_value(reply);
1669 for (i = 0; i < num; ++i)
1671 if (oldset[i] == sub_window)
1677 newset[i] = oldset[i];
1680 newset[num++] = sub_window;
1683 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
1684 ECORE_X_ATOM_WM_COLORMAP_WINDOWS,
1685 ECORE_X_ATOM_WINDOW,
1688 } /* ecore_x_icccm_colormap_window_set */
1691 * Remove a window from the list of colormap windows.
1692 * @param window The toplevel window
1693 * @param sub_window The window to be removed from the colormap window list.
1695 * Remove @p sub_window from the list of colormap windows.
1697 * To use this function, you must call before, and in order,
1698 * ecore_x_icccm_colormap_window_get_prefetch(), which sends the GetProperty request,
1699 * then ecore_x_icccm_colormap_window_get_fetch(), which gets the reply.
1700 * @ingroup Ecore_X_ICCCM_Group
1703 ecore_x_icccm_colormap_window_unset(Ecore_X_Window window,
1704 Ecore_X_Window sub_window)
1707 Ecore_X_Window *oldset = NULL;
1708 Ecore_X_Window *newset = NULL;
1709 xcb_get_property_reply_t *reply;
1716 window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1718 reply = _ecore_xcb_reply_get();
1719 if (!reply || (reply->format != 32) || (reply->value_len == 0))
1722 num = reply->value_len;
1723 oldset = (Ecore_X_Window *)xcb_get_property_value(reply);
1724 for (i = 0; i < num; i++)
1726 if (oldset[i] == sub_window)
1730 xcb_delete_property(_ecore_xcb_conn, window,
1731 ECORE_X_ATOM_WM_COLORMAP_WINDOWS);
1736 data = calloc(num - 1, sizeof(Ecore_X_Window));
1737 newset = (Ecore_X_Window *)data;
1738 for (j = 0; j < num; ++j)
1739 if (oldset[j] != sub_window)
1740 newset[k++] = oldset[j];
1742 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
1743 ECORE_X_ATOM_WM_COLORMAP_WINDOWS,
1744 ECORE_X_ATOM_WINDOW,
1751 } /* ecore_x_icccm_colormap_window_unset */
1754 * Specify that a window is transient for another top-level window and should be handled accordingly.
1755 * @param window The transient window
1756 * @param forwindow The toplevel window
1757 * @ingroup Ecore_X_ICCCM_Group
1760 ecore_x_icccm_transient_for_set(Ecore_X_Window window,
1761 Ecore_X_Window forwindow)
1763 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
1764 ECORE_X_ATOM_WM_TRANSIENT_FOR, ECORE_X_ATOM_WINDOW, 32,
1765 1, (void *)&forwindow);
1766 } /* ecore_x_icccm_transient_for_set */
1769 * Remove the transient_for setting from a window.
1770 * @param window The window.
1771 * @ingroup Ecore_X_ICCCM_Group
1774 ecore_x_icccm_transient_for_unset(Ecore_X_Window window)
1776 xcb_delete_property(_ecore_xcb_conn, window, ECORE_X_ATOM_WM_TRANSIENT_FOR);
1777 } /* ecore_x_icccm_transient_for_unset */
1780 * Sends the GetProperty request.
1781 * @ingroup Ecore_X_ICCCM_Group
1784 ecore_x_icccm_transient_for_get_prefetch(Ecore_X_Window window)
1786 xcb_get_property_cookie_t cookie;
1788 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
1789 ECORE_X_ATOM_WM_TRANSIENT_FOR,
1790 ECORE_X_ATOM_WINDOW,
1792 _ecore_xcb_cookie_cache(cookie.sequence);
1793 } /* ecore_x_icccm_transient_for_get_prefetch */
1796 * Gets the reply of the GetProperty request sent by ecore_x_icccm_transient_for_get_prefetch().
1797 * @ingroup Ecore_X_ICCCM_Group
1800 ecore_x_icccm_transient_for_get_fetch(void)
1802 xcb_get_property_cookie_t cookie;
1803 xcb_get_property_reply_t *reply;
1805 cookie.sequence = _ecore_xcb_cookie_get();
1806 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1807 _ecore_xcb_reply_cache(reply);
1808 } /* ecore_x_icccm_transient_for_get_fetch */
1811 * Get the window this window is transient for, if any.
1812 * @param window The window to check (Unused).
1813 * @return The window ID of the top-level window, or 0 if the property does not exist.
1815 * To use this function, you must call before, and in order,
1816 * ecore_x_icccm_transient_for_get_prefetch(), which sends the GetProperty request,
1817 * then ecore_x_icccm_transient_for_get_fetch(), which gets the reply.
1818 * @ingroup Ecore_X_ICCCM_Group
1821 ecore_x_icccm_transient_for_get(Ecore_X_Window window __UNUSED__)
1823 xcb_get_property_reply_t *reply;
1824 Ecore_X_Window forwin = 0;
1826 reply = _ecore_xcb_reply_get();
1830 if ((reply->format != 32) ||
1831 (reply->value_len == 0) ||
1832 (reply->type != ECORE_X_ATOM_WINDOW))
1835 forwin = *(Ecore_X_Window *)xcb_get_property_value(reply);
1838 } /* ecore_x_icccm_transient_for_get */
1841 * Set the window role hint.
1842 * @param window The window
1843 * @param role The role string.
1844 * @ingroup Ecore_X_ICCCM_Group
1847 ecore_x_icccm_window_role_set(Ecore_X_Window window,
1850 ecore_x_window_prop_string_set(window, ECORE_X_ATOM_WM_WINDOW_ROLE,
1852 } /* ecore_x_icccm_window_role_set */
1855 * Sends the GetProperty request.
1856 * @param window Window whose properties are requested.
1857 * @ingroup Ecore_X_ICCCM_Group
1860 ecore_x_icccm_window_role_get_prefetch(Ecore_X_Window window)
1862 xcb_get_property_cookie_t cookie;
1864 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0,
1865 window ? window : ((xcb_screen_t *)_ecore_xcb_screen)->root,
1866 ECORE_X_ATOM_WM_WINDOW_ROLE, XCB_GET_PROPERTY_TYPE_ANY,
1868 _ecore_xcb_cookie_cache(cookie.sequence);
1869 } /* ecore_x_icccm_window_role_get_prefetch */
1872 * Gets the reply of the GetProperty request sent by ecore_x_icccm_window_role_get_prefetch().
1873 * @ingroup Ecore_X_ICCCM_Group
1876 ecore_x_icccm_window_role_get_fetch(void)
1878 xcb_get_property_cookie_t cookie;
1879 xcb_get_property_reply_t *reply;
1881 cookie.sequence = _ecore_xcb_cookie_get();
1882 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1883 _ecore_xcb_reply_cache(reply);
1884 } /* ecore_x_icccm_window_role_get_fetch */
1887 * Get the window role.
1888 * @param window The window.
1889 * @return The window's role string.
1891 * To use this function, you must call before, and in order,
1892 * ecore_x_icccm_window_role_get_prefetch(), which sends the GetProperty request,
1893 * then ecore_x_icccm_window_role_get_fetch(), which gets the reply.
1894 * @ingroup Ecore_X_ICCCM_Group
1897 ecore_x_icccm_window_role_get(Ecore_X_Window window)
1899 return ecore_x_window_prop_string_get(window, ECORE_X_ATOM_WM_WINDOW_ROLE);
1900 } /* ecore_x_icccm_window_role_get */
1903 * Set the window's client leader.
1904 * @param window The window
1905 * @param leader The client leader window
1907 * All non-transient top-level windows created by an app other than
1908 * the main window must have this property set to the app's main window.
1909 * @ingroup Ecore_X_ICCCM_Group
1912 ecore_x_icccm_client_leader_set(Ecore_X_Window window,
1913 Ecore_X_Window leader)
1915 ecore_x_window_prop_window_set(window, ECORE_X_ATOM_WM_CLIENT_LEADER,
1917 } /* ecore_x_icccm_client_leader_set */
1920 * Sends the GetProperty request.
1921 * @param window Window whose properties are requested.
1922 * @ingroup Ecore_X_ICCCM_Group
1925 ecore_x_icccm_client_leader_get_prefetch(Ecore_X_Window window)
1927 xcb_get_property_cookie_t cookie;
1929 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0,
1931 ECORE_X_ATOM_WM_CLIENT_LEADER,
1932 ECORE_X_ATOM_WINDOW,
1934 _ecore_xcb_cookie_cache(cookie.sequence);
1935 } /* ecore_x_icccm_client_leader_get_prefetch */
1938 * Gets the reply of the GetProperty request sent by ecore_x_icccm_client_leader_get_prefetch().
1939 * @ingroup Ecore_X_ICCCM_Group
1942 ecore_x_icccm_client_leader_get_fetch(void)
1944 xcb_get_property_cookie_t cookie;
1945 xcb_get_property_reply_t *reply;
1947 cookie.sequence = _ecore_xcb_cookie_get();
1948 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1949 _ecore_xcb_reply_cache(reply);
1950 } /* ecore_x_icccm_client_leader_get_fetch */
1953 * Get the window's client leader.
1954 * @param window The window
1955 * @return The window's client leader window, or 0 if unset.
1957 * To use this function, you must call before, and in order,
1958 * ecore_x_icccm_client_leader_get_prefetch(), which sends the GetProperty request,
1959 * then ecore_x_icccm_client_leader_get_fetch(), which gets the reply.
1960 * @ingroup Ecore_X_ICCCM_Group
1963 ecore_x_icccm_client_leader_get(Ecore_X_Window window)
1965 Ecore_X_Window leader;
1967 if (ecore_x_window_prop_window_get(window, ECORE_X_ATOM_WM_CLIENT_LEADER,
1972 } /* ecore_x_icccm_client_leader_get */
1975 * Send the ClientMessage event with the ChangeState property.
1976 * @param window The window.
1977 * @param root The root window.
1978 * @ingroup Ecore_X_ICCCM_Group
1981 ecore_x_icccm_iconic_request_send(Ecore_X_Window window,
1982 Ecore_X_Window root)
1984 xcb_client_message_event_t ev;
1990 root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1992 /* send_event is bit 7 (0x80) of response_type */
1993 ev.response_type = XCB_CLIENT_MESSAGE | 0x80;
1997 ev.type = ECORE_X_ATOM_WM_CHANGE_STATE;
1998 ev.data.data32[0] = XCB_WM_STATE_ICONIC;
2000 xcb_send_event(_ecore_xcb_conn, 0, root,
2001 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT,
2003 } /* ecore_x_icccm_iconic_request_send */
2005 /* FIXME: there are older E hints, gnome hints and mwm hints and new netwm */
2006 /* hints. each should go in their own file/section so we know which */
2007 /* is which. also older kde hints too. we should try support as much */
2008 /* as makese sense to support */