Make tiling shortcuts practical in tiled mode
This commit is contained in:
parent
755eb1acc4
commit
2e0dc4f268
@ -1,6 +1,7 @@
|
||||
-- Offers window tiling functionnality
|
||||
|
||||
local awful = require("awful")
|
||||
local grect = require("gears.geometry").rectangle
|
||||
|
||||
-- Placements
|
||||
local leftTileGeometry = awful.placement.scale
|
||||
@ -52,6 +53,26 @@ local screenRight = function(geo)
|
||||
end
|
||||
end
|
||||
|
||||
local swapClient = function(c, dir, stacked)
|
||||
local sel = c or capi.client.focus
|
||||
if sel then
|
||||
local cltbl = awful.client.visible(sel.screen, stacked)
|
||||
local geomtbl = {}
|
||||
for i,cl in ipairs(cltbl) do
|
||||
geomtbl[i] = cl:geometry()
|
||||
end
|
||||
local target = grect.get_in_direction(dir, geomtbl, sel:geometry())
|
||||
|
||||
-- If we found a client to swap with, then go for it
|
||||
if target then
|
||||
cltbl[target]:swap(sel)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
client.connect_signal("manage", function (c)
|
||||
if awesome.startup
|
||||
and not c.size_hints.user_position
|
||||
@ -68,30 +89,43 @@ end)
|
||||
return {
|
||||
key = {
|
||||
tileRight = function (c)
|
||||
c.maximized = true
|
||||
if not applyTile(c, rightTileGeometry) then
|
||||
screenRight(leftTileGeometry)(c)
|
||||
if c.maximized then
|
||||
c:raise()
|
||||
if not applyTile(c, rightTileGeometry) then
|
||||
screenRight(leftTileGeometry)(c)
|
||||
end
|
||||
else
|
||||
swapClient(c, 'right')
|
||||
end
|
||||
end,
|
||||
tileLeft = function (c)
|
||||
c.maximized = true
|
||||
if not applyTile(c, leftTileGeometry) then
|
||||
screenLeft(rightTileGeometry)(c)
|
||||
if c.maximized then
|
||||
c:raise()
|
||||
if not applyTile(c, leftTileGeometry) then
|
||||
screenLeft(rightTileGeometry)(c)
|
||||
end
|
||||
else
|
||||
swapClient(c, 'left')
|
||||
end
|
||||
end,
|
||||
screenLeft = screenLeft(maximizedTileGeometry),
|
||||
screenRight = screenRight(maximizedTileGeometry),
|
||||
toggleMaximized = function (c)
|
||||
if not c.maximized then
|
||||
c.maximized = true
|
||||
if not swapClient(c, 'up') then
|
||||
c.maximized = true
|
||||
c:raise()
|
||||
end
|
||||
else
|
||||
if not applyTile(c, maximizedTileGeometry) then
|
||||
c.maximized = false
|
||||
end
|
||||
end
|
||||
end,
|
||||
minimize = function(c)
|
||||
c.minimized = true
|
||||
minimize = function(c)
|
||||
if c.maximized or not swapClient(c, 'down') then
|
||||
c.minimized = true
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user