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
@@ -601,6 +601,14 @@ export function getBrightnessPreferences() {
|
||||
curve: autoBrightnessCurveSetting.getValidValue(), fadeMs: scaleAnimationDuration(SCREEN_FADE_MS, screenFadeSetting.get()) };
|
||||
}
|
||||
|
||||
export const swapMenuGesturesSetting = new ConfigSettingBoolean({
|
||||
id: "swap-menu-gestures",
|
||||
label: "Long press for app menu",
|
||||
storageKey: "input.swapMenuGestures",
|
||||
defaultValue: false,
|
||||
description: "Use long press for the app menu and tap then hold for the system menu. Apps using long press for a game action or voice capture keep their gestures. The app switcher keeps its system menu gestures.",
|
||||
});
|
||||
|
||||
export const wakeToLastAppSetting = new ConfigSettingBoolean({
|
||||
id: "wake-to-last-app",
|
||||
label: "Wake into last app",
|
||||
|
||||
@@ -89,6 +89,7 @@ import {
|
||||
voiceProviderSetting,
|
||||
screenTimeoutSetting,
|
||||
wakeToLastAppSetting,
|
||||
swapMenuGesturesSetting,
|
||||
wakeWordActionSetting,
|
||||
watchCanUnlockSetting,
|
||||
watchCrownClockwiseNextSetting,
|
||||
@@ -125,6 +126,7 @@ function settingsSections(): SettingsSection[] {
|
||||
}),
|
||||
toggleSettingMenuItem(lockScreenEnabledSetting),
|
||||
toggleSettingMenuItem(wakeToLastAppSetting),
|
||||
toggleSettingMenuItem(swapMenuGesturesSetting),
|
||||
// A band (at one of five heights) / Tall / Full Screen; the
|
||||
// dashboard controller moves or reflows windows on change.
|
||||
enumSettingMenuItem(displayLayoutSetting),
|
||||
|
||||
+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);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { swapMenuGesturesSetting } from "./dashboard-settings";
|
||||
import { GrayImage } from "../graphics/image";
|
||||
import { singlePlane, type Plane } from "../graphics/plane";
|
||||
import { GESTURE_LONG_PRESS, GESTURE_SHORT_THEN_LONG_PRESS, gestureHints, type InputEvent } from "./gestures";
|
||||
@@ -6,8 +7,9 @@ import { CONTEXT_MENU_DIM, MenuLayer, type MenuItem, type MenuLayout } from "./m
|
||||
import type { WorkerAppReply } from "./shell/worker-window";
|
||||
|
||||
/**
|
||||
* The window context menu, opened by tap-then-hold: an app's own menu,
|
||||
* holding its app-specific actions. The shell's system menu (long-press)
|
||||
* The window context menu, opened by tap-then-hold by default: an app's own menu,
|
||||
* holding its app-specific actions. The menu gesture preference can swap
|
||||
* these bindings unless the app owns long-press. The shell's system menu
|
||||
* carries the entries every window shares — Focus app switcher, Voice input,
|
||||
* Close window — so an app with nothing of its own to offer has no menu of
|
||||
* its own: tap-then-hold then opens the system menu in its place, so both
|
||||
@@ -28,8 +30,8 @@ export const WINDOW_MENU_LAYOUT: MenuLayout = {
|
||||
};
|
||||
|
||||
export class WindowMenuLayer extends MenuLayer {
|
||||
constructor(title: string | null, items: MenuItem[], holdToTalk = false) {
|
||||
super(title, items, holdToTalk
|
||||
constructor(title: string | null, items: MenuItem[], holdToTalk = false, claimsLongPress = false) {
|
||||
super(title, items, (holdToTalk || (swapMenuGesturesSetting.get() && !claimsLongPress))
|
||||
? { ...WINDOW_MENU_LAYOUT, footer: gestureHints([[GESTURE_SHORT_THEN_LONG_PRESS, "system menu"]]) }
|
||||
: WINDOW_MENU_LAYOUT);
|
||||
}
|
||||
@@ -123,7 +125,7 @@ export class WindowMenu {
|
||||
handleInput: () => {},
|
||||
};
|
||||
const stack = new LayerStack(base, this.layerActions(), this.options.size, this.options.isFocused);
|
||||
const layer = new WindowMenuLayer(title, items);
|
||||
const layer = new WindowMenuLayer(title, items, false, this.options.claimsLongPress?.() ?? false);
|
||||
if (selectedIndex !== undefined) layer.selectItem(selectedIndex);
|
||||
stack.push(layer);
|
||||
this.stack = stack;
|
||||
|
||||
Reference in new issue
Block a user