Add a placement to try empty area only. Minor bug fixing.
This commit is contained in:
parent
8f3261d9da
commit
f3c5535aa7
|
@ -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
|
||||||
|
|
||||||
|
|
17
layout.lua
17
layout.lua
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue