From 0acb4aeff4cea1f632e7b1efc0ce4e37c9e933a4 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 10 Aug 2009 11:36:11 +0200 Subject: [PATCH] client: store WM_CLIENT_MACHINE Signed-off-by: Julien Danjou --- client.c | 7 ++----- client.h | 2 ++ property.c | 33 ++++++++++++++++++++++++++++++++- property.h | 3 ++- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/client.c b/client.c index 236c0d16..3993ed81 100644 --- a/client.c +++ b/client.c @@ -548,6 +548,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); /* Then check clients hints */ ewmh_client_check_hints(c); @@ -1731,11 +1732,7 @@ luaA_client_index(lua_State *L) lua_pushnumber(L, c->leader_win); break; case A_TK_MACHINE: - if(!xutil_text_prop_get(globalconf.connection, c->win, - WM_CLIENT_MACHINE, &value, &slen)) - return 0; - lua_pushlstring(L, value, slen); - p_delete(&value); + lua_pushstring(L, c->machine); break; case A_TK_ICON_NAME: lua_pushstring(L, c->icon_name); diff --git a/client.h b/client.h index 2bdb69e1..d0d98736 100644 --- a/client.h +++ b/client.h @@ -148,6 +148,8 @@ struct client_t /** Size hints */ xcb_size_hints_t size_hints; bool size_hints_honor; + /** Machine the client is running on. */ + char *machine; /** Window it is transient for */ client_t *transient_for; }; diff --git a/property.c b/property.c index 0645df9f..1df965f4 100644 --- a/property.c +++ b/property.c @@ -1,7 +1,7 @@ /* * property.c - property handlers * - * Copyright © 2008 Julien Danjou + * Copyright © 2008-2009 Julien Danjou * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -70,6 +70,35 @@ property_handle_wm_transient_for(void *data, return 0; } +void +property_update_wm_client_machine(client_t *c) +{ + ssize_t slen; + char *value; + + if(!xutil_text_prop_get(globalconf.connection, c->win, + WM_CLIENT_MACHINE, &value, &slen)) + return; + + p_delete(&c->machine); + c->machine = a_strdup(value); +} + +static int +property_handle_wm_client_machine(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_client_machine(c); + + return 0; +} /** Update leader hint of a client. * \param c The client. @@ -498,6 +527,8 @@ void a_xcb_set_property_handlers(void) property_handle_wm_class, NULL); xcb_property_set_handler(&globalconf.prophs, WM_PROTOCOLS, UINT_MAX, property_handle_wm_protocols, NULL); + xcb_property_set_handler(&globalconf.prophs, WM_CLIENT_MACHINE, UINT_MAX, + property_handle_wm_client_machine, NULL); /* EWMH stuff */ xcb_property_set_handler(&globalconf.prophs, _NET_WM_NAME, UINT_MAX, diff --git a/property.h b/property.h index f492d10a..9c8e0941 100644 --- a/property.h +++ b/property.h @@ -1,7 +1,7 @@ /* * property.h - property handlers header * - * Copyright © 2008 Julien Danjou + * Copyright © 2008-2009 Julien Danjou * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,6 +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 a_xcb_set_property_handlers(void); #endif