forked from Blendman974/faceclaw
[verified] fix(evenhub): preserve app hold gestures without forcing host menu
This commit is contained in:
1 parent
bd630845b6
commit
7c71729d83
4 files changed
+130
-25
No files matched your search
@@ -49,11 +49,9 @@ class EvenHubAppLayer implements Layer {
|
||||
}
|
||||
|
||||
handleInput(event: InputEvent): void {
|
||||
// Everything goes to the app; the menu gestures never reach here (the
|
||||
// shell keeps long-press for its system menu and the window's context
|
||||
// menu intercepts tap-then-hold), which is the guaranteed way out since
|
||||
// EvenHub apps own double-click. Tap-then-hold is still reported to the
|
||||
// app as LONG_PRESS_EVENT — see the handleInput wrapper below.
|
||||
// The shell reserves the configured system-menu gesture as the way out.
|
||||
// Without a registered EvenHub menu, the app-menu gesture belongs to the
|
||||
// app and reaches this layer as the canonical tap-then-hold event.
|
||||
this.session.handleGesture(isDirectionalInput(event) ? ({ ...directionalFallback(event), source: "watch" } as InputEvent) : event);
|
||||
}
|
||||
}
|
||||
@@ -86,6 +84,8 @@ export function createEvenHubWindow(
|
||||
// apps register with `menuObject` (SDK 0.0.14): the app's own entries come
|
||||
// first, then the host entries. Evaluated at open time, so a rebuild that
|
||||
// changes or clears the menu is reflected on the next press.
|
||||
// A host-only "Show phone UI" entry must not steal the app's hold.
|
||||
openMenuOnAppGesture: () => session.contextMenuItems().length > 0,
|
||||
menuItems: () => [
|
||||
...session.contextMenuItems().map((item) => ({
|
||||
label: item.itemName,
|
||||
@@ -133,15 +133,15 @@ export function createEvenHubWindow(
|
||||
windowId,
|
||||
});
|
||||
|
||||
// LONG_PRESS_EVENT / LONG_PRESS_RELEASE_EVENT (SDK 0.0.14): the app hears
|
||||
// the context-menu gesture (tap-then-hold; a plain long-press is the
|
||||
// shell's and never arrives) as its long-press. Wrapped at the window
|
||||
// rather than handled in the base layer because the press opens the window
|
||||
// menu and so never reaches a layer, and because the release lands on that
|
||||
// menu once it is up.
|
||||
// Notify the app even when its registered menu or another overlay consumes
|
||||
// the gesture. At base, with no registered menu, the app layer delivers it
|
||||
// instead; never deliver a press or release twice.
|
||||
const baseHandleInput = created.window.handleInput;
|
||||
created.window.handleInput = async (event, frameId) => {
|
||||
if (event.type === "short-then-long-press" || event.type === "long-press-release") {
|
||||
const opensMenu = event.type === "short-then-long-press" && session.contextMenuItems().length > 0;
|
||||
const overlayOwnsInput = !created.stack.isAtBase();
|
||||
if (opensMenu || (overlayOwnsInput &&
|
||||
(event.type === "short-then-long-press" || event.type === "long-press-release"))) {
|
||||
session.handleGesture(event);
|
||||
}
|
||||
await baseHandleInput(event, frameId);
|
||||
|
||||
@@ -603,13 +603,10 @@ export class EvenHubSession implements EvenHubMicClient, EvenHubImuClient, EvenH
|
||||
case "long-press":
|
||||
case "short-then-long-press":
|
||||
case "long-press-release": {
|
||||
// SDK 0.0.14 exposes press and release as ordinary events. The app's
|
||||
// press is the context-menu gesture (tap-then-hold; the shell keeps
|
||||
// the plain long-press for its system menu): the window still opens
|
||||
// its menu on it (that menu is where the app's contextual-menu items
|
||||
// live, and it is the way out of an app that owns double-click), so
|
||||
// an app hears the press as well as seeing the menu — it cannot be
|
||||
// given exclusive use of the gesture.
|
||||
// SDK 0.0.14 exposes press and release as ordinary events. The shell
|
||||
// canonicalizes the configured app gesture to tap-then-hold. The app
|
||||
// owns it unless it registered contextual-menu items; the separate
|
||||
// system-menu gesture remains available as the way out.
|
||||
const eventType = event.type === "long-press-release" ? LONG_PRESS_RELEASE_EVENT : LONG_PRESS_EVENT;
|
||||
if (capture?.kind === "list") {
|
||||
this.emitListEvent(capture, eventType, inputSource);
|
||||
|
||||
Reference in new issue
Block a user