LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.
C cdebiandesktop-environmentebpffirewalllandlocklinuxlinux-distributionopen-sourceprivacyquickjsraspberry-pi-5reactsecuritywaylandwayland-compositor
Window snapping, lord.wm.pointer, banners above a taskbar, reusable search, windows back after a theme switch; scaled rasters with a blur inside
Federico Pereira18043a25fb67
diff --git a/sdk/index.js b/sdk/index.jsindex 7586e8c..b7e58dc 100644--- a/sdk/index.js+++ b/sdk/index.js@@ -56,7 +56,7 @@ export { packages, packageList, refreshPackages, packageFile, loadWasm } from '.import { refreshPackages } from './packages.js';export {windows, wm, openedAt, useWindows, configureWindows, getApp, listApps, isLiveSystem, appIdOf, workArea, workAreaOf, pointerWorkArea, appMenus, useAppMenus, windowTitle, appRegistry, appMenuClick,- registerBuiltinApp, isSystemApp,+ registerBuiltinApp, isSystemApp, snapPreview, snapRect, snapZoneAt, snapEnabled, SNAP_ZONES,} from './windows.js';export { codeStatus } from './codesig.js';import { reportRefusedCode } from './codesig.js';@@ -64,9 +64,9 @@ export { WindowShell, WINDOW_EDGE } from './windowshell.jsx';export { term } from './terminal.js';export { clipboard, clipboardHistory, clipboardPanel, clipboardKind } from './clipboard.js';export { spotlight, spotlightOpen, calc as spotlightCalc, convert as spotlightConvert } from './spotlight.js';-export { registerSpotlightSource } from './spotlight.js';+export { registerSpotlightSource, searchEverything } from './spotlight.js';// session notifications, menu bar status items, Clock (alarms) and Help (docs/SYSTEM.md)-export { notify, dismissNotification, useNotifications, notifications, notifyHistory, clearNotifyHistory, NotificationBanner } from './notify.js';+export { notify, dismissNotification, useNotifications, notifications, notifyHistory, clearNotifyHistory, NotificationBanner, setBannerPlacement } from './notify.js';export { registerStatusItem, StatusItems, statusItems } from './statusitems.js';export { clockAlarms, clockTimer, timerStart, timerPause, timerResume, timerReset, timerLeft, stopwatch, swStart, swStop, swLap, swReset, swElapsed, nextAlarm, nextFire } from './alarms.js';export { help } from './help.js';@@ -74,7 +74,7 @@ import { NotificationBanner } from './notify.js';import { startAlarms } from './alarms.js';import { startDiskWatch } from './diskwatch.js';import { maybeStartTour } from './help.js';-import { getApp as getAppOf, isLiveSystem as isLiveSystemOf, wm as wmOf } from './windows.js';+import { getApp as getAppOf, isLiveSystem as isLiveSystemOf, wm as wmOf, windows as windowsStore } from './windows.js';export const windowIcon = (w) => windowIconOf(w, getAppOf);export { systemInfo, lordosVersion, useSystemInfo, useServerStats, useCpuUsage, formatBytes, formatDuration } from './system.js';export * as fs from './fs.js';@@ -133,9 +133,17 @@ export const themes = {description: tOptional(`shell.theme.${t.id}.description`) || meta.description || '' };}).filter((t) => !t.hidden), // the login screen (themes/greeter) can't be chosencurrent: () => lord.themes.list().find((t) => t.current)?.id || null,- // Switches theme live: the server discards this JS context and loads the new one.+ // Switches theme live: the server discards this JS context and loads the new one. The LordOS+ // app windows that are open come back in the new theme (themeReopen, read once by startShell);+ // Linux app windows stay connected and simply get the new theme's frame.use(id) {- settings.set({ theme: id });+ let reopen = [];+ try {+ reopen = windowsStore.get().filter((w) => { const a = getAppOf(w.id); return a && !a.builtin; }).slice(-8)+ .map((w) => ({ app: w.app, id: w.id, args: w.args ? JSON.parse(JSON.stringify(w.args)) : null, minimized: !!w.minimized,+ frame: { x: w.x, y: w.y, w: w.w, h: w.h }, maximized: !!w.maximized }));+ } catch (e) { reopen = []; }+ settings.set({ theme: id, themeReopen: reopen.length ? reopen : null });lord.settings.save(JSON.stringify(settings.get(), null, 2));return lord.themes.use(id);},@@ -174,6 +182,7 @@ export function startShell(element) {if (wanted && current && wanted !== current && lord.themes.use(wanted)) return;refreshPackages(); // after the theme's configureWindowsenableShellLayers(); // menus, popovers and prompts go to their layer (sdk/layers.js)+ reopenAfterThemeSwitch();render(createElement(LocaleRoot, null, element));// live ISO: the installation assistant opens by itself, in frontif (isLiveSystemOf() && getAppOf('installer')) setTimeout(() => wmOf.open('installer'), 300);@@ -187,6 +196,26 @@ export function startShell(element) {setTimeout(reportRefusedCode, 800); // "This LordOS component was modified and was not loaded" (docs/SIGNING.md)}+// After Settings → Appearance switched theme: the windows that were open replace the ones the new+// theme opens by itself at start.+function reopenAfterThemeSwitch() {+ const list = settings.get().themeReopen;+ if (!Array.isArray(list) || !list.length) return;+ settings.set({ themeReopen: null });+ for (const w of windowsStore.get()) if (!getAppOf(w.id)?.builtin) wmOf.close(w.id, true);+ for (const r of list) {+ if (!r || typeof r.app !== 'string' || !getAppOf(r.app)) continue;+ const inst = typeof r.id === 'string' && r.id.includes('#') ? r.id.split('#')[1] : null;+ const id = wmOf.open(r.app, { ...(inst ? { instance: inst } : null), ...(r.args ? { args: r.args } : null), frame: r.frame });+ if (id && r.maximized) wmOf.toggleMaximize(id);+ if (id && r.minimized) wmOf.minimize(id);+ }+ // apps that bring their own windows back as they start (the Terminal's sessions) must not end up+ // in front of the one the user was using+ const top = [...list].reverse().find((r) => r && !r.minimized && getAppOf(r.app));+ if (top) setTimeout(() => { if (windowsStore.get().some((w) => w.id === top.id)) wmOf.focus(top.id); }, 900);+}+// Changing the language remounts the whole interface (windows, tabs and// sessions live in stores and are not lost).function LocaleRoot({ children }) {diff --git a/sdk/notify.js b/sdk/notify.jsindex be07e94..8c892e8 100644--- a/sdk/notify.js+++ b/sdk/notify.js@@ -104,6 +104,11 @@ export function dismissNotification(id, reason = 'closed') {}export const useNotifications = () => useStore(notifications);++// Where the banners go: 'top' (default: below a menu bar) or 'bottom' (above a taskbar, the Classic+// theme). Always on the end side of the line.+let placement = 'top';+export function setBannerPlacement(p) { placement = p === 'bottom' ? 'bottom' : 'top'; }export const clearNotifyHistory = () => notifyHistory.set([]);function runAction(n, a) {@@ -153,8 +158,13 @@ export function NotificationBanner() {const area = workArea() || { x: 0, y: 0, w: screen.width, h: screen.height };const rtl = direction() === 'rtl';const left = rtl ? (area.x || 0) + 12 : (area.x || 0) + (area.w || screen.width) - 352;- return h(View, { style: { position: 'absolute', left, top: (area.y || 0) + 10, width: 340, gap: 10 } },- ...grouped(list).map((n) => h(Banner, { key: n.id, n, th })));+ const at = placement === 'bottom'+ ? { bottom: Math.max(0, screen.height - ((area.y || 0) + (area.h || screen.height))) + 12 }+ : { top: (area.y || 0) + 10 };+ const shown = grouped(list);+ if (placement === 'bottom') shown.reverse(); // the newest one next to the taskbar+ return h(View, { style: { position: 'absolute', left, width: 340, gap: 10, ...at } },+ ...shown.map((n) => h(Banner, { key: n.id, n, th })));}// Grouping by app (Settings → Notifications): the newest banner of each app, with "+N".diff --git a/sdk/snap.js b/sdk/snap.jsnew file mode 100644index 0000000..9d40805--- /dev/null+++ b/sdk/snap.js@@ -0,0 +1,55 @@+// snap.js — the geometry of window snapping (sdk/windows.js "Snapping", docs/WINDOWS.md), with no+// runtime imports so it can be tested with node (server/tests/snap_test.mjs).++export const SNAP_ZONES = ['left', 'right', 'top-left', 'top-right', 'bottom-left', 'bottom-right', 'max',+ 'left-third', 'center-third', 'right-third', 'left-two-thirds', 'right-two-thirds'];++// The rectangle of a zone inside a work area `a` ({ x, y, w, h }). Halves and quarters round to+// whole pixels and share the middle line, so two snapped windows never overlap or leave a gap.+export function snapRect(zone, a) {+ const hw = Math.round(a.w / 2), hh = Math.round(a.h / 2), t1 = Math.round(a.w / 3), t2 = Math.round((2 * a.w) / 3);+ switch (zone) {+ case 'left': return { x: a.x, y: a.y, w: hw, h: a.h };+ case 'right': return { x: a.x + hw, y: a.y, w: a.w - hw, h: a.h };+ case 'top-left': return { x: a.x, y: a.y, w: hw, h: hh };+ case 'top-right': return { x: a.x + hw, y: a.y, w: a.w - hw, h: hh };+ case 'bottom-left': return { x: a.x, y: a.y + hh, w: hw, h: a.h - hh };+ case 'bottom-right': return { x: a.x + hw, y: a.y + hh, w: a.w - hw, h: a.h - hh };+ case 'left-third': return { x: a.x, y: a.y, w: t1, h: a.h };+ case 'center-third': return { x: a.x + t1, y: a.y, w: t2 - t1, h: a.h };+ case 'right-third': return { x: a.x + t2, y: a.y, w: a.w - t2, h: a.h };+ case 'left-two-thirds': return { x: a.x, y: a.y, w: t2, h: a.h };+ case 'right-two-thirds': return { x: a.x + t1, y: a.y, w: a.w - t1, h: a.h };+ default: return { x: a.x, y: a.y, w: a.w, h: a.h };+ }+}++// The zone for a window dropped with the pointer at (x, y) in work area `a`, or null: within EDGE px+// of the left or right side (or past it, over a taskbar on that side) is a half, and in the top or+// bottom fifth of that side a quarter; the top edge is the whole area ('max').+export const SNAP_EDGE = 8;+export function zoneAt(x, y, a) {+ const band = Math.max(48, a.h / 5);+ const side = x <= a.x + SNAP_EDGE ? 'left' : x >= a.x + a.w - 1 - SNAP_EDGE ? 'right' : null;+ if (side) return y < a.y + band ? `top-${side}` : y > a.y + a.h - band ? `bottom-${side}` : side;+ if (y <= a.y + SNAP_EDGE) return 'max';+ return null;+}++// Super+arrows: where each arrow takes a window from where it is (`at`: a zone, 'max' or null).+// Returns a zone, 'restore', 'minimize', or null (nothing to do).+const KEYS = {+ none: { left: 'left', right: 'right', up: 'max', down: 'minimize' },+ max: { left: 'left', right: 'right', down: 'restore' },+ left: { right: 'restore', up: 'top-left', down: 'bottom-left' },+ right: { left: 'restore', up: 'top-right', down: 'bottom-right' },+ 'top-left': { right: 'top-right', up: 'max', down: 'left' },+ 'top-right': { left: 'top-left', up: 'max', down: 'right' },+ 'bottom-left': { right: 'bottom-right', up: 'left', down: 'minimize' },+ 'bottom-right': { left: 'bottom-left', up: 'right', down: 'minimize' },+ third: { left: 'left', right: 'right', up: 'max', down: 'restore' },+};+export function snapNext(at, dir) {+ const from = !at ? 'none' : /third/.test(at) ? 'third' : at;+ return (KEYS[from] && KEYS[from][dir]) || null;+}diff --git a/sdk/spotlight.js b/sdk/spotlight.jsindex b45f6bb..7875b18 100644--- a/sdk/spotlight.js+++ b/sdk/spotlight.js@@ -339,6 +339,19 @@ function buildResults(raw, apps) {return sections.sort((a, b) => b.top - a.top);}+// The same search for another surface (the Classic start menu): sections of results, the file index+// built on first use, and run() that counts the choice like the search panel does.+export const searchEverything = {+ results: (query, apps) => buildResults(query, apps),+ prepare: () => buildFileIndex(),+ version: () => resultsVersion,+ run(item, reveal = false) {+ if (!item) return;+ noteUse(item.key);+ setTimeout(() => (reveal && item.reveal ? item.reveal() : item.run()), 0);+ },+};+// ---- preview ----const previewCache = new Map();diff --git a/sdk/windows.js b/sdk/windows.jsindex 8015d9c..9c52e77 100644--- a/sdk/windows.js+++ b/sdk/windows.js@@ -8,6 +8,9 @@import { screen, onScreenChange, addListener, mainDisplay, displayAt, displayFor } from '@lordos/runtime';import { createStore, useStore } from './store.js';import { appName } from './i18n.js';+import { SNAP_ZONES, snapRect, zoneAt, snapNext } from './snap.js';++export { SNAP_ZONES, snapRect };let registry = new Map();let builtins = [];@@ -68,12 +71,15 @@ export const appMenus = createStore({});// chrome: what the theme's frame adds around the content (borders and title bar);// used to open Linux app windows at the size they requested.-export function configureWindows({ apps, workArea, chrome: c }) {+// snap: true turns on window snapping (dragging a window to an edge of the screen, see "Snapping"+// below); the Classic theme does.+export function configureWindows({ apps, workArea, chrome: c, snap }) {themeApps = apps;rebuild();if (typeof workArea === 'function') areaFn = workArea;else if (workArea) { area = workArea; areaFn = null; }if (c) chrome = c;+ if (snap != null) snapOn = !!snap;}// SDK internal apps (they don't appear in the app launcher): 'linux' = Wayland windows.@@ -145,6 +151,57 @@ function frameRef(id, inset = 0) {}return fn;}+// ---- Snapping (docs/WINDOWS.md, "Snapping") ----+// A window dragged to the left or right edge of a display takes that half of its work area; near the+// top or bottom of that edge, a quarter; to the top edge, the whole area (maximized). The theme turns+// it on (configureWindows({ snap: true })), draws the preview from `snapPreview` and may offer the+// layouts with wm.snap(id, zone). While a window is moved in C, the SDK only reads the pointer a few+// times per second (lord.wm.pointer), never per frame.+let snapOn = false;+// { id, zone, rect: { x, y, w, h } } while a dragged window would snap, else null+export const snapPreview = createStore(null);+export const snapEnabled = () => snapOn;+// The zone under the pointer at (x, y), or null (the rules are in snap.js, zoneAt).+export function snapZoneAt(x, y) {+ const d = displayAt(x, y);+ return d ? zoneAt(x, y, workAreaOf(d)) : null;+}+// Snaps window `id` to `zone` in the work area of its display (or of `display`).+function snapTo(id, zone, display) {+ windows.set((ws) => ws.map((w) => {+ if (w.id !== id) return w;+ const restore = w.snapped ? w.restore : { x: w.x, y: w.y, w: w.w, h: w.h };+ if (zone === 'max') return { ...w, maximized: true, minimized: false, snapped: null, restore: null, ...(w.snapped ? restore : null) };+ const a = workAreaOf(display || displayFor(w));+ const [minW, minH] = registry.get(w.app)?.minSize || [160, 100];+ const r = snapRect(zone, a);+ return { ...w, ...r, w: Math.max(r.w, Math.min(minW, a.w)), h: Math.max(r.h, Math.min(minH, a.h)), maximized: false, minimized: false, snapped: zone, restore };+ }));+}+function unsnap(id) {+ windows.set((ws) => ws.map((w) => {+ if (w.id !== id) return w;+ if (w.maximized) return { ...w, maximized: false };+ if (!w.snapped) return w;+ return { ...w, ...(w.restore || {}), snapped: null, restore: null };+ }));+}+let previewTimer = 0;+function watchSnap(id) {+ clearInterval(previewTimer);+ previewTimer = 0;+ if (!snapOn || typeof lord === 'undefined' || !lord.wm || typeof lord.wm.pointer !== 'function') return;+ previewTimer = setInterval(() => {+ const p = lord.wm.pointer();+ const zone = p.active && p.edges === 0 ? snapZoneAt(p.x, p.y) : null;+ if (!p.active) { clearInterval(previewTimer); previewTimer = 0; }+ const cur = snapPreview.get();+ if ((cur ? cur.zone : null) === zone) return;+ if (!zone) { snapPreview.set(null); return; }+ snapPreview.set({ id, zone, rect: snapRect(zone, workAreaOf(displayAt(p.x, p.y))) });+ }, 90);+}+function beginGrab(id, edges) {const w = windows.get().find((x) => x.id === id);const f = frameNodes.get(id);@@ -152,15 +209,38 @@ function beginGrab(id, edges) {const [minW, minH] = registry.get(w.app)?.minSize || [160, 100];const areas = screen.displays.map((d) => workAreaOf(d)).map((a, i) => ({ x: screen.displays[i].x, w: screen.displays[i].w, y: a.y }));if (!lord.wm.grab(f.node, edges, { inset: f.inset, minW, minH, minTop: areaOfWindow(w).y, areas })) return false;- grab = { id, node: f.node, f: { x: w.x, y: w.y, w: w.w, h: w.h } };+ grab = { id, node: f.node, edges, f: { x: w.x, y: w.y, w: w.w, h: w.h } };+ if (!edges) watchSnap(id);return true;}globalThis.__lordWm = (type, d) => {if (type !== 'end' || !grab || grab.node !== d.node) return;- const { id, f } = grab;+ const { id, f, edges } = grab;grab = null;+ clearInterval(previewTimer);+ previewTimer = 0;+ if (snapPreview.get()) snapPreview.set(null);if (!d.dx && !d.dy && !d.dw && !d.dh) return; // it was a click on the bar- patch(id, { x: Math.round(f.x + d.dx), y: Math.round(f.y + d.dy), w: Math.round(f.w + d.dw), h: Math.round(f.h + d.dh), maximized: false });+ const nx = Math.round(f.x + d.dx), ny = Math.round(f.y + d.dy);+ if (snapOn && !edges && typeof lord !== 'undefined' && lord.wm && typeof lord.wm.pointer === 'function') {+ const p = lord.wm.pointer();+ const zone = snapZoneAt(p.x, p.y);+ const w = windows.get().find((x) => x.id === id);+ if (zone && w) {+ if (!w.snapped) patch(id, { x: nx, y: ny, w: f.w, h: f.h }); // the size to go back to: from before the first snap+ snapTo(id, zone, displayAt(p.x, p.y));+ return;+ }+ if (w && w.snapped && w.restore) {+ // dragged out of a snapped place: back to its size, under the pointer where it was grabbed+ const rel = f.w ? Math.min(1, Math.max(0, (p.x - nx) / f.w)) : 0.5;+ const r = w.restore;+ patch(id, { x: Math.round(p.x - rel * r.w), y: ny, w: r.w, h: r.h, maximized: false, snapped: null, restore: null });+ return;+ }+ }+ patch(id, { x: nx, y: ny, w: Math.round(f.w + d.dw), h: Math.round(f.h + d.dh), maximized: false,+ ...(edges ? { snapped: null, restore: null } : null) });};// when each window was opened (lord.now()), for the developer timing log (settings "debugTiming")@@ -201,10 +281,24 @@ export const wm = {},focus: (id) => windows.set((ws) => (ws[ws.length - 1]?.id === id && !ws[ws.length - 1].minimized ? ws : raise(ws, id))),minimize: (id) => patch(id, { minimized: true }),- toggleMaximize: (id) => windows.set((ws) => ws.map((w) => (w.id === id ? { ...w, maximized: !w.maximized } : w))),- move: (id, x, y) => patch(id, { x: Math.round(x), y: Math.round(Math.max(workAreaOf(displayAt(x, y)).y, y)), maximized: false }),+ toggleMaximize: (id) => windows.set((ws) => ws.map((w) => (w.id !== id ? w : w.snapped && w.restore+ ? { ...w, ...w.restore, snapped: null, restore: null, maximized: true }+ : { ...w, maximized: !w.maximized }))),+ // Snapping (see "Snapping" above): zone is one of SNAP_ZONES; 'restore' goes back to the size+ // and place from before the first snap (or un-maximizes).+ snap: (id, zone) => { if (zone === 'restore') unsnap(id); else if (SNAP_ZONES.includes(zone)) snapTo(id, zone); },+ // Super+arrow (dir: 'left' | 'right' | 'up' | 'down'): snap.js snapNext.+ snapKey(id, dir) {+ const w = windows.get().find((x) => x.id === id);+ if (!w || w.fullscreen || w.pip) return;+ const to = snapNext(w.maximized ? 'max' : w.snapped, dir);+ if (!to) return;+ if (to === 'minimize') wm.minimize(id);+ else wm.snap(id, to);+ },+ move: (id, x, y) => patch(id, { x: Math.round(x), y: Math.round(Math.max(workAreaOf(displayAt(x, y)).y, y)), maximized: false, snapped: null, restore: null }),resize: (id, w, h) => patch(id, { w: Math.round(w), h: Math.round(h) }),- setFrame: (id, f) => patch(id, { ...f, maximized: false }),+ setFrame: (id, f) => patch(id, { ...f, maximized: false, snapped: null, restore: null }),setTitle: (id, title) => {const w = windows.get().find((x) => x.id === id);if (w && w.title !== title) patch(id, { title });diff --git a/server/src/ui/grab.c b/server/src/ui/grab.cindex 70111c6..22568c0 100644--- a/server/src/ui/grab.c+++ b/server/src/ui/grab.c@@ -26,6 +26,13 @@ void grab_note_pointer(float x, float y, int buttons) {int grab_active(void) { return g.active; }+int grab_state(float *x, float *y, int *edges) {+ *x = ptr_x;+ *y = ptr_y;+ *edges = g.active ? g.edges : 0;+ return g.active;+}+int grab_cursor(void) { return g.edges ? cursor_for_edges(g.edges) : CUR_MOVE; }static float dim_or(Dim d, float fallback) { return d.unit == UNIT_PX ? d.v : fallback; }diff --git a/server/src/ui/grab.h b/server/src/ui/grab.hindex 9cec1be..25cf50e 100644--- a/server/src/ui/grab.h+++ b/server/src/ui/grab.h@@ -27,6 +27,9 @@ void grab_note_pointer(float x, float y, int buttons);int grab_begin(int node, int edges, const GrabLimits *lim);int grab_active(void);int grab_cursor(void); /* cursor shape during the drag (cursor.h) */+/* Where the pointer is now and the drag's edges (0 = moving); 1 while a drag is active. Read by the+ * theme a few times per second for the window snapping preview (lord.wm.pointer, docs/WINDOWS.md). */+int grab_state(float *x, float *y, int *edges);void grab_motion(float x, float y); /* once per frame, with the accumulated pointer *//* Finished (the button was released): 1 and the node's change relative to the start. */int grab_finish(int *node, int *edges, float *dx, float *dy, float *dw, float *dh);diff --git a/server/src/ui/js_wm.c b/server/src/ui/js_wm.cindex b4f6cd5..7fa6fd8 100644--- a/server/src/ui/js_wm.c+++ b/server/src/ui/js_wm.c@@ -4,6 +4,8 @@* edges 0 = move; 1 top, 2 bottom, 4 left, 8 right (like xdg_toplevel.resize).* Only with a button held down; lord-server tracks it until it is released.* lord.wm.cancel()+ * lord.wm.pointer() → { x, y, active, edges }: the pointer now and the drag in progress (no+ * arguments, read only). The theme polls it while a window moves, for the snapping preview.* On release: __lordWm('end', { node, edges, dx, dy, dw, dh }) with the node's change.** lord.portal.set({ dark, accent: '#rrggbb', accentName, buttons })@@ -64,6 +66,18 @@ static JSValue f_cancel(JSContext *c, JSValueConst t, int argc, JSValueConst *arreturn JS_UNDEFINED;}+static JSValue f_pointer(JSContext *c, JSValueConst t, int argc, JSValueConst *argv) {+ (void)t; (void)argc; (void)argv;+ float x = 0, y = 0;+ int edges = 0, active = grab_state(&x, &y, &edges);+ JSValue o = JS_NewObject(c);+ JS_SetPropertyStr(c, o, "x", JS_NewFloat64(c, x));+ JS_SetPropertyStr(c, o, "y", JS_NewFloat64(c, y));+ JS_SetPropertyStr(c, o, "active", JS_NewBool(c, active));+ JS_SetPropertyStr(c, o, "edges", JS_NewInt32(c, edges));+ return o;+}+/* Short text without odd characters (accent name, GTK button order). */static int get_word(JSContext *c, JSValueConst o, const char *k, char *out, size_t n, const char *allowed) {JSValue v = JS_GetPropertyStr(c, o, k);@@ -102,6 +116,7 @@ static const JSCFunctionListEntry portal_funcs[] = {static const JSCFunctionListEntry wm_funcs[] = {JS_CFUNC_DEF("grab", 3, f_grab),JS_CFUNC_DEF("cancel", 0, f_cancel),+ JS_CFUNC_DEF("pointer", 0, f_pointer),};void js_wm_register(JSContext *c, JSValue lord) {diff --git a/server/src/ui/paint.c b/server/src/ui/paint.cindex 9de9a72..bddc942 100644--- a/server/src/ui/paint.c+++ b/server/src/ui/paint.c@@ -207,9 +207,9 @@ static int box_eq(Box a, Box b) {* minimize, a button's press) only re-rasterizes when it crosses a step: in between it is the same* raster composited at another scale. Anything that changes inside (a style, a text, a child's box)* invalidates it (damage_walk). The GPU path composites the same CPU canvas, so it gets the same- * result. Subtrees with an app window or a video on the GPU, or a backdrop blur, are painted- * untransformed; terminals and app windows on the CPU path are rasterized at the display's scale- * and never cached. */+ * result. Subtrees with an app window or a video on the GPU are painted untransformed; terminals,+ * backdrop blurs (blurring only the subtree's own pixels) and app windows on the CPU path are+ * rasterized at the display's scale and never cached. */#define TF_CACHE 16#define TF_MAX_PX (2048 * 2048)typedef struct {@@ -248,7 +248,10 @@ static void tf_norm(const Style *s, Style *o, StyleExt *ox) {* if something in it changes on its own (terminal, app window: never cached). */static void tf_bounds(const Node *n, Affine rel, Box *b, int *ok, int *live) {if (n->type == NODE_RAW || n->s.display_none) return;- if (n->s.backdrop_blur >= 1) *ok = 0;+ /* a backdrop blur inside only sees what the subtree painted under it in the raster (a window's+ * own content, not the desktop): good enough for a scaled preview (the Classic task view, the+ * Dock's minimize), and much better than painting the subtree untransformed. Never cached. */+ if (n->s.backdrop_blur >= 1) *live = 1;if (n->type == NODE_MEDIA) *ok = 0;if (n->type == NODE_SURFACE) { if (gpu_active()) *ok = 0; *live = 1; }if (n->type == NODE_TERM) *live = 1;diff --git a/server/tests/engine_test.c b/server/tests/engine_test.cindex cc08baf..c8adb46 100644--- a/server/tests/engine_test.c+++ b/server/tests/engine_test.c@@ -660,6 +660,19 @@ static void test_transform_paint_hit(void) {for (int x = 100; x < 230; x++) { uint32_t p = pix(x, 61); if (p != 0x00ff00 && p != 0xffffff && p != 0xff0000 && p != 0x000000) soft++; }CHECK(pix(150, 75) == 0x00ff00, "scaled bar at 150%%: %06x", pix(150, 75));CHECK(soft == 0, "blurry row inside the scaled bar at 150%% (%d px)", soft);++ /* a scaled subtree with a backdrop blur inside is still painted scaled (the Classic task view:+ * a translucent Terminal); before, it was painted at full size */+ if (FW != 160) { free(fb); fb = calloc(160 * 100, 4); FW = 160; FH = 100; }+ canvas_init(&frame, fb, 160, 100, 160);+ sn(a, "scaleX", 0.5); sn(a, "scaleY", 0.5);+ sn(b, "scaleX", 1); sn(b, "scaleY", 1); sn(b, "rotate", 90);+ sn(ac, "backgroundColor", 0x800000ff);+ sn(ac, "backdropBlur", 6);+ node_invalidate(a); node_invalidate(ac); node_invalidate(b);+ render(root, 160, 100);+ CHECK(pix(15, 15) == 0xffffff && pix(45, 30) == 0xffffff, "a blurred child kept its box unscaled: %06x %06x", pix(15, 15), pix(45, 30));+ CHECK(pix(35, 35) == 0xff0000, "the scaled box with a blurred child: %06x", pix(35, 35));}#endifdiff --git a/server/tests/run_suites.sh b/server/tests/run_suites.shindex 89e6398..03b86a3 100644--- a/server/tests/run_suites.sh+++ b/server/tests/run_suites.sh@@ -153,6 +153,9 @@ EOF# the Dock's pinned-list model (sdk/dockmodel.js)if have node; then run "dock-model-test (sdk/dockmodel.js)" node tests/dock_model_test.mjselse skip "dock-model-test" "node"; fi+ # window snapping geometry (sdk/snap.js): zones without gaps or overlaps, drop zones, Super+arrows+ if have node; then run "snap-test (sdk/snap.js)" node tests/snap_test.mjs+ else skip "snap-test" "node"; fi# smartctl's JSON → the Disks/Monitor SMART model (sdk/smartparse.js), with real smartctl outputif have node; then run "smart-parse-test (sdk/smartparse.js)" node tests/smart_parse_test.mjselse skip "smart-parse-test" "node"; fidiff --git a/server/tests/snap_test.mjs b/server/tests/snap_test.mjsnew file mode 100644index 0000000..862b478--- /dev/null+++ b/server/tests/snap_test.mjs@@ -0,0 +1,67 @@+// snap_test.mjs — window snapping geometry (sdk/snap.js): zones fill the work area without gaps or+// overlaps at odd sizes, the drop zones at the edges, and the Super+arrow moves.+//+// node tests/snap_test.mjs (from server/; run_suites.sh runs it when node exists)+import path from 'node:path';+import { fileURLToPath } from 'node:url';++const here = path.dirname(fileURLToPath(import.meta.url));+const { SNAP_ZONES, snapRect, zoneAt, snapNext, SNAP_EDGE } = await import(path.join(here, '../../sdk/snap.js'));++let n = 0, bad = 0;+const eq = (name, got, want) => {+ n++;+ const g = JSON.stringify(got), w = JSON.stringify(want);+ if (g !== w) { bad++; console.log(`✗ ${name}: want ${w}, got ${g}`); }+};+const area = (r) => r.w * r.h;+const overlap = (a, b) => a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h;++// a bottom taskbar (48 px) at 1280×800, an odd work area, a second display to the right, a left bar+const areas = [{ x: 0, y: 0, w: 1280, h: 752 }, { x: 0, y: 0, w: 1365, h: 719 }, { x: 1280, y: 0, w: 1921, h: 1033 }, { x: 56, y: 0, w: 1224, h: 800 }];+const layouts = [['left', 'right'], ['top-left', 'top-right', 'bottom-left', 'bottom-right'], ['left-third', 'center-third', 'right-third'],+ ['left-two-thirds', 'right-third'], ['left-third', 'right-two-thirds']];+for (const a of areas) {+ for (const l of layouts) {+ const rs = l.map((z) => snapRect(z, a));+ eq(`${l.join('+')} fills ${a.w}×${a.h}`, rs.reduce((s, r) => s + area(r), 0), area(a));+ let ov = 0;+ for (let i = 0; i < rs.length; i++) for (let j = i + 1; j < rs.length; j++) if (overlap(rs[i], rs[j])) ov++;+ eq(`${l.join('+')} no overlap at ${a.w}×${a.h}`, ov, 0);+ eq(`${l.join('+')} inside`, rs.every((r) => r.x >= a.x && r.y >= a.y && r.x + r.w <= a.x + a.w && r.y + r.h <= a.y + a.h), true);+ }+ eq(`max is the area ${a.w}`, snapRect('max', a), a);+ for (const z of SNAP_ZONES) eq(`${z} whole pixels`, Object.values(snapRect(z, a)).every(Number.isInteger), true);+}++// drop zones+const a = areas[0];+eq('left edge', zoneAt(0, 400, a), 'left');+eq('left edge within the margin', zoneAt(SNAP_EDGE, 400, a), 'left');+eq('just past the margin', zoneAt(SNAP_EDGE + 1, 400, a), null);+eq('right edge', zoneAt(1279, 400, a), 'right');+eq('top-left corner band', zoneAt(2, 40, a), 'top-left');+eq('bottom-right corner band', zoneAt(1279, 740, a), 'bottom-right');+eq('over a bottom taskbar, left side', zoneAt(0, 780, a), 'bottom-left');+eq('top edge', zoneAt(640, 0, a), 'max');+eq('middle', zoneAt(640, 400, a), null);+eq('left taskbar: its own strip counts as the left edge', zoneAt(20, 400, areas[3]), 'left');+eq('second display left edge', zoneAt(1281, 500, areas[2]), 'left');++// Super+arrows+eq('free → left', snapNext(null, 'left'), 'left');+eq('free → up maximizes', snapNext(null, 'up'), 'max');+eq('free → down minimizes', snapNext(null, 'down'), 'minimize');+eq('left → up is the top quarter', snapNext('left', 'up'), 'top-left');+eq('left → right restores', snapNext('left', 'right'), 'restore');+eq('left → left stays', snapNext('left', 'left'), null);+eq('top-left → right', snapNext('top-left', 'right'), 'top-right');+eq('top-right → up maximizes', snapNext('top-right', 'up'), 'max');+eq('bottom-right → down minimizes', snapNext('bottom-right', 'down'), 'minimize');+eq('max → down restores', snapNext('max', 'down'), 'restore');+eq('max → up stays', snapNext('max', 'up'), null);+eq('a third → left is the half', snapNext('center-third', 'left'), 'left');+eq('unknown direction', snapNext('left', 'sideways'), null);++console.log(`snap-test: ${n - bad}/${n} ok`);+process.exit(bad ? 1 : 0);