An open-source, self-hosted system for apps built with web technologies.
Release System 0.1.103 with one Window menu and per-view maximize
zohayrslileh383384a3ca75
diff --git a/package.json b/package.jsonindex 5c2bc21..7603898 100644--- a/package.json+++ b/package.json@@ -1,7 +1,7 @@{"name": "phreshos","displayName": "PhreshOS",- "version": "0.1.102",+ "version": "0.1.103","description": "The PhreshOS server, desktop, and authoritative system runtime.","type": "module","private": true,diff --git a/source/client/view/components/window-manager/window-geometry.ts b/source/client/view/components/window-manager/window-geometry.tsindex 8aa5e8c..4fe34a4 100644--- a/source/client/view/components/window-manager/window-geometry.ts+++ b/source/client/view/components/window-manager/window-geometry.ts@@ -166,6 +166,19 @@ export function shiftPosition(position: Position, views: ViewportOffset): Positireturn { x: shiftValue(position.x, views.x), y: shiftValue(position.y, views.y) }}+/** The whole view a Window's center is in, counted from the plane's center. */+export function viewOfGeometry(position: Position, size: Size, surface: WindowSurfaceSize): ViewportOffset {++ if (!surface.width || !surface.height) return { x: 0, y: 0 }++ const region = resolveWindowGeometry(position, size, surface)++ return {+ x: Math.round((region.x + region.width / 2 - surface.width / 2) / surface.width),+ y: Math.round((region.y + region.height / 2 - surface.height / 2) / surface.height)+ }+}+/** A point of the plane in pixels, recorded as the view it is in plus pixels within that view, so it keeps to its view on every Desktop. */export function recordedPosition(point: { x: number, y: number }, surface: WindowSurfaceSize): Position {diff --git a/source/client/view/structure/desktop/desktop.tsx b/source/client/view/structure/desktop/desktop.tsxindex de2b7f5..e6f15c4 100644--- a/source/client/view/structure/desktop/desktop.tsx+++ b/source/client/view/structure/desktop/desktop.tsx@@ -18,7 +18,7 @@ import { useProperty } from "@the-link/react"import SharedResizeBoundaries from "./windows/shared-resize-boundaries"import { programsRequirement } from "../readiness-requirements"import { LaunchPlacementContext, type LaunchPlacement } from "./launch-placement"-import { boundedGeometry, planeGeometry, recordedPosition, resolveWindowGeometry, shiftPosition, shownSize, type WindowRegion } from "@client/view/components/window-manager/window-geometry"+import { boundedGeometry, planeGeometry, recordedPosition, resolveWindowGeometry, shiftPosition, shownSize, viewOfGeometry, type WindowRegion } from "@client/view/components/window-manager/window-geometry"import { type MappedWindow } from "./layers/shell/taskbar/viewport/viewport-control"import type Process from "@client/core/link-manager/auth-manager/process-manager/process"import { type Layer, type Position, type Size } from "@phreshos/core"@@ -99,6 +99,22 @@ export default function Workspace() {return shown}+ // A maximized Window fills the whole view its geometry is in: shown where that view is from this one.+ const maximizedPositions = useMemo(() => new Map<string, Position>(), [views.x, views.y])++ function maximizedPosition(position: Position, size: Size) {++ const view = viewOfGeometry(position, size, windowSurfaceSize)++ const key = `${view.x},${view.y}`++ let shown = maximizedPositions.get(key)++ if (!shown) maximizedPositions.set(key, shown = shiftPosition({ x: "-1/2", y: "-1/2" }, { x: view.x - views.x, y: view.y - views.y }))++ return shown+ }+const move = useCallback(function (record: Process, x: number, y: number) {const recorded = shiftPosition({ x, y }, back)@@ -213,6 +229,8 @@ export default function Workspace() {maximized={presentation.maximized}+ maximizedPosition={presentation.layer === "window" ? maximizedPosition(bounded.position, bounded.size) : undefined}+interactive={presentation.interactive}closing={closing}@@ -257,9 +275,9 @@ export default function Workspace() {const taskbarOrientation = appearance.taskbar.position === "top" || appearance.taskbar.position === "bottom" ? "horizontal" : "vertical"- // Each standard Window where it is on the plane, for the map of views.+ // Each standard Window where it is on the plane, minimized or not, for the map of views.const mappedWindows: MappedWindow[] = windowSurfaceSize.width && windowSurfaceSize.height- ? windows.panesByLayer.window.filter(pane => !pane.presentation.minimized).map(({ identity, record, presentation }) => {+ ? windows.panesByLayer.window.filter(pane => !pane.closing).map(({ identity, record, presentation }) => {const shown = boundedGeometry(presentation.position, shownSize(presentation.size), windowSurfaceSize)@@ -271,7 +289,12 @@ export default function Workspace() {icon: icon(record),region,front: fronts.window?.identity === record.identity,+ minimized: presentation.minimized,+ maximized: presentation.maximized,show: () => show(record),+ bringHere: () => bringHere(record),+ toggleMinimized: () => toggleMinimized(record),+ fill: () => void windows.fill(record),close: () => focus.close(record),moveTo: center => {@@ -315,16 +338,52 @@ export default function Workspace() {const launchPlacement = useMemo<LaunchPlacement>(() => ({ place, reveal }), [place, reveal])// Going to a Window brings the view to it, so it is in the middle, whether it was minimized or only- // out of view, and brings it to the front. A maximized Window fills every view, so the view stays.+ // out of view, and brings it to the front. A maximized Window fills its view, so the view goes there.const show = useCallback(function (record: Process) {const window = windows.presentation.projection(record.identity)- if (window.layer === "window" && !window.maximized) reveal(window.position, window.size)+ if (window.layer === "window") {++ const shown = boundedGeometry(window.position, shownSize(window.size), windowSurfaceSize)++ if (window.maximized) viewport.moveTo(viewOfGeometry(shown.position, shown.size, windowSurfaceSize))++ else reveal(window.position, window.size)+ }windows.show(record)- }, [windows.presentation, windows.show, reveal])+ }, [windows.presentation, windows.show, reveal, viewport.moveTo, windowSurfaceSize])++ // Bringing a Window here moves it by whole views into the view on screen, so it keeps its place+ // within a view: a Window on the left half arrives on the left half, a maximized one fills this view.+ const bringHere = useCallback(function (record: Process) {++ const window = windows.presentation.projection(record.identity)++ if (window.layer !== "window") return++ const shown = boundedGeometry(window.position, shownSize(window.size), windowSurfaceSize)++ const from = viewOfGeometry(shown.position, shown.size, windowSurfaceSize)++ const brought = shiftPosition(shown.position, { x: viewport.view.x - from.x, y: viewport.view.y - from.y })++ void windows.move(record, brought.x, brought.y)++ windows.show(record)++ }, [windows.presentation, windows.move, windows.show, viewport.view.x, viewport.view.y, windowSurfaceSize])++ // Showing and hiding in place, as the Taskbar does.+ const toggleMinimized = useCallback(function (record: Process) {++ if (windows.presentation.projection(record.identity).minimized) windows.show(record)++ else focus.minimize(record, true)++ }, [windows.presentation, windows.show, focus.minimize])const taskbarItems = <OverflowRoworientation={taskbarOrientation}@@ -367,6 +426,8 @@ export default function Workspace() {onGoTo={show}+ onBringHere={bringHere}+onFill={windows.fill}onClose={focus.close}diff --git a/source/client/view/structure/desktop/layers/shell/taskbar/programs/window-taskbar-item.tsx b/source/client/view/structure/desktop/layers/shell/taskbar/programs/window-taskbar-item.tsxindex dc3c58d..423fd30 100644--- a/source/client/view/structure/desktop/layers/shell/taskbar/programs/window-taskbar-item.tsx+++ b/source/client/view/structure/desktop/layers/shell/taskbar/programs/window-taskbar-item.tsx@@ -1,13 +1,13 @@import Process from "@client/core/link-manager/auth-manager/process-manager/process"import { type TaskbarPosition } from "@phreshos/core"-import { ContextMenu, Menu } from "@phreshos/react-ui"-import { ArrowDownLeft, ArrowUpRight, LocateFixed, Maximize2, Minimize2, X } from "@phreshos/react-ui/icons"+import { ContextMenu } from "@phreshos/react-ui"+import WindowMenu from "../../window-menu"import { useDesktopScaleContainer } from "../../../../desktop-scale"import TaskbarItem from "./taskbar-item"import { memo, useCallback } from "react"/** A taskbar entry rerenders only when what that entry shows changes. */-export default memo(function ({ record, title, icon, position, active, minimized, maximized, onElement, onMinimize, onShow, onGoTo, onFill, onClose }: WindowTaskbarItemProps) {+export default memo(function ({ record, title, icon, position, active, minimized, maximized, onElement, onMinimize, onShow, onGoTo, onBringHere, onFill, onClose }: WindowTaskbarItemProps) {const scaleContainer = useDesktopScaleContainer()@@ -28,6 +28,8 @@ export default memo(function ({ record, title, icon, position, active, minimized}, [minimized, onMinimize, onShow, record])const fill = useCallback(() => onFill(record), [onFill, record])+ const goTo = useCallback(() => onGoTo(record), [onGoTo, record])+ const bringHere = useCallback(() => onBringHere(record), [onBringHere, record])const close = useCallback(() => onClose(record), [onClose, record])return <ContextMenu>@@ -44,28 +46,8 @@ export default memo(function ({ record, title, icon, position, active, minimized<ContextMenu.Content portalContainer={scaleContainer ?? undefined}>- <Menu aria-label={`${title} window actions`} size="small" onAction={action => {- if (action === "goTo") onGoTo(record)- else if (action === "visibility") changeVisibility()- else if (action === "fill") fill()- else if (action === "close") close()- }}>-- {/* Where the Window is on the plane is the Map's concern; from here it is one choice away. */}- <Menu.Item id="goTo" textValue="Go to"><LocateFixed aria-hidden />Go to</Menu.Item>-- <Menu.Separator />-- {/* The icons are the Window's own title bar controls. */}- <Menu.Item id="visibility" textValue={minimized ? "Show" : "Minimize"}>{minimized ? <><ArrowUpRight aria-hidden />Show</> : <><ArrowDownLeft aria-hidden />Minimize</>}</Menu.Item>-- <Menu.Item id="fill" textValue={maximized ? "Restore" : "Maximize"}>{maximized ? <><Minimize2 aria-hidden />Restore</> : <><Maximize2 aria-hidden />Maximize</>}</Menu.Item>-- <Menu.Separator />-- <Menu.Item id="close" color="danger" textValue="Close"><X aria-hidden />Close</Menu.Item>-- </Menu>+ <WindowMenu title={title} minimized={minimized} maximized={maximized}+ onGoTo={goTo} onBringHere={bringHere} onToggleMinimized={changeVisibility} onFill={fill} onClose={close} /></ContextMenu.Content>@@ -97,6 +79,9 @@ interface WindowTaskbarItemProps {/** Brings the view to the Window and the Window to the front. */onGoTo: (record: Process) => void+ /** Moves the Window into the view on screen and brings it to the front. */+ onBringHere: (record: Process) => void+onFill: (record: Process) => voidonClose: (record: Process) => voiddiff --git a/source/client/view/structure/desktop/layers/shell/taskbar/viewport/viewport-control.tsx b/source/client/view/structure/desktop/layers/shell/taskbar/viewport/viewport-control.tsxindex b7ef734..2a37ac6 100644--- a/source/client/view/structure/desktop/layers/shell/taskbar/viewport/viewport-control.tsx+++ b/source/client/view/structure/desktop/layers/shell/taskbar/viewport/viewport-control.tsx@@ -1,5 +1,6 @@-import { Button, ContextMenu, Menu, Panel, Surface, Text, useAppearance, useColor, useScale } from "@phreshos/react-ui"-import { LocateFixed, Map as MapIcon, X } from "@phreshos/react-ui/icons"+import { Button, ContextMenu, Panel, Surface, Text, useAppearance, useColor, useScale } from "@phreshos/react-ui"+import { Map as MapIcon, Maximize2 } from "@phreshos/react-ui/icons"+import WindowMenu from "../../window-menu"import { useCallback, useEffect, useId, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from "react"import { planeReach, type WindowRegion } from "@client/view/components/window-manager/window-geometry"import { type AppearanceTaskbar } from "@phreshos/core"@@ -26,9 +27,22 @@ export interface MappedWindow {/** Whether it is the front Window. */front: boolean+ minimized: boolean++ maximized: boolean+/** Brings the view to the Window and the Window to the front. */show(): void+ /** Moves the Window into the view on screen and brings it to the front. */+ bringHere(): void++ /** Shows the Window where it is, or minimizes it. */+ toggleMinimized(): void++ /** Maximizes the Window in its view, or restores it. */+ fill(): void+/** Closes the Window, which exits its Process. */close(): void@@ -181,6 +195,8 @@ function ViewMap({ labelId, viewport, windows, centered, menus }: Readonly<{ labconst space = useScale(useAppearance().spacing)+ const primary = useColor("primary").base+// The lines between views, as faint as React UI's separators.const line = `color-mix(in oklab, ${useColor("foreground").base} 10%, transparent)`@@ -203,6 +219,20 @@ function ViewMap({ labelId, viewport, windows, centered, menus }: Readonly<{ lab// The Window whose title shows, by pointer or focus.const [named, setNamed] = useState<MappedWindow | null>(null)+ // The whole view a released frame would settle on, shown while it is dragged.+ const [settle, setSettle] = useState<{ x: number, y: number } | null>(null)++ // Where that mark last stood, so it can fade out in place.+ const lastSettle = useRef(settle)++ if (settle) lastSettle.current = settle++ const shownSettle = settle ?? lastSettle.current++ const reducedMotion = useReducedMotion()++ const transaction = useAppearance().transaction+function grab(event: ReactPointerEvent<HTMLDivElement>) {event.currentTarget.setPointerCapture(event.pointerId)@@ -217,16 +247,30 @@ function ViewMap({ labelId, viewport, windows, centered, menus }: Readonly<{ labif (!started) return// The frame stays on the map: its center goes no further than the outer views' centers.- viewport.place({+ const point = {x: clamp(started.offset.x + (event.clientX - started.pointer.x) / started.scale / cell.width * surface.width, range.minX * surface.width, range.maxX * surface.width),y: clamp(started.offset.y + (event.clientY - started.pointer.y) / started.scale / cell.height * surface.height, range.minY * surface.height, range.maxY * surface.height)- })+ }++ // The frame follows the pointer freely; a nearby whole view is only marked until release.+ viewport.place(point)++ setSettle(nearView(point, surface))+ }++ function release() {++ if (drag.current && settle) viewport.moveTo(settle)++ drag.current = null++ setSettle(null)}// The panel is as wide as the map; its words wrap under it.return <div className="grid" style={{ gap: space.medium, padding: space.large, width: columns * cell.width, boxSizing: "content-box" }}>- <Text id={labelId} size="medium" style={{ fontWeight: 500 }}>Map</Text>+ <Text id={labelId} size="medium" className="flex items-center" style={{ fontWeight: 500, gap: space.small }}><MapIcon aria-hidden />Map</Text><div className="relative">@@ -258,10 +302,21 @@ function ViewMap({ labelId, viewport, windows, centered, menus }: Readonly<{ labbackgroundSize: `${cell.width}px 100%, 100% ${cell.height}px`}} />+ {/* Where the frame will settle when released: the whole view it is near, lightly tinted.+ It fades in and out, and keeps its last place while it fades away. */}+ {shownSettle && <motion.div aria-hidden="true" className="pointer-events-none absolute"+ initial={{ opacity: 0 }}+ animate={{ opacity: settle ? 1 : 0 }}+ transition={surfacePresenceTransition(reducedMotion, transaction)}+ style={{+ left: mapX(shownSettle.x * surface.width) - cell.width / 2, top: mapY(shownSettle.y * surface.height) - cell.height / 2, width: cell.width, height: cell.height,+ background: `color-mix(in oklab, ${primary} 18%, transparent)`+ }} />}+{/* The view itself, over the views and dragged anywhere on the map. */}<Surface aria-hidden="true" color="primary" material={{ opacity: 0.3, backdrop: 0 }} radius="small" className="cursor-grab touch-none active:cursor-grabbing"style={{ position: "absolute", left: mapX(viewport.offset.x) - cell.width / 2, top: mapY(viewport.offset.y) - cell.height / 2, width: cell.width, height: cell.height }}- onPointerDown={grab} onPointerMove={follow} onPointerUp={() => { drag.current = null }} onPointerCancel={() => { drag.current = null }} />+ onPointerDown={grab} onPointerMove={follow} onPointerUp={release} onPointerCancel={() => { drag.current = null; setSettle(null) }} />{/* The Windows above everything, since they are dragged too. */}{windows.map(window => <MapWindow key={window.identity} window={window} viewport={viewport} menus={menus} onName={setNamed} mapX={mapX} mapY={mapY} cell={cell} />)}@@ -271,7 +326,7 @@ function ViewMap({ labelId, viewport, windows, centered, menus }: Readonly<{ lab{/* A Window's title above its card; outside the plane, so its edges do not cut it. */}{named && <Surface aria-hidden="true" color="foreground" radius="small" className="pointer-events-none absolute whitespace-nowrap"style={{ position: "absolute", left: mapX(named.region.x + named.region.width / 2), top: mapY(named.region.y + named.region.height / 2) - space.medium, transform: "translate(-50%, -100%)", paddingBlock: space.xsmall, paddingInline: space.small }}>- <Text size="xsmall">{named.title}</Text>+ <Text size="xsmall">{named.title}{windowState(named) && ` · ${windowState(named)}`}</Text></Surface>}</div>@@ -290,7 +345,7 @@ function ViewMap({ labelId, viewport, windows, centered, menus }: Readonly<{ lab/*** A Window on the map: a small card around its icon where the Window's center is, in a light tint* of the secondary color like the Start Menu's cards, and in the primary color when it is the front- * Window. Its title shows on hover and focus. Pressing it, or Go to in its menu, brings the view to the Window and the Window to the front; Close in its menu closes the Window; dragging it moves the+ * Window. Its title shows on hover and focus. Pressing it brings the view to the Window and the Window to the front; its menu is the Window's menu, as in the Taskbar; dragging it moves the* Window anywhere on the map.*/function MapWindow({ window, viewport, menus, onName, mapX, mapY, cell }: Readonly<{@@ -323,6 +378,9 @@ function MapWindow({ window, viewport, menus, onName, mapX, mapY, cell }: Readonconst card = icon + space.xsmall * 2+ // The maximize mark on a card's corner.+ const mark = Math.round(card / 2)+// The card is a Button, which keeps its pointer events to itself, and the pointer soon leaves so small// a card; so the drag listens before the Button does, and then follows the pointer across the page.function down(event: ReactPointerEvent<HTMLDivElement>) {@@ -382,10 +440,12 @@ function MapWindow({ window, viewport, menus, onName, mapX, mapY, cell }: Readon<ContextMenu.Trigger>- <Button size="xsmall" iconOnly depth="flat" color={window.front ? "primary:soft" : "secondary:subtle"} aria-label={window.title}+ {/* The front Window is apricot; a minimized one fades; a maximized one carries the title bar's maximize mark. */}+ <Button size="xsmall" iconOnly depth="flat" color={window.front ? "primary:soft" : "secondary:subtle"}+ aria-label={windowState(window) ? `${window.title}, ${windowState(window)}` : window.title}onPress={() => { if (!moved.current) window.show() }}onHoverStart={() => onName(window)} onHoverEnd={() => onName(null)} onFocus={() => onName(window)} onBlur={() => onName(null)}- style={{ width: card, height: card, paddingInline: 0 }}>+ style={{ width: card, height: card, paddingInline: 0, opacity: window.minimized ? 0.45 : 1 }}><img src={window.icon} alt="" draggable={false} className="object-contain" style={{ width: icon, height: icon }} /></Button>@@ -393,32 +453,46 @@ function MapWindow({ window, viewport, menus, onName, mapX, mapY, cell }: Readon<ContextMenu.Content portalContainer={menus ?? undefined}>- <Menu aria-label={`${window.title} window actions`} size="small" onAction={action => {- if (action === "show") window.show()- else if (action === "close") window.close()- }}>-- <Menu.Item id="show" textValue="Go to"><LocateFixed aria-hidden />Go to</Menu.Item>-- <Menu.Separator />-- <Menu.Item id="close" color="danger" textValue="Close"><X aria-hidden />Close</Menu.Item>-- </Menu>+ <WindowMenu title={window.title} minimized={window.minimized} maximized={window.maximized}+ onGoTo={window.show} onBringHere={window.bringHere} onToggleMinimized={window.toggleMinimized} onFill={window.fill} onClose={window.close} /></ContextMenu.Content></ContextMenu>+ {window.maximized && <Surface aria-hidden="true" color={window.front ? "primary" : "secondary"} radius="full" className="pointer-events-none grid place-items-center"+ style={{ position: "absolute", top: -mark / 3, right: -mark / 3, width: mark, height: mark, opacity: window.minimized ? 0.45 : 1 }}>+ <Maximize2 style={{ width: mark * 0.6, height: mark * 0.6 }} strokeWidth={2.5} />+ </Surface>}+</div>}+/** What sets a Window apart on the map, in words. */+function windowState(window: MappedWindow) {++ return [window.minimized && "Minimized", window.maximized && "Maximized"].filter(Boolean).join(", ")+}+/** How much larger than its own pixels an element is shown: the Desktop's scale preference, which pointer distances include. */function shownScale(element: HTMLElement) {return element.offsetWidth ? element.getBoundingClientRect().width / element.offsetWidth : 1}+/** The whole view a dragged frame is near enough to settle on when released, if any. */+function nearView(center: { x: number, y: number }, surface: { width: number, height: number }) {++ const view = { x: Math.round(center.x / surface.width), y: Math.round(center.y / surface.height) }++ const near = Math.abs(center.x - view.x * surface.width) < surface.width * snapReach && Math.abs(center.y - view.y * surface.height) < surface.height * snapReach++ return near ? view : null+}++/** How near a whole view the frame settles on it, as a share of the view. */+const snapReach = 0.2+/** The whole view a region's center is in. */function viewOf(region: WindowRegion, surface: { width: number, height: number }) {diff --git a/source/client/view/structure/desktop/layers/shell/window-menu.tsx b/source/client/view/structure/desktop/layers/shell/window-menu.tsxnew file mode 100644index 0000000..530cc18--- /dev/null+++ b/source/client/view/structure/desktop/layers/shell/window-menu.tsx@@ -0,0 +1,43 @@+import { Menu } from "@phreshos/react-ui"+import { ArrowDownLeft, ArrowUpRight, LocateFixed, Magnet, Maximize2, Minimize2, X } from "@phreshos/react-ui/icons"++/**+ * What can be done to one standard Window, the same wherever it is offered: its Taskbar item and its+ * icon on the Map. Going to it and bringing it here move between views; the rest act on the Window+ * where it is, with the same icons as the Window's own title bar controls.+ */+export default function WindowMenu({ title, minimized, maximized, onGoTo, onBringHere, onToggleMinimized, onFill, onClose }: Readonly<{+ title: string+ minimized: boolean+ maximized: boolean+ onGoTo: () => void+ onBringHere: () => void+ onToggleMinimized: () => void+ onFill: () => void+ onClose: () => void+}>) {++ return <Menu aria-label={`${title} window actions`} size="small" onAction={action => {+ if (action === "goTo") onGoTo()+ else if (action === "bringHere") onBringHere()+ else if (action === "visibility") onToggleMinimized()+ else if (action === "fill") onFill()+ else if (action === "close") onClose()+ }}>++ <Menu.Item id="goTo" textValue="Go to"><LocateFixed aria-hidden />Go to</Menu.Item>++ <Menu.Item id="bringHere" textValue="Bring here"><Magnet aria-hidden />Bring here</Menu.Item>++ <Menu.Separator />++ <Menu.Item id="visibility" textValue={minimized ? "Show" : "Minimize"}>{minimized ? <><ArrowUpRight aria-hidden />Show</> : <><ArrowDownLeft aria-hidden />Minimize</>}</Menu.Item>++ <Menu.Item id="fill" textValue={maximized ? "Restore" : "Maximize"}>{maximized ? <><Minimize2 aria-hidden />Restore</> : <><Maximize2 aria-hidden />Maximize</>}</Menu.Item>++ <Menu.Separator />++ <Menu.Item id="close" color="danger" textValue="Close"><X aria-hidden />Close</Menu.Item>++ </Menu>+}diff --git a/source/client/view/structure/desktop/windows/process-window.tsx b/source/client/view/structure/desktop/windows/process-window.tsxindex d0fcc9f..b81c798 100644--- a/source/client/view/structure/desktop/windows/process-window.tsx+++ b/source/client/view/structure/desktop/windows/process-window.tsx@@ -24,7 +24,7 @@ export function processWindowProgress(layer: WindowLayer, loading: boolean, stop* props so memoization can see which process actually changed even though* the peer deliberately keeps each Process instance alive and mutates it.*/-export default memo(function ({ identity, record, assetId, client, title, header, surface, layer, icon, position, size, taskbarPosition, surfaceAnimation, geometryAnimation, minimizeAnimation, onPresentationAnimationComplete, onPresentationRepresentation, onPresentationMoveGesture, paintSurfaceSize, paintMargins, spacing, depth, active, minimized, maximized, interactive, closing, stopping, entering, door, programAccess, theme, onFrame, onFrameLoad, onReady, onRaise, onMinimize, onFill, onClose, onClosed, onUnavailable, onMove, onResize, onSnap }: ProcessWindowProps) {+export default memo(function ({ identity, record, assetId, client, title, header, surface, layer, icon, position, size, taskbarPosition, surfaceAnimation, geometryAnimation, minimizeAnimation, onPresentationAnimationComplete, onPresentationRepresentation, onPresentationMoveGesture, paintSurfaceSize, paintMargins, spacing, depth, active, minimized, maximized, maximizedPosition, interactive, closing, stopping, entering, door, programAccess, theme, onFrame, onFrameLoad, onReady, onRaise, onMinimize, onFill, onClose, onClosed, onUnavailable, onMove, onResize, onSnap }: ProcessWindowProps) {const activate = useCallback(() => onRaise(record), [onRaise, record])@@ -139,6 +139,8 @@ export default memo(function ({ identity, record, assetId, client, title, headerminimized={minimized}+ maximizedPosition={maximizedPosition}+maximized={maximized}interactive={interactive}@@ -270,6 +272,8 @@ interface ProcessWindowProps {minimized: boolean+ maximizedPosition?: Position+maximized: booleaninteractive: booleandiff --git a/source/client/view/structure/desktop/windows/window.tsx b/source/client/view/structure/desktop/windows/window.tsxindex a75efa2..635af48 100644--- a/source/client/view/structure/desktop/windows/window.tsx+++ b/source/client/view/structure/desktop/windows/window.tsx@@ -66,7 +66,9 @@ export function windowMinimizePose(position: TaskbarPosition) {}}-export default function ({ title, header = true, surface, layer, icon, children, onClose, onClosed, onMinimize, onMaximize, onActivate, onUnavailable, onMove, onResize, onSnap, onPresentationAnimationComplete, onPresentationRepresentation, onPresentationMoveGesture, onFocusCapture, active = false, closing = false, stopping = false, minimized = false, maximized = false, interactive = true, entering = false, position = { x: 0, y: 0 }, size = presentedWindowSize, taskbarPosition = "bottom", surfaceAnimation, geometryAnimation, minimizeAnimation, paintSurfaceSize = { width: 0, height: 0 }, paintMargins = noPaintMargins, spacing = 0, minWidth = minimumWindowSize.width, minHeight = minimumWindowSize.height, className, style, ...props }: WindowProps) {+const wholeView: Position = Object.freeze({ x: "-1/2", y: "-1/2" })++export default function ({ title, header = true, surface, layer, icon, children, onClose, onClosed, onMinimize, onMaximize, onActivate, onUnavailable, onMove, onResize, onSnap, onPresentationAnimationComplete, onPresentationRepresentation, onPresentationMoveGesture, onFocusCapture, active = false, closing = false, stopping = false, minimized = false, maximized = false, maximizedPosition = wholeView, interactive = true, entering = false, position = { x: 0, y: 0 }, size = presentedWindowSize, taskbarPosition = "bottom", surfaceAnimation, geometryAnimation, minimizeAnimation, paintSurfaceSize = { width: 0, height: 0 }, paintMargins = noPaintMargins, spacing = 0, minWidth = minimumWindowSize.width, minHeight = minimumWindowSize.height, className, style, ...props }: WindowProps) {const reducedMotion = useReducedMotion()const appearance = useAppearance()@@ -87,7 +89,7 @@ export default function ({ title, header = true, surface, layer, icon, children,// Hidden windows retain their last presentation while lower-priority state changes.const presented = useRef({ position, size })if (!minimized) presented.current = maximized- ? { position: { x: "-1/2", y: "-1/2" }, size: { width: "1/1", height: "1/1" } }+ ? { position: maximizedPosition, size: { width: "1/1", height: "1/1" } }: { position, size }const geometryMotion = useWindowGeometryMotion({@@ -783,6 +785,9 @@ interface WindowProps extends Omit<ComponentProps<"div">, "onAnimationStart" | "maximized?: boolean+ /** Where a maximized Window's view starts, as shown: the whole view it is in, which is not always the one on screen. */+ maximizedPosition?: Position+/** Whether this presentation participates in focus and hit testing. */interactive?: booleandiff --git a/tests/window-geometry.test.ts b/tests/window-geometry.test.tsindex 9059202..b5fe6dc 100644--- a/tests/window-geometry.test.ts+++ b/tests/window-geometry.test.ts@@ -3,7 +3,7 @@ import ClientWindow from "@client/core/link-manager/auth-manager/process-managerimport ClientProcessManager from "@client/core/link-manager/auth-manager/process-manager/process-manager"import ProcessManager from "@server/core/link-manager/auth-manager/process-manager/process-manager"import ServerWindow from "@server/core/link-manager/auth-manager/process-manager/window"-import { boundedGeometry, constrainWindowGeometry, minimumWindowSize, noPaintMargins, planeGeometry, recordedPosition, resolveWindowGeometry, shiftPosition, windowPaintInsets } from "@client/view/components/window-manager/window-geometry"+import { boundedGeometry, constrainWindowGeometry, minimumWindowSize, noPaintMargins, planeGeometry, recordedPosition, resolveWindowGeometry, shiftPosition, viewOfGeometry, windowPaintInsets } from "@client/view/components/window-manager/window-geometry"import { defaultAppearance } from "@phreshos/core"import { TheLink } from "@the-link/core"import { test } from "vitest"@@ -37,6 +37,10 @@ test("the view moves a position by whole shares of the surface, so it keeps to iassert.deepEqual(resolveWindowGeometry(recorded, { width: 600, height: 400 }, surface), resolveWindowGeometry(stored, { width: 600, height: 400 }, surface))}+ // A Window belongs to the view its center is in.+ assert.deepEqual(viewOfGeometry({ x: "50%", y: "-1/2" }, { width: "1/2", height: "1/1" }, { width: 1200, height: 800 }), { x: 1, y: 0 })+ assert.deepEqual(viewOfGeometry({ x: -300, y: "100% - 200" }, { width: 600, height: 400 }, { width: 1200, height: 800 }), { x: 0, y: 1 })+// A point of the plane is recorded as its view and the pixels within it.assert.deepEqual(recordedPosition({ x: 2500, y: -100 }, { width: 1200, height: 800 }), { x: "200% + 100", y: -100 })})