[PATCH 1/2] icccm: add missing setters for WM_CLASS and WM_TRANSIENT_FOR properties
Arnaud Fontaine
ArnaudFontainearnau at debian.org
Mon Mar 22 04:38:32 PDT 2010
---
icccm/icccm.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++
icccm/xcb_icccm.h | 46 +++++++++++++++++++++++++++++++++++
2 files changed, 114 insertions(+), 0 deletions(-)
diff --git a/icccm/icccm.c b/icccm/icccm.c
index f94ace1..6cd55cc 100644
--- a/icccm/icccm.c
+++ b/icccm/icccm.c
@@ -233,6 +233,55 @@ xcb_watch_wm_client_machine(xcb_property_handlers_t *prophs, uint32_t long_len,
/* WM_CLASS */
+static inline void
+set_wm_class_string(char *wm_class,
+ uint32_t instance_name_len,
+ const char *instance_name,
+ uint32_t class_name_len,
+ const char *class_name)
+{
+ strncpy(wm_class, instance_name, instance_name_len);
+ strncpy(wm_class + instance_name_len, class_name, class_name_len);
+}
+
+xcb_void_cookie_t
+xcb_set_wm_class_checked(xcb_connection_t *c,
+ xcb_window_t window,
+ uint32_t instance_name_len,
+ const char *instance_name,
+ uint32_t class_name_len,
+ const char *class_name)
+{
+ const uint32_t wm_class_len = instance_name_len + class_name_len;
+ char wm_class[wm_class_len];
+
+ set_wm_class_string(wm_class, instance_name_len, instance_name,
+ class_name_len, class_name);
+
+ return xcb_change_property_checked(c, XCB_PROP_MODE_REPLACE, window,
+ XCB_ATOM_WM_CLASS, XCB_ATOM_STRING, 8,
+ wm_class_len, wm_class);
+}
+
+xcb_void_cookie_t
+xcb_set_wm_class(xcb_connection_t *c,
+ xcb_window_t window,
+ uint32_t instance_name_len,
+ const char *instance_name,
+ uint32_t class_name_len,
+ const char *class_name)
+{
+ const uint32_t wm_class_len = instance_name_len + class_name_len;
+ char wm_class[wm_class_len];
+
+ set_wm_class_string(wm_class, instance_name_len, instance_name,
+ class_name_len, class_name);
+
+ return xcb_change_property(c, XCB_PROP_MODE_REPLACE, window,
+ XCB_ATOM_WM_CLASS, XCB_ATOM_STRING, 8,
+ wm_class_len, wm_class);
+}
+
xcb_get_property_cookie_t
xcb_get_wm_class(xcb_connection_t *c, xcb_window_t window)
{
@@ -284,6 +333,25 @@ xcb_get_wm_class_reply_wipe(xcb_get_wm_class_reply_t *prop)
/* WM_TRANSIENT_FOR */
+xcb_void_cookie_t
+xcb_set_wm_transient_for_checked(xcb_connection_t *c, xcb_window_t window,
+ xcb_window_t transient_for_window)
+{
+ return xcb_change_property_checked(c, XCB_PROP_MODE_REPLACE, window,
+ XCB_ATOM_WM_TRANSIENT_FOR,
+ XCB_ATOM_WINDOW, 32, 1,
+ &transient_for_window);
+}
+
+xcb_void_cookie_t
+xcb_set_wm_transient_for(xcb_connection_t *c, xcb_window_t window,
+ xcb_window_t transient_for_window)
+{
+ return xcb_change_property(c, XCB_PROP_MODE_REPLACE, window,
+ XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32,
+ 1, &transient_for_window);
+}
+
xcb_get_property_cookie_t
xcb_get_wm_transient_for(xcb_connection_t *c, xcb_window_t window)
{
diff --git a/icccm/xcb_icccm.h b/icccm/xcb_icccm.h
index 2d80ffb..9112b46 100644
--- a/icccm/xcb_icccm.h
+++ b/icccm/xcb_icccm.h
@@ -307,6 +307,34 @@ uint8_t xcb_watch_wm_client_machine(xcb_property_handlers_t *prophs,
/**
* @brief WM_CLASS hint structure
*/
+
+/**
+ * @brief Deliver a SetProperty request to set WM_CLASS property value.
+ * @param c The connection to the X server.
+ * @param window Window X identifier.
+ * @param instance_name_len Length of application instance name (including null character).
+ * @param instance_name Application instance name.
+ * @param class_name_len Length of application general class name (including null character).
+ * @param class_name Application general class name.
+ * @return The request cookie.
+ */
+xcb_void_cookie_t xcb_set_wm_class_checked(xcb_connection_t *c,
+ xcb_window_t window,
+ uint32_t instance_name_len,
+ const char *instance_name,
+ uint32_t class_name_len,
+ const char *class_name);
+
+/**
+ * @see xcb_set_wm_class_checked()
+ */
+xcb_void_cookie_t xcb_set_wm_class(xcb_connection_t *c,
+ xcb_window_t window,
+ uint32_t instance_name_len,
+ const char *instance_name,
+ uint32_t class_name_len,
+ const char *class_name);
+
typedef struct {
/** Instance name */
char *instance_name;
@@ -371,6 +399,24 @@ void xcb_get_wm_class_reply_wipe(xcb_get_wm_class_reply_t *prop);
/* WM_TRANSIENT_FOR */
/**
+ * @brief Deliver a SetProperty request to set WM_TRANSIENT_FOR property value.
+ * @param c The connection to the X server.
+ * @param window Window X identifier.
+ * @param transient_for_window The WM_TRANSIENT_FOR window X identifier.
+ * @return The request cookie.
+ */
+xcb_void_cookie_t xcb_set_wm_transient_for_checked(xcb_connection_t *c,
+ xcb_window_t window,
+ xcb_window_t transient_for_window);
+
+/**
+ * @see xcb_set_wm_transient_for
+ */
+xcb_void_cookie_t xcb_set_wm_transient_for(xcb_connection_t *c,
+ xcb_window_t window,
+ xcb_window_t transient_for_window);
+
+/**
* @brief Send request to get WM_TRANSIENT_FOR property of a window.
* @param c The connection to the X server
* @param window Window X identifier.
--
1.7.0
--=-=-=
Content-Type: text/x-diff
Content-Disposition: attachment;
filename=0002-icccm-allow-to-set-the-encoding-format-for-TEXT-prop.patch
More information about the Xcb
mailing list