client: icon_name is stored and watched
This permits to update tasklist on icon name changes. Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
c0f75c2ed8
commit
2a36b021d1
9
client.c
9
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);
|
||||
|
|
|
@ -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)
|
||||
|
|
45
property.c
45
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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue