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
Paint: repaint a blurred surface whole, no lighter band after a menu closes
Federico Pereiradac30372cbb6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0c3e8e5..ccbfd03 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -84,6 +84,12 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),bar < fullscreen < launcher < menus and popovers < sheets < notifications < tooltips < dragimages < system prompts), and clicks follow it, in every Dock position, light and dark, RTL andthe Classic theme ([docs/LAYERS.md](docs/LAYERS.md)).+- **No lighter band in the menu bar after a menu or the Control Center closes.** The menu bar's+ background blur read the screen around it, and outside the repainted area that still held the+ bar's previous frame, so the repainted part came out lighter until something else redrew the bar.+ Now a change that touches a blurred surface, or the margin its blur reads, repaints the whole+ surface (the GPU path composites the same canvas; `engine-test` checks it against a full+ repaint).- **"No Bluetooth" for Linux apps is enforced on the Raspberry Pi 5** (a known issue in 0.8.0):`lord-netperm` loads its Bluetooth socket program there as on a PC (`npverify-test` 37/37 on theboard), and a process in a restricted app's scope gets `EPERM` from `socket(AF_BLUETOOTH)` whilediff --git a/docs/LAYERS.md b/docs/LAYERS.mdindex f69f6e9..8827e57 100644--- a/docs/LAYERS.md+++ b/docs/LAYERS.md@@ -83,11 +83,30 @@ import { Layer, Overlay, LAYERS } from '@lordos/sdk';- **Don't** fight the order with large `zIndex` values: they only order siblings. A new kind ofsurface gets a row in the table above (and in `sdk/layers.js`) instead.+## Blurred surfaces and partial repaints++The menu bar, the Dock, menus and the Control Center blur what is behind them+(`backdropFilter`). The blur reads the screen around the surface, a margin of twice its radius+(`canvas_backdrop_blur`). lord-server only repaints the area that changed, and outside it the+screen still holds the last frame, with the surface's own tint already on it: before 0.8.1, closing+a menu or the Control Center left a lighter band in the menu bar where the repainted area met it.+Now `paint_damage` (`paint.c`, `blur_walk`) grows the damaged area to the whole surface whenever a+change touches a blurred surface or the margin its blur reads, so the blur only sees this frame.+The GPU path composites that same canvas, so it gets the same fix (tested on VM 122 on the CPU+path).++| | |+|---|---|+|  |  |+| Before: the Control Center has just closed, a lighter band from «Help» to «US» | After: the same steps, the bar is even |+## Tests- `build/engine-test` (`make -C server test`), `test_layers`: layers created in the «wrong» treeorder still paint and hit in `zIndex` order; an empty layer lets the click through; a `zIndex`inside the base can't climb above a layer; `pointerEvents: 'none'` still hides a subtree.+ `test_backdrop_band`: after a menu closes, the blurred bar is repainted whole and matches a full+ repaint (37 levels lighter without the fix).- On the VM: the screenshots above (VM 122), clicking the crown menu's items over the Dock (theyopen their item, not the Dock's app) and the Passwords category list (picking «Licenses» changesthe form).diff --git a/docs/menubar-band-after.png b/docs/menubar-band-after.pngnew file mode 100644index 0000000..5ee8483Binary files /dev/null and b/docs/menubar-band-after.png differdiff --git a/docs/menubar-band-before.png b/docs/menubar-band-before.pngnew file mode 100644index 0000000..5ce36a9Binary files /dev/null and b/docs/menubar-band-before.png differdiff --git a/server/src/ui/paint.c b/server/src/ui/paint.cindex 8a8fc9c..ddbb5a7 100644--- a/server/src/ui/paint.c+++ b/server/src/ui/paint.c@@ -689,6 +689,23 @@ static void damage_walk(Node *n, int parent_dirty, int visible, int in_layer, Bostatic int box_inside(Box a, Box b) { return a.x0 >= b.x0 && a.y0 >= b.y0 && a.x1 <= b.x1 && a.y1 <= b.y1; }static int box_meets(Box a, Box b) { return a.x0 < b.x1 && b.x0 < a.x1 && a.y0 < b.y1 && b.y0 < a.y1; }+/* A backdrop blur reads the canvas around its box (canvas_backdrop_blur samples a margin of twice+ * the radius), and outside the region being repainted the canvas still holds the last frame, with+ * this node's own tint already on it. Blurring that in made the repainted part lighter: the band+ * left in the menu bar where a menu or the Control Center had just closed (0.8.1, docs/LAYERS.md).+ * So a damage that touches a blurred node, or the margin it samples, repaints the whole node: what+ * it blurs is then this frame's, as in a full repaint. Same on the GPU path (same CPU canvas). */+static void blur_walk(Node *n, int *grew) {+ if (n->type == NODE_RAW || n->s.display_none) return;+ Box b = n->prev_box;+ if (n->s.backdrop_blur >= 1 && b.x1 > b.x0 && b.y1 > b.y0) {+ float m = ceilf(n->s.backdrop_blur * 2) + 1;+ Box near = { b.x0 - m, b.y0 - m, b.x1 + m, b.y1 + m };+ if (box_meets(ui.damage, near) && !box_inside(b, ui.damage)) { damage_add(b); *grew = 1; }+ }+ for (Node *c = n->first; c; c = c->next) blur_walk(c, grew);+}+int paint_damage(Node *root) {/* lo que llegó de afuera desde el cuadro anterior (terminal, apps Linux, video): si toca la* ventana, se vuelve a pintar su capa; si cae afuera, lo de abajo */@@ -707,6 +724,8 @@ int paint_damage(Node *root) {if (!box_inside(ext, layer.at) && !box_inside(ext, now)) layer.below_valid = 0;}if (root) damage_walk(root, 0, 1, 0, (Box){ -1e9f, -1e9f, 1e9f, 1e9f });+ /* the damage is one box: growing it for a blurred node can reach another one (the bar and a menu) */+ for (int pass = 0, grew = 1; root && grew && pass < 4 && ui.damage.x1 > ui.damage.x0; pass++) { grew = 0; blur_walk(root, &grew); }if (layer.want && layer.valid && layer.part.x1 > layer.part.x0) { /* esa parte, donde está ahora la ventana */Node *n = node_get(layer.node);if (n) {diff --git a/server/tests/engine_test.c b/server/tests/engine_test.cindex 9c3fcf5..562d426 100644--- a/server/tests/engine_test.c+++ b/server/tests/engine_test.c@@ -402,6 +402,46 @@ static void test_layers(void) {CHECK(hit_test(root, 20, 30) == menu && pix(20, 30) == 0xff0000, "a zIndex inside the base stays under the layers");}+/* Closing a menu repaints only where it was; the translucent, blurred menu bar above it must come+ * out as in a full repaint (before 0.8.1 the blur mixed in the bar's last frame: a lighter band). */+static void test_backdrop_band(void) {+ ui_reset();+ Node *root = view(NULL);+ ui.root = root;+ sn(root, "backgroundColor", 0xff102040);+ for (int i = 0; i < 8; i++) box_in(root, (float)(i * 20), 0, 10, 100, 0xff4060a0); /* stripes to blur */+ Node *barl = layer_node(root, 20, 160, 100);+ Node *bar = box_in(barl, 0, 0, 160, 28, 0x80ffffff);+ sn(bar, "backdropBlur", 12);+ Node *popl = layer_node(root, 50, 160, 100);+ Node *menu = box_in(popl, 30, 20, 60, 60, 0xffff0000); /* reaches into the bar, like its shadow */+ render(root, 160, 100);+ node_destroy(menu);+ layout_root(root, 160, 100);+ Box d = { 0, 0, 0, 0 };+ if (paint_damage(root)) d = ui.damage;+ CHECK(d.x0 <= 0 && d.y0 <= 0 && d.x1 >= 160 && d.y1 >= 28, "the blurred bar is repainted whole: %.0f,%.0f %.0f,%.0f", d.x0, d.y0, d.x1, d.y1);+ ui.damage = d;+ Rect r = { (int)fmaxf(0, floorf(d.x0)), (int)fmaxf(0, floorf(d.y0)), (int)fminf(160, ceilf(d.x1)), (int)fminf(100, ceilf(d.y1)) };+ canvas_set_clip(&frame, r);+ canvas_clear(&frame, 0);+ paint_root(&frame, root);+ canvas_set_clip(&frame, (Rect){ 0, 0, 160, 100 });+ ui.damage = (Box){ 0, 0, 0, 0 };+ uint32_t *partial = malloc(160 * 28 * 4);+ if (!partial) return;+ memcpy(partial, fb, 160 * 28 * 4);+ render(root, 160, 100);+ int worst = 0;+ for (int i = 0; i < 160 * 28; i++)+ for (int sh = 0; sh < 24; sh += 8) {+ int dv = abs((int)((partial[i] >> sh) & 255) - (int)((fb[i] >> sh) & 255));+ if (dv > worst) worst = dv;+ }+ CHECK(worst <= 1, "menu bar after closing a menu differs from a full repaint by %d", worst);+ free(partial);+}+static void test_transform_paint_hit(void) {ui_reset();Node *root = view(NULL);@@ -674,6 +714,7 @@ int main(int argc, char **argv) {test_transform_math();test_transform_paint_hit();test_layers();+ test_backdrop_band();printf("engine-test: %d checks, %d failures\n", checks, fails);return fails ? 1 : 0;#endif