From 42183b308e01a51b8f9e3ed7264fa5c80d9f06df Mon Sep 17 00:00:00 2001 From: bbedward Date: Mon, 21 Jul 2025 20:52:58 -0400 Subject: [PATCH] Fix focused window --- Services/FocusedWindowService.qml | 43 +++---------------------------- 1 file changed, 3 insertions(+), 40 deletions(-) diff --git a/Services/FocusedWindowService.qml b/Services/FocusedWindowService.qml index 5165d770..a22940fd 100644 --- a/Services/FocusedWindowService.qml +++ b/Services/FocusedWindowService.qml @@ -21,13 +21,8 @@ Singleton { return; } - const focusedWindowId = NiriWorkspaceService.focusedWindowId; - if (!focusedWindowId) { - clearFocusedWindow(); - return; - } + let focusedWindow = NiriWorkspaceService.windows.find(w => w.is_focused); - const focusedWindow = NiriWorkspaceService.windows.find(w => w.id === focusedWindowId); if (focusedWindow) { root.focusedAppId = focusedWindow.app_id || ""; root.focusedWindowTitle = focusedWindow.title || ""; @@ -38,10 +33,6 @@ Singleton { } } - function loadInitialFocusedWindow() { - if (root.niriAvailable) - focusedWindowQuery.running = true; - } function clearFocusedWindow() { root.focusedAppId = ""; @@ -89,11 +80,11 @@ Singleton { NiriWorkspaceService.onNiriAvailableChanged.connect(() => { root.niriAvailable = NiriWorkspaceService.niriAvailable; if (root.niriAvailable) - loadInitialFocusedWindow(); + updateFromNiriData(); }); if (root.niriAvailable) - loadInitialFocusedWindow(); + updateFromNiriData(); } @@ -103,9 +94,6 @@ Singleton { updateFromNiriData(); } - function onFocusedWindowTitleChanged() { - root.focusedWindowTitle = NiriWorkspaceService.focusedWindowTitle; - } function onWindowsChanged() { updateFromNiriData(); @@ -123,31 +111,6 @@ Singleton { target: NiriWorkspaceService } - Process { - id: focusedWindowQuery - - command: ["niri", "msg", "--json", "focused-window"] - running: false - - stdout: StdioCollector { - onStreamFinished: { - if (text && text.trim()) { - try { - const windowData = JSON.parse(text.trim()); - root.focusedAppId = windowData.app_id || ""; - root.focusedWindowTitle = windowData.title || ""; - root.focusedAppName = getDisplayName(windowData.app_id || ""); - root.focusedWindowId = parseInt(windowData.id) || -1; - } catch (e) { - console.warn("FocusedWindowService: Failed to parse focused window data:", e); - clearFocusedWindow(); - } - } else { - clearFocusedWindow(); - } - } - } - } }