diff --git a/client.c b/client.c index 917b1013..89a56fe1 100644 --- a/client.c +++ b/client.c @@ -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); diff --git a/property.c b/property.c index dd4e00b4..79565e8a 100644 --- a/property.c +++ b/property.c @@ -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); - } + 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; } diff --git a/property.h b/property.h index 1c98fe0c..259821f2 100644 --- a/property.h +++ b/property.h @@ -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);