From 61430f860d80d9979de8999ca76db7de390aaee7 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 8 Oct 2009 14:49:41 +0200 Subject: [PATCH] ewmh: use client signals to update NET_ACTIVE_WINDOW Signed-off-by: Julien Danjou --- ewmh.c | 39 +++++++++++++++++++++++---------------- ewmh.h | 1 - objects/client.c | 3 --- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/ewmh.c b/ewmh.c index abdbf97c..4c192062 100644 --- a/ewmh.c +++ b/ewmh.c @@ -111,6 +111,25 @@ ewmh_update_desktop_geometry(int phys_screen) _NET_DESKTOP_GEOMETRY, CARDINAL, 32, countof(sizes), sizes); } +static int +ewmh_update_net_active_window(lua_State *L) +{ + client_t *c = luaA_checkudata(L, 1, &client_class); + xcb_window_t win; + + if(globalconf.screen_focus->client_focus + && globalconf.screen_focus->client_focus->phys_screen == c->phys_screen) + win = globalconf.screen_focus->client_focus->window; + else + win = XCB_NONE; + + xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, + xutil_screen_get(globalconf.connection, c->phys_screen)->root, + _NET_ACTIVE_WINDOW, WINDOW, 32, 1, &win); + + return 0; +} + void ewmh_init(int phys_screen) { @@ -196,6 +215,10 @@ ewmh_init(int phys_screen) lua_pushcfunction(globalconf.L, ewmh_signal_on_client_new); luaA_class_add_signal(globalconf.L, &client_class, "new", -1); + lua_pushcfunction(globalconf.L, ewmh_update_net_active_window); + luaA_class_add_signal(globalconf.L, &client_class, "focus", -1); + lua_pushcfunction(globalconf.L, ewmh_update_net_active_window); + luaA_class_add_signal(globalconf.L, &client_class, "unfocus", -1); } void @@ -273,22 +296,6 @@ ewmh_update_net_desktop_names(int phys_screen) buffer_wipe(&buf); } -void -ewmh_update_net_active_window(int phys_screen) -{ - xcb_window_t win; - - if(globalconf.screen_focus->client_focus - && globalconf.screen_focus->client_focus->phys_screen == phys_screen) - win = globalconf.screen_focus->client_focus->window; - else - win = XCB_NONE; - - xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, - xutil_screen_get(globalconf.connection, phys_screen)->root, - _NET_ACTIVE_WINDOW, WINDOW, 32, 1, &win); -} - static void ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set) { diff --git a/ewmh.h b/ewmh.h index cfdddd85..8311c1b7 100644 --- a/ewmh.h +++ b/ewmh.h @@ -30,7 +30,6 @@ void ewmh_update_net_client_list(int); void ewmh_update_net_numbers_of_desktop(int); void ewmh_update_net_current_desktop(int); void ewmh_update_net_desktop_names(int); -void ewmh_update_net_active_window(int); int ewmh_process_client_message(xcb_client_message_event_t *); void ewmh_update_net_client_list_stacking(int); void ewmh_client_check_hints(client_t *); diff --git a/objects/client.c b/objects/client.c index 1f08fc88..79dce8fd 100644 --- a/objects/client.c +++ b/objects/client.c @@ -240,7 +240,6 @@ void client_unfocus_update(client_t *c) { globalconf.screens.tab[c->phys_screen].client_focus = NULL; - ewmh_update_net_active_window(c->phys_screen); luaA_object_push(globalconf.L, c); luaA_class_emit_signal(globalconf.L, &client_class, "unfocus", 1); @@ -380,8 +379,6 @@ client_focus_update(client_t *c) /* according to EWMH, we have to remove the urgent state from a client */ client_set_urgent(globalconf.L, -1, false); - ewmh_update_net_active_window(c->phys_screen); - luaA_class_emit_signal(globalconf.L, &client_class, "focus", 1); }