Merge pull request #2266 from ZipFile/fix-no_overlap

Improve no_overlap placement
This commit is contained in:
Emmanuel Lepage Vallée 2018-06-26 10:05:49 -04:00 committed by GitHub
commit 25adaae594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 9 deletions

View File

@ -874,7 +874,10 @@ function placement.no_overlap(c, args)
local curlay = layout.get() local curlay = layout.get()
local areas = { screen.workarea } local areas = { screen.workarea }
for _, cl in pairs(cls) do 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)) areas = grect.area_remove(areas, area_common(cl))
end end
end end
@ -905,14 +908,19 @@ function placement.no_overlap(c, args)
-- This makes sure to have the whole screen's area in case it has been -- This makes sure to have the whole screen's area in case it has been
-- removed. -- removed.
if not found then if not found then
if #areas == 0 then if #areas > 0 then
areas = { screen.workarea }
end
for _, r in ipairs(areas) do for _, r in ipairs(areas) do
if r.width * r.height > new.width * new.height then if r.width * r.height > new.width * new.height then
new = r new = r
end end
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 end
-- Restore height and width -- Restore height and width

View File

@ -151,7 +151,7 @@ end
-- @param a The area. -- @param a The area.
-- @param b The other area. -- @param b The other area.
-- @return True if they intersect, false otherwise. -- @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 return (b.x < a.x + a.width
and b.x + b.width > a.x and b.x + b.width > a.x
and b.y < a.y + a.height and b.y < a.y + a.height
@ -194,7 +194,7 @@ end
function gears.geometry.rectangle.area_remove(areas, elem) function gears.geometry.rectangle.area_remove(areas, elem)
for i = #areas, 1, -1 do for i = #areas, 1, -1 do
-- Check if the 'elem' intersect -- 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 -- It does? remove it
local r = table.remove(areas, i) local r = table.remove(areas, i)
local inter = gears.geometry.rectangle.get_intersection(r, elem) local inter = gears.geometry.rectangle.get_intersection(r, elem)