forked from Blendman974/faceclaw
Long-press and short-then-long with a context menu open switches between context menus
This commit is contained in:
1 parent
c364099a8c
commit
fddb6ea886
5 files changed
+37
No files matched your search
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## 0.6.4 - Future
|
## 0.6.4 - Future
|
||||||
* Context menus are centered and include window title
|
* Context menus are centered and include window title
|
||||||
|
* Long-press and short-then-long with a context menu open switches between context menus
|
||||||
* Developer speed metrics include bytes/frame
|
* Developer speed metrics include bytes/frame
|
||||||
|
|
||||||
Compass app:
|
Compass app:
|
||||||
|
|||||||
@@ -27,6 +27,13 @@ export type InputEventPayload =
|
|||||||
| { type: "long-press-release"; source: InputSource }
|
| { type: "long-press-release"; source: InputSource }
|
||||||
/** G2 2.2.9 tap-then-hold gesture, reserved for the shell system menu. */
|
/** G2 2.2.9 tap-then-hold gesture, reserved for the shell system menu. */
|
||||||
| { type: "short-then-long-press"; source: InputSource }
|
| { type: "short-then-long-press"; source: InputSource }
|
||||||
|
/**
|
||||||
|
* Not a gesture: a shell -> foreground-window notification that the shell
|
||||||
|
* opened its system context menu over the window. An app with its own
|
||||||
|
* context menu up closes it in response, so the two menus never stack.
|
||||||
|
* Everything else ignores it.
|
||||||
|
*/
|
||||||
|
| { type: "system-menu-opened" }
|
||||||
/**
|
/**
|
||||||
* Spatial (four-way) input, which only a watch can produce: the ring's
|
* Spatial (four-way) input, which only a watch can produce: the ring's
|
||||||
* scroll is a one-dimensional cursor, these are directions. Components with
|
* scroll is a one-dimensional cursor, these are directions. Components with
|
||||||
|
|||||||
@@ -185,6 +185,14 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
|
|||||||
},
|
},
|
||||||
drawIcon: options.drawIcon ?? windowIcon(options.icon, options.iconLetter),
|
drawIcon: options.drawIcon ?? windowIcon(options.icon, options.iconLetter),
|
||||||
handleInput: async (event, frameId) => {
|
handleInput: async (event, frameId) => {
|
||||||
|
// The shell opened its system menu over this window; close our own
|
||||||
|
// context menu so the two never stack. Never forwarded to app layers.
|
||||||
|
if (event.type === "system-menu-opened") {
|
||||||
|
if (stack.popIfTop((layer) => layer instanceof WindowMenuLayer)) {
|
||||||
|
requestRender();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
// The default long-press response: the window menu. Handled here (not
|
// The default long-press response: the window menu. Handled here (not
|
||||||
// per-layer) so it works over submenus and app content alike.
|
// per-layer) so it works over submenus and app content alike.
|
||||||
if (event.type === "long-press") {
|
if (event.type === "long-press") {
|
||||||
|
|||||||
@@ -650,6 +650,15 @@ class Shell {
|
|||||||
// holding the press long enough opens the shell's own menu.
|
// holding the press long enough opens the shell's own menu.
|
||||||
if (event.type === "long-press") {
|
if (event.type === "long-press") {
|
||||||
this.startEscapeMenuTimer();
|
this.startEscapeMenuTimer();
|
||||||
|
// A long-press while the system menu is open switches to the app's
|
||||||
|
// context menu: close the system menu and deliver the press to the
|
||||||
|
// window as usual (apps conventionally answer it with their menu).
|
||||||
|
if (
|
||||||
|
!this.activeVoiceLayer &&
|
||||||
|
this.stack.popIfTop((layer) => layer instanceof ShellOverlayMenuLayer)
|
||||||
|
) {
|
||||||
|
this.config.requestShellRender();
|
||||||
|
}
|
||||||
if (this.activeVoiceLayer || !this.stack.isAtBase()) {
|
if (this.activeVoiceLayer || !this.stack.isAtBase()) {
|
||||||
return { shell: true, window: false };
|
return { shell: true, window: false };
|
||||||
}
|
}
|
||||||
@@ -1183,6 +1192,9 @@ class Shell {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
this.stack.push(new ShellOverlayMenuLayer(items, () => this.yieldFocusToSidebar()));
|
this.stack.push(new ShellOverlayMenuLayer(items, () => this.yieldFocusToSidebar()));
|
||||||
|
// Tell the window the system menu opened over it: an app with its own
|
||||||
|
// context menu up closes it, so the two context menus never stack.
|
||||||
|
void foreground.handleInput(makeInputEvent({ type: "system-menu-opened" }), 0);
|
||||||
this.config.requestShellRender();
|
this.config.requestShellRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1355,6 +1367,8 @@ export function inputEventToString(event: InputEvent): string {
|
|||||||
return `Display wake`;
|
return `Display wake`;
|
||||||
case "wakeword":
|
case "wakeword":
|
||||||
return `Wakeword`;
|
return `Wakeword`;
|
||||||
|
case "system-menu-opened":
|
||||||
|
return `System menu opened`;
|
||||||
default:
|
default:
|
||||||
case "unknown":
|
case "unknown":
|
||||||
return `Unknown event: ${event.kind} ${event.eventSource} ${event.eventType}`;
|
return `Unknown event: ${event.kind} ${event.eventSource} ${event.eventType}`;
|
||||||
|
|||||||
@@ -68,6 +68,13 @@ export class WindowMenu {
|
|||||||
async handleInput(event: InputEvent): Promise<void> {
|
async handleInput(event: InputEvent): Promise<void> {
|
||||||
const stack = this.stack;
|
const stack = this.stack;
|
||||||
if (!stack) return;
|
if (!stack) return;
|
||||||
|
// The shell opened its system menu over this window; close ours so the
|
||||||
|
// two context menus never stack.
|
||||||
|
if (event.type === "system-menu-opened") {
|
||||||
|
stack.clearToBase();
|
||||||
|
this.stack = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
await stack.handleInput(event);
|
await stack.handleInput(event);
|
||||||
if (stack.isAtBase()) {
|
if (stack.isAtBase()) {
|
||||||
this.stack = null;
|
this.stack = null;
|
||||||
|
|||||||
Reference in new issue
Block a user