Merge configurable menu gestures

# Conflicts:
#	app/ui/shell/shell.ts
#	tests/ai-chat.test.cjs
#	tests/brightness-picker.test.cjs
This commit is contained in:
Blendman974 committed 2026-11-06 04:46:29 +01:00
commit 5ae06c1818
11 files changed
+168 -13

No files matched your search

+17 -6
View File
@@ -9,6 +9,7 @@ import {
directionalFallback,
type DirectionalInputEvent,
GESTURE_SHORT_THEN_LONG_PRESS,
GESTURE_LONG_PRESS,
gestureHints,
InputEvent,
type InputEventPayload,
@@ -55,6 +56,7 @@ import {
timeFormatSetting,
wakeWordActionSetting,
wakeToLastAppSetting,
swapMenuGesturesSetting,
windowBorderSetting,
} from "../dashboard-settings";
import { onAmbientCardsChanged } from "./ambient-cards";
@@ -1077,7 +1079,15 @@ class Shell {
return { shell: false, window: false };
}
// Long-press is the shell's own gesture: it opens the system menu
// Remap menu intent only. Apps still receive the canonical context-menu
// event, while owned holds (games / voice) retain their raw input.
const menuWindow = this.foregroundWindow();
const swapMenus = this.focus === "window" && swapMenuGesturesSetting.get() &&
!menuWindow?.holdToTalk && !menuWindow?.claimsLongPress?.();
const systemMenuGesture = swapMenus ? "short-then-long-press" : "long-press";
const appMenuGesture = swapMenus ? "long-press" : "short-then-long-press";
// The resolved system gesture opens the shell's own menu
// directly, never reaching the app — over the app's own context menu
// too (the window closes that on system-menu-opened), while an already
// open system menu just stays. Its later generic release is consumed
@@ -1085,7 +1095,7 @@ class Shell {
// app. The exception is a window that claims long-press for a move of
// its own: it gets the press forwarded, with the escape timer running
// so that holding the press long enough still opens the system menu.
if (event.type === "long-press") {
if (event.type === systemMenuGesture) {
if (this.activeVoiceLayer || !this.stack.isAtBase()) {
return { shell: true, window: false };
}
@@ -1109,11 +1119,11 @@ class Shell {
return { shell: true, window: true };
}
// The 2.2.9 tap-then-hold gesture is the app's context-menu gesture: it
// The resolved app-menu gesture is delivered as tap-then-hold: it
// goes to the foreground window (from the sidebar it focuses the window
// first), which answers with its own menu or asks for the system menu
// when it has none.
if (event.type === "short-then-long-press") {
if (event.type === appMenuGesture) {
if (this.focus === "sidebar" && !this.activeVoiceLayer && this.stack.isAtBase()) {
this.openEscapeMenu();
return { shell: true, window: false };
@@ -1145,7 +1155,7 @@ class Shell {
window.onFocus?.(this.lastInput);
}
// The window owns frameId from here (render or explicit finish).
await window.handleInput(event, frameId);
await window.handleInput(swapMenus ? { ...event, type: "short-then-long-press" } : event, frameId);
return { shell: true, window: true };
}
if (event.type === "long-press-release") {
@@ -2034,7 +2044,8 @@ class Shell {
// when the app has one (otherwise it opens this very menu, not worth a
// hint).
const footer = foreground.hasAppMenu?.()
? (foreground.holdToTalk ? undefined : gestureHints([[GESTURE_SHORT_THEN_LONG_PRESS, "app menu"]]))
? (foreground.holdToTalk ? undefined : gestureHints([[this.focus === "window" && swapMenuGesturesSetting.get() && !foreground.claimsLongPress?.()
? GESTURE_LONG_PRESS : GESTURE_SHORT_THEN_LONG_PRESS, "app menu"]]))
: undefined;
const layer = new ShellOverlayMenuLayer(items, footer, () => this.yieldFocusToSidebar());
layer.selectItem(initialSelection);