From 79cd569c33e8c697b76e8d1a7f5a1836abb38b84 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 31 Jul 2012 20:43:21 +0200 Subject: [PATCH] signals: better handling of sloppy focus and mouse follows focus It may happend that a client is focused on `mouse::enter` without the `focus` event being fired. Therefore, the next client to be focused will not get the mouse on its top left corner because we think that the focus comes from sloppy focus. We circumvent this by: 1. giving sloppy focus only if we don't have focus 2. keeping track of the client getting the focus through sloppy focus and checking it if we get the same client on focus event --- rc/signals.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/rc/signals.lua b/rc/signals.lua index ae3b7ae..05bdb24 100644 --- a/rc/signals.lua +++ b/rc/signals.lua @@ -20,13 +20,19 @@ client.add_signal("manage", -- Enable sloppy focus c:add_signal("mouse::enter", function(c) - if ((awful.layout.get(c.screen) ~= awful.layout.suit.magnifier or awful.client.getmaster(c.screen) == c) + -- If magnifier suit, only give sloppy focus to master window + if ((awful.layout.get(c.screen) ~= awful.layout.suit.magnifier or + awful.client.getmaster(c.screen) == c) + -- Don't give focus to a client already having focus + and client.focus ~= c + -- Don't give focus to a window that does not want focus and awful.client.focus.filter(c)) then - focus_from_mouse = true + focus_from_mouse = c client.focus = c end end) + -- If a window change its geometry, track it with the mouse c:add_signal("property::geometry", function() if client.focus == c then @@ -56,7 +62,7 @@ client.add_signal("focus", function(c) c.border_color = beautiful.border_focus c.opacity = 1 - if not focus_from_mouse then + if focus_from_mouse ~= c then mouse_follow_focus(c) end focus_from_mouse = false