Add client_t::protocols

We now always know a client's WM_PROTOCOLS property without asking the X server.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Uli Schlachter 2009-06-24 17:59:19 +02:00 committed by Julien Danjou
parent 2cb34a30f2
commit f1b3583064
4 changed files with 42 additions and 0 deletions

View File

@ -54,6 +54,7 @@ luaA_client_gc(lua_State *L)
button_array_wipe(&c->buttons); button_array_wipe(&c->buttons);
key_array_wipe(&c->keys); key_array_wipe(&c->keys);
image_unref(L, c->icon); image_unref(L, c->icon);
xcb_get_wm_protocols_reply_wipe(&c->protocols);
p_delete(&c->class); p_delete(&c->class);
p_delete(&c->startup_id); p_delete(&c->startup_id);
p_delete(&c->instance); p_delete(&c->instance);
@ -510,6 +511,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
property_update_wm_name(c); property_update_wm_name(c);
property_update_wm_icon_name(c); property_update_wm_icon_name(c);
property_update_wm_class(c, NULL); property_update_wm_class(c, NULL);
property_update_wm_protocols(c);
xutil_text_prop_get(globalconf.connection, c->win, _NET_STARTUP_ID, &c->startup_id, NULL); xutil_text_prop_get(globalconf.connection, c->win, _NET_STARTUP_ID, &c->startup_id, NULL);

View File

@ -130,6 +130,8 @@ struct client_t
xcb_window_t group_win; xcb_window_t group_win;
/** Window holding command needed to start it (session management related) */ /** Window holding command needed to start it (session management related) */
xcb_window_t leader_win; xcb_window_t leader_win;
/** Client's WM_PROTOCOLS property */
xcb_get_wm_protocols_reply_t protocols;
/** Client logical screen */ /** Client logical screen */
screen_t *screen; screen_t *screen;
/** Client physical screen */ /** Client physical screen */

View File

@ -365,6 +365,41 @@ property_handle_net_wm_icon(void *data,
return 0; return 0;
} }
/** Update the list of supported protocols for a client.
* \param c The client.
*/
void
property_update_wm_protocols(client_t *c)
{
xcb_get_wm_protocols_reply_t protocols;
/* If this fails for any reason, we still got the old value */
if(xcb_get_wm_protocols_reply(globalconf.connection,
xcb_get_wm_protocols_unchecked(globalconf.connection,
c->win, WM_PROTOCOLS),
&protocols, NULL))
{
xcb_get_wm_protocols_reply_wipe(&c->protocols);
memcpy(&c->protocols, &protocols, sizeof(protocols));
}
}
static int
property_handle_wm_protocols(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_protocols(c);
return 0;
}
/** The property notify event handler. /** The property notify event handler.
* \param data currently unused. * \param data currently unused.
* \param connection The connection to the X server. * \param connection The connection to the X server.
@ -447,6 +482,8 @@ void a_xcb_set_property_handlers(void)
property_handle_wm_icon_name, NULL); property_handle_wm_icon_name, NULL);
xcb_property_set_handler(&globalconf.prophs, WM_CLASS, UINT_MAX, xcb_property_set_handler(&globalconf.prophs, WM_CLASS, UINT_MAX,
property_handle_wm_class, NULL); property_handle_wm_class, NULL);
xcb_property_set_handler(&globalconf.prophs, WM_PROTOCOLS, UINT_MAX,
property_handle_wm_protocols, 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,

View File

@ -31,6 +31,7 @@ void property_update_wm_hints(client_t *, xcb_get_property_reply_t *);
void property_update_wm_class(client_t *, xcb_get_property_reply_t *); void property_update_wm_class(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 property_update_wm_icon_name(client_t *);
void property_update_wm_protocols(client_t *);
void a_xcb_set_property_handlers(void); void a_xcb_set_property_handlers(void);
#endif #endif