From 04dee81d135bf630368bd2c5aef126b3f7b35cd1 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 6 Mar 2014 17:47:55 +0100 Subject: [PATCH] client: Add request::activate signal (FS#848) When we receive a _NET_ACTIVE_WINDOW request on the root window, we used to just focus and raise the window. This didn't do much for clients which are on non-selected tags. Thus, this commit makes awesome emit request::activate on the client instead. This is used in awful.ewmh to implement the old behavior again, but with additionally marking the client as urgent if it isn't visible. People who don't like this behavior can use client.disconnect_signal to disable this behavior again. To make this really possible, awful.ewmh becomes a "non-nil" module. Signed-off-by: Uli Schlachter --- ewmh.c | 5 +++-- lib/awful/ewmh.lua.in | 14 ++++++++++++++ objects/client.c | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ewmh.c b/ewmh.c index 7ffd3abf2..398322105 100644 --- a/ewmh.c +++ b/ewmh.c @@ -401,8 +401,9 @@ ewmh_process_client_message(xcb_client_message_event_t *ev) else if(ev->type == _NET_ACTIVE_WINDOW) { if((c = client_getbywin(ev->window))) { - client_focus(c); - client_raise(c); + luaA_object_push(globalconf.L, c); + luaA_object_emit_signal(globalconf.L, -1, "request::activate", 0); + lua_pop(globalconf.L, 1); } } diff --git a/lib/awful/ewmh.lua.in b/lib/awful/ewmh.lua.in index a99add151..6d9bd93c3 100644 --- a/lib/awful/ewmh.lua.in +++ b/lib/awful/ewmh.lua.in @@ -12,6 +12,7 @@ local math = math --- Implements EWMH requests handling. -- awful.ewmh +local ewmh = {} local data = setmetatable({}, { __mode = 'k' }) @@ -131,10 +132,23 @@ local function border_change(window) end end +-- Activate a window +function ewmh.activate(c) + if c:isvisible() then + client.focus = c + c:raise() + else + c.urgent = true + end +end + +client.connect_signal("request::activate", ewmh.activate) client.connect_signal("request::maximized_horizontal", maximized_horizontal) client.connect_signal("request::maximized_vertical", maximized_vertical) client.connect_signal("request::fullscreen", fullscreen) client.connect_signal("property::screen", screen_change) client.connect_signal("property::border_width", border_change) +return ewmh + -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/objects/client.c b/objects/client.c index 89507da7e..d77606f38 100644 --- a/objects/client.c +++ b/objects/client.c @@ -2401,6 +2401,7 @@ client_class_setup(lua_State *L) signal_add(&client_class.signals, "property::window"); signal_add(&client_class.signals, "property::x"); signal_add(&client_class.signals, "property::y"); + signal_add(&client_class.signals, "request::activate"); signal_add(&client_class.signals, "request::fullscreen"); signal_add(&client_class.signals, "request::maximized_horizontal"); signal_add(&client_class.signals, "request::maximized_vertical");