From 5dd43a681ec81c9d35517c48e30acbd723dd7ffd Mon Sep 17 00:00:00 2001 From: Lucas Oskorep Date: Mon, 2 Mar 2026 11:26:28 -0500 Subject: [PATCH] fix: when new items enter the tabbed view they should be the active window --- src/wm/container.ts | 15 +++++++++++++++ src/wm/monitor.ts | 6 ++++++ src/wm/windowManager.ts | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/src/wm/container.ts b/src/wm/container.ts index 8335680..09e0137 100644 --- a/src/wm/container.ts +++ b/src/wm/container.ts @@ -161,6 +161,21 @@ export default class WindowContainer { return this._activeTabIndex; } + /** + * If the given window is a tab in this container, make it the active tab. + * Returns true if the window was found and activated. + */ + focusWindowTab(windowId: number): boolean { + if (!this.isTabbed()) return false; + + const index = this._getIndexOfWindow(windowId); + if (index !== -1 && index !== this._activeTabIndex) { + this.setActiveTab(index); + return true; + } + return index !== -1; + } + hideTabBar(): void { this._tabBar?.hide(); } diff --git a/src/wm/monitor.ts b/src/wm/monitor.ts index d4f0953..dc6c9e2 100644 --- a/src/wm/monitor.ts +++ b/src/wm/monitor.ts @@ -72,6 +72,12 @@ export default class Monitor { this._workspaces.push(new WindowContainer(this._workArea)); } + focusWindowTab(windowId: number): void { + for (const container of this._workspaces) { + if (container.focusWindowTab(windowId)) return; + } + } + refreshTabTitlesForWindow(winWrap: WindowWrapper): void { const wsId = winWrap.getWorkspace(); if (wsId >= 0 && wsId < this._workspaces.length) { diff --git a/src/wm/windowManager.ts b/src/wm/windowManager.ts index 19aebeb..fa79b89 100644 --- a/src/wm/windowManager.ts +++ b/src/wm/windowManager.ts @@ -504,6 +504,10 @@ export default class WindowManager implements IWindowManager { if (focusWindow) { this._activeWindowId = focusWindow.get_id(); Logger.debug(`Active window changed to: ${this._activeWindowId} (${focusWindow.get_title()})`); + + // If the focused window is inside a tabbed container, make it the active tab + const monId = focusWindow.get_monitor(); + this._monitors.get(monId)?.focusWindowTab(this._activeWindowId); } else { this._activeWindowId = null; Logger.debug('No active window');