forked from Blendman974/faceclaw
feat: allow swapping app and system menu hold gestures
This commit is contained in:
9 files changed
+162
-12
No files matched your search
+17
-6
@@ -9,6 +9,7 @@ import {
|
||||
directionalFallback,
|
||||
type DirectionalInputEvent,
|
||||
GESTURE_SHORT_THEN_LONG_PRESS,
|
||||
GESTURE_LONG_PRESS,
|
||||
gestureHints,
|
||||
InputEvent,
|
||||
type InputEventPayload,
|
||||
@@ -52,6 +53,7 @@ import {
|
||||
timeFormatSetting,
|
||||
wakeWordActionSetting,
|
||||
wakeToLastAppSetting,
|
||||
swapMenuGesturesSetting,
|
||||
windowBorderSetting,
|
||||
} from "../dashboard-settings";
|
||||
import { onAmbientCardsChanged } from "./ambient-cards";
|
||||
@@ -1061,7 +1063,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
|
||||
@@ -1069,7 +1079,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 };
|
||||
}
|
||||
@@ -1091,11 +1101,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) {
|
||||
const window = this.foregroundWindow();
|
||||
if (window?.holdToTalk) {
|
||||
this.openEscapeMenu();
|
||||
@@ -1123,7 +1133,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") {
|
||||
@@ -1980,7 +1990,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);
|
||||
|
||||
Reference in new issue
Block a user