forked from Blendman974/faceclaw
[verified] merge upstream 25cb255b into all-features
This commit is contained in:
commit
ffcdae660d
169 files changed
+16201
-597
No files matched your search
@@ -50,6 +50,8 @@ export type InProcessWindowOptions = {
|
||||
setScreenOn?: ShellWindow["setScreenOn"];
|
||||
/** See ShellWindow.keepsScreenOn. */
|
||||
keepsScreenOn?: ShellWindow["keepsScreenOn"];
|
||||
/** See ShellWindow.restoresApp. */
|
||||
restoresApp?: boolean;
|
||||
/** The window came to or left the foreground (after its surface visibility follows). */
|
||||
onForegroundChanged?: (foreground: boolean) => void;
|
||||
/** Shared actions; requestRender is rebound to this window's render. */
|
||||
@@ -179,6 +181,7 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
|
||||
holdToTalk: options.holdToTalk,
|
||||
isVoiceCapturing: options.isVoiceCapturing,
|
||||
keepsScreenOn: options.keepsScreenOn,
|
||||
restoresApp: options.restoresApp,
|
||||
setScreenOn: options.setScreenOn,
|
||||
heightMode,
|
||||
hasAppMenu: () => appMenuItems().length > 0,
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
isWatchInput,
|
||||
makeInputEvent,
|
||||
} from "../gestures";
|
||||
import type { KeyEvent } from "../../g2/keyboard/keys";
|
||||
import { Layer, LayerActions, LayerContext, LayerStack, noopLayerActions } from "../layers";
|
||||
import { CONTEXT_MENU_DIM, MenuLayer, type MenuItem } from "../menu";
|
||||
import { VoiceInputLayer, type VoiceSendTarget } from "./voice-input";
|
||||
@@ -158,6 +159,13 @@ export type ShellWindow = {
|
||||
* draws this window's top bar.
|
||||
*/
|
||||
heightMode: WindowHeightMode;
|
||||
/**
|
||||
* False for a window that must not bring its app back when Faceclaw
|
||||
* restarts (the controller's open-apps restore relaunches apps, not
|
||||
* windows): one that shows something a plain launch of its app would not,
|
||||
* where the relaunch would do something else in its place.
|
||||
*/
|
||||
restoresApp?: boolean;
|
||||
/** App-side cleanup when the shell closes the window (worker notification, surface removal). */
|
||||
close?: () => void;
|
||||
drawIcon: ShellChromeWindow["drawIcon"];
|
||||
@@ -192,6 +200,15 @@ export type ShellWindow = {
|
||||
* only windows that consume typed text (the terminal) implement it.
|
||||
*/
|
||||
receiveTextInput?: (text: string, options?: { submit?: boolean }) => void;
|
||||
/**
|
||||
* Take a key from a hardware keyboard (app/g2/keyboard) as a key. Optional:
|
||||
* only windows that give keys a meaning of their own (the terminal)
|
||||
* implement it. They get the keys no keybinding claimed while they have
|
||||
* input focus, presses and releases alike; the rest of the time, and for
|
||||
* every other window, the navigation keys act as gestures (see
|
||||
* app/g2/keyboard/bindings.ts).
|
||||
*/
|
||||
handleKeyEvent?: (event: KeyEvent) => void;
|
||||
/** Foreground state changed: this window's surface is (not) the visible one. */
|
||||
setForeground?: (foreground: boolean) => void;
|
||||
/**
|
||||
@@ -1671,6 +1688,21 @@ class Shell {
|
||||
this.foregroundWindow()?.receiveTextInput?.(text, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Offer a hardware-keyboard key to the window that has input focus. True
|
||||
* when that window takes keys (ShellWindow.handleKeyEvent) and got this
|
||||
* one; false when the key is the caller's to interpret: the screen is off,
|
||||
* the sidebar or a shell overlay has focus, or the window has no use for
|
||||
* keys. Typing counts as activity for the screen timeout.
|
||||
*/
|
||||
receiveKeyEvent(event: KeyEvent): boolean {
|
||||
const window = this.inputTargetWindow();
|
||||
if (!window?.handleKeyEvent) return false;
|
||||
if (event.phase === "down") this.lastInputAtMs = Date.now();
|
||||
window.handleKeyEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the voice dialog aimed at the foreground window. Called when the
|
||||
* user picks Voice input from the system menu (or an app asks via a
|
||||
|
||||
@@ -28,6 +28,8 @@ export type WorkerAppMessage =
|
||||
| { type: "close-window"; windowId: string }
|
||||
| { type: "input"; windowId: string; event: unknown; frameId: number; focused: boolean }
|
||||
| { type: "text-input"; windowId: string; text: string; submit?: boolean }
|
||||
/** A hardware-keyboard key (a KeyEvent), for windows opened with acceptsKeys. */
|
||||
| { type: "key"; windowId: string; event: unknown; focused: boolean }
|
||||
| { type: "render"; windowId: string; focused: boolean }
|
||||
| { type: "foreground"; windowId: string; foreground: boolean; focused: boolean }
|
||||
/**
|
||||
@@ -56,6 +58,16 @@ export type WorkerAppReply =
|
||||
type: "worker-ready";
|
||||
}
|
||||
| { type: "yield-focus"; windowId: string }
|
||||
| {
|
||||
/**
|
||||
* A "key" message the window had no use for as a key (a terminal
|
||||
* showing its session list rather than a session). The host gives it
|
||||
* the keyboard's navigation meaning instead.
|
||||
*/
|
||||
type: "key-unhandled";
|
||||
windowId: string;
|
||||
event: unknown;
|
||||
}
|
||||
| {
|
||||
/** Foreground and focus one of the app's existing windows. */
|
||||
type: "focus-window";
|
||||
@@ -81,6 +93,8 @@ export type WorkerAppReply =
|
||||
focus?: boolean;
|
||||
/** Window height: the standard 288px band ("min", default) or full screen ("max"). */
|
||||
heightMode?: WindowHeightMode;
|
||||
/** Send the window hardware-keyboard keys (see WorkerWindowSpec). */
|
||||
acceptsKeys?: boolean;
|
||||
}
|
||||
| {
|
||||
/**
|
||||
@@ -196,6 +210,13 @@ export type WorkerWindowSpec = {
|
||||
* of all four directions in every window state (see ShellWindow).
|
||||
*/
|
||||
acceptsDirectional?: boolean;
|
||||
/**
|
||||
* Deliver hardware-keyboard keys to the worker as "key" messages while the
|
||||
* window has input focus (see ShellWindow.handleKeyEvent). The worker
|
||||
* answers "key-unhandled" for a key it doesn't want as a key just then,
|
||||
* which gets the keyboard's navigation meaning instead.
|
||||
*/
|
||||
acceptsKeys?: boolean;
|
||||
};
|
||||
|
||||
export type WorkerAppHostOptions = {
|
||||
@@ -223,6 +244,8 @@ export type WorkerAppHostOptions = {
|
||||
startTextSettingEdit: (settingId: string) => void;
|
||||
/** Close the phone text editor opened by startTextSettingEdit. */
|
||||
endTextSettingEdit: () => void;
|
||||
/** A key a window was sent and handed back (the "key-unhandled" reply); a KeyEvent. */
|
||||
unhandledKey?: (event: unknown) => void;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -312,6 +335,10 @@ export class WorkerAppHost {
|
||||
shell.yieldFocusToSidebar();
|
||||
}
|
||||
break;
|
||||
case "key-unhandled":
|
||||
// Stale once focus has moved on: the key was meant for that window.
|
||||
if (shell.isWindowFocused(message.windowId)) this.options.unhandledKey?.(message.event);
|
||||
break;
|
||||
case "focus-window":
|
||||
if (this.openWindows.has(message.windowId)) {
|
||||
shell.focusWindow(message.windowId);
|
||||
@@ -335,6 +362,7 @@ export class WorkerAppHost {
|
||||
iconGlyph: message.iconGlyph,
|
||||
focus: message.focus,
|
||||
heightMode: message.heightMode,
|
||||
acceptsKeys: message.acceptsKeys,
|
||||
});
|
||||
break;
|
||||
case "set-height-mode":
|
||||
@@ -522,6 +550,13 @@ export class WorkerAppHost {
|
||||
receiveTextInput: (text, options) => {
|
||||
this.post({ type: "text-input", windowId: spec.windowId, text, ...(options?.submit === undefined ? {} : { submit: options.submit }) });
|
||||
},
|
||||
...(spec.acceptsKeys
|
||||
? {
|
||||
handleKeyEvent: (event) => {
|
||||
this.post({ type: "key", windowId: spec.windowId, event, focused: shell.isWindowFocused(spec.windowId) });
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
setForeground: (foreground) => {
|
||||
this.options.setSurfaceVisible(surfaceId, foreground);
|
||||
if (foreground) {
|
||||
|
||||
Reference in new issue
Block a user