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

+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