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 <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2011-01-27 18:10:39 +01:00
parent 514fd796f3
commit 88aff03005
1 changed files with 14 additions and 5 deletions

View File

@ -13,19 +13,28 @@ local atag = require("awful.tag")
-- on event such as tag switching, client unmanaging, etc. -- on event such as tag switching, client unmanaging, etc.
module("awful.autofocus") 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. -- @param obj An object that should have a .screen property.
local function check_focus(obj) local function check_focus(obj)
-- When no visible client has the focus...
if not client.focus or not client.focus:isvisible() then if not client.focus or not client.focus:isvisible() then
local c = aclient.focus.history.get(obj.screen, 0) local c = aclient.focus.history.get(obj.screen, 0)
if c then client.focus = c end 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
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("unmanage", check_focus)
client.connect_signal("untagged", check_focus) client.connect_signal("untagged", check_focus)
client.connect_signal("property::hidden", check_focus) client.connect_signal("property::hidden", check_focus)