Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat(desktop): add Snap layouts, Snap assist, taskbar peek and Fluent, Aqua and Classic shell styles

nirholas20f5e63cc52a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5b64d8a1d..1db5bd18f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -36,6 +36,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **The desktop behaves like a real computer**: Drag a selection box across the desktop, move icons on a snap grid, right-click for view options, and open every app from desktop icons or All Apps. Settings now covers your profile, theme, accent colour, wallpaper (including your own photo), icon size and taskbar, and the whole session (windows, icon layout, preferences) is saved in your browser, with export, import and reset. (`/docs/desktop`) `[feature, desktop]`
- **The prompt director works again, found by its own run receipts**: The first receipts showed the director's brief falling back on every Studio run. The replies were arriving in 5 to 10 seconds but ran past the 1000-character prompt cap or ended on the closing constraint the director is told to end on, and both were discarded as clipped. The director now writes to a word budget the models actually follow, the guard accepts the mandated ending, both forge clients share one guard, and a receipt now names the exact reason a brief fell back (too long with its length, unfinished, no reply) instead of a generic timeout. Receipts also stop saying every stage met when a stage was skipped. (`/runs`) `[fix]`
- **The terminal 3D renderer animates live in every HTTP client**: curl three.ws/tty streams an animated 3D character into your terminal frame by frame. Clients that ask for compressed responses, such as curl --compressed, scripts using fetch, and most HTTP libraries, used to get nothing for about ten seconds and then the whole animation at once. Live streams are no longer compressed, so every client sees the character move from the first frame. Streaming agent and chat responses get the same fix. (`/tty`) `[fix]`
+- **The web desktop gets Snap layouts, taskbar peek and three shell styles: Fluent, Aqua and Classic**: Hover a window's maximize button (or press Alt+Z) to tile it into one of six layouts, then let Snap assist fill the empty zones with your other windows. Corners snap to quarters, Ctrl+Alt+Arrows snap from the keyboard, minimize flies the window into its taskbar button, and hovering a running app shows its window card with Aero Peek. Settings, Personalization, Style switches the whole shell to Aqua (menu bar, magnifying dock, traffic lights) or Classic (bevelled 9x chrome with a labelled taskbar). (`/?view=desktop`) `[feature, desktop]`
- **three.ws is now a desktop**: The homepage is a web desktop with a taskbar, Start menu, widgets and draggable, snappable windows that open every part of the platform, in the CTRL Windows-style Mica theme. The original homepage is kept as the classic view at /classic, one click from the taskbar. (`/docs/desktop`) `[feature]`
- **Trenches Pulse: live launch and smart-money intelligence**: A new Trenches page shows what is happening on Solana and Robinhood Chain right now: new launches and graduations as they happen, the hottest tokens by trade flow, and scored smart-money wallets. Every number comes from a live on-chain feed, and if the data service is unreachable the page says so instead of showing made-up figures. (`/trenches`) `[feature]`
- **Walk into three.ws: the homepage boots, unlocks, and lets you enter the desktop as your avatar**: The homepage now starts like a real computer. A boot screen runs live checks (your GPU, the site catalog, your account, the avatar body, the $THREE feed, your gem ledger) and a lock screen greets you with the $THREE price and your balances. Press Walk in and you arrive on a campus as your avatar: walk to your desk and sit down to open the desktop on the monitor, pick up the phone for Pocket, put on the headset for VR, enter the three.ws Exchange (a live ticker board and Trenches inside), the Launchpad, the Forge, the Gallery, Agent Plaza and the Marketplace, or dig for gems in the mine, where every gem is rolled server-side and kept on your account. Settings gets an Arrival section to choose where you start, the taskbar gets a World button, and the desktop wears the classic three.ws violet grid. (`/`) `[feature, desktop]`
diff --git a/data/changelog.json b/data/changelog.json
index 0cba4b469..fbd4a1d67 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,13 @@
{
"$comment": "Curated changelog entries for three.ws, the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security, desktop (desktop entries become the desktop app's release notes). `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-10-11",
+ "title": "The web desktop gets Snap layouts, taskbar peek and three shell styles: Fluent, Aqua and Classic",
+ "link": "/?view=desktop",
+ "summary": "Hover a window's maximize button (or press Alt+Z) to tile it into one of six layouts, then let Snap assist fill the empty zones with your other windows. Corners snap to quarters, Ctrl+Alt+Arrows snap from the keyboard, minimize flies the window into its taskbar button, and hovering a running app shows its window card with Aero Peek. Settings, Personalization, Style switches the whole shell to Aqua (menu bar, magnifying dock, traffic lights) or Classic (bevelled 9x chrome with a labelled taskbar).",
+ "tags": ["feature", "desktop"]
+ },
{
"date": "2026-10-11",
"title": "3D viewers no longer flood the browser console, and /trenches stops hammering an offline feed",
diff --git a/docs/desktop.md b/docs/desktop.md
index 483d3eab9..485cbf22a 100644
--- a/docs/desktop.md
+++ b/docs/desktop.md
@@ -90,10 +90,14 @@ storage: migration `20261015000000_world_gems.sql`.
## Working like a computer
- **Icons.** Every app has a desktop icon on a snap grid. Click selects, Ctrl or Shift extends the selection, double-click (or Enter) opens, and a tap opens on touch. Drag to move one icon or a whole selection; drops land on the nearest free cell. Arrow keys move focus, Ctrl+Arrow nudges, Ctrl+A selects all, Delete removes an icon from the desktop.
+- **Styles.** Settings, Personalization, Style switches the whole shell, not just colours. **Fluent** (default): Mica windows, a centred taskbar and Snap layouts. **Aqua**: a menu bar across the top that names the window in front (click it for Minimize, Zoom, Snap layouts, Reload, Quit), a floating dock that magnifies under the pointer, and traffic-light window controls on the left. **Classic**: bevelled 9x chrome, navy title bars and a taskbar with a labelled button per window. Saved as `style` in `tws:prefs`. On a phone every style keeps a single bottom bar, so Aqua falls back to the Fluent taskbar there.
+- **Snap.** Drag a window to the top edge to maximize, a side to fill that half, or a corner for a quarter. Hover the maximize button (or press Alt+Z) for the Snap layouts flyout: halves, two-thirds and a third, thirds, a main window with a stack, quarters, and a centred focus layout. Layouts narrower than a usable window are hidden on small screens. After a window lands in a layout, Snap assist offers the other open windows for each empty zone; pick one per zone, or press Esc or click the backdrop to stop. Ctrl+Alt+Left and Right snap the focused window to a half, Ctrl+Alt+Up maximizes, Ctrl+Alt+Down restores and then minimizes.
+- **Motion.** Minimize flies the window into its taskbar button and restore flies it back; snapping, maximizing and restoring morph between the two frames. Every motion is skipped when the system asks for reduced motion.
+- **Peek.** Hover a running app in the taskbar for its window card (title, page, state, close). Hover the card and every other window fades out so the one you are pointing at shows through. The taskbar marks running apps with a short pill and the window in front with a long accent pill; pinned apps that are not running show none.
- **Rubber band.** Drag on the empty desktop to draw a selection box; Ctrl or Shift adds to the current selection.
- **Right-click.** The desktop menu sets icon size, sorts by name, auto-arranges, refreshes, and opens All Apps and Personalize. Icon menus open or remove the selection.
- **All Apps.** A native app listing every app and page from the site navigation, with Open and Add to desktop for each.
-- **Settings.** Profile (name, avatar colour), Arrival (start in the campus or on the desktop, startup chime, a Walk the campus button), Personalization (dark, light or match system, seven accents, six wallpapers or your own photo; the default `three.ws` wallpaper is the classic site's violet glow over a hairline grid), Desktop and taskbar (icon size, taskbar alignment, 24-hour clock), and Session and storage.
+- **Settings.** Profile (name, avatar colour), Arrival (start in the campus or on the desktop, startup chime, a Walk the campus button), Personalization (style, dark, light or match system, seven accents, six wallpapers or your own photo; the default `three.ws` wallpaper is the classic site's violet glow over a hairline grid), Desktop and taskbar (icon size, taskbar alignment, 24-hour clock), and Session and storage.
- **Session.** Open windows and their geometry, icon layout, preferences, recent apps and the custom wallpaper are saved in this browser (`tws:desktop`, `tws:icons`, `tws:prefs`, `tws:recent` in localStorage; the wallpaper image in IndexedDB database `tws-desktop`) and restored on reload. Settings can export the session to a JSON file, import one (only known `tws:` keys are accepted, files over 2 MB are refused), close all windows, or reset everything. Nothing is sent to a server.
## URLs and preferences
@@ -142,3 +146,9 @@ tests/desktop-layout.test.js tests/desktop-page.test.js`.
The visual design language and token values are ported from CTRL
(`nirholas/CTRL`), whose theme descends from the open-source Win12 project. The
DOM and JavaScript here are written for three.ws and share no code with it.
+
+The three shell styles follow the long-standing conventions of Windows 11
+(Snap layouts, Snap assist, taskbar peek), macOS (menu bar, magnifying dock,
+traffic-light controls) and Windows 9x (bevelled chrome). The open-source web
+desktops collected on GitHub were studied for interaction detail only; the
+code and CSS are original to three.ws.
diff --git a/public/changelog-recent.json b/public/changelog-recent.json
index 6b559a6f0..068a941c4 100644
--- a/public/changelog-recent.json
+++ b/public/changelog-recent.json
@@ -1,11 +1,11 @@
{
- "generated_at": "2026-10-11T06:20:32.492Z",
+ "generated_at": "2026-10-11T06:41:38.455Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
"url": "https://three.ws"
},
- "total": 3990,
+ "total": 3991,
"complete": false,
"full_feed": "/changelog.json",
"entries": [
@@ -281,6 +281,17 @@
"fix"
]
},
+ {
+ "date": "2026-10-11",
+ "type": "update",
+ "title": "The web desktop gets Snap layouts, taskbar peek and three shell styles: Fluent, Aqua and Classic",
+ "summary": "Hover a window's maximize button (or press Alt+Z) to tile it into one of six layouts, then let Snap assist fill the empty zones with your other windows. Corners snap to quarters, Ctrl+Alt+Arrows snap from the keyboard, minimize flies the window into its taskbar button, and hovering a running app shows its window card with Aero Peek. Settings, Personalization, Style switches the whole shell to Aqua (menu bar, magnifying dock, traffic lights) or Classic (bevelled 9x chrome with a labelled taskbar).",
+ "link": "/?view=desktop",
+ "tags": [
+ "feature",
+ "desktop"
+ ]
+ },
{
"date": "2026-10-11",
"type": "update",
@@ -1532,17 +1543,6 @@
"feature",
"improvement"
]
- },
- {
- "date": "2026-10-09",
- "type": "update",
- "title": "The leaderboard now ranks agents by what they earned",
- "summary": "A new Earned tab on the leaderboard ranks every public agent by what it earned over the last 24 hours, 7 days, 30 days or all time: creator fees from its coin plus what people and other agents paid for its skills, shown separately and added up in SOL with dollars beside it, with how far each agent moved since the previous period. Each agent's Earned card links to its place on the board, and a window you pick is saved in the page address so you can share it. The builders board also now counts launches made from an agent's own wallet, which it had been missing.",
- "link": "/leaderboard",
- "tags": [
- "feature",
- "fix"
- ]
}
]
}
diff --git a/public/changelog.json b/public/changelog.json
index cbd25dbdf..556be80ba 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-10-11T06:20:32.470Z",
+ "generated_at": "2026-10-11T06:41:38.424Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -278,6 +278,17 @@
"fix"
]
},
+ {
+ "date": "2026-10-11",
+ "type": "update",
+ "title": "The web desktop gets Snap layouts, taskbar peek and three shell styles: Fluent, Aqua and Classic",
+ "summary": "Hover a window's maximize button (or press Alt+Z) to tile it into one of six layouts, then let Snap assist fill the empty zones with your other windows. Corners snap to quarters, Ctrl+Alt+Arrows snap from the keyboard, minimize flies the window into its taskbar button, and hovering a running app shows its window card with Aero Peek. Settings, Personalization, Style switches the whole shell to Aqua (menu bar, magnifying dock, traffic lights) or Classic (bevelled 9x chrome with a labelled taskbar).",
+ "link": "/?view=desktop",
+ "tags": [
+ "feature",
+ "desktop"
+ ]
+ },
{
"date": "2026-10-11",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index b37b4faca..5da274cce 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -222,6 +222,14 @@
<category>fix</category>
<description>curl three.ws/tty streams an animated 3D character into your terminal frame by frame. Clients that ask for compressed responses, such as curl --compressed, scripts using fetch, and most HTTP libraries, used to get nothing for about ten seconds and then the whole animation at once. Live streams are no longer compressed, so every client sees the character move from the first frame. Streaming agent and chat responses get the same fix.</description>
</item>
+ <item>
+ <title>The web desktop gets Snap layouts, taskbar peek and three shell styles: Fluent, Aqua and Classic</title>
+ <link>https://three.ws/?view=desktop</link>
+ <guid isPermaLink="false">2026-10-11:The web desktop gets Snap layouts, taskbar peek and three shell styles: Fluent, Aqua and Classic</guid>
+ <pubDate>Sun, 11 Oct 2026 12:00:00 GMT</pubDate>
+ <category>feature</category>
+ <description>Hover a window's maximize button (or press Alt+Z) to tile it into one of six layouts, then let Snap assist fill the empty zones with your other windows. Corners snap to quarters, Ctrl+Alt+Arrows snap from the keyboard, minimize flies the window into its taskbar button, and hovering a running app shows its window card with Aero Peek. Settings, Personalization, Style switches the whole shell to Aqua (menu bar, magnifying dock, traffic lights) or Classic (bevelled 9x chrome with a labelled taskbar).</description>
+ </item>
<item>
<title>three.ws is now a desktop</title>
<link>https://three.ws/docs/desktop</link>
diff --git a/src/desktop/README.md b/src/desktop/README.md
index c5c272b24..0f4c5843b 100644
--- a/src/desktop/README.md
+++ b/src/desktop/README.md
@@ -8,12 +8,12 @@ The web desktop served at `/` (page: `pages/desktop.html`). See
| `main.js` | Entry: runs the boot checks, shows the lock screen, then walks the visitor in as an avatar or lands them on the desktop; deep links |
| `boot-logic.js` | Pure boot rules: concurrent boot steps with timings, entry mode (`?world=1`, `?world=0`, `?view=desktop`, deep links, WebGL, the Arrival preference), greeting, summary, GPU name (unit tested) |
| `boot.js`, `boot.css` | The boot screen (live log of real checks) and the lock screen (greeting, $THREE, gems and account chips, Walk in / Desktop), plus the synthesised startup chime |
-| `shell.js` | Taskbar, Start, widgets, calendar, menus, native apps, the World button and the Arrival settings |
-| `wm.js` | Window manager (drag, resize, snap, focus, persistence hooks) |
-| `layout.js` | Pure geometry, search ranking, state and preference validation (unit tested) |
+| `shell.js` | Taskbar (peek cards, Aqua dock magnification and menu bar), Start, widgets, calendar, menus, native apps, the World button and the Arrival settings |
+| `wm.js` | Window manager (drag, resize, edge and corner snap, Snap layouts flyout, Snap assist, minimize flight and morph motion, focus, persistence hooks) |
+| `layout.js` | Pure geometry (snap zones, Snap layouts, dock magnification curve), shell styles and their bar sizes, search ranking, state and preference validation (unit tested) |
| `apps.js` | App registry and wallpapers |
| `icons.js` | Stroke glyphs |
-| `theme.css`, `desktop.css` | CTRL tokens; shell and window styles |
+| `theme.css`, `desktop.css`, `styles.css` | CTRL tokens; shell and window styles; Snap layouts, Snap assist, peek and the Fluent, Aqua and Classic skins |
| `world/index.js` | The campus controller: mounts the 3D world over the desktop, input, proximity prompts, sit-down and walk-in transitions, the phone, the VR headset, mining, the frame loop |
| `world/campus.js` | The scene: ground, office desk, exchange, launchpad, mine, forge, gallery, plaza, market, lighting |
| `world/places.js` | Pure campus map: places, keep-outs, veins, desk objects, trigger radii, stand points (unit tested) |
diff --git a/src/desktop/layout.js b/src/desktop/layout.js
index 56378b399..f699aef13 100644
--- a/src/desktop/layout.js
+++ b/src/desktop/layout.js
@@ -22,20 +22,95 @@ export function clampRect(rect, area) {
return { x: Math.round(x), y: Math.round(y), w: Math.round(w), h: Math.round(h) };
}
+/** How far from a corner (along either edge) a drag snaps to a quarter instead of a half. */
+export const SNAP_CORNER = 96;
+
/** Which snap zone, if any, the pointer is in while dragging a window. */
export function snapZone(px, py, area) {
- if (py <= area.y + SNAP_EDGE) return 'max';
- if (px <= area.x + SNAP_EDGE) return 'left';
- if (px >= area.x + area.w - SNAP_EDGE) return 'right';
+ const atL = px <= area.x + SNAP_EDGE;
+ const atR = px >= area.x + area.w - SNAP_EDGE;
+ const atT = py <= area.y + SNAP_EDGE;
+ const nearT = py <= area.y + SNAP_CORNER;
+ const nearB = py >= area.y + area.h - SNAP_CORNER;
+ const nearL = px <= area.x + SNAP_CORNER;
+ const nearR = px >= area.x + area.w - SNAP_CORNER;
+ if (atL && nearT) return 'tl';
+ if (atL && nearB) return 'bl';
+ if (atR && nearT) return 'tr';
+ if (atR && nearB) return 'br';
+ if (atT && nearL) return 'tl';
+ if (atT && nearR) return 'tr';
+ if (atT) return 'max';
+ if (atL) return 'left';
+ if (atR) return 'right';
return null;
}
+/** Edge and corner snap targets as fractions of the work area: [x, y, w, h]. */
+const SNAP_FRACTIONS = {
+ max: [0, 0, 1, 1],
+ left: [0, 0, 0.5, 1],
+ right: [0.5, 0, 0.5, 1],
+ tl: [0, 0, 0.5, 0.5],
+ tr: [0.5, 0, 0.5, 0.5],
+ bl: [0, 0.5, 0.5, 0.5],
+ br: [0.5, 0.5, 0.5, 0.5],
+};
+
export function snapRect(zone, area) {
- if (zone === 'max') return { x: area.x, y: area.y, w: area.w, h: area.h };
- const half = Math.floor(area.w / 2);
- if (zone === 'left') return { x: area.x, y: area.y, w: half, h: area.h };
- if (zone === 'right') return { x: area.x + half, y: area.y, w: area.w - half, h: area.h };
- return null;
+ const f = SNAP_FRACTIONS[zone];
+ return f ? fractionRect(f, area) : null;
+}
+
+/**
+ * A fractional [x, y, w, h] cell resolved to pixels. Both edges are rounded
+ * from the area origin, so neighbouring cells share an edge exactly and a
+ * layout always tiles the work area with no gap or overlap.
+ */
+export function fractionRect([fx, fy, fw, fh], area) {
+ const x0 = Math.round(area.x + fx * area.w);
+ const y0 = Math.round(area.y + fy * area.h);
+ const x1 = Math.round(area.x + (fx + fw) * area.w);
+ const y1 = Math.round(area.y + (fy + fh) * area.h);
+ return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };
+}
+
+/**
+ * The Snap layouts flyout (hover the maximize button). Each layout is a set of
+ * zones; picking a zone places the window there and offers the other open
+ * windows for the zones that are left (Snap assist).
+ */
+export const SNAP_LAYOUTS = [
+ { id: 'halves', label: 'Two columns', zones: [[0, 0, 0.5, 1], [0.5, 0, 0.5, 1]] },
+ { id: 'wide-left', label: 'Wide and narrow', zones: [[0, 0, 2 / 3, 1], [2 / 3, 0, 1 / 3, 1]] },
+ { id: 'thirds', label: 'Three columns', zones: [[0, 0, 1 / 3, 1], [1 / 3, 0, 1 / 3, 1], [2 / 3, 0, 1 / 3, 1]] },
+ { id: 'main-stack', label: 'Main and stack', zones: [[0, 0, 0.5, 1], [0.5, 0, 0.5, 0.5], [0.5, 0.5, 0.5, 0.5]] },
+ { id: 'quarters', label: 'Four quarters', zones: [[0, 0, 0.5, 0.5], [0.5, 0, 0.5, 0.5], [0, 0.5, 0.5, 0.5], [0.5, 0.5, 0.5, 0.5]] },
+ { id: 'focus', label: 'Centre focus', zones: [[0, 0, 0.25, 1], [0.25, 0, 0.5, 1], [0.75, 0, 0.25, 1]] },
+];
+
+/** Pixel rect for zone `zone` of layout `layoutId`, or null if either is unknown. */
+export function layoutZoneRect(layoutId, zone, area) {
+ const l = SNAP_LAYOUTS.find((x) => x.id === layoutId);
+ const f = l?.zones[zone];
+ return f ? fractionRect(f, area) : null;
+}
+
+/** Layouts that need more width than the screen has are not offered. */
+export function snapLayoutsFor(area) {
+ return SNAP_LAYOUTS.filter((l) => l.zones.every(([, , fw]) => fw * area.w >= MIN_W));
+}
+
+/**
+ * Dock magnification: the scale of an item whose centre is `dist` px from the
+ * pointer. A cosine falloff gives the smooth bulge of a real dock (peak `max`
+ * at the pointer, 1 at `range` and beyond). Mirrors the curve the macOS web
+ * recreations use, without a spring library.
+ */
+export function dockScale(dist, max = 1.6, range = 150) {
+ const d = Math.abs(dist);
+ if (!Number.isFinite(d) || d >= range) return 1;
+ return 1 + (max - 1) * (Math.cos((Math.PI * d) / range) + 1) / 2;
}
/** Staggered placement for the nth open window so new ones never sit exactly on top. */
@@ -191,6 +266,17 @@ export const ACCENTS = ['#8b5cf6', '#3b91d8', '#ad6eca', '#e5484d', '#f08a24', '
/** How the visitor arrives at `/`: as an avatar walking to the desk, or straight at the desktop. */
export const START_MODES = ['world', 'desktop'];
export const MODES = ['dark', 'light', 'auto'];
+/**
+ * Desktop styles, each a whole shell skin: Fluent is the Windows 11
+ * Mica shell, Aqua puts a menu bar on top and a magnifying dock at the bottom
+ * with traffic-light window controls, Classic is bevelled 9x chrome with a
+ * labelled taskbar. `menuH` and `dockH` are the bars the work area avoids.
+ */
+export const STYLES = {
+ fluent: { label: 'Fluent', menuH: 0, dockH: 48 },
+ aqua: { label: 'Aqua', menuH: 28, dockH: 84 },
+ classic: { label: 'Classic', menuH: 0, dockH: 40 },
+};
export const PREFS_VERSION = 1;
export const DEFAULT_PREFS = {
wall: 'three',
@@ -203,6 +289,7 @@ export const DEFAULT_PREFS = {
avatarHue: 262,
startIn: 'world',
sound: true,
+ style: 'fluent',
};
/** Normalise a rectangle given two corner points (any drag direction). */
@@ -359,6 +446,7 @@ export function sanitizePrefs(raw, wallpaperIds) {
avatarHue: hue,
startIn: START_MODES.includes(d.startIn) ? d.startIn : DEFAULT_PREFS.startIn,
sound: d.sound !== false,
+ style: Object.hasOwn(STYLES, d.style) ? d.style : DEFAULT_PREFS.style,
};
}
diff --git a/src/desktop/main.js b/src/desktop/main.js
index 1250e9053..d13732417 100644
--- a/src/desktop/main.js
+++ b/src/desktop/main.js
@@ -5,6 +5,7 @@
import './theme.css';
import './desktop.css';
+import './styles.css';
import './boot.css';
import { createShell } from './shell.js';
import { APPS } from './apps.js';
diff --git a/src/desktop/shell.js b/src/desktop/shell.js
index 87b9d8908..d9d9699bf 100644
--- a/src/desktop/shell.js
+++ b/src/desktop/shell.js
@@ -12,7 +12,9 @@ import {
EXPORT_KEYS,
ICON_SIZES,
STATE_VERSION,
+ STYLES,
cleanTitle,
+ dockScale,
formatBytes,
initialsOf,
isInternalPath,
@@ -25,7 +27,6 @@ import {
storageBytes,
} from './layout.js';
-const TASK_H = 48;
const NAV_DATA = '/nav-data.js';
const KEY = {
state: 'tws:desktop',
@@ -204,6 +205,14 @@ export async function createShell(root, opts = {}) {
const effectiveTheme = () => (prefs.mode === 'auto' ? (dark.matches ? 'dark' : 'light') : prefs.mode);
let tickClock = null;
let deskIcons = null;
+ // The bars the work area avoids for the current style. On a phone Aqua
+ // falls back to the Fluent taskbar (no menu bar, no magnifying dock).
+ const bars = () => {
+ const st = STYLES[prefs.style] || STYLES.fluent;
+ const small = innerWidth <= 720;
+ return small ? { menuH: 0, dockH: prefs.style === 'aqua' ? STYLES.fluent.dockH : st.dockH } : { menuH: st.menuH, dockH: st.dockH };
+ };
+ let shownStyle = null;
async function applyWall() {
if (prefs.wall === CUSTOM_WALL) {
@@ -222,10 +231,24 @@ export async function createShell(root, opts = {}) {
delete wall.dataset.custom;
root.dataset.wall = prefs.wall;
}
+ function applyStyle() {
+ const { menuH, dockH } = bars();
+ root.dataset.style = prefs.style;
+ root.style.setProperty('--menu-h', `${menuH}px`);
+ root.style.setProperty('--task-h', `${dockH}px`);
+ if (shownStyle === prefs.style) return;
+ const first = shownStyle === null;
+ shownStyle = prefs.style;
+ if (first) return;
+ wm.relayout();
+ deskIcons?.reseat();
+ renderTask();
+ }
function applyPrefs() {
root.style.setProperty('--accent', prefs.accent);
root.style.setProperty('--theme-2', prefs.accent);
task.classList.toggle('left', prefs.taskbarAlign === 'left');
+ applyStyle();
const theme = effectiveTheme();
document.documentElement.setAttribute('data-theme', theme);
store.set(THEME_KEY, theme);
@@ -276,9 +299,14 @@ export async function createShell(root, opts = {}) {
let saveTimer = 0;
const wm = createWM({
layer,
- getMetrics: () => ({ vw: innerWidth, vh: innerHeight, menuH: 0, dockH: TASK_H, mobile: innerWidth <= 720 }),
+ getMetrics: () => ({ vw: innerWidth, vh: innerHeight, ...bars(), mobile: innerWidth <= 720 }),
renderNative: (app, body) => renderNative(app, body),
notify: toast,
+ getTaskRect: (id) => {
+ const b = mid.querySelector(`.os-tb.run[data-app="${CSS.escape(id)}"]`);
+ const r = b?.getBoundingClientRect();
+ return r && r.width ? r : null;
+ },
onChange: ({ windows, focus }) => {
running = windows;
focusId = focus;
@@ -323,7 +351,25 @@ export async function createShell(root, opts = {}) {
btnSearch.title = 'Search';
const left = h('div', 'os-task-left');
- left.append(btnWidgets);
+ // Aqua's menu bar names the app in front, as macOS does. Hidden in other styles.
+ const menuTitle = h('button', 'os-menu-app');
+ menuTitle.type = 'button';
+ menuTitle.addEventListener('click', (e) => {
+ const id = focusId;
+ const r = menuTitle.getBoundingClientRect();
+ e.stopPropagation();
+ if (!id) return toggleStart();
+ const w = running.find((x) => x.id === id);
+ menu(r.left, r.bottom + 4, [
+ ['Minimize', 'minimize', () => wm.minimize(id)],
+ [w && w.maximized ? 'Restore' : 'Zoom', 'maximize', () => wm.toggleMax(id)],
+ ['Snap layouts', 'grid', () => wm.snapLayouts(id)],
+ ['Reload', 'reload', () => wm.reload(id)],
+ '-',
+ [`Quit ${w ? w.title : ''}`.trim(), 'close', () => wm.close(id)],
+ ]);
+ });
+ left.append(btnWidgets, menuTitle);
const mid = h('div', 'os-task-mid');
const right = h('div', 'os-task-right');
task.append(left, mid, right);
@@ -335,13 +381,28 @@ export async function createShell(root, opts = {}) {
running.forEach((w) => {
if (!list.some((a) => a.id === w.id)) list.push(w.app);
});
+ const front = running.find((x) => x.id === focusId && !x.minimized);
+ menuTitle.textContent = front ? front.title : 'three.ws';
+ menuTitle.title = front ? `${front.title} window menu` : 'three.ws';
list.forEach((app) => {
const w = byId.get(app.id);
const b = h('button', `os-tb run${w ? ' open' : ''}${w && !w.minimized && focusId === app.id ? ' on' : ''}`, tile(app, 'xs', 15));
+ if (w) {
+ // Classic shows a labelled button per window; the other styles hide the label.
+ const label = h('span', 'tb-label');
+ label.textContent = w.title;
+ b.append(label);
+ b.addEventListener('pointerenter', (e) => e.pointerType !== 'touch' && peekSoon(app.id, b));
+ b.addEventListener('pointerleave', peekLeave);
+ b.addEventListener('focus', () => peekSoon(app.id, b));
+ b.addEventListener('blur', peekLeave);
+ }
b.type = 'button';
+ b.dataset.app = app.id;
b.title = w ? w.title : app.title;
b.setAttribute('aria-label', w ? `${w.title}, ${w.minimized ? 'minimized' : 'open'}` : `Open ${app.title}`);
b.addEventListener('click', () => {
+ peekHide(true);
if (!w) return launch(app);
if (w.minimized) wm.focus(app.id);
else if (focusId === app.id) wm.minimize(app.id);
@@ -356,8 +417,114 @@ export async function createShell(root, opts = {}) {
});
mid.append(b);
});
+ if (peek.id && !byId.has(peek.id)) peekHide(true);
}
+ // ---------- taskbar peek ----------
+ // Hover a running app for its window card (title, page, close), as on
+ // Windows 11. Hovering the card is Aero Peek: every other
+ // window fades so the one you are pointing at shows through.
+ const peek = { el: null, id: null, showT: 0, hideT: 0 };
+ function peekSoon(id, btn) {
+ clearTimeout(peek.hideT);
+ clearTimeout(peek.showT);
+ if (pop) return;
+ peek.showT = setTimeout(() => peekShow(id, btn), peek.el ? 60 : 400);
+ }
+ function peekLeave() {
+ clearTimeout(peek.showT);
+ clearTimeout(peek.hideT);
+ peek.hideT = setTimeout(() => peekHide(), 220);
+ }
+ function peekHide(now = false) {
+ clearTimeout(peek.showT);
+ clearTimeout(peek.hideT);
+ layer.classList.remove('is-peek');
+ layer.querySelectorAll('.win.is-peeked').forEach((el) => el.classList.remove('is-peeked'));
+ if (!peek.el) return;
+ const el = peek.el;
+ peek.el = null;
+ peek.id = null;
+ if (now) el.remove();
+ else {
+ el.classList.add('is-leaving');
+ el.addEventListener('animationend', () => el.remove(), { once: true });
+ }
+ }
+ function peekShow(id, btn) {
+ const w = running.find((x) => x.id === id);
+ if (!w || !btn.isConnected) return peekHide(true);
+ const had = !!peek.el;
+ peek.el?.remove();
+ const el = h('div', `os-peek${had ? ' is-moving' : ''}`);
+ el.setAttribute('role', 'tooltip');
+ const where = w.app.native ? 'three.ws app' : w.path || w.app.href;
+ el.innerHTML =
+ `<div class="pk-head">${tile(w.app, 'xs', 14)}<b></b><button type="button" class="pk-x" aria-label="Close window" title="Close">${icon('close', 14)}</button></div>` +
+ `<div class="pk-body" style="--hue:${w.app.hue}">${tile(w.app, '', 24)}<small></small><span class="pk-state"></span></div>`;
+ el.querySelector('b').textContent = w.title;
+ el.querySelector('small').textContent = where;
+ el.querySelector('.pk-state').textContent = w.minimized ? 'Minimized' : w.maximized ? 'Maximized' : focusId === id ? 'In front' : 'Open';
+ el.querySelector('.pk-x').addEventListener('click', (e) => {
+ e.stopPropagation();
+ peekHide(true);
+ wm.close(id);
+ });
+ el.addEventListener('click', () => {
+ peekHide(true);
+ wm.focus(id);
+ });
+ el.addEventListener('pointerenter', () => {
+ clearTimeout(peek.hideT);
+ if (w.minimized) return;
+ layer.classList.add('is-peek');
+ layer.querySelector(`.win[data-app="${CSS.escape(id)}"]`)?.classList.add('is-peeked');
+ });
+ el.addEventListener('pointerleave', () => {
+ layer.classList.remove('is-peek');
+ layer.querySelectorAll('.win.is-peeked').forEach((x) => x.classList.remove('is-peeked'));
+ peekLeave();
+ });
+ root.append(el);
+ const b = btn.getBoundingClientRect();
+ const r = el.getBoundingClientRect();
+ const x = Math.max(8, Math.min(b.left + b.width / 2 - r.width / 2, innerWidth - r.width - 8));
+ el.style.left = `${x}px`;
+ if (prefs.style === 'aqua' || b.top > innerHeight / 2) el.style.bottom = `${innerHeight - b.top + 8}px`;
+ else el.style.top = `${b.bottom + 8}px`;
+ peek.el = el;
+ peek.id = id;
+ }
+
+ // ---------- dock magnification (Aqua) ----------
+ // Every dock item scales with its distance from the pointer (dockScale in
+ // layout.js), then eases back when the pointer leaves the dock.
+ let dockRaf = 0;
+ let dockX = null;
+ function paintDock() {
+ dockRaf = 0;
+ const items = mid.querySelectorAll('.os-tb');
+ items.forEach((b) => {
+ let s = 1;
+ if (dockX != null) {
+ const r = b.getBoundingClientRect();
+ s = dockScale(dockX - (r.left + r.width / 2), 1.55, 140);
+ }
+ b.style.setProperty('--mag', s.toFixed(3));
+ });
+ }
+ const dockOn = () => prefs.style === 'aqua' && innerWidth > 720 && !matchMedia('(prefers-reduced-motion: reduce)').matches;
+ mid.addEventListener('pointermove', (e) => {
+ if (e.pointerType === 'touch' || !dockOn()) return;
+ dockX = e.clientX;
+ if (!dockRaf) dockRaf = requestAnimationFrame(paintDock);
+ });
+ mid.addEventListener('pointerleave', () => {
+ if (dockX == null) return;
+ dockX = null;
+ if (!dockRaf) dockRaf = requestAnimationFrame(paintDock);
+ });
+
// tray
const tray = h('div', 'os-tray');
const btnTheme = h('button', 'os-tb', '');
@@ -463,6 +630,7 @@ export async function createShell(root, opts = {}) {
const same = pop && pop.kind === kind;
closePops();
if (same) return false;
+ peekHide(true);
root.append(el);
trigger?.setAttribute('aria-expanded', 'true');
pop = { kind, el, trigger, onClose };
@@ -728,7 +896,8 @@ export async function createShell(root, opts = {}) {
root.append(el);
const r = el.getBoundingClientRect();
el.style.left = `${Math.max(4, Math.min(x, innerWidth - r.width - 4))}px`;
- el.style.top = `${Math.max(4, Math.min(y, innerHeight - r.height - TASK_H - 4))}px`;
+ const { menuH, dockH } = bars();
+ el.style.top = `${Math.max(menuH + 4, Math.min(y, innerHeight - r.height - dockH - 4))}px`;
el.style.bottom = 'auto';
pop = { kind: 'ctx', el, trigger: null };
el.querySelector('button')?.focus();
@@ -796,10 +965,19 @@ export async function createShell(root, opts = {}) {
} else if (e.altKey && e.key.toLowerCase() === 'w' && wm.focused()) {
e.preventDefault();
wm.close(wm.focused());
+ } else if (e.altKey && !mod && e.key.toLowerCase() === 'z' && wm.focused()) {
+ e.preventDefault();
+ wm.snapLayouts(wm.focused());
+ } else if (e.ctrlKey && e.altKey && wm.focused()) {
+ const dir = { ArrowLeft: 'left', ArrowRight: 'right', ArrowUp: 'up', ArrowDown: 'down' }[e.key];
+ if (!dir) return;
+ e.preventDefault();
+ wm.snapKey(wm.focused(), dir);
}
});
let resizeT = 0;
addEventListener('resize', () => {
+ applyStyle();
wm.relayout();
clearTimeout(resizeT);
resizeT = setTimeout(() => deskIcons.reseat(), 120);
@@ -988,6 +1166,29 @@ export async function createShell(root, opts = {}) {
function paintPersonalize() {
pane.append(h('h2', '', 'Personalization'));
+ pane.append(h('h3', '', 'Style'));
+ pane.append(h('p', '', 'The whole shell, not just the colours: windows, taskbar, menus and motion.'));
+ const styles = h('div', 'styles');
+ const STYLE_NOTES = {
+ fluent: 'Mica windows, a centred taskbar and Snap layouts.',
+ aqua: 'A menu bar on top, a magnifying dock and traffic-light controls.',
+ classic: 'Bevelled 9x chrome with a labelled taskbar.',
+ };
+ Object.entries(STYLES).forEach(([id, st]) => {
+ const b = h(
+ 'button',
+ 'style-opt',
+ `<i class="style-prev" data-prev="${id}" aria-hidden="true"><s class="sp-win"><s class="sp-bar"></s></s><s class="sp-task"></s></i><b>${esc(st.label)}</b><small>${esc(STYLE_NOTES[id])}</small>`,
+ );
+ b.type = 'button';
+ b.setAttribute('aria-pressed', String(prefs.style === id));
+ b.addEventListener('click', () => {
+ setPrefs({ style: id });
+ styles.querySelectorAll('.style-opt').forEach((o) => o.setAttribute('aria-pressed', String(o === b)));
+ });
+ styles.append(b);
+ });
+ pane.append(styles);
pane.append(h('h3', '', 'Theme'));
pane.append(seg([['dark', 'Dark'], ['light', 'Light'], ['auto', 'Match system']], prefs.mode, (v) => setPrefs({ mode: v })));
pane.append(h('h3', '', 'Accent colour'));
diff --git a/src/desktop/styles.css b/src/desktop/styles.css
new file mode 100644
index 000000000..e55575053
--- /dev/null
+++ b/src/desktop/styles.css
@@ -0,0 +1,1012 @@
+/* three.ws Desktop: Snap layouts, Snap assist, taskbar peek and the three
+ * shell styles (Fluent, Aqua, Classic). Loaded after desktop.css, so the
+ * rules here refine the base shell. The active style is .os[data-style];
+ * shell.js also sets --menu-h and --task-h for it (see STYLES in layout.js). */
+
+.os {
+ --menu-h: 0px;
+ --ease-out: cubic-bezier(0.1, 0.9, 0.2, 1);
+}
+
+/* Desktop icons sit between the menu bar (Aqua) and the taskbar or dock. */
+.os-icons {
+ top: var(--menu-h);
+ height: calc(100% - var(--task-h) - var(--menu-h));
+}
+
+/* Layered window shadow: a tight contact shadow plus a long soft one. */
+.win.is-focused {
+ box-shadow:
+ 0 8.5px 10px rgba(0, 0, 0, 0.115),
+ 0 68px 80px rgba(0, 0, 0, 0.23),
+ 0 0 0 1px rgba(0, 0, 0, 0.12);
+}
+
+/* Taskbar indicator: pinned apps that are not running show nothing, a
+ * running app a short grey pill, the window in front a long accent pill. */
+.os-tb.run::after {
+ background: #858585;
+}
+.os-tb.run:not(.open)::after {
+ width: 0;
+ margin-left: 0;
+ opacity: 0;
+}
+.os-tb.run.on::after {
+ background: var(--accent);
+}
+.tb-label,
+.os .os-menu-app {
+ display: none;
+}
+
+/* ---------- Snap layouts flyout ---------- */
+.snap-fly {
+ position: absolute;
+ z-index: 99990;
+ display: grid;
+ grid-template-columns: repeat(3, 76px);
+ gap: 10px;
+ padding: 12px;
+ border-radius: 10px;
+ background: var(--cm);
+ backdrop-filter: var(--blur-heavy);
+ border: 1px solid var(--hr);
+ box-shadow: var(--shadow-lg);
+ transform-origin: top center;
+ animation: snap-fly-in 0.18s var(--ease-out);
+}
+@keyframes snap-fly-in {
+ from {
+ opacity: 0;
+ transform: scale(0.92);
+ }
+}
+.snap-lay {
+ position: relative;
+ height: 50px;
+}
+.snap-zone {
+ position: absolute;
+ border: 2px solid transparent;
+ background-clip: padding-box;
+ border-radius: 5px;
+ background-color: var(--hover-b);
+ box-shadow: inset 0 0 0 1px var(--hr);
+ transition: background-color 0.12s;
+}
+.os .snap-zone {
+ background-color: var(--hover-b);
+}
+.os .snap-zone:hover,
+.os .snap-zone:focus-visible {
+ background-color: var(--accent);
+ outline: 0;
+}
+
+/* ---------- Snap assist ---------- */
+.snap-assist {
+ position: absolute;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: rgba(0, 0, 0, 0.32);
+ animation: snap-assist-in 0.2s ease-out;
+}
+@keyframes snap-assist-in {
+ from {
+ opacity: 0;
+ }
+}
+.snap-slot {
+ position: absolute;
+}
+.snap-slot::before {
+ content: '';
+ position: absolute;
+ inset: 6px;
+ border-radius: 10px;
+ background: var(--bg50);
+ border: 1px solid var(--hr);
+ backdrop-filter: var(--blur-light);
+ transition: border-color 0.15s, background 0.15s;
+}
+.snap-slot:not(.is-active) {
+ cursor: pointer;
+}
+.snap-slot:not(.is-active):hover::before {
+ border-color: var(--text2);
+}
+.snap-slot.is-active::before {
+ border: 2px solid var(--accent);
+ background: var(--material-thick);
+}
+.snap-cands {
+ position: absolute;
+ inset: 8px;
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
+ align-content: center;
+ gap: 10px;
+ padding: 16px;
+ overflow-y: auto;
+ scrollbar-width: thin;
+}
+.snap-cand {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 8px;
+ min-width: 0;
+ padding: 16px 10px 12px;
+ border-radius: 10px;
+ background: var(--card);
+ border: 1px solid var(--hr);
+ font-size: 12px;
+ transition: transform 0.15s var(--ease-out), border-color 0.15s, background 0.15s;
+ animation: snap-cand-in 0.24s var(--ease-out) backwards;
+}
+.snap-cand:nth-child(2) {
+ animation-delay: 30ms;
+}
+.snap-cand:nth-child(3) {
+ animation-delay: 60ms;
+}
+.snap-cand:nth-child(n + 4) {
+ animation-delay: 90ms;
+}
+@keyframes snap-cand-in {
+ from {
+ opacity: 0;
+ transform: translateY(8px) scale(0.96);
+ }
+}
+.snap-cand:hover,
+.snap-cand:focus-visible {
+ border-color: var(--accent);
+ background: var(--hover-b);
+ transform: translateY(-2px);
+}
+.snap-cand:active {
+ transform: scale(0.97);
+}
+.snap-cand-t {
+ max-width: 100%;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+/* ---------- Taskbar peek and Aero Peek ---------- */
+.os-peek {
+ position: absolute;
+ z-index: 10003;
+ width: 232px;
+ padding: 6px;
+ border-radius: 10px;
+ background: var(--cm);
+ backdrop-filter: var(--blur-heavy);
+ border: 1px solid var(--hr);
+ box-shadow: var(--shadow-lg);
+ cursor: pointer;
+ animation: peek-in 0.18s var(--ease-out);
+}
+.os-peek.is-moving {
+ animation: none;
+}
+.os-peek.is-leaving {
+ animation: peek-out 0.14s ease-in forwards;
+ pointer-events: none;
+}
+@keyframes peek-in {
+ from {
+ opacity: 0;
+ transform: translateY(6px);
+ }
+}
+@keyframes peek-out {
+ to {
+ opacity: 0;
+ transform: translateY(4px);
+ }
+}
+.pk-head {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 2px 2px 6px 4px;
+ font-size: 12px;
+}
+.pk-head b {
+ flex: 1;
+ min-width: 0;
+ font-weight: 500;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+.pk-head .app-tile {
+ width: 20px;
+ height: 20px;
+ border-radius: 6px;
+ box-shadow: none;
+}
+.os .pk-x {
+ display: grid;
+ place-items: center;
+ width: 26px;
+ height: 26px;
+ border-radius: 6px;
+ opacity: 0.75;
+ transition: background 0.12s, opacity 0.12s;
+}
+.os .pk-x:hover {
+ background: #c42b1c;
+ color: #fff;
+ opacity: 1;
+}
+.pk-body {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ gap: 6px;
+ height: 116px;
+ padding: 10px;
+ border-radius: 7px;
+ background:
+ radial-gradient(120% 90% at 50% 0%, hsl(var(--hue) 70% 50% / 0.35), transparent 70%),
+ var(--card);
+ border: 1px solid var(--hr);
+ font-size: 11px;
+ text-align: center;
+ transition: border-color 0.15s;
+}
+.os-peek:hover .pk-body {
+ border-color: var(--accent);
+}
+.pk-body small {
+ max-width: 100%;
+ color: var(--text2);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+.pk-state {
+ padding: 1px 8px;
+ border-radius: 99px;
+ background: var(--fill);
+ font-size: 10px;
+ letter-spacing: 0.02em;
+}
+.os-layer .win {
+ transition:
+ box-shadow 0.2s,
+ opacity 0.25s,
+ transform 0.2s;
+}
+.os-layer.is-peek .win:not(.is-peeked) {
+ opacity: 0.06;
+}
+.os-layer.is-peek .win.is-peeked {
+ box-shadow:
+ 0 0 0 2px var(--accent),
+ var(--shadow-lg);
+}
+
+/* ---------- Settings: style picker ---------- */
+.styles {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
+ gap: 10px;
+}
+.style-opt {
+ display: flex;
+ flex-direction: column;
+ gap: 3px;
+ padding: 8px 8px 10px;
+ border-radius: 10px;
+ border: 2px solid transparent;
+ background: var(--card);
+ text-align: left;
+ transition: border-color 0.15s, background 0.15s;
+}
+.style-opt:hover {
+ border-color: var(--hr);
+ background: var(--hover-b);
+}
+.style-opt[aria-pressed='true'] {
+ border-color: var(--accent);
+}
+.style-opt b {
+ margin-top: 5px;
+ font-size: 13px;
+ font-weight: 600;
+}
+.style-opt small {
+ color: var(--text2);
+ font-size: 11px;
+ line-height: 1.35;
+}
+.style-prev {
+ position: relative;
+ display: block;
+ height: 86px;
+ border-radius: 6px;
+ overflow: hidden;
+ background: linear-gradient(150deg, #3a2a55, #16325c 60%, #0e1c33);
+}
+.style-prev s {
+ position: absolute;
+ display: block;
+ text-decoration: none;
+}
+.style-prev .sp-win {
+ left: 16%;
+ top: 14%;
+ width: 62%;
+ height: 52%;
+ border-radius: 4px;
+ background: #1d1d22;
+ border: 1px solid #ffffff22;
+ box-shadow: 0 6px 14px #0007;
+}
+.style-prev .sp-bar {
+ left: 0;
+ right: 0;
+ top: 0;
+ height: 8px;
+ background:
+ linear-gradient(90deg, transparent calc(100% - 22px), #ffffff30 calc(100% - 22px)),
+ #2a2a32;
+}
+.style-prev .sp-task {
+ left: 0;
+ right: 0;
+ bottom: 0;
+ height: 11px;
+ background:
+ radial-gradient(circle at 42% 50%, #6aa7ff 2px, transparent 2.6px),
+ radial-gradient(circle at 50% 50%, #c9a7ff 2px, transparent 2.6px),
+ radial-gradient(circle at 58% 50%, #7ee0b5 2px, transparent 2.6px),
+ #111a;
+ border-top: 1px solid #ffffff1c;
+}
+.style-prev[data-prev='aqua']::before {
+ content: '';
+ position: absolute;
+ left: 0;
+ right: 0;
+ top: 0;
+ height: 7px;
+ background: #ffffff40;
+}
+.style-prev[data-prev='aqua'] .sp-win {
+ top: 18%;
+ border-radius: 5px;
+}
+.style-prev[data-prev='aqua'] .sp-bar {
+ background:
+ radial-gradient(circle at 5px 4px, #ff5f57 1.7px, transparent 2.2px),
+ radial-gradient(circle at 11px 4px, #febc2e 1.7px, transparent 2.2px),
+ radial-gradient(circle at 17px 4px, #28c840 1.7px, transparent 2.2px),
+ #2a2a32;
+}
+.style-prev[data-prev='aqua'] .sp-task {
+ left: 28%;
+ right: 28%;
+ bottom: 4px;
+ height: 12px;
+ border-radius: 4px;
+ border: 1px solid #ffffff33;
+ background:
+ radial-gradient(circle at 30% 50%, #6aa7ff 2.6px, transparent 3.2px),
+ radial-gradient(circle at 50% 50%, #c9a7ff 3.4px, transparent 4px),
+ radial-gradient(circle at 70% 50%, #7ee0b5 2.6px, transparent 3.2px),
+ #ffffff2a;
+}
+.style-prev[data-prev='classic'] {
+ background: #008080;
+}
+.style-prev[data-prev='classic'] .sp-win {
+ border-radius: 0;
+ border: 0;
+ background: #c0c0c0;
+ box-shadow:
+ inset -1px -1px #0a0a0a,
+ inset 1px 1px #fff;
+}
+.style-prev[data-prev='classic'] .sp-bar {
+ left: 2px;
+ right: 2px;
+ top: 2px;
+ height: 7px;
+ background: linear-gradient(90deg, #000080, #1084d0);
+}
+.style-prev[data-prev='classic'] .sp-task {
+ height: 12px;
+ border-top: 1px solid #fff;
+ background:
+ linear-gradient(#c0c0c0, #c0c0c0) 3px 2px / 18px 8px no-repeat,
+ linear-gradient(#0a0a0a, #0a0a0a) 4px 3px / 18px 8px no-repeat,
+ linear-gradient(#a8a8a8, #a8a8a8) 26px 2px / 34px 8px no-repeat,
+ #c0c0c0;
+}
+
+/* =================================================================
+ * Aqua: a menu bar across the top, a floating magnifying dock and
+ * traffic-light window controls. Desktop widths only; on a phone the
+ * shell falls back to the Fluent taskbar (shell.js bars()).
+ * ================================================================= */
+@media (min-width: 721px) {
+ .os[data-style='aqua'] .os-task {
+ display: contents;
+ }
+ .os[data-style='aqua'] .os-task-right {
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ height: var(--menu-h);
+ padding: 0 6px 0 0;
+ gap: 0;
+ background: var(--bg70);
+ backdrop-filter: var(--blur-medium);
+ border-bottom: 1px solid var(--hr);
+ z-index: 10000;
+ font-size: 13px;
+ }
+ .os[data-style='aqua'] .os-task-left {
+ position: absolute;
+ top: 0;
+ left: 6px;
+ height: var(--menu-h);
+ gap: 2px;
+ z-index: 10001;
+ }
+ .os[data-style='aqua'] .os-task-left .os-tb,
+ .os[data-style='aqua'] .os-task-right .os-tb {
+ width: 30px;
+ height: calc(var(--menu-h) - 4px);
+ border-radius: 5px;
+ }
+ .os[data-style='aqua'] .os-task-left .ico,
+ .os[data-style='aqua'] .os-task-right .ico {
+ width: 16px;
+ height: 16px;
+ }
+ .os[data-style='aqua'] .os-clock,
+ .os[data-style='aqua'] .os-chip {
+ height: calc(var(--menu-h) - 4px);
+ border-radius: 5px;
+ padding: 0 8px;
+ }
+ .os[data-style='aqua'] .os-clock {
+ flex-direction: row-reverse;
+ align-items: center;
+ gap: 8px;
+ font-size: 13px;
+ }
+ .os[data-style='aqua'] .os .os-menu-app,
+ .os[data-style='aqua'] .os-menu-app {
+ display: flex;
+ align-items: center;
+ max-width: 260px;
+ height: calc(var(--menu-h) - 4px);
+ padding: 0 9px;
+ border-radius: 5px;
+ font-size: 13px;
+ font-weight: 700;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+ .os[data-style='aqua'] .os-menu-app:hover,
+ .os[data-style='aqua'] .os-menu-app:focus-visible {
+ background: var(--hover-b);
+ }
+
+ /* The dock */
+ .os[data-style='aqua'] .os-task-mid {
+ position: absolute;
+ left: 50%;
+ bottom: 8px;
+ transform: translateX(-50%);
+ z-index: 10000;
+ max-width: calc(100vw - 24px);
+ height: 64px;
+ align-items: flex-end;
+ gap: 6px;
+ padding: 6px 8px;
+ border-radius: 20px;
+ background: color-mix(in srgb, var(--bg) 42%, transparent);
+ backdrop-filter: var(--blur-heavy);
+ border: 1px solid var(--hr);
+ box-shadow:
+ inset 0 1px 0 #ffffff26,
+ 0 10px 30px #0006;
+ }
+ .os[data-style='aqua'] .os-task-mid .os-tb {
+ --mag: 1;
+ width: 50px;
+ height: 50px;
+ border-radius: 12px;
+ transform: scale(var(--mag));
+ transform-origin: 50% 100%;
+ margin-inline: calc((var(--mag) - 1) * 25px);
+ transition:
+ transform 0.12s ease-out,
+ margin 0.12s ease-out;
+ }
+ .os[data-style='aqua'] .os-task-mid .os-tb:hover,
+ .os[data-style='aqua'] .os-task-mid .os-tb.run.on,
+ .os[data-style='aqua'] .os-task-mid .os-tb[aria-expanded='true'] {
+ background: none;
+ }
+ .os[data-style='aqua'] .os-task-mid .os-tb:active {
+ transform: scale(var(--mag));
+ filter: brightness(0.75);
+ }
+ .os[data-style='aqua'] .os-task-mid .app-tile.xs {
+ width: 46px;
+ height: 46px;
+ border-radius: 12px;
+ }
+ .os[data-style='aqua'] .os-task-mid .app-tile.xs .ico {
+ width: 24px;
+ height: 24px;
+ }
+ .os[data-style='aqua'] .os-task-mid .os-tb.start,
+ .os[data-style='aqua'] .os-task-mid .os-tb.hide-sm {
+ border-radius: 12px;
+ background: var(--card);
+ box-shadow:
+ inset 0 1px 0 #ffffff22,
+ 0 4px 12px #0004;
+ }
+ .os[data-style='aqua'] .os-task-mid .os-tb.hide-sm {
+ margin-right: calc(8px + (var(--mag) - 1) * 25px);
+ }
+ .os[data-style='aqua'] .os-task-mid .os-tb.hide-sm::after {
+ content: '';
+ position: absolute;
+ top: 6px;
+ bottom: 6px;
+ right: -8px;
+ width: 1px;
+ background: var(--hr);
+ }
+ .os[data-style='aqua'] .os-tb.run::after {
+ bottom: -5px;
+ width: 4px;
+ height: 4px;
+ margin-left: -2px;
+ border-radius: 50%;
+ background: var(--text);
+ }
+ .os[data-style='aqua'] .os-tb.run:not(.open)::after {
+ opacity: 0;
+ }
+
+ /* Windows: rounder, traffic lights on the left, title centred. */
+ .os[data-style='aqua'] .win {
+ border-radius: 12px;
+ }
+ .os[data-style='aqua'] .win.is-max {
+ border-radius: 0;
+ }
+ /* order: -1 also moves the controls under the bar's Mica layer in paint
+ * order, so they and the title sit on their own layer above it. */
+ .os[data-style='aqua'] .win-ctl {
+ order: -1;
+ z-index: 1;
+ align-self: center;
+ align-items: center;
+ gap: 8px;
+ padding: 0 4px 0 13px;
+ }
+ .os[data-style='aqua'] .win-bar .win-btn {
+ width: 12px;
+ height: 12px;
+ border-radius: 50%;
+ opacity: 1;
+ color: #0009;
+ box-shadow: inset 0 0 0 0.5px #0003;
+ transition: filter 0.12s;
+ }
+ .os[data-style='aqua'] .win-bar .win-close {
+ order: 0;
+ background: #ff5f57;
+ }
+ .os[data-style='aqua'] .win-bar .win-min {
+ order: 1;
+ background: #febc2e;
+ }
+ .os[data-style='aqua'] .win-bar .win-maxbtn {
+ order: 2;
+ background: #28c840;
+ }
+ .os[data-style='aqua'] .win:not(.is-focused) .win-ctl:not(:hover) .win-btn {
+ background: var(--hover-b);
+ box-shadow: inset 0 0 0 0.5px var(--hr);
+ }
+ .os[data-style='aqua'] .win-bar .win-btn:hover,
+ .os[data-style='aqua'] .win-bar .win-close:hover {
+ color: #0009;
+ }
+ .os[data-style='aqua'] .win-bar .win-btn:active {
+ filter: brightness(0.8);
+ }
+ .os[data-style='aqua'] .win-bar .win-btn .ico {
+ width: 8px;
+ height: 8px;
+ opacity: 0;
+ transition: opacity 0.1s;
+ }
+ .os[data-style='aqua'] .win-ctl:hover .win-btn .ico,
+ .os[data-style='aqua'] .win-ctl:focus-within .win-btn .ico {
+ opacity: 1;
+ }
+ .os[data-style='aqua'] .win-bar {
+ position: relative;
+ }
+ .os[data-style='aqua'] .win-bar > .win-title {
+ position: absolute;
+ left: 0;
+ right: 0;
+ top: 0;
+ bottom: 0;
+ justify-content: center;
+ padding: 0 96px;
+ z-index: 1;
+ pointer-events: none;
+ font-weight: 600;
+ }
+ .os[data-style='aqua'] .win-tools {
+ margin-left: auto;
+ }
+
+ /* Popovers hang from the menu bar, Start rises from the dock. */
+ .os[data-style='aqua'] .widgets {
+ top: calc(var(--menu-h) + 6px);
+ bottom: auto;
+ max-height: calc(100vh - var(--menu-h) - var(--task-h) - 16px);
+ transform-origin: top left;
+ animation-name: pop-down;
+ }
+ .os[data-style='aqua'] .calendar {
+ top: calc(var(--menu-h) + 6px);
+ bottom: auto;
+ transform-origin: top right;
+ animation-name: pop-down;
+ }
+ .os[data-style='aqua'] .os-toasts {
+ top: calc(var(--menu-h) + 12px);
+ bottom: auto;
+ }
+}
+@keyframes pop-down {
+ from {
+ opacity: 0;
+ transform: translateY(-10px) scale(0.98);
+ }
+}
+
+/* =================================================================
+ * Classic: bevelled 9x chrome. Grey face, navy title bars, square
+ * corners, a labelled taskbar. The chrome keeps its own palette in
+ * both themes; app content keeps the visitor's theme.
+ * ================================================================= */
+.os[data-style='classic'] {
+ --c-face: #c0c0c0;
+ --c-bevel-out: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px #808080, inset 2px 2px #dfdfdf;
+ --c-bevel-in: inset -1px -1px #fff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px #808080;
+}
+.os[data-style='classic'] :is(.os-task, .os-pop, .os-peek, .snap-fly, .win-bar, .os-toast) {
+ --text: #000;
+ --text2: #404040;
+ --hover-b: #d4d0c8;
+ --hover-half: transparent;
+ --fill: #a8a8a8;
+ --hr: #808080;
+ --card: #d4d0c8;
+ --cm: var(--c-face);
+ --bg50: #c0c0c0;
+ --material-thick: #c0c0c0;
+ --accent: #000080;
+ color: #000;
+ font-family: Tahoma, 'MS Sans Serif', 'Segoe UI', sans-serif;
+}
+.os[data-style='classic'] .os-icon .os-label {
+ font-family: Tahoma, 'MS Sans Serif', 'Segoe UI', sans-serif;
+}
+.os[data-style='classic'] .os-icons .os-icon.is-sel {
+ background: none;
+ border: 1px dotted #fff;
+}
+.os[data-style='classic'] .os-icons .os-icon.is-sel .os-label {
+ background: #000080;
+}
+
+/* Windows */
+.os[data-style='classic'] .win {
+ border-radius: 0;
+ border: 0;
+ padding: 3px;
+ background: var(--c-face);
+ box-shadow: var(--c-bevel-out);
+}
+.os[data-style='classic'] .win.is-focused {
+ box-shadow: var(--c-bevel-out), 4px 4px 0 #0003;
+}
+.os[data-style='classic'] .win.is-max {
+ padding: 0;
+}
+.os[data-style='classic'] .win.is-opening,
+.os[data-style='classic'] .win.is-closing {
+ animation-duration: 0.01ms;
+}
+.os[data-style='classic'] .win-bar,
+.os[data-style='classic'] .win.is-focused .win-bar {
+ height: 22px;
+ padding: 0 2px;
+ border: 0;
+ color: #fff;
+ background: linear-gradient(90deg, #808080, #b5b5b5);
+}
+.os[data-style='classic'] .win.is-focused .win-bar {
+ background: linear-gradient(90deg, #000080, #1084d0);
+}
+.os[data-style='classic'] .win.is-focused .win-bar::before {
+ display: none;
+}
+.os[data-style='classic'] .win-title {
+ padding-left: 3px;
+ gap: 5px;
+ font-size: 12px;
+ font-weight: 700;
+}
+.os[data-style='classic'] .win-glyph {
+ color: #fff;
+}
+.os[data-style='classic'] .win-glyph .ico {
+ width: 14px;
+ height: 14px;
+}
+.os[data-style='classic'] .win-tools {
+ gap: 2px;
+ padding-right: 4px;
+}
+.os[data-style='classic'] .win-ctl {
+ align-self: center;
+ gap: 0;
+}
+.os[data-style='classic'] .win-bar :is(.win-btn, .win-tool) {
+ width: 16px;
+ height: 14px;
+ border-radius: 0;
+ color: #000;
+ opacity: 1;
+ background: var(--c-face);
+ box-shadow: var(--c-bevel-out);
+}
+.os[data-style='classic'] .win-bar .win-close {
+ margin-left: 2px;
+}
+.os[data-style='classic'] .win-bar :is(.win-btn, .win-tool):hover,
+.os[data-style='classic'] .win-bar .win-btn.win-close:hover {
+ background: var(--c-face);
+ color: #000;
+}
+.os[data-style='classic'] .win-bar :is(.win-btn, .win-tool):active,
+.os[data-style='classic'] .win-bar .win-btn.win-close:active {
+ background: var(--c-face);
+ box-shadow: var(--c-bevel-in);
+}
+.os[data-style='classic'] .win-bar :is(.win-btn, .win-tool) .ico {
+ width: 9px;
+ height: 9px;
+ stroke-width: 3;
+}
+.os[data-style='classic'] .win-body {
+ margin-top: 2px;
+ box-shadow: inset 1px 1px #808080;
+}
+.os[data-style='classic'] .win-snap {
+ border-radius: 0;
+ border: 2px dotted #fff;
+ background: #ffffff18;
+ backdrop-filter: none;
+}
+
+/* Taskbar */
+.os[data-style='classic'] .os-task {
+ grid-template-columns: auto 1fr auto;
+ padding: 0 2px;
+ gap: 4px;
+ background: var(--c-face);
+ backdrop-filter: none;
+ border-top: 0;
+ box-shadow:
+ inset 0 1px #dfdfdf,
+ inset 0 2px #fff;
+}
+.os[data-style='classic'] .os-task-mid {
+ justify-content: flex-start;
+ gap: 2px;
+ min-width: 0;
+ overflow: hidden;
+}
+.os[data-style='classic'] .os-tb {
+ width: 28px;
+ height: 30px;
+ border-radius: 0;
+ transition: none;
+}
+.os[data-style='classic'] .os-tb:hover,
+.os[data-style='classic'] .os-tb[aria-pressed='true'] {
+ background: none;
+}
+.os[data-style='classic'] .os-tb:active {
+ transform: none;
+ box-shadow: var(--c-bevel-in);
+}
+.os[data-style='classic'] .os-tb .app-tile.xs {
+ width: 20px;
+ height: 20px;
+ border-radius: 3px;
+ box-shadow: none;
+}
+.os[data-style='classic'] .os-tb.start {
+ width: auto;
+ padding: 0 6px;
+ color: #000;
+ box-shadow: var(--c-bevel-out);
+}
+.os[data-style='classic'] .os-tb.start .ico {
+ filter: none;
+}
+.os[data-style='classic'] .os-tb.start[aria-expanded='true'] {
+ box-shadow: var(--c-bevel-in);
+ background: none;
+}
+.os[data-style='classic'] .os-tb.hide-sm {
+ margin-right: 6px;
+}
+.os[data-style='classic'] .os-tb.run.open {
+ display: flex;
+ justify-content: flex-start;
+ gap: 5px;
+ width: 156px;
+ min-width: 72px;
+ flex: 0 1 156px;
+ padding: 0 6px;
+ box-shadow: var(--c-bevel-out);
+}
+.os[data-style='classic'] .os-tb.run.on {
+ box-shadow: var(--c-bevel-in);
+ background: repeating-conic-gradient(#fff 0 25%, var(--c-face) 0 50%) 0 0 / 2px 2px;
+ font-weight: 700;
+}
+.os[data-style='classic'] .os-tb.run::after {
+ display: none;
+}
+.os[data-style='classic'] .tb-label {
+ display: block;
+ min-width: 0;
+ font-size: 12px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+.os[data-style='classic'] .os-task-right {
+ height: 30px;
+ padding: 0 2px 0 6px;
+ box-shadow: inset 1px 1px #808080, inset -1px -1px #fff;
+}
+.os[data-style='classic'] .os-task-right .os-tb {
+ width: 24px;
+ height: 24px;
+}
+.os[data-style='classic'] .os-clock,
+.os[data-style='classic'] .os-chip {
+ height: 26px;
+ border-radius: 0;
+}
+.os[data-style='classic'] .os-clock {
+ flex-direction: row-reverse;
+ align-items: center;
+ gap: 6px;
+}
+.os[data-style='classic'] .os-clock:hover,
+.os[data-style='classic'] .os-chip:hover {
+ background: none;
+}
+
+/* Popovers, menus, toasts, peek, flyout */
+.os[data-style='classic'] :is(.os-pop, .os-peek, .snap-fly, .os-toast) {
+ border: 0;
+ border-radius: 0;
+ backdrop-filter: none;
+ background: var(--c-face);
+ box-shadow: var(--c-bevel-out), 2px 2px 0 #0004;
+ animation-duration: 0.01ms;
+}
+.os[data-style='classic'] .ctx {
+ padding: 3px;
+}
+.os[data-style='classic'] .ctx button {
+ border-radius: 0;
+ padding: 4px 10px;
+ font-size: 12px;
+}
+.os[data-style='classic'] .ctx button:hover,
+.os[data-style='classic'] .ctx button:focus-visible {
+ background: #000080;
+ color: #fff;
+ outline: 0;
+}
+.os[data-style='classic'] .ctx hr {
+ border-top: 1px solid #808080;
+ border-bottom: 1px solid #fff;
+ margin: 3px 2px;
+}
+.os[data-style='classic'] :is(.wg-card, .pk-body, .snap-cand) {
+ border-radius: 0;
+ border: 0;
+ background: #fff;
+ box-shadow: inset 1px 1px #808080, inset -1px -1px #dfdfdf;
+}
+.os[data-style='classic'] .snap-zone {
+ border-radius: 0;
+ box-shadow: inset 1px 1px #808080, inset -1px -1px #fff;
+}
+.os[data-style='classic'] .snap-slot::before {
+ border-radius: 0;
+ border: 2px dotted #fff;
+ backdrop-filter: none;
+}
+.os[data-style='classic'] .snap-slot.is-active::before {
+ border: 0;
+ background: var(--c-face);
+ box-shadow: var(--c-bevel-out);
+}
+.os[data-style='classic'] .snap-cand:hover,
+.os[data-style='classic'] .snap-cand:focus-visible {
+ transform: none;
+ background: #000080;
+ color: #fff;
+}
+.os[data-style='classic'] .pk-head b {
+ font-weight: 700;
+}
+.os[data-style='classic'] .os .pk-x,
+.os[data-style='classic'] .pk-x {
+ width: 16px;
+ height: 14px;
+ border-radius: 0;
+ opacity: 1;
+ background: var(--c-face);
+ box-shadow: var(--c-bevel-out);
+}
+.os[data-style='classic'] .pk-x .ico {
+ width: 9px;
+ height: 9px;
+}
+.os[data-style='classic'] .os .pk-x:hover,
+.os[data-style='classic'] .pk-x:hover {
+ background: var(--c-face);
+ color: #000;
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .snap-fly,
+ .snap-assist,
+ .snap-cand,
+ .os-peek {
+ animation-duration: 0.01ms !important;
+ }
+ .os[data-style='aqua'] .os-task-mid .os-tb {
+ --mag: 1 !important;
+ }
+}
diff --git a/src/desktop/wm.js b/src/desktop/wm.js
index e1176f496..5adbb64f7 100644
--- a/src/desktop/wm.js
+++ b/src/desktop/wm.js
@@ -8,7 +8,9 @@ import {
cascadeRect,
cleanTitle,
isInternalPath,
+ layoutZoneRect,
resizeRect,
+ snapLayoutsFor,
snapRect,
snapZone,
workArea,
@@ -17,7 +19,12 @@ import { icon } from './icons.js';
const HANDLES = ['n', 's', 'e', 'w', 'ne', 'nw', 'se', 'sw'];
-export function createWM({ layer, getMetrics, renderNative, onChange, notify }) {
+// Motion: Fluent's standard curves. Accelerate out of view, decelerate in.
+const EASE_OUT = 'cubic-bezier(0.1, 0.9, 0.2, 1)';
+const EASE_IN = 'cubic-bezier(0.7, 0, 1, 0.5)';
+const reducedMotion = () => matchMedia('(prefers-reduced-motion: reduce)').matches;
+
+export function createWM({ layer, getMetrics, renderNative, onChange, notify, getTaskRect }) {
const wins = new Map(); // app id -> window record
let zTop = 10;
let opened = 0;
@@ -28,6 +35,57 @@ export function createWM({ layer, getMetrics, renderNative, onChange, notify })
snapGhost.hidden = true;
layer.append(snapGhost);
+ /**
+ * FLIP a window from where it was drawn (`before`, a DOMRect) to where it
+ * is now, so maximize, restore and every snap glide instead of jumping.
+ */
+ function morph(w, before) {
+ if (!before || reducedMotion() || !w.el.animate) return;
+ const after = w.el.getBoundingClientRect();
+ if (!after.width || !after.height) return;
+ const dx = before.left - after.left;
+ const dy = before.top - after.top;
+ const sx = before.width / after.width;
+ const sy = before.height / after.height;
+ if (Math.abs(dx) + Math.abs(dy) < 1 && Math.abs(sx - 1) + Math.abs(sy - 1) < 0.01) return;
+ w.el.animate(
+ [
+ { transformOrigin: '0 0', transform: `translate(${dx}px, ${dy}px) scale(${sx}, ${sy})` },
+ { transformOrigin: '0 0', transform: 'none' },
+ ],
+ { duration: 240, easing: EASE_OUT },
+ );
+ }
+
+ /**
+ * Fly a window into (or out of) its taskbar button: the Windows 11 minimize
+ * motion. Resolves when the motion ends or is skipped.
+ */
+ function flyTask(w, out) {
+ w.anim?.cancel();
+ const t = getTaskRect?.(w.app.id);
+ if (!t || reducedMotion() || !w.el.animate) return Promise.resolve(true);
+ const r = w.el.getBoundingClientRect();
+ if (!r.width) return Promise.resolve(true);
+ const dx = t.left + t.width / 2 - (r.left + r.width / 2);
+ const dy = t.top + t.height / 2 - (r.top + r.height / 2);
+ const s = Math.max(0.06, Math.min(0.3, (t.width * 3) / r.width));
+ const hidden = { transform: `translate(${dx}px, ${dy}px) scale(${s})`, opacity: 0 };
+ const shown = { transform: 'none', opacity: 1 };
+ const a = w.el.animate(out ? [shown, hidden] : [hidden, shown], {
+ duration: out ? 220 : 280,
+ easing: out ? EASE_IN : EASE_OUT,
+ });
+ w.anim = a;
+ return a.finished.then(
+ () => {
+ if (w.anim === a) w.anim = null;
+ return true;
+ },
+ () => false,
+ );
+ }
+
const isMobile = () => getMetrics().mobile;
const area = () => {
const m = getMetrics();
@@ -93,11 +151,15 @@ export function createWM({ layer, getMetrics, renderNative, onChange, notify })
const w = wins.get(id);
if (!w || w.min) return;
w.min = true;
- w.el.classList.add('is-min');
w.el.setAttribute('aria-hidden', 'true');
w.el.inert = true;
if (focusedId === id) pickNextFocus();
emit();
+ // The window stays drawn while it flies into its taskbar button; a
+ // restore during the flight cancels it (and `finished` resolves false).
+ flyTask(w, true).then((done) => {
+ if (done && w.min) w.el.classList.add('is-min');
+ });
}
function restore(id) {
@@ -107,26 +169,60 @@ export function createWM({ layer, getMetrics, renderNative, onChange, notify })
w.el.classList.remove('is-min');
w.el.removeAttribute('aria-hidden');
w.el.inert = false;
+ flyTask(w, false);
+ }
+
+ function syncMaxBtn(w) {
+ w.maxBtn.setAttribute('aria-label', w.max ? 'Restore window' : 'Maximize window');
+ w.maxBtn.title = w.max ? 'Restore' : 'Maximize';
+ w.maxBtn.innerHTML = icon(w.max ? 'restore' : 'maximize', 13);
}
function toggleMax(id) {
const w = wins.get(id);
if (!w) return;
+ const before = w.el.getBoundingClientRect();
w.max = !w.max;
applyRect(w);
- w.maxBtn.setAttribute('aria-label', w.max ? 'Restore window' : 'Maximize window');
- w.maxBtn.title = w.max ? 'Restore' : 'Maximize';
- w.maxBtn.innerHTML = icon(w.max ? 'restore' : 'maximize', 13);
+ syncMaxBtn(w);
+ morph(w, before);
emit();
}
+ /** Place a window at a rect (or maximize it), restoring it first if needed. */
+ function place(id, rect, max = false) {
+ const w = wins.get(id);
+ if (!w) return;
+ if (w.min) restore(id);
+ const before = w.el.getBoundingClientRect();
+ w.max = max;
+ if (rect) w.rect = clampRect(rect, area());
+ applyRect(w);
+ syncMaxBtn(w);
+ morph(w, before);
+ focus(id);
+ }
+
+ /** Snap the focused window from the keyboard: left, right, up (maximize), down (restore, then minimize). */
+ function snapKey(id, dir) {
+ const w = wins.get(id);
+ if (!w || isMobile()) return;
+ const a = area();
+ if (dir === 'up') return place(id, null, true);
+ if (dir === 'down') {
+ if (w.max) return place(id, w.rect, false);
+ return minimize(id);
+ }
+ place(id, snapRect(dir, a));
+ }
+
function close(id) {
const w = wins.get(id);
if (!w) return;
w.el.classList.add('is-closing');
wins.delete(id);
const done = () => w.el.remove();
- if (matchMedia('(prefers-reduced-motion: reduce)').matches) done();
+ if (reducedMotion()) done();
else {
w.el.addEventListener('animationend', done, { once: true });
setTimeout(done, 260);
@@ -281,7 +377,21 @@ export function createWM({ layer, getMetrics, renderNative, onChange, notify })
const id = w.app.id;
bar.querySelector('.win-close').addEventListener('click', () => close(id));
bar.querySelector('.win-min').addEventListener('click', () => minimize(id));
- w.maxBtn.addEventListener('click', () => toggleMax(id));
+ w.maxBtn.addEventListener('click', () => {
+ hideFlyout(true);
+ toggleMax(id);
+ });
+ // Hovering maximize offers the snap layouts, as on Windows 11.
+ w.maxBtn.addEventListener('pointerenter', (e) => {
+ if (e.pointerType === 'touch' || isMobile()) return;
+ clearTimeout(fly.hideT);
+ clearTimeout(fly.showT);
+ fly.showT = setTimeout(() => showFlyout(id), 420);
+ });
+ w.maxBtn.addEventListener('pointerleave', () => {
+ clearTimeout(fly.showT);
+ hideFlyout();
+ });
bar.addEventListener('dblclick', (e) => {
if (!e.target.closest('.win-ctl, .win-tools')) toggleMax(id);
});
@@ -337,12 +447,15 @@ export function createWM({ layer, getMetrics, renderNative, onChange, notify })
layer.classList.remove('is-dragging');
w.el.classList.remove('is-moving');
snapGhost.hidden = true;
+ const before = zone ? w.el.getBoundingClientRect() : null;
if (zone === 'max') {
w.max = true;
} else if (zone) {
w.rect = snapRect(zone, a);
}
applyRect(w);
+ syncMaxBtn(w);
+ morph(w, before);
emit();
};
w.bar.addEventListener('pointermove', move);
@@ -375,6 +488,170 @@ export function createWM({ layer, getMetrics, renderNative, onChange, notify })
grip.addEventListener('pointercancel', up);
}
+ // ---------- Snap layouts flyout and Snap assist ----------
+ const fly = { el: null, id: null, showT: 0, hideT: 0 };
+
+ function hideFlyout(now = false) {
+ clearTimeout(fly.hideT);
+ const go = () => {
+ fly.el?.remove();
+ fly.el = null;
+ fly.id = null;
+ };
+ if (now) go();
+ else fly.hideT = setTimeout(go, 260);
+ }
+
+ /** The layouts flyout under a window's maximize button (also Alt+Z for the focused window). */
+ function showFlyout(id, viaKeyboard = false) {
+ const w = wins.get(id);
+ if (!w || isMobile()) return;
+ hideFlyout(true);
+ hideAssist();
+ const a = area();
+ const el = document.createElement('div');
+ el.className = 'snap-fly';
+ el.setAttribute('role', 'menu');
+ el.setAttribute('aria-label', 'Snap layouts');
+ snapLayoutsFor(a).forEach((l) => {
+ const box = document.createElement('div');
+ box.className = 'snap-lay';
+ box.setAttribute('role', 'group');
+ box.setAttribute('aria-label', l.label);
+ l.zones.forEach(([fx, fy, fw, fh], i) => {
+ const z = document.createElement('button');
+ z.type = 'button';
+ z.className = 'snap-zone';
+ z.setAttribute('role', 'menuitem');
+ z.setAttribute('aria-label', `${l.label}, zone ${i + 1} of ${l.zones.length}`);
+ z.style.cssText = `left:${fx * 100}%;top:${fy * 100}%;width:${fw * 100}%;height:${fh * 100}%`;
+ z.addEventListener('click', () => {
+ hideFlyout(true);
+ place(id, layoutZoneRect(l.id, i, a));
+ showAssist(l.id, i, id);
+ });
+ box.append(z);
+ });
+ el.append(box);
+ });
+ el.addEventListener('pointerenter', () => clearTimeout(fly.hideT));
+ el.addEventListener('pointerleave', () => hideFlyout());
+ el.addEventListener('keydown', (e) => {
+ if (e.key === 'Escape') {
+ e.stopPropagation();
+ hideFlyout(true);
+ w.maxBtn.focus();
+ return;
+ }
+ const all = [...el.querySelectorAll('.snap-zone')];
+ const k = all.indexOf(document.activeElement);
+ const step = { ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1 }[e.key];
+ if (step && k >= 0) {
+ e.preventDefault();
+ all[(k + step + all.length) % all.length].focus();
+ }
+ });
+ layer.append(el);
+ const b = w.maxBtn.getBoundingClientRect();
+ const host = layer.getBoundingClientRect();
+ const r = el.getBoundingClientRect();
+ const left = Math.max(8, Math.min(b.left + b.width / 2 - r.width / 2 - host.left, host.width - r.width - 8));
+ const below = b.bottom - host.top + 6;
+ const top = below + r.height > host.height - 8 ? Math.max(8, b.top - host.top - r.height - 6) : below;
+ el.style.left = `${left}px`;
+ el.style.top = `${top}px`;
+ fly.el = el;
+ fly.id = id;
+ if (viaKeyboard) el.querySelector('.snap-zone')?.focus();
+ }
+
+ const assist = { el: null };
+
+ function hideAssist() {
+ assist.el?.remove();
+ assist.el = null;
+ }
+
+ /**
+ * After a window lands in a layout zone, offer the other open windows for
+ * the zones that are still empty, one zone at a time, until the layout is
+ * full or the visitor dismisses it (Esc or a click on the backdrop).
+ */
+ function showAssist(layoutId, usedZone, placedId) {
+ hideAssist();
+ const a = area();
+ const layout = snapLayoutsFor(a).find((l) => l.id === layoutId);
+ if (!layout) return;
+ let free = layout.zones.map((_, i) => i).filter((i) => i !== usedZone);
+ const placed = new Set([placedId]);
+ const candidates = () =>
+ [...wins.values()].filter((o) => !placed.has(o.app.id)).sort((x, y) => y.lastFocus - x.lastFocus);
+ if (!free.length || !candidates().length) return;
+
+ const el = document.createElement('div');
+ el.className = 'snap-assist';
+ el.setAttribute('role', 'dialog');
+ el.setAttribute('aria-label', 'Snap assist: choose a window for the empty space');
+ el.addEventListener('pointerdown', (e) => {
+ if (e.target === el) hideAssist();
+ });
+ el.addEventListener('keydown', (e) => {
+ if (e.key === 'Escape') {
+ e.stopPropagation();
+ hideAssist();
+ }
+ });
+ el.style.zIndex = String(++zTop + 1);
+ let active = free[0];
+
+ function paint() {
+ el.replaceChildren();
+ const left = candidates();
+ if (!free.length || !left.length) return hideAssist();
+ if (!free.includes(active)) active = free[0];
+ free.forEach((zi) => {
+ const r = layoutZoneRect(layoutId, zi, a);
+ const zone = document.createElement('div');
+ zone.className = `snap-slot${zi === active ? ' is-active' : ''}`;
+ Object.assign(zone.style, { left: `${r.x}px`, top: `${r.y - a.y}px`, width: `${r.w}px`, height: `${r.h}px` });
+ if (zi !== active) {
+ zone.addEventListener('pointerdown', (e) => {
+ e.stopPropagation();
+ active = zi;
+ paint();
+ });
+ el.append(zone);
+ return;
+ }
+ const list = document.createElement('div');
+ list.className = 'snap-cands';
+ left.forEach((o) => {
+ const c = document.createElement('button');
+ c.type = 'button';
+ c.className = 'snap-cand';
+ c.innerHTML = `<span class="app-tile sm" style="--hue:${o.app.hue}">${icon(o.app.icon, 17)}</span><span class="snap-cand-t"></span>`;
+ c.querySelector('.snap-cand-t').textContent = o.title;
+ c.title = `Snap ${o.title} here`;
+ c.addEventListener('click', () => {
+ placed.add(o.app.id);
+ place(o.app.id, r);
+ free = free.filter((x) => x !== zi);
+ el.style.zIndex = String(++zTop + 1);
+ paint();
+ });
+ list.append(c);
+ });
+ zone.append(list);
+ el.append(zone);
+ });
+ el.querySelector('.snap-cand')?.focus({ preventScroll: true });
+ }
+ el.style.top = `${a.y}px`;
+ layer.append(el);
+ assist.el = el;
+ paint();
+ }
+
function open(app, opts = {}) {
const existing = wins.get(app.id);
if (existing) {
@@ -398,7 +675,15 @@ export function createWM({ layer, getMetrics, renderNative, onChange, notify })
w.el.classList.add('is-min');
w.el.inert = true;
}
- if (!opts.quiet) w.el.classList.add('is-opening');
+ if (!opts.quiet) {
+ // Drop the class once the opening plays, or it replays on every restore from minimize.
+ w.el.classList.add('is-opening');
+ w.el.addEventListener('animationend', function done(e) {
+ if (e.target !== w.el) return;
+ w.el.classList.remove('is-opening');
+ w.el.removeEventListener('animationend', done);
+ });
+ }
w.suppressFrameFocus = !!opts.quiet;
if (!opts.min && !opts.quiet) focus(app.id);
else emit();
@@ -406,6 +691,8 @@ export function createWM({ layer, getMetrics, renderNative, onChange, notify })
}
function relayout() {
+ hideFlyout(true);
+ hideAssist();
const a = area();
wins.forEach((w) => {
if (!w.max) w.rect = clampRect(w.rect, a);
@@ -458,6 +745,9 @@ export function createWM({ layer, getMetrics, renderNative, onChange, notify })
focus,
toggleMax,
cycle,
+ place,
+ snapKey,
+ snapLayouts: (id) => showFlyout(id, true),
relayout,
snapshot,
reload: (id) => wins.has(id) && reloadFrame(wins.get(id)),
diff --git a/tests/desktop-layout.test.js b/tests/desktop-layout.test.js
index 7d67ce98b..40d1b8f8a 100644
--- a/tests/desktop-layout.test.js
+++ b/tests/desktop-layout.test.js
@@ -4,6 +4,11 @@ import {
clampRect,
snapZone,
snapRect,
+ fractionRect,
+ layoutZoneRect,
+ snapLayoutsFor,
+ dockScale,
+ SNAP_LAYOUTS,
cascadeRect,
resizeRect,
isInternalPath,
@@ -57,6 +62,55 @@ describe('desktop layout geometry', () => {
expect(snapRect(null, area)).toBeNull();
});
+ it('snaps to quarters at the corners, from either edge', () => {
+ expect(snapZone(2, 40, area)).toBe('tl');
+ expect(snapZone(40, 31, area)).toBe('tl');
+ expect(snapZone(1438, 40, area)).toBe('tr');
+ expect(snapZone(1400, 31, area)).toBe('tr');
+ expect(snapZone(2, 800, area)).toBe('bl');
+ expect(snapZone(1438, 800, area)).toBe('br');
+ const q = ['tl', 'tr', 'bl', 'br'].map((z) => snapRect(z, area));
+ expect(q.reduce((n, r) => n + r.w * r.h, 0)).toBe(area.w * area.h);
+ expect(q[1].x).toBe(q[0].x + q[0].w);
+ expect(q[2].y).toBe(q[0].y + q[0].h);
+ });
+
+ it('resolves every snap layout zone so the zones tile the work area exactly', () => {
+ const odd = workArea(1367, 901, 30, 84);
+ for (const l of SNAP_LAYOUTS) {
+ const rects = l.zones.map((_, i) => layoutZoneRect(l.id, i, odd));
+ const sum = rects.reduce((n, r) => n + r.w * r.h, 0);
+ expect(sum, l.id).toBe(odd.w * odd.h);
+ rects.forEach((r) => {
+ expect(r.x).toBeGreaterThanOrEqual(odd.x);
+ expect(r.y).toBeGreaterThanOrEqual(odd.y);
+ expect(r.x + r.w).toBeLessThanOrEqual(odd.x + odd.w);
+ expect(r.y + r.h).toBeLessThanOrEqual(odd.y + odd.h);
+ });
+ }
+ expect(layoutZoneRect('halves', 5, odd)).toBeNull();
+ expect(layoutZoneRect('nope', 0, odd)).toBeNull();
+ expect(fractionRect([0, 0, 1, 1], odd)).toEqual(odd);
+ });
+
+ it('only offers snap layouts whose narrowest zone still fits a window', () => {
+ expect(snapLayoutsFor(area).map((l) => l.id)).toContain('thirds');
+ const narrow = snapLayoutsFor(workArea(900, 700, 0, 48)).map((l) => l.id);
+ expect(narrow).toContain('halves');
+ expect(narrow).not.toContain('thirds');
+ expect(narrow).not.toContain('focus');
+ });
+
+ it('magnifies dock items with a smooth falloff', () => {
+ expect(dockScale(0)).toBeCloseTo(1.6);
+ expect(dockScale(150)).toBe(1);
+ expect(dockScale(400)).toBe(1);
+ expect(dockScale(NaN)).toBe(1);
+ expect(dockScale(-40)).toBe(dockScale(40));
+ expect(dockScale(30)).toBeGreaterThan(dockScale(60));
+ expect(dockScale(0, 2)).toBeCloseTo(2);
+ });
+
it('cascades new windows to different positions that stay on screen', () => {
const seen = new Set();
for (let n = 0; n < MAX_WINDOWS; n++) {
@@ -330,6 +384,12 @@ describe('preferences and session export', () => {
expect(p.name).not.toMatch(/[<>]/);
expect(p.avatarHue).toBe(330);
});
+ it('accepts only known desktop styles', () => {
+ expect(sanitizePrefs({ style: 'aqua' }, walls).style).toBe('aqua');
+ expect(sanitizePrefs({ style: 'classic' }, walls).style).toBe('classic');
+ expect(sanitizePrefs({ style: 'toString' }, walls).style).toBe('fluent');
+ expect(sanitizePrefs({ style: 'vista' }, walls).style).toBe('fluent');
+ });
it('survives bad JSON', () => {
expect(sanitizePrefs('{oops', walls)).toEqual(DEFAULT_PREFS);
expect(sanitizePrefs(null, walls)).toEqual(DEFAULT_PREFS);