awful.placement.no_overlap: Honor original position

awful.placement.no_overlap caused clients on an otherwise empty desktop to stich
to the top-left corner of the screen because it always preferred the top-left
corner of the available space.

This commit doesn't change the way in which the available area is computed, but
instead this now tries to keep the client at its original position if that is
available.

This fixes cases where calling awful.placement.no_overlap as a callback from an
awful.rule rule didn't work because the manage signal in the default config
later overrode that via calling awful.placement.no_overlap.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2011-03-01 17:52:00 +01:00
parent af6915fda2
commit 00273528b0
1 changed files with 10 additions and 1 deletions

View File

@ -145,10 +145,19 @@ function no_overlap(c)
and r.width * r.height > new.width * new.height then and r.width * r.height > new.width * new.height then
found = true found = true
new = r new = r
-- Check if the client's current position is available
-- and prefer that one (why move it around pointlessly?)
if geometry.x >= r.x
and geometry.y >= r.y
and geometry.x + geometry.width <= r.x + r.width
and geometry.y + geometry.height <= r.y + r.height then
new.x = geometry.x
new.y = geometry.y
end
end end
end end
-- We did not foudn an area with enough space for our size: -- We did not find an area with enough space for our size:
-- just take the biggest available one and go in -- just take the biggest available one and go in
if not found then if not found then
for i, r in ipairs(areas) do for i, r in ipairs(areas) do