forked from Blendman974/faceclaw
Move and rename DashboardInputEvent->InputEvent
This commit is contained in:
1 parent
3e8be93833
commit
80d688dd4e
51 files changed
+299
-361
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { GESTURE_DOUBLE_CLICK } from "./gestures";
|
||||
import { GESTURE_DOUBLE_CLICK, InputEvent } from "./gestures";
|
||||
import {
|
||||
getBooleanSetting,
|
||||
getStringSetting,
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
import { isLocalModelReady } from "../native/llama";
|
||||
import { drawRightValueMenuItem, drawToggleMenuItem, MenuItem, openModalMenu } from "./menu";
|
||||
import { LIST_ROW_TEXT_INSET, lineStep } from "./metrics";
|
||||
import { DashboardInputEvent, Layer, type LayerContext } from "./layers";
|
||||
import { Layer, type LayerContext } from "./layers";
|
||||
import { GrayImage } from "~/graphics/image";
|
||||
|
||||
export type NightscoutSettings = {
|
||||
@@ -878,7 +878,7 @@ export class EditTextSettingLayer implements Layer {
|
||||
return image;
|
||||
}
|
||||
|
||||
handleInput(event: DashboardInputEvent, ctx: LayerContext): void {
|
||||
handleInput(event: InputEvent, ctx: LayerContext): void {
|
||||
if (event.type === "double-click") {
|
||||
void ctx.actions.endTextSettingEdit();
|
||||
ctx.stack.pop();
|
||||
|
||||
@@ -2,7 +2,8 @@ import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { GrayImage, type UiFont } from "../../graphics/image";
|
||||
import { wrapText } from "../../graphics/textwrap";
|
||||
import { clamp } from "../../util/numeric-util";
|
||||
import { DashboardInputEvent, Layer, LayerContext, PaintBelow } from "../layers";
|
||||
import { InputEvent } from "../gestures";
|
||||
import { Layer, LayerContext, PaintBelow } from "../layers";
|
||||
import { drawSelectionHighlight, isMenuItemDisabled, MenuItem, MenuLayer, openModalMenu } from "../menu";
|
||||
import { LIST_ROW_TEXT_INSET, lineStep, listRowHeight } from "../metrics";
|
||||
import { shell } from "../shell/shell";
|
||||
@@ -184,7 +185,7 @@ export class SettingsPanelLayer implements Layer {
|
||||
}
|
||||
}
|
||||
|
||||
async handleInput(event: DashboardInputEvent, ctx: LayerContext): Promise<void> {
|
||||
async handleInput(event: InputEvent, ctx: LayerContext): Promise<void> {
|
||||
if (this.focus === "left") {
|
||||
switch (event.type) {
|
||||
case "scroll-up":
|
||||
@@ -263,7 +264,7 @@ export class SettingsDescriptionOverlayLayer implements Layer {
|
||||
return image;
|
||||
}
|
||||
|
||||
handleInput(event: DashboardInputEvent, ctx: LayerContext): Promise<void> {
|
||||
handleInput(event: InputEvent, ctx: LayerContext): Promise<void> {
|
||||
return this.panel.handleInput(event, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ import {
|
||||
type BitmapFace,
|
||||
type UiFontSelection,
|
||||
} from "../graphics/ui-fonts";
|
||||
import { GESTURE_DOUBLE_CLICK } from "./gestures";
|
||||
import { GESTURE_DOUBLE_CLICK, type InputEvent } from "./gestures";
|
||||
import { drawRightValueMenuItem, drawSelectionHighlight, openModalMenu, type MenuItem } from "./menu";
|
||||
import { LIST_ROW_TEXT_INSET, listRowHeight } from "./metrics";
|
||||
import type { DashboardInputEvent, Layer, LayerContext } from "./layers";
|
||||
import type { Layer, LayerContext } from "./layers";
|
||||
|
||||
const SIZE_CHOICES = [12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28] as const;
|
||||
const DEFAULT_TTF_SIZE = 16;
|
||||
@@ -162,7 +162,7 @@ export class FontPickerLayer implements Layer {
|
||||
return String(this.draft.size);
|
||||
}
|
||||
|
||||
handleInput(event: DashboardInputEvent, ctx: LayerContext): void {
|
||||
handleInput(event: InputEvent, ctx: LayerContext): void {
|
||||
switch (event.type) {
|
||||
case "scroll-up":
|
||||
this.selectedRow = (this.selectedRow + ROWS.length - 1) % ROWS.length;
|
||||
|
||||
@@ -1,3 +1,103 @@
|
||||
/**
|
||||
* Where an input came from. The ring and the glasses' arms are the stock
|
||||
* sources; "watch" is the Wear OS remote, which components may treat with a
|
||||
* richer scheme (see isWatchInput) — the ring's semantics are never changed
|
||||
* by it.
|
||||
*/
|
||||
export type InputSource = "ring" | "left-arm" | "right-arm" | "watch";
|
||||
|
||||
/** Fields shared by every input event, whatever its type. */
|
||||
export type BaseInputEvent = {
|
||||
/**
|
||||
* When the event was received from the device (or synthesized), as a
|
||||
* Date.now() epoch-ms value. The G2 wire formats carry no device-side
|
||||
* clock, so this is phone receive time.
|
||||
*/
|
||||
timestampMs: number;
|
||||
};
|
||||
|
||||
/** The per-type part of InputEvent; makeInputEvent adds the BaseInputEvent fields. */
|
||||
export type InputEventPayload =
|
||||
| { type: "click"; source: InputSource }
|
||||
| { type: "double-click"; source: InputSource }
|
||||
/** Ring scroll (or a watch crown turn, then tagged source "watch"). */
|
||||
| { type: "scroll-up"; source?: InputSource }
|
||||
| { type: "scroll-down"; source?: InputSource }
|
||||
| { type: "long-press"; source: InputSource }
|
||||
| { type: "long-press-release"; source: InputSource }
|
||||
/**
|
||||
* Spatial (four-way) input, which only a watch can produce: the ring's
|
||||
* scroll is a one-dimensional cursor, these are directions. Components with
|
||||
* a spatial meaning for them opt in with Layer.acceptsDirectional /
|
||||
* ShellWindow.acceptsDirectional and must then handle all four; for the
|
||||
* rest, directionalFallback turns up/down into scroll, right into "select"
|
||||
* (click) and left into "back" (double-click), so a swipe always does
|
||||
* something sensible.
|
||||
*/
|
||||
| { type: "swipe-up"; source: "watch" }
|
||||
| { type: "swipe-down"; source: "watch" }
|
||||
| { type: "swipe-left"; source: "watch" }
|
||||
| { type: "swipe-right"; source: "watch" }
|
||||
/**
|
||||
* The stock display lifecycle woke while no EvenHub page was running. This
|
||||
* is wake-only, unlike a normal double-click (which turns an on screen off).
|
||||
*/
|
||||
| { type: "display-wake" }
|
||||
/**
|
||||
* The on-glasses "Hey Even" wakeword fired. Delivered on sid 0x07 by the
|
||||
* stock firmware regardless of CFW; the CFW additionally suppresses the stock
|
||||
* Even AI app so this is ours to handle. Its configured action may be applied
|
||||
* while the screen is off, unlike ordinary input events.
|
||||
*/
|
||||
| { type: "wakeword" }
|
||||
| { type: "unknown"; kind: string; eventSource: number; eventType: number };
|
||||
|
||||
export type InputEvent = BaseInputEvent & InputEventPayload;
|
||||
|
||||
/** Stamp an event payload into a full InputEvent, timestamped now. */
|
||||
export function makeInputEvent(payload: InputEventPayload): InputEvent {
|
||||
return { ...payload, timestampMs: Date.now() };
|
||||
}
|
||||
|
||||
/** True for input from the Wear OS remote (any type that carries a source). */
|
||||
export function isWatchInput(event: InputEvent): boolean {
|
||||
return "source" in event && event.source === "watch";
|
||||
}
|
||||
|
||||
export type DirectionalInputEvent = Extract<
|
||||
InputEvent,
|
||||
{ type: "swipe-up" | "swipe-down" | "swipe-left" | "swipe-right" }
|
||||
>;
|
||||
|
||||
export function isDirectionalInput(event: InputEvent): event is DirectionalInputEvent {
|
||||
return (
|
||||
event.type === "swipe-up" ||
|
||||
event.type === "swipe-down" ||
|
||||
event.type === "swipe-left" ||
|
||||
event.type === "swipe-right"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The ring-vocabulary equivalent of a directional swipe: up/down scroll,
|
||||
* right selects, left backs out.
|
||||
*/
|
||||
export function directionalFallback(event: InputEvent): InputEvent {
|
||||
const base = { timestampMs: event.timestampMs };
|
||||
switch (event.type) {
|
||||
case "swipe-up":
|
||||
return { ...base, type: "scroll-up" };
|
||||
case "swipe-down":
|
||||
return { ...base, type: "scroll-down" };
|
||||
case "swipe-right":
|
||||
return { ...base, type: "click", source: "ring" };
|
||||
case "swipe-left":
|
||||
return { ...base, type: "double-click", source: "ring" };
|
||||
default:
|
||||
return event;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compact glyphs for the ring gestures, used in on-glasses hint text instead
|
||||
* of spelling the gesture out. All codepoints exist in terminus12/16.
|
||||
|
||||
+3
-83
@@ -2,93 +2,13 @@ import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../graphics/image";
|
||||
import { type Plane } from "../graphics/plane";
|
||||
import { spanCurrent } from "../native/frame-timings";
|
||||
import { type ConfigSettingBoolean, type ConfigSettingString } from "./dashboard-settings";
|
||||
import { directionalFallback, isDirectionalInput, type InputEvent } from "./gestures";
|
||||
|
||||
export type TextSettingsEditToggle = {
|
||||
setting: ConfigSettingBoolean;
|
||||
label: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Where an input came from. The ring and the glasses' arms are the stock
|
||||
* sources; "watch" is the Wear OS remote, which components may treat with a
|
||||
* richer scheme (see isWatchInput) — the ring's semantics are never changed
|
||||
* by it.
|
||||
*/
|
||||
export type InputSource = "ring" | "left-arm" | "right-arm" | "watch";
|
||||
|
||||
export type DashboardInputEvent =
|
||||
| { type: "click"; source: InputSource }
|
||||
| { type: "double-click"; source: InputSource }
|
||||
/** Ring scroll (or a watch crown turn, then tagged source "watch"). */
|
||||
| { type: "scroll-up"; source?: InputSource }
|
||||
| { type: "scroll-down"; source?: InputSource }
|
||||
| { type: "long-press"; source: InputSource }
|
||||
| { type: "long-press-release"; source: InputSource }
|
||||
/**
|
||||
* Spatial (four-way) input, which only a watch can produce: the ring's
|
||||
* scroll is a one-dimensional cursor, these are directions. Components with
|
||||
* a spatial meaning for them opt in with Layer.acceptsDirectional /
|
||||
* ShellWindow.acceptsDirectional and must then handle all four; for the
|
||||
* rest, directionalFallback turns up/down into scroll, right into "select"
|
||||
* (click) and left into "back" (double-click), so a swipe always does
|
||||
* something sensible.
|
||||
*/
|
||||
| { type: "swipe-up"; source: "watch" }
|
||||
| { type: "swipe-down"; source: "watch" }
|
||||
| { type: "swipe-left"; source: "watch" }
|
||||
| { type: "swipe-right"; source: "watch" }
|
||||
/**
|
||||
* The stock display lifecycle woke while no EvenHub page was running. This
|
||||
* is wake-only, unlike a normal double-click (which turns an on screen off).
|
||||
*/
|
||||
| { type: "display-wake" }
|
||||
/**
|
||||
* The on-glasses "Hey Even" wakeword fired. Delivered on sid 0x07 by the
|
||||
* stock firmware regardless of CFW; the CFW additionally suppresses the stock
|
||||
* Even AI app so this is ours to handle. Its configured action may be applied
|
||||
* while the screen is off, unlike ordinary input events.
|
||||
*/
|
||||
| { type: "wakeword" }
|
||||
| { type: "unknown"; kind: string; eventSource: number; eventType: number };
|
||||
|
||||
/** True for input from the Wear OS remote (any type that carries a source). */
|
||||
export function isWatchInput(event: DashboardInputEvent): boolean {
|
||||
return "source" in event && event.source === "watch";
|
||||
}
|
||||
|
||||
export type DirectionalInputEvent = Extract<
|
||||
DashboardInputEvent,
|
||||
{ type: "swipe-up" | "swipe-down" | "swipe-left" | "swipe-right" }
|
||||
>;
|
||||
|
||||
export function isDirectionalInput(event: DashboardInputEvent): event is DirectionalInputEvent {
|
||||
return (
|
||||
event.type === "swipe-up" ||
|
||||
event.type === "swipe-down" ||
|
||||
event.type === "swipe-left" ||
|
||||
event.type === "swipe-right"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The ring-vocabulary equivalent of a directional swipe: up/down scroll,
|
||||
* right selects, left backs out.
|
||||
*/
|
||||
export function directionalFallback(event: DashboardInputEvent): DashboardInputEvent {
|
||||
switch (event.type) {
|
||||
case "swipe-up":
|
||||
return { type: "scroll-up" };
|
||||
case "swipe-down":
|
||||
return { type: "scroll-down" };
|
||||
case "swipe-right":
|
||||
return { type: "click", source: "ring" };
|
||||
case "swipe-left":
|
||||
return { type: "double-click", source: "ring" };
|
||||
default:
|
||||
return event;
|
||||
}
|
||||
}
|
||||
|
||||
export type LayerActions = {
|
||||
/** Ask for a dashboard repaint+transmit, e.g. when async data arrives. */
|
||||
requestRender: () => void;
|
||||
@@ -161,7 +81,7 @@ export interface LayerContext {
|
||||
export interface Layer {
|
||||
readonly paintOverBase?: boolean;
|
||||
paint(ctx: LayerContext, paintBelow: PaintBelow): GrayImage;
|
||||
handleInput(event: DashboardInputEvent, ctx: LayerContext): Promise<void> | void;
|
||||
handleInput(event: InputEvent, ctx: LayerContext): Promise<void> | void;
|
||||
/**
|
||||
* True when handleInput gives swipe-left / swipe-right a meaning of its own.
|
||||
* Otherwise the stack hands the layer directionalFallback(event) instead.
|
||||
@@ -286,7 +206,7 @@ export class LayerStack {
|
||||
return this.paintLayer(this.layers.length - 1);
|
||||
}
|
||||
|
||||
async handleInput(event: DashboardInputEvent): Promise<void> {
|
||||
async handleInput(event: InputEvent): Promise<void> {
|
||||
const top = this.layers[this.layers.length - 1]!;
|
||||
const delivered = isDirectionalInput(event) && !top.acceptsDirectional ? directionalFallback(event) : event;
|
||||
await top.handleInput(delivered, this.ctx);
|
||||
|
||||
+4
-4
@@ -2,9 +2,9 @@ import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage, type UiFont } from "../graphi
|
||||
import { wrapText } from "../graphics/textwrap";
|
||||
import { getDefaultSmallFont } from "../graphics/ui-fonts";
|
||||
import { clamp } from "../util/numeric-util";
|
||||
import { DashboardInputEvent, Layer, LayerContext, PaintBelow } from "./layers";
|
||||
import { Layer, LayerContext, PaintBelow } from "./layers";
|
||||
|
||||
import { GESTURE_DOUBLE_CLICK } from "./gestures";
|
||||
import { GESTURE_DOUBLE_CLICK, InputEvent } from "./gestures";
|
||||
import { LIST_ROW_TEXT_INSET, lineStep, listRowHeight, menuTitleHeight } from "./metrics";
|
||||
const DEFAULT_MENU_X = 8;
|
||||
const DEFAULT_MENU_Y = 8;
|
||||
@@ -280,7 +280,7 @@ export class MenuLayer implements Layer {
|
||||
return image;
|
||||
}
|
||||
|
||||
async handleInput(event: DashboardInputEvent, ctx: LayerContext): Promise<void> {
|
||||
async handleInput(event: InputEvent, ctx: LayerContext): Promise<void> {
|
||||
if (!this.items.length) {
|
||||
if (event.type === "double-click") {
|
||||
ctx.stack.pop();
|
||||
@@ -358,7 +358,7 @@ export class TextPageLayer implements Layer {
|
||||
return image;
|
||||
}
|
||||
|
||||
handleInput(event: DashboardInputEvent, ctx: LayerContext): void {
|
||||
handleInput(event: InputEvent, ctx: LayerContext): void {
|
||||
if (event.type === "double-click") {
|
||||
ctx.stack.pop();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ import {
|
||||
} from "../native/notification-icons";
|
||||
import { isNotificationListenerEnabled } from "../native/notification-access";
|
||||
import { noteStaleDataUsed, renderPassAllowsStaleData } from "../util/render-freshness";
|
||||
import { type DashboardInputEvent, type Layer, type LayerContext, type PaintBelow } from "./layers";
|
||||
import { type InputEvent } from "./gestures";
|
||||
import { type Layer, type LayerContext, type PaintBelow } from "./layers";
|
||||
|
||||
const PAGE_X = 12;
|
||||
const PAGE_Y = 12;
|
||||
@@ -119,7 +120,7 @@ export class NotificationsListLayer implements Layer {
|
||||
return image;
|
||||
}
|
||||
|
||||
handleInput(event: DashboardInputEvent, ctx: LayerContext): void {
|
||||
handleInput(event: InputEvent, ctx: LayerContext): void {
|
||||
const notifications = readActiveNotifications(MAX_NOTIFICATIONS);
|
||||
const selectedIndex = this.resolveSelectedIndex(notifications);
|
||||
if (event.type === "double-click") {
|
||||
@@ -189,7 +190,7 @@ export class SingleNotificationLayer implements Layer {
|
||||
return image;
|
||||
}
|
||||
|
||||
handleInput(event: DashboardInputEvent, ctx: LayerContext): void {
|
||||
handleInput(event: InputEvent, ctx: LayerContext): void {
|
||||
const notification = readActiveNotifications(MAX_NOTIFICATIONS).find((item) => item.key === this.notificationKey);
|
||||
if (!notification) {
|
||||
this.closeUnavailableNotification(ctx);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { G2_LENS_WIDTH, GrayImage } from "../../graphics/image";
|
||||
import { type BdfFont } from "../../graphics/bdffont";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { GESTURE_DOUBLE_CLICK } from "../gestures";
|
||||
import { GESTURE_DOUBLE_CLICK, type InputEvent } from "../gestures";
|
||||
import { drawSelectionHighlight } from "../menu";
|
||||
import { listRowHeight } from "../metrics";
|
||||
import { Layer, type DashboardInputEvent, type LayerActions, type LayerContext } from "../layers";
|
||||
import { Layer, type LayerActions, type LayerContext } from "../layers";
|
||||
import { wrapText, truncateText } from "../../graphics/textwrap";
|
||||
import { MIN_WINDOW_HEIGHT, minWindowTop } from "./geometry";
|
||||
|
||||
@@ -134,7 +134,7 @@ export class AssistantLayer implements Layer {
|
||||
return image;
|
||||
}
|
||||
|
||||
handleInput(event: DashboardInputEvent, _ctx: LayerContext): void {
|
||||
handleInput(event: InputEvent, _ctx: LayerContext): void {
|
||||
if (this.phase === "thinking") {
|
||||
if (event.type === "double-click") {
|
||||
this.callbacks.onCancel();
|
||||
|
||||
@@ -2,7 +2,8 @@ import { GrayImage } from "../../graphics/image";
|
||||
import { type Plane } from "../../graphics/plane";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import { beginRenderPass, endRenderPass } from "../../util/render-freshness";
|
||||
import { DashboardInputEvent, Layer, LayerActions, LayerContext, LayerStack, PaintBelow } from "../layers";
|
||||
import { InputEvent } from "../gestures";
|
||||
import { Layer, LayerActions, LayerContext, LayerStack, PaintBelow } from "../layers";
|
||||
import { type MenuItem } from "../menu";
|
||||
import { WindowMenuLayer } from "../window-menu";
|
||||
import { windowIcon } from "./chrome-layer";
|
||||
@@ -249,7 +250,7 @@ export class YieldAtRootLayer implements Layer {
|
||||
return this.inner.paint(ctx, paintBelow);
|
||||
}
|
||||
|
||||
async handleInput(event: DashboardInputEvent, ctx: LayerContext): Promise<void> {
|
||||
async handleInput(event: InputEvent, ctx: LayerContext): Promise<void> {
|
||||
if (event.type === "double-click") {
|
||||
shell.yieldFocusToSidebar();
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes } from "../../graphics/plane";
|
||||
import { DashboardInputEvent, Layer, LayerActions, LayerContext, LayerStack, PaintBelow } from "../layers";
|
||||
import { InputEvent } from "../gestures";
|
||||
import { Layer, LayerActions, LayerContext, LayerStack, PaintBelow } from "../layers";
|
||||
import { appViewportRect, appViewportSize, SHELL_OPAQUE_BLACK } from "./geometry";
|
||||
|
||||
// The modal covers most of the min-height app viewport, leaving a little of
|
||||
@@ -59,7 +60,7 @@ export class ShellModalLayer implements Layer {
|
||||
return image;
|
||||
}
|
||||
|
||||
async handleInput(event: DashboardInputEvent, _ctx: LayerContext): Promise<void> {
|
||||
async handleInput(event: InputEvent, _ctx: LayerContext): Promise<void> {
|
||||
await this.stack.handleInput(event);
|
||||
}
|
||||
}
|
||||
+16
-14
@@ -4,16 +4,14 @@ import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { EvenAIStatus, EventSourceType, OsEventTypeList, WatchGestureType } from "../../g2/events";
|
||||
import type { RawInputEvent } from "../../native/faceclaw-communicator";
|
||||
import {
|
||||
DashboardInputEvent,
|
||||
directionalFallback,
|
||||
InputEvent,
|
||||
type InputEventPayload,
|
||||
type InputSource,
|
||||
isDirectionalInput,
|
||||
Layer,
|
||||
LayerActions,
|
||||
LayerContext,
|
||||
LayerStack,
|
||||
noopLayerActions,
|
||||
} from "../layers";
|
||||
makeInputEvent,
|
||||
} from "../gestures";
|
||||
import { Layer, LayerActions, LayerContext, LayerStack, noopLayerActions } from "../layers";
|
||||
import { MenuLayer, type MenuItem } from "../menu";
|
||||
import { VoiceInputLayer, type VoiceSendTarget } from "./voice-input";
|
||||
import { voiceActivity } from "./voice-activity";
|
||||
@@ -92,7 +90,7 @@ export type ShellWindow = {
|
||||
* tracking) passes to the window: it must eventually reach a frame submit
|
||||
* or a finishFrame call.
|
||||
*/
|
||||
handleInput: (event: DashboardInputEvent, frameId: number) => Promise<void> | void;
|
||||
handleInput: (event: InputEvent, frameId: number) => Promise<void> | void;
|
||||
/** Repaint and resubmit this window's surface. */
|
||||
requestRender: () => void;
|
||||
/**
|
||||
@@ -213,7 +211,7 @@ class ShellAlertLayer implements Layer {
|
||||
return image;
|
||||
}
|
||||
|
||||
handleInput(event: DashboardInputEvent, _ctx: LayerContext): void {
|
||||
handleInput(event: InputEvent, _ctx: LayerContext): void {
|
||||
if (event.type === "click" || event.type === "double-click") {
|
||||
this.clearTimer();
|
||||
this.onDismiss();
|
||||
@@ -548,7 +546,7 @@ class Shell {
|
||||
return this.stack.paint();
|
||||
}
|
||||
|
||||
async receiveInput(event: DashboardInputEvent, frameId = 0): Promise<ShellInputOutcome> {
|
||||
async receiveInput(event: InputEvent, frameId = 0): Promise<ShellInputOutcome> {
|
||||
// The stock lifecycle has already interpreted the physical double tap as
|
||||
// "wake". Keep that directionality if delivery is delayed or duplicated.
|
||||
if (event.type === "display-wake") {
|
||||
@@ -698,7 +696,7 @@ class Shell {
|
||||
return this.screenOn && this.foregroundWindow()?.windowId === windowId;
|
||||
}
|
||||
|
||||
private handleSidebarInput(event: DashboardInputEvent): ShellInputOutcome {
|
||||
private handleSidebarInput(event: InputEvent): ShellInputOutcome {
|
||||
switch (event.type) {
|
||||
case "double-click":
|
||||
// A double-tap at the root (the app switcher selected) turns the
|
||||
@@ -1147,7 +1145,11 @@ function formatAssistantTime(date: Date): string {
|
||||
return `${day}, ${hours}:${minutes} ${meridiem}`;
|
||||
}
|
||||
|
||||
export function rawInputEventToInputEvent(event: RawInputEvent): DashboardInputEvent {
|
||||
export function rawInputEventToInputEvent(event: RawInputEvent): InputEvent {
|
||||
return makeInputEvent(rawInputEventToPayload(event));
|
||||
}
|
||||
|
||||
function rawInputEventToPayload(event: RawInputEvent): InputEventPayload {
|
||||
if (event.kind === "sys-event") {
|
||||
if (event.eventType === OsEventTypeList.CLICK_EVENT) {
|
||||
return {
|
||||
@@ -1210,7 +1212,7 @@ export function rawInputEventToInputEvent(event: RawInputEvent): DashboardInputE
|
||||
}
|
||||
|
||||
/** Scroll events only carry a source when it is the watch (the stock ones never needed one). */
|
||||
function scrollEvent(type: "scroll-up" | "scroll-down", eventSource: number): DashboardInputEvent {
|
||||
function scrollEvent(type: "scroll-up" | "scroll-down", eventSource: number): InputEventPayload {
|
||||
return eventSource === EventSourceType.TOUCH_EVENT_FROM_WATCH ? { type, source: "watch" } : { type };
|
||||
}
|
||||
|
||||
@@ -1227,7 +1229,7 @@ function eventSourceToString(eventSource: number): InputSource {
|
||||
return "ring";
|
||||
}
|
||||
|
||||
export function inputEventToString(event: DashboardInputEvent): string {
|
||||
export function inputEventToString(event: InputEvent): string {
|
||||
switch (event.type) {
|
||||
case "click":
|
||||
return `Click from ${event.source}`;
|
||||
|
||||
@@ -3,7 +3,8 @@ import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { wrapText } from "../../graphics/textwrap";
|
||||
import { clamp } from "../../util/numeric-util";
|
||||
import type { ToolDebugEntry } from "../../assistant/tool-registry";
|
||||
import { DashboardInputEvent, Layer, LayerContext, PaintBelow } from "../layers";
|
||||
import { InputEvent } from "../gestures";
|
||||
import { Layer, LayerContext, PaintBelow } from "../layers";
|
||||
import { MenuLayer, drawListScrollbar, type MenuItem } from "../menu";
|
||||
import { MIN_WINDOW_HEIGHT, minWindowTop, sidebarWidth, TOP_BAR_HEIGHT } from "./geometry";
|
||||
import { lineStep } from "../metrics";
|
||||
@@ -139,7 +140,7 @@ class ToolDetailLayer implements Layer {
|
||||
return lines;
|
||||
}
|
||||
|
||||
handleInput(event: DashboardInputEvent, ctx: LayerContext): void {
|
||||
handleInput(event: InputEvent, ctx: LayerContext): void {
|
||||
switch (event.type) {
|
||||
case "scroll-up":
|
||||
this.scrollRow = Math.max(0, this.scrollRow - 1);
|
||||
|
||||
@@ -5,10 +5,10 @@ import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { voiceControlBridge, type VoiceTranscriptEvent } from "../../native/voice-control";
|
||||
import { refineDictation, type AnthropicStreamHandle } from "../../native/anthropic";
|
||||
import { anthropicApiKeySetting } from "../dashboard-settings";
|
||||
import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK, gestureHints } from "../gestures";
|
||||
import { GESTURE_CLICK, GESTURE_DOUBLE_CLICK, gestureHints, type InputEvent } from "../gestures";
|
||||
import { drawSelectionHighlight } from "../menu";
|
||||
import { listRowHeight } from "../metrics";
|
||||
import { Layer, type DashboardInputEvent, type LayerActions, type LayerContext } from "../layers";
|
||||
import { Layer, type LayerActions, type LayerContext } from "../layers";
|
||||
import { MIN_WINDOW_HEIGHT, minWindowTop } from "./geometry";
|
||||
|
||||
const DIALOG_X = 40;
|
||||
@@ -273,7 +273,7 @@ export class VoiceInputLayer implements Layer {
|
||||
return image;
|
||||
}
|
||||
|
||||
handleInput(event: DashboardInputEvent, _ctx: LayerContext): void {
|
||||
handleInput(event: InputEvent, _ctx: LayerContext): void {
|
||||
switch (this.phase) {
|
||||
case "capturing":
|
||||
if (event.type === "double-click") {
|
||||
@@ -300,7 +300,7 @@ export class VoiceInputLayer implements Layer {
|
||||
}
|
||||
}
|
||||
|
||||
private handleMenuInput(event: DashboardInputEvent): void {
|
||||
private handleMenuInput(event: InputEvent): void {
|
||||
const rowCount = this.menuRows().length;
|
||||
switch (event.type) {
|
||||
case "scroll-up":
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
import { GrayImage } from "../graphics/image";
|
||||
import { singlePlane, type Plane } from "../graphics/plane";
|
||||
import {
|
||||
noopLayerActions,
|
||||
LayerStack,
|
||||
type DashboardInputEvent,
|
||||
type Layer,
|
||||
} from "./layers";
|
||||
import { type InputEvent } from "./gestures";
|
||||
import { type Layer, LayerStack, noopLayerActions } from "./layers";
|
||||
import { MenuLayer, type MenuItem, type MenuLayout } from "./menu";
|
||||
import type { WorkerAppReply } from "./shell/worker-window";
|
||||
|
||||
@@ -67,7 +63,7 @@ export class WindowMenu {
|
||||
}
|
||||
|
||||
/** Route an input event to the menu; the menu closes by popping itself. */
|
||||
async handleInput(event: DashboardInputEvent): Promise<void> {
|
||||
async handleInput(event: InputEvent): Promise<void> {
|
||||
const stack = this.stack;
|
||||
if (!stack) return;
|
||||
await stack.handleInput(event);
|
||||
|
||||
Reference in new issue
Block a user