fix moving left / right

This commit is contained in:
2026-10-12 10:04:13 -07:00
parent 3c7c3a37dd
commit 5c068602d5
+19 -3
View File
@@ -174,9 +174,25 @@ end
) )
hl.bind(mainMod .. " + SHIFT + Q", hl.dsp.window.close()) hl.bind(mainMod .. " + SHIFT + Q", hl.dsp.window.close())
-- change focus
hl.bind(mainMod .. " + LEFT", hl.dsp.focus({ direction = "left" })) -- move focus left / right. Using the layout or geometric method has quirks that this does nicely.
hl.bind(mainMod .. " + RIGHT", hl.dsp.focus({ direction = "right" })) local function focus_horizontal(dir) -- "l" or "r"
local direction = (dir == "l") and "left" or "right"
return function()
local before = hl.get_active_window()
hl.dispatch(hl.dsp.layout("focus " .. dir))
local after = hl.get_active_window()
local same = (before == nil and after == nil)
or (before and after and before.address == after.address)
if same then
hl.dispatch(hl.dsp.focus({ direction = direction }))
end
end
end
hl.bind(mainMod .. " + LEFT", focus_horizontal("l"))
hl.bind(mainMod .. " + RIGHT", focus_horizontal("r"))
hl.bind(mainMod .. " + UP", hl.dsp.focus({ direction = "up" })) hl.bind(mainMod .. " + UP", hl.dsp.focus({ direction = "up" }))
hl.bind(mainMod .. " + DOWN", hl.dsp.focus({ direction = "down" })) hl.bind(mainMod .. " + DOWN", hl.dsp.focus({ direction = "down" }))