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:
Julien Danjou 2008-10-21 15:12:55 +02:00
parent c0f75c2ed8
commit 2a36b021d1
5 changed files with 51 additions and 9 deletions

View File

@ -461,6 +461,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
/* update window title */ /* update window title */
property_update_wm_name(c); property_update_wm_name(c);
property_update_wm_icon_name(c);
/* update strut */ /* update strut */
ewmh_client_strut_update(c, NULL); ewmh_client_strut_update(c, NULL);
@ -1436,13 +1437,7 @@ luaA_client_index(lua_State *L)
p_delete(&value); p_delete(&value);
break; break;
case A_TK_ICON_NAME: case A_TK_ICON_NAME:
if(!xutil_text_prop_get(globalconf.connection, (*c)->win, lua_pushstring(L, (*c)->icon_name);
_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);
break; break;
case A_TK_SCREEN: case A_TK_SCREEN:
lua_pushnumber(L, 1 + (*c)->screen); lua_pushnumber(L, 1 + (*c)->screen);

View File

@ -254,7 +254,8 @@ function tasklist.new(label, buttons)
if prop == "urgent" if prop == "urgent"
or prop == "floating" or prop == "floating"
or prop == "icon" or prop == "icon"
or prop == "name" then or prop == "name"
or prop == "icon_name" then
tasklist_update() tasklist_update()
end end
end) end)

View File

@ -239,6 +239,31 @@ property_update_wm_name(client_t *c)
hooks_property(c, "name"); 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 static int
property_handle_wm_name(void *data, property_handle_wm_name(void *data,
xcb_connection_t *connection, xcb_connection_t *connection,
@ -255,6 +280,22 @@ property_handle_wm_name(void *data,
return 0; 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 static int
property_handle_net_wm_strut_partial(void *data, property_handle_net_wm_strut_partial(void *data,
xcb_connection_t *connection, xcb_connection_t *connection,
@ -360,10 +401,14 @@ void a_xcb_set_property_handlers(void)
property_handle_wm_hints, NULL); property_handle_wm_hints, NULL);
xcb_property_set_handler(&globalconf.prophs, WM_NAME, UINT_MAX, xcb_property_set_handler(&globalconf.prophs, WM_NAME, UINT_MAX,
property_handle_wm_name, NULL); property_handle_wm_name, NULL);
xcb_property_set_handler(&globalconf.prophs, WM_ICON_NAME, UINT_MAX,
property_handle_wm_icon_name, NULL);
/* EWMH stuff */ /* EWMH stuff */
xcb_property_set_handler(&globalconf.prophs, _NET_WM_NAME, UINT_MAX, xcb_property_set_handler(&globalconf.prophs, _NET_WM_NAME, UINT_MAX,
property_handle_wm_name, NULL); 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, xcb_property_set_handler(&globalconf.prophs, _NET_WM_STRUT_PARTIAL, UINT_MAX,
property_handle_net_wm_strut_partial, NULL); property_handle_net_wm_strut_partial, NULL);
xcb_property_set_handler(&globalconf.prophs, _NET_WM_ICON, UINT_MAX, xcb_property_set_handler(&globalconf.prophs, _NET_WM_ICON, UINT_MAX,

View File

@ -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_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_hints(client_t *, xcb_get_property_reply_t *);
void property_update_wm_name(client_t *); void property_update_wm_name(client_t *);
void property_update_wm_icon_name(client_t *);
void a_xcb_set_property_handlers(void); void a_xcb_set_property_handlers(void);
#endif #endif

View File

@ -219,7 +219,7 @@ struct client_t
/** Valid, or not ? */ /** Valid, or not ? */
bool invalid; bool invalid;
/** Client name */ /** Client name */
char *name; char *name, *icon_name;
/** Window geometry */ /** Window geometry */
area_t geometry; area_t geometry;
/** Floating window geometry */ /** Floating window geometry */