Unify vertical position and display mode settings; add to onboarding

This commit is contained in:
James Babcock committed 2026-10-10 22:48:26 -07:00
1 parent 6b1e64c5ac
commit 5a9ca08921
36 files changed
+810 -574

No files matched your search

+109 -93
View File
@@ -329,49 +329,6 @@ export const timeFormatSetting = new ConfigSettingEnum<TimeFormat>({
description: "Whether the top-bar clock shows 24-hour or 12-hour time.",
});
/**
* How much of the 640x480 panel the UI uses. "576x288" is the stock band
* (sidebar + a 288px-tall window at the vertical position); "576x480" keeps
* the sidebar and gives every window the full height; "640x480" is the whole
* panel, with the sidebar an overlay that shows only while it has focus. The
* values name the sizes beside a side strip; with the app switcher along the
* bottom, the tall height loses the switcher row (displayModeLabel shows the
* actual size).
*/
export const DISPLAY_MODE_VALUES = ["576x288", "576x480", "640x480"] as const;
export type DisplayModeSetting = (typeof DISPLAY_MODE_VALUES)[number];
const DISPLAY_MODE_NAMES: Record<DisplayModeSetting, string> = {
"576x288": "Band",
"576x480": "Tall",
"640x480": "Full panel",
};
/** Window size per mode with the app switcher along the bottom (see geometry.ts). */
const BOTTOM_SWITCHER_SIZES: Record<DisplayModeSetting, string> = {
"576x288": "576×288",
"576x480": "576×444",
"640x480": "640×480",
};
export function displayModeLabel(value: DisplayModeSetting): string {
const name = DISPLAY_MODE_NAMES[value];
if (!name) return value;
const size = appSwitcherPositionSetting.get() === "bottom" ? BOTTOM_SWITCHER_SIZES[value] : value.replace("x", "×");
return `${name} · ${size}`;
}
export const displayModeSetting = new ConfigSettingEnum<DisplayModeSetting>({
id: "display-mode",
label: "Display mode",
storageKey: "display.mode",
defaultValue: "576x288",
values: DISPLAY_MODE_VALUES,
formatValue: displayModeLabel,
description:
"Band: the stock 288px-tall window beside the app switcher. Tall: the app switcher plus full-height windows. Full panel: the whole 640×480 display; the app switcher overlays the app only while you are in it. Open apps reopen in the new size.",
});
/**
* Where the app switcher (the open-window icons) sits: a strip along the
* left or right edge of the display, a row under the window, or a popup box
@@ -397,6 +354,83 @@ export const appSwitcherPositionSetting = new ConfigSettingEnum<AppSwitcherPosit
"Where the open-app icons go. Left and right take a column beside windows; bottom puts a row beneath the window, which makes full-height windows a little shorter; popup shows them only while you're in the app switcher, in a box over the dimmed window. Bottom and popup leave room at the sides to set the display's depth. Open apps reopen at their new size when a change resizes windows.",
});
/**
* An enum setting that took over from older settings: until it is first
* set, its value is derived from theirs.
*/
class ConfigSettingEnumWithLegacy<TValue extends string> extends ConfigSettingEnum<TValue> {
constructor(options: ConfigSettingEnumOptions<TValue, string>, private readonly legacyValue: () => TValue) {
super(options);
}
get(): TValue {
return getStringSetting(this.storageKey, "") === "" ? this.legacyValue() : super.get();
}
}
/**
* How much of the 640x480 panel windows use, and where: the stock
* 288px-tall band, at one of five heights in the field of view; Tall, every
* window the full height; or Full Screen, Tall at the panel's whole 640px
* width. The app switcher keeps its own room in every mode. Full Screen
* needs a bottom row or popup app switcher (a side strip leaves no width to
* spare; there it is Tall), has no window frame, and plays at depth 0,
* since its windows reach the panel's edges (geometry.ts).
*/
export const DISPLAY_LAYOUT_VALUES = [
"band-top", "band-high", "band-middle", "band-low", "band-bottom", "tall", "fullscreen",
] as const;
export type DisplayLayout = (typeof DISPLAY_LAYOUT_VALUES)[number];
const DISPLAY_LAYOUT_LABELS: Record<DisplayLayout, string> = {
"band-top": "Band · Top",
"band-high": "Band · High",
"band-middle": "Band · Middle",
"band-low": "Band · Low",
"band-bottom": "Band · Bottom",
tall: "Tall",
fullscreen: "Full Screen",
};
export function displayLayoutLabel(value: DisplayLayout): string {
return DISPLAY_LAYOUT_LABELS[value] ?? value;
}
/** Whether the Full Screen display mode is available: with a bottom row or popup app switcher. */
export function fullScreenAvailable(): boolean {
const position = appSwitcherPositionSetting.get();
return position === "bottom" || position === "popup";
}
// Until 2026-10-10 the display mode ("576x288" band, "576x480" tall,
// "640x480" full panel) and the band's vertical position were separate
// settings, globally and per app.
const LEGACY_MODE_LAYOUTS: Record<string, DisplayLayout> = { "576x480": "tall", "640x480": "fullscreen" };
const LEGACY_POSITION_LAYOUTS: Record<string, DisplayLayout> = {
top: "band-top", upper: "band-high", middle: "band-middle", lower: "band-low", bottom: "band-bottom",
};
function legacyBand(position: string): DisplayLayout {
return LEGACY_POSITION_LAYOUTS[position] ?? "band-middle";
}
function legacyDisplayLayout(): DisplayLayout {
const mode = getStringSetting("display.mode", "576x288");
return LEGACY_MODE_LAYOUTS[mode] ?? legacyBand(getStringSetting("display.verticalPosition", "middle"));
}
export const displayLayoutSetting = new ConfigSettingEnumWithLegacy<DisplayLayout>({
id: "display-mode",
label: "Display mode",
storageKey: "display.layout",
defaultValue: "band-middle",
values: DISPLAY_LAYOUT_VALUES,
formatValue: displayLayoutLabel,
isDisabled: (value) => value === "fullscreen" && !fullScreenAvailable(),
description:
"Band: the stock 288px-tall window, at the height in your field of view you choose. Tall: full-height windows. Full Screen: full-height windows across the display's whole width; it needs the app switcher at the bottom or as a popup, and turns depth off, since windows reach the display's edges. Navigate and Terminal can override this. Open apps reopen in the new size.",
}, legacyDisplayLayout);
const UI_DEPTH_VALUES = ["-62", "-48", "-32", "-16", "0", "16", "32", "48", "62"] as const;
export type UiDepth = (typeof UI_DEPTH_VALUES)[number];
@@ -406,8 +440,9 @@ export type UiDepth = (typeof UI_DEPTH_VALUES)[number];
* directions. Only applies with the app switcher at the bottom or a popup,
* where the windows' 576px width leaves 32px at each side: one for the side
* of the window's frame and 31 to shift into, hence ±62 (see geometry.ts
* uiDepth and windowFramed); values stay even so the per-lens halves of
* nested depths add exactly.
* uiDepth and windowFramed); not to Full Screen windows, which have no such
* margins. Values stay even so the per-lens halves of nested depths add
* exactly.
*/
export const uiDepthSetting = new ConfigSettingEnum<UiDepth>({
id: "ui-depth",
@@ -420,7 +455,7 @@ export const uiDepthSetting = new ConfigSettingEnum<UiDepth>({
return depth === 0 ? "0" : depth > 0 ? `+${depth} (nearer)` : `${depth} (farther)`;
},
description:
"Moves the whole display nearer (positive) or farther away (negative) by shifting it in opposite directions on the two lenses. Available with the app switcher at the bottom or as a popup. Full-panel windows lose a sliver at the edges.",
"Moves the whole display nearer (positive) or farther away (negative) by shifting it in opposite directions on the two lenses. Available with the app switcher at the bottom or as a popup; not applied in the Full Screen display mode, whose windows reach the display's edges.",
});
/**
@@ -443,7 +478,7 @@ export const statusBarPositionSetting = new ConfigSettingEnum<StatusBarPosition>
formatValue: (value) => value === "top" ? "Top"
: appSwitcherPositionSetting.get() === "bottom" ? "With app switcher" : "Bottom",
description:
"Where the clock, notification icons, app widgets and battery indicators go. With the app switcher at the bottom, With app switcher puts them at the right end of its row, and windows grow into the top bar's space; with a popup app switcher, Bottom puts them under the window. Available with the app switcher at the bottom or as a popup; with a bottom app switcher, the full-panel display mode keeps the top bar. Changing it reopens open apps in the new size.",
"Where the clock, notification icons, app widgets and battery indicators go. With the app switcher at the bottom, With app switcher puts them at the right end of its row, and windows grow into the top bar's space; with a popup app switcher, Bottom puts them under the window. Available with the app switcher at the bottom or as a popup. Changing it reopens open apps in the new size.",
});
/**
@@ -629,60 +664,41 @@ export const watchMirrorAssistantSetting = new ConfigSettingBoolean({
description: "Stream assistant replies and on-glasses alerts to the watch so they can be read from the wrist.",
});
export type VerticalPosition = "top" | "upper" | "middle" | "lower" | "bottom";
/**
* A per-app display mode (Navigate, Terminal): the global one ("global"),
* Terminal's own default ("default": tall sessions, the sessions list at
* the global mode), or a mode of its own.
*/
export type AppDisplayLayout = "default" | "global" | DisplayLayout;
const VERTICAL_POSITION_LABELS: Record<VerticalPosition, string> = {
top: "Top",
upper: "Upper",
middle: "Middle",
lower: "Lower",
bottom: "Bottom",
};
function legacyAppDisplayLayout(appId: string, defaultValue: AppDisplayLayout): AppDisplayLayout {
const mode = getStringSetting(`${appId}.displayMode`, defaultValue);
const position = getStringSetting(`${appId}.verticalPosition`, "global");
if (LEGACY_MODE_LAYOUTS[mode]) return LEGACY_MODE_LAYOUTS[mode];
const global = displayLayoutSetting.get();
if (mode === "576x288") return position === "global" ? (global.startsWith("band-") ? global : legacyDisplayLayout()) : legacyBand(position);
// Following the global mode at a band position of its own.
if (mode === "global" && position !== "global" && global.startsWith("band-")) return legacyBand(position);
return mode === "default" || mode === "global" ? mode : defaultValue;
}
export const verticalPositionSetting = new ConfigSettingEnum<VerticalPosition>({
id: "vertical-position",
label: "Vertical position",
storageKey: "display.verticalPosition",
defaultValue: "middle",
values: ["top", "upper", "middle", "lower", "bottom"],
formatValue: (value) => VERTICAL_POSITION_LABELS[value] ?? value,
description:
"Where standard (reduced-height) windows sit vertically within the display area, to position them within your field of view. Full-height windows use the whole screen. Navigate and Terminal can override these display settings.",
});
/** Per-app layouts can inherit the display preferences or choose their own size. */
export type AppDisplayMode = "default" | "global" | DisplayModeSetting;
function appDisplayModeSetting(appId: string, defaultValue: AppDisplayMode): ConfigSettingEnum<AppDisplayMode> {
return new ConfigSettingEnum<AppDisplayMode>({
function appDisplayLayoutSetting(appId: string, defaultValue: AppDisplayLayout): ConfigSettingEnum<AppDisplayLayout> {
return new ConfigSettingEnumWithLegacy<AppDisplayLayout>({
id: `${appId}-display-mode`,
label: "Display mode",
storageKey: `${appId}.displayMode`,
storageKey: `${appId}.displayLayout`,
defaultValue,
values: appId === "terminal" ? ["default", "global", ...DISPLAY_MODE_VALUES] : ["global", ...DISPLAY_MODE_VALUES],
formatValue: (value) => value === "default" ? "Tall sessions (default)" : value === "global" ? "Use global" : displayModeLabel(value),
values: appId === "terminal" ? ["default", "global", ...DISPLAY_LAYOUT_VALUES] : ["global", ...DISPLAY_LAYOUT_VALUES],
formatValue: (value) => value === "default" ? "Tall sessions (default)" : value === "global" ? "Use global" : displayLayoutLabel(value),
isDisabled: (value) => value === "fullscreen" && !fullScreenAvailable(),
description: appId === "terminal"
? "Screen size for Terminal. The default keeps session windows tall and the terminals list at the global size. Use global follows Display settings for all Terminal windows. Resizing an open session reconnects its view at the new size."
: "Screen size for Navigate. Choose Band to leave more of your field of view clear, or Use global to follow Display settings. Applies to the current route too.",
});
? "Display mode for Terminal. The default keeps session windows tall and the terminals list in the global mode. Use global follows Display settings for all Terminal windows. Resizing an open session reconnects its view at the new size."
: "Display mode for Navigate. Choose a Band to leave more of your field of view clear, or Use global to follow Display settings. Applies to the current route too.",
}, () => legacyAppDisplayLayout(appId, defaultValue));
}
function appVerticalPositionSetting(appId: string): ConfigSettingEnum<"global" | VerticalPosition> {
return new ConfigSettingEnum<"global" | VerticalPosition>({
id: `${appId}-vertical-position`,
label: "Vertical position",
storageKey: `${appId}.verticalPosition`,
defaultValue: "global",
values: ["global", "top", "upper", "middle", "lower", "bottom"],
formatValue: (value) => value === "global" ? "Use global" : VERTICAL_POSITION_LABELS[value],
description: "Where reduced-height windows for this app sit in your field of view. Use global follows Display settings. Full-height windows fill the display vertically.",
});
}
export const navigateDisplayModeSetting = appDisplayModeSetting("navigate", "global");
export const navigateVerticalPositionSetting = appVerticalPositionSetting("navigate");
export const terminalDisplayModeSetting = appDisplayModeSetting("terminal", "default");
export const terminalVerticalPositionSetting = appVerticalPositionSetting("terminal");
export const navigateDisplayLayoutSetting = appDisplayLayoutSetting("navigate", "global");
export const terminalDisplayLayoutSetting = appDisplayLayoutSetting("terminal", "default");
export type { DataCollectionLevel };
+4 -7
View File
@@ -51,7 +51,7 @@ import {
phoneBatteryVisibilitySetting,
ringBatteryVisibilitySetting,
watchBatteryVisibilitySetting,
displayModeSetting,
displayLayoutSetting,
elevenLabsApiKeySetting,
mapboxApiKeySetting,
mirrorTouchSetting,
@@ -72,7 +72,6 @@ import {
timeFormatSetting,
toggleSettingMenuItem,
useMicControlSetting,
verticalPositionSetting,
voiceProviderSetting,
screenTimeoutSetting,
wakeWordActionSetting,
@@ -106,11 +105,9 @@ function settingsSections(): SettingsSection[] {
},
}),
toggleSettingMenuItem(lockScreenEnabledSetting),
// Where min-height windows (and the sidebar) sit vertically on the
// screen; the dashboard controller repositions surfaces on change.
enumSettingMenuItem(verticalPositionSetting),
// Band / tall / full-panel; the dashboard controller reflows windows.
enumSettingMenuItem(displayModeSetting),
// A band (at one of five heights) / Tall / Full Screen; the
// dashboard controller moves or reflows windows on change.
enumSettingMenuItem(displayLayoutSetting),
],
},
{
+8 -8
View File
@@ -27,7 +27,7 @@ import { scrollToKeepSelectionVisible } from "../menu";
import { lineStep } from "../metrics";
import {
appViewportRect,
isFullscreen,
isImmersive,
MIN_WINDOW_HEIGHT,
minWindowTop,
SHELL_OPAQUE_BLACK,
@@ -251,7 +251,7 @@ export function sidebarContentSpan(windowCount: number): { left: number; right:
/**
* Horizontal extent of the top bar: the foreground window's, short of a side
* strip overlaid on it (full-panel mode, sidebar focused).
* strip overlaid on it (an immersive window, sidebar focused).
*/
function topBarSpan(state: ShellChromeState): { left: number; right: number } {
const viewport = appViewportRect(state.foregroundHeightMode, state.foregroundAppId);
@@ -276,7 +276,7 @@ type StatusBarPlacement = { left: number; right: number; top: number; contentTop
/**
* The status bar's placement for the foreground window, or null when it
* isn't drawn as a bar: when the window is fullscreen, when it shares a
* isn't drawn as a bar: when the window is immersive, when it shares a
* bottom switcher row, or when it overlays the window (geometry.ts
* statusBarOverlays) and the popup switcher isn't up. An overlaying bar
* sits inside a window frame, whose side runs along its outer row, so it
@@ -284,7 +284,7 @@ type StatusBarPlacement = { left: number; right: number; top: number; contentTop
*/
function statusBarPlacement(state: ShellChromeState): StatusBarPlacement | null {
const appId = state.foregroundAppId;
if (isFullscreen(appId) || statusInSwitcherRow(appId)) return null;
if (isImmersive(appId) || statusInSwitcherRow(appId)) return null;
const overlays = statusBarOverlays();
if (overlays && !sidebarStripVisible(state.focus, appId)) return null;
const { left, right } = topBarSpan(state);
@@ -433,9 +433,9 @@ export class ShellChromeLayer implements Layer {
this.notificationEntries = [];
const statusInRow = statusInSwitcherRow(state.foregroundAppId);
const popup = switcherPosition() === "popup";
// Full-panel mode: the strip is an overlay, present only while the user
// is in it (the window underneath keeps its full width the rest of the
// time); a popup only ever shows then.
// Over an immersive window the strip is an overlay, present only while
// the user is in it (the window underneath keeps the whole panel the
// rest of the time); a popup only ever shows then.
const switcherShown = sidebarStripVisible(state.focus, state.foregroundAppId);
if (switcherShown && !popup) {
this.drawSidebar(image, state, statusInRow ? image : undefined);
@@ -744,7 +744,7 @@ export class ShellChromeLayer implements Layer {
// edge of the foreground window's band, wherever its height mode puts
// that (screen top for max height). It moves when the foreground
// switches to a window of a different height. It spans the app viewport;
// with a side strip overlaid (full-panel mode, sidebar focused) it still
// with a side strip overlaid (an immersive window, sidebar focused) it still
// stops at the strip.
const { left: barLeft, right: barRight } = bar;
image.fillRect(barLeft, bar.top, barRight - barLeft, TOP_BAR_HEIGHT, SHELL_OPAQUE_BLACK);
+94 -86
View File
@@ -2,13 +2,10 @@ import { G2_LENS_HEIGHT, G2_LENS_WIDTH } from "../../graphics/image";
import {
appSwitcherPositionSetting,
type AppSwitcherPosition,
displayModeSetting,
type DisplayModeSetting,
verticalPositionSetting,
navigateDisplayModeSetting,
navigateVerticalPositionSetting,
terminalDisplayModeSetting,
terminalVerticalPositionSetting,
displayLayoutSetting,
type DisplayLayout,
navigateDisplayLayoutSetting,
terminalDisplayLayoutSetting,
statusBarPositionSetting,
statusBarVisibilitySetting,
uiDepthSetting,
@@ -21,9 +18,10 @@ export const TOP_BAR_HEIGHT = 28;
* Width of the sidebar strip as painted (the app switcher on the left or
* right edge). App windows get the other 576px — the surface width EvenHub
* apps expect — and keep that width with the switcher at the bottom or a
* popup too, except in the full-panel display mode, where the switcher
* overlays the app (see sidebarWidth). Icon column layout within the strip
* (one wide column vs. two narrow ones) is the chrome layer's business.
* popup too, except in the Full Screen display mode (640 wide; never beside
* a strip) and immersive windows, which the switcher overlays (see
* sidebarWidth). Icon column layout within the strip (one wide column vs.
* two narrow ones) is the chrome layer's business.
*/
export const SIDEBAR_WIDTH = 64;
@@ -34,7 +32,8 @@ export const SIDEBAR_WIDTH = 64;
* two-column icons. It comes out of the height available to windows; their
* width stays 576, centred, leaving SIDEBAR_WIDTH / 2 at each side: one
* pixel for the side of the window's frame (windowFramed), the rest for the
* whole display's stereo shift (uiDepth).
* whole display's stereo shift (uiDepth). Full Screen windows take those
* margins too, giving up both.
*/
export const SWITCHER_ROW_HEIGHT = 36;
@@ -49,72 +48,89 @@ function sideStrip(): boolean {
return position === "left" || position === "right";
}
/** The Display > Display mode setting (see dashboard-settings.ts). */
function appDisplayMode(appId?: string) {
return appId === "navigate" ? navigateDisplayModeSetting.get()
: appId === "terminal" ? terminalDisplayModeSetting.get() : "default";
}
export function displayMode(appId?: string): DisplayModeSetting {
const mode = appDisplayMode(appId);
return mode === "global" || mode === "default" ? displayModeSetting.get() : mode;
/** An app's own Display mode setting (Navigate, Terminal); "default" for the rest. */
function appDisplayLayout(appId?: string) {
return appId === "navigate" ? navigateDisplayLayoutSetting.get()
: appId === "terminal" ? terminalDisplayLayoutSetting.get() : "default";
}
/**
* Apps whose windows are fullscreen right now: the whole panel, with no
* status bar, window frame or room kept for the switcher (which overlays
* them only while it has focus, as in the full-panel mode), at depth 0. An
* app switches it at runtime (InProcessWindow.setFullscreen; the onboarding's
* first pages), so it is per app, like the per-app display modes.
* The display mode an app's windows use (see dashboard-settings.ts
* DisplayLayout): its own, or the global one. Full Screen needs the width a
* side strip takes, so beside one it is Tall.
*/
const fullscreenApps = new Set<string>();
export function displayLayout(appId?: string): DisplayLayout {
const own = appDisplayLayout(appId);
const layout = own === "global" || own === "default" ? displayLayoutSetting.get() : own;
return layout === "fullscreen" && sideStrip() ? "tall" : layout;
}
/** Mark an app's windows fullscreen or not; true if that changed anything. */
export function setAppFullscreen(appId: string, fullscreen: boolean): boolean {
if (fullscreenApps.has(appId) === fullscreen) return false;
if (fullscreen) fullscreenApps.add(appId);
else fullscreenApps.delete(appId);
/** Fraction of the slack above a window band in each band display mode. */
const BAND_FRACTIONS: Partial<Record<DisplayLayout, number>> = {
"band-top": 0,
"band-high": 0.25,
"band-middle": 0.5,
"band-low": 0.75,
"band-bottom": 1,
};
/** A band display mode's fraction of the slack above the band; undefined for Tall and Full Screen. */
function bandFraction(layout: DisplayLayout): number | undefined {
return BAND_FRACTIONS[layout];
}
/**
* Apps whose windows are immersive right now: the whole panel, with no
* status bar, window frame or room kept for the switcher (which overlays
* them only while it has focus), at depth 0. An app switches it at runtime
* (InProcessWindow.setImmersive; the onboarding's first pages), so it is
* per app, like the per-app display modes.
*/
const immersiveApps = new Set<string>();
/** Mark an app's windows immersive or not; true if that changed anything. */
export function setAppImmersive(appId: string, immersive: boolean): boolean {
if (immersiveApps.has(appId) === immersive) return false;
if (immersive) immersiveApps.add(appId);
else immersiveApps.delete(appId);
return true;
}
export function isFullscreen(appId?: string): boolean {
return appId !== undefined && fullscreenApps.has(appId);
export function isImmersive(appId?: string): boolean {
return appId !== undefined && immersiveApps.has(appId);
}
/**
* The full-panel mode (or a fullscreen app): windows fill the panel; the
* switcher overlays them only while it has focus.
*/
function fullPanel(appId?: string): boolean {
return isFullscreen(appId) || displayMode(appId) === "640x480";
/** Whether an app's windows span the panel's whole width: Full Screen, or immersive. */
function fullWidth(appId?: string): boolean {
return isImmersive(appId) || displayLayout(appId) === "fullscreen";
}
/**
* How much of the screen's width the sidebar takes away from app windows:
* the strip, or nothing when the switcher is a bottom row or a popup or in
* the full-panel mode (where the chrome paints the strip over the window
* the strip, or nothing when the switcher is a bottom row or a popup or the
* window is immersive (where the chrome paints the strip over the window
* while the sidebar has focus).
*/
export function sidebarWidth(appId?: string): number {
return !fullPanel(appId) && sideStrip() ? SIDEBAR_WIDTH : 0;
return !isImmersive(appId) && sideStrip() ? SIDEBAR_WIDTH : 0;
}
/**
* How much of the screen's height a bottom switcher row takes away from app
* windows: the row, or nothing beside a side strip or in the full-panel mode
* (where the row overlays the window's bottom edge while it has focus).
* windows: the row, or nothing beside a side strip or under an immersive
* window (where the row overlays the window's bottom edge while it has
* focus).
*/
export function switcherRowHeight(appId?: string): number {
return !fullPanel(appId) && switcherPosition() === "bottom" ? SWITCHER_ROW_HEIGHT : 0;
return !isImmersive(appId) && switcherPosition() === "bottom" ? SWITCHER_ROW_HEIGHT : 0;
}
/**
* Whether the switcher is on screen: always when it reserves room; as a
* popup, or in the full-panel mode (where it overlays the window), only
* while it has focus.
* popup, or over an immersive window, only while it has focus.
*/
export function sidebarStripVisible(focus: "sidebar" | "window", appId?: string): boolean {
return (!fullPanel(appId) && switcherPosition() !== "popup") || focus === "sidebar";
return (!isImmersive(appId) && switcherPosition() !== "popup") || focus === "sidebar";
}
/**
@@ -122,8 +138,8 @@ export function sidebarStripVisible(focus: "sidebar" | "window", appId?: string)
* band (like the shell overlays). A bottom row sits right under the given
* (foreground) window and spans its width, so a band shorter than the
* screen has no gap below it; it moves when the foreground switches to a
* window of another height, as the top bar does. In the full-panel mode the
* row overlays the bottom edge of the screen. A popup's is the area it
* window of another height, as the top bar does. Over an immersive window
* the row overlays the bottom edge of the screen. A popup's is the area it
* centres in, the foreground window's content (the chrome layer sizes the
* box itself).
*/
@@ -150,9 +166,9 @@ export function switcherRect(heightMode: WindowHeightMode, appId?: string): { x:
/**
* 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 in the full-panel mode, nor need
* beside a side strip. With a reserved bottom switcher row it always has
* one: the row's top edge is the frame's bottom side, as the window
* 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
@@ -161,9 +177,9 @@ export function switcherRect(heightMode: WindowHeightMode, appId?: string): { x:
export function windowFramed(appId?: string): boolean {
switch (switcherPosition()) {
case "bottom":
return switcherRowHeight(appId) > 0;
return switcherRowHeight(appId) > 0 && !fullWidth(appId);
case "popup":
return !fullPanel(appId) && windowBorderSetting.get();
return !fullWidth(appId) && windowBorderSetting.get();
default:
return false;
}
@@ -172,7 +188,8 @@ export function windowFramed(appId?: string): boolean {
/**
* Whether the status bar shares the bottom switcher row instead of topping
* each window (Settings > Customization > Status bar position): only beside
* a reserved row, as the full-panel mode's row shows just while it has focus.
* a reserved row, as the row over an immersive window shows just while it
* has focus.
*/
export function statusInSwitcherRow(appId?: string): boolean {
return switcherRowHeight(appId) > 0 && statusBarPositionSetting.get() === "bottom";
@@ -200,12 +217,13 @@ export function statusBarOverlays(): boolean {
* Rows the shell draws along one edge of each window's content: the status
* bar's (the top bar, as a header), the frame's side, or none. A bottom
* switcher row's band has no footer: the frame's bottom side is the row's
* top edge. A fullscreen window has neither.
* top edge. An immersive window has neither.
*/
function windowEdgeHeight(edge: "top" | "bottom", appId?: string): number {
if (isFullscreen(appId)) return 0;
if (isImmersive(appId)) return 0;
if (switcherPosition() !== "popup") {
return edge === "bottom" ? 0 : statusInSwitcherRow(appId) ? 1 : TOP_BAR_HEIGHT;
if (edge === "bottom") return 0;
return !statusInSwitcherRow(appId) ? TOP_BAR_HEIGHT : windowFramed(appId) ? 1 : 0;
}
if (!statusBarOverlays() && statusBarEdge() === edge) return TOP_BAR_HEIGHT;
return windowFramed(appId) ? 1 : 0;
@@ -258,9 +276,9 @@ export function isOnSwitcherEdge(x: number, y: number, heightMode: WindowHeightM
}
}
/** Width of app windows: the panel's in the full-panel mode, else 576 (see SIDEBAR_WIDTH). */
/** Width of app windows: the panel's when Full Screen or immersive, else 576 (see SIDEBAR_WIDTH). */
function appViewportWidth(appId?: string): number {
return fullPanel(appId) ? G2_LENS_WIDTH : G2_LENS_WIDTH - SIDEBAR_WIDTH;
return fullWidth(appId) ? G2_LENS_WIDTH : G2_LENS_WIDTH - SIDEBAR_WIDTH;
}
/**
@@ -269,7 +287,7 @@ function appViewportWidth(appId?: string): number {
* edge.
*/
export function appViewportLeft(appId?: string): number {
if (fullPanel(appId)) return 0;
if (fullWidth(appId)) return 0;
switch (switcherPosition()) {
case "left":
return SIDEBAR_WIDTH;
@@ -287,20 +305,22 @@ export function appViewportLeft(appId?: string): number {
* which shifts the screen and everything drawn over it per lens. Only with
* the switcher at the bottom or a popup, where the windows' side margins,
* less the window frame's pixel, leave room for the shift; not while the
* given (foreground) app is fullscreen, which has no margins.
* given (foreground) app's windows are Full Screen or immersive, which have
* no margins.
*/
export function uiDepth(appId?: string): number {
return sideStrip() || isFullscreen(appId) ? 0 : Number(uiDepthSetting.get());
return sideStrip() || fullWidth(appId) ? 0 : Number(uiDepthSetting.get());
}
/**
* Explicit app sizes (including Use global) replace the requested height.
* The default keeps legacy per-window heights, such as tall terminal sessions.
* A fullscreen app is always the whole height.
* In a band display mode, explicit app modes (including Use global) replace
* the requested height; the default keeps legacy per-window heights, such
* as tall terminal sessions. Tall, Full Screen and immersive windows are
* always the whole height.
*/
export function effectiveHeightMode(mode: WindowHeightMode, appId?: string): WindowHeightMode {
if (isFullscreen(appId)) return "max";
return displayMode(appId) === "576x288" ? (appDisplayMode(appId) === "default" ? mode : "min") : "max";
if (isImmersive(appId) || bandFraction(displayLayout(appId)) === undefined) return "max";
return appDisplayLayout(appId) === "default" ? mode : "min";
}
/**
@@ -355,25 +375,13 @@ export function windowBandHeight(mode: WindowHeightMode, appId?: string): number
}
/**
* Fraction of the slack above a window band, from the Display > Vertical
* position setting: each band height distributes its own free space by the
* same fraction, so all heights sit consistently within the screen.
* Fraction of the slack above a window band, from the band display mode's
* position: each band height distributes its own free space by the same
* fraction, so all heights sit consistently within the screen. Tall and
* Full Screen windows leave no slack.
*/
function verticalPositionFraction(appId?: string): number {
const position = appId === "navigate" ? navigateVerticalPositionSetting.get()
: appId === "terminal" ? terminalVerticalPositionSetting.get() : "global";
switch (position === "global" ? verticalPositionSetting.get() : position) {
case "top":
return 0;
case "upper":
return 0.25;
case "lower":
return 0.75;
case "bottom":
return 1;
default:
return 0.5;
}
return bandFraction(displayLayout(appId)) ?? 0.5;
}
/**
+11 -11
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, setAppFullscreen, type WindowHeightMode } from "./geometry";
import { appViewportSize, setAppImmersive, type WindowHeightMode } from "./geometry";
import { shell, type ShellWindow } from "./shell";
/**
@@ -30,8 +30,8 @@ export type InProcessWindowOptions = {
closeable: boolean;
/** Window height: the standard 288px band ("min", default) or full screen ("max"). */
heightMode?: WindowHeightMode;
/** Open fullscreen: the whole panel, without the status bar (see geometry.ts isFullscreen). */
fullscreen?: boolean;
/** Open immersive: the whole panel, without the status bar (see geometry.ts isImmersive). */
immersive?: boolean;
/**
* The window's tap-then-hold context menu: app-specific entries only (the
* shared Focus app switcher / Voice input / Close window entries live in
@@ -76,11 +76,11 @@ export type InProcessWindow = {
/** Change the window's height band at runtime (resizes the viewport + surface). */
setHeightMode: (mode: WindowHeightMode) => void;
/**
* Enter or leave fullscreen at runtime (resizes the viewport + surface).
* It is per app (geometry.ts isFullscreen), so an app with several
* Enter or leave immersive mode at runtime (resizes the viewport +
* surface). It is per app (geometry.ts isImmersive), so an app with several
* windows switches them all.
*/
setFullscreen: (fullscreen: boolean) => void;
setImmersive: (immersive: boolean) => void;
};
/** The controller-provided plumbing common to every in-process app window. */
@@ -110,7 +110,7 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
// Handed to app code as a bare callback, so it takes no arguments.
const requestRender = () => renderInNewFrame(0);
let heightMode = options.heightMode ?? "min";
setAppFullscreen(options.appId, options.fullscreen ?? false);
setAppImmersive(options.appId, options.immersive ?? false);
const viewportSize = () => appViewportSize(heightMode, options.appId);
const stack = new LayerStack(
options.baseLayer,
@@ -182,7 +182,7 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
hasAppMenu: () => appMenuItems().length > 0,
close: () => {
closed = true;
setAppFullscreen(options.appId, false);
setAppImmersive(options.appId, false);
// Fire onRemoved for any pushed layers so they release resources (e.g. a
// demo that enabled a hardware stream) even when closed from within.
stack.clearToBase();
@@ -248,10 +248,10 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
window.heightMode = mode;
resize();
};
const setFullscreen = (fullscreen: boolean) => {
if (!closed && setAppFullscreen(options.appId, fullscreen)) resize();
const setImmersive = (immersive: boolean) => {
if (!closed && setAppImmersive(options.appId, immersive)) resize();
};
return { window, stack, requestRender, setHeightMode, setFullscreen };
return { window, stack, requestRender, setHeightMode, setImmersive };
}
/**
+2 -2
View File
@@ -271,7 +271,7 @@ class ShellOverlayMenuLayer extends MenuLayer {
// Aligned to the min-height window band (like the sidebar), wherever the
// vertical position setting currently puts it; centered over the
// application area, i.e. the part of the screen beside a side strip
// (the whole width with a bottom row, or in the full-panel mode, where
// (the whole width with a bottom row, or over an immersive window, where
// the strip overlays).
const width = 272;
const area = appViewportRect("min");
@@ -832,7 +832,7 @@ class Shell {
/**
* Paint the shell surface: transparent chrome, or all-transparent when
* asleep. The scene also carries the whole display's stereo depth (none
* under a fullscreen window).
* under a Full Screen or immersive window).
*/
paintScene(): Uint8Array {
return this.screenOn