From 88aff03005912049574e5b7f52e56f8362f6084d Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 27 Jan 2011 18:10:39 +0100 Subject: [PATCH] Don't focus a different screen on unmanage (FS#850) When some client on the left monitor was closed while client.focus is on the right monitor (e.g. 'sleep 5 ; exit' in a terminal), awful.autofocus would shift the input focus to whatever client happened to be next in the focus history on the left monitor. Fix this by only ever moving the input focus between screens when a tag is selected, not when some client does its magic. Signed-off-by: Uli Schlachter --- lib/awful/autofocus.lua.in | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/awful/autofocus.lua.in b/lib/awful/autofocus.lua.in index 486c7f9c..11a3cbff 100644 --- a/lib/awful/autofocus.lua.in +++ b/lib/awful/autofocus.lua.in @@ -13,19 +13,28 @@ local atag = require("awful.tag") -- on event such as tag switching, client unmanaging, etc. module("awful.autofocus") --- Give focus on tag selection change. +-- Give focus when clients appear/disappear. -- @param obj An object that should have a .screen property. local function check_focus(obj) + -- When no visible client has the focus... if not client.focus or not client.focus:isvisible() then local c = aclient.focus.history.get(obj.screen, 0) if c then client.focus = c end - elseif client.focus and client.focus.screen ~= obj.screen then - local c = aclient.focus.history.get(obj.screen, 0) - if c then client.focus = c end end end -atag.attached_connect_signal(nil, "property::selected", check_focus) +-- Give focus on tag selection change. +-- @param obj An object that should have a .screen property. +local function check_focus_screen(obj) + check_focus(obj) + if client.focus and client.focus.screen ~= obj.screen then + local c = nil + c = aclient.focus.history.get(obj.screen, 0) + if c then client.focus = c end + end +end + +atag.attached_connect_signal(nil, "property::selected", check_focus_screen) client.connect_signal("unmanage", check_focus) client.connect_signal("untagged", check_focus) client.connect_signal("property::hidden", check_focus)