Skip to content

Commit b008fcd

Browse files
committed
Focus second item in Opened windows view as an alternative window
1 parent 1a2368f commit b008fcd

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

bundled_plugins/gauntlet/src/window/shared.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@ import {
44
GeneratedEntrypointAction,
55
} from "@project-gauntlet/api/helpers";
66
import { linux_open_application } from "gauntlet:bridge/internal-linux";
7+
import { useState } from "react";
78
import { Action, ActionPanel, List } from "@project-gauntlet/api/components";
89

9-
export function ListOfWindows({ windows, focusWindow }: {
10+
export function ListOfWindows({ windows, focusWindow, focusSecond }: {
1011
windows: Record<string, OpenWindowData>,
11-
focusWindow: (windowId: string) => void
12+
focusWindow: (windowId: string) => void,
13+
focusSecond: boolean
1214
}) {
1315
const knownWindows = readWindowOrder();
1416

1517
const sortedWindows = Object.keys(windows) // sort windows based on array stored on storage
1618
.sort((a, b) => knownWindows.indexOf(a) - knownWindows.indexOf(b));
1719

20+
const [id, setId] = useState<string | null>(
21+
focusSecond ? sortedWindows.at(1) || null : null
22+
);
23+
1824
return (
1925
<List
2026
actions={
@@ -30,6 +36,8 @@ export function ListOfWindows({ windows, focusWindow }: {
3036
/>
3137
</ActionPanel>
3238
}
39+
onItemFocusChange={setId}
40+
focusedItemId={id}
3341
>
3442
{
3543
sortedWindows.map(window => <List.Item key={window} id={window} title={windows[window]!!.title}/>)
@@ -112,6 +120,7 @@ export function applicationActions(
112120
<ListOfWindows
113121
windows={appWindows}
114122
focusWindow={windowId => focusWindow(windowId)}
123+
focusSecond={false}
115124
/>
116125
)
117126
}

bundled_plugins/gauntlet/src/windows.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ export default function Windows(): ReactElement {
1313
<ListOfWindows
1414
windows={openWindows()}
1515
focusWindow={(windowId) => focusWaylandWindow(windowId)}
16+
focusSecond={true}
1617
/>
1718
)
1819
} else {
1920
return (
2021
<ListOfWindows
2122
windows={openWindows()}
2223
focusWindow={(windowId) => focusX11Window(windowId)}
24+
focusSecond={true}
2325
/>
2426
)
2527
}

0 commit comments

Comments
 (0)