ewmh: make ewmh_window_icon_get() asynchronous

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Arnaud Fontaine 2008-08-13 02:02:19 +02:00 committed by Julien Danjou
parent 5c9cc7857d
commit 9e3fbfdb4b
4 changed files with 22 additions and 9 deletions

View file

@ -363,6 +363,7 @@ client_raise(client_t *c)
void
client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int screen)
{
xcb_get_property_cookie_t ewmh_icon_cookie;
client_t *c, *t = NULL;
xcb_window_t trans;
bool rettrans, retloadprops;
@ -374,6 +375,8 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int screen)
| XCB_EVENT_MASK_ENTER_WINDOW
};
/* Send request to get NET_WM_ICON property as soon as possible... */
ewmh_icon_cookie = ewmh_window_icon_get_unchecked(w);
xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK, select_input_val);
if(systray_iskdedockapp(w))
@ -399,7 +402,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int screen)
c->geometry.height = c->f_geometry.height = c->m_geometry.height = wgeom->height;
c->layer = c->oldlayer = LAYER_TILE;
client_setborder(c, wgeom->border_width);
c->icon = ewmh_window_icon_get(c->win);
c->icon = ewmh_window_icon_get_reply(ewmh_icon_cookie);
/* update hints */
u_size_hints = client_updatesizehints(c);

View file

@ -540,9 +540,10 @@ event_handle_propertynotify(void *data __attribute__ ((unused)),
client_updatetitle(c);
else if(ev->atom == _NET_WM_ICON)
{
xcb_get_property_cookie_t icon_q = ewmh_window_icon_get_unchecked(c->win);
netwm_icon_delete(&c->icon);
c->icon = ewmh_window_icon_get(c->win);
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
c->icon = ewmh_window_icon_get_reply(icon_q);
}
}

20
ewmh.c
View file

@ -511,12 +511,23 @@ ewmh_check_client_hints(client_t *c)
p_delete(&reply);
}
/** Get NET_WM_ICON.
/** Send request to get NET_WM_ICON (EWMH)
* \param w The window.
* \return The cookie associated with the request.
*/
xcb_get_property_cookie_t
ewmh_window_icon_get_unchecked(xcb_window_t w)
{
return xcb_get_property_unchecked(globalconf.connection, false, w,
_NET_WM_ICON, CARDINAL, 0, UINT32_MAX);
}
/** Get NET_WM_ICON.
* \param cookie The cookie.
* \return A netwm_icon_t structure which must be deleted after usage.
*/
netwm_icon_t *
ewmh_window_icon_get(xcb_window_t w)
ewmh_window_icon_get_reply(xcb_get_property_cookie_t cookie)
{
double alpha;
netwm_icon_t *icon;
@ -525,10 +536,7 @@ ewmh_window_icon_get(xcb_window_t w)
unsigned char *imgdata;
xcb_get_property_reply_t *r;
r = xcb_get_property_reply(globalconf.connection,
xcb_get_property_unchecked(globalconf.connection, false, w,
_NET_WM_ICON, CARDINAL, 0, UINT32_MAX),
NULL);
r = xcb_get_property_reply(globalconf.connection, cookie, NULL);
if(!r || r->type != CARDINAL || r->format != 32 || r->length < 2 ||
!(data = (uint32_t *) xcb_get_property_value(r)))
{

3
ewmh.h
View file

@ -44,7 +44,8 @@ int ewmh_process_client_message(xcb_client_message_event_t *);
void ewmh_update_net_client_list_stacking(int);
void ewmh_check_client_hints(client_t *);
void ewmh_update_workarea(int);
netwm_icon_t * ewmh_window_icon_get(xcb_window_t);
xcb_get_property_cookie_t ewmh_window_icon_get_unchecked(xcb_window_t);
netwm_icon_t *ewmh_window_icon_get_reply(xcb_get_property_cookie_t);
void ewmh_restart(void);
#endif