Why spend time creating an account on flyspray that you'll probably
only use once when you can send a patch directly... right? Now I just
hope that the mailing list doesn't require subscribing... ;-)

Bug report: awful.autofocus doesn't work properly if windows on other
screens are visible.
Steps to reproduce:
- open terminals A and B on screen 1
- open (and focus) terminal C on screen 2
- close terminal C
- (there's no other window on screen 2, so client.focus is nil now)
- move mouse pointer between A and B: they have sloppy keyboard focus,
but neither shows as focused on tasklist, both have unfocused borders
etc. (this is X11's default behavior and so it's used when
client.focus is nil)

The patch modifies awful.autofocus to try all screens, not just the
active one (though that one goes first). It should apply cleanly to
3.4, master and next.

The patch itself is in an attachment because gmail tends to meddle
with formatting. If you think of something to change or improve,
please tell me. (As I mentioned, I'm not subscribed to the ML, so Cc
me.)

Tomi Belan
From f6167b5434cbfc841ef3b5a0de8dadc6c50ec827 Mon Sep 17 00:00:00 2001
From: Tomi Belan <[email protected]>
Date: Thu, 12 Nov 2009 17:13:57 +0100
Subject: [PATCH] awful.autofocus: fix multiple screens autofocus

There might be multiple screens with visible windows. When closing the
last window of the current screen, try to focus them as well.

If no window has focus and yet some windows are visible (e.g. on another
screen), awesome misbehaves: it uses sloppy keyboard focus (as is the X11
default), but doesn't refresh their border colors or tasklists etc.

Signed-off-by: Tomi Belan <[email protected]>
---
 lib/awful/autofocus.lua.in |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/lib/awful/autofocus.lua.in b/lib/awful/autofocus.lua.in
index 923fabf..bed228a 100644
--- a/lib/awful/autofocus.lua.in
+++ b/lib/awful/autofocus.lua.in
@@ -20,6 +20,13 @@ local function check_focus(obj)
         local c = aclient.focus.history.get(obj.screen, 0)
         if c then client.focus = c end
     end
+    -- If we didn't find a client, try other screens.
+    if not client.focus or not client.focus:isvisible() then
+        for i = 1, screen.count() do
+            local c = aclient.focus.history.get(i, 0)
+            if c and c:isvisible() then client.focus = c; return end
+        end
+    end
 end
 
 atag.attached_add_signal(nil, "property::selected", check_focus)
-- 
1.6.5.2

Reply via email to