layout.arrange: delay a call per screen

This is a followup / fix for 7410646, which did not handle multiple
arrange calls to different screens per main lopp.
This commit is contained in:
Daniel Hahler 2015-02-15 00:46:38 +01:00
parent 72659a5ebb
commit 17776051ec
1 changed files with 8 additions and 2 deletions

View File

@ -42,6 +42,8 @@ layout.layouts = {
-- This is a special lock used by the arrange function.
-- This avoids recurring call by emitted signals.
local arrange_lock = false
-- Delay one arrange call per screen.
local delayed_arrange = {}
--- Get the current layout.
-- @param screen The screen number.
@ -95,10 +97,13 @@ end
--- Arrange a screen using its current layout.
-- @param screen The screen to arrange.
function layout.arrange(screen)
if delayed_arrange[screen] then return end
delayed_arrange[screen] = true
timer.delayed_call(function()
if arrange_lock then return end
arrange_lock = true
timer.delayed_call(function()
local p = {}
p.workarea = capi.screen[screen].workarea
-- Handle padding
@ -116,6 +121,7 @@ function layout.arrange(screen)
capi.screen[screen]:emit_signal("arrange")
arrange_lock = false
delayed_arrange[screen] = nil
end)
end