diff --git a/client.c b/client.c index 1177620a..e4e148a5 100644 --- a/client.c +++ b/client.c @@ -461,6 +461,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); /* update strut */ ewmh_client_strut_update(c, NULL); @@ -1436,13 +1437,7 @@ luaA_client_index(lua_State *L) p_delete(&value); break; case A_TK_ICON_NAME: - if(!xutil_text_prop_get(globalconf.connection, (*c)->win, - _NET_WM_ICON_NAME, &value, &slen)) - if(!xutil_text_prop_get(globalconf.connection, (*c)->win, - WM_ICON_NAME, &value, &slen)) - return 0; - lua_pushlstring(L, value, slen); - p_delete(&value); + lua_pushstring(L, (*c)->icon_name); break; case A_TK_SCREEN: lua_pushnumber(L, 1 + (*c)->screen); diff --git a/lib/awful/widget.lua.in b/lib/awful/widget.lua.in index 62793d0b..cfd45c26 100644 --- a/lib/awful/widget.lua.in +++ b/lib/awful/widget.lua.in @@ -254,7 +254,8 @@ function tasklist.new(label, buttons) if prop == "urgent" or prop == "floating" or prop == "icon" - or prop == "name" then + or prop == "name" + or prop == "icon_name" then tasklist_update() end end) diff --git a/property.c b/property.c index ccc77bfc..ddb22919 100644 --- a/property.c +++ b/property.c @@ -239,6 +239,31 @@ property_update_wm_name(client_t *c) hooks_property(c, "name"); } +/** Update client icon name attribute with its new title. + * \param c The client. + * \param Return true if it has been updated. + */ +void +property_update_wm_icon_name(client_t *c) +{ + char *name, *utf8; + ssize_t len; + + if(!xutil_text_prop_get(globalconf.connection, c->win, _NET_WM_ICON_NAME, &name, &len)) + if(!xutil_text_prop_get(globalconf.connection, c->win, WM_ICON_NAME, &name, &len)) + return; + + p_delete(&c->icon_name); + + if((utf8 = draw_iso2utf8(name, len))) + c->icon_name = utf8; + else + c->icon_name = name; + + /* call hook */ + hooks_property(c, "icon_name"); +} + static int property_handle_wm_name(void *data, xcb_connection_t *connection, @@ -255,6 +280,22 @@ property_handle_wm_name(void *data, return 0; } +static int +property_handle_wm_icon_name(void *data, + xcb_connection_t *connection, + uint8_t state, + xcb_window_t window, + xcb_atom_t name, + xcb_get_property_reply_t *reply) +{ + client_t *c = client_getbywin(window); + + if(c) + property_update_wm_icon_name(c); + + return 0; +} + static int property_handle_net_wm_strut_partial(void *data, xcb_connection_t *connection, @@ -360,10 +401,14 @@ void a_xcb_set_property_handlers(void) property_handle_wm_hints, NULL); xcb_property_set_handler(&globalconf.prophs, WM_NAME, UINT_MAX, property_handle_wm_name, NULL); + xcb_property_set_handler(&globalconf.prophs, WM_ICON_NAME, UINT_MAX, + property_handle_wm_icon_name, NULL); /* EWMH stuff */ xcb_property_set_handler(&globalconf.prophs, _NET_WM_NAME, UINT_MAX, property_handle_wm_name, NULL); + xcb_property_set_handler(&globalconf.prophs, _NET_WM_ICON_NAME, UINT_MAX, + property_handle_wm_icon_name, NULL); xcb_property_set_handler(&globalconf.prophs, _NET_WM_STRUT_PARTIAL, UINT_MAX, property_handle_net_wm_strut_partial, NULL); xcb_property_set_handler(&globalconf.prophs, _NET_WM_ICON, UINT_MAX, diff --git a/property.h b/property.h index 56cfba4d..f62a520c 100644 --- a/property.h +++ b/property.h @@ -28,6 +28,7 @@ void property_update_wm_transient_for(client_t *, 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_name(client_t *); +void property_update_wm_icon_name(client_t *); void a_xcb_set_property_handlers(void); #endif diff --git a/structs.h b/structs.h index 45f6cd50..d3131b3d 100644 --- a/structs.h +++ b/structs.h @@ -219,7 +219,7 @@ struct client_t /** Valid, or not ? */ bool invalid; /** Client name */ - char *name; + char *name, *icon_name; /** Window geometry */ area_t geometry; /** Floating window geometry */