From 5c068602d52a50b817d3981ca42efd615435c719 Mon Sep 17 00:00:00 2001 From: Rosty Hnatyshyn Date: Mon, 12 Oct 2026 10:04:13 -0700 Subject: [PATCH] fix moving left / right --- hypr/hyprland.lua | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/hypr/hyprland.lua b/hypr/hyprland.lua index ed28acc..b9a3c6d 100644 --- a/hypr/hyprland.lua +++ b/hypr/hyprland.lua @@ -174,9 +174,25 @@ end ) hl.bind(mainMod .. " + SHIFT + Q", hl.dsp.window.close()) --- change focus -hl.bind(mainMod .. " + LEFT", hl.dsp.focus({ direction = "left" })) -hl.bind(mainMod .. " + RIGHT", hl.dsp.focus({ direction = "right" })) + +-- move focus left / right. Using the layout or geometric method has quirks that this does nicely. +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 .. " + DOWN", hl.dsp.focus({ direction = "down" }))