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 <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2014-03-06 17:47:55 +01:00
parent 2f3998639e
commit 04dee81d13
3 changed files with 18 additions and 2 deletions

5
ewmh.c
View File

@ -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);
}
}

View File

@ -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

View File

@ -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");