[verified] merge upstream c162c8e6 into all-features

This commit is contained in:
MasterControl committed 2026-11-14 23:24:08 +00:00
commit 5790e98d27
176 files changed
+5311 -2307

No files matched your search

+27 -9
View File
@@ -38,6 +38,7 @@ import {
SHELL_OPAQUE_BLACK,
SIDEBAR_WIDTH,
sidebarStripVisible,
statusBarDivider,
statusBarEdge,
statusBarOverlays,
statusBarTop,
@@ -45,7 +46,9 @@ import {
SWITCHER_ROW_HEIGHT,
switcherPosition,
switcherRect,
switcherRowDivider,
TOP_BAR_HEIGHT,
windowBorder,
windowFooterHeight,
windowFramed,
windowHeaderHeight,
@@ -186,10 +189,19 @@ function switcherLayout(windowCount: number, heightMode: WindowHeightMode, appId
// Under a framed window the first window's cell (the launcher's) starts
// at the frame's left side, one pixel outside the window, so a selection
// tab there carries the side straight down (drawWindowFrame squares that
// corner for it). Scrolled past it, the cells keep the margin the left
// chevron needs. The count of slots stays the same either way. Only the
// first row's cells touch the separator; a second row's lines up under it.
const first = windowFramed(appId) && scrollRow === 0 ? row.x - 1 : row.x + LIST_MARGIN - 2;
// corner for it). With a border that isn't all around (geometry.ts
// windowBorder) it starts at the row's own end, in line with the
// window's edge. Scrolled past it, and under an unframed window whose
// border is all around (Full Screen, immersive), the cells keep the
// margin the left chevron needs. The count of slots stays the same
// either way. Only the first row's cells touch the separator; a second
// row's lines up under it. Where the row has no separator line
// (geometry.ts switcherRowDivider) none do, and every selection is a box.
const first = scrollRow > 0 ? row.x + LIST_MARGIN - 2
: windowFramed(appId) ? row.x - 1
: windowBorder() !== "all" ? row.x
: row.x + LIST_MARGIN - 2;
const divided = switcherRowDivider(appId);
return {
position,
iconSize: ROW_ICON_SIZE,
@@ -198,7 +210,7 @@ function switcherLayout(windowCount: number, heightMode: WindowHeightMode, appId
const line = (slot / columns) | 0;
return {
x: first + (slot % columns) * ROW_STEP, y: row.y + line * SWITCHER_ROW_HEIGHT,
width: ROW_ICON_SIZE + 4, height: SWITCHER_ROW_HEIGHT, atSeparator: line === 0,
width: ROW_ICON_SIZE + 4, height: SWITCHER_ROW_HEIGHT, atSeparator: divided && line === 0,
};
},
};
@@ -413,7 +425,8 @@ function topBarSpan(state: ShellChromeState): { left: number; right: number } {
* bar's layout starts in them: a row lower at the window's bottom, where
* the bar's first row is the one next to the window. `divider` is the row
* of the line between bar and window, or null where the window frame's side
* runs along it instead.
* runs along it instead, or the Border setting leaves the line out
* (geometry.ts statusBarDivider).
*/
type StatusBarPlacement = { left: number; right: number; top: number; contentTop: number; divider: number | null };
@@ -433,7 +446,8 @@ function statusBarPlacement(state: ShellChromeState): StatusBarPlacement | null
const { left, right } = topBarSpan(state);
const top = statusBarTop(state.foregroundHeightMode, appId);
const atBottom = statusBarEdge() === "bottom";
const divider = windowFramed(appId) && !overlays ? null : atBottom ? top : top + TOP_BAR_HEIGHT - 1;
const framedSide = windowFramed(appId) && !overlays;
const divider = framedSide || !statusBarDivider() ? null : atBottom ? top : top + TOP_BAR_HEIGHT - 1;
return { left, right, top, contentTop: atBottom ? top + 1 : top, divider };
}
@@ -1001,7 +1015,8 @@ export class ShellChromeLayer implements Layer {
// stops at the strip.
const { left: barLeft, right: barRight } = bar;
image.fillRect(barLeft, bar.top, barRight - barLeft, TOP_BAR_HEIGHT, SHELL_OPAQUE_BLACK);
// A framed window's frame draws this line as its side (drawWindowFrame).
// A framed window's frame draws this line as its side (drawWindowFrame);
// without any border there is none.
if (bar.divider !== null) {
image.drawLine(barLeft, bar.divider, barRight - 1, bar.divider, BORDER_VALUE);
}
@@ -1369,7 +1384,9 @@ const TAB_STROKE = 150;
/**
* Draw the switcher/main separator line along the strip's inner edge, with
* a gap where the selection tab `gap` diverts it.
* a gap where the selection tab `gap` diverts it. A bottom row has the line
* only where the Border setting gives it one (geometry.ts
* switcherRowDivider).
*/
function drawSeparator(
image: GrayImage,
@@ -1378,6 +1395,7 @@ function drawSeparator(
gap: SwitcherCell | null,
): void {
if (switcherPosition() === "bottom") {
if (!switcherRowDivider(state.foregroundAppId)) return;
// Along the row's top edge: the full width of the row, or between the
// corners of the window frame, whose bottom side this is.
// A selection tab at the frame's left side squares that corner (see
+74 -10
View File
@@ -10,8 +10,10 @@ import {
statusBarPositionSetting,
statusBarVisibilitySetting,
uiDepthSetting,
type WindowBorder,
windowBorderSetting,
} from "../dashboard-settings";
import { type EdgeKind, type Edges, uniformEdges, type Viewport, viewportWith } from "../viewport";
/** The paired glasses' screen, which the shell lays out in (graphics/screen-size.ts). */
export { screenHeight, screenWidth };
@@ -190,28 +192,59 @@ export function switcherRect(heightMode: WindowHeightMode, appId?: string): { x:
}
}
/**
* Which lines the chrome draws round the foreground window (Settings >
* Customization > Border): all of them, only the one between the window and
* the status bar, or none. The choice is a bottom or popup switcher's; a
* side strip always has its lines.
*/
export function windowBorder(): WindowBorder {
return sideStrip() ? "all" : windowBorderSetting.get();
}
/**
* Whether the foreground window's content gets a rounded frame (drawn by
* the chrome layer). Its left and right sides take the pixel just outside
* the 576-wide window; there's no room around a Full Screen or immersive
* window, nor need beside a side strip. With a reserved bottom switcher row
* it otherwise always has one: the row's top edge is the frame's bottom side, as the window
* header's last row is its top. With a popup switcher it's the Window
* border setting's choice, and its top and bottom take a header or footer
* row of their own, except where the status bar's row next to the window
* serves.
* the chrome layer): with every border line on (windowBorder), where
* there's room. Its left and right sides take the pixel just outside the
* 576-wide window; there's no room around a Full Screen or immersive
* window, nor need beside a side strip. With a reserved bottom switcher
* row, the row's top edge is the frame's bottom side, as the window
* header's last row is its top. With a popup switcher, its top and bottom
* take a header or footer row of their own, except where the status bar's
* row next to the window serves.
*/
export function windowFramed(appId?: string): boolean {
if (fullWidth(appId) || windowBorder() !== "all") return false;
switch (switcherPosition()) {
case "bottom":
return switcherRowHeight(appId) > 0 && !fullWidth(appId);
return switcherRowHeight(appId) > 0;
case "popup":
return !fullWidth(appId) && windowBorderSetting.get();
return true;
default:
return false;
}
}
/**
* Whether a line divides a status bar with rows of its own (the top bar, or
* a popup switcher's at the bottom) from the window. A window frame's side
* is that line where there is one (chrome-layer.ts statusBarPlacement).
*/
export function statusBarDivider(): boolean {
return windowBorder() !== "none";
}
/**
* Whether a line runs along a bottom switcher's top edge, between it and
* the window: a window frame's bottom side, or straight across where the
* window has no room for a frame. As the status line alone, only where the
* status bar shares the row.
*/
export function switcherRowDivider(appId?: string): boolean {
const border = windowBorder();
return border === "all" || (border === "status" && statusInSwitcherRow(appId));
}
/**
* Whether the status bar shares the bottom switcher row instead of topping
* each window (Settings > Customization > Status bar position): only beside
@@ -450,6 +483,37 @@ export function appViewportSize(mode: WindowHeightMode, appId?: string): { width
};
}
/**
* What each edge of an app's windows touches (see viewport.ts EdgeKind): a
* line the chrome draws right outside it, or nothing. A framed window has a
* line on every side. Otherwise the top or bottom has one where a status bar
* with rows of its own, or a bottom switcher row, lies past it and the
* Border setting divides the two; a side has one only beside a side strip,
* whose separator it is. An immersive window has the whole panel, and so
* none.
*/
export function windowEdges(appId?: string): Edges<EdgeKind> {
if (isImmersive(appId)) return uniformEdges("offscreen");
if (windowFramed(appId)) return uniformEdges("border");
const position = switcherPosition();
const line = (drawn: boolean): EdgeKind => (drawn ? "border" : "offscreen");
const statusLine = (edge: "top" | "bottom") => windowEdgeHeight(edge, appId) === TOP_BAR_HEIGHT && statusBarDivider();
return {
top: line(statusLine("top")),
right: line(position === "right"),
bottom: line(position === "bottom" ? switcherRowHeight(appId) > 0 && switcherRowDivider(appId) : statusLine("bottom")),
left: line(position === "left"),
};
}
/**
* A window's viewport as its layouts get it: the app-content size for its
* height mode, what its edges touch, and the padding suggested for them.
*/
export function appViewport(mode: WindowHeightMode, appId?: string): Viewport {
return viewportWith(appViewportSize(mode, appId), windowEdges(appId));
}
/** Screen rect of a window's app-content viewport (between its header and footer). */
export function appViewportRect(mode: WindowHeightMode, appId?: string): {
x: number;
+2 -2
View File
@@ -8,7 +8,7 @@ import { type MenuItem } from "../menu";
import { WindowMenuLayer } from "../window-menu";
import { windowIcon } from "./chrome-layer";
import { type IconName } from "../../graphics/icons";
import { appViewportSize, setAppImmersive, type WindowHeightMode } from "./geometry";
import { appViewport, setAppImmersive, type WindowHeightMode } from "./geometry";
import { shell, type ShellWindow } from "./shell";
/**
@@ -111,7 +111,7 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
const requestRender = () => renderInNewFrame(0);
let heightMode = options.heightMode ?? "min";
setAppImmersive(options.appId, options.immersive ?? false);
const viewportSize = () => appViewportSize(heightMode, options.appId);
const viewportSize = () => appViewport(heightMode, options.appId);
const stack = new LayerStack(
options.baseLayer,
{ ...options.actions, requestRender },
+8 -4
View File
@@ -4,6 +4,7 @@ import { flattenPlanes } from "../../graphics/plane";
import { InputEvent } from "../gestures";
import { Layer, LayerActions, LayerContext, LayerStack, PaintBelow } from "../layers";
import { appViewportRect, appViewportSize, SHELL_OPAQUE_BLACK } from "./geometry";
import { uniformEdges, type Viewport, viewportWith } from "../viewport";
// The modal box covers most of the min-height app viewport. Retained vector
// clears optionally hide the app outside its opaque rect. Size and position are
@@ -12,13 +13,16 @@ import { appViewportRect, appViewportSize, SHELL_OPAQUE_BLACK } from "./geometry
const MODAL_MARGIN = 14;
const MODAL_PADDING = 4;
/** Content (inner layer stack) size of the modal box. */
function modalInterior(): { width: number; height: number } {
/**
* The modal box's content (inner layer stack) viewport: every edge is just
* inside the box's border.
*/
function modalInterior(): Viewport {
const viewport = appViewportSize("min");
return {
return viewportWith({
width: viewport.width - 2 * MODAL_MARGIN - 2 * MODAL_PADDING,
height: Math.min(viewport.height - 2 * MODAL_MARGIN, Math.floor(65530 / Math.ceil((viewport.width - 2 * MODAL_MARGIN) / 2))) - 2 * MODAL_PADDING,
};
}, uniformEdges("border"));
}
/** Screen rect of the modal box, aligned to the min-height window band. */
+5 -4
View File
@@ -95,6 +95,7 @@ import {
screenWidth,
} from "./geometry";
import type { AppSwitcherPosition } from "../dashboard-settings";
import type { Viewport } from "../viewport";
/**
* The shell: owns the window registry, focus, screen on/off, and the shell
@@ -176,11 +177,11 @@ export type ShellWindow = {
*/
relayout?: () => void;
/**
* The viewport size the window is laid out at (it changes on relayout), so
* the controller can tell a window whose size fell behind the geometry from
* one whose surface merely moved.
* The viewport the window is laid out at (it changes on relayout), so the
* controller can tell a window whose size, or whose edges, fell behind the
* geometry from one whose surface merely moved.
*/
layoutSize?: () => { width: number; height: number };
layoutSize?: () => Viewport;
/**
* A touch from the phone's mirror at (x, y) in app-viewport coordinates.
* True if the window acted on it; otherwise the controller sends a select.
+8 -5
View File
@@ -3,7 +3,8 @@ import { GrayImage } from "../../graphics/image";
import { windowIcon } from "./chrome-layer";
import { type IconActivity, type IconName } from "../../graphics/icons";
import { toolRegistry, type ToolResult, type ToolSpec } from "../../assistant/tool-registry";
import { appViewportSize, type WindowHeightMode } from "./geometry";
import { appViewport, type WindowHeightMode } from "./geometry";
import { type Viewport } from "../viewport";
import * as frameTimings from "../../native/frame-timings";
import { shell, type ShellWindow } from "./shell";
import { publishWorkerState } from "./worker-state";
@@ -20,8 +21,10 @@ export type WorkerAppMessage =
/** Release app-wide resources, then acknowledge with worker-stopped. */
| { type: "shutdown" }
| { type: "navigation-sensors"; event: NavigationSensorEvent }
| { type: "open-window"; windowId: string; surfaceId: string; title: string; viewport: { width: number; height: number } }
| { type: "resize-window"; windowId: string; viewport: { width: number; height: number } }
/** `viewport` carries what the window's edges touch and the padding suggested for them (viewport.ts). */
| { type: "open-window"; windowId: string; surfaceId: string; title: string; viewport: Viewport }
/** The window's size changed, or what its edges touch did (so its padding). */
| { type: "resize-window"; windowId: string; viewport: Viewport }
| { type: "close-window"; windowId: string }
| { type: "input"; windowId: string; event: unknown; frameId: number; focused: boolean }
| { type: "text-input"; windowId: string; text: string; submit?: boolean }
@@ -462,7 +465,7 @@ export class WorkerAppHost {
const surfaceId = `window:${spec.windowId}`;
const heightMode = spec.heightMode ?? "min";
this.openWindows.add(spec.windowId);
let viewport = appViewportSize(heightMode, this.options.appId);
let viewport = appViewport(heightMode, this.options.appId);
this.post({
type: "open-window",
windowId: spec.windowId,
@@ -482,7 +485,7 @@ export class WorkerAppHost {
// (a game in progress, a route): the bottom switcher's height changes
// with what it holds, and full-height windows give way to it.
relayout: () => {
viewport = appViewportSize(window.heightMode, this.options.appId);
viewport = appViewport(window.heightMode, this.options.appId);
this.post({ type: "resize-window", windowId: spec.windowId, viewport });
},
layoutSize: () => viewport,