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
Fixes for 0.8.2: list items measured at their width, several damaged rectangles off by default, app host hashed off the main thread
Federico Pereirac1e41a3cec34
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a24e5a3..3cae13d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -113,13 +113,12 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),keeps it. The login screen (and the remote login page) now shows **Crystal Crown**.- The Control Center shows the current wallpaper and three from the collection; the rest are inSettings → Wallpaper (**Change Wallpaper…**).-- **The map's moving dots cost about half as much.** lord-server now repaints several small- rectangles per frame instead of the one box around every change, skips clipped parts of the- interface outside them, and copies only those rectangles to the screen; the dots are small- ready-made images. With Monitor's map animating, the animation's share of lord-server's CPU went- from 2.9 to 1.6 points of one core (VM 119, CPU compositing), and every partial repaint of the- desktop gets cheaper the same way. Blurred surfaces (the menu bar, the Dock) are still repainted- whole when anything touches them, as in 0.8.1 ([docs/MONITOR.md](docs/MONITOR.md#082-several-damaged-rectangles-vm-119)).+- **The map's moving dots are cheaper to draw:** they are small ready-made images and the map's+ frame is opaque, so a repaint starts there. Repainting several small rectangles per frame instead+ of the one box around every change (which halved the animation's cost in our measurements) is in+ this version but **off by default**: in one test a minimized window left a grey rectangle on the+ screen, and correctness comes first. `LORD_DAMAGE=multi` in lord-server's environment turns it+ on for testing ([docs/MONITOR.md](docs/MONITOR.md#082-several-damaged-rectangles-vm-119)).- Isolated apps start faster: the app host is compiled to bytecode once per session, so an app'sJavaScript loads in ~23 ms instead of ~110 ms (Mail's window: ~145 ms from the click to its firstframe on a 1.8 GHz test machine).@@ -133,6 +132,12 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),### Fixed+- **Long notes no longer overlap.** In a row with a part that grows (a list item's text next to its+ bullet), the layout engine measured that part's wrapped height at the whole row's width, so the+ last line of a long bullet could be drawn over the next one (Store → Updates, "What's new", and+ any Markdown list). It is now measured at the width it is drawn at.+- The app host's read and hash for isolated apps' bytecode moved off the main thread at session+ start (about 15 ms on a cold start); the bytecode is still compiled from exactly the verified bytes.- **Package lists after enabling a component.** Adding a component (such as `non-free-firmware`)or a source whose signed release file hadn't changed upstream left the package list as it was("already up to date"); the index is now rebuilt whenever the set of lists it is built fromdiff --git a/docs/LAYERS.md b/docs/LAYERS.mdindex 92a981b..e1779ee 100644--- a/docs/LAYERS.md+++ b/docs/LAYERS.md@@ -96,7 +96,8 @@ The GPU path composites that same canvas, so it gets the same fix (tested on VMpath).Since 0.8.2 the damage can be several rectangles painted one by one (`paint.c`, "Several damaged-rectangles"; the Monitor's moving map dots). The rule holds for each of them: a rectangle that+rectangles"; the Monitor's moving map dots; off by default in the 0.8.2 release, `LORD_DAMAGE=multi`+turns it on, see [MONITOR.md](MONITOR.md#082-several-damaged-rectangles-vm-119)). The rule holds for each of them: a rectangle thattouches a blurred surface or its margin grows to the whole surface, and every other rectangletouching that margin joins it, so a blur never reads a neighbour rectangle half painted(`test_multi_damage` in `build/engine-test`, against a full repaint).diff --git a/docs/MONITOR.md b/docs/MONITOR.mdindex 80fe1ba..7c908d6 100644--- a/docs/MONITOR.md+++ b/docs/MONITOR.md@@ -73,7 +73,8 @@ itself.`lord.setStyle`, no React render per frame: 12 frames per second with the window in front, 5behind it, at most the 12 busiest arcs and only those on screen; the timer stops with the windowminimized, while the map is being moved and when nothing moves. Each frame repaints only the- small rectangles the dots left and entered (0.8.2, "Several damaged rectangles"). With Appearance → Reduce motion, each busy arc shows two still markers instead: a short+ small rectangles the dots left and entered (0.8.2, "Several damaged rectangles", off by default+ in the 0.8.2 release). With Appearance → Reduce motion, each busy arc shows two still markers instead: a shortcomet of three dots, the biggest in front, pointing the way the bytes go.When an app is chosen, the map shows only its places and frames them. A click on a dot or an arc@@ -603,6 +604,17 @@ Network tab in front, five downloads running (one over HTTP/3), arcs to 4–6 co### 0.8.2: several damaged rectangles (VM 119)+**Off by default in the 0.8.2 release.** During the release integration test, a Terminal window+minimized over the animated map once (out of five tries) left a grey rectangle on the screen until+the window came back. The cause was not found in time: `test_minimize_damage` in+`build/engine-test` (a window remounted with a shrinking, fading transform towards a blurred Dock+and then removed, over moving dots, every frame compared with a full repaint) passes, so it is not+in the scene's painting as the test models it. Until it is found, lord-server repaints one box per+frame, exactly as in 0.8.1; `LORD_DAMAGE=multi` in its environment turns on the several-rectangles+path described here (with the clipped-subtree skip and the per-rectangle present, which follow the+same switch). The measurements below are with it on. The 9×9 dot images and the map frame's opaque+color (below, "The Monitor's side") stay on.+VM 119: 4 vCPU Xeon Silver 4108 at 1.8 GHz, `virtio` GPU without 3D, CPU compositing, 1280×800.Network tab in front, ten slow downloads to mirrors in ten countries (arcs to 8–11 countries, about20 moving dots). `lord-server` (whole process, % of one core), 5 × 30 s each, the same session@@ -629,7 +641,8 @@ moving, about 14 frames per second):the box around them; `paint_damage` joins pairs whose union wastes less than `DAMAGE_PASS_PX`(1,024 px, measured: 256 to 4,096 px all cost within 10 %), falls back to one box when theycover 70 % of it, and `paint_out` paints each one (clear, `paint_root` clipped to it). Only on- the CPU path and without a window being dragged; `LORD_DAMAGE=1` forces one box.+ the CPU path and without a window being dragged; only with `LORD_DAMAGE=multi` (off by default+ in 0.8.2, see above).- **Blurred surfaces** keep the 0.8.1 rule ("Paint: repaint a blurred surface whole"): a rectanglethat touches a blurred node or the margin its blur samples grows to the whole node, and everyrectangle touching that margin joins it, so the margin is either repainted in the same pass or@@ -648,7 +661,7 @@ moving, about 14 frames per second):inside a clipped, rounded "map" under a translucent blurred bar (dots crossing its blur margin, amenu opening and closing), each frame painted rectangle by rectangle and compared with a fullrepaint: identical (at most 1 level, as `test_backdrop_band`); no rectangle outside the box or- overlapping another; one box with `LORD_DAMAGE=1`; a full repaint set directly stays one box.+ overlapping another; one box when it is off; a full repaint set directly stays one box.With the blur rule turned off, 15 checks fail. `perf` was installed on VM 119 to find where thetime went (`VM-SETUP.md`).diff --git a/docs/PRIVACY.md b/docs/PRIVACY.mdindex bad8048..4bc3319 100644--- a/docs/PRIVACY.md+++ b/docs/PRIVACY.md@@ -522,10 +522,12 @@ package keeps its plain owner while a user `.lpk` with the same id does not reac| App host JavaScript in the app | — | **23 ms** (bytecode) instead of 110 ms (parsing 430 KB) || Memory | the session grows ~5 MB when Mail opens | Mail 26 MB RSS / 18 MB PSS; Calendar 22 / 15 MB; Contacts 20 / 13.5 MB; Reminders ~21 MB RSS |-- **The app host as bytecode** (`app/apphost_bc.c`): when the session starts, `lord-server` reads- `assets/app-host.bundle.js` once through the verified-code check (`codesig_load`, see- [SIGNING.md](SIGNING.md), "Verified system code") and, three seconds later, compiles exactly those- verified bytes on a thread with its own QuickJS runtime into a sealed memfd (1.7 MB); if the check+- **The app host as bytecode** (`app/apphost_bc.c`): three seconds after the session starts, a+ thread of `lord-server` with its own QuickJS runtime reads `assets/app-host.bundle.js` once+ through the verified-code check (`codesig_load`, see [SIGNING.md](SIGNING.md), "Verified system+ code"; the check's state is set up on the main thread before, and only its counters change+ under a lock) and compiles exactly those verified bytes into a sealed memfd (1.7 MB), so the+ read and the hash (~15 ms cold) stay off the main thread; if the checkrefuses the file nothing is compiled. Each app process gets a read-only fd of it(`LORD_APPHOST_BC_FD`), loads and verifies the source itself as before, and uses the bytecode onlyif its header carries the size and SHA-256 of those same bytes; otherwise it parses the source.diff --git a/server/Makefile b/server/Makefileindex 17ea601..b19105d 100644--- a/server/Makefile+++ b/server/Makefile@@ -218,7 +218,7 @@ build/sign-test: tests/sign_test.c src/sec/json.c src/sec/sign.c src/lpk.c src/ptest: build/codesig-testbuild/codesig-test: tests/codesig_test.c src/sec/codesig.c src/sec/json.c src/pkg/crypto.c src/sec/codesig.h src/sec/json.h src/pkg/crypto.h build/gen/codesig_build.h@mkdir -p build- $(CC) $(CPPFLAGS) $(CFLAGS) $(WARN) -std=c11 -o $@ tests/codesig_test.c src/sec/codesig.c src/sec/json.c src/pkg/crypto.c+ $(CC) $(CPPFLAGS) $(CFLAGS) $(WARN) -std=c11 -o $@ tests/codesig_test.c src/sec/codesig.c src/sec/json.c src/pkg/crypto.c -lpthread./$@ ../tools/release/lordos-release.pub.pem || { rm -f $@; exit 1; }# Clock time zones: TZif and POSIX rules against glibc (docs/SYSTEM.md)test: build/tzif-testdiff --git a/server/src/app/apphost_bc.c b/server/src/app/apphost_bc.cindex 60e1b5d..e298b39 100644--- a/server/src/app/apphost_bc.c+++ b/server/src/app/apphost_bc.c@@ -3,8 +3,8 @@* every time it starts (~80 ms on a 1.8 GHz core; reading the bytecode takes ~3 ms).** lord-server reads the bundle once through the verified-code check (codesig_load: the bytes that- * were hashed against the signed manifest are the bytes returned) and compiles exactly those bytes- * on a thread of its own, with its own QuickJS runtime, a few seconds after the session starts,+ * were hashed against the signed manifest are the bytes returned) and compiles exactly those bytes,+ * both on a thread of its own, with its own QuickJS runtime, a few seconds after the session starts,* into a sealed memfd. app_spawn() hands the app process a read-only fd of it* (LORD_APPHOST_BC_FD). The app process loads and verifies the source itself as before and uses* the bytecode only if its header carries the size and SHA-256 of those same bytes; otherwise, or@@ -38,8 +38,6 @@ typedef struct {static _Atomic int bc_fd = -1;static char bc_path[1024];-static char *bc_src; /* the verified bytes (codesig_load), owned by the thread */-static size_t bc_len;static void header_of(const char *src, size_t len, BcHeader *h) {memset(h, 0, sizeof *h);@@ -52,9 +50,12 @@ static void *compile_thread(void *arg) {(void)arg;struct timespec pause = { 3, 0 }; /* after the desktop has drawn its first frames */nanosleep(&pause, NULL);- char *src = bc_src;- size_t got = bc_len;- bc_src = NULL;+ /* read and hashed here, off the main thread (~15 ms cold at session start); the state and the+ * manifest were set up on the main thread before it started (apphost_bc_start) */+ char why[160];+ size_t got = 0;+ char *src = codesig_load(bc_path, BC_MAX, &got, why, sizeof why);+ if (!src) { fprintf(stderr, "lord-server: no app host bytecode: %s\n", why); return NULL; }JSRuntime *rt = JS_NewRuntime();JSContext *cx = rt ? JS_NewContext(rt) : NULL;uint8_t *bc = NULL;@@ -93,18 +94,15 @@ void apphost_bc_start(const char *bundle_path) {if (started || !bundle_path || strlen(bundle_path) >= sizeof bc_path) return;started = 1;snprintf(bc_path, sizeof bc_path, "%s", bundle_path);- /* in this thread: the verified-code state is the process's own (sec/codesig.c) */- char why[160];- bc_src = codesig_load(bc_path, BC_MAX, &bc_len, why, sizeof why);- if (!bc_src) { fprintf(stderr, "lord-server: no app host bytecode: %s\n", why); return; }+ /* the verified-code state is set up once, on this thread (main.c); without it, no bytecode:+ * the apps parse the source, as before */+ if (codesig_state() == CODE_UNCHECKED) { fprintf(stderr, "lord-server: no app host bytecode: code check not set up\n"); return; }pthread_t t;pthread_attr_t at;pthread_attr_init(&at);pthread_attr_setdetachstate(&at, PTHREAD_CREATE_DETACHED);if (pthread_create(&t, &at, compile_thread, NULL)) {fprintf(stderr, "lord-server: no thread for the app host bytecode\n");- free(bc_src);- bc_src = NULL;}pthread_attr_destroy(&at);}diff --git a/server/src/main.c b/server/src/main.cindex 5e9dc98..300e6f1 100644--- a/server/src/main.c+++ b/server/src/main.c@@ -1193,7 +1193,7 @@ static void present_cpu(Server *s, Out *o, int index, Rect r, int feed) {for (int i = 1; i < cp.n; i++) cb = box_join(cb, cp.r[i]);Rect cbr = { (int)cb.x0, (int)cb.y0, (int)cb.x1, (int)cb.y1 };Rect nj = rect_join(rect_join(o->stale[bi], r), o->curs[bi]);- if (!xf && cp.n > 1 && cbr.x0 == nj.x0 && cbr.y0 == nj.y0 && cbr.x1 == nj.x1 && cbr.y1 == nj.y1) {+ if (paint_multi_damage && !xf && cp.n > 1 && cbr.x0 == nj.x0 && cbr.y0 == nj.y0 && cbr.x1 == nj.x1 && cbr.y1 == nj.y1) {for (int i = 0; i < cp.n; i++) {Rect q = { (int)cp.r[i].x0, (int)cp.r[i].y0, (int)cp.r[i].x1, (int)cp.r[i].y1 };if (q.x0 < 0) q.x0 = 0;@@ -1636,7 +1636,7 @@ int main(int argc, char **argv) {if (ok && !s.greeter) portal_start(); /* dark mode, accent and buttons for GTK/GNOME/Qt (ui/portal.c) */if (ok && !s.greeter) term_restore(); /* shells still alive from the previous start */netrec_init(ok && !s.greeter && session_user != NULL); /* the Monitor's traffic history (monitor/netrec.c) */- if (getenv("LORD_DAMAGE") && !strcmp(getenv("LORD_DAMAGE"), "1")) paint_multi_damage = 0; /* one damaged box (paint.c) */+ if (getenv("LORD_DAMAGE") && !strcmp(getenv("LORD_DAMAGE"), "multi")) paint_multi_damage = 1; /* several damaged rectangles (paint.c; off by default) */remote_server = &s;tp_route_init(&tp_host);static const MirrorInput mirror_in = { remote_pointer, remote_button, remote_wheel, remote_key, remote_clip, remote_clients,diff --git a/server/src/sec/codesig.c b/server/src/sec/codesig.cindex 3b0c8cc..d459c30 100644--- a/server/src/sec/codesig.c+++ b/server/src/sec/codesig.c@@ -8,6 +8,7 @@#include <errno.h>#include <fcntl.h>#include <limits.h>+#include <pthread.h>#include <stdio.h>#include <stdlib.h>#include <string.h>@@ -177,6 +178,11 @@ static struct {CodeRefusal refused[16];int nrefused;} cs = { .state = CODE_UNCHECKED, .rootfd = -1 };+/* codesig_load also runs on the app host's bytecode thread (app/apphost_bc.c), after the state+ * was set up on the main thread: the manifest is read-only then, only the time spent and the+ * refusals change, under this lock */+static pthread_mutex_t cs_mu = PTHREAD_MUTEX_INITIALIZER;+static void add_ms(double dt) { pthread_mutex_lock(&cs_mu); cs.ms += dt; pthread_mutex_unlock(&cs_mu); }static double now_ms(void) {struct timespec t;@@ -303,9 +309,9 @@ CodeState codesig_state(void) { return cs.state; }const char *codesig_root(void) { return cs.root; }const char *codesig_reason(void) { return cs.reason; }const CodeManifest *codesig_manifest(void) { return cs.have_manifest ? &cs.m : NULL; }-double codesig_ms(void) { return cs.ms; }-int codesig_refused_count(void) { return cs.nrefused; }-CodeRefusal *codesig_refused(int i) { return i >= 0 && i < cs.nrefused ? &cs.refused[i] : NULL; }+double codesig_ms(void) { pthread_mutex_lock(&cs_mu); double v = cs.ms; pthread_mutex_unlock(&cs_mu); return v; }+int codesig_refused_count(void) { pthread_mutex_lock(&cs_mu); int v = cs.nrefused; pthread_mutex_unlock(&cs_mu); return v; }+CodeRefusal *codesig_refused(int i) { return i >= 0 && i < codesig_refused_count() ? &cs.refused[i] : NULL; }const char *codesig_state_name(CodeState s) {switch (s) {@@ -318,12 +324,17 @@ const char *codesig_state_name(CodeState s) {static void refuse(const char *rel, const char *why) {fprintf(stderr, "code: REFUSED %s: %s — this LordOS component was modified and was not loaded\n", rel, why);- for (int i = 0; i < cs.nrefused; i++) if (!strcmp(cs.refused[i].path, rel)) return;- if (cs.nrefused >= (int)(sizeof cs.refused / sizeof cs.refused[0])) return;- CodeRefusal *r = &cs.refused[cs.nrefused++];- snprintf(r->path, sizeof r->path, "%s", rel);- snprintf(r->reason, sizeof r->reason, "%s", why);- r->reported = 0;+ pthread_mutex_lock(&cs_mu);+ int known = 0;+ for (int i = 0; i < cs.nrefused; i++) if (!strcmp(cs.refused[i].path, rel)) known = 1;+ if (!known && cs.nrefused < (int)(sizeof cs.refused / sizeof cs.refused[0])) {+ CodeRefusal *r = &cs.refused[cs.nrefused];+ snprintf(r->path, sizeof r->path, "%s", rel);+ snprintf(r->reason, sizeof r->reason, "%s", why);+ r->reported = 0;+ cs.nrefused++; /* after the entry is complete */+ }+ pthread_mutex_unlock(&cs_mu);}char *codesig_load(const char *path, size_t max, size_t *len, char *why, size_t whylen) {@@ -357,7 +368,7 @@ char *codesig_load(const char *path, size_t max, size_t *len, char *why, size_tif (!buf) { snprintf(why, whylen, "cannot read it"); return NULL; } /* missing: not a modification */if (!cs.have_manifest) {/* development build without a manifest: runs, flagged in About */- cs.ms += now_ms() - t0;+ add_ms(now_ms() - t0);*len = n;return buf;}@@ -367,7 +378,7 @@ char *codesig_load(const char *path, size_t max, size_t *len, char *why, size_treturn NULL;}double dt = now_ms() - t0;- cs.ms += dt;+ add_ms(dt);fprintf(stderr, "code: %s %s (%zu KB) checked in %.2f ms\n", cs.state == CODE_VERIFIED ? "verified" : "hash ok", rel, n / 1024, dt);*len = n;return buf;diff --git a/server/src/ui/layout.c b/server/src/ui/layout.cindex 5f57e43..66c88c5 100644--- a/server/src/ui/layout.c+++ b/server/src/ui/layout.c@@ -112,6 +112,14 @@ static void measure(Node *n, float aw, float ah, float *ow, float *oh) {int wrap = s->wrap && !isnan(lim);float line_m = 0, line_c = 0, tot_m = 0, tot_c = 0;int in_line = 0;+ /* a row's children that grow (flex: 1) end up narrower than the whole row: their height+ * is measured again below at the width layout_line gives them, or wrapping text inside+ * them (a list item's text next to its bullet) is taller than measured and overlaps+ * what follows (0.8.2: Store → Updates, "What's new") */+ enum { GROW_MAX = 16 };+ Node *gk[GROW_MAX];+ float gbase[GROW_MAX], gmv[GROW_MAX], gw[GROW_MAX], fixed_m = 0, grow_sum = 0;+ int ng = 0, grow_over = 0;for (Node *c = n->first; c; c = c->next) {if (!in_flow(c)) continue;prepare(c);@@ -133,10 +141,38 @@ static void measure(Node *n, float aw, float ah, float *ow, float *oh) {in_line++;continue;}- if (s->row) { cw += c_w; if (c_h > ch) ch = c_h; }+ if (s->row) {+ cw += c_w;+ if (c_h > ch) ch = c_h;+ if (c->s.grow > 0 && !isnan(iaw)) {+ if (ng < GROW_MAX) {+ float b = res(c->s.basis, iaw);+ gk[ng] = c;+ gbase[ng] = (isnan(b) ? c_w - mh : b) + mh;+ gmv[ng] = mv;+ gw[ng] = c_w - mh;+ ng++;+ grow_sum += c->s.grow;+ } else grow_over = 1;+ } else fixed_m += c_w;+ }else { ch += c_h; if (c_w > cw) cw = c_w; }count++;}+ if (s->row && ng && !grow_over && !wrap) {+ float free = iaw - fixed_m - (count > 1 ? s->gap * (count - 1) : 0);+ for (int i = 0; i < ng; i++) free -= gbase[i];+ for (int i = 0; i < ng; i++) {+ const float *cm = node_margin(gk[i]);+ float mh = cm[EDGE_L] + cm[EDGE_R];+ float sz = gbase[i] + (free > 0 ? free * gk[i]->s.grow / grow_sum : 0) - mh;+ sz = clamp_dim(sz, gk[i]->s.min_w, gk[i]->s.max_w, iaw);+ if (gw[i] <= sz + 0.5f) continue; /* it fits: same height */+ float c_w, c_h;+ measure(gk[i], sz, isnan(iah) ? NAN : iah - gmv[i], &c_w, &c_h);+ if (c_h + gmv[i] > ch) ch = c_h + gmv[i];+ }+ }if (wrap) {if (line_m > tot_m) tot_m = line_m;tot_c += line_c;diff --git a/server/src/ui/paint.c b/server/src/ui/paint.cindex 9de9a72..73d665c 100644--- a/server/src/ui/paint.c+++ b/server/src/ui/paint.c@@ -730,11 +730,13 @@ static void blur_walk(Node *n, int *grew) {* the same pass or not repainted this frame at all (then it still holds what it showed).* - Only on the CPU path and without a window being dragged (its layer and the GPU's window list* are built for one paint_root per frame); otherwise one box, as before. */-#ifdef LORD_DAMAGE_SINGLE-int paint_multi_damage = 0; /* a build for comparing (docs/MONITOR.md, measurements) */-#else-int paint_multi_damage = 1; /* LORD_DAMAGE=1 in lord-server's environment: one box */-#endif+/* Off by default since the 0.8.2 release: once, out of five tries during the 0.8.2 integration+ * test, a window minimized over Monitor's animated map left a grey rectangle until it came back,+ * and the cause was not found (engine-test test_minimize_damage, a full-repaint comparison of that+ * scene, passes). Correctness first: one box, exactly as in 0.8.1, unless lord-server runs with+ * LORD_DAMAGE=multi (main.c). The clipped-subtree skip (paint_cull) and the copy of only the+ * painted rectangles (present_cpu) follow the same switch. */+int paint_multi_damage = 0;static Box drects[DAMAGE_MAX];static int ndrects;@@ -905,7 +907,7 @@ void paint_root(Canvas *c, Node *root) {skip_until = gpu_active() ? 0 : media_cover_node(ui.damage.x0, ui.damage.y0, ui.damage.x1, ui.damage.y1);if (!skip_until && !gpu_active() && !layer.want) skip_until = opaque_cover_node(root);skip_reached = 0;- paint_cull = !gpu_active();+ paint_cull = !gpu_active() && paint_multi_damage;/* una ventana que se mueve: lo de abajo se copia y se pinta desde ella (capa del arrastre) */if (!skip_until && below_ready(c, root)) {below_copy(c);diff --git a/server/src/ui/ui.h b/server/src/ui/ui.hindex 81cdf37..5bc8ac4 100644--- a/server/src/ui/ui.h+++ b/server/src/ui/ui.h@@ -280,7 +280,7 @@ int paint_damage(Node *root); /* computes ui.damage; 0 if there is nothing/* after paint_damage: the rectangles to repaint (1 = just ui.damage), each inside ui.damage;* see "Several damaged rectangles" in paint.c */int paint_damage_rects(Box *out, int max);-extern int paint_multi_damage; /* 0: always one rectangle (LORD_DAMAGE=1, tests) */+extern int paint_multi_damage; /* 1: several rectangles (LORD_DAMAGE=multi, tests); 0 by default */void paint_root(Canvas *c, Node *root);Node *hit_test(Node *root, float x, float y);/* Capture mode (media/capture.c): protected nodes are painted black and app windowsdiff --git a/server/tests/engine_test.c b/server/tests/engine_test.cindex cc08baf..b97736f 100644--- a/server/tests/engine_test.c+++ b/server/tests/engine_test.c@@ -496,6 +496,7 @@ static int full_differs(Node *root, int w, int h, int *where) {static void test_multi_damage(void) {enum { W = 640, H = 400, DOTS = 24 };+ paint_multi_damage = 1; /* off by default (paint.c); LORD_DAMAGE=multi */ui_reset();Node *root = view(NULL);ui.root = root;@@ -585,6 +586,122 @@ static void test_multi_damage(void) {if (l.r[i].x0 < l.r[j].x1 && l.r[j].x0 < l.r[i].x1 && l.r[i].y0 < l.r[j].y1 && l.r[j].y0 < l.r[i].y1) overl++;CHECK(!overl, "dlist never holds two overlapping rectangles (%d)", overl);(void)worst_all;+ paint_multi_damage = 0;+}+++/* Minimizing a window over the Monitor's moving dots (0.8.2 release): the window is remounted with a+ * shrinking transform towards the Dock, then removed, while the dots keep moving. Every frame,+ * painted as several rectangles, must match a full repaint: once a few small rectangles are the+ * only damage, anything left behind stays on screen (the grey rectangle seen during integration). */+static Node *mk_window(Node *root, float x, float y, float w, float h) {+ Node *win = box_in(root, x, y, w, h, 0xff3a3a3c);+ ss(win, "overflow", "hidden");+ sn(win, "borderRadius", 10);+ sn(win, "shadowColor", 0x80000000);+ sn(win, "shadowBlur", 28);+ sn(win, "shadowOffsetY", 10);+ sn(win, "borderWidth", 1);+ sn(win, "borderColor", 0x40ffffff);+ box_in(win, 0, 0, w, 28, 0xff505052); /* title bar */+ box_in(win, 8, 36, w - 16, h - 44, 0xff1e1e1e); /* content */+ return win;+}++static void test_minimize_damage(void) {+ enum { W = 640, H = 400, DOTS = 24 };+ for (int variant = 0; variant < 8; variant++) {+ paint_multi_damage = variant < 4; /* both: several rectangles (LORD_DAMAGE=multi) and one box */+ ui_reset();+ Node *root = view(NULL);+ ui.root = root;+ sn(root, "backgroundColor", 0xff1c1c1e);+ Node *map = box_in(root, 20, 30, 600, 350, 0xff20304a);+ ss(map, "overflow", "hidden");+ sn(map, "borderRadius", 12);+ Node *dots[DOTS];+ float dx[DOTS], dy[DOTS];+ for (int i = 0; i < DOTS; i++) {+ dx[i] = (float)(rnd() % 580);+ dy[i] = (float)(rnd() % 330);+ dots[i] = box_in(map, dx[i], dy[i], 6, 6, i % 2 ? 0xd8ff9f0a : 0xd830d158);+ sn(dots[i], "borderRadius", 3);+ }+ Node *barl = layer_node(root, 20, W, H);+ Node *bar = box_in(barl, 0, 0, W, 24, 0x80ffffff);+ sn(bar, "backdropBlur", 10);+ Node *dockl = layer_node(root, 10, W, H);+ Node *dock = box_in(dockl, 220, 350, 200, 46, 0x90303034);+ sn(dock, "backdropBlur", 20);+ sn(dock, "borderRadius", 14);+ float wx = 140 + (variant % 4) * 20, wy = 90, ww = 320, wh = 200;+ Node *win = mk_window(root, wx, wy, ww, wh);+ render(root, W, H);+ int steps = 6 + (variant % 4) * 3, bad = 0;+ for (int f = 0; f < 40; f++) {+ for (int i = 0; i < DOTS; i++) {+ if ((i + f) % 4 == 0) continue;+ dx[i] += (float)((int)(rnd() % 9) - 4) + 0.5f;+ dy[i] += (float)((int)(rnd() % 7) - 3);+ if (dx[i] < -6) dx[i] = 580;+ if (dx[i] > 600) dx[i] = 0;+ if (dy[i] > 350 || dy[i] < -6) dy[i] = 100;+ sn(dots[i], "left", dx[i]);+ sn(dots[i], "top", dy[i]);+ }+ if (f == 4) { /* minimize: the same window, remounted */+ node_destroy(win);+ win = mk_window(root, wx, wy, ww, wh);+ }+ if (f >= 4 && f < 4 + steps) {+ float p = (float)(f - 4 + 1) / (float)steps, e = p * p;+ sn(win, "scaleX", 1 - 0.92f * e);+ sn(win, "scaleY", 1 - 0.92f * e);+ sn(win, "translateX", (320 - (wx + ww / 2)) * e);+ sn(win, "translateY", (364 - (wy + wh / 2)) * e);+ sn(win, "opacity", 1 - 0.7f * e);+ }+ if (f == 4 + steps && win) { node_destroy(win); win = NULL; }+ if (f == 30) win = mk_window(root, wx, wy, ww, wh); /* restored */+ layout_root(root, W, H);+ int n = 0;+ float area = 0;+ if (paint_partial(root, W, H, &n, &area) < 0) { bad++; continue; }+ int where = 0, worst = full_differs(root, W, H, &where);+ CHECK(worst <= 1, "minimize variant %d frame %d (%d rects) differs from a full repaint by %d at %d,%d",+ variant, f, n, worst, where % W, where / W);+ }+ CHECK(!bad, "minimize variant %d: %d frames with bad rectangles", variant, bad);+ }+ paint_multi_damage = 0;+}+++/* A row with a fixed child and one that grows (a list item: bullet + text): the growing child's+ * wrapped height is measured at the width it gets, not the whole row's (0.8.2: the last line of a+ * long "What's new" bullet in Store → Updates drew over the next bullet). */+static void test_grow_wrap_height(void) {+ ui_reset();+ Node *root = view(NULL);+ ui.root = root;+ sn(root, "width", 200);+ Node *row = view(root);+ ss(row, "flexDirection", "row");+ Node *bullet = view(row);+ sn(bullet, "width", 18); sn(bullet, "height", 14);+ Node *text = view(row);+ sn(text, "flexGrow", 1); sn(text, "flexBasis", 0);+ Node *words = view(text);+ ss(words, "flexDirection", "row");+ ss(words, "flexWrap", "wrap");+ for (int i = 0; i < 10; i++) { Node *w = view(words); sn(w, "width", 40); sn(w, "height", 14); }+ Node *next = view(root);+ sn(next, "height", 10);+ layout_root(root, 200, 300);+ /* 182 px for the words: 4 per line, 3 lines (at 200 it would be 5 per line, 2 lines) */+ CHECK(fabsf(words->h - 42) < 0.5f, "wrapped words: %g high, want 42", words->h);+ CHECK(row->h >= words->h - 0.5f, "the row (%g) is shorter than its wrapped text (%g)", row->h, words->h);+ CHECK(next->ay >= row->ay + words->h - 0.5f, "the next item (y %g) overlaps the wrapped text (ends at %g)", next->ay, row->ay + words->h);}static void test_transform_paint_hit(void) {@@ -861,6 +978,8 @@ int main(int argc, char **argv) {test_layers();test_backdrop_band();test_multi_damage();+ test_minimize_damage();+ test_grow_wrap_height();printf("engine-test: %d checks, %d failures\n", checks, fails);return fails ? 1 : 0;#endif