Make tiling shortcuts practical in tiled mode
This commit is contained in:
parent
755eb1acc4
commit
2e0dc4f268
@ -1,6 +1,7 @@
|
|||||||
-- Offers window tiling functionnality
|
-- Offers window tiling functionnality
|
||||||
|
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
|
local grect = require("gears.geometry").rectangle
|
||||||
|
|
||||||
-- Placements
|
-- Placements
|
||||||
local leftTileGeometry = awful.placement.scale
|
local leftTileGeometry = awful.placement.scale
|
||||||
@ -52,6 +53,26 @@ local screenRight = function(geo)
|
|||||||
end
|
end
|
||||||
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)
|
client.connect_signal("manage", function (c)
|
||||||
if awesome.startup
|
if awesome.startup
|
||||||
and not c.size_hints.user_position
|
and not c.size_hints.user_position
|
||||||
@ -68,22 +89,33 @@ end)
|
|||||||
return {
|
return {
|
||||||
key = {
|
key = {
|
||||||
tileRight = function (c)
|
tileRight = function (c)
|
||||||
c.maximized = true
|
if c.maximized then
|
||||||
|
c:raise()
|
||||||
if not applyTile(c, rightTileGeometry) then
|
if not applyTile(c, rightTileGeometry) then
|
||||||
screenRight(leftTileGeometry)(c)
|
screenRight(leftTileGeometry)(c)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
swapClient(c, 'right')
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
tileLeft = function (c)
|
tileLeft = function (c)
|
||||||
c.maximized = true
|
if c.maximized then
|
||||||
|
c:raise()
|
||||||
if not applyTile(c, leftTileGeometry) then
|
if not applyTile(c, leftTileGeometry) then
|
||||||
screenLeft(rightTileGeometry)(c)
|
screenLeft(rightTileGeometry)(c)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
swapClient(c, 'left')
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
screenLeft = screenLeft(maximizedTileGeometry),
|
screenLeft = screenLeft(maximizedTileGeometry),
|
||||||
screenRight = screenRight(maximizedTileGeometry),
|
screenRight = screenRight(maximizedTileGeometry),
|
||||||
toggleMaximized = function (c)
|
toggleMaximized = function (c)
|
||||||
if not c.maximized then
|
if not c.maximized then
|
||||||
|
if not swapClient(c, 'up') then
|
||||||
c.maximized = true
|
c.maximized = true
|
||||||
|
c:raise()
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if not applyTile(c, maximizedTileGeometry) then
|
if not applyTile(c, maximizedTileGeometry) then
|
||||||
c.maximized = false
|
c.maximized = false
|
||||||
@ -91,7 +123,9 @@ return {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
minimize = function(c)
|
minimize = function(c)
|
||||||
|
if c.maximized or not swapClient(c, 'down') then
|
||||||
c.minimized = true
|
c.minimized = true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user