diff --git a/modules/overview/OverviewWidget.qml b/modules/overview/OverviewWidget.qml index 9cb2750..5490ebe 100644 --- a/modules/overview/OverviewWidget.qml +++ b/modules/overview/OverviewWidget.qml @@ -153,12 +153,20 @@ Item { const inWorkspaceGroup = (root.workspaceGroup * root.workspacesShown < win?.workspace?.id && win?.workspace?.id <= (root.workspaceGroup + 1) * root.workspacesShown) return inWorkspaceGroup; }).sort((a, b) => { - // Sort by stacking order from Hyprland (index in windowList) + // Proper stacking order: floating windows on top, sorted by focus history const addrA = `0x${a.HyprlandToplevel.address}` const addrB = `0x${b.HyprlandToplevel.address}` - const indexA = root.windowAddresses.indexOf(addrA) - const indexB = root.windowAddresses.indexOf(addrB) - return indexA - indexB + const winA = windowByAddress[addrA] + const winB = windowByAddress[addrB] + + // Floating windows always above tiled windows + if (winA?.floating !== winB?.floating) { + return winA?.floating ? 1 : -1 + } + + // Within same type (both floating or both tiled), sort by focus history + // Higher focusHistoryID = more recently focused = higher in stack + return (winA?.focusHistoryID ?? 0) - (winB?.focusHistoryID ?? 0) }) } }