Add a placement to try empty area only. Minor bug fixing.

This commit is contained in:
Xinhao Yuan 2021-02-28 13:04:06 -05:00
parent 8f3261d9da
commit f3c5535aa7
2 changed files with 15 additions and 4 deletions

View File

@ -97,7 +97,7 @@ For `new_placement_cb` the arguments are:
The callback places the new client by changing its geometry and client data. The callback places the new client by changing its geometry and client data.
Note that after the callback machi will validate the geometry and fit into the areas. Note that after the callback machi will validate the geometry and fit into the areas.
So no need to set the `.area`, `.lu`, or `.rd` field of the client data in the callback. So no need to set the `.area`, `.lu`, or `.rd` field of the client data in the callback.
See `placement.empty_then_fair` in `layout.lua` for an example. See `placement.empty` in `layout.lua` for an example.
## The layout editor and commands ## The layout editor and commands

View File

@ -493,7 +493,7 @@ end
module.placement = {} module.placement = {}
function module.placement.empty_then_fair(c, instance, areas, geometry) local function empty_then_maybe_fair(c, instance, areas, geometry, do_fair)
local area_client_count = {} local area_client_count = {}
for _, oc in ipairs(c.screen.tiled_clients) do for _, oc in ipairs(c.screen.tiled_clients) do
local cd = instance.client_data[oc] local cd = instance.client_data[oc]
@ -521,8 +521,11 @@ function module.placement.empty_then_fair(c, instance, areas, geometry)
end end
end end
end end
instance.client_data[c].lu = choice if choice_client_count > 1 and not do_fair then
instance.client_data[c].rd = choice return
end
instance.client_data[c].lu = nil
instance.client_data[c].rd = nil
instance.client_data[c].area = choice instance.client_data[c].area = choice
geometry.x = areas[choice].x geometry.x = areas[choice].x
geometry.y = areas[choice].y geometry.y = areas[choice].y
@ -530,4 +533,12 @@ function module.placement.empty_then_fair(c, instance, areas, geometry)
geometry.height = areas[choice].height geometry.height = areas[choice].height
end end
function module.placement.empty(c, instance, areas, geometry)
empty_then_maybe_fair(c, instance, areas, geometry, false)
end
function module.placement.empty_then_fair(c, instance, areas, geometry)
empty_then_maybe_fair(c, instance, areas, geometry, true)
end
return module return module