Sort windows by position

This commit is contained in:
Thomas Avé 2026-03-26 18:39:02 +07:00
parent b6e789c102
commit cf85fc5283
1 changed files with 8 additions and 1 deletions

View File

@ -278,7 +278,9 @@ function Workspaces({ connector }: { connector: string }): JSX.Element {
<box class="workspaces"> <box class="workspaces">
{/* Generate a derived binding by passing a transformation function into the `workspaces` state */} {/* Generate a derived binding by passing a transformation function into the `workspaces` state */}
<For each={workspaces((wss: any[]) => <For each={workspaces((wss: any[]) =>
wss.filter((ws) => ws.output === connector).sort((a, b) => a.idx - b.idx) wss.filter((ws) => ws.output === connector)
.filter((ws) => ws.is_active || windows().some((w: any) => w.workspace_id === ws.id))
.sort((a, b) => a.idx - b.idx)
)}> )}>
{(ws: any) => ( {(ws: any) => (
<button <button
@ -311,6 +313,11 @@ function Clients({ connector }: { connector: string }): JSX.Element {
<For each={windows((wins: any[]) => <For each={windows((wins: any[]) =>
wins.filter((w: any) => !w.title?.includes("rofi")) wins.filter((w: any) => !w.title?.includes("rofi"))
.filter((w: any) => w.workspace_id === active_ws_for_monitor) .filter((w: any) => w.workspace_id === active_ws_for_monitor)
.sort((a: any, b: any) => {
const posA = a.layout?.pos_in_scrolling_layout?.[0] ?? 0;
const posB = b.layout?.pos_in_scrolling_layout?.[0] ?? 0;
return posA - posB;
})
)}> )}>
{(win: any) => ( {(win: any) => (
<box class={win.is_focused ? "focused" : "unfocused"}> <box class={win.is_focused ? "focused" : "unfocused"}>