From 5e95658fa97fa032cd13e0143b2ee20a46cac9aa Mon Sep 17 00:00:00 2001 From: Lysec Date: Tue, 17 Mar 2026 11:23:11 +0100 Subject: [PATCH] fix(hyprland): correct focusedWindowIndex after sorting window list --- Services/Compositor/HyprlandService.qml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Services/Compositor/HyprlandService.qml b/Services/Compositor/HyprlandService.qml index acb654058..42836a194 100644 --- a/Services/Compositor/HyprlandService.qml +++ b/Services/Compositor/HyprlandService.qml @@ -246,7 +246,7 @@ Item { } const hlToplevels = Hyprland.toplevels.values; - let newFocusedIndex = -1; + let focusedWindowId = null; // Get active workspaces to filter focus const activeWorkspaceIds = {}; @@ -288,13 +288,24 @@ Item { windowCache[normalized.id] = normalized; if (normalized.isFocused) { - newFocusedIndex = windowsList.length - 1; + focusedWindowId = normalized.id; } } } windows = toSortedWindowList(windowsList); + // Resolve focused index from sorted list (order changes after sort) + let newFocusedIndex = -1; + if (focusedWindowId) { + for (let k = 0; k < windows.length; k++) { + if (windows[k].id === focusedWindowId) { + newFocusedIndex = k; + break; + } + } + } + if (newFocusedIndex !== focusedWindowIndex) { focusedWindowIndex = newFocusedIndex; activeWindowChanged();