From a6c0d9398ec7e6b6edb107618e74bec2c7ad450d Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sat, 22 Aug 2009 15:05:29 +0200 Subject: [PATCH] property: use provided reply to get machine This avoid a roundtrip when getting a property change event. Signed-off-by: Julien Danjou --- client.c | 2 +- property.c | 23 +++++++++++++++-------- property.h | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/client.c b/client.c index f1d81588b..5d8f65fe0 100644 --- a/client.c +++ b/client.c @@ -629,7 +629,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, property_update_wm_hints(c, NULL); property_update_wm_transient_for(c, NULL); property_update_wm_client_leader(c, NULL); - property_update_wm_client_machine(c); + property_update_wm_client_machine(c, NULL); property_update_wm_window_role(c); property_update_net_wm_pid(c, NULL); property_update_net_wm_icon(c, NULL); diff --git a/property.c b/property.c index 556661925..0054d3501 100644 --- a/property.c +++ b/property.c @@ -74,19 +74,26 @@ property_handle_wm_transient_for(void *data, } void -property_update_wm_client_machine(client_t *c) +property_update_wm_client_machine(client_t *c, xcb_get_property_reply_t *reply) { - ssize_t slen; - char *value; + bool no_reply = !reply; - if(!xutil_text_prop_get(globalconf.connection, c->window, - WM_CLIENT_MACHINE, &value, &slen)) - return; + if(no_reply) + reply = xcb_get_property_reply(globalconf.connection, + xcb_get_any_property(globalconf.connection, + false, + c->window, + WM_CLIENT_MACHINE, + UINT_MAX), NULL); + + const char *value = xutil_get_text_property_from_reply(reply); luaA_object_push(globalconf.L, c); client_set_machine(globalconf.L, -1, value); - p_delete(&value); lua_pop(globalconf.L, 1); + + if(no_reply) + p_delete(&reply); } static int @@ -100,7 +107,7 @@ property_handle_wm_client_machine(void *data, client_t *c = client_getbywin(window); if(c) - property_update_wm_client_machine(c); + property_update_wm_client_machine(c, reply); return 0; } diff --git a/property.h b/property.h index ac0a5b780..5aee3fca2 100644 --- a/property.h +++ b/property.h @@ -32,7 +32,7 @@ void property_update_wm_class(client_t *, xcb_get_property_reply_t *); void property_update_wm_name(client_t *); void property_update_wm_icon_name(client_t *); void property_update_wm_protocols(client_t *); -void property_update_wm_client_machine(client_t *); +void property_update_wm_client_machine(client_t *, xcb_get_property_reply_t *); void property_update_wm_window_role(client_t *); void property_update_net_wm_pid(client_t *, xcb_get_property_reply_t *); void property_update_net_wm_icon(client_t *, xcb_get_property_reply_t *);