An open-source, self-hosted system for apps built with web technologies.
The Start menu and System dialogs size themselves by the visible viewport in Desktop pixels
zohayrslilehf98bdc9b21c9
diff --git a/source/client/view/structure/desktop/layers/desktop-layers.tsx b/source/client/view/structure/desktop/layers/desktop-layers.tsxindex 507d805..11ee484 100644--- a/source/client/view/structure/desktop/layers/desktop-layers.tsx+++ b/source/client/view/structure/desktop/layers/desktop-layers.tsx@@ -1,6 +1,7 @@import { type CSSProperties, type ReactNode, type Ref } from "react"import { type AppearanceTaskbar } from "@phreshos/core"import { type PaintMargins } from "@client/view/components/window-manager/window-geometry"+import { useDesktopScale } from "../desktop-scale"/*** Five coextensive Desktop layers ordered from back to front. No layer owns@@ -8,10 +9,13 @@ import { type PaintMargins } from "@client/view/components/window-manager/window*/export default function DesktopLayers({ wallpaper, underWindows, windows, sharedResizeBoundaries, overWindows, shell, windowSurfaceRef, spacing }: DesktopLayersProps) {+ // The Desktop's zoom multiplies viewport units too: what sizes itself by the viewport divides by it.+ const scale = useDesktopScale()+return <divdata-desktop-layers=""className="absolute inset-0 isolate overflow-hidden"- style={{ "--desktop-gutter": `${spacing}px` } as CSSProperties}+ style={{ "--desktop-gutter": `${spacing}px`, "--desktop-scale": scale } as CSSProperties}><div data-desktop-layer="wallpaper" className="absolute inset-0 z-0 overflow-hidden">diff --git a/source/client/view/structure/desktop/layers/shell/dialogs/open-requests.tsx b/source/client/view/structure/desktop/layers/shell/dialogs/open-requests.tsxindex d7bb04b..f64f5aa 100644--- a/source/client/view/structure/desktop/layers/shell/dialogs/open-requests.tsx+++ b/source/client/view/structure/desktop/layers/shell/dialogs/open-requests.tsx@@ -45,7 +45,7 @@ export default function OpenRequests() {animate={surfaceLifecyclePose.visible}transition={surfacePresenceTransition(reducedMotion, transaction)}onCancel={event => { event.preventDefault(); void manager.cancel(request.identity).catch(() => undefined) }}- className={`${shellSurfaceClassName} pointer-events-auto fixed inset-0 m-auto h-fit w-[min(24rem,calc(100vw-var(--desktop-gutter)*2))] backdrop:bg-transparent`}+ className={`${shellSurfaceClassName} pointer-events-auto fixed inset-0 m-auto h-fit w-[min(24rem,calc(100dvw/var(--desktop-scale)-var(--desktop-gutter)*2))] backdrop:bg-transparent`}><ShellSurface material="full" label="Open with" labelId={title}><OpenRequestView key={request.identity} request={request} />diff --git a/source/client/view/structure/desktop/layers/shell/dialogs/permission-requests.tsx b/source/client/view/structure/desktop/layers/shell/dialogs/permission-requests.tsxindex 449cc91..3fc14a4 100644--- a/source/client/view/structure/desktop/layers/shell/dialogs/permission-requests.tsx+++ b/source/client/view/structure/desktop/layers/shell/dialogs/permission-requests.tsx@@ -46,7 +46,7 @@ export default function PermissionRequests() {animate={surfaceLifecyclePose.visible}transition={surfacePresenceTransition(reducedMotion, transaction)}onCancel={event => event.preventDefault()}- className={`${shellSurfaceClassName} pointer-events-auto fixed inset-0 m-auto h-fit w-[min(28rem,calc(100vw-var(--desktop-gutter)*2))] backdrop:bg-transparent`}+ className={`${shellSurfaceClassName} pointer-events-auto fixed inset-0 m-auto h-fit w-[min(28rem,calc(100dvw/var(--desktop-scale)-var(--desktop-gutter)*2))] backdrop:bg-transparent`}><ShellSurface material="full" label="Permission request" labelId={title}><PermissionRequestView request={request} description={description} />diff --git a/source/client/view/structure/desktop/layers/shell/dialogs/system-errors.tsx b/source/client/view/structure/desktop/layers/shell/dialogs/system-errors.tsxindex bfad011..f1996ec 100644--- a/source/client/view/structure/desktop/layers/shell/dialogs/system-errors.tsx+++ b/source/client/view/structure/desktop/layers/shell/dialogs/system-errors.tsx@@ -75,7 +75,7 @@ export default function SystemErrors() {onCancel={event => event.preventDefault()}- className={`${shellSurfaceClassName} pointer-events-auto fixed inset-0 m-auto h-fit w-[min(28rem,calc(100vw-var(--desktop-gutter)*2))] backdrop:bg-transparent`}+ className={`${shellSurfaceClassName} pointer-events-auto fixed inset-0 m-auto h-fit w-[min(28rem,calc(100dvw/var(--desktop-scale)-var(--desktop-gutter)*2))] backdrop:bg-transparent`}>diff --git a/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx b/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsxindex 05b9505..74d3d14 100644--- a/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx+++ b/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx@@ -11,6 +11,7 @@ import { useTiming } from "@phreshos/react-ui"import { cssEasing } from "@phreshos/core"import { surfaceLifecyclePose, surfacePresenceTransition } from "@client/view/appearance/surface-presence"import { usePortrait } from "../../../orientation"+import { useDesktopScale } from "../../../desktop-scale"const StartMenuContext = createContext<StartMenuControl | null>(null)@@ -112,6 +113,8 @@ export default memo(function StartMenu() {const portrait = usePortrait()+ const scale = useDesktopScale()+return <motion.divref={control.surface}id={control.id}@@ -121,7 +124,7 @@ export default memo(function StartMenu() {tabIndex={-1}className={`${shellSurfaceClassName} pointer-events-auto fixed hidden open:block`}style={{- ...startMenuStyle(control.taskbar, control.spacing, portrait),+ ...startMenuStyle(control.taskbar, control.spacing, portrait, scale),transitionBehavior: "allow-discrete",transitionDuration: reducedMotion ? "0ms" : String(transaction.duration) + "ms",transitionTimingFunction: cssEasing(transaction.easing),@@ -154,9 +157,12 @@ export default memo(function StartMenu() {* The menu occupies the leading corner beside the Taskbar: one spacing from* its perpendicular screen edge and two spacings beyond the Taskbar edge. It* takes the screen's shape: wide on a wide screen, and the same size turned on- * a tall one, each within the room the screen has.+ * a tall one, each within the room the screen has. That room is the visible+ * viewport (`dvh`, which leaves out a phone browser's bars, as the Desktop+ * itself does), in Desktop pixels: the Desktop's zoom multiplies viewport units+ * too, so they are divided by its scale.*/-export function startMenuStyle(taskbar: AppearanceTaskbar, spacing: number, portrait = false): CSSProperties {+export function startMenuStyle(taskbar: AppearanceTaskbar, spacing: number, portrait = false, scale = 1): CSSProperties {const [long, short] = ["44rem", "32rem"]const [across, down] = portrait ? [short, long] : [long, short]const horizontal = taskbar.position === "top" || taskbar.position === "bottom"@@ -171,11 +177,11 @@ export function startMenuStyle(taskbar: AppearanceTaskbar, spacing: number, portbottom: "auto",left: "auto",width: horizontal- ? `min(${across}, calc(100vw - ${spacing * 2}px))`- : `min(${across}, calc(100vw - ${taskbarInset + spacing}px))`,+ ? `min(${across}, calc(100dvw / ${scale} - ${spacing * 2}px))`+ : `min(${across}, calc(100dvw / ${scale} - ${taskbarInset + spacing}px))`,height: horizontal- ? `min(${down}, calc(100vh - ${taskbarInset + spacing}px))`- : `min(${down}, calc(100vh - ${spacing * 2}px))`+ ? `min(${down}, calc(100dvh / ${scale} - ${taskbarInset + spacing}px))`+ : `min(${down}, calc(100dvh / ${scale} - ${spacing * 2}px))`} satisfies CSSPropertiesif (taskbar.position === "bottom") return { ...style, left: spacing, bottom: taskbarInset }diff --git a/tests/desktop-replacements.test.tsx b/tests/desktop-replacements.test.tsxindex e985ee3..62a59b3 100644--- a/tests/desktop-replacements.test.tsx+++ b/tests/desktop-replacements.test.tsx@@ -148,6 +148,12 @@ test.each(["top", "right", "bottom", "left"] as const)("Taskbar occupies its conif (position === "right") expect(menu).toMatchObject({ top: spacing, right: taskbarInset, bottom: "auto", left: "auto" })expect(menu).not.toHaveProperty("insetInlineStart")++ // The room is the visible viewport, in Desktop pixels: a phone browser's bars and the Desktop's zoom both left out.+ const scaled = startMenuStyle(taskbar, spacing, false, 1.25)+ expect(String(scaled.height)).toContain("100dvh / 1.25")+ expect(String(scaled.width)).toContain("100dvw / 1.25")+ expect(String(menu.height)).not.toContain("100vh")expect(menu).not.toHaveProperty("insetBlockStart")})