2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
6 * _NET_WM... aka Extended Window Manager Hint (EWMH) functions.
9 #include "Ecore_Data.h"
10 #include "ecore_xcb_private.h"
11 #include "Ecore_X_Atoms.h"
15 * @defgroup Ecore_X_NetWM_Group Extended Window Manager Hint (EWMH) functions
17 * Functions related to the Extended Window Manager Hint (EWMH).
21 typedef struct _Ecore_X_Startup_Info Ecore_X_Startup_Info;
23 struct _Ecore_X_Startup_Info
34 /* These are the sequence info fields */
48 static void _ecore_x_window_prop_string_utf8_get_prefetch(Ecore_X_Window window, Ecore_X_Atom atom);
49 static void _ecore_x_window_prop_string_utf8_get_fetch(void);
51 static void _ecore_x_window_prop_string_utf8_set(Ecore_X_Window window, Ecore_X_Atom atom, const char *str);
52 static char *_ecore_x_window_prop_string_utf8_get(Ecore_X_Window window, Ecore_X_Atom atom);
54 static int _ecore_x_netwm_startup_info_process(Ecore_X_Startup_Info *info);
55 static int _ecore_x_netwm_startup_info_parse(Ecore_X_Startup_Info *info, char *data);
57 static void _ecore_x_netwm_startup_info_free(void *data);
63 static Ecore_Hash *startup_info = NULL;
66 * Initialize the NetWM module
69 ecore_x_netwm_init(void)
71 startup_info = ecore_hash_new(ecore_direct_hash, ecore_direct_compare);
74 ecore_hash_free_value_cb_set(startup_info, _ecore_x_netwm_startup_info_free);
79 * Shutdown the NetWM module
82 ecore_x_netwm_shutdown(void)
85 ecore_hash_destroy(startup_info);
90 * Set the _NET_SUPPORTING_WM_CHECK property.
91 * @param root The root window.
92 * @param check The child window.
93 * @param wm_name The name of the Window Manager.
95 * Set the _NET_SUPPORTING_WM_CHECK property on the @p root window to be
96 * the ID of the child window @p check created by the Window Manager.
97 * @p check also have the _NET_WM_NAME property set to the name
98 * @p wm_name of the Window Manager.
100 * The Window MUST call that function to indicate that a compliant
101 * window manager is active.
102 * @ingroup Ecore_X_NetWM_Group
105 ecore_x_netwm_wm_identify(Ecore_X_Window root,
106 Ecore_X_Window check,
109 ecore_x_window_prop_window_set(root, ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK, &check, 1);
110 ecore_x_window_prop_window_set(check, ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK, &check, 1);
111 _ecore_x_window_prop_string_utf8_set(check, ECORE_X_ATOM_NET_WM_NAME, wm_name);
112 /* This one isn't mandatory */
113 _ecore_x_window_prop_string_utf8_set(root, ECORE_X_ATOM_NET_WM_NAME, wm_name);
117 * Set the _NET_SUPPORTED property.
118 * @param root The root window.
119 * @param supported The supported hints.
120 * @param num The number of hints.
122 * Set the _NET_SUPPORTED property on the @p root window. The hints
123 * that the Window Manager supports are stored in @p supported.
125 * The Window Manager MUST set this property to indicate which hints
127 * @ingroup Ecore_X_NetWM_Group
130 ecore_x_netwm_supported_set(Ecore_X_Window root,
131 Ecore_X_Atom *supported,
134 ecore_x_window_prop_atom_set(root, ECORE_X_ATOM_NET_SUPPORTED, supported, num);
138 * Sends the GetProperty request.
139 * @param root The root window
140 * @ingroup Ecore_X_NetWM_Group
143 ecore_x_netwm_supported_get_prefetch(Ecore_X_Window root)
145 xcb_get_property_cookie_t cookie;
147 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, root,
148 ECORE_X_ATOM_NET_SUPPORTED, ECORE_X_ATOM_ATOM,
150 _ecore_xcb_cookie_cache(cookie.sequence);
154 * Gets the reply of the GetProperty request sent by ecore_x_netwm_supported_get_prefetch().
155 * @ingroup Ecore_X_NetWM_Group
158 ecore_x_netwm_supported_get_fetch(void)
160 xcb_get_property_cookie_t cookie;
161 xcb_get_property_reply_t *reply;
163 cookie.sequence = _ecore_xcb_cookie_get();
164 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
165 _ecore_xcb_reply_cache(reply);
169 * Get the hints supported by the Window Manager.
170 * @param root The root window.
171 * @param supported The supported hints.
172 * @param num The number of atoms.
173 * @return 1 on success, 0 otherwise.
175 * Get the hints supported by the Window Manager. @p root is the root
176 * window. The hints are stored in @p supported. The number of hints
177 * is stored in @p num.
179 * To use this function, you must call before, and in order,
180 * ecore_x_netwm_supported_get_prefetch(), which sends the GetProperty request,
181 * then ecore_x_netwm_supported_get_fetch(), which gets the reply.
182 * @ingroup Ecore_X_NetWM_Group
185 ecore_x_netwm_supported_get(Ecore_X_Window root,
186 Ecore_X_Atom **supported,
192 if (supported) *supported = NULL;
194 num_ret = ecore_x_window_prop_xid_list_get(root,
195 ECORE_X_ATOM_NET_SUPPORTED,
201 if (num) *num = (uint32_t)num_ret;
206 * Set the _NET_NUMBER_OF_DESKTOPS property.
207 * @param root The root window.
208 * @param n_desks The number of desktops.
210 * Set the number of desktops @p n_desks of the Window Manager by
211 * sending the _NET_NUMBER_OF_DESKTOPS to the @p root window.
213 * The Window Manager SHOULD set and update this property to indicate
214 * the number of virtual desktops. A Pager can request a change in the
215 * number of desktops by using that function.
216 * @ingroup Ecore_X_NetWM_Group
219 ecore_x_netwm_desk_count_set(Ecore_X_Window root,
220 unsigned int n_desks)
222 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_NUMBER_OF_DESKTOPS,
227 * Set the _NET_VIRTUAL_ROOTS property.
228 * @param root The root window.
229 * @param vroots The virtual root windows.
230 * @param n_desks The number of desks.
232 * Set the number of virtual desktops by sending the
233 * _NET_VIRTUAL_ROOTS property to the @p root window. @p vroots is an
234 * array of window and @p n_desks is the number of windows.
236 * A Window Manager that implements virtual desktops by reparent
237 * client windows to a child of the root window MUST use that
239 * @ingroup Ecore_X_NetWM_Group
242 ecore_x_netwm_desk_roots_set(Ecore_X_Window root,
243 Ecore_X_Window *vroots,
244 unsigned int n_desks)
246 ecore_x_window_prop_window_set(root, ECORE_X_ATOM_NET_VIRTUAL_ROOTS, vroots, n_desks);
250 * Set the _NET_DESKTOP_NAMES property.
251 * @param root The root window.
252 * @param names The names of the virtual desktops.
253 * @param n_desks The number of virtual desktops.
255 * Set the name of each virtual desktop by sending the
256 * _NET_DESKTOP_NAMES to the @p root window. @p names are the names of
257 * the virtual desktops and @p n_desks is the number of virtual
260 * A Pager MAY use that function. @p n_desks may be different from the
261 * one passed to ecore_x_netwm_desk_count_set(). If it less or equal,
262 * then the desktops with high numbers are unnamed. If it is larger,
263 * then the excess names are considered to be reserved in case the
264 * number of desktops is increased.
265 * @ingroup Ecore_X_NetWM_Group
268 ecore_x_netwm_desk_names_set(Ecore_X_Window root,
270 unsigned int n_desks)
282 for (i = 0; i < n_desks; i++)
284 s = (names) ? names[i] : NULL;
287 /* Default to "Desk-<number>" */
288 sprintf(ss, "Desk-%d", i);
293 buf = realloc(buf, len + l);
294 memcpy(buf + len, s, l);
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,
301 8, len, (const void *)buf);
306 * Set the _NET_DESKTOP_GEOMETRY property.
307 * @param root The root window.
308 * @param width The width of the desktop.
309 * @param height The height of the desktop.
311 * Set the common @p width and @p height of all desktops by sending
312 * the _NET_DESKTOP_GEOMETRY to the @p root window.
314 * This size is equal to the screen size if the Window Manager doesn't
315 * support large desktops, otherwise it's equal to the virtual size of
316 * the desktop. The Window Manager SHOULD set this property. A Pager
317 * can request a change in the desktop geometry by using this
319 * @ingroup Ecore_X_NetWM_Group
322 ecore_x_netwm_desk_size_set(Ecore_X_Window root,
330 ecore_x_window_prop_card32_set(root,
331 ECORE_X_ATOM_NET_DESKTOP_GEOMETRY,
336 * Set the _NET_DESKTOP_VIEWPORT property.
337 * @param root The root window.
338 * @param origins An array of paris of coordiantes.
339 * @param n_desks The number of virtual desktops.
341 * Set the top left corner of each desktop's viewport by sending the
342 * _NET_DESKTOP_VIEWPORT property to the @p root window. @p origins
343 * contains each pair of X coordinate and Y coordinate of the top left
344 * corner of each desktop's viewport.
346 * If the Window Manager does not support large desktops, the
347 * coordinates MUST be (0,0). A Pager can request to change the
348 * viewport for the current desktop by using this function.
349 * @ingroup Ecore_X_NetWM_Group
352 ecore_x_netwm_desk_viewports_set(Ecore_X_Window root,
353 unsigned int *origins,
354 unsigned int n_desks)
356 ecore_x_window_prop_card32_set(root,
357 ECORE_X_ATOM_NET_DESKTOP_VIEWPORT,
358 origins, 2 * n_desks);
362 * Set the _NET_DESKTOP_LAYOUT property.
363 * @param root The root window.
367 * @param starting_corner
369 * Set the layout of virtual desktops relative to each other by
370 * sending the _NET_DESKTOP_LAYOUT to the @p root window.
371 * @p orientation defines the orientation of the virtual desktop. 0
372 * means horizontal layout, 1 means vertical layout. @p columns is
373 * the number of desktops in the X direction and @p rows is the number
374 * in the Y direction. @p starting_corner is the corner containing the
375 * first desktop. The values for @p starting_corner are 0 (top-left),
376 * 1 (top-right), 2 (bottom-right) and 3 (bottom-left).
378 * When the orientation is horizontal the desktops are laid out in
379 * rows, with the first desktop in the specified starting corner. So a
380 * layout with four columns and three rows starting in
381 * the top-left corner looks like this:
391 * With @p starting_corner being bottom-right, it looks like this:
401 * When the orientation is vertical the layout with four columns and
402 * three rows starting in the top-left corner looks like:
412 * With @p starting_corner being top-right, it looks like:
422 * This function MUST be used by a Pager and NOT by the Window
423 * Manager. When using this function, the Pager must own a manager
425 * @ingroup Ecore_X_NetWM_Group
428 ecore_x_netwm_desk_layout_set(Ecore_X_Window root,
436 layout[0] = orientation;
439 layout[3] = starting_corner;
440 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_DESKTOP_LAYOUT, layout, 4);
444 * Set the _NET_WORKAREA property.
445 * @param root The root window.
446 * @param areas An array of areas.
447 * @param n_desks The number of desks.
449 * Set the work area for each desktop by sending the _NET_WORKAREA
450 * property to the @p root window. An area contains the geometry (X
451 * and Y coordinates, width and height). These geometries are
452 * specified relative to the viewport on each desktop and specify an
453 * area that is completely contained within the viewport. @p areas
454 * stores these geometries. @p n_desks is the number of geometry to
457 * This function MUST be set by the Window Manager. It is used by
458 * desktop applications to place desktop icons appropriately.
459 * @ingroup Ecore_X_NetWM_Group
462 ecore_x_netwm_desk_workareas_set(Ecore_X_Window root,
464 unsigned int n_desks)
466 ecore_x_window_prop_card32_set(root,
467 ECORE_X_ATOM_NET_WORKAREA,
472 * Set the _NET_CURRENT_DESKTOP property.
473 * @param root The root window.
474 * @param desk The index of the current desktop.
476 * Set the current desktop by sending the _NET_CURRENT_DESKTOP to the
477 * @p root window. @p deskmust be an integer number between 0 and the
478 * number of desks (set by ecore_x_netwm_desk_count_set()) -1.
480 * This function MUST be called by the Window Manager. If a Pagerwants
481 * to switch to naother desktop, it MUST call that function.
482 * @ingroup Ecore_X_NetWM_Group
485 ecore_x_netwm_desk_current_set(Ecore_X_Window root,
488 ecore_x_window_prop_card32_set(root,
489 ECORE_X_ATOM_NET_CURRENT_DESKTOP,
494 * Set the _NET_SHOWING_DESKTOP property.
495 * @param root The root window
496 * @param on 0 to hide the desktop, non 0 to show it.
498 * Set or unset the desktop in a "showing mode" by sending the
499 * _NET_SHOWING_DESKTOP property to the @p root window. If @p on is 0,
500 * the windows are hidden and the desktop background is displayed and
503 * If a Pager wants to enter or leave the mode, it MUST use this
505 * @ingroup Ecore_X_NetWM_Group
508 ecore_x_netwm_showing_desktop_set(Ecore_X_Window root,
514 ecore_x_window_prop_card32_set(root,
515 ECORE_X_ATOM_NET_SHOWING_DESKTOP,
524 * Set the _NET_CLIENT_LIST property.
525 * @param root The root window.
526 * @param p_clients An array of windows.
527 * @param n_clients The number of windows.
529 * Map all the X windows managed by the window manager from the oldest
530 * to the newest by sending the _NET_CLIENT_LIST property to the
531 * @p root window. The X windows are stored in @p p_clients and their
532 * number in @p n_clients.
534 * This function SHOULD be called by the Window Manager.
535 * @ingroup Ecore_X_NetWM_Group
538 ecore_x_netwm_client_list_set(Ecore_X_Window root,
539 Ecore_X_Window *p_clients,
540 unsigned int n_clients)
542 ecore_x_window_prop_window_set(root,
543 ECORE_X_ATOM_NET_CLIENT_LIST,
544 p_clients, n_clients);
548 * Set the _NET_CLIENT_LIST_STACKING property.
549 * @param root The root window.
550 * @param p_clients An array of windows.
551 * @param n_clients The number of windows.
553 * Stack all the X windows managed by the window manager from bottom
554 * to top order by sending the _NET_CLIENT_LIST_STACKING property to the
555 * @p root window. The X windows are stored in @p p_clients and their
556 * number in @p n_clients.
558 * This function SHOULD be called by the Window Manager.
559 * @ingroup Ecore_X_NetWM_Group
562 ecore_x_netwm_client_list_stacking_set(Ecore_X_Window root,
563 Ecore_X_Window *p_clients,
564 unsigned int n_clients)
566 ecore_x_window_prop_window_set(root,
567 ECORE_X_ATOM_NET_CLIENT_LIST_STACKING,
568 p_clients, n_clients);
572 * Set the _NET_ACTIVE_WINDOW property.
573 * @param root The root window.
574 * @param window The widow to activate.
576 * Activate @p window by sending the _NET_ACTIVE_WINDOW property to
577 * the @p root window.
579 * If a Client wants to activate another window, it MUST call this
581 * @ingroup Ecore_X_NetWM_Group
584 ecore_x_netwm_client_active_set(Ecore_X_Window root,
585 Ecore_X_Window window)
587 ecore_x_window_prop_window_set(root,
588 ECORE_X_ATOM_NET_ACTIVE_WINDOW,
593 * Set the _NET_WM_NAME property.
594 * @param window The widow to activate.
595 * @param name The title name of the window.
597 * Set the title name of @p window to @p name by sending the
598 * _NET_WM_NAME property to @p window.
600 * The Client SHOULD set the title of @p window in UTF-8 encoding. If
601 * set, the Window Manager should use this in preference to WM_NAME.
602 * @ingroup Ecore_X_NetWM_Group
605 ecore_x_netwm_name_set(Ecore_X_Window window,
608 _ecore_x_window_prop_string_utf8_set(window, ECORE_X_ATOM_NET_WM_NAME, name);
612 * Sends the GetProperty request.
613 * @param window The window.
614 * @ingroup Ecore_X_NetWM_Group
617 ecore_x_netwm_name_get_prefetch(Ecore_X_Window window)
619 xcb_get_property_cookie_t cookie;
621 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
622 ECORE_X_ATOM_NET_WM_NAME, ECORE_X_ATOM_UTF8_STRING,
624 _ecore_xcb_cookie_cache(cookie.sequence);
628 * Gets the reply of the GetProperty request sent by ecore_x_netwm_name_get_prefetch().
629 * @ingroup Ecore_X_NetWM_Group
632 ecore_x_netwm_name_get_fetch(void)
634 xcb_get_property_cookie_t cookie;
635 xcb_get_property_reply_t *reply;
637 cookie.sequence = _ecore_xcb_cookie_get();
638 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
639 _ecore_xcb_reply_cache(reply);
643 * Get the title of a window.
644 * @param window The window.
645 * @param name The title name.
646 * @return Returns always 1.
648 * Retrieve the title name of @p window and store it in @p name. The
649 * function returns always 1.
651 * To use this function, you must call before, and in order,
652 * ecore_x_netwm_name_get_prefetch(), which sends the GetProperty request,
653 * then ecore_x_netwm_name_get_fetch(), which gets the reply.
654 * @ingroup Ecore_X_NetWM_Group
657 ecore_x_netwm_name_get(Ecore_X_Window window,
661 *name = _ecore_x_window_prop_string_utf8_get(window, ECORE_X_ATOM_NET_WM_NAME);
666 * Set the _NET_STARTUP_ID property.
667 * @param window The window.
668 * @param id The ID name.
670 * Set the ID @p id used for the startup sequence by sending the
671 * property _NET_STARTUP_ID to @p window. The ID name should be
674 * If a new value for the property is set, the Window Manager
675 * should update the window's status accordingly (update its virtual
677 * @ingroup Ecore_X_NetWM_Group
680 ecore_x_netwm_startup_id_set(Ecore_X_Window window,
683 _ecore_x_window_prop_string_utf8_set(window, ECORE_X_ATOM_NET_STARTUP_ID, id);
687 * Sends the GetProperty request.
688 * @param window The window.
689 * @ingroup Ecore_X_NetWM_Group
692 ecore_x_netwm_startup_id_get_prefetch(Ecore_X_Window window)
694 xcb_get_property_cookie_t cookie;
696 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
697 ECORE_X_ATOM_NET_STARTUP_ID, ECORE_X_ATOM_UTF8_STRING,
699 _ecore_xcb_cookie_cache(cookie.sequence);
703 * Gets the reply of the GetProperty request sent by ecore_x_netwm_startup_id_get_prefetch().
704 * @ingroup Ecore_X_NetWM_Group
707 ecore_x_netwm_startup_id_get_fetch(void)
709 xcb_get_property_cookie_t cookie;
710 xcb_get_property_reply_t *reply;
712 cookie.sequence = _ecore_xcb_cookie_get();
713 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
714 _ecore_xcb_reply_cache(reply);
718 * Get the startup ID name of a window.
719 * @param window The window
720 * @param id The ID name
721 * @return Return always 1.
723 * To use this function, you must call before, and in order,
724 * ecore_x_netwm_startup_id_get_prefetch(), which sends the GetProperty request,
725 * then ecore_x_netwm_startup_id_get_fetch(), which gets the reply.
726 * @ingroup Ecore_X_NetWM_Group
729 ecore_x_netwm_startup_id_get(Ecore_X_Window window,
733 *id = _ecore_x_window_prop_string_utf8_get(window, ECORE_X_ATOM_NET_STARTUP_ID);
738 * Set the _NET_WM_VISIBLE_NAME property.
739 * @param window The widow to activate.
740 * @param name The title name of the window.
742 * Set the title name of @p window to @p name by sending the
743 * _NET_WM_VISIBLE_NAME property to @p window, when the Window Manager
744 * displays a window name other than by calling
745 * ecore_x_netwm_name_set().
747 * The Client SHOULD set the title of @p window in UTF-8
748 * encoding. This function is used for displaying title windows like
749 * [xterm1], [xterm2], ... thereby allowing Pagers to display the same
750 * title as the Window Manager.
751 * @ingroup Ecore_X_NetWM_Group
754 ecore_x_netwm_visible_name_set(Ecore_X_Window window,
757 _ecore_x_window_prop_string_utf8_set(window, ECORE_X_ATOM_NET_WM_VISIBLE_NAME,
762 * Sends the GetProperty request.
763 * @param window The window.
764 * @ingroup Ecore_X_NetWM_Group
767 ecore_x_netwm_visible_name_get_prefetch(Ecore_X_Window window)
769 xcb_get_property_cookie_t cookie;
771 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
772 ECORE_X_ATOM_NET_WM_VISIBLE_NAME, ECORE_X_ATOM_UTF8_STRING,
774 _ecore_xcb_cookie_cache(cookie.sequence);
778 * Gets the reply of the GetProperty request sent by ecore_x_netwm_visible_name_get_prefetch().
779 * @ingroup Ecore_X_NetWM_Group
782 ecore_x_netwm_visible_name_get_fetch(void)
784 xcb_get_property_cookie_t cookie;
785 xcb_get_property_reply_t *reply;
787 cookie.sequence = _ecore_xcb_cookie_get();
788 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
789 _ecore_xcb_reply_cache(reply);
793 * Get the visible title of a window.
794 * @param window The window.
795 * @param name The title name.
796 * @return Returns always 1.
798 * Retrieve the visible title name of @p window and store it in @p name. The
799 * function returns always 1.
800 * @param window The window
802 * To use this function, you must call before, and in order,
803 * ecore_x_netwm_visible_name_get_prefetch(), which sends the GetProperty request,
804 * then ecore_x_netwm_visible_name_get_fetch(), which gets the reply.
805 * @ingroup Ecore_X_NetWM_Group
808 ecore_x_netwm_visible_name_get(Ecore_X_Window window,
812 *name = _ecore_x_window_prop_string_utf8_get(window,
813 ECORE_X_ATOM_NET_WM_VISIBLE_NAME);
818 * Set the _NET_WM_ICON_NAME property.
819 * @param window The widow to activate.
820 * @param name The icon name of the window.
822 * Set the icon name of @p window to @p name by sending the
823 * _NET_WM_ICON_NAME property to @p window.
825 * The Client SHOULD set the title of @p window in UTF-8 encoding. If
826 * set, the Window Manager should use this in preference to WM_ICON_NAME.
827 * @ingroup Ecore_X_NetWM_Group
830 ecore_x_netwm_icon_name_set(Ecore_X_Window window,
833 _ecore_x_window_prop_string_utf8_set(window, ECORE_X_ATOM_NET_WM_ICON_NAME,
838 * Sends the GetProperty request.
839 * @param window The window.
840 * @ingroup Ecore_X_NetWM_Group
843 ecore_x_netwm_icon_name_get_prefetch(Ecore_X_Window window)
845 xcb_get_property_cookie_t cookie;
847 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
848 ECORE_X_ATOM_NET_WM_ICON_NAME, ECORE_X_ATOM_UTF8_STRING,
850 _ecore_xcb_cookie_cache(cookie.sequence);
854 * Gets the reply of the GetProperty request sent by ecore_x_netwm_icon_name_get_prefetch().
855 * @ingroup Ecore_X_NetWM_Group
858 ecore_x_netwm_icon_name_get_fetch(void)
860 xcb_get_property_cookie_t cookie;
861 xcb_get_property_reply_t *reply;
863 cookie.sequence = _ecore_xcb_cookie_get();
864 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
865 _ecore_xcb_reply_cache(reply);
869 * Get the icon name of a window.
870 * @param window The window.
871 * @param name The icon name.
872 * @return Returns always 1.
874 * Retrieve the icon name of @p window and store it in @p name. The
875 * function returns always 1.
877 * To use this function, you must call before, and in order,
878 * ecore_x_netwm_icon_name_get_prefetch(), which sends the GetProperty request,
879 * then ecore_x_netwm_icon_name_get_fetch(), which gets the reply.
880 * @ingroup Ecore_X_NetWM_Group
883 ecore_x_netwm_icon_name_get(Ecore_X_Window window,
887 *name = _ecore_x_window_prop_string_utf8_get(window,
888 ECORE_X_ATOM_NET_WM_ICON_NAME);
893 * Set the _NET_WM_VISIBLE_ICON_NAME property.
894 * @param window The widow to activate.
895 * @param name The title name of the window.
897 * Set the icon name of @p window to @p name by sending the
898 * _NET_WM_VISIBLE_ICON_NAME property to @p window, when the Window Manager
899 * displays a icon name other than by calling
900 * ecore_x_netwm_icon_name_set().
902 * The Client SHOULD set the icon name in UTF-8
903 * encoding. The Window Manager MUST use this function is it display
904 * an icon name other than with ecore_x_netwm_icon_name_set().
905 * @ingroup Ecore_X_NetWM_Group
908 ecore_x_netwm_visible_icon_name_set(Ecore_X_Window window,
911 _ecore_x_window_prop_string_utf8_set(window,
912 ECORE_X_ATOM_NET_WM_VISIBLE_ICON_NAME,
917 * Sends the GetProperty request.
918 * @param window The window.
919 * @ingroup Ecore_X_NetWM_Group
922 ecore_x_netwm_visible_icon_name_get_prefetch(Ecore_X_Window window)
924 xcb_get_property_cookie_t cookie;
926 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
927 ECORE_X_ATOM_NET_WM_VISIBLE_ICON_NAME, ECORE_X_ATOM_UTF8_STRING,
929 _ecore_xcb_cookie_cache(cookie.sequence);
933 * Gets the reply of the GetProperty request sent by ecore_x_netwm_visible_icon_name_get_prefetch().
934 * @ingroup Ecore_X_NetWM_Group
937 ecore_x_netwm_visible_icon_name_get_fetch(void)
939 xcb_get_property_cookie_t cookie;
940 xcb_get_property_reply_t *reply;
942 cookie.sequence = _ecore_xcb_cookie_get();
943 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
944 _ecore_xcb_reply_cache(reply);
948 * Get the visible icon name of a window.
949 * @param window The window.
950 * @param name The icon name.
951 * @return Returns always 1.
953 * Retrieve the visible icon name of @p window and store it in
954 * @p name. The function returns always 1.
956 * To use this function, you must call before, and in order,
957 * ecore_x_netwm_visible_icon_name_get_prefetch(), which sends the GetProperty request,
958 * then ecore_x_netwm_visible_icon_name_get_fetch(), which gets the reply.
959 * @ingroup Ecore_X_NetWM_Group
962 ecore_x_netwm_visible_icon_name_get(Ecore_X_Window window,
966 *name = _ecore_x_window_prop_string_utf8_get(window,
967 ECORE_X_ATOM_NET_WM_VISIBLE_ICON_NAME);
972 * Set the _NET_WM_DESKTOP property.
973 * @param window The window.
974 * @param desk The desktop index.
976 * Set on which desktop the @p window is in by sending the
977 * _NET_WM_DESKTOP property to @p window. @p desk is the index of
978 * the desktop, starting from 0. To indicate that the window should
979 * appear on all desktops, @p desk must be equal to 0xFFFFFFFF.
981 * A Client MAY choose not to set this property, in which case the
982 * Window Manager SHOULD place it as it wishes.
984 * The Window Manager should honor _NET_WM_DESKTOP whenever a
985 * withdrawn window requests to be mapped.
987 * A Client can request a change of desktop for a non-withdrawn window
988 * by sending a _NET_WM_DESKTOP client message to the root window.
989 * @ingroup Ecore_X_NetWM_Group
992 ecore_x_netwm_desktop_set(Ecore_X_Window window,
995 ecore_x_window_prop_card32_set(window, ECORE_X_ATOM_NET_WM_DESKTOP, &desk, 1);
999 * Sends the GetProperty request.
1000 * @param window The window.
1001 * @ingroup Ecore_X_NetWM_Group
1004 ecore_x_netwm_desktop_get_prefetch(Ecore_X_Window window)
1006 xcb_get_property_cookie_t cookie;
1008 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
1009 ECORE_X_ATOM_NET_WM_DESKTOP, ECORE_X_ATOM_CARDINAL,
1011 _ecore_xcb_cookie_cache(cookie.sequence);
1015 * Gets the reply of the GetProperty request sent by ecore_x_netwm_desktop_get_prefetch().
1016 * @ingroup Ecore_X_NetWM_Group
1019 ecore_x_netwm_desktop_get_fetch(void)
1021 xcb_get_property_cookie_t cookie;
1022 xcb_get_property_reply_t *reply;
1024 cookie.sequence = _ecore_xcb_cookie_get();
1025 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1026 _ecore_xcb_reply_cache(reply);
1030 * Get the visible icon name of a window.
1031 * @param window The window.
1032 * @param desk The desktop index.
1033 * @return 1 on success, 0 otherwise.
1035 * Retrieve the desktop index in which @p window is displayed and
1036 * store it in @p desk. If @p desk value is 0xFFFFFFFF, the window
1037 * appears on all desktops. The function returns 1 on success, 0
1040 * To use this function, you must call before, and in order,
1041 * ecore_x_netwm_desktop_get_prefetch(), which sends the GetProperty request,
1042 * then ecore_x_netwm_desktop_get_fetch(), which gets the reply.
1043 * @ingroup Ecore_X_NetWM_Group
1046 ecore_x_netwm_desktop_get(Ecore_X_Window window,
1052 ret = ecore_x_window_prop_card32_get(window, ECORE_X_ATOM_NET_WM_DESKTOP,
1055 if (desk) *desk = tmp;
1056 return (ret == 1) ? 1 : 0;
1060 * Set the _NET_WM_STRUT property.
1061 * @param window The window
1062 * @param left The number of pixels at the left of the screen.
1063 * @param right The number of pixels at the right of the screen.
1064 * @param top The number of pixels at the top of the screen.
1065 * @param bottom The number of pixels at the bottom of the screen.
1067 * Set space at the edje of the screen by sending the _NET_WM_STRUT
1068 * property to @p window if @p window is to reserve that space.
1069 * @p left, @p right, @p top and @p bottom are respectively the number
1070 * of pixels at the left, right, top and bottom of the screen.
1072 * This property is deprecated and ecore_x_netwm_strut_partial_set()
1073 * should be used instead. However, Clients MAY set this property in
1074 * addition to _NET_WM_STRUT_PARTIAL to ensure backward compatibility
1075 * with Window Managers supporting older versions of the
1077 * @ingroup Ecore_X_NetWM_Group
1080 ecore_x_netwm_strut_set(Ecore_X_Window window,
1092 ecore_x_window_prop_card32_set(window, ECORE_X_ATOM_NET_WM_STRUT, strut, 4);
1096 * Sends the GetProperty request.
1097 * @param window The window.
1098 * @ingroup Ecore_X_NetWM_Group
1101 ecore_x_netwm_strut_get_prefetch(Ecore_X_Window window)
1103 xcb_get_property_cookie_t cookie;
1105 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
1106 ECORE_X_ATOM_NET_WM_STRUT, ECORE_X_ATOM_CARDINAL,
1108 _ecore_xcb_cookie_cache(cookie.sequence);
1112 * Gets the reply of the GetProperty request sent by ecore_x_strut_get_prefetch().
1113 * @ingroup Ecore_X_NetWM_Group
1116 ecore_x_netwm_strut_get_fetch(void)
1118 xcb_get_property_cookie_t cookie;
1119 xcb_get_property_reply_t *reply;
1121 cookie.sequence = _ecore_xcb_cookie_get();
1122 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1123 _ecore_xcb_reply_cache(reply);
1127 * _NET_WM_STRUT is deprecated
1131 * Get the space at the edje of the screen.
1132 * @param window The window
1133 * @param left The number of pixels at the left of the screen.
1134 * @param right The number of pixels at the right of the screen.
1135 * @param top The number of pixels at the top of the screen.
1136 * @param bottom The number of pixels at the bottom of the screen.
1137 * @return 1 on success, 0 otherwise.
1139 * Retrieve the space at the edje of the screen if @p window is to
1140 * reserve such space. The number of pixels at the left, right, top
1141 * and bottom of the screen are respectively stored in @p left,
1142 * @p right, @p top and @p bottom. This function returns 1 on success,
1145 * This property is deprecated. See ecore_x_netwm_strut_set() for more
1148 * To use this function, you must call before, and in order,
1149 * ecore_x_netwm_strut_get_prefetch(), which sends the GetProperty request,
1150 * then ecore_x_netwm_strut_get_fetch(), which gets the reply.
1151 * @ingroup Ecore_X_NetWM_Group
1154 ecore_x_netwm_strut_get(Ecore_X_Window window,
1163 ret = ecore_x_window_prop_card32_get(window, ECORE_X_ATOM_NET_WM_STRUT, strut, 4);
1167 if (left) *left = strut[0];
1168 if (right) *right = strut[1];
1169 if (top) *top = strut[2];
1170 if (bottom) *bottom = strut[3];
1176 * Set the _NET_WM_STRUT_PARTIAL property.
1177 * @param window The window
1178 * @param left The number of pixels at the left of the screen.
1179 * @param right The number of pixels at the right of the screen.
1180 * @param top The number of pixels at the top of the screen.
1181 * @param bottom The number of pixels at the bottom of the screen.
1182 * @param left_start_y The number of pixels.
1183 * @param left_end_y The number of pixels.
1184 * @param right_start_y The number of pixels.
1185 * @param right_end_y The number of pixels.
1186 * @param top_start_x The number of pixels.
1187 * @param top_end_x The number of pixels.
1188 * @param bottom_start_x The number of pixels.
1189 * @param bottom_end_x The number of pixels.
1191 * Set space at the edje of the screen by sending the
1192 * _NET_WM_STRUT_PARTIAL property to @p window if @p window is to
1193 * reserve that space. @p left, @p right, @p top and @p bottom are
1194 * respectively the number of pixels at the left, right, top and
1195 * bottom of the screen.
1197 * TODO: more description for that function.
1198 * @ingroup Ecore_X_NetWM_Group
1201 ecore_x_netwm_strut_partial_set(Ecore_X_Window window,
1215 unsigned int strut[12];
1221 strut[4] = left_start_y;
1222 strut[5] = left_end_y;
1223 strut[6] = right_start_y;
1224 strut[7] = right_end_y;
1225 strut[8] = top_start_x;
1226 strut[9] = top_end_x;
1227 strut[10] = bottom_start_x;
1228 strut[11] = bottom_end_x;
1229 ecore_x_window_prop_card32_set(window, ECORE_X_ATOM_NET_WM_STRUT_PARTIAL, strut, 12);
1233 * Sends the GetProperty request.
1234 * @param window The window.
1235 * @ingroup Ecore_X_NetWM_Group
1238 ecore_x_netwm_strut_partial_get_prefetch(Ecore_X_Window window)
1240 xcb_get_property_cookie_t cookie;
1242 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
1243 ECORE_X_ATOM_NET_WM_STRUT_PARTIAL, ECORE_X_ATOM_CARDINAL,
1245 _ecore_xcb_cookie_cache(cookie.sequence);
1249 * Gets the reply of the GetProperty request sent by ecore_x_strut_partial_get_prefetch().
1250 * @ingroup Ecore_X_NetWM_Group
1253 ecore_x_netwm_strut_partial_get_fetch(void)
1255 xcb_get_property_cookie_t cookie;
1256 xcb_get_property_reply_t *reply;
1258 cookie.sequence = _ecore_xcb_cookie_get();
1259 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1260 _ecore_xcb_reply_cache(reply);
1264 * Get the space at the edje of the screen of a window.
1265 * @param window The window
1266 * @param left The number of pixels at the left of the screen.
1267 * @param right The number of pixels at the right of the screen.
1268 * @param top The number of pixels at the top of the screen.
1269 * @param bottom The number of pixels at the bottom of the screen.
1270 * @param left_start_y The number of pixels.
1271 * @param left_end_y The number of pixels.
1272 * @param right_start_y The number of pixels.
1273 * @param right_end_y The number of pixels.
1274 * @param top_start_x The number of pixels.
1275 * @param top_end_x The number of pixels.
1276 * @param bottom_start_x The number of pixels.
1277 * @param bottom_end_x The number of pixels.
1279 * Retrieve the space at the edje of the screen if @p window is to
1280 * reserve such space. The number of pixels at the left, right, top
1281 * and bottom of the screen are respectively stored in @p left,
1282 * @p right, @p top and @p bottom. This function returns 1 on success,
1285 * TODO: more description for that function.
1287 * To use this function, you must call before, and in order,
1288 * ecore_x_netwm_strut_partial_get_prefetch(), which sends the GetProperty request,
1289 * then ecore_x_netwm_strut_partial_get_fetch(), which gets the reply.
1290 * @ingroup Ecore_X_NetWM_Group
1293 ecore_x_netwm_strut_partial_get(Ecore_X_Window window,
1304 int *bottom_start_x,
1310 ret = ecore_x_window_prop_card32_get(window, ECORE_X_ATOM_NET_WM_STRUT_PARTIAL, strut, 12);
1314 if (left) *left = strut[0];
1315 if (right) *right = strut[1];
1316 if (top) *top = strut[2];
1317 if (bottom) *bottom = strut[3];
1318 if (left_start_y) *left_start_y = strut[4];
1319 if (left_end_y) *left_end_y = strut[5];
1320 if (right_start_y) *right_start_y = strut[6];
1321 if (right_end_y) *right_end_y = strut[7];
1322 if (top_start_x) *top_start_x = strut[8];
1323 if (top_end_x) *top_end_x = strut[9];
1324 if (bottom_start_x) *bottom_start_x = strut[10];
1325 if (bottom_end_x) *bottom_end_x = strut[11];
1330 * Sends the GetProperty request.
1331 * @param window The window.
1332 * @ingroup Ecore_X_NetWM_Group
1335 ecore_x_netwm_icons_get_prefetch(Ecore_X_Window window)
1337 xcb_get_property_cookie_t cookie;
1339 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
1340 ECORE_X_ATOM_NET_WM_ICON, ECORE_X_ATOM_CARDINAL,
1342 _ecore_xcb_cookie_cache(cookie.sequence);
1346 * Gets the reply of the GetProperty request sent by ecore_x_icons_get_prefetch().
1347 * @ingroup Ecore_X_NetWM_Group
1350 ecore_x_netwm_icons_get_fetch(void)
1352 xcb_get_property_cookie_t cookie;
1353 xcb_get_property_reply_t *reply;
1355 cookie.sequence = _ecore_xcb_cookie_get();
1356 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1357 _ecore_xcb_reply_cache(reply);
1361 * Retrieve hte possible icons of a window.
1362 * @param window The window
1363 * @param icon An array of icons.
1364 * @param num The number of icons.
1365 * @return 1 on success, 0 otherwise.
1367 * Retrieve an array of possible icons of @p window. The icons are
1368 * stored in @p icon and their number in @p num.
1370 * To use this function, you must call before, and in order,
1371 * ecore_x_netwm_icons_get_prefetch(), which sends the GetProperty request,
1372 * then ecore_x_netwm_icons_get_fetch(), which gets the reply.
1373 * @ingroup Ecore_X_NetWM_Group
1376 ecore_x_netwm_icons_get(Ecore_X_Window window,
1377 Ecore_X_Icon **icon,
1388 if (num) *num = 0UL;
1389 if (icon) *icon = NULL;
1391 num_ret = ecore_x_window_prop_card32_list_get(window,
1392 ECORE_X_ATOM_NET_WM_ICON,
1394 if ((num_ret <= 0) || !data)
1403 /* Check how many icons there are */
1410 if ((p - data) > num_ret)
1417 if ((p - data) == num_ret)
1420 if (num) *num = icons;
1422 /* If the user doesn't want the icons, return */
1429 /* Allocate memory */
1430 *icon = malloc(icons * sizeof(Ecore_X_Icon));
1437 /* Fetch the icons */
1439 for (i = 0; i < icons; i++)
1441 uint32_t *ps, *pd, *pe;
1444 ((*icon)[i]).width = p[0];
1445 ((*icon)[i]).height = p[1];
1447 ((*icon)[i]).data = malloc(len * sizeof(uint32_t));
1448 if (!((*icon)[i]).data)
1451 free(((*icon)[--i]).data);
1457 pd = ((*icon)[i]).data;
1460 for (; ps < pe; ps++)
1462 uint32_t r, g, b, a;
1464 a = (*ps >> 24) & 0xff;
1465 r = (((*ps >> 16) & 0xff) * a) / 255;
1466 g = (((*ps >> 8) & 0xff) * a) / 255;
1467 b = (((*ps ) & 0xff) * a) / 255;
1468 *pd = (a << 24) | (r << 16) | (g << 8) | (b);
1480 * Set the _NET_WM_ICON_GEOMETRY property.
1481 * @param window The window.
1482 * @param x The X coordinate of the icon.
1483 * @param y The Y coordinate of the icon.
1484 * @param width The width of the icon.
1485 * @param height The height of the icon.
1487 * Set the geometry of the icon of @p window by sending the
1488 * _NET_WM_ICON_GEOMETRY property to @p window. @p x, @p y, @p width
1489 * and @p height specify respectively the X coordinate, the Y
1490 * coordinate, the width and the height of the icon.
1492 * Stand alone tools like a taskbar or an iconbox MAY use this
1493 * function. This functions makes possible for a Window Manager to
1494 * display a nice animation like morphing the window into its icon.
1495 * @ingroup Ecore_X_NetWM_Group
1498 ecore_x_netwm_icon_geometry_set(Ecore_X_Window window,
1504 uint32_t geometry[4];
1506 geometry[0] = (uint32_t)x;
1507 geometry[1] = (uint32_t)y;
1508 geometry[2] = (uint32_t)width;
1509 geometry[3] = (uint32_t)height;
1510 ecore_x_window_prop_card32_set(window, ECORE_X_ATOM_NET_WM_ICON_GEOMETRY, geometry, 4);
1514 * Sends the GetProperty request.
1515 * @param window The window.
1516 * @ingroup Ecore_X_NetWM_Group
1519 ecore_x_netwm_icon_geometry_get_prefetch(Ecore_X_Window window)
1521 xcb_get_property_cookie_t cookie;
1523 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
1524 ECORE_X_ATOM_NET_WM_ICON_GEOMETRY, ECORE_X_ATOM_CARDINAL,
1526 _ecore_xcb_cookie_cache(cookie.sequence);
1530 * Gets the reply of the GetProperty request sent by ecore_x_icon_geometry_get_prefetch().
1531 * @ingroup Ecore_X_NetWM_Group
1534 ecore_x_netwm_icon_geometry_get_fetch(void)
1536 xcb_get_property_cookie_t cookie;
1537 xcb_get_property_reply_t *reply;
1539 cookie.sequence = _ecore_xcb_cookie_get();
1540 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1541 _ecore_xcb_reply_cache(reply);
1545 * Get the geometry of an icon.
1546 * @param window The window
1548 * @param x The X coordinate of the icon.
1549 * @param y The Y coordinate of the icon.
1550 * @param width The width of the icon.
1551 * @param height The height of the icon.
1552 * @return 1 on success, 0 othrwise.
1554 * Retrieve the geometry of the icon of @p window. The geometry is
1555 * stored in @p x, @p y, @p width and @p height. The function returns
1556 * 1 on success, 0 otherwise.
1558 * To use this function, you must call before, and in order,
1559 * ecore_x_netwm_icon_geometry_get_prefetch(), which sends the GetProperty request,
1560 * then ecore_x_netwm_icon_geometry_get_fetch(), which gets the reply.
1561 * @ingroup Ecore_X_NetWM_Group
1564 ecore_x_netwm_icon_geometry_get(Ecore_X_Window window,
1570 uint32_t geometry[4];
1573 ret = ecore_x_window_prop_card32_get(window, ECORE_X_ATOM_NET_WM_ICON_GEOMETRY, geometry, 4);
1577 if (x) *x = geometry[0];
1578 if (y) *y = geometry[1];
1579 if (width) *width = geometry[2];
1580 if (height) *height = geometry[3];
1586 * Set the _NET_WM_PID property.
1587 * @param window The window.
1588 * @param pid The process ID.
1590 * Set the process ID of the client owning @p window by sending the
1591 * _NET_WM_PID property to @p window.
1593 * This function MAY be used by the Window Manager to kill windows
1594 * which do not respond to the _NET_WM_PING protocol.
1596 * If _NET_WM_PID is set, the ICCCM-specified property
1597 * WM_CLIENT_MACHINE MUST also be set.
1598 * @ingroup Ecore_X_NetWM_Group
1601 ecore_x_netwm_pid_set(Ecore_X_Window window,
1607 ecore_x_window_prop_card32_set(window, ECORE_X_ATOM_NET_WM_PID,
1612 * Sends the GetProperty request.
1613 * @param window The window.
1614 * @ingroup Ecore_X_NetWM_Group
1617 ecore_x_netwm_pid_get_prefetch(Ecore_X_Window window)
1619 xcb_get_property_cookie_t cookie;
1621 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
1622 ECORE_X_ATOM_NET_WM_PID, ECORE_X_ATOM_CARDINAL,
1624 _ecore_xcb_cookie_cache(cookie.sequence);
1628 * Gets the reply of the GetProperty request sent by ecore_x_pid_get_prefetch().
1629 * @ingroup Ecore_X_NetWM_Group
1632 ecore_x_netwm_pid_get_fetch(void)
1634 xcb_get_property_cookie_t cookie;
1635 xcb_get_property_reply_t *reply;
1637 cookie.sequence = _ecore_xcb_cookie_get();
1638 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1639 _ecore_xcb_reply_cache(reply);
1643 * Get the process ID of a client window.
1644 * @param window The window.
1645 * @param pid The process ID.
1646 * @return 1 on success, 0 otherwise.
1648 * Retrieve the process ID of @p window and store it in @p pid. This
1649 * function returns 1 on success, 0 otherwise.
1651 * To use this function, you must call before, and in order,
1652 * ecore_x_netwm_pid_get_prefetch(), which sends the GetProperty request,
1653 * then ecore_x_netwm_pid_get_fetch(), which gets the reply.
1654 * @ingroup Ecore_X_NetWM_Group
1657 ecore_x_netwm_pid_get(Ecore_X_Window window,
1663 ret = ecore_x_window_prop_card32_get(window, ECORE_X_ATOM_NET_WM_PID,
1665 if (pid) *pid = tmp;
1667 return (ret == 1) ? 1 : 0;
1671 * Set the _NET_WM_HANDLED_ICONS property.
1672 * @param window The window.
1674 * Indicate to the Window Manager that it does not need to provide
1675 * icons for the iconified @p window by sending the
1676 * _NET_WM_HANDLED_ICONS property to @p window.
1678 * This function can be used by a Pager on one of its own toplevel
1679 * windows (for example if the Client is a taskbar and provides
1680 * buttons for iconified windows).
1681 * @ingroup Ecore_X_NetWM_Group
1684 ecore_x_netwm_handled_icons_set(Ecore_X_Window window)
1686 ecore_x_window_prop_card32_set(window, ECORE_X_ATOM_NET_WM_HANDLED_ICONS,
1691 * Sends the GetProperty request.
1692 * @param window The window.
1693 * @ingroup Ecore_X_NetWM_Group
1696 ecore_x_netwm_handled_icons_get_prefetch(Ecore_X_Window window)
1698 xcb_get_property_cookie_t cookie;
1700 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
1701 ECORE_X_ATOM_NET_WM_HANDLED_ICONS, ECORE_X_ATOM_CARDINAL,
1703 _ecore_xcb_cookie_cache(cookie.sequence);
1707 * Gets the reply of the GetProperty request sent by ecore_x_handled_icons_get_prefetch().
1708 * @ingroup Ecore_X_NetWM_Group
1711 ecore_x_netwm_handled_icons_get_fetch(void)
1713 xcb_get_property_cookie_t cookie;
1714 xcb_get_property_reply_t *reply;
1716 cookie.sequence = _ecore_xcb_cookie_get();
1717 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1718 _ecore_xcb_reply_cache(reply);
1722 * Return wheter the Client handles icons or not.
1723 * @param window The window.
1724 * @return 1 if icons are handled, 0 otherwise.
1726 * Return whether the client handles icons or not if @p window is
1729 * To use this function, you must call before, and in order,
1730 * ecore_x_netwm_handled_icons_get_prefetch(), which sends the GetProperty request,
1731 * then ecore_x_netwm_handled_icons_get_fetch(), which gets the reply.
1732 * @ingroup Ecore_X_NetWM_Group
1735 ecore_x_netwm_handled_icons_get(Ecore_X_Window window)
1738 ret = ecore_x_window_prop_card32_get(window, ECORE_X_ATOM_NET_WM_HANDLED_ICONS,
1740 return (ret == 0) ? 1 : 0;
1744 * Set the _NET_WM_USER_TIME property.
1745 * @param window The window.
1746 * @param time The last user activity time in the window.
1748 * Set the XServer time at which last user activity in @p window took
1749 * place by sending the _NET_WM_USER_TIME property to @p window. @p
1750 * time contains that XServer time in seconds.
1752 * This function allows a Window Manager to alter the focus, stacking,
1753 * and/or placement behavior of windows when they are mapped depending
1754 * on whether the new window was created by a user action or is a
1755 * "pop-up" window activated by a timer or some other event.
1756 * @ingroup Ecore_X_NetWM_Group
1759 ecore_x_netwm_user_time_set(Ecore_X_Window window,
1762 ecore_x_window_prop_card32_set(window, ECORE_X_ATOM_NET_WM_USER_TIME,
1767 * Sends the GetProperty request.
1768 * @param window The window.
1769 * @ingroup Ecore_X_NetWM_Group
1772 ecore_x_netwm_user_time_get_prefetch(Ecore_X_Window window)
1774 xcb_get_property_cookie_t cookie;
1776 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
1777 ECORE_X_ATOM_NET_WM_USER_TIME, ECORE_X_ATOM_CARDINAL,
1779 _ecore_xcb_cookie_cache(cookie.sequence);
1783 * Gets the reply of the GetProperty request sent by ecore_x_netwm_user_time_get_prefetch().
1784 * @ingroup Ecore_X_NetWM_Group
1787 ecore_x_netwm_user_time_get_fetch(void)
1789 xcb_get_property_cookie_t cookie;
1790 xcb_get_property_reply_t *reply;
1792 cookie.sequence = _ecore_xcb_cookie_get();
1793 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1794 _ecore_xcb_reply_cache(reply);
1798 * Get the last user activity time in the window.
1799 * @param window The window.
1800 * @param time The returned time.
1801 * @return 1 on success, 0 otherwise.
1803 * Return the XServer time at which last user activity in @p window
1804 * took place. The time is stored in @p time.
1806 * To use this function, you must call before, and in order,
1807 * ecore_x_netwm_user_time_get_prefetch(), which sends the GetProperty request,
1808 * then ecore_x_netwm_user_time_get_fetch(), which gets the reply.
1809 * @ingroup Ecore_X_NetWM_Group
1812 ecore_x_netwm_user_time_get(Ecore_X_Window window,
1818 ret = ecore_x_window_prop_card32_get(window, ECORE_X_ATOM_NET_WM_USER_TIME,
1820 if (time) *time = tmp;
1821 return (ret == 1) ? 1 : 0;
1824 Ecore_X_Window_State
1825 _ecore_x_netwm_state_get(Ecore_X_Atom a)
1827 if (a == ECORE_X_ATOM_NET_WM_STATE_MODAL)
1828 return ECORE_X_WINDOW_STATE_MODAL;
1829 else if (a == ECORE_X_ATOM_NET_WM_STATE_STICKY)
1830 return ECORE_X_WINDOW_STATE_STICKY;
1831 else if (a == ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT)
1832 return ECORE_X_WINDOW_STATE_MAXIMIZED_VERT;
1833 else if (a == ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ)
1834 return ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ;
1835 else if (a == ECORE_X_ATOM_NET_WM_STATE_SHADED)
1836 return ECORE_X_WINDOW_STATE_SHADED;
1837 else if (a == ECORE_X_ATOM_NET_WM_STATE_SKIP_TASKBAR)
1838 return ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
1839 else if (a == ECORE_X_ATOM_NET_WM_STATE_SKIP_PAGER)
1840 return ECORE_X_WINDOW_STATE_SKIP_PAGER;
1841 else if (a == ECORE_X_ATOM_NET_WM_STATE_HIDDEN)
1842 return ECORE_X_WINDOW_STATE_HIDDEN;
1843 else if (a == ECORE_X_ATOM_NET_WM_STATE_FULLSCREEN)
1844 return ECORE_X_WINDOW_STATE_FULLSCREEN;
1845 else if (a == ECORE_X_ATOM_NET_WM_STATE_ABOVE)
1846 return ECORE_X_WINDOW_STATE_ABOVE;
1847 else if (a == ECORE_X_ATOM_NET_WM_STATE_BELOW)
1848 return ECORE_X_WINDOW_STATE_BELOW;
1849 else if (a == ECORE_X_ATOM_NET_WM_STATE_DEMANDS_ATTENTION)
1850 return ECORE_X_WINDOW_STATE_DEMANDS_ATTENTION;
1852 return ECORE_X_WINDOW_STATE_UNKNOWN;
1856 _ecore_x_netwm_state_atom_get(Ecore_X_Window_State s)
1860 case ECORE_X_WINDOW_STATE_MODAL:
1861 return ECORE_X_ATOM_NET_WM_STATE_MODAL;
1862 case ECORE_X_WINDOW_STATE_STICKY:
1863 return ECORE_X_ATOM_NET_WM_STATE_STICKY;
1864 case ECORE_X_WINDOW_STATE_MAXIMIZED_VERT:
1865 return ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT;
1866 case ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ:
1867 return ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ;
1868 case ECORE_X_WINDOW_STATE_SHADED:
1869 return ECORE_X_ATOM_NET_WM_STATE_SHADED;
1870 case ECORE_X_WINDOW_STATE_SKIP_TASKBAR:
1871 return ECORE_X_ATOM_NET_WM_STATE_SKIP_TASKBAR;
1872 case ECORE_X_WINDOW_STATE_SKIP_PAGER:
1873 return ECORE_X_ATOM_NET_WM_STATE_SKIP_PAGER;
1874 case ECORE_X_WINDOW_STATE_HIDDEN:
1875 return ECORE_X_ATOM_NET_WM_STATE_HIDDEN;
1876 case ECORE_X_WINDOW_STATE_FULLSCREEN:
1877 return ECORE_X_ATOM_NET_WM_STATE_FULLSCREEN;
1878 case ECORE_X_WINDOW_STATE_ABOVE:
1879 return ECORE_X_ATOM_NET_WM_STATE_ABOVE;
1880 case ECORE_X_WINDOW_STATE_BELOW:
1881 return ECORE_X_ATOM_NET_WM_STATE_BELOW;
1882 case ECORE_X_WINDOW_STATE_DEMANDS_ATTENTION:
1883 return ECORE_X_ATOM_NET_WM_STATE_DEMANDS_ATTENTION;
1890 * Set the _NET_WM_STATE property.
1891 * @param window The window.
1892 * @param state An array of window hints.
1893 * @param num The number of hints.
1895 * Set a list of hints describing @p window state by sending the
1896 * _NET_WM_STATE property to @p window. The hints are stored in the
1897 * array @p state. @p num must contain the number of hints.
1899 * The Window Manager SHOULD honor _NET_WM_STATE whenever a withdrawn
1900 * window requests to be mapped. A Client wishing to change the state
1901 * of a window MUST send a _NET_WM_STATE client message to the root
1902 * window. The Window Manager MUST keep this property updated to
1903 * reflect the current state of the window.
1904 * @ingroup Ecore_X_NetWM_Group
1907 ecore_x_netwm_window_state_set(Ecore_X_Window window,
1908 Ecore_X_Window_State *state,
1916 ecore_x_window_prop_property_del(window, ECORE_X_ATOM_NET_WM_STATE);
1920 set = malloc(num * sizeof(Ecore_X_Atom));
1923 for (i = 0; i < num; i++)
1924 set[i] = _ecore_x_netwm_state_atom_get(state[i]);
1926 ecore_x_window_prop_atom_set(window, ECORE_X_ATOM_NET_WM_STATE, set, num);
1932 * Sends the GetProperty request.
1933 * @param window The window.
1934 * @ingroup Ecore_X_NetWM_Group
1937 ecore_x_netwm_window_state_get_prefetch(Ecore_X_Window window)
1939 xcb_get_property_cookie_t cookie;
1941 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
1942 ECORE_X_ATOM_NET_WM_STATE, ECORE_X_ATOM_ATOM,
1944 _ecore_xcb_cookie_cache(cookie.sequence);
1948 * Gets the reply of the GetProperty request sent by ecore_x_window_state_get_prefetch().
1949 * @ingroup Ecore_X_NetWM_Group
1952 ecore_x_netwm_window_state_get_fetch(void)
1954 xcb_get_property_cookie_t cookie;
1955 xcb_get_property_reply_t *reply;
1957 cookie.sequence = _ecore_xcb_cookie_get();
1958 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
1959 _ecore_xcb_reply_cache(reply);
1963 * Get the hints describing the window state.
1964 * @param window The window.
1965 * @param state The returned hins.
1966 * @param num The number of hints.
1967 * @return 1 on success, 0 otherwise.
1969 * Retrieve the hints describing @p window state. The state is
1970 * returned in @p state. The nummber of hints is stored in @p
1971 * num. This function returns 1 on success, 0 otherwise.
1973 * To use this function, you must call before, and in order,
1974 * ecore_x_netwm_window_state_get_prefetch(), which sends the GetProperty request,
1975 * then ecore_x_netwm_window_state_get_fetch(), which gets the reply.
1976 * @ingroup Ecore_X_NetWM_Group
1979 ecore_x_netwm_window_state_get(Ecore_X_Window window,
1980 Ecore_X_Window_State **state,
1983 Ecore_X_Atom *atoms;
1988 if (state) *state = NULL;
1990 num_ret = ecore_x_window_prop_atom_list_get(window, ECORE_X_ATOM_NET_WM_STATE,
1997 *state = malloc(num_ret * sizeof(Ecore_X_Window_State));
1999 for (i = 0; i < num_ret; ++i)
2000 (*state)[i] = _ecore_x_netwm_state_get(atoms[i]);
2002 if (num) *num = num_ret;
2010 static Ecore_X_Window_Type
2011 _ecore_x_netwm_window_type_type_get(Ecore_X_Atom atom)
2013 if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DESKTOP)
2014 return ECORE_X_WINDOW_TYPE_DESKTOP;
2015 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DOCK)
2016 return ECORE_X_WINDOW_TYPE_DOCK;
2017 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLBAR)
2018 return ECORE_X_WINDOW_TYPE_TOOLBAR;
2019 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_MENU)
2020 return ECORE_X_WINDOW_TYPE_MENU;
2021 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_UTILITY)
2022 return ECORE_X_WINDOW_TYPE_UTILITY;
2023 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_SPLASH)
2024 return ECORE_X_WINDOW_TYPE_SPLASH;
2025 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DIALOG)
2026 return ECORE_X_WINDOW_TYPE_DIALOG;
2027 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NORMAL)
2028 return ECORE_X_WINDOW_TYPE_NORMAL;
2030 return ECORE_X_WINDOW_TYPE_UNKNOWN;
2034 _ecore_x_netwm_window_type_atom_get(Ecore_X_Window_Type type)
2038 case ECORE_X_WINDOW_TYPE_DESKTOP:
2039 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DESKTOP;
2040 case ECORE_X_WINDOW_TYPE_DOCK:
2041 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DOCK;
2042 case ECORE_X_WINDOW_TYPE_TOOLBAR:
2043 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLBAR;
2044 case ECORE_X_WINDOW_TYPE_MENU:
2045 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_MENU;
2046 case ECORE_X_WINDOW_TYPE_UTILITY:
2047 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_UTILITY;
2048 case ECORE_X_WINDOW_TYPE_SPLASH:
2049 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_SPLASH;
2050 case ECORE_X_WINDOW_TYPE_DIALOG:
2051 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DIALOG;
2052 case ECORE_X_WINDOW_TYPE_NORMAL:
2053 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NORMAL;
2060 * FIXME: We should set WM_TRANSIENT_FOR if type is ECORE_X_WINDOW_TYPE_TOOLBAR
2061 * , ECORE_X_WINDOW_TYPE_MENU or ECORE_X_WINDOW_TYPE_DIALOG
2065 * Set the _NET_WM_WINDOW_TYPE property.
2066 * @param window The window.
2067 * @param type The functional type of the window.
2069 * Set the functional @p type of @p window by sending _NET_WM_WINDOW_TYPE
2070 * property to @p window.
2072 * This property SHOULD be set by the Client before mapping. This
2073 * property SHOULD be used by the window manager in determining the
2074 * decoration, stacking position and other behavior of the window. The
2075 * Client SHOULD specify window types in order of preference (the first
2076 * being most preferable).
2078 * This hint is intended to replace the MOTIF hints.
2079 * @ingroup Ecore_X_NetWM_Group
2082 ecore_x_netwm_window_type_set(Ecore_X_Window window,
2083 Ecore_X_Window_Type type)
2087 atom = _ecore_x_netwm_window_type_atom_get(type);
2088 ecore_x_window_prop_atom_set(window, ECORE_X_ATOM_NET_WM_WINDOW_TYPE,
2093 * Sends the GetProperty request.
2094 * @param window The window.
2095 * @ingroup Ecore_X_NetWM_Group
2098 ecore_x_netwm_window_type_get_prefetch(Ecore_X_Window window)
2100 xcb_get_property_cookie_t cookie;
2102 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
2103 ECORE_X_ATOM_NET_WM_WINDOW_TYPE, ECORE_X_ATOM_ATOM,
2105 _ecore_xcb_cookie_cache(cookie.sequence);
2109 * Gets the reply of the GetProperty request sent by ecore_x_window_type_get_prefetch().
2110 * @ingroup Ecore_X_NetWM_Group
2113 ecore_x_netwm_window_type_get_fetch(void)
2115 xcb_get_property_cookie_t cookie;
2116 xcb_get_property_reply_t *reply;
2118 cookie.sequence = _ecore_xcb_cookie_get();
2119 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
2120 _ecore_xcb_reply_cache(reply);
2123 /* FIXME: Maybe return 0 on some conditions? */
2126 * Get the functional type of a window.
2127 * @param window The window.
2128 * @param type The function type of the window.
2129 * @return 1 on success, 0 otherwise.
2131 * Retrieve the functional type of @p window. The type is stored in
2132 * @p type. This function returns 1 on success, 0 otherwise.
2134 * To use this function, you must call before, and in order,
2135 * ecore_x_netwm_window_type_get_prefetch(), which sends the GetProperty request,
2136 * then ecore_x_netwm_window_type_get_fetch(), which gets the reply.
2137 * @ingroup Ecore_X_NetWM_Group
2140 ecore_x_netwm_window_type_get(Ecore_X_Window window,
2141 Ecore_X_Window_Type *type)
2143 Ecore_X_Atom *atoms;
2147 if (type) *type = ECORE_X_WINDOW_TYPE_NORMAL;
2149 num = ecore_x_window_prop_atom_list_get(window, ECORE_X_ATOM_NET_WM_WINDOW_TYPE,
2153 /* IMO this is not the place to mix netwm and icccm /kwo */
2154 /* Check if WM_TRANSIENT_FOR is set */
2156 /* Disable it for xcb */
2158 /* if ((type) && (ecore_x_icccm_transient_for_get(window))) */
2159 /* *type = ECORE_X_WINDOW_TYPE_DIALOG; */
2165 for (i = 0; i < num; ++i)
2167 *type = _ecore_x_netwm_window_type_type_get(atoms[i]);
2168 if (*type != ECORE_X_WINDOW_TYPE_UNKNOWN)
2179 _ecore_x_netwm_action_atom_get(Ecore_X_Action action)
2183 case ECORE_X_ACTION_MOVE:
2184 return ECORE_X_ATOM_NET_WM_ACTION_MOVE;
2185 case ECORE_X_ACTION_RESIZE:
2186 return ECORE_X_ATOM_NET_WM_ACTION_RESIZE;
2187 case ECORE_X_ACTION_MINIMIZE:
2188 return ECORE_X_ATOM_NET_WM_ACTION_MINIMIZE;
2189 case ECORE_X_ACTION_SHADE:
2190 return ECORE_X_ATOM_NET_WM_ACTION_SHADE;
2191 case ECORE_X_ACTION_STICK:
2192 return ECORE_X_ATOM_NET_WM_ACTION_STICK;
2193 case ECORE_X_ACTION_MAXIMIZE_HORZ:
2194 return ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_HORZ;
2195 case ECORE_X_ACTION_MAXIMIZE_VERT:
2196 return ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_VERT;
2197 case ECORE_X_ACTION_FULLSCREEN:
2198 return ECORE_X_ATOM_NET_WM_ACTION_FULLSCREEN;
2199 case ECORE_X_ACTION_CHANGE_DESKTOP:
2200 return ECORE_X_ATOM_NET_WM_ACTION_CHANGE_DESKTOP;
2201 case ECORE_X_ACTION_CLOSE:
2202 return ECORE_X_ATOM_NET_WM_ACTION_CLOSE;
2209 * Sends the GetProperty request.
2210 * @param window The window.
2211 * @ingroup Ecore_X_NetWM_Group
2214 ecore_x_netwm_allowed_action_get_prefetch(Ecore_X_Window window)
2216 xcb_get_property_cookie_t cookie;
2218 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
2219 ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS, ECORE_X_ATOM_ATOM,
2221 _ecore_xcb_cookie_cache(cookie.sequence);
2225 * Gets the reply of the GetProperty request sent by ecore_x_allowed_action_get_prefetch().
2226 * @ingroup Ecore_X_NetWM_Group
2229 ecore_x_netwm_allowed_action_get_fetch(void)
2231 xcb_get_property_cookie_t cookie;
2232 xcb_get_property_reply_t *reply;
2234 cookie.sequence = _ecore_xcb_cookie_get();
2235 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
2236 _ecore_xcb_reply_cache(reply);
2239 /* FIXME: Get complete list */
2242 * Check whether an action is supported by a window.
2243 * @param window The window
2244 * @param action The action
2245 * @return 1 if set, 0 otherwise.
2247 * Return whether the user operation @p action is supported by the
2248 * Window Manager for @p window.
2250 * To use this function, you must call before, and in order,
2251 * ecore_x_netwm_allowed_action_get_prefetch(), which sends the GetProperty request,
2252 * then ecore_x_netwm_allowed_action_get_fetch(), which gets the reply.
2253 * @ingroup Ecore_X_NetWM_Group
2256 ecore_x_netwm_allowed_action_isset(Ecore_X_Window window,
2257 Ecore_X_Action action)
2259 Ecore_X_Atom *atoms;
2265 num = ecore_x_window_prop_atom_list_get(window, ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS,
2270 atom = _ecore_x_netwm_action_atom_get(action);
2272 for (i = 0; i < num; ++i)
2274 if (atom == atoms[i])
2286 /* FIXME: Set complete list */
2288 * Set the _NET_WM_ALLOWED_ACTIONS property.
2289 * @param window The window.
2290 * @param action An array of allowed actions.
2291 * @param num The number of actions.
2293 * Set the user operations that the Window Manager supports for
2294 * @p window by sending the _NET_WM_ALLOWED_ACTIONS property to
2295 * @p window. @p action stores @p num actions.
2297 * To use this function, you must call before, and in order,
2298 * ecore_x_netwm_allowed_action_get_prefetch(), which sends the GetProperty request,
2299 * then ecore_x_netwm_allowed_action_get_fetch(), which gets the reply.
2300 * @ingroup Ecore_X_NetWM_Group
2303 ecore_x_netwm_allowed_action_set(Ecore_X_Window window,
2304 Ecore_X_Action *action,
2312 ecore_x_window_prop_property_del(window, ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS);
2316 set = malloc(num * sizeof(Ecore_X_Atom));
2319 for (i = 0; i < num; i++)
2320 set[i] = _ecore_x_netwm_action_atom_get(action[i]);
2322 ecore_x_window_prop_atom_set(window, ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS, set, num);
2328 * Get the allowed actions supported by a window.
2329 * @param window The window.
2330 * @param action The returned array of the actions.
2331 * @param num The number of actions.
2332 * @return 1 on success, 0 otherwise.
2334 * Retrieve the user operations that the Window Manager supports for
2335 * @p window and store them in @p action. The number of actions is
2336 * stored in @p num. This function returns 1 on success, 0 otherwise.
2338 * To use this function, you must call before, and in order,
2339 * ecore_x_netwm_allowed_action_get_prefetch(), which sends the GetProperty request,
2340 * then ecore_x_netwm_allowed_action_get_fetch(), which gets the reply.
2341 * @ingroup Ecore_X_NetWM_Group
2344 ecore_x_netwm_allowed_action_get(Ecore_X_Window window,
2345 Ecore_X_Action **action,
2348 Ecore_X_Atom *atoms;
2353 if (action) *action = NULL;
2355 num_ret = ecore_x_window_prop_atom_list_get(window, ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS,
2362 *action = malloc(num_ret * sizeof(Ecore_X_Action));
2364 for (i = 0; i < num_ret; ++i)
2365 (*action)[i] = _ecore_x_netwm_action_atom_get(atoms[i]);
2367 if (num) *num = num_ret;
2376 * Set the _NET_WM_WINDOW_OPACITY property.
2377 * @param window The window.
2378 * @param opacity The opacity value.
2380 * Set the desired opacity of @p window by sending the
2381 * _NET_WM_WINDOW_OPACITY property to @p window. @p opacity is 0 for a
2382 * transparent window and 0xffffffff for an opaque window. @p opacity
2383 * must be multiplied with the original alpha value of @p window
2384 * (which is 1 for visuals not including an alpha component) so that
2385 * @p window content is modulated by the opacity value.
2387 * Window Managers acting as compositing managers MAY take this into
2388 * account when displaying a window. Window Managers MUST forward the
2389 * value of this property to any enclosing frame window. This
2390 * property MAY change while the window is mapped and the Window
2391 * Manager MUST respect changes while the window is mapped.
2392 * @ingroup Ecore_X_NetWM_Group
2395 ecore_x_netwm_opacity_set(Ecore_X_Window window,
2396 unsigned int opacity)
2398 uint32_t op = opacity;
2399 ecore_x_window_prop_card32_set(window, ECORE_X_ATOM_NET_WM_WINDOW_OPACITY,
2404 * Sends the GetProperty request.
2405 * @param window The window.
2406 * @ingroup Ecore_X_NetWM_Group
2409 ecore_x_netwm_opacity_get_prefetch(Ecore_X_Window window)
2411 xcb_get_property_cookie_t cookie;
2413 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
2414 ECORE_X_ATOM_NET_WM_WINDOW_OPACITY, ECORE_X_ATOM_CARDINAL,
2416 _ecore_xcb_cookie_cache(cookie.sequence);
2420 * Gets the reply of the GetProperty request sent by ecore_x_netwm_opacity_get_prefetch().
2421 * @ingroup Ecore_X_NetWM_Group
2424 ecore_x_netwm_opacity_get_fetch(void)
2426 xcb_get_property_cookie_t cookie;
2427 xcb_get_property_reply_t *reply;
2429 cookie.sequence = _ecore_xcb_cookie_get();
2430 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
2431 _ecore_xcb_reply_cache(reply);
2435 * Get the opacity value of a window.
2436 * @param window The window.
2437 * @param opacity The returned opacity.
2438 * @return 1 on success, 0 otherwise.
2440 * Retriee the opacity value of @p window and store it in
2441 * @p opacity. This function returns 1 on sucess, 0 otherwise.
2443 * To use this function, you must call before, and in order,
2444 * ecore_x_netwm_opacity_get_prefetch(), which sends the GetProperty request,
2445 * then ecore_x_netwm_opacity_get_fetch(), which gets the reply.
2446 * @ingroup Ecore_X_NetWM_Group
2449 ecore_x_netwm_opacity_get(Ecore_X_Window window,
2450 unsigned int *opacity)
2455 ret = ecore_x_window_prop_card32_get(window, ECORE_X_ATOM_NET_WM_WINDOW_OPACITY,
2457 if (opacity) *opacity = tmp;
2458 return ret == 1 ? 1 : 0;
2462 * Set the _NET_FRAME_EXTENTS property.
2463 * @param window The window.
2464 * @param fl The number of pixels of the left border of the window.
2465 * @param fr The number of pixels of the right border of the window.
2466 * @param ft The number of pixels of the top border of the window.
2467 * @param fb The number of pixels of the bottom border of the window.
2469 * Set the border witdh of @p window by sending the _NET_FRAME_EXTENTS
2470 * property to @p window. @p fl, @p fr, @p ft and @p fb are respectively
2471 * the number of pixels of the left, right, top and bottom border of
2474 * The Window Manager MUST set _NET_FRAME_EXTENTS to the extents of
2475 * the window's frame.
2476 * @ingroup Ecore_X_NetWM_Group
2479 ecore_x_netwm_frame_size_set(Ecore_X_Window window,
2491 ecore_x_window_prop_card32_set(window, ECORE_X_ATOM_NET_FRAME_EXTENTS, frames, 4);
2495 * Sends the GetProperty request.
2496 * @param window The window.
2497 * @ingroup Ecore_X_NetWM_Group
2500 ecore_x_netwm_frame_size_get_prefetch(Ecore_X_Window window)
2502 xcb_get_property_cookie_t cookie;
2504 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
2505 ECORE_X_ATOM_NET_FRAME_EXTENTS, ECORE_X_ATOM_CARDINAL,
2507 _ecore_xcb_cookie_cache(cookie.sequence);
2511 * Gets the reply of the GetProperty request sent by ecore_x_netwm_frame_size_get_prefetch().
2512 * @ingroup Ecore_X_NetWM_Group
2515 ecore_x_netwm_frame_size_get_fetch(void)
2517 xcb_get_property_cookie_t cookie;
2518 xcb_get_property_reply_t *reply;
2520 cookie.sequence = _ecore_xcb_cookie_get();
2521 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
2522 _ecore_xcb_reply_cache(reply);
2526 * Get the frame extent of a window.
2527 * @param window The window.
2528 * @param fl The number of pixels of the left border of the window.
2529 * @param fr The number of pixels of the right border of the window.
2530 * @param ft The number of pixels of the top border of the window.
2531 * @param fb The number of pixels of the bottom border of the window.
2532 * @return 1 on success, 0 otherwise.
2534 * Retrieve the frame extents of @p window. The number of pixels of
2535 * the left, right, top and bottom border of @p window are
2536 * respectively stored in @p fl, @p fr, @p ft anfd @p fb. TYhis
2537 * function retuirns 1 on success, 0 otherwise.
2539 * To use this function, you must call before, and in order,
2540 * ecore_x_netwm_frame_size_get_prefetch(), which sends the GetProperty request,
2541 * then ecore_x_netwm_frame_size_get_fetch(), which gets the reply.
2542 * @ingroup Ecore_X_NetWM_Group
2545 ecore_x_netwm_frame_size_get(Ecore_X_Window window,
2554 ret = ecore_x_window_prop_card32_get(window, ECORE_X_ATOM_NET_FRAME_EXTENTS, frames, 4);
2558 if (fl) *fl = frames[0];
2559 if (fr) *fr = frames[1];
2560 if (ft) *ft = frames[2];
2561 if (fb) *fb = frames[3];
2566 * Sends the GetProperty request.
2567 * @param window The window.
2568 * @ingroup Ecore_X_NetWM_Group
2571 ecore_x_netwm_sync_counter_get_prefetch(Ecore_X_Window window)
2573 xcb_get_property_cookie_t cookie;
2575 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
2576 ECORE_X_ATOM_NET_WM_SYNC_REQUEST_COUNTER, ECORE_X_ATOM_CARDINAL,
2578 _ecore_xcb_cookie_cache(cookie.sequence);
2582 * Gets the reply of the GetProperty request sent by ecore_x_netwm_sync_counter_get_prefetch().
2583 * @ingroup Ecore_X_NetWM_Group
2586 ecore_x_netwm_sync_counter_get_fetch(void)
2588 xcb_get_property_cookie_t cookie;
2589 xcb_get_property_reply_t *reply;
2591 cookie.sequence = _ecore_xcb_cookie_get();
2592 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
2593 _ecore_xcb_reply_cache(reply);
2597 * Get the X ID of a X Sync counter.
2598 * @param window The window.
2599 * @param counter The X ID of the Sync counter.
2600 * @return 1 on success, 0 otherwise.
2602 * Retrieve the X ID of the X Sync counter of @p window and store it
2603 * in @p counter. This function returns 1 on success, 0 otherwise.
2605 * To use this function, you must call before, and in order,
2606 * ecore_x_netwm_frame_size_get_prefetch(), which sends the GetProperty request,
2607 * then ecore_x_netwm_frame_size_get_fetch(), which gets the reply.
2608 * @ingroup Ecore_X_NetWM_Group
2611 ecore_x_netwm_sync_counter_get(Ecore_X_Window window,
2612 Ecore_X_Sync_Counter *counter)
2617 ret = ecore_x_window_prop_card32_get(window, ECORE_X_ATOM_NET_WM_SYNC_REQUEST_COUNTER,
2620 if (counter) *counter = tmp;
2621 return (ret == 1) ? 1 : 0;
2625 * Send a _NET_WM_PING property event.
2626 * @param window The window.
2628 * Send a ClientMessage event from @p window with the _NET_WM_PING
2630 * @ingroup Ecore_X_NetWM_Group
2633 ecore_x_netwm_ping_send(Ecore_X_Window window)
2635 xcb_client_message_event_t ev;
2637 if (!window) return;
2639 ev.response_type = XCB_CLIENT_MESSAGE | 0x80;
2643 ev.type = ECORE_X_ATOM_WM_PROTOCOLS;
2644 ev.data.data32[0] = ECORE_X_ATOM_NET_WM_PING;
2645 ev.data.data32[1] = XCB_CURRENT_TIME;
2646 ev.data.data32[2] = window;
2647 ev.data.data32[3] = 0;
2648 ev.data.data32[4] = 0;
2649 ev.data.data32[5] = 0;
2651 xcb_send_event(_ecore_xcb_conn, 0, window, XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
2655 * Send a _NET_WM_SYNC_REQUEST property event.
2656 * @param window The window.
2657 * @param serial The update request number.
2659 * Send a ClientMessage event from @p window with the _NET_WM_SYNC_REQUEST
2661 * @ingroup Ecore_X_NetWM_Group
2664 ecore_x_netwm_sync_request_send(Ecore_X_Window window,
2665 unsigned int serial)
2667 xcb_client_message_event_t ev;
2669 if (!window) return;
2671 ev.response_type = XCB_CLIENT_MESSAGE | 0x80;
2674 ev.type = ECORE_X_ATOM_WM_PROTOCOLS;
2675 ev.data.data32[0] = ECORE_X_ATOM_NET_WM_SYNC_REQUEST;
2676 ev.data.data32[1] = XCB_CURRENT_TIME;
2677 ev.data.data32[2] = serial;
2678 /* FIXME: imho, the following test is useless as serial is non negative */
2679 /* should we remove it ? */
2680 ev.data.data32[3] = (serial < 0) ? ~0L : 0L;
2681 ev.data.data32[4] = 0;
2683 xcb_send_event(_ecore_xcb_conn, 0, window, 0, (const char *)&ev);
2687 * Send a _NET_WM_STATE property event.
2688 * @param window The window.
2689 * @param root The root window.
2690 * @param s1 The first state to alter.
2691 * @param s2 The second state to alter.
2692 * @param set 0 to unset the property, set it otherwise.
2694 * Send a ClientMessage event from @p window to the @p root window
2695 * with the _NET_WM_STATE property set. This change the state of a
2696 * mapped window. @p s1 is the first state to alter. @p s2 is the
2697 * second state to alter. If @p set value is 0, the property is
2698 * removed (or unset), otherwise, the property is set.
2699 * @ingroup Ecore_X_NetWM_Group
2702 ecore_x_netwm_state_request_send(Ecore_X_Window window,
2703 Ecore_X_Window root,
2704 Ecore_X_Window_State s1,
2705 Ecore_X_Window_State s2,
2708 xcb_client_message_event_t ev;
2710 if (!window) return;
2711 if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
2713 ev.response_type = XCB_CLIENT_MESSAGE | 0x80;
2716 ev.type = ECORE_X_ATOM_NET_WM_STATE;
2717 ev.data.data32[0] = !!set;
2718 ev.data.data32[1] = _ecore_x_netwm_state_atom_get(s1);
2719 ev.data.data32[2] = _ecore_x_netwm_state_atom_get(s2);
2720 /* 1 == normal client, if someone wants to use this
2721 * function in a pager, this should be 2 */
2722 ev.data.data32[3] = 1;
2723 ev.data.data32[4] = 0;
2725 xcb_send_event(_ecore_xcb_conn, 0, root,
2726 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT,
2731 * Send a _NET_WM_DESKTOP property event.
2732 * @param window The window.
2733 * @param root The root window.
2734 * @param desktop The new desktop index.
2736 * Send a ClientMessage event from @p window to the @p root window
2737 * with the _NET_WM_DESKTOP property set. This change the state of a
2738 * non-withdrawn window. @p desktop is the new desktop index to set.
2739 * @ingroup Ecore_X_NetWM_Group
2742 ecore_x_netwm_desktop_request_send(Ecore_X_Window window,
2743 Ecore_X_Window root,
2744 unsigned int desktop)
2746 xcb_client_message_event_t ev;
2748 if (!window) return;
2749 if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
2751 ev.response_type = XCB_CLIENT_MESSAGE | 0x80;
2754 ev.type = ECORE_X_ATOM_NET_WM_DESKTOP;
2755 ev.data.data32[0] = desktop;
2757 xcb_send_event(_ecore_xcb_conn, 0, root,
2758 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT,
2763 _ecore_x_netwm_startup_info_begin(Ecore_X_Window window,
2767 Ecore_X_Startup_Info *info;
2769 if (!startup_info) return 0;
2770 info = ecore_hash_get(startup_info, (void *)window);
2773 printf("Already got info for win: 0x%x\n", window);
2774 _ecore_x_netwm_startup_info_free(info);
2776 info = calloc(1, sizeof(Ecore_X_Startup_Info));
2777 if (!info) return 0;
2780 info->buffer_size = 161;
2781 info->buffer = calloc(info->buffer_size, sizeof(char));
2784 _ecore_x_netwm_startup_info_free(info);
2787 memcpy(info->buffer, data, 20);
2789 info->buffer[info->length] = 0;
2790 ecore_hash_set(startup_info, (void *)info->win, info);
2791 if (strlen(info->buffer) != 20)
2793 /* We have a '\0' in there, the message is done */
2794 _ecore_x_netwm_startup_info_process(info);
2805 _ecore_x_netwm_startup_info(Ecore_X_Window window,
2809 Ecore_X_Startup_Info *info;
2812 if (!startup_info) return 0;
2813 info = ecore_hash_get(startup_info, (void *)window);
2814 if (!info) return 0;
2815 if ((info->length + 20) > info->buffer_size)
2817 info->buffer_size += 160;
2818 info->buffer = realloc(info->buffer, info->buffer_size * sizeof(char));
2821 ecore_hash_remove(startup_info, (void *)info->win);
2822 _ecore_x_netwm_startup_info_free(info);
2826 memcpy(info->buffer + info->length, data, 20);
2827 p = info->buffer + info->length;
2829 info->buffer[info->length] = 0;
2830 if (strlen(p) != 20)
2832 /* We have a '\0' in there, the message is done */
2833 _ecore_x_netwm_startup_info_process(info);
2844 * Set UTF-8 string property
2847 _ecore_x_window_prop_string_utf8_set(Ecore_X_Window window,
2851 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
2852 atom, ECORE_X_ATOM_UTF8_STRING,
2853 8, strlen(str), str);
2858 _ecore_x_window_prop_string_utf8_get_prefetch(Ecore_X_Window window,
2861 xcb_get_property_cookie_t cookie;
2863 cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, window,
2864 atom, ECORE_X_ATOM_UTF8_STRING,
2866 _ecore_xcb_cookie_cache(cookie.sequence);
2870 _ecore_x_window_prop_string_utf8_get_fetch(void)
2872 xcb_get_property_cookie_t cookie;
2873 xcb_get_property_reply_t *reply;
2875 cookie.sequence = _ecore_xcb_cookie_get();
2876 reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
2877 _ecore_xcb_reply_cache(reply);
2882 * Get UTF-8 string property
2885 _ecore_x_window_prop_string_utf8_get(Ecore_X_Window window __UNUSED__,
2886 Ecore_X_Atom atom __UNUSED__)
2888 xcb_get_property_reply_t *reply;
2892 reply = _ecore_xcb_reply_get();
2893 if (!reply) return NULL;
2895 if ((reply->format != 8) ||
2896 (reply->value_len <= 0))
2899 length = reply->value_len;
2900 str = (char *)malloc (sizeof (char) * (length + 1));
2905 memcpy(str, xcb_get_property_value(reply), length);
2913 * Process startup info
2916 _ecore_x_netwm_startup_info_process(Ecore_X_Startup_Info *info)
2918 Ecore_X_Event_Startup_Sequence *e;
2922 p = strchr(info->buffer, ':');
2925 ecore_hash_remove(startup_info, (void *)info->win);
2926 _ecore_x_netwm_startup_info_free(info);
2930 if (!strcmp(info->buffer, "new"))
2933 event = ECORE_X_EVENT_STARTUP_SEQUENCE_CHANGE;
2935 event = ECORE_X_EVENT_STARTUP_SEQUENCE_NEW;
2938 else if (!strcmp(info->buffer, "change"))
2940 event = ECORE_X_EVENT_STARTUP_SEQUENCE_CHANGE;
2942 else if (!strcmp(info->buffer, "remove"))
2943 event = ECORE_X_EVENT_STARTUP_SEQUENCE_REMOVE;
2946 ecore_hash_remove(startup_info, (void *)info->win);
2947 _ecore_x_netwm_startup_info_free(info);
2953 if (!_ecore_x_netwm_startup_info_parse(info, p))
2955 ecore_hash_remove(startup_info, (void *)info->win);
2956 _ecore_x_netwm_startup_info_free(info);
2962 e = calloc(1, sizeof(Ecore_X_Event_Startup_Sequence));
2965 ecore_hash_remove(startup_info, (void *)info->win);
2966 _ecore_x_netwm_startup_info_free(info);
2970 ecore_event_add(event, e, NULL, NULL);
2973 if (event == ECORE_X_EVENT_STARTUP_SEQUENCE_REMOVE)
2975 ecore_hash_remove(startup_info, (void *)info->win);
2976 _ecore_x_netwm_startup_info_free(info);
2980 /* Discard buffer */
2982 info->buffer[0] = 0;
2988 * Parse startup info
2991 _ecore_x_netwm_startup_info_parse(Ecore_X_Startup_Info *info,
2997 int in_quot_sing, in_quot_dbl, escaped;
3003 while (*data == ' ') data++;
3006 data = strchr(key, '=');
3007 if (!data) return 0;
3019 if ((pp - value) >= 1024) return 0;
3026 else if (in_quot_sing)
3030 else if (*p == '\'')
3038 else if (in_quot_dbl)
3042 else if (*p == '\"')
3054 else if (*p == '\'')
3056 else if (*p == '\"')
3070 if ((in_quot_dbl) || (in_quot_sing)) return 0;
3075 if (!strcmp(key, "ID"))
3077 if ((info->id) && (strcmp(info->id, value))) return 0;
3078 info->id = strdup(value);
3079 p = strstr(value, "_TIME");
3082 info->timestamp = atoi(p + 5);
3085 else if (!strcmp(key, "NAME"))
3087 if (info->name) free(info->name);
3088 info->name = strdup(value);
3090 else if (!strcmp(key, "SCREEN"))
3092 info->screen = atoi(value);
3094 else if (!strcmp(key, "BIN"))
3096 if (info->bin) free(info->bin);
3097 info->bin = strdup(value);
3099 else if (!strcmp(key, "ICON"))
3101 if (info->icon) free(info->icon);
3102 info->icon = strdup(value);
3104 else if (!strcmp(key, "DESKTOP"))
3106 info->desktop = atoi(value);
3108 else if (!strcmp(key, "TIMESTAMP"))
3110 if (!info->timestamp)
3111 info->timestamp = atoi(value);
3113 else if (!strcmp(key, "DESCRIPTION"))
3115 if (info->description) free(info->description);
3116 info->description = strdup(value);
3118 else if (!strcmp(key, "WMCLASS"))
3120 if (info->wmclass) free(info->wmclass);
3121 info->wmclass = strdup(value);
3123 else if (!strcmp(key, "SILENT"))
3125 info->silent = atoi(value);
3129 printf("Ecore X Sequence, Unknown: %s=%s\n", key, value);
3132 if (!info->id) return 0;
3138 * Free startup info struct
3141 _ecore_x_netwm_startup_info_free(void *data)
3143 Ecore_X_Startup_Info *info;
3147 if (info->buffer) free(info->buffer);
3148 if (info->id) free(info->id);
3149 if (info->name) free(info->name);
3150 if (info->bin) free(info->bin);
3151 if (info->icon) free(info->icon);
3152 if (info->description) free(info->description);
3153 if (info->wmclass) free(info->wmclass);
3158 * Is screen composited?
3161 /* FIXME: one round trip can be removed. Can we keep it ? */
3164 * Check whether a screen is composited or not.
3165 * @param screen The screen index.
3167 * Return 1 if @p screen is composited, 0 otherwise.
3168 * @ingroup Ecore_X_NetWM_Group
3171 ecore_x_screen_is_composited(int screen)
3174 xcb_intern_atom_cookie_t cookie_atom;
3175 xcb_get_selection_owner_cookie_t cookie_owner;
3176 xcb_intern_atom_reply_t *reply_atom;
3177 xcb_get_selection_owner_reply_t *reply_owner;
3178 Ecore_X_Window window;
3181 snprintf(buf, sizeof(buf), "_NET_WM_CM_S%d", screen);
3182 cookie_atom = xcb_intern_atom_unchecked(_ecore_xcb_conn, 1,
3184 reply_atom = xcb_intern_atom_reply(_ecore_xcb_conn, cookie_atom, NULL);
3185 if (!reply_atom) return 0;
3186 atom = reply_atom->atom;
3189 cookie_owner = xcb_get_selection_owner_unchecked(_ecore_xcb_conn, atom);
3190 reply_owner = xcb_get_selection_owner_reply(_ecore_xcb_conn, cookie_owner, NULL);
3191 if (!reply_owner) return 0;
3193 window = reply_owner->owner;
3196 return window != XCB_NONE;