summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Danjou <julien@danjou.info>2009-04-04 13:38:12 +0200
committerJulien Danjou <julien@danjou.info>2009-04-04 13:38:12 +0200
commit803deddb31931211099309d78d3bb6bcff29487b (patch)
tree437380aa3f167ba1a96ec9c206cb39318aa2e07a
parent4c9a707f472e49bc3005354db265a0214071d46b (diff)
icccm: add xcb_get_wm_class_from_reply()
Signed-off-by: Julien Danjou <julien@danjou.info>
-rw-r--r--icccm/icccm.c21
-rw-r--r--icccm/xcb_icccm.h11
2 files changed, 25 insertions, 7 deletions
diff --git a/icccm/icccm.c b/icccm/icccm.c
index a1d7502..d818d7e 100644
--- a/icccm/icccm.c
+++ b/icccm/icccm.c
@@ -238,16 +238,11 @@ xcb_get_wm_class_unchecked(xcb_connection_t *c, xcb_window_t window)
}
uint8_t
-xcb_get_wm_class_reply(xcb_connection_t *c, xcb_get_property_cookie_t cookie,
- xcb_get_wm_class_reply_t *prop, xcb_generic_error_t **e)
+xcb_get_wm_class_from_reply(xcb_get_wm_class_reply_t *prop,
+ xcb_get_property_reply_t *reply)
{
- xcb_get_property_reply_t *reply = xcb_get_property_reply(c, cookie, e);
-
if(!reply || reply->type != STRING || reply->format != 8)
- {
- free(reply);
return 0;
- }
prop->_reply = reply;
prop->instance_name = (char *) xcb_get_property_value(prop->_reply);
@@ -261,6 +256,18 @@ xcb_get_wm_class_reply(xcb_connection_t *c, xcb_get_property_cookie_t cookie,
return 1;
}
+uint8_t
+xcb_get_wm_class_reply(xcb_connection_t *c, xcb_get_property_cookie_t cookie,
+ xcb_get_wm_class_reply_t *prop, xcb_generic_error_t **e)
+{
+ xcb_get_property_reply_t *reply = xcb_get_property_reply(c, cookie, e);
+ uint8_t ret = xcb_get_wm_class_from_reply(prop, reply);
+ /* if reply parsing failed, free the reply to avoid mem leak */
+ if(!ret)
+ free(reply);
+ return ret;
+}
+
void xcb_get_wm_class_reply_wipe(xcb_get_wm_class_reply_t *prop)
{
free(prop->_reply);
diff --git a/icccm/xcb_icccm.h b/icccm/xcb_icccm.h
index 745f920..5358d89 100644
--- a/icccm/xcb_icccm.h
+++ b/icccm/xcb_icccm.h
@@ -327,6 +327,17 @@ xcb_get_property_cookie_t xcb_get_wm_class(xcb_connection_t *c,
xcb_get_property_cookie_t xcb_get_wm_class_unchecked(xcb_connection_t *c,
xcb_window_t window);
+
+/**
+ * @brief Fill give structure with the WM_CLASS property of a window.
+ * @param prop The property structur to fill.
+ * @param reply The property request reply.
+ * @return Return 1 on success, 0 otherwise.
+ */
+uint8_t
+xcb_get_wm_class_from_reply(xcb_get_wm_class_reply_t *prop,
+ xcb_get_property_reply_t *reply);
+
/**
* @brief Fill given structure with the WM_CLASS property of a window.
* @param c The connection to the X server.