From 374d3681ce3aa13c0b1bd87ffa03aa74a37ea0b4 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Sat, 23 Aug 2025 15:07:54 +0200 Subject: [PATCH] Fix ActiveWindow Title change (#128) --- Modules/Bar/Widgets/ActiveWindow.qml | 17 ++++++++++++++--- Services/CompositorService.qml | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Modules/Bar/Widgets/ActiveWindow.qml b/Modules/Bar/Widgets/ActiveWindow.qml index 8ca49dc..afcd724 100644 --- a/Modules/Bar/Widgets/ActiveWindow.qml +++ b/Modules/Bar/Widgets/ActiveWindow.qml @@ -27,7 +27,7 @@ Row { } } - // Update text when window changes + // Update text when window changes or title changes Connections { target: CompositorService function onActiveWindowChanged() { @@ -38,11 +38,22 @@ Row { fullTitleTimer.restart() } } + + function onWindowTitleChanged() { + // Direct response to title changes + if (CompositorService.focusedWindowIndex === lastWindowIndex) { + // Same window, title changed - show full title briefly + showingFullTitle = true + fullTitleTimer.restart() + } + } } function getTitle() { - const focusedWindow = CompositorService.getFocusedWindow() - return focusedWindow ? (focusedWindow.title || focusedWindow.appId || "") : "" + // Use the service's focusedWindowTitle property which is updated immediately + // when WindowOpenedOrChanged events are received + return CompositorService.focusedWindowTitle !== "(No active window)" ? + CompositorService.focusedWindowTitle : "" } function getAppIcon() { diff --git a/Services/CompositorService.qml b/Services/CompositorService.qml index f657cb1..595f153 100644 --- a/Services/CompositorService.qml +++ b/Services/CompositorService.qml @@ -27,6 +27,7 @@ Singleton { signal activeWindowChanged signal overviewStateChanged signal windowListChanged + signal windowTitleChanged // Compositor detection Component.onCompleted: { @@ -297,6 +298,8 @@ Singleton { "isFocused": windowData.is_focused === true } + + if (existingIndex >= 0) { // Update existing window windows[existingIndex] = newWindow @@ -311,6 +314,11 @@ Singleton { focusedWindowIndex = windows.findIndex(w => w.id === windowData.id) updateFocusedWindowTitle() activeWindowChanged() + } else if (existingIndex >= 0 && existingIndex === focusedWindowIndex) { + // If this is the currently focused window (but not newly focused), + // still update the title in case it changed + updateFocusedWindowTitle() + activeWindowChanged() } windowListChanged() @@ -449,11 +457,17 @@ Singleton { } function updateFocusedWindowTitle() { + const oldTitle = focusedWindowTitle if (focusedWindowIndex >= 0 && focusedWindowIndex < windows.length) { focusedWindowTitle = windows[focusedWindowIndex].title || "(Unnamed window)" } else { focusedWindowTitle = "(No active window)" } + + // Emit signal if title actually changed + if (oldTitle !== focusedWindowTitle) { + windowTitleChanged() + } } // Generic workspace switching