Merge open app switcher ordering

# Conflicts:
#	app/ui/shell/shell.ts
#	docs/validation-launcher-layout.md
This commit is contained in:
Blendman974 committed 2026-11-06 06:32:58 +01:00
commit 428142aef7
5 files changed
+212 -8

No files matched your search

+49 -2
View File
@@ -336,7 +336,7 @@ class ShellOverlayMenuLayer extends MenuLayer {
*/
keepWindowFocus = false;
constructor(items: MenuItem[], footer: string | undefined, private readonly onClosed: () => void) {
constructor(items: MenuItem[], footer: string | undefined, private readonly onClosed: () => void, title = "System") {
// Aligned to the min-height window band (like the sidebar), wherever the
// vertical position setting currently puts it; centered over the
// application area, i.e. the part of the screen beside a side strip
@@ -344,7 +344,7 @@ class ShellOverlayMenuLayer extends MenuLayer {
// the strip overlays).
const width = 272;
const area = appViewportRect("min");
super("System", items, {
super(title, items, {
x: area.x + (((area.width - width) / 2) | 0),
y: area.y + 8,
width,
@@ -1336,6 +1336,43 @@ class Shell {
return hidden ? this.windows.filter((window) => window !== hidden) : this.windows;
}
/** Reorder visible app windows while keeping pinned/temporary slots and foreground stable. */
private moveSwitcherWindow(windowId: string, targetId: string): boolean {
const movable = this.switcherWindows().filter(window => window.closeable);
const from = movable.findIndex(window => window.windowId === windowId);
const to = movable.findIndex(window => window.windowId === targetId);
if (from < 0 || to < 0 || from === to) return false;
const foreground = this.foregroundWindow();
const ids = new Set(movable.map(window => window.windowId));
const [moved] = movable.splice(from, 1);
movable.splice(to, 0, moved!);
let index = 0;
this.windows = this.windows.map(window => ids.has(window.windowId) ? movable[index++]! : window);
if (foreground) this.selectedIndex = this.windows.indexOf(foreground);
this.config.onWindowsChanged?.();
this.config.requestShellRender();
return true;
}
/** Capture window IDs: changing titles or closing windows cannot redirect a pending move. */
private openSwitcherMoveMenu(windowId: string): void {
if (!this.screenOn || this.activeVoiceLayer || !this.stack.isAtBase()) return;
const movable = this.switcherWindows().filter(window => window.closeable);
const selected = movable.findIndex(window => window.windowId === windowId);
if (selected < 0 || movable.length < 2) return;
const items: MenuItem[] = movable.map((window, index) => ({
label: `${index + 1}. ${window.title}`,
onSelect: ctx => {
ctx.stack.pop();
this.moveSwitcherWindow(windowId, window.windowId);
},
}));
const layer = new ShellOverlayMenuLayer(items, undefined, () => this.yieldFocusToSidebar(), "Move app to position");
layer.selectItem(selected);
this.stack.push(layer);
this.config.requestShellRender();
}
/**
* The status bar items the switcher's selection can move onto, in order:
* with a bottom switcher (the selection reaches them past the last
@@ -2022,6 +2059,16 @@ class Shell {
},
}));
}
if (foreground.closeable && this.switcherWindows().filter(window => window.closeable).length > 1) {
items.push({
label: "Move in app switcher",
description: "Choose this open window's position in the app switcher.",
onSelect: ctx => {
ctx.stack.pop();
this.openSwitcherMoveMenu(foreground.windowId);
},
});
}
if (brightnessSetting.get() !== "auto") {
items.push({
label: "Brightness",