awful.layout: listen to geometry signal and lock arrange (FS#625)

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-09-18 11:31:49 +02:00
parent 91b4611c94
commit 9c21ce8907
1 changed files with 8 additions and 0 deletions

View File

@ -22,6 +22,10 @@ local client = require("awful.client")
--- Layout module for awful --- Layout module for awful
module("awful.layout") module("awful.layout")
-- This is a special lock used by the arrange function.
-- This avoids recurring call by emitted signals.
local arrange_lock = false
--- Get the current layout. --- Get the current layout.
-- @param screen The screen number. -- @param screen The screen number.
-- @return The layout function. -- @return The layout function.
@ -62,6 +66,8 @@ end
--- Arrange a screen using its current layout. --- Arrange a screen using its current layout.
-- @param screen The screen to arrange. -- @param screen The screen to arrange.
function arrange(screen) function arrange(screen)
if arrange_lock then return end
arrange_lock = true
local p = {} local p = {}
p.workarea = capi.screen[screen].workarea p.workarea = capi.screen[screen].workarea
-- Handle padding -- Handle padding
@ -76,6 +82,7 @@ function arrange(screen)
p.clients = client.tiled(screen) p.clients = client.tiled(screen)
p.screen = screen p.screen = screen
get(screen).arrange(p) get(screen).arrange(p)
arrange_lock = false
end end
--- Get the current layout name. --- Get the current layout name.
@ -100,6 +107,7 @@ capi.client.add_signal("new", function(c)
c:add_signal("property::hidden", arrange_prop) c:add_signal("property::hidden", arrange_prop)
c:add_signal("property::titlebar", arrange_prop) c:add_signal("property::titlebar", arrange_prop)
c:add_signal("property::floating", arrange_prop) c:add_signal("property::floating", arrange_prop)
c:add_signal("property::geometry", arrange_prop)
-- If prop is screen, we do not know what was the previous screen, so -- If prop is screen, we do not know what was the previous screen, so
-- let's arrange all screens :-( -- let's arrange all screens :-(
c:add_signal("property::screen", function(c) c:add_signal("property::screen", function(c)