Skip to content

Commit

Permalink
icccm: add xcb_get_wm_class_from_reply()
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Danjou <[email protected]>
  • Loading branch information
jd committed Apr 4, 2009
1 parent 4c9a707 commit 803dedd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
21 changes: 14 additions & 7 deletions icccm/icccm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions icccm/xcb_icccm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 803dedd

Please sign in to comment.