From 7d795256de6dbe7b4044161af2b6002421bdb188 Mon Sep 17 00:00:00 2001 From: Lemmy Date: Sat, 13 Dec 2025 20:21:18 -0500 Subject: [PATCH] Compositor: another take on not resyncing all windows when only the focus changes. --- Modules/Bar/Widgets/Taskbar.qml | 3 +++ Modules/Bar/Widgets/Workspace.qml | 8 +++++++- Services/Compositor/CompositorService.qml | 22 ++++++++++++++++++---- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Modules/Bar/Widgets/Taskbar.qml b/Modules/Bar/Widgets/Taskbar.qml index 55317f17f..8ee03f2fd 100644 --- a/Modules/Bar/Widgets/Taskbar.qml +++ b/Modules/Bar/Widgets/Taskbar.qml @@ -381,6 +381,9 @@ Rectangle { Connections { target: CompositorService + function onActiveWindowChanged() { + updateCombinedModel(); + } function onWindowListChanged() { updateCombinedModel(); } diff --git a/Modules/Bar/Widgets/Workspace.qml b/Modules/Bar/Widgets/Workspace.qml index cf43b48ec..2d661ce6d 100644 --- a/Modules/Bar/Widgets/Workspace.qml +++ b/Modules/Bar/Widgets/Workspace.qml @@ -171,8 +171,14 @@ Item { refreshWorkspaces(); } function onWindowListChanged() { - if (showApplications || showLabelsOnlyWhenOccupied) + if (showApplications || showLabelsOnlyWhenOccupied) { refreshWorkspaces(); + } + } + function onActiveWindowChanged() { + if (showApplications || showLabelsOnlyWhenOccupied) { + refreshWorkspaces(); + } } } diff --git a/Services/Compositor/CompositorService.qml b/Services/Compositor/CompositorService.qml index f88baf52e..60c3a18cc 100644 --- a/Services/Compositor/CompositorService.qml +++ b/Services/Compositor/CompositorService.qml @@ -168,9 +168,8 @@ Singleton { }); backend.activeWindowChanged.connect(() => { - // Sync active window when it changes - // TODO: Avoid re-syncing all windows - syncWindows(); + // Only sync focus state, not entire window list + syncFocusedWindow(); // Forward the signal activeWindowChanged(); }); @@ -209,10 +208,25 @@ Singleton { for (var i = 0; i < ws.length; i++) { windows.append(ws[i]); } - // Emit signal to notify listeners that workspace list has been updated + // Emit signal to notify listeners that window list has been updated windowListChanged(); } + // Sync only the focused window state, not the entire window list + function syncFocusedWindow() { + const newIndex = backend.focusedWindowIndex; + + // Update isFocused flags by syncing from backend + for (var i = 0; i < windows.count && i < backend.windows.length; i++) { + const backendFocused = backend.windows[i].isFocused; + if (windows.get(i).isFocused !== backendFocused) { + windows.setProperty(i, "isFocused", backendFocused); + } + } + + focusedWindowIndex = newIndex; + } + // Update display scales from backend function updateDisplayScales() { if (!backend || !backend.queryDisplayScales) {