From b2e2959be815401bba2f59aa3b027300b863b8f7 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Tue, 1 Mar 2011 17:52:00 +0100 Subject: [PATCH] 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 --- lib/awful/placement.lua.in | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/awful/placement.lua.in b/lib/awful/placement.lua.in index 38f39e06..c30327fb 100644 --- a/lib/awful/placement.lua.in +++ b/lib/awful/placement.lua.in @@ -145,10 +145,19 @@ function no_overlap(c) and r.width * r.height > new.width * new.height then found = true 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 - -- 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 if not found then for i, r in ipairs(areas) do