Push the property requests down
Instead of calling each property handler with a property reply, it's now up to the handlers to request the properties. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
2f20494676
commit
709619b466
17
ewmh.c
17
ewmh.c
|
@ -590,17 +590,14 @@ ewmh_client_check_hints(client_t *c)
|
||||||
* \param strut_r (Optional) An existing reply.
|
* \param strut_r (Optional) An existing reply.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ewmh_process_client_strut(client_t *c, xcb_get_property_reply_t *strut_r)
|
ewmh_process_client_strut(client_t *c)
|
||||||
{
|
{
|
||||||
void *data;
|
void *data;
|
||||||
xcb_get_property_reply_t *mstrut_r = NULL;
|
xcb_get_property_reply_t *strut_r;
|
||||||
|
|
||||||
if(!strut_r)
|
xcb_get_property_cookie_t strut_q = xcb_get_property_unchecked(globalconf.connection, false, c->window,
|
||||||
{
|
_NET_WM_STRUT_PARTIAL, XCB_ATOM_CARDINAL, 0, 12);
|
||||||
xcb_get_property_cookie_t strut_q = xcb_get_property_unchecked(globalconf.connection, false, c->window,
|
strut_r = xcb_get_property_reply(globalconf.connection, strut_q, NULL);
|
||||||
_NET_WM_STRUT_PARTIAL, XCB_ATOM_CARDINAL, 0, 12);
|
|
||||||
strut_r = mstrut_r = xcb_get_property_reply(globalconf.connection, strut_q, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(strut_r
|
if(strut_r
|
||||||
&& strut_r->value_len
|
&& strut_r->value_len
|
||||||
|
@ -640,7 +637,7 @@ ewmh_process_client_strut(client_t *c, xcb_get_property_reply_t *strut_r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p_delete(&mstrut_r);
|
p_delete(&strut_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Send request to get NET_WM_ICON (EWMH)
|
/** Send request to get NET_WM_ICON (EWMH)
|
||||||
|
@ -654,7 +651,7 @@ ewmh_window_icon_get_unchecked(xcb_window_t w)
|
||||||
_NET_WM_ICON, XCB_ATOM_CARDINAL, 0, UINT32_MAX);
|
_NET_WM_ICON, XCB_ATOM_CARDINAL, 0, UINT32_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
ewmh_window_icon_from_reply(xcb_get_property_reply_t *r)
|
ewmh_window_icon_from_reply(xcb_get_property_reply_t *r)
|
||||||
{
|
{
|
||||||
uint32_t *data;
|
uint32_t *data;
|
||||||
|
|
3
ewmh.h
3
ewmh.h
|
@ -34,10 +34,9 @@ int ewmh_process_client_message(xcb_client_message_event_t *);
|
||||||
void ewmh_update_net_client_list_stacking(int);
|
void ewmh_update_net_client_list_stacking(int);
|
||||||
void ewmh_client_check_hints(client_t *);
|
void ewmh_client_check_hints(client_t *);
|
||||||
void ewmh_client_update_desktop(client_t *);
|
void ewmh_client_update_desktop(client_t *);
|
||||||
void ewmh_process_client_strut(client_t *, xcb_get_property_reply_t *);
|
void ewmh_process_client_strut(client_t *);
|
||||||
void ewmh_update_strut(xcb_window_t, strut_t *);
|
void ewmh_update_strut(xcb_window_t, strut_t *);
|
||||||
xcb_get_property_cookie_t ewmh_window_icon_get_unchecked(xcb_window_t);
|
xcb_get_property_cookie_t ewmh_window_icon_get_unchecked(xcb_window_t);
|
||||||
int ewmh_window_icon_from_reply(xcb_get_property_reply_t *);
|
|
||||||
int ewmh_window_icon_get_reply(xcb_get_property_cookie_t);
|
int ewmh_window_icon_get_reply(xcb_get_property_cookie_t);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -551,7 +551,7 @@ HANDLE_GEOM(height)
|
||||||
property_update_wm_protocols(c, property_get_wm_protocols(c));
|
property_update_wm_protocols(c, property_get_wm_protocols(c));
|
||||||
|
|
||||||
/* update strut */
|
/* update strut */
|
||||||
ewmh_process_client_strut(c, NULL);
|
ewmh_process_client_strut(c);
|
||||||
|
|
||||||
ewmh_update_net_client_list(c->phys_screen);
|
ewmh_update_net_client_list(c->phys_screen);
|
||||||
|
|
||||||
|
|
95
property.c
95
property.c
|
@ -56,8 +56,7 @@
|
||||||
static int \
|
static int \
|
||||||
property_handle_##funcname(uint8_t state, \
|
property_handle_##funcname(uint8_t state, \
|
||||||
xcb_window_t window, \
|
xcb_window_t window, \
|
||||||
xcb_atom_t name, \
|
xcb_atom_t name) \
|
||||||
xcb_get_property_reply_t *reply) \
|
|
||||||
{ \
|
{ \
|
||||||
client_t *c = client_getbywin(window); \
|
client_t *c = client_getbywin(window); \
|
||||||
if(c) \
|
if(c) \
|
||||||
|
@ -79,8 +78,7 @@ HANDLE_TEXT_PROPERTY(wm_window_role, WM_WINDOW_ROLE, client_set_role)
|
||||||
static int \
|
static int \
|
||||||
property_handle_##name(uint8_t state, \
|
property_handle_##name(uint8_t state, \
|
||||||
xcb_window_t window, \
|
xcb_window_t window, \
|
||||||
xcb_atom_t name, \
|
xcb_atom_t name) \
|
||||||
xcb_get_property_reply_t *reply) \
|
|
||||||
{ \
|
{ \
|
||||||
client_t *c = client_getbywin(window); \
|
client_t *c = client_getbywin(window); \
|
||||||
if(c) \
|
if(c) \
|
||||||
|
@ -227,13 +225,12 @@ property_update_wm_class(client_t *c, xcb_get_property_cookie_t cookie)
|
||||||
static int
|
static int
|
||||||
property_handle_net_wm_strut_partial(uint8_t state,
|
property_handle_net_wm_strut_partial(uint8_t state,
|
||||||
xcb_window_t window,
|
xcb_window_t window,
|
||||||
xcb_atom_t name,
|
xcb_atom_t name)
|
||||||
xcb_get_property_reply_t *reply)
|
|
||||||
{
|
{
|
||||||
client_t *c = client_getbywin(window);
|
client_t *c = client_getbywin(window);
|
||||||
|
|
||||||
if(c)
|
if(c)
|
||||||
ewmh_process_client_strut(c, reply);
|
ewmh_process_client_strut(c);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -317,13 +314,20 @@ property_update_wm_protocols(client_t *c, xcb_get_property_cookie_t cookie)
|
||||||
static int
|
static int
|
||||||
property_handle_xembed_info(uint8_t state,
|
property_handle_xembed_info(uint8_t state,
|
||||||
xcb_window_t window,
|
xcb_window_t window,
|
||||||
xcb_atom_t name,
|
xcb_atom_t name)
|
||||||
xcb_get_property_reply_t *reply)
|
|
||||||
{
|
{
|
||||||
xembed_window_t *emwin = xembed_getbywin(&globalconf.embedded, window);
|
xembed_window_t *emwin = xembed_getbywin(&globalconf.embedded, window);
|
||||||
|
|
||||||
if(emwin)
|
if(emwin)
|
||||||
xembed_property_update(globalconf.connection, emwin, reply);
|
{
|
||||||
|
xcb_get_property_cookie_t cookie =
|
||||||
|
xcb_get_property(globalconf.connection, 0, window, _XEMBED_INFO,
|
||||||
|
XCB_GET_PROPERTY_TYPE_ANY, 0, 3);
|
||||||
|
xcb_get_property_reply_t *propr =
|
||||||
|
xcb_get_property_reply(globalconf.connection, cookie, 0);
|
||||||
|
xembed_property_update(globalconf.connection, emwin, propr);
|
||||||
|
p_delete(&propr);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -331,8 +335,7 @@ property_handle_xembed_info(uint8_t state,
|
||||||
static int
|
static int
|
||||||
property_handle_xrootpmap_id(uint8_t state,
|
property_handle_xrootpmap_id(uint8_t state,
|
||||||
xcb_window_t window,
|
xcb_window_t window,
|
||||||
xcb_atom_t name,
|
xcb_atom_t name)
|
||||||
xcb_get_property_reply_t *reply)
|
|
||||||
{
|
{
|
||||||
if(globalconf.xinerama_is_active)
|
if(globalconf.xinerama_is_active)
|
||||||
foreach(w, globalconf.wiboxes)
|
foreach(w, globalconf.wiboxes)
|
||||||
|
@ -351,15 +354,14 @@ property_handle_xrootpmap_id(uint8_t state,
|
||||||
static int
|
static int
|
||||||
property_handle_net_wm_opacity(uint8_t state,
|
property_handle_net_wm_opacity(uint8_t state,
|
||||||
xcb_window_t window,
|
xcb_window_t window,
|
||||||
xcb_atom_t name,
|
xcb_atom_t name)
|
||||||
xcb_get_property_reply_t *reply)
|
|
||||||
{
|
{
|
||||||
wibox_t *wibox = wibox_getbywin(window);
|
wibox_t *wibox = wibox_getbywin(window);
|
||||||
|
|
||||||
if(wibox)
|
if(wibox)
|
||||||
{
|
{
|
||||||
luaA_object_push(globalconf.L, wibox);
|
luaA_object_push(globalconf.L, wibox);
|
||||||
window_set_opacity(globalconf.L, -1, xwindow_get_opacity_from_reply(reply));
|
window_set_opacity(globalconf.L, -1, xwindow_get_opacity(wibox->window));
|
||||||
lua_pop(globalconf.L, -1);
|
lua_pop(globalconf.L, -1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -368,7 +370,7 @@ property_handle_net_wm_opacity(uint8_t state,
|
||||||
if(c)
|
if(c)
|
||||||
{
|
{
|
||||||
luaA_object_push(globalconf.L, c);
|
luaA_object_push(globalconf.L, c);
|
||||||
window_set_opacity(globalconf.L, -1, xwindow_get_opacity_from_reply(reply));
|
window_set_opacity(globalconf.L, -1, xwindow_get_opacity(c->window));
|
||||||
lua_pop(globalconf.L, 1);
|
lua_pop(globalconf.L, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,68 +387,51 @@ property_handle_net_wm_opacity(uint8_t state,
|
||||||
void
|
void
|
||||||
property_handle_propertynotify(xcb_property_notify_event_t *ev)
|
property_handle_propertynotify(xcb_property_notify_event_t *ev)
|
||||||
{
|
{
|
||||||
uint32_t length;
|
|
||||||
int (*handler)(uint8_t state,
|
int (*handler)(uint8_t state,
|
||||||
xcb_window_t window,
|
xcb_window_t window,
|
||||||
xcb_atom_t name,
|
xcb_atom_t name) = NULL;
|
||||||
xcb_get_property_reply_t *reply) = NULL;
|
|
||||||
|
|
||||||
/* Find the correct event handler */
|
/* Find the correct event handler */
|
||||||
#define HANDLE(atom_, cb, len) \
|
#define HANDLE(atom_, cb) \
|
||||||
if (ev->atom == atom_) \
|
if (ev->atom == atom_) \
|
||||||
{ \
|
{ \
|
||||||
handler = cb; \
|
handler = cb; \
|
||||||
length = len; \
|
|
||||||
} else
|
} else
|
||||||
#define HANDLE_L(atom, cb) HANDLE(atom, cb, UINT_MAX)
|
|
||||||
#define HANDLE_S(atom, cb) HANDLE(atom, cb, 1)
|
|
||||||
#define END return
|
#define END return
|
||||||
|
|
||||||
/* Xembed stuff */
|
/* Xembed stuff */
|
||||||
HANDLE_L(_XEMBED_INFO, property_handle_xembed_info)
|
HANDLE(_XEMBED_INFO, property_handle_xembed_info)
|
||||||
|
|
||||||
/* ICCCM stuff */
|
/* ICCCM stuff */
|
||||||
HANDLE_L(XCB_ATOM_WM_TRANSIENT_FOR, property_handle_wm_transient_for)
|
HANDLE(XCB_ATOM_WM_TRANSIENT_FOR, property_handle_wm_transient_for)
|
||||||
HANDLE_L(WM_CLIENT_LEADER, property_handle_wm_client_leader)
|
HANDLE(WM_CLIENT_LEADER, property_handle_wm_client_leader)
|
||||||
HANDLE_L(XCB_ATOM_WM_NORMAL_HINTS, property_handle_wm_normal_hints)
|
HANDLE(XCB_ATOM_WM_NORMAL_HINTS, property_handle_wm_normal_hints)
|
||||||
HANDLE_L(XCB_ATOM_WM_HINTS, property_handle_wm_hints)
|
HANDLE(XCB_ATOM_WM_HINTS, property_handle_wm_hints)
|
||||||
HANDLE_L(XCB_ATOM_WM_NAME, property_handle_wm_name)
|
HANDLE(XCB_ATOM_WM_NAME, property_handle_wm_name)
|
||||||
HANDLE_L(XCB_ATOM_WM_ICON_NAME, property_handle_wm_icon_name)
|
HANDLE(XCB_ATOM_WM_ICON_NAME, property_handle_wm_icon_name)
|
||||||
HANDLE_L(XCB_ATOM_WM_CLASS, property_handle_wm_class)
|
HANDLE(XCB_ATOM_WM_CLASS, property_handle_wm_class)
|
||||||
HANDLE_L(WM_PROTOCOLS, property_handle_wm_protocols)
|
HANDLE(WM_PROTOCOLS, property_handle_wm_protocols)
|
||||||
HANDLE_L(XCB_ATOM_WM_CLIENT_MACHINE, property_handle_wm_client_machine)
|
HANDLE(XCB_ATOM_WM_CLIENT_MACHINE, property_handle_wm_client_machine)
|
||||||
HANDLE_L(WM_WINDOW_ROLE, property_handle_wm_window_role)
|
HANDLE(WM_WINDOW_ROLE, property_handle_wm_window_role)
|
||||||
|
|
||||||
/* EWMH stuff */
|
/* EWMH stuff */
|
||||||
HANDLE_L(_NET_WM_NAME, property_handle_net_wm_name)
|
HANDLE(_NET_WM_NAME, property_handle_net_wm_name)
|
||||||
HANDLE_L(_NET_WM_ICON_NAME, property_handle_net_wm_icon_name)
|
HANDLE(_NET_WM_ICON_NAME, property_handle_net_wm_icon_name)
|
||||||
HANDLE_L(_NET_WM_STRUT_PARTIAL, property_handle_net_wm_strut_partial)
|
HANDLE(_NET_WM_STRUT_PARTIAL, property_handle_net_wm_strut_partial)
|
||||||
HANDLE_L(_NET_WM_ICON, property_handle_net_wm_icon)
|
HANDLE(_NET_WM_ICON, property_handle_net_wm_icon)
|
||||||
HANDLE_L(_NET_WM_PID, property_handle_net_wm_pid)
|
HANDLE(_NET_WM_PID, property_handle_net_wm_pid)
|
||||||
HANDLE_S(_NET_WM_WINDOW_OPACITY, property_handle_net_wm_opacity)
|
HANDLE(_NET_WM_WINDOW_OPACITY, property_handle_net_wm_opacity)
|
||||||
|
|
||||||
/* background change */
|
/* background change */
|
||||||
HANDLE_S(_XROOTPMAP_ID, property_handle_xrootpmap_id)
|
HANDLE(_XROOTPMAP_ID, property_handle_xrootpmap_id)
|
||||||
|
|
||||||
/* If nothing was found, return */
|
/* If nothing was found, return */
|
||||||
END;
|
END;
|
||||||
|
|
||||||
#undef HANDLE_L
|
#undef HANDLE
|
||||||
#undef HANDLE_S
|
|
||||||
#undef END
|
#undef END
|
||||||
|
|
||||||
/* Get the property, if needed. */
|
(*handler)(ev->state, ev->window, ev->atom);
|
||||||
xcb_get_property_reply_t *propr = NULL;
|
|
||||||
if(ev->state != XCB_PROPERTY_DELETE)
|
|
||||||
{
|
|
||||||
xcb_get_property_cookie_t cookie =
|
|
||||||
xcb_get_property(globalconf.connection, 0, ev->window, ev->atom,
|
|
||||||
XCB_GET_PROPERTY_TYPE_ANY, 0, length);
|
|
||||||
propr = xcb_get_property_reply(globalconf.connection, cookie, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
(*handler)(ev->state, ev->window, ev->atom, propr);
|
|
||||||
p_delete(&propr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue