summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Fontaine <arnau@debian.org>2009-11-22 16:57:28 +0100
committerArnaud Fontaine <arfontaine@ITEM-58736.dhcp.oxfd.uk.sopra>2010-02-11 14:47:30 +0000
commitadab882a7d49f898cfead29ec4fd3968fc6a1b14 (patch)
tree83292c4de36abc9067902012cfe81997de0c6034
parent9d1433f5f9f4524e34b6132c34bda994873dd5b3 (diff)
Clean up
-rw-r--r--ewmh/ewmh.c.m41404
-rw-r--r--ewmh/xcb_ewmh.h.m4138
2 files changed, 737 insertions, 805 deletions
diff --git a/ewmh/ewmh.c.m4 b/ewmh/ewmh.c.m4
index 5038d37..836ef8d 100644
--- a/ewmh/ewmh.c.m4
+++ b/ewmh/ewmh.c.m4
@@ -37,11 +37,9 @@
#include "xcb_aux.h"
#include "../xcb-util-common.h"
-#define ROOT_WINDOW_MESSAGE_EVENT_MASK (XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | \
- XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT)
-
/**
- * @brief The structure used on initialization
+ * @brief The structure used on screen initialization including the
+ * atoms name and its length
*/
typedef struct {
/** The Atom name length */
@@ -55,51 +53,58 @@ define(`DO_ENTRY', `
define(`DO', `DO_ENTRY(`$1', `$2')ifelse(`$2', , , `DO(shift($@))')')dnl
+/**
+ * @brief List of atoms where each entry contains the Atom name and
+ * its length
+ */
static ewmh_atom_t ewmh_atoms[] = {dnl
- include(atomlist.m4)dnl
+ include(atomlist.m4)dnl
};
#define NB_EWMH_ATOMS countof(ewmh_atoms)
+/** Get the number of elements from the reply length */
#define GET_NB_FROM_LEN(len, shift_value) ((len) >> (shift_value))
+
+/** Get the length of elements from the number of elements of a reply */
#define GET_LEN_FROM_NB(nb, shift_value) ((nb) << (shift_value))
/**
* Common functions and macro
*/
-#define DO_GET_PROPERTY(atom, name, request_type, length) \
- xcb_get_property_cookie_t \
- xcb_ewmh_get_##name(xcb_ewmh_connection_t *ewmh, \
- xcb_window_t window) \
- { \
- return xcb_get_property(ewmh->connection, 0, window, ewmh->atom, \
- request_type, 0, length); \
-} \
- \
-xcb_get_property_cookie_t \
-xcb_ewmh_get_##name##_unchecked(xcb_ewmh_connection_t *ewmh, \
- xcb_window_t window) \
-{ \
- return xcb_get_property_unchecked(ewmh->connection, 0, window, \
- ewmh->atom, request_type, 0, \
- length); \
-}
+#define DO_GET_PROPERTY(atom, name, request_type, length) \
+ xcb_get_property_cookie_t \
+ xcb_ewmh_get_##name(xcb_ewmh_connection_t *ewmh, \
+ xcb_window_t window) \
+ { \
+ return xcb_get_property(ewmh->connection, 0, window, ewmh->atom, \
+ request_type, 0, length); \
+ } \
+ \
+ xcb_get_property_cookie_t \
+ xcb_ewmh_get_##name##_unchecked(xcb_ewmh_connection_t *ewmh, \
+ xcb_window_t window) \
+ { \
+ return xcb_get_property_unchecked(ewmh->connection, 0, window, \
+ ewmh->atom, request_type, 0, \
+ length); \
+ }
-#define DO_GET_ROOT_PROPERTY(atom, name, request_type, length) \
- xcb_get_property_cookie_t \
- xcb_ewmh_get_##name(xcb_ewmh_connection_t *ewmh) \
- { \
- return xcb_get_property(ewmh->connection, 0, ewmh->root, \
- ewmh->atom, request_type, 0, length); \
- } \
- \
- xcb_get_property_cookie_t \
- xcb_ewmh_get_##name##_unchecked(xcb_ewmh_connection_t *ewmh) \
- { \
- return xcb_get_property_unchecked(ewmh->connection, 0, ewmh->root, \
- ewmh->atom, request_type, 0, \
- length); \
+#define DO_GET_ROOT_PROPERTY(atom, name, request_type, length) \
+ xcb_get_property_cookie_t \
+ xcb_ewmh_get_##name(xcb_ewmh_connection_t *ewmh) \
+ { \
+ return xcb_get_property(ewmh->connection, 0, ewmh->root, \
+ ewmh->atom, request_type, 0, length); \
+ } \
+ \
+ xcb_get_property_cookie_t \
+ xcb_ewmh_get_##name##_unchecked(xcb_ewmh_connection_t *ewmh) \
+ { \
+ return xcb_get_property_unchecked(ewmh->connection, 0, ewmh->root, \
+ ewmh->atom, request_type, 0, \
+ length); \
}
/**
@@ -118,110 +123,118 @@ xcb_ewmh_get_##name##_unchecked(xcb_ewmh_connection_t *ewmh, \
*/
/**
- * Macro defining function for set_property and get_property functions
- */
-#define DO_SET_SINGLE_VALUE_PROPERTY(atom, name, name_type, request_type) \
- xcb_void_cookie_t \
- xcb_ewmh_set_##name##_checked(xcb_ewmh_connection_t *ewmh, \
- xcb_window_t window, \
- name_type value) \
- { \
- return xcb_change_property_checked(ewmh->connection, \
- XCB_PROP_MODE_REPLACE, \
- window, ewmh->atom, \
- request_type, 32, 1, \
- &value); \
- } \
- \
- xcb_void_cookie_t \
- xcb_ewmh_set_##name(xcb_ewmh_connection_t *ewmh, \
- xcb_window_t window, \
- name_type value) \
- { \
- return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, \
- window, ewmh->atom, request_type, 32, 1, \
- &value); \
- }
-
-#define DO_SET_ROOT_SINGLE_VALUE_PROPERTY(atom, name, name_type, request_type) \
- xcb_void_cookie_t \
- xcb_ewmh_set_##name##_checked(xcb_ewmh_connection_t *ewmh, \
- name_type value) \
- { \
- return xcb_change_property_checked(ewmh->connection, \
- XCB_PROP_MODE_REPLACE, \
- ewmh->root, ewmh->atom, \
- request_type, 32, 1, &value); \
- } \
- \
- xcb_void_cookie_t \
- xcb_ewmh_set_##name(xcb_ewmh_connection_t *ewmh, \
- name_type value) \
- { \
- return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, \
- ewmh->root, ewmh->atom, request_type, \
- 32, 1, &value); \
- }
-
-/**
- * Macro defining a generic function for reply containing a single
- * value
+ * Macro defining a generic function for reply with a single value,
+ * considering that the value is 32-bit long (actually only used for
+ * WINDOW and CARDINAL)
*/
-#define DO_REPLY_SINGLE_VALUE_ATOM(name, name_type, reply_type) \
- static uint8_t \
- get_single_##name##_from_reply(name_type *atom_value, \
- xcb_get_property_reply_t *r) \
- { \
- if(!r || r->type != reply_type || r->format != 32 || \
- xcb_get_property_value_length(r) != 4) \
- return 0; \
- \
- *atom_value = *((name_type *) xcb_get_property_value(r)); \
- return 1; \
- } \
- \
- static uint8_t \
- get_single_##name##_reply(xcb_ewmh_connection_t *ewmh, \
- xcb_get_property_cookie_t cookie, \
- name_type *atom_value, \
- xcb_generic_error_t **e) \
- { \
- xcb_get_property_reply_t *r = xcb_get_property_reply(ewmh->connection, cookie, e); \
- const uint8_t ret = get_single_##name##_from_reply(atom_value, r); \
- free(r); \
- return ret; \
+#define DO_REPLY_SINGLE_VALUE_ATOM(name, name_type, reply_type) \
+ static uint8_t \
+ get_single_##name##_from_reply(name_type *atom_value, \
+ xcb_get_property_reply_t *r) \
+ { \
+ if(!r || r->type != reply_type || r->format != 32 || \
+ xcb_get_property_value_length(r) != 4) \
+ return 0; \
+ \
+ *atom_value = *((name_type *) xcb_get_property_value(r)); \
+ return 1; \
+ } \
+ \
+ static uint8_t \
+ get_single_##name##_reply(xcb_ewmh_connection_t *ewmh, \
+ xcb_get_property_cookie_t cookie, \
+ name_type *atom_value, \
+ xcb_generic_error_t **e) \
+ { \
+ xcb_get_property_reply_t *r = \
+ xcb_get_property_reply(ewmh->connection, \
+ cookie, e); \
+ \
+ const uint8_t ret = get_single_##name##_from_reply(atom_value, r); \
+ \
+ free(r); \
+ return ret; \
}
+/** Define reply functions for common WINDOW Atom */
DO_REPLY_SINGLE_VALUE_ATOM(window, xcb_window_t, WINDOW)
+
+/** Define reply functions for common CARDINAL Atom */
DO_REPLY_SINGLE_VALUE_ATOM(cardinal, uint32_t, CARDINAL)
-#define DO_ACCESSORS_SINGLE_VALUE_ATOM(atom, name, reply_type, out_type, func_reply) \
- DO_GET_PROPERTY(atom, name, reply_type, 1L) \
- DO_SET_SINGLE_VALUE_PROPERTY(atom, name, out_type, reply_type) \
- DO_ACCESSORS_GET_SINGLE_VALUE_ATOM(atom, name, reply_type, out_type, func_reply)
-
-#define DO_ACCESSORS_ROOT_SINGLE_VALUE_ATOM(atom, name, reply_type, out_type, func_reply) \
- DO_GET_ROOT_PROPERTY(atom, name, reply_type, 1L) \
- DO_SET_ROOT_SINGLE_VALUE_PROPERTY(atom, name, out_type, reply_type) \
- DO_ACCESSORS_GET_SINGLE_VALUE_ATOM(atom, name, reply_type, out_type, func_reply)
-
-#define DO_ACCESSORS_GET_SINGLE_VALUE_ATOM(atom, name, reply_type, out_type, func_reply) \
- uint8_t \
- xcb_ewmh_get_##name##_from_reply(out_type *out, \
- xcb_get_property_reply_t *r) \
- { \
- return get_single_##func_reply##_from_reply(out, r); \
- } \
- \
- uint8_t \
- xcb_ewmh_get_##name##_reply(xcb_ewmh_connection_t *ewmh, \
- xcb_get_property_cookie_t cookie, \
- out_type *out, \
- xcb_generic_error_t **e) \
- { \
- return get_single_##func_reply##_reply(ewmh, cookie, out, e); \
+#define DO_GET_SINGLE_VALUE_ATOM(atom, name, reply_type, \
+ out_type, func_reply) \
+ uint8_t \
+ xcb_ewmh_get_##name##_from_reply(out_type *out, \
+ xcb_get_property_reply_t *r) \
+ { \
+ return get_single_##func_reply##_from_reply(out, r); \
+ } \
+ \
+ uint8_t \
+ xcb_ewmh_get_##name##_reply(xcb_ewmh_connection_t *ewmh, \
+ xcb_get_property_cookie_t cookie, \
+ out_type *out, \
+ xcb_generic_error_t **e) \
+ { \
+ return get_single_##func_reply##_reply(ewmh, cookie, out, e); \
}
+#define DO_SINGLE_VALUE_ATOM(atom, name, reply_type, \
+ out_type, func_reply) \
+ DO_GET_PROPERTY(atom, name, reply_type, 1L) \
+ \
+ xcb_void_cookie_t \
+ xcb_ewmh_set_##name##_checked(xcb_ewmh_connection_t *ewmh, \
+ xcb_window_t window, \
+ out_type value) \
+ { \
+ return xcb_change_property_checked(ewmh->connection, \
+ XCB_PROP_MODE_REPLACE, \
+ window, ewmh->atom, \
+ reply_type, 32, 1, \
+ &value); \
+ } \
+ \
+ xcb_void_cookie_t \
+ xcb_ewmh_set_##name(xcb_ewmh_connection_t *ewmh, \
+ xcb_window_t window, \
+ out_type value) \
+ { \
+ return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, \
+ window, ewmh->atom, reply_type, 32, 1, \
+ &value); \
+ } \
+ \
+ DO_GET_SINGLE_VALUE_ATOM(atom, name, reply_type, out_type, \
+ func_reply)
+
+#define DO_ROOT_SINGLE_VALUE_ATOM(atom, name, reply_type, \
+ out_type, func_reply) \
+ DO_GET_ROOT_PROPERTY(atom, name, reply_type, 1L) \
+ \
+ xcb_void_cookie_t \
+ xcb_ewmh_set_##name##_checked(xcb_ewmh_connection_t *ewmh, \
+ out_type value) \
+ { \
+ return xcb_change_property_checked(ewmh->connection, \
+ XCB_PROP_MODE_REPLACE, \
+ ewmh->root, ewmh->atom, \
+ reply_type, 32, 1, &value); \
+ } \
+ \
+ xcb_void_cookie_t \
+ xcb_ewmh_set_##name(xcb_ewmh_connection_t *ewmh, \
+ out_type value) \
+ { \
+ return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, \
+ ewmh->root, ewmh->atom, reply_type, \
+ 32, 1, &value); \
+ } \
+ \
+ DO_GET_SINGLE_VALUE_ATOM(atom, name, reply_type, out_type, \
+ func_reply)
+
/**
* Generic function for EWMH atoms with a list of values which may be
* actually WINDOW or ATOM.
@@ -234,59 +247,6 @@ DO_REPLY_SINGLE_VALUE_ATOM(cardinal, uint32_t, CARDINAL)
* _NET_WM_ALLOWED_ACTIONS, ATOM[]
*/
-#define DO_SET_LIST_VALUES_PROPERTY(atom, name, name_type, request_type, len_shift) \
- xcb_void_cookie_t \
- xcb_ewmh_set_##name##_checked(xcb_ewmh_connection_t *ewmh, \
- xcb_window_t window, \
- uint32_t list_len, \
- name_type *list) \
- { \
- return xcb_change_property_checked(ewmh->connection, \
- XCB_PROP_MODE_REPLACE, window, \
- ewmh->atom, request_type, 32, \
- GET_LEN_FROM_NB(list_len, \
- len_shift), \
- list); \
- } \
- \
- xcb_void_cookie_t \
- xcb_ewmh_set_##name(xcb_ewmh_connection_t *ewmh, \
- xcb_window_t window, \
- uint32_t list_len, \
- name_type *list) \
- { \
- return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, \
- window, ewmh->atom, request_type, 32, \
- GET_LEN_FROM_NB(list_len, len_shift), \
- list); \
- }
-
-#define DO_SET_ROOT_LIST_VALUES_PROPERTY(atom, name, name_type, request_type, len_shift) \
- xcb_void_cookie_t \
- xcb_ewmh_set_##name##_checked(xcb_ewmh_connection_t *ewmh, \
- uint32_t list_len, \
- name_type *list) \
- { \
- return xcb_change_property_checked(ewmh->connection, \
- XCB_PROP_MODE_REPLACE, \
- ewmh->root, ewmh->atom, \
- request_type, 32, \
- GET_LEN_FROM_NB(list_len, \
- len_shift), \
- list); \
- } \
- \
- xcb_void_cookie_t \
- xcb_ewmh_set_##name(xcb_ewmh_connection_t *ewmh, \
- uint32_t list_len, \
- name_type *list) \
- { \
- return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, \
- ewmh->root, ewmh->atom, request_type, \
- 32, GET_LEN_FROM_NB(list_len, len_shift), \
- list); \
- }
-
/**
* Macro defining a generic function for reply containing a list of
* values and also defines a function to wipe the reply.
@@ -296,45 +256,147 @@ DO_REPLY_SINGLE_VALUE_ATOM(cardinal, uint32_t, CARDINAL)
* component (such as coordinates), and divide by (r->format / 8)
* where r->format always equals to 32 in this case.
*/
-#define DO_REPLY_LIST_VALUES_ATOM(visibility, name, name_type, reply_type, len_shift) \
- visibility uint8_t \
+#define DO_REPLY_LIST_VALUES_ATOM(name, name_type, reply_type, len_shift) \
+ uint8_t \
xcb_ewmh_get_##name##_from_reply(xcb_ewmh_get_##name##_reply_t *data, \
- xcb_get_property_reply_t *r) \
- { \
+ xcb_get_property_reply_t *r) \
+ { \
if(!r || r->type != reply_type || r->format != 32) \
- return 0; \
- \
- data->_reply = r; \
- data->name##_len = GET_NB_FROM_LEN(xcb_get_property_value_length(data->_reply), len_shift + 2); \
- data->name = (name_type *) xcb_get_property_value(data->_reply); \
- return 1; \
- } \
- \
- visibility uint8_t \
- xcb_ewmh_get_##name##_reply(xcb_ewmh_connection_t *ewmh, \
- xcb_get_property_cookie_t cookie, \
- xcb_ewmh_get_##name##_reply_t *data, \
- xcb_generic_error_t **e) \
- { \
- xcb_get_property_reply_t *r = xcb_get_property_reply(ewmh->connection, cookie, e); \
- const uint8_t ret = xcb_ewmh_get_##name##_from_reply(data, r); \
- \
- /* If the last call was not successful (ret equals to 0), then \
- just free the reply as the data value is not consistent */ \
- if(!ret) \
- free(r); \
- \
- return ret; \
- } \
- \
- void \
- xcb_ewmh_get_##name##_reply_wipe(xcb_ewmh_get_##name##_reply_t *data) \
- { \
- free(data->_reply); \
+ return 0; \
+ \
+ data->_reply = r; \
+ data->name##_len = \
+ GET_NB_FROM_LEN(xcb_get_property_value_length(data->_reply), \
+ len_shift + 2); \
+ \
+ data->name = (name_type *) xcb_get_property_value(data->_reply); \
+ return 1; \
+ } \
+ \
+ uint8_t \
+ xcb_ewmh_get_##name##_reply(xcb_ewmh_connection_t *ewmh, \
+ xcb_get_property_cookie_t cookie, \
+ xcb_ewmh_get_##name##_reply_t *data, \
+ xcb_generic_error_t **e) \
+ { \
+ xcb_get_property_reply_t *r = \
+ xcb_get_property_reply(ewmh->connection, \
+ cookie, e); \
+ \
+ const uint8_t ret = xcb_ewmh_get_##name##_from_reply(data, r); \
+ \
+ /* If the last call was not successful (ret equals to 0), then \
+ just free the reply as the data value is not consistent */ \
+ if(!ret) \
+ free(r); \
+ \
+ return ret; \
+ } \
+ \
+ void \
+ xcb_ewmh_get_##name##_reply_wipe(xcb_ewmh_get_##name##_reply_t *data) \
+ { \
+ free(data->_reply); \
}
-DO_REPLY_LIST_VALUES_ATOM(static, windows, xcb_window_t, WINDOW, 0)
-DO_REPLY_LIST_VALUES_ATOM(static, atoms, xcb_atom_t, ATOM, 0)
+#define DO_ROOT_LIST_VALUES(atom, name, kind_type, kind, shift) \
+ DO_GET_ROOT_PROPERTY(atom, name, kind_type, UINT_MAX) \
+ \
+ xcb_void_cookie_t \
+ xcb_ewmh_set_##name##_checked(xcb_ewmh_connection_t *ewmh, \
+ uint32_t list_len, \
+ xcb_##kind##_t *list) \
+ { \
+ return xcb_change_property_checked(ewmh->connection, \
+ XCB_PROP_MODE_REPLACE, \
+ ewmh->root, ewmh->atom, \
+ kind_type, 32, \
+ GET_LEN_FROM_NB(list_len, \
+ shift), \
+ list); \
+ } \
+ \
+ xcb_void_cookie_t \
+ xcb_ewmh_set_##name(xcb_ewmh_connection_t *ewmh, \
+ uint32_t list_len, \
+ xcb_##kind##_t *list) \
+ { \
+ return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, \
+ ewmh->root, ewmh->atom, kind_type, \
+ 32, GET_LEN_FROM_NB(list_len, shift), \
+ list); \
+ }
+
+#define DO_LIST_VALUES(atom, name, kind_type, kind) \
+ DO_GET_PROPERTY(atom, name, kind_type, UINT_MAX) \
+ \
+ xcb_void_cookie_t \
+ xcb_ewmh_set_##name##_checked(xcb_ewmh_connection_t *ewmh, \
+ xcb_window_t window, \
+ uint32_t list_len, \
+ xcb_##kind##_t *list) \
+ { \
+ return xcb_change_property_checked(ewmh->connection, \
+ XCB_PROP_MODE_REPLACE, window, \
+ ewmh->atom, kind_type, 32, \
+ list_len, list); \
+ } \
+ \
+ xcb_void_cookie_t \
+ xcb_ewmh_set_##name(xcb_ewmh_connection_t *ewmh, \
+ xcb_window_t window, \
+ uint32_t list_len, \
+ xcb_##kind##_t *list) \
+ { \
+ return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, \
+ window, ewmh->atom, kind_type, 32, \
+ list_len, list); \
+ } \
+ \
+ uint8_t \
+ xcb_ewmh_get_##name##_from_reply(xcb_ewmh_get_##kind##s_reply_t *name, \
+ xcb_get_property_reply_t *r) \
+ { \
+ return xcb_ewmh_get_##kind##s_from_reply(name, r); \
+ } \
+ \
+ uint8_t \
+ xcb_ewmh_get_##name##_reply(xcb_ewmh_connection_t *ewmh, \
+ xcb_get_property_cookie_t cookie, \
+ xcb_ewmh_get_##kind##s_reply_t *name, \
+ xcb_generic_error_t **e) \
+ { \
+ return xcb_ewmh_get_##kind##s_reply(ewmh, cookie, name, e); \
+ }
+
+#define DO_REPLY_STRUCTURE(name, out_type) \
+ uint8_t \
+ xcb_ewmh_get_##name##_from_reply(out_type *out, \
+ xcb_get_property_reply_t *r) \
+ { \
+ if(!r || r->type != CARDINAL || r->format != 32 || \
+ xcb_get_property_value_length(r) != sizeof(out_type)) \
+ return 0; \
+ \
+ memcpy(out, xcb_get_property_value(r), \
+ xcb_get_property_value_length(r)); \
+ \
+ return 1; \
+ } \
+ \
+ uint8_t \
+ xcb_ewmh_get_##name##_reply(xcb_ewmh_connection_t *ewmh, \
+ xcb_get_property_cookie_t cookie, \
+ out_type *out, \
+ xcb_generic_error_t **e) \
+ { \
+ xcb_get_property_reply_t *r = \
+ xcb_get_property_reply(ewmh->connection, cookie, e); \
+ \
+ const uint8_t ret = xcb_ewmh_get_##name##_from_reply(out, r); \
+ free(r); \
+ return ret; \
+ }
/**
* UTF8_STRING handling
@@ -342,8 +404,8 @@ DO_REPLY_LIST_VALUES_ATOM(static, atoms, xcb_atom_t, ATOM, 0)
static uint8_t
get_utf8_from_reply(xcb_ewmh_connection_t *ewmh,
- xcb_ewmh_get_utf8_strings_reply_t *data,
- xcb_get_property_reply_t *r)
+ xcb_ewmh_get_utf8_strings_reply_t *data,
+ xcb_get_property_reply_t *r)
{
if(!r || r->type != ewmh->UTF8_STRING || r->format != 8)
return 0;
@@ -357,11 +419,13 @@ get_utf8_from_reply(xcb_ewmh_connection_t *ewmh,
static uint8_t
get_utf8_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- xcb_ewmh_get_utf8_strings_reply_t *data,
- xcb_generic_error_t **e)
+ xcb_get_property_cookie_t cookie,
+ xcb_ewmh_get_utf8_strings_reply_t *data,
+ xcb_generic_error_t **e)
{
- xcb_get_property_reply_t *r = xcb_get_property_reply(ewmh->connection, cookie, e);
+ xcb_get_property_reply_t *r = xcb_get_property_reply(ewmh->connection,
+ cookie, e);
+
const uint8_t ret = get_utf8_from_reply(ewmh, data, r);
/* If the last call was not successful (ret equals to 0), then just
@@ -378,89 +442,89 @@ xcb_ewmh_get_utf8_strings_reply_wipe(xcb_ewmh_get_utf8_strings_reply_t *data)
free(data->_reply);
}
-#define DO_ACCESSORS_COMMON_UTF8_STRING(atom, name) \
- uint8_t \
- xcb_ewmh_get_##name##_from_reply(xcb_ewmh_connection_t *ewmh, \
- xcb_ewmh_get_utf8_strings_reply_t *data, \
- xcb_get_property_reply_t *r) \
- { \
- return get_utf8_from_reply(ewmh, data, r); \
- } \
- \
- uint8_t \
- xcb_ewmh_get_##name##_reply(xcb_ewmh_connection_t *ewmh, \
- xcb_get_property_cookie_t cookie, \
- xcb_ewmh_get_utf8_strings_reply_t *data, \
- xcb_generic_error_t **e) \
- { \
- return get_utf8_reply(ewmh, cookie, data, e); \
+#define DO_REPLY_UTF8_STRING(atom, name) \
+ uint8_t \
+ xcb_ewmh_get_##name##_from_reply(xcb_ewmh_connection_t *ewmh, \
+ xcb_ewmh_get_utf8_strings_reply_t *data, \
+ xcb_get_property_reply_t *r) \
+ { \
+ return get_utf8_from_reply(ewmh, data, r); \
+ } \
+ \
+ uint8_t \
+ xcb_ewmh_get_##name##_reply(xcb_ewmh_connection_t *ewmh, \
+ xcb_get_property_cookie_t cookie, \
+ xcb_ewmh_get_utf8_strings_reply_t *data, \
+ xcb_generic_error_t **e) \
+ { \
+ return get_utf8_reply(ewmh, cookie, data, e); \
}
-#define DO_ACCESSORS_ROOT_UTF8_STRING(atom, name) \
- DO_GET_ROOT_PROPERTY(atom, name, 0, UINT_MAX) \
- DO_ACCESSORS_COMMON_UTF8_STRING(atom, name) \
- \
- xcb_void_cookie_t \
- xcb_ewmh_set_##name(xcb_ewmh_connection_t *ewmh, \
- uint32_t strings_len, \
- const char *strings) \
- { \
- return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, \
- ewmh->root, ewmh->atom, \
- ewmh->UTF8_STRING, 8, strings_len, \
- strings); \
- } \
- \
- xcb_void_cookie_t \
- xcb_ewmh_set_##name##_checked(xcb_ewmh_connection_t *ewmh, \
- uint32_t strings_len, \
- const char *strings) \
- { \
- return xcb_change_property_checked(ewmh->connection, \
- XCB_PROP_MODE_REPLACE, \
- ewmh->root, ewmh->atom, \
- ewmh->UTF8_STRING, 8, \
- strings_len, strings); \
+#define DO_ROOT_UTF8_STRING(atom, name) \
+ DO_GET_ROOT_PROPERTY(atom, name, 0, UINT_MAX) \
+ DO_REPLY_UTF8_STRING(atom, name) \
+ \
+ xcb_void_cookie_t \
+ xcb_ewmh_set_##name(xcb_ewmh_connection_t *ewmh, \
+ uint32_t strings_len, \
+ const char *strings) \
+ { \
+ return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, \
+ ewmh->root, ewmh->atom, \
+ ewmh->UTF8_STRING, 8, strings_len, \
+ strings); \
+ } \
+ \
+ xcb_void_cookie_t \
+ xcb_ewmh_set_##name##_checked(xcb_ewmh_connection_t *ewmh, \
+ uint32_t strings_len, \
+ const char *strings) \
+ { \
+ return xcb_change_property_checked(ewmh->connection, \
+ XCB_PROP_MODE_REPLACE, \
+ ewmh->root, ewmh->atom, \
+ ewmh->UTF8_STRING, 8, \
+ strings_len, strings); \
}
-#define DO_ACCESSORS_UTF8_STRING(atom, name) \
- DO_GET_PROPERTY(atom, name, 0, UINT_MAX) \
- DO_ACCESSORS_COMMON_UTF8_STRING(atom, name) \
- \
- xcb_void_cookie_t \
- xcb_ewmh_set_##name(xcb_ewmh_connection_t *ewmh, \
- xcb_window_t window, \
- uint32_t strings_len, \
- const char *strings) \
- { \
+#define DO_UTF8_STRING(atom, name) \
+ DO_GET_PROPERTY(atom, name, 0, UINT_MAX) \
+ DO_REPLY_UTF8_STRING(atom, name) \
+ \
+ xcb_void_cookie_t \
+ xcb_ewmh_set_##name(xcb_ewmh_connection_t *ewmh, \
+ xcb_window_t window, \
+ uint32_t strings_len, \
+ const char *strings) \
+ { \
return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, \
- window, ewmh->atom, ewmh->UTF8_STRING, \
- 8, strings_len, strings); \
- } \
- \
- xcb_void_cookie_t \
- xcb_ewmh_set_##name##_checked(xcb_ewmh_connection_t *ewmh, \
- xcb_window_t window, \
- uint32_t strings_len, \
- const char *strings) \
- { \
- return xcb_change_property_checked(ewmh->connection, \
- XCB_PROP_MODE_REPLACE, \
- window, ewmh->atom, \
- ewmh->UTF8_STRING, 8, \
- strings_len, strings); \
+ window, ewmh->atom, ewmh->UTF8_STRING, \
+ 8, strings_len, strings); \
+ } \
+ \
+ xcb_void_cookie_t \
+ xcb_ewmh_set_##name##_checked(xcb_ewmh_connection_t *ewmh, \
+ xcb_window_t window, \
+ uint32_t strings_len, \
+ const char *strings) \
+ { \
+ return xcb_change_property_checked(ewmh->connection, \
+ XCB_PROP_MODE_REPLACE, \
+ window, ewmh->atom, \
+ ewmh->UTF8_STRING, 8, \
+ strings_len, strings); \
}
/**
* ClientMessage generic function
*/
xcb_void_cookie_t
-send_client_message(xcb_connection_t *c,
- xcb_window_t window,
- xcb_window_t dest,
- xcb_atom_t atom,
- uint32_t data_len,
- const uint32_t *data)
+xcb_ewmh_send_client_message(xcb_connection_t *c,
+ xcb_window_t window,
+ xcb_window_t dest,
+ xcb_atom_t atom,
+ uint32_t data_len,
+ const uint32_t *data)
{
xcb_client_message_event_t ev;
memset(&ev, 0, sizeof(xcb_client_message_event_t));
@@ -473,18 +537,22 @@ send_client_message(xcb_connection_t *c,
for(; data_len != 0; data_len--)
ev.data.data32[0] = data[1];
- return xcb_send_event(c, 0, dest, ROOT_WINDOW_MESSAGE_EVENT_MASK,
- (char *) &ev);
+ return xcb_send_event(c, 0, dest, XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
+ XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT,
+ (char *) &ev);
}
+DO_REPLY_LIST_VALUES_ATOM(windows, xcb_window_t, WINDOW, 0)
+DO_REPLY_LIST_VALUES_ATOM(atoms, xcb_atom_t, ATOM, 0)
+
/**
* Atoms initialisation
*/
xcb_intern_atom_cookie_t *
xcb_ewmh_init_atoms(xcb_connection_t *c,
- xcb_ewmh_connection_t * const ewmh,
- const int screen_nbr)
+ xcb_ewmh_connection_t * const ewmh,
+ const int screen_nbr)
{
ewmh->connection = c;
@@ -495,24 +563,25 @@ xcb_ewmh_init_atoms(xcb_connection_t *c,
/* Compute _NET_WM_CM_Sn according to the screen number 'n' */
char wm_cm_sn[32];
const int wm_cm_sn_len = snprintf(wm_cm_sn, 32, "_NET_WM_CM_S%d",
- screen_nbr);
+ screen_nbr);
assert(wm_cm_sn_len > 0 && wm_cm_sn_len < 32);
ewmh->root = screen->root;
xcb_intern_atom_cookie_t *ewmh_cookies = malloc(sizeof(xcb_intern_atom_cookie_t) *
- NB_EWMH_ATOMS);
+ NB_EWMH_ATOMS);
uint8_t i;
for(i = 0; i < NB_EWMH_ATOMS; i++)
{
if(strcmp(ewmh_atoms[i].name, "_NET_WM_CM_Sn") == 0)
- ewmh_cookies[i] = xcb_intern_atom(ewmh->connection, 0, wm_cm_sn_len, wm_cm_sn);
+ ewmh_cookies[i] = xcb_intern_atom(ewmh->connection, 0,
+ wm_cm_sn_len, wm_cm_sn);
else
- ewmh_cookies[i] = xcb_intern_atom(ewmh->connection, 0,
- ewmh_atoms[i].name_len,
- ewmh_atoms[i].name);
+ ewmh_cookies[i] = xcb_intern_atom(ewmh->connection, 0,
+ ewmh_atoms[i].name_len,
+ ewmh_atoms[i].name);
}
return ewmh_cookies;
@@ -520,8 +589,8 @@ xcb_ewmh_init_atoms(xcb_connection_t *c,
uint8_t
xcb_ewmh_init_atoms_replies(xcb_ewmh_connection_t * const ewmh,
- xcb_intern_atom_cookie_t *ewmh_cookies,
- xcb_generic_error_t **e)
+ xcb_intern_atom_cookie_t *ewmh_cookies,
+ xcb_generic_error_t **e)
{
uint8_t i = 0;
xcb_intern_atom_reply_t *reply;
@@ -532,12 +601,12 @@ xcb_ewmh_init_atoms_replies(xcb_ewmh_connection_t * const ewmh,
free(reply);
')dnl
-include(atomlist.m4)dnl
+ include(atomlist.m4)dnl
- free(ewmh_cookies);
+ free(ewmh_cookies);
return 1;
-init_atoms_replies_error:
+ init_atoms_replies_error:
free(ewmh_cookies);
return 0;
}
@@ -546,69 +615,24 @@ init_atoms_replies_error:
* _NET_SUPPORTED
*/
-DO_GET_ROOT_PROPERTY(_NET_SUPPORTED, supported, ATOM, UINT_MAX)
-DO_SET_ROOT_LIST_VALUES_PROPERTY(_NET_SUPPORTED, supported, xcb_atom_t, ATOM, 0)
-
-uint8_t
-xcb_ewmh_get_supported_from_reply(xcb_ewmh_get_atoms_reply_t *supported,
- xcb_get_property_reply_t *r)
-{
- return xcb_ewmh_get_atoms_from_reply(supported, r);
-}
-
-uint8_t
-xcb_ewmh_get_supported_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- xcb_ewmh_get_atoms_reply_t *supported,
- xcb_generic_error_t **e)
-{
- return xcb_ewmh_get_atoms_reply(ewmh, cookie, supported, e);
-}
+DO_ROOT_LIST_VALUES(_NET_SUPPORTED, supported, ATOM, atom, 0)
/**
* _NET_CLIENT_LIST
* _NET_CLIENT_LIST_STACKING
*/
-DO_GET_ROOT_PROPERTY(_NET_CLIENT_LIST, client_list, WINDOW, UINT_MAX)
-DO_SET_ROOT_LIST_VALUES_PROPERTY(_NET_CLIENT_LIST, client_list, xcb_window_t,
- WINDOW, 0)
-
-DO_GET_ROOT_PROPERTY(_NET_CLIENT_LIST_STACKING, client_list_stacking, WINDOW, UINT_MAX)
-DO_SET_ROOT_LIST_VALUES_PROPERTY(_NET_CLIENT_LIST_STACKING, client_list_stacking,
- xcb_window_t, WINDOW, 0)
+DO_ROOT_LIST_VALUES(_NET_CLIENT_LIST, client_list, WINDOW, window, 0)
-uint8_t
-xcb_ewmh_get_client_list_from_reply(xcb_ewmh_get_windows_reply_t *clients,
- xcb_get_property_reply_t *r)
-{
- return xcb_ewmh_get_windows_from_reply(clients, r);
-}
-
-uint8_t
-xcb_ewmh_get_client_list_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- xcb_ewmh_get_windows_reply_t *clients,
- xcb_generic_error_t **e)
-{
- return xcb_ewmh_get_windows_reply(ewmh, cookie, clients, e);
-}
+DO_ROOT_LIST_VALUES(_NET_CLIENT_LIST_STACKING, client_list_stacking, WINDOW,
+ window, 0)
/**
* _NET_NUMBER_OF_DESKTOPS
*/
-DO_ACCESSORS_ROOT_SINGLE_VALUE_ATOM(_NET_NUMBER_OF_DESKTOPS, number_of_desktops,
- CARDINAL, uint32_t, cardinal)
-
-xcb_void_cookie_t
-xcb_ewmh_request_change_number_of_desktops(xcb_ewmh_connection_t *ewmh,
- uint32_t new_number_of_desktops)
-{
- return send_client_message(ewmh->connection, XCB_NONE, ewmh->root,
- ewmh->_NET_NUMBER_OF_DESKTOPS, 1,
- &new_number_of_desktops);
-}
+DO_ROOT_SINGLE_VALUE_ATOM(_NET_NUMBER_OF_DESKTOPS, number_of_desktops,
+ CARDINAL, uint32_t, cardinal)
/**
* _NET_DESKTOP_GEOMETRY
@@ -618,38 +642,38 @@ DO_GET_ROOT_PROPERTY(_NET_DESKTOP_GEOMETRY, desktop_geometry, CARDINAL, 2L)
xcb_void_cookie_t
xcb_ewmh_set_desktop_geometry(xcb_ewmh_connection_t *ewmh,
- uint32_t new_width, uint32_t new_height)
+ uint32_t new_width, uint32_t new_height)
{
const uint32_t data[] = { new_width, new_height };
return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, ewmh->root,
- ewmh->_NET_DESKTOP_GEOMETRY, CARDINAL, 32, 2, data);
+ ewmh->_NET_DESKTOP_GEOMETRY, CARDINAL, 32, 2, data);
}
xcb_void_cookie_t
xcb_ewmh_set_desktop_geometry_checked(xcb_ewmh_connection_t *ewmh,
- uint32_t new_width, uint32_t new_height)
+ uint32_t new_width, uint32_t new_height)
{
const uint32_t data[] = { new_width, new_height };
return xcb_change_property_checked(ewmh->connection, XCB_PROP_MODE_REPLACE,
- ewmh->root, ewmh->_NET_DESKTOP_GEOMETRY,
- CARDINAL, 32, 2, data);
+ ewmh->root, ewmh->_NET_DESKTOP_GEOMETRY,
+ CARDINAL, 32, 2, data);
}
xcb_void_cookie_t
xcb_ewmh_request_change_desktop_geometry(xcb_ewmh_connection_t *ewmh,
- uint32_t new_width, uint32_t new_height)
+ uint32_t new_width, uint32_t new_height)
{
const uint32_t data[] = { new_width, new_height };
- return send_client_message(ewmh->connection, XCB_NONE, ewmh->root,
- ewmh->_NET_DESKTOP_GEOMETRY, 2, data);
+ return xcb_ewmh_send_client_message(ewmh->connection, XCB_NONE, ewmh->root,
+ ewmh->_NET_DESKTOP_GEOMETRY, 2, data);
}
uint8_t
xcb_ewmh_get_desktop_geometry_from_reply(uint32_t *width, uint32_t *height,
- xcb_get_property_reply_t *r)
+ xcb_get_property_reply_t *r)
{
if(!r || r->type != CARDINAL || r->format != 32 ||
xcb_get_property_value_length(r) != 8)
@@ -665,9 +689,9 @@ xcb_ewmh_get_desktop_geometry_from_reply(uint32_t *width, uint32_t *height,
uint8_t
xcb_ewmh_get_desktop_geometry_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- uint32_t *width, uint32_t *height,
- xcb_generic_error_t **e)
+ xcb_get_property_cookie_t cookie,
+ uint32_t *width, uint32_t *height,
+ xcb_generic_error_t **e)
{
xcb_get_property_reply_t *r = xcb_get_property_reply(ewmh->connection, cookie, e);
const uint8_t ret = xcb_ewmh_get_desktop_geometry_from_reply(width, height, r);
@@ -679,174 +703,123 @@ xcb_ewmh_get_desktop_geometry_reply(xcb_ewmh_connection_t *ewmh,
* _NET_DESKTOP_VIEWPORT
*/
-DO_GET_ROOT_PROPERTY(_NET_DESKTOP_VIEWPORT, desktop_viewport, CARDINAL, UINT_MAX)
-DO_SET_ROOT_LIST_VALUES_PROPERTY(_NET_DESKTOP_VIEWPORT, desktop_viewport,
- xcb_ewmh_coordinates_t, CARDINAL, 1)
+DO_ROOT_LIST_VALUES(_NET_DESKTOP_VIEWPORT, desktop_viewport, CARDINAL,
+ ewmh_coordinates, 1)
+
+DO_REPLY_LIST_VALUES_ATOM(desktop_viewport, xcb_ewmh_coordinates_t, CARDINAL, 1)
xcb_void_cookie_t
xcb_ewmh_request_change_desktop_viewport(xcb_ewmh_connection_t *ewmh,
- uint32_t x, uint32_t y)
+ uint32_t x, uint32_t y)
{
const uint32_t data[] = { x, y };
- return send_client_message(ewmh->connection, XCB_NONE, ewmh->root,
- ewmh->_NET_DESKTOP_VIEWPORT, 2, data);
+ return xcb_ewmh_send_client_message(ewmh->connection, XCB_NONE, ewmh->root,
+ ewmh->_NET_DESKTOP_VIEWPORT, 2, data);
}
-DO_REPLY_LIST_VALUES_ATOM(extern, desktop_viewport, xcb_ewmh_coordinates_t, CARDINAL, 1)
-
/**
* _NET_CURRENT_DESKTOP
*/
-DO_ACCESSORS_ROOT_SINGLE_VALUE_ATOM(_NET_CURRENT_DESKTOP, current_desktop,
- CARDINAL, uint32_t, cardinal)
+DO_ROOT_SINGLE_VALUE_ATOM(_NET_CURRENT_DESKTOP, current_desktop,
+ CARDINAL, uint32_t, cardinal)
xcb_void_cookie_t
xcb_ewmh_request_change_current_desktop(xcb_ewmh_connection_t *ewmh,
- uint32_t new_desktop,
- xcb_timestamp_t timestamp)
+ uint32_t new_desktop,
+ xcb_timestamp_t timestamp)
{
const uint32_t data[] = { new_desktop, timestamp };
- return send_client_message(ewmh->connection, XCB_NONE, ewmh->root,
- ewmh->_NET_CURRENT_DESKTOP, 2, data);
+ return xcb_ewmh_send_client_message(ewmh->connection, XCB_NONE, ewmh->root,
+ ewmh->_NET_CURRENT_DESKTOP, 2, data);
}
/**
* _NET_DESKTOP_NAMES
*/
-DO_ACCESSORS_ROOT_UTF8_STRING(_NET_DESKTOP_NAMES, desktop_names)
+DO_ROOT_UTF8_STRING(_NET_DESKTOP_NAMES, desktop_names)
/**
* _NET_ACTIVE_WINDOW
*/
-DO_ACCESSORS_ROOT_SINGLE_VALUE_ATOM(_NET_ACTIVE_WINDOW, active_window,
- WINDOW, xcb_window_t, window)
+DO_ROOT_SINGLE_VALUE_ATOM(_NET_ACTIVE_WINDOW, active_window,
+ WINDOW, xcb_window_t, window)
xcb_void_cookie_t
xcb_ewmh_request_change_active_window(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window_to_activate,
- xcb_ewmh_client_source_type_t source_indication,
- xcb_timestamp_t timestamp,
- xcb_window_t current_active_window)
+ xcb_window_t window_to_activate,
+ xcb_ewmh_client_source_type_t source_indication,
+ xcb_timestamp_t timestamp,
+ xcb_window_t current_active_window)
{
const uint32_t data[] = { source_indication, timestamp, current_active_window };
- return send_client_message(ewmh->connection, window_to_activate, ewmh->root,
- ewmh->_NET_ACTIVE_WINDOW, 3, data);
+ return xcb_ewmh_send_client_message(ewmh->connection, window_to_activate,
+ ewmh->root, ewmh->_NET_ACTIVE_WINDOW,
+ 3, data);
}
/**
* _NET_WORKAREA
*/
-DO_GET_ROOT_PROPERTY(_NET_WORKAREA, workarea, CARDINAL, UINT_MAX)
-DO_SET_ROOT_LIST_VALUES_PROPERTY(_NET_WORKAREA, workarea, xcb_ewmh_geometry_t, CARDINAL, 2)
-DO_REPLY_LIST_VALUES_ATOM(extern, workarea, xcb_ewmh_geometry_t, CARDINAL, 2)
+DO_ROOT_LIST_VALUES(_NET_WORKAREA, workarea, CARDINAL, ewmh_geometry, 2)
+DO_REPLY_LIST_VALUES_ATOM(workarea, xcb_ewmh_geometry_t, CARDINAL, 2)
/**
* _NET_SUPPORTING_WM_CHECK
*/
-DO_ACCESSORS_ROOT_SINGLE_VALUE_ATOM(_NET_SUPPORTING_WM_CHECK, supporting_wm_check,
- WINDOW, xcb_window_t, window)
+DO_ROOT_SINGLE_VALUE_ATOM(_NET_SUPPORTING_WM_CHECK, supporting_wm_check,
+ WINDOW, xcb_window_t, window)
/**
* _NET_VIRTUAL_ROOTS
*/
-DO_GET_ROOT_PROPERTY(_NET_VIRTUAL_ROOTS, virtual_roots, WINDOW, UINT_MAX)
-DO_SET_LIST_VALUES_PROPERTY(_NET_VIRTUAL_ROOTS, virtual_roots, xcb_window_t, WINDOW, 0)
-
-uint8_t
-xcb_ewmh_get_virtual_roots_from_reply(xcb_ewmh_get_windows_reply_t *virtual_roots,
- xcb_get_property_reply_t *r)
-{
- return xcb_ewmh_get_windows_from_reply(virtual_roots, r);
-}
-
-uint8_t
-xcb_ewmh_get_virtual_roots_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- xcb_ewmh_get_windows_reply_t *virtual_roots,
- xcb_generic_error_t **e)
-{
- return xcb_ewmh_get_windows_reply(ewmh, cookie, virtual_roots, e);
-}
+DO_ROOT_LIST_VALUES(_NET_VIRTUAL_ROOTS, virtual_roots, WINDOW, window, 0)
/**
* _NET_DESKTOP_LAYOUT
*/
DO_GET_ROOT_PROPERTY(_NET_DESKTOP_LAYOUT, desktop_layout, CARDINAL, 4)
+DO_REPLY_STRUCTURE(desktop_layout, xcb_ewmh_get_desktop_layout_reply_t)
xcb_void_cookie_t
xcb_ewmh_set_desktop_layout(xcb_ewmh_connection_t *ewmh,
- xcb_ewmh_desktop_layout_orientation_t orientation,
- uint32_t columns, uint32_t rows,
- xcb_ewmh_desktop_layout_starting_corner_t starting_corner)
+ xcb_ewmh_desktop_layout_orientation_t orientation,
+ uint32_t columns, uint32_t rows,
+ xcb_ewmh_desktop_layout_starting_corner_t starting_corner)
{
const uint32_t data[] = { orientation, columns, rows, starting_corner };
return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, ewmh->root,
- ewmh->_NET_DESKTOP_LAYOUT, CARDINAL, 32, 2, data);
+ ewmh->_NET_DESKTOP_LAYOUT, CARDINAL, 32, 2, data);
}
xcb_void_cookie_t
xcb_ewmh_set_desktop_layout_checked(xcb_ewmh_connection_t *ewmh,
- xcb_ewmh_desktop_layout_orientation_t orientation,
- uint32_t columns, uint32_t rows,
- xcb_ewmh_desktop_layout_starting_corner_t starting_corner)
+ xcb_ewmh_desktop_layout_orientation_t orientation,
+ uint32_t columns, uint32_t rows,
+ xcb_ewmh_desktop_layout_starting_corner_t starting_corner)
{
const uint32_t data[] = { orientation, columns, rows, starting_corner };
return xcb_change_property_checked(ewmh->connection, XCB_PROP_MODE_REPLACE,
- ewmh->root, ewmh->_NET_DESKTOP_LAYOUT,
- CARDINAL, 32, 2, data);
-}
-
-uint8_t
-xcb_ewmh_get_desktop_layout_from_reply(xcb_ewmh_get_desktop_layout_reply_t *desktop_layout,
- xcb_get_property_reply_t *r)
-{
- if(!r || r->type != CARDINAL || r->format != 32 ||
- GET_NB_FROM_LEN(xcb_get_property_value_length(r), 2) != 4)
- return 0;
-
- memcpy(desktop_layout, xcb_get_property_value(r),
- xcb_get_property_value_length(r));
-
- return 1;
-}
-
-uint8_t
-xcb_ewmh_get_desktop_layout_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- xcb_ewmh_get_desktop_layout_reply_t *desktop_layout,
- xcb_generic_error_t **e)
-{
- xcb_get_property_reply_t *r = xcb_get_property_reply(ewmh->connection, cookie, e);
- const uint8_t ret = xcb_ewmh_get_desktop_layout_from_reply(desktop_layout, r);
- free(r);
- return ret;
+ ewmh->root, ewmh->_NET_DESKTOP_LAYOUT,
+ CARDINAL, 32, 2, data);
}
/**
* _NET_SHOWING_DESKTOP
*/
-DO_ACCESSORS_ROOT_SINGLE_VALUE_ATOM(_NET_SHOWING_DESKTOP, showing_desktop, CARDINAL,
- uint32_t, cardinal)
-
-xcb_void_cookie_t
-xcb_ewmh_request_change_showing_desktop(xcb_ewmh_connection_t *ewmh,
- uint32_t enter)
-{
- return send_client_message(ewmh->connection, XCB_NONE, ewmh->root,
- ewmh->_NET_SHOWING_DESKTOP, 1, &enter);
-}
+DO_ROOT_SINGLE_VALUE_ATOM(_NET_SHOWING_DESKTOP, showing_desktop, CARDINAL,
+ uint32_t, cardinal)
/**
* _NET_CLOSE_WINDOW
@@ -854,14 +827,14 @@ xcb_ewmh_request_change_showing_desktop(xcb_ewmh_connection_t *ewmh,
xcb_void_cookie_t
xcb_ewmh_request_close_window(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window_to_close,
- xcb_timestamp_t timestamp,
- xcb_ewmh_client_source_type_t source_indication)
+ xcb_window_t window_to_close,
+ xcb_timestamp_t timestamp,
+ xcb_ewmh_client_source_type_t source_indication)
{
const uint32_t data[] = { timestamp, source_indication };
- return send_client_message(ewmh->connection, window_to_close, ewmh->root,
- ewmh->_NET_CLOSE_WINDOW, 2, data);
+ return xcb_ewmh_send_client_message(ewmh->connection, window_to_close, ewmh->root,
+ ewmh->_NET_CLOSE_WINDOW, 2, data);
}
/**
@@ -871,18 +844,20 @@ xcb_ewmh_request_close_window(xcb_ewmh_connection_t *ewmh,
/* x, y, width, height may be equal to -1 */
xcb_void_cookie_t
xcb_ewmh_request_moveresize_window(xcb_ewmh_connection_t *ewmh,
- xcb_window_t moveresize_window,
- xcb_gravity_t gravity,
- xcb_ewmh_client_source_type_t source_indication,
- xcb_ewmh_moveresize_window_opt_flags_t flags,
- uint32_t x, uint32_t y,
- uint32_t width, uint32_t height)
+ xcb_window_t moveresize_window,
+ xcb_gravity_t gravity,
+ xcb_ewmh_client_source_type_t source_indication,
+ xcb_ewmh_moveresize_window_opt_flags_t flags,
+ uint32_t x, uint32_t y,
+ uint32_t width, uint32_t height)
{
- const uint32_t data[] = { (gravity | flags | GET_LEN_FROM_NB(source_indication, 12)),
- x, y, width, height };
+ const uint32_t data[] = { (gravity | flags |
+ GET_LEN_FROM_NB(source_indication, 12)),
+ x, y, width, height };
- return send_client_message(ewmh->connection, moveresize_window, ewmh->root,
- ewmh->_NET_MOVERESIZE_WINDOW, 5, data);
+ return xcb_ewmh_send_client_message(ewmh->connection, moveresize_window,
+ ewmh->root, ewmh->_NET_MOVERESIZE_WINDOW,
+ 5, data);
}
/**
@@ -891,16 +866,17 @@ xcb_ewmh_request_moveresize_window(xcb_ewmh_connection_t *ewmh,
xcb_void_cookie_t
xcb_ewmh_request_wm_moveresize(xcb_ewmh_connection_t *ewmh,
- xcb_window_t moveresize_window,
- uint32_t x_root, uint32_t y_root,
- xcb_ewmh_moveresize_direction_t direction,
- xcb_button_index_t button,
- xcb_ewmh_client_source_type_t source_indication)
+ xcb_window_t moveresize_window,
+ uint32_t x_root, uint32_t y_root,
+ xcb_ewmh_moveresize_direction_t direction,
+ xcb_button_index_t button,
+ xcb_ewmh_client_source_type_t source_indication)
{
const uint32_t data[] = { x_root, y_root, direction, button, source_indication };
- return send_client_message(ewmh->connection, moveresize_window, ewmh->root,
- ewmh->_NET_WM_MOVERESIZE, 5, data);
+ return xcb_ewmh_send_client_message(ewmh->connection, moveresize_window,
+ ewmh->root, ewmh->_NET_WM_MOVERESIZE,
+ 5, data);
}
/**
@@ -909,65 +885,58 @@ xcb_ewmh_request_wm_moveresize(xcb_ewmh_connection_t *ewmh,
xcb_void_cookie_t
xcb_ewmh_request_restack_window(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window_to_restack,
- xcb_window_t sibling_window,
- xcb_stack_mode_t detail)
+ xcb_window_t window_to_restack,
+ xcb_window_t sibling_window,
+ xcb_stack_mode_t detail)
{
const uint32_t data[] = { XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER, sibling_window,
- detail };
+ detail };
- return send_client_message(ewmh->connection, window_to_restack, ewmh->root,
- ewmh->_NET_RESTACK_WINDOW, 3, data);
-}
-
-xcb_void_cookie_t
-xcb_ewmh_request_frame_extents(xcb_ewmh_connection_t *ewmh,
- xcb_window_t client_window)
-{
- return send_client_message(ewmh->connection, client_window, ewmh->root,
- ewmh->_NET_REQUEST_FRAME_EXTENTS, 0, NULL);
+ return xcb_ewmh_send_client_message(ewmh->connection, window_to_restack,
+ ewmh->root, ewmh->_NET_RESTACK_WINDOW,
+ 3, data);
}
/**
* _NET_WM_NAME
*/
-DO_ACCESSORS_UTF8_STRING(_NET_WM_NAME, wm_name)
+DO_UTF8_STRING(_NET_WM_NAME, wm_name)
/**
* _NET_WM_VISIBLE_NAME
*/
-DO_ACCESSORS_UTF8_STRING(_NET_WM_VISIBLE_NAME, wm_visible_name)
+DO_UTF8_STRING(_NET_WM_VISIBLE_NAME, wm_visible_name)
/**
* _NET_WM_ICON_NAME
*/
-DO_ACCESSORS_UTF8_STRING(_NET_WM_ICON_NAME, wm_icon_name)
+DO_UTF8_STRING(_NET_WM_ICON_NAME, wm_icon_name)
/**
* _NET_WM_VISIBLE_ICON_NAME
*/
-DO_ACCESSORS_UTF8_STRING(_NET_WM_VISIBLE_ICON_NAME, wm_visible_icon_name)
+DO_UTF8_STRING(_NET_WM_VISIBLE_ICON_NAME, wm_visible_icon_name)
/**
* _NET_WM_DESKTOP
*/
-DO_ACCESSORS_SINGLE_VALUE_ATOM(_NET_WM_DESKTOP, wm_desktop, CARDINAL, uint32_t, cardinal)
+DO_SINGLE_VALUE_ATOM(_NET_WM_DESKTOP, wm_desktop, CARDINAL, uint32_t, cardinal)
xcb_void_cookie_t
xcb_ewmh_request_change_wm_desktop(xcb_ewmh_connection_t *ewmh,
- xcb_window_t client_window,
- uint32_t new_desktop,
- xcb_ewmh_client_source_type_t source_indication)
+ xcb_window_t client_window,
+ uint32_t new_desktop,
+ xcb_ewmh_client_source_type_t source_indication)
{
const uint32_t data[] = { new_desktop, source_indication };
- return send_client_message(ewmh->connection, client_window, ewmh->root,
- ewmh->_NET_WM_DESKTOP, 2, data);
+ return xcb_ewmh_send_client_message(ewmh->connection, client_window, ewmh->root,
+ ewmh->_NET_WM_DESKTOP, 2, data);
}
/**
@@ -976,24 +945,7 @@ xcb_ewmh_request_change_wm_desktop(xcb_ewmh_connection_t *ewmh,
* TODO: check possible atoms?
*/
-DO_GET_PROPERTY(_NET_WM_WINDOW_TYPE, wm_window_type, ATOM, UINT_MAX)
-DO_SET_LIST_VALUES_PROPERTY(_NET_WM_WINDOW_TYPE, wm_window_type, xcb_atom_t, ATOM, 0)
-
-uint8_t
-xcb_ewmh_get_wm_window_type_from_reply(xcb_ewmh_get_atoms_reply_t *window_types,
- xcb_get_property_reply_t *r)
-{
- return xcb_ewmh_get_atoms_from_reply(window_types, r);
-}
-
-uint8_t
-xcb_ewmh_get_wm_window_type_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- xcb_ewmh_get_atoms_reply_t *window_types,
- xcb_generic_error_t **e)
-{
- return xcb_ewmh_get_atoms_reply(ewmh, cookie, window_types, e);
-}
+DO_LIST_VALUES(_NET_WM_WINDOW_TYPE, wm_window_type, ATOM, atom)
/**
* _NET_WM_STATE
@@ -1001,37 +953,21 @@ xcb_ewmh_get_wm_window_type_reply(xcb_ewmh_connection_t *ewmh,
* TODO: check possible atoms?
*/
-DO_GET_PROPERTY(_NET_WM_STATE, wm_state, ATOM, UINT_MAX)
-DO_SET_LIST_VALUES_PROPERTY(_NET_WM_STATE, wm_state, xcb_atom_t, ATOM, 0)
+DO_LIST_VALUES(_NET_WM_STATE, wm_state, ATOM, atom)
xcb_void_cookie_t
xcb_ewmh_request_change_wm_state(xcb_ewmh_connection_t *ewmh,
- xcb_window_t client_window,
- xcb_ewmh_wm_state_action_t action,
- xcb_atom_t first_property,
- xcb_atom_t second_property,
- xcb_ewmh_client_source_type_t source_indication)
-{
- const uint32_t data[] = { action, first_property, second_property, source_indication };
-
- return send_client_message(ewmh->connection, client_window, ewmh->root,
- ewmh->_NET_WM_STATE, 4, data);
-}
-
-uint8_t
-xcb_ewmh_get_wm_state_from_reply(xcb_ewmh_get_atoms_reply_t *wm_states,
- xcb_get_property_reply_t *r)
+ xcb_window_t client_window,
+ xcb_ewmh_wm_state_action_t action,
+ xcb_atom_t first_property,
+ xcb_atom_t second_property,
+ xcb_ewmh_client_source_type_t source_indication)
{
- return xcb_ewmh_get_atoms_from_reply(wm_states, r);
-}
+ const uint32_t data[] = { action, first_property, second_property,
+ source_indication };
-uint8_t
-xcb_ewmh_get_wm_state_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- xcb_ewmh_get_atoms_reply_t *wm_states,
- xcb_generic_error_t **e)
-{
- return xcb_ewmh_get_atoms_reply(ewmh, cookie, wm_states, e);
+ return xcb_ewmh_send_client_message(ewmh->connection, client_window, ewmh->root,
+ ewmh->_NET_WM_STATE, 4, data);
}
/**
@@ -1040,24 +976,7 @@ xcb_ewmh_get_wm_state_reply(xcb_ewmh_connection_t *ewmh,
* TODO: check possible atoms?
*/
-DO_GET_PROPERTY(_NET_WM_ALLOWED_ACTIONS, wm_allowed_actions, ATOM, UINT_MAX)
-DO_SET_LIST_VALUES_PROPERTY(_NET_WM_ALLOWED_ACTIONS, wm_allowed_actions, xcb_atom_t, ATOM, 0)
-
-uint8_t
-xcb_ewmh_get_wm_allowed_actions_from_reply(xcb_ewmh_get_atoms_reply_t *wm_allowed_actions,
- xcb_get_property_reply_t *r)
-{
- return xcb_ewmh_get_atoms_from_reply(wm_allowed_actions, r);
-}
-
-uint8_t
-xcb_ewmh_get_wm_allowed_actions_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- xcb_ewmh_get_atoms_reply_t *wm_allowed_actions,
- xcb_generic_error_t **e)
-{
- return xcb_ewmh_get_atoms_reply(ewmh, cookie, wm_allowed_actions, e);
-}
+DO_LIST_VALUES(_NET_WM_ALLOWED_ACTIONS, wm_allowed_actions, ATOM, atom)
/**
* _NET_WM_STRUT
@@ -1065,52 +984,25 @@ xcb_ewmh_get_wm_allowed_actions_reply(xcb_ewmh_connection_t *ewmh,
*/
DO_GET_PROPERTY(_NET_WM_STRUT, wm_strut, CARDINAL, 12)
+DO_REPLY_STRUCTURE(wm_strut, xcb_ewmh_wm_strut_t)
xcb_void_cookie_t
xcb_ewmh_set_wm_strut_checked(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window,
- xcb_ewmh_wm_strut_t wm_strut)
+ xcb_window_t window,
+ xcb_ewmh_wm_strut_t wm_strut)
{
return xcb_change_property_checked(ewmh->connection, XCB_PROP_MODE_REPLACE,
- window, ewmh->_NET_WM_STRUT, CARDINAL, 32,
- 12, &wm_strut);
+ window, ewmh->_NET_WM_STRUT, CARDINAL, 32,
+ 12, &wm_strut);
}
xcb_void_cookie_t
xcb_ewmh_set_wm_strut(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window,
- xcb_ewmh_wm_strut_t wm_strut)
+ xcb_window_t window,
+ xcb_ewmh_wm_strut_t wm_strut)
{
return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, window,
- ewmh->_NET_WM_STRUT, CARDINAL, 32, 12, &wm_strut);
-}
-
-uint8_t
-xcb_ewmh_get_wm_strut_from_reply(xcb_ewmh_wm_strut_t *wm_strut,
- xcb_get_property_reply_t *r)
-{
- if(!r || r->type != CARDINAL || r->format != 32 ||
- GET_NB_FROM_LEN(xcb_get_property_value_length(r), 2) != 12)
- return 0;
-
- memset(wm_strut, 0, sizeof(wm_strut));
-
- memcpy(wm_strut, xcb_get_property_value(r),
- xcb_get_property_value_length(r));
-
- return 1;
-}
-
-uint8_t
-xcb_ewmh_get_wm_strut_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- xcb_ewmh_wm_strut_t *wm_strut,
- xcb_generic_error_t **e)
-{
- xcb_get_property_reply_t *r = xcb_get_property_reply(ewmh->connection, cookie, e);
- const uint8_t ret = xcb_ewmh_get_wm_strut_from_reply(wm_strut, r);
- free(r);
- return ret;
+ ewmh->_NET_WM_STRUT, CARDINAL, 32, 12, &wm_strut);
}
/**
@@ -1118,56 +1010,31 @@ xcb_ewmh_get_wm_strut_reply(xcb_ewmh_connection_t *ewmh,
*/
DO_GET_PROPERTY(_NET_WM_ICON_GEOMETRY, wm_icon_geometry, CARDINAL, 4)
+DO_REPLY_STRUCTURE(wm_icon_geometry, xcb_ewmh_geometry_t)
xcb_void_cookie_t
xcb_ewmh_set_wm_icon_geometry_checked(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window,
- uint32_t left, uint32_t right,
- uint32_t top, uint32_t bottom)
+ xcb_window_t window,
+ uint32_t left, uint32_t right,
+ uint32_t top, uint32_t bottom)
{
const uint32_t data[] = { left, right, top, bottom };
return xcb_change_property_checked(ewmh->connection, XCB_PROP_MODE_REPLACE,
- window, ewmh->_NET_WM_ICON_GEOMETRY,
- CARDINAL, 32, 4, data);
+ window, ewmh->_NET_WM_ICON_GEOMETRY,
+ CARDINAL, 32, 4, data);
}
xcb_void_cookie_t
xcb_ewmh_set_wm_icon_geometry(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window,
- uint32_t left, uint32_t right,
- uint32_t top, uint32_t bottom)
+ xcb_window_t window,
+ uint32_t left, uint32_t right,
+ uint32_t top, uint32_t bottom)
{
const uint32_t data[] = { left, right, top, bottom };
return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, window,
- ewmh->_NET_WM_ICON_GEOMETRY, CARDINAL, 32, 4, data);
-}
-
-uint8_t
-xcb_ewmh_get_wm_icon_geometry_from_reply(xcb_ewmh_geometry_t *wm_icon_geometry,
- xcb_get_property_reply_t *r)
-{
- if(!r || r->type != CARDINAL || r->format != 32 ||
- GET_NB_FROM_LEN(xcb_get_property_value_length(r), 2) != 4)
- return 0;
-
- memcpy(wm_icon_geometry, xcb_get_property_value(r),
- xcb_get_property_value_length(r));
-
- return 1;
-}
-
-uint8_t
-xcb_ewmh_get_wm_icon_geometry_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- xcb_ewmh_geometry_t *wm_icon_geometry,
- xcb_generic_error_t **e)
-{
- xcb_get_property_reply_t *r = xcb_get_property_reply(ewmh->connection, cookie, e);
- const uint8_t ret = xcb_ewmh_get_wm_icon_geometry_from_reply(wm_icon_geometry, r);
- free(r);
- return ret;
+ ewmh->_NET_WM_ICON_GEOMETRY, CARDINAL, 32, 4, data);
}
/**
@@ -1178,7 +1045,7 @@ DO_GET_PROPERTY(_NET_WM_ICON, wm_icon, CARDINAL, UINT_MAX)
static inline void
set_wm_icon_data(uint32_t data[], uint32_t width, uint32_t height,
- uint32_t img_len, uint32_t *img)
+ uint32_t img_len, uint32_t *img)
{
data[0] = width;
data[1] = height;
@@ -1188,9 +1055,9 @@ set_wm_icon_data(uint32_t data[], uint32_t width, uint32_t height,
xcb_void_cookie_t
xcb_ewmh_set_wm_icon_checked(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window,
- uint32_t width, uint32_t height,
- uint32_t img_len, uint32_t *img)
+ xcb_window_t window,
+ uint32_t width, uint32_t height,
+ uint32_t img_len, uint32_t *img)
{
const uint32_t data_len = img_len + 2;
uint32_t data[data_len];
@@ -1198,15 +1065,15 @@ xcb_ewmh_set_wm_icon_checked(xcb_ewmh_connection_t *ewmh,
set_wm_icon_data(data, width, height, img_len, img);
return xcb_change_property_checked(ewmh->connection, XCB_PROP_MODE_REPLACE,
- window, ewmh->_NET_WM_ICON, CARDINAL, 32,
- data_len, data);
+ window, ewmh->_NET_WM_ICON, CARDINAL, 32,
+ data_len, data);
}
xcb_void_cookie_t
xcb_ewmh_set_wm_icon(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window,
- uint32_t width, uint32_t height,
- uint32_t img_len, uint32_t *img)
+ xcb_window_t window,
+ uint32_t width, uint32_t height,
+ uint32_t img_len, uint32_t *img)
{
const uint32_t data_len = img_len + 2;
uint32_t data[data_len];
@@ -1214,12 +1081,12 @@ xcb_ewmh_set_wm_icon(xcb_ewmh_connection_t *ewmh,
set_wm_icon_data(data, width, height, img_len, img);
return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, window,
- ewmh->_NET_WM_ICON, CARDINAL, 32, data_len, data);
+ ewmh->_NET_WM_ICON, CARDINAL, 32, data_len, data);
}
uint8_t
xcb_ewmh_get_wm_icon_from_reply(xcb_ewmh_get_wm_icon_reply_t *wm_icon,
- xcb_get_property_reply_t *r)
+ xcb_get_property_reply_t *r)
{
if(!r || r->type != CARDINAL || r->format != 32 ||
GET_NB_FROM_LEN(xcb_get_property_value_length(r), 2) <= 2)
@@ -1237,9 +1104,9 @@ xcb_ewmh_get_wm_icon_from_reply(xcb_ewmh_get_wm_icon_reply_t *wm_icon,
uint8_t
xcb_ewmh_get_wm_icon_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- xcb_ewmh_get_wm_icon_reply_t *wm_icon,
- xcb_generic_error_t **e)
+ xcb_get_property_cookie_t cookie,
+ xcb_ewmh_get_wm_icon_reply_t *wm_icon,
+ xcb_generic_error_t **e)
{
xcb_get_property_reply_t *r = xcb_get_property_reply(ewmh->connection, cookie, e);
const uint8_t ret = xcb_ewmh_get_wm_icon_from_reply(wm_icon, r);
@@ -1259,78 +1126,53 @@ xcb_ewmh_get_wm_icon_reply_wipe(xcb_ewmh_get_wm_icon_reply_t *wm_icon)
* _NET_WM_PID
*/
-DO_ACCESSORS_SINGLE_VALUE_ATOM(_NET_WM_PID, wm_pid, CARDINAL, uint32_t,
- cardinal)
+DO_SINGLE_VALUE_ATOM(_NET_WM_PID, wm_pid, CARDINAL, uint32_t,
+ cardinal)
/**
* _NET_WM_USER_TIME
*/
-DO_ACCESSORS_SINGLE_VALUE_ATOM(_NET_WM_USER_TIME, wm_user_time, CARDINAL,
- uint32_t, cardinal)
+DO_SINGLE_VALUE_ATOM(_NET_WM_USER_TIME, wm_user_time, CARDINAL,
+ uint32_t, cardinal)
/**
* _NET_WM_USER_TIME_WINDOW
*/
-DO_ACCESSORS_SINGLE_VALUE_ATOM(_NET_WM_USER_TIME_WINDOW, wm_user_time_window,
- CARDINAL, uint32_t, cardinal)
+DO_SINGLE_VALUE_ATOM(_NET_WM_USER_TIME_WINDOW, wm_user_time_window,
+ CARDINAL, uint32_t, cardinal)
/**
* _NET_FRAME_EXTENTS
*/
DO_GET_PROPERTY(_NET_FRAME_EXTENTS, frame_extents, CARDINAL, 4)
+DO_REPLY_STRUCTURE(frame_extents, xcb_ewmh_get_frame_extents_reply_t)
xcb_void_cookie_t
xcb_ewmh_set_frame_extents(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window,
- uint32_t left, uint32_t right,
- uint32_t top, uint32_t bottom)
+ xcb_window_t window,
+ uint32_t left, uint32_t right,
+ uint32_t top, uint32_t bottom)
{
const uint32_t data[] = { left, right, top, bottom };
return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, window,
- ewmh->_NET_FRAME_EXTENTS, CARDINAL, 32, 4, data);
+ ewmh->_NET_FRAME_EXTENTS, CARDINAL, 32, 4, data);
}
xcb_void_cookie_t
xcb_ewmh_set_frame_extents_checked(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window,
- uint32_t left, uint32_t right,
- uint32_t top, uint32_t bottom)
+ xcb_window_t window,
+ uint32_t left, uint32_t right,
+ uint32_t top, uint32_t bottom)
{
const uint32_t data[] = { left, right, top, bottom };
return xcb_change_property_checked(ewmh->connection, XCB_PROP_MODE_REPLACE,
- window, ewmh->_NET_FRAME_EXTENTS, CARDINAL,
- 32, 4, data);
-}
-
-uint8_t
-xcb_ewmh_get_frame_extents_from_reply(xcb_ewmh_get_frame_extents_reply_t *frame_extents,
- xcb_get_property_reply_t *r)
-{
- if(!r || r->type != CARDINAL || r->format != 32 ||
- GET_NB_FROM_LEN(xcb_get_property_value_length(r), 2) != 4)
- return 0;
-
- memcpy(frame_extents, xcb_get_property_value(r),
- xcb_get_property_value_length(r));
-
- return 1;
-}
-
-uint8_t
-xcb_ewmh_get_frame_extents_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- xcb_ewmh_get_frame_extents_reply_t *frame_extents,
- xcb_generic_error_t **e)
-{
- xcb_get_property_reply_t *r = xcb_get_property_reply(ewmh->connection, cookie, e);
- const uint8_t ret = xcb_ewmh_get_frame_extents_from_reply(frame_extents, r);
- free(r);
- return ret;
+ window, ewmh->_NET_FRAME_EXTENTS, CARDINAL,
+ 32, 4, data);
}
/**
@@ -1341,13 +1183,13 @@ xcb_ewmh_get_frame_extents_reply(xcb_ewmh_connection_t *ewmh,
xcb_void_cookie_t
xcb_ewmh_send_wm_ping(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window,
- xcb_timestamp_t timestamp)
+ xcb_window_t window,
+ xcb_timestamp_t timestamp)
{
const uint32_t data[] = { ewmh->_NET_WM_PING, timestamp, window };
- return send_client_message(ewmh->connection, window, window,
- ewmh->WM_PROTOCOLS, 3, data);
+ return xcb_ewmh_send_client_message(ewmh->connection, window, window,
+ ewmh->WM_PROTOCOLS, 3, data);
}
/**
@@ -1359,51 +1201,51 @@ DO_GET_PROPERTY(_NET_WM_SYNC_REQUEST, wm_sync_request_counter, CARDINAL, 2)
xcb_void_cookie_t
xcb_ewmh_set_wm_sync_request_counter(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window,
- xcb_atom_t wm_sync_request_counter_atom,
- uint32_t low, uint32_t high)
+ xcb_window_t window,
+ xcb_atom_t wm_sync_request_counter_atom,
+ uint32_t low, uint32_t high)
{
const uint32_t data[] = { low, high };
return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, window,
- ewmh->_NET_WM_SYNC_REQUEST, CARDINAL, 32, 2, data);
+ ewmh->_NET_WM_SYNC_REQUEST, CARDINAL, 32, 2, data);
}
xcb_void_cookie_t
xcb_ewmh_set_wm_sync_request_counter_checked(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window,
- xcb_atom_t wm_sync_request_counter_atom,
- uint32_t low, uint32_t high)
+ xcb_window_t window,
+ xcb_atom_t wm_sync_request_counter_atom,
+ uint32_t low, uint32_t high)
{
const uint32_t data[] = { low, high };
return xcb_change_property_checked(ewmh->connection, XCB_PROP_MODE_REPLACE,
- window, ewmh->_NET_WM_SYNC_REQUEST,
- CARDINAL, 32, 2, data);
+ window, ewmh->_NET_WM_SYNC_REQUEST,
+ CARDINAL, 32, 2, data);
}
xcb_void_cookie_t
xcb_ewmh_send_wm_sync_request(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window,
- xcb_atom_t wm_protocols_atom,
- xcb_atom_t wm_sync_request_atom,
- xcb_timestamp_t timestamp,
- uint64_t counter)
+ xcb_window_t window,
+ xcb_atom_t wm_protocols_atom,
+ xcb_atom_t wm_sync_request_atom,
+ xcb_timestamp_t timestamp,
+ uint64_t counter)
{
const uint32_t data[] = { ewmh->_NET_WM_SYNC_REQUEST, timestamp, counter,
- GET_NB_FROM_LEN(counter, 32) };
+ GET_NB_FROM_LEN(counter, 32) };
- return send_client_message(ewmh->connection, window, window,
- ewmh->WM_PROTOCOLS, 4, data);
+ return xcb_ewmh_send_client_message(ewmh->connection, window, window,
+ ewmh->WM_PROTOCOLS, 4, data);
}
uint8_t
xcb_ewmh_get_wm_sync_request_counter_from_reply(uint64_t *counter,
- xcb_get_property_reply_t *r)
+ xcb_get_property_reply_t *r)
{
/* 2 cardinals? */
if(!r || r->type != CARDINAL || r->format != 32 ||
- GET_NB_FROM_LEN(xcb_get_property_value_length(r), 2) != 2)
+ xcb_get_property_value_length(r) != sizeof(uint64_t))
return 0;
uint32_t *r_value = (uint32_t *) xcb_get_property_value(r);
@@ -1414,9 +1256,9 @@ xcb_ewmh_get_wm_sync_request_counter_from_reply(uint64_t *counter,
uint8_t
xcb_ewmh_get_wm_sync_request_counter_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- uint64_t *counter,
- xcb_generic_error_t **e)
+ xcb_get_property_cookie_t cookie,
+ uint64_t *counter,
+ xcb_generic_error_t **e)
{
xcb_get_property_reply_t *r = xcb_get_property_reply(ewmh->connection, cookie, e);
const uint8_t ret = xcb_ewmh_get_wm_sync_request_counter_from_reply(counter, r);
@@ -1430,68 +1272,46 @@ xcb_ewmh_get_wm_sync_request_counter_reply(xcb_ewmh_connection_t *ewmh,
DO_GET_PROPERTY(_NET_WM_FULLSCREEN_MONITORS, wm_fullscreen_monitors, CARDINAL, 4)
+DO_REPLY_STRUCTURE(wm_fullscreen_monitors,
+ xcb_ewmh_get_wm_fullscreen_monitors_reply_t)
+
xcb_void_cookie_t
xcb_ewmh_set_wm_fullscreen_monitors(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window,
- uint32_t top, uint32_t bottom,
- uint32_t left, uint32_t right)
+ xcb_window_t window,
+ uint32_t top, uint32_t bottom,
+ uint32_t left, uint32_t right)
{
const uint32_t data[] = { top, bottom, left, right };
return xcb_change_property(ewmh->connection, XCB_PROP_MODE_REPLACE, window,
- ewmh->_NET_WM_FULLSCREEN_MONITORS, CARDINAL, 32, 4, data);
+ ewmh->_NET_WM_FULLSCREEN_MONITORS, CARDINAL, 32,
+ 4, data);
}
xcb_void_cookie_t
xcb_ewmh_set_wm_fullscreen_monitors_checked(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window,
- uint32_t top, uint32_t bottom,
- uint32_t left, uint32_t right)
+ xcb_window_t window,
+ uint32_t top, uint32_t bottom,
+ uint32_t left, uint32_t right)
{
const uint32_t data[] = { top, bottom, left, right };
return xcb_change_property_checked(ewmh->connection, XCB_PROP_MODE_REPLACE,
- window, ewmh->_NET_WM_FULLSCREEN_MONITORS,
- CARDINAL, 32, 4, data);
+ window, ewmh->_NET_WM_FULLSCREEN_MONITORS,
+ CARDINAL, 32, 4, data);
}
xcb_void_cookie_t
xcb_ewmh_request_change_wm_fullscreen_monitors(xcb_ewmh_connection_t *ewmh,
- xcb_window_t window,
- uint32_t top, uint32_t bottom,
- uint32_t left, uint32_t right,
- xcb_ewmh_client_source_type_t source_indication)
+ xcb_window_t window,
+ uint32_t top, uint32_t bottom,
+ uint32_t left, uint32_t right,
+ xcb_ewmh_client_source_type_t source_indication)
{
const uint32_t data[] = { top, bottom, left, right, source_indication };
- return send_client_message(ewmh->connection, window, ewmh->root,
- ewmh->_NET_WM_FULLSCREEN_MONITORS, 5, data);
-}
-
-uint8_t
-xcb_ewmh_get_wm_fullscreen_monitors_from_reply(xcb_ewmh_get_wm_fullscreen_monitors_reply_t *wm_fullscreen_monitors,
- xcb_get_property_reply_t *r)
-{
- if(!r || r->type != CARDINAL || r->format != 32 ||
- GET_NB_FROM_LEN(xcb_get_property_value_length(r), 2) != 4)
- return 0;
-
- memcpy(wm_fullscreen_monitors, xcb_get_property_value(r),
- xcb_get_property_value_length(r));
-
- return 1;
-}
-
-uint8_t
-xcb_ewmh_get_wm_fullscreen_monitors_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- xcb_ewmh_get_wm_fullscreen_monitors_reply_t *wm_fullscreen_monitors,
- xcb_generic_error_t **e)
-{
- xcb_get_property_reply_t *r = xcb_get_property_reply(ewmh->connection, cookie, e);
- const uint8_t ret = xcb_ewmh_get_wm_fullscreen_monitors_from_reply(wm_fullscreen_monitors, r);
- free(r);
- return ret;
+ return xcb_ewmh_send_client_message(ewmh->connection, window, ewmh->root,
+ ewmh->_NET_WM_FULLSCREEN_MONITORS, 5, data);
}
/**
@@ -1511,12 +1331,13 @@ xcb_ewmh_get_wm_cm_owner(xcb_ewmh_connection_t *ewmh)
xcb_get_selection_owner_cookie_t
xcb_ewmh_get_wm_cm_owner_unchecked(xcb_ewmh_connection_t *ewmh)
{
- return xcb_get_selection_owner_unchecked(ewmh->connection, ewmh->_NET_WM_CM_Sn);
+ return xcb_get_selection_owner_unchecked(ewmh->connection,
+ ewmh->_NET_WM_CM_Sn);
}
uint8_t
xcb_ewmh_get_wm_cm_owner_from_reply(xcb_window_t *owner,
- xcb_get_selection_owner_reply_t *r)
+ xcb_get_selection_owner_reply_t *r)
{
if(!r)
return 0;
@@ -1528,12 +1349,12 @@ xcb_ewmh_get_wm_cm_owner_from_reply(xcb_window_t *owner,
uint8_t
xcb_ewmh_get_wm_cm_owner_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_selection_owner_cookie_t cookie,
- xcb_window_t *owner,
- xcb_generic_error_t **e)
+ xcb_get_selection_owner_cookie_t cookie,
+ xcb_window_t *owner,
+ xcb_generic_error_t **e)
{
- xcb_get_selection_owner_reply_t *r = xcb_get_selection_owner_reply(ewmh->connection,
- cookie, e);
+ xcb_get_selection_owner_reply_t *r =
+ xcb_get_selection_owner_reply(ewmh->connection, cookie, e);
return xcb_ewmh_get_wm_cm_owner_from_reply(owner, r);
}
@@ -1541,10 +1362,10 @@ xcb_ewmh_get_wm_cm_owner_reply(xcb_ewmh_connection_t *ewmh,
/* TODO: section 2.1, 2.2 */
static xcb_void_cookie_t
set_wm_cm_owner_client_message(xcb_ewmh_connection_t *ewmh,
- xcb_window_t owner,
- xcb_timestamp_t timestamp,
- uint32_t selection_data1,
- uint32_t selection_data2)
+ xcb_window_t owner,
+ xcb_timestamp_t timestamp,
+ uint32_t selection_data1,
+ uint32_t selection_data2)
{
xcb_client_message_event_t ev;
memset(&ev, 0, sizeof(xcb_client_message_event_t));
@@ -1559,33 +1380,34 @@ set_wm_cm_owner_client_message(xcb_ewmh_connection_t *ewmh,
ev.data.data32[4] = selection_data2;
return xcb_send_event(ewmh->connection, 0, ewmh->root,
- XCB_EVENT_MASK_STRUCTURE_NOTIFY,
- (char *) &ev);
+ XCB_EVENT_MASK_STRUCTURE_NOTIFY,
+ (char *) &ev);
}
/* TODO: check both */
xcb_void_cookie_t
xcb_ewmh_set_wm_cm_owner(xcb_ewmh_connection_t *ewmh,
- xcb_window_t owner,
- xcb_timestamp_t timestamp,
- uint32_t selection_data1,
- uint32_t selection_data2)
+ xcb_window_t owner,
+ xcb_timestamp_t timestamp,
+ uint32_t selection_data1,
+ uint32_t selection_data2)
{
xcb_set_selection_owner(ewmh->connection, owner, ewmh->_NET_WM_CM_Sn, 0);
return set_wm_cm_owner_client_message(ewmh, owner, timestamp,
- selection_data1, selection_data2);
+ selection_data1, selection_data2);
}
xcb_void_cookie_t
xcb_ewmh_set_wm_cm_owner_checked(xcb_ewmh_connection_t *ewmh,
- xcb_window_t owner,
- xcb_timestamp_t timestamp,
- uint32_t selection_data1,
- uint32_t selection_data2)
+ xcb_window_t owner,
+ xcb_timestamp_t timestamp,
+ uint32_t selection_data1,
+ uint32_t selection_data2)
{
- xcb_set_selection_owner_checked(ewmh->connection, owner, ewmh->_NET_WM_CM_Sn, 0);
+ xcb_set_selection_owner_checked(ewmh->connection, owner,
+ ewmh->_NET_WM_CM_Sn, 0);
return set_wm_cm_owner_client_message(ewmh, owner, timestamp,
- selection_data1, selection_data2);
+ selection_data1, selection_data2);
}
diff --git a/ewmh/xcb_ewmh.h.m4 b/ewmh/xcb_ewmh.h.m4
index 4b4f1f9..2cde22b 100644
--- a/ewmh/xcb_ewmh.h.m4
+++ b/ewmh/xcb_ewmh.h.m4
@@ -43,9 +43,6 @@
* directly and has to be wipe afterwards. This structure provides a
* convenient access to the list given in the reply itself.
*
- * \todo Add missing prototypes but asks for advices on XCB mailing
- * list before.
- *
* @{
*/
@@ -56,7 +53,7 @@ extern "C" {
#endif
/**
- * @brief Hold EWMH
+ * @brief Hold EWMH information specific to a screen
*/
typedef struct {
/** The X connection */
@@ -106,7 +103,7 @@ typedef struct {
} xcb_ewmh_get_utf8_strings_reply_t;
/**
- * @brief Property values as coordinates
+ * @brief Coordinates Property values
*/
typedef struct {
/** The x coordinate */
@@ -128,7 +125,7 @@ typedef struct {
} xcb_ewmh_get_desktop_viewport_reply_t;
/**
- * @brief Property values as a geometry
+ * @brief Geometry Property values
*/
typedef struct {
/** The x coordinate */
@@ -340,6 +337,42 @@ typedef struct {
} xcb_ewmh_get_wm_fullscreen_monitors_reply_t;
/**
+ * @brief Send a ClientMessage request
+ *
+ * This function is called by all the xcb_ewmh_request* functions
+ * whose should be used instead of calling directly this function
+ *
+ * @param c The X connection
+ * @param window
+ * @param dest Destination Window XID
+ * @param atom
+ * @param data_len The length of data
+ * @param data
+ */
+xcb_void_cookie_t xcb_ewmh_send_client_message(xcb_connection_t *c,
+ xcb_window_t window,
+ xcb_window_t dest,
+ xcb_atom_t atom,
+ uint32_t data_len,
+ const uint32_t *data);
+
+uint8_t xcb_ewmh_get_atoms_from_reply(xcb_ewmh_get_atoms_reply_t *atoms,
+ xcb_get_property_reply_t *r);
+
+uint8_t xcb_ewmh_get_atoms_reply(xcb_ewmh_connection_t *ewmh,
+ xcb_get_property_cookie_t cookie,
+ xcb_ewmh_get_atoms_reply_t *atoms,
+ xcb_generic_error_t **e);
+
+uint8_t xcb_ewmh_get_windows_from_reply(xcb_ewmh_get_windows_reply_t *atoms,
+ xcb_get_property_reply_t *r);
+
+uint8_t xcb_ewmh_get_windows_reply(xcb_ewmh_connection_t *ewmh,
+ xcb_get_property_cookie_t cookie,
+ xcb_ewmh_get_windows_reply_t *atoms,
+ xcb_generic_error_t **e);
+
+/**
* @brief Send InternAtom requests for the EWMH atoms and its required atoms.
* @param c The connection to the X server.
* @param ewmh The information relative to EWMH.
@@ -412,6 +445,12 @@ xcb_get_property_cookie_t xcb_ewmh_get_supported_unchecked(xcb_ewmh_connection_t
*/
xcb_get_property_cookie_t xcb_ewmh_get_supported(xcb_ewmh_connection_t *ewmh);
+static inline uint8_t xcb_ewmh_get_supported_from_reply(xcb_ewmh_get_atoms_reply_t *supported,
+ xcb_get_property_reply_t *r)
+{
+ return xcb_ewmh_get_atoms_from_reply(supported, r);
+}
+
/**
* @brief Get reply from the GetProperty _NET_SUPPORTED cookie
*
@@ -425,10 +464,13 @@ xcb_get_property_cookie_t xcb_ewmh_get_supported(xcb_ewmh_connection_t *ewmh);
* @param The xcb_generic_error_t supplied.
* @return Return 1 on success, 0 otherwise.
*/
-uint8_t xcb_ewmh_get_supported_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- xcb_ewmh_get_atoms_reply_t *supported,
- xcb_generic_error_t **e);
+static inline uint8_t xcb_ewmh_get_supported_reply(xcb_ewmh_connection_t *ewmh,
+ xcb_get_property_cookie_t cookie,
+ xcb_ewmh_get_atoms_reply_t *supported,
+ xcb_generic_error_t **e)
+{
+ return xcb_ewmh_get_atoms_reply(ewmh, cookie, supported, e);
+}
/**
* @brief Send GetProperty request to get _NET_CLIENT_LIST root window
@@ -454,6 +496,13 @@ xcb_get_property_cookie_t xcb_ewmh_get_client_list_unchecked(xcb_ewmh_connection
*/
xcb_get_property_cookie_t xcb_ewmh_get_client_list(xcb_ewmh_connection_t *ewmh);
+static inline uint8_t
+xcb_ewmh_get_client_list_from_reply(xcb_ewmh_get_windows_reply_t *clients,
+ xcb_get_property_reply_t *r)
+{
+ return xcb_ewmh_get_windows_from_reply(clients, r);
+}
+
/**
* @brief Get reply from the GetProperty _NET_CLIENT_LIST cookie
*
@@ -467,10 +516,29 @@ xcb_get_property_cookie_t xcb_ewmh_get_client_list(xcb_ewmh_connection_t *ewmh);
* @param The xcb_generic_error_t supplied.
* @return Return 1 on success, 0 otherwise.
*/
-uint8_t xcb_ewmh_get_client_list_reply(xcb_ewmh_connection_t *ewmh,
- xcb_get_property_cookie_t cookie,
- xcb_ewmh_get_windows_reply_t *clients,
- xcb_generic_error_t **e);
+static inline uint8_t xcb_ewmh_get_client_list_reply(xcb_ewmh_connection_t *ewmh,
+ xcb_get_property_cookie_t cookie,
+ xcb_ewmh_get_windows_reply_t *clients,
+ xcb_generic_error_t **e)
+{
+ return xcb_ewmh_get_windows_reply(ewmh, cookie, clients, e);
+}
+
+static inline uint8_t
+xcb_ewmh_get_client_list_stacking_from_reply(xcb_ewmh_get_windows_reply_t *clients,
+ xcb_get_property_reply_t *r)
+{
+ return xcb_ewmh_get_windows_from_reply(clients, r);
+}
+
+static inline uint8_t
+xcb_ewmh_get_client_list_stacking_reply(xcb_ewmh_connection_t *ewmh,
+ xcb_get_property_cookie_t cookie,
+ xcb_ewmh_get_windows_reply_t *clients,
+ xcb_generic_error_t **e)
+{
+ return xcb_ewmh_get_windows_reply(ewmh, cookie, clients, e);
+}
/**
* @brief Send GetProperty request to get _NET_ACTIVE_WINDOW root
@@ -599,6 +667,48 @@ xcb_void_cookie_t xcb_ewmh_set_wm_cm_owner(xcb_ewmh_connection_t *ewmh,
uint32_t selection_data1,
uint32_t selection_data2);
+static inline uint8_t
+xcb_ewmh_get_virtual_roots_from_reply(xcb_ewmh_get_windows_reply_t *virtual_roots,
+ xcb_get_property_reply_t *r)
+{
+ return xcb_ewmh_get_windows_from_reply(virtual_roots, r);
+}
+
+static inline uint8_t
+xcb_ewmh_get_virtual_roots_reply(xcb_ewmh_connection_t *ewmh,
+ xcb_get_property_cookie_t cookie,
+ xcb_ewmh_get_windows_reply_t *virtual_roots,
+ xcb_generic_error_t **e)
+{
+ return xcb_ewmh_get_windows_reply(ewmh, cookie, virtual_roots, e);
+}
+
+
+static inline xcb_void_cookie_t
+xcb_ewmh_request_change_showing_desktop(xcb_ewmh_connection_t *ewmh,
+ uint32_t enter)
+{
+ return xcb_ewmh_send_client_message(ewmh->connection, XCB_NONE, ewmh->root,
+ ewmh->_NET_SHOWING_DESKTOP, 1, &enter);
+}
+
+static inline xcb_void_cookie_t
+xcb_ewmh_request_change_number_of_desktops(xcb_ewmh_connection_t *ewmh,
+ uint32_t new_number_of_desktops)
+{
+ return xcb_ewmh_send_client_message(ewmh->connection, XCB_NONE, ewmh->root,
+ ewmh->_NET_NUMBER_OF_DESKTOPS, 1,
+ &new_number_of_desktops);
+}
+
+static inline xcb_void_cookie_t
+xcb_ewmh_request_frame_extents(xcb_ewmh_connection_t *ewmh,
+ xcb_window_t client_window)
+{
+ return xcb_ewmh_send_client_message(ewmh->connection, client_window, ewmh->root,
+ ewmh->_NET_REQUEST_FRAME_EXTENTS, 0, NULL);
+}
+
#ifdef __cplusplus
}
#endif