From 6d3ca588965bab095c32db3f2b62759b48fd7c77 Mon Sep 17 00:00:00 2001 From: Lysec Date: Mon, 30 Mar 2026 15:20:57 +0200 Subject: [PATCH] fix(workspaces): assign display index per output in ExtWorkspaceService --- Services/Compositor/ExtWorkspaceService.qml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Services/Compositor/ExtWorkspaceService.qml b/Services/Compositor/ExtWorkspaceService.qml index 067eab990..1ed455178 100644 --- a/Services/Compositor/ExtWorkspaceService.qml +++ b/Services/Compositor/ExtWorkspaceService.qml @@ -93,7 +93,10 @@ Item { workspaces.clear(); nativeWorkspaceMap = {}; - let idx = 1; + /* Per-output (projection) index: compositors expose one workspace group per + * monitor with names "1"…"9". A single global idx produced 10–18 on the + * second head because all windowsets were merged into one list. */ + const perOutputNextIdx = {}; for (const ws of nativeWs) { if (!ws.shouldDisplay) { @@ -108,6 +111,18 @@ Item { } } + const groupKey = outputName || "_"; + let idx; + const numericName = ws.name && /^\d+$/.test(String(ws.name)) ? parseInt(ws.name, 10) : NaN; + if (!isNaN(numericName) && numericName >= 1) { + idx = numericName; + } else { + if (perOutputNextIdx[groupKey] === undefined) { + perOutputNextIdx[groupKey] = 1; + } + idx = perOutputNextIdx[groupKey]++; + } + const wsEntry = { "id": ws.id || idx.toString(), "idx": idx, @@ -122,8 +137,6 @@ Item { workspaces.append(wsEntry); nativeWorkspaceMap[wsEntry.id] = ws; - - idx++; } updateWindowWorkspaces();