Merge pull request #1825 from psychon/magnifier-relayout

Re-arrange the magnifier layout on focus changes
This commit is contained in:
Emmanuel Lepage Vallée 2017-06-09 05:24:38 -04:00 committed by GitHub
commit 7c44b05deb
3 changed files with 71 additions and 0 deletions

View File

@ -269,6 +269,12 @@ capi.tag.connect_signal("tagged", arrange_tag)
capi.screen.connect_signal("property::workarea", layout.arrange) capi.screen.connect_signal("property::workarea", layout.arrange)
capi.screen.connect_signal("padding", layout.arrange) capi.screen.connect_signal("padding", layout.arrange)
capi.client.connect_signal("focus", function(c)
local screen = c.screen
if layout.get(screen).need_focus_update then
layout.arrange(screen)
end
end)
capi.client.connect_signal("raised", function(c) layout.arrange(c.screen) end) capi.client.connect_signal("raised", function(c) layout.arrange(c.screen) end)
capi.client.connect_signal("lowered", function(c) layout.arrange(c.screen) end) capi.client.connect_signal("lowered", function(c) layout.arrange(c.screen) end)
capi.client.connect_signal("list", function() capi.client.connect_signal("list", function()

View File

@ -146,6 +146,10 @@ end
magnifier.name = "magnifier" magnifier.name = "magnifier"
-- This layout handles the currently focused client specially and needs to be
-- called again when the focus changes.
magnifier.need_focus_update = true
return magnifier return magnifier
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -29,6 +29,67 @@ local steps = {
} }
-- Test if layouts are called
do
local c1, c2
local arrange_expected = false
local fake_layout = {
arrange = function()
assert(arrange_expected)
arrange_expected = false
end,
name = "fake",
}
table.insert(steps, function()
c1, c2 = client.get()[1], client.get()[2]
client.focus = c1
arrange_expected = true
awful.layout.set(fake_layout)
return true
end)
table.insert(steps, function()
assert(arrange_expected == false)
arrange_expected = false
client.focus = c2
return true
end)
table.insert(steps, function()
-- This sync is needed to avoid a race: Consider the code
-- client.focus = c2
-- gears.timer.start_new(0, function()
-- client.focus = c1
-- end)
-- The C code would focus c2, but Lua would then change the focus to c1
-- before the X11 server acknowledged the focus change (FocusIn event).
-- Thus, when that event comes in, the C code things that c1 currently
-- has the focus and thus would do c2:emit_signal("focus"). Then, when
-- the FocusIn event for c1 comes, it would do c1:emit_signal("focus").
awesome.sync()
return true
end)
table.insert(steps, function()
assert(arrange_expected == false)
arrange_expected = true
fake_layout.need_focus_update = true
client.focus = c1
return true
end)
table.insert(steps, function()
assert(arrange_expected == false)
awful.layout.set(awful.layout.suit.floating)
return true
end)
end
local function next_layout() local function next_layout()
awful.layout.inc(1) awful.layout.inc(1)