Update window tiling

This commit is contained in:
Lukas Cech 2025-01-20 15:07:33 +01:00
parent edac0da023
commit 9fd1171c2c

View File

@ -10,7 +10,6 @@ end)
local wm = {
sizes = { 1 / 2, 2 / 3, 1 / 3 },
fullScreenSizes = { 1, 3 / 4, 1 / 2 },
}
function wm:_nextStep(dim, offs, cb)
@ -19,7 +18,6 @@ function wm:_nextStep(dim, offs, cb)
local oppDim = dim == "w" and "h" or "w"
local oppAxis = dim == "w" and "y" or "x"
local win = hs.window.frontmostWindow()
local id = win:id()
local screen = win:screen()
local cell = hs.grid.get(win, screen)
@ -45,31 +43,17 @@ function wm:_nextStep(dim, offs, cb)
end
end
function wm:_nextFullScreenStep()
function wm:_fullscreen()
if hs.window.focusedWindow() then
local win = hs.window.frontmostWindow()
local id = win:id()
local screen = win:screen()
local cell = hs.grid.get(win, screen)
local nextSize = self.fullScreenSizes[1]
for i = 1, #self.fullScreenSizes do
if
cell.w == self.GRID.w * self.fullScreenSizes[i]
and cell.h == self.GRID.h * self.fullScreenSizes[i]
and cell.x == (self.GRID.w - self.GRID.w * self.fullScreenSizes[i]) / 2
and cell.y == (self.GRID.h - self.GRID.h * self.fullScreenSizes[i]) / 2
then
nextSize = self.fullScreenSizes[(i % #self.fullScreenSizes) + 1]
break
end
end
cell.w = self.GRID.w * nextSize
cell.h = self.GRID.h * nextSize
cell.x = (self.GRID.w - self.GRID.w * nextSize) / 2
cell.y = (self.GRID.h - self.GRID.h * nextSize) / 2
cell.x = 0
cell.y = 0
cell.w = self.GRID.w
cell.h = self.GRID.h
hs.grid.set(win, cell, screen)
end
@ -163,7 +147,7 @@ function wm:init()
end)
hs.hotkey.bind(hyper, "m", function()
self:_nextFullScreenStep()
self:_fullscreen()
end)
end