From dd3658bb1c3ce60459f4a824339dbeab45d9737c Mon Sep 17 00:00:00 2001 From: Anatolii Aniskovych Date: Wed, 16 May 2018 23:37:37 +0300 Subject: [PATCH 1/3] awful.placement: Ignore fullscreen/maximized clients in no_overlap() Fullscreen/maximized client takes full workspace area making free space detection logic useless. --- lib/awful/placement.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/awful/placement.lua b/lib/awful/placement.lua index db4dd87f..d0da647c 100644 --- a/lib/awful/placement.lua +++ b/lib/awful/placement.lua @@ -874,7 +874,10 @@ function placement.no_overlap(c, args) local curlay = layout.get() local areas = { screen.workarea } for _, cl in pairs(cls) do - if cl ~= c and cl.type ~= "desktop" and (cl.floating or curlay == layout.suit.floating) then + if cl ~= c + and cl.type ~= "desktop" + and (cl.floating or curlay == layout.suit.floating) + and not (cl.maximized or cl.fullscreen) then areas = grect.area_remove(areas, area_common(cl)) end end From da418b56ab2f93b45c58317c611bffe74198e9df Mon Sep 17 00:00:00 2001 From: Anatolii Aniskovych Date: Fri, 18 May 2018 23:44:35 +0300 Subject: [PATCH 2/3] gears.geometry: Make area_intersect_area() public --- lib/gears/geometry.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gears/geometry.lua b/lib/gears/geometry.lua index 70628888..876fb1e6 100644 --- a/lib/gears/geometry.lua +++ b/lib/gears/geometry.lua @@ -151,7 +151,7 @@ end -- @param a The area. -- @param b The other area. -- @return True if they intersect, false otherwise. -local function area_intersect_area(a, b) +function gears.geometry.rectangle.area_intersect_area(a, b) return (b.x < a.x + a.width and b.x + b.width > a.x and b.y < a.y + a.height @@ -194,7 +194,7 @@ end function gears.geometry.rectangle.area_remove(areas, elem) for i = #areas, 1, -1 do -- Check if the 'elem' intersect - if area_intersect_area(areas[i], elem) then + if gears.geometry.rectangle.area_intersect_area(areas[i], elem) then -- It does? remove it local r = table.remove(areas, i) local inter = gears.geometry.rectangle.get_intersection(r, elem) From cbfe8274be63a7b5e8a0b1a60da6a333b1d8eac1 Mon Sep 17 00:00:00 2001 From: Anatolii Aniskovych Date: Fri, 18 May 2018 23:55:39 +0300 Subject: [PATCH 3/3] awful.placement: Keep client position when no space available in no_overlap() (#2139) --- lib/awful/placement.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/awful/placement.lua b/lib/awful/placement.lua index d0da647c..273bbbf7 100644 --- a/lib/awful/placement.lua +++ b/lib/awful/placement.lua @@ -908,13 +908,18 @@ function placement.no_overlap(c, args) -- This makes sure to have the whole screen's area in case it has been -- removed. if not found then - if #areas == 0 then - areas = { screen.workarea } - end - for _, r in ipairs(areas) do - if r.width * r.height > new.width * new.height then - new = r + if #areas > 0 then + for _, r in ipairs(areas) do + if r.width * r.height > new.width * new.height then + new = r + end end + elseif grect.area_intersect_area(geometry, screen.workarea) then + new.x = geometry.x + new.y = geometry.y + else + new.x = screen.workarea.x + new.y = screen.workarea.y end end