property: make use of xcb_get_wm_class_from_reply() when possible

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-04-18 14:20:06 +02:00
parent b6db5137fc
commit 0b93186f09
3 changed files with 25 additions and 13 deletions

View File

@ -509,7 +509,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
/* update window title */
property_update_wm_name(c);
property_update_wm_icon_name(c);
property_update_wm_class(c);
property_update_wm_class(c, NULL);
xutil_text_prop_get(globalconf.connection, c->win, _NET_STARTUP_ID, &c->startup_id, NULL);

View File

@ -221,22 +221,34 @@ property_update_wm_name(client_t *c)
hooks_property(c, "name");
}
/** Update WM_CLASS of a client.
* \param c The client.
* \param reply The reply to get property request, or NULL if none.
*/
void
property_update_wm_class(client_t *c)
property_update_wm_class(client_t *c, xcb_get_property_reply_t *reply)
{
xcb_get_wm_class_reply_t hint;
if(reply)
{
if(!xcb_get_wm_class_from_reply(&hint, reply))
return;
}
else
{
if(!xcb_get_wm_class_reply(globalconf.connection,
xcb_get_wm_class_unchecked(globalconf.connection, c->win),
&hint, NULL))
return;
}
p_delete(&c->instance);
p_delete(&c->class);
if(xcb_get_wm_class_reply(globalconf.connection,
xcb_get_wm_class_unchecked(globalconf.connection, c->win),
&hint, NULL))
{
c->instance = a_strdup(hint.instance_name);
c->class = a_strdup(hint.class_name);
xcb_get_wm_class_reply_wipe(&hint);
}
}
/** Update client icon name attribute with its new title.
@ -304,7 +316,7 @@ property_handle_wm_class(void *data,
client_t *c = client_getbywin(window);
if(c)
property_update_wm_class(c);
property_update_wm_class(c, reply);
return 0;
}

View File

@ -25,10 +25,10 @@
#include "structs.h"
void property_update_wm_transient_for(client_t *, xcb_get_property_reply_t *);
void property_update_wm_client_leader(client_t *c, xcb_get_property_reply_t *reply);
void property_update_wm_client_leader(client_t *c, xcb_get_property_reply_t *);
void property_update_wm_normal_hints(client_t *, xcb_get_property_reply_t *);
void property_update_wm_hints(client_t *, xcb_get_property_reply_t *);
void property_update_wm_class(client_t *);
void property_update_wm_class(client_t *, xcb_get_property_reply_t *);
void property_update_wm_name(client_t *);
void property_update_wm_icon_name(client_t *);
void a_xcb_set_property_handlers(void);