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
Compositor: the selection (clipboard and primary) goes to the focused client, its owner included, as the protocol says, and a new selection is offered at once; zwp_idle_inhibit_manager_v1 keeps the idle timers from running while an inhibiting surface is shown. Test Bench: idle-inhibit check, SIGPIPE ignored, clipboard read-back fix; 16 passed, 0 failed on VM 116
Federico Pereira5ff558f297ef
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9e73a06..383c7b1 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -26,6 +26,8 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),configured or actually tried. **Run tests** starts a test app that tries, inside the same sandbox asany isolated app, what it must not be able to do (your files, sockets, ptrace, leaving its scope,exec), plus the decoders' sandbox and the requests the system must refuse.+- **Linux video players can keep the screen on** (idle-inhibit), and an app that copies now sees its+ own copy in the clipboard as the Wayland protocol says.- **Test Bench** (`lordos-testbench`): a test pattern window that checks the display server from theoutside: frame timing and when frames really reach the screen, every key of the keyboard, themouse and wheel, and the Wayland protocols the system offers.diff --git a/docs/PAPER-VALIDATION.md b/docs/PAPER-VALIDATION.mdindex aa6dd48..3799e74 100644--- a/docs/PAPER-VALIDATION.md+++ b/docs/PAPER-VALIDATION.md@@ -153,7 +153,7 @@ compositor's keymap, modifiers and layout, repeat rate and delay) and every globthe picture for a still capture) and in `--auto`'s JSON. Each protocol is bound at the advertised versionand exercised, and a protocol error ends the connection with the failing check named (its first run caughtthe bench's own mistake, `wl_shm.release` on version 1, which LordOS's compositor rightly refused). First-run on VM 116 (headless session):+run on VM 116 (headless session); after the two compositor fixes below: 16 passed, 0 failed:| Check | Result ||---|---|@@ -164,10 +164,11 @@ run on VM 116 (headless session):| xdg popup | pass: configured 200×100 and mapped || maximize, fullscreen | pass: the configure carries the state, and loses it after unset || `linux-dmabuf` v4 feedback | pass, with a finding: a headless session sends main device 0:0 (none) and 4 formats |-| clipboard, primary selection round trip | **fail**: the compositor doesn't send a new selection back to the focused client that set it (`wl.c`, `offer_selection` returns early for "its own"); the protocol says the focused client gets every new selection. Toolkits cope, but it is a deviation |+| clipboard, primary selection round trip | **failed, then fixed (same day)**: the compositor didn't send a new selection back to the focused client that set it (`wl.c`, `offer_selection` and `prim_offer_to` returned early for "its own"), which the protocol requires. Now the focused client gets every new selection and `dev_set_selection` offers it at once; both round trips come back intact || `wp_presentation` | offered, but a headless session discards every frame and gives no refresh (the output's mode says 60 Hz) || cursor shape, relative pointer, gestures | bound; they need the real pointer or a touchpad to go green |-| not offered | text-input v3 (input methods for Linux apps), xdg-activation, idle-inhibit (a video player can't keep the screen on), single-pixel buffers, tearing control, content type, tablets, idle notify, drm-lease |+| idle inhibit | **added (same day)**: `zwp_idle_inhibit_manager_v1`; while a shown surface holds an inhibitor, `main.c` keeps the idle timers (screen off, lock, sleep) from running. The bench creates and releases one |+| not offered | text-input v3 (input methods for Linux apps), xdg-activation, single-pixel buffers, tearing control, content type, tablets, idle notify, drm-lease |Also seen: system shortcuts (F1 opens Help, F4 the launcher, ❖ combinations) never reach the app, so thekeyboard test can't light them; the bench should list them as taken by the system.diff --git a/docs/WAYLAND.md b/docs/WAYLAND.mdindex 00d057b..4b268a4 100644--- a/docs/WAYLAND.md+++ b/docs/WAYLAND.md@@ -470,3 +470,13 @@ display.- Drag and drop, `text-input` (LordOS input methods inside Wayland apps), activation(`xdg-activation`). (Fractional scale and several outputs: done, see `DISPLAYS.md`; primaryselection and Xwayland: done in 0.8.3, above.)++## Clipboard to its owner and idle-inhibit (0.8.5)++- **The selection goes to the focused client, its owner included.** `offer_selection` and `prim_offer_to`+ used to skip the client that set the selection; the protocol says the client with the keyboard gets every+ new selection. Now it does, and `dev_set_selection` offers the new selection at once (a receive from the+ owner is forwarded to its own source). Found by `lordos-testbench` (`docs/PAPER-VALIDATION.md`).+- **`zwp_idle_inhibit_manager_v1`**: a video player or a presentation creates an inhibitor on its surface;+ while that surface is mapped, `wl_idle_inhibited()` is true and `main.c` resets the idle timers (screen off,+ lock, sleep; Settings → Battery) on every loop.diff --git a/server/Makefile b/server/Makefileindex d492eac..28b9215 100644--- a/server/Makefile+++ b/server/Makefile@@ -29,7 +29,7 @@ WL_MORE := stable/linux-dmabuf/linux-dmabuf-v1 stable/presentation-time/presentaunstable/pointer-gestures/pointer-gestures-unstable-v1 \staging/cursor-shape/cursor-shape-v1 unstable/tablet/tablet-unstable-v2 \staging/fractional-scale/fractional-scale-v1 unstable/xdg-output/xdg-output-unstable-v1 \- unstable/primary-selection/primary-selection-unstable-v1+ unstable/primary-selection/primary-selection-unstable-v1 unstable/idle-inhibit/idle-inhibit-unstable-v1WL_GEN += $(foreach p,$(WL_MORE),build/gen/$(notdir $(p))-protocol.h)WL_OBJ += $(foreach p,$(WL_MORE),build/gen/$(notdir $(p))-protocol.o)@@ -425,7 +425,7 @@ CLIENT_PROTO := stable/xdg-shell/xdg-shell unstable/xdg-decoration/xdg-decoratiounstable/relative-pointer/relative-pointer-unstable-v1 unstable/pointer-constraints/pointer-constraints-unstable-v1 \unstable/pointer-gestures/pointer-gestures-unstable-v1 unstable/primary-selection/primary-selection-unstable-v1 \stable/viewporter/viewporter staging/fractional-scale/fractional-scale-v1 unstable/xdg-output/xdg-output-unstable-v1 \- stable/tablet/tablet-v2 staging/cursor-shape/cursor-shape-v1+ stable/tablet/tablet-v2 staging/cursor-shape/cursor-shape-v1 unstable/idle-inhibit/idle-inhibit-unstable-v1CLIENT_GEN := $(foreach p,$(CLIENT_PROTO),build/gen/client/$(notdir $(p))-client-protocol.h build/gen/client/$(notdir $(p))-protocol.c)define wl_client_protobuild/gen/client/$(notdir $(1))-client-protocol.h: $(WLPROTO)/$(1).xmldiff --git a/server/src/main.c b/server/src/main.cindex 33cfd8b..17d1d89 100644--- a/server/src/main.c+++ b/server/src/main.c@@ -1784,6 +1784,7 @@ int main(int argc, char **argv) {double td = term_timeout(now);if (td >= 0 && (delay < 0 || td < delay)) delay = td;tp_tick(now); /* touchpad: tocar, arrastrar, inercia (tp/tp.c) */+ if (wl_idle_inhibited()) display_activity(now_ms()); /* a video or a presentation keeps the screen on */display_tick(now_ms()); /* screen off, lock and sleep after N minutes (src/hw) */double hwd = display_timeout(now_ms());if (hwd >= 0 && (delay < 0 || hwd < delay)) delay = hwd;diff --git a/server/src/testbench/checks.c b/server/src/testbench/checks.cindex 6f2dfed..a6ce2a4 100644--- a/server/src/testbench/checks.c+++ b/server/src/testbench/checks.c@@ -30,6 +30,7 @@#include "client/pointer-constraints-unstable-v1-client-protocol.h"#include "client/pointer-gestures-unstable-v1-client-protocol.h"#include "client/primary-selection-unstable-v1-client-protocol.h"+#include "client/idle-inhibit-unstable-v1-client-protocol.h"Check checks[48];int nchecks, checks_done;@@ -450,6 +451,7 @@ int checks_run(void) {if (clip_offer_ready && clip_offer) {int pp[2];if (!pipe2(pp, O_CLOEXEC)) {+ clip_sent = 0; /* the compositor's own read of the source may have set it already */wl_data_offer_receive(clip_offer, CLIP_MIME, pp[1]);close(pp[1]);wl_display_flush(dpy);@@ -477,6 +479,7 @@ int checks_run(void) {if (prim_ready && prim_offer) {int pp[2];if (!pipe2(pp, O_CLOEXEC)) {+ prim_sent = 0;zwp_primary_selection_offer_v1_receive(prim_offer, CLIP_MIME, pp[1]);close(pp[1]);wl_display_flush(dpy);@@ -525,11 +528,23 @@ int checks_run(void) {gest_check = c;set(c, CK_UNTESTED, "BOUND V%u: SWIPE OR PINCH ON A TOUCHPAD", gg->version);}+ /* idle inhibit: what a video player does to keep the screen on */+ c = begin("idle inhibit");+ struct zwp_idle_inhibit_manager_v1 *iim = bind("zwp_idle_inhibit_manager_v1", &zwp_idle_inhibit_manager_v1_interface, 1);+ if (!iim) set(c, CK_FAIL, "%s", "NOT OFFERED: A VIDEO PLAYER CAN'T KEEP THE SCREEN ON");+ else {+ struct zwp_idle_inhibitor_v1 *in = zwp_idle_inhibit_manager_v1_create_inhibitor(iim, surf);+ sync_or();+ if (wl_display_get_error(dpy)) return died();+ zwp_idle_inhibitor_v1_destroy(in);+ sync_or();+ set(c, CK_PASS, "%s", "INHIBITOR CREATED AND RELEASED");+ }/* what a desktop expects to find, offered or not */static const struct { const char *iface, *what; int needed; } expect[] = {{ "wl_seat", "seat", 1 }, { "xdg_wm_base", "xdg-shell", 1 }, { "zxdg_decoration_manager_v1", "server decorations", 0 },{ "wp_presentation", "presentation time", 0 }, { "zwp_text_input_manager_v3", "input methods (text-input v3)", 0 },- { "xdg_activation_v1", "xdg-activation", 0 }, { "zwp_idle_inhibit_manager_v1", "idle inhibit (video)", 0 },+ { "xdg_activation_v1", "xdg-activation", 0 },{ "wp_single_pixel_buffer_manager_v1", "single-pixel buffers", 0 }, { "wp_tearing_control_manager_v1", "tearing control (games)", 0 },{ "wp_content_type_manager_v1", "content type", 0 }, { "zwp_tablet_manager_v2", "drawing tablets", 0 },{ "ext_idle_notifier_v1", "idle notify", 0 }, { "wp_drm_lease_device_v1", "VR headsets (drm-lease)", 0 },diff --git a/server/src/testbench/testbench.c b/server/src/testbench/testbench.cindex 9620cf2..f530152 100644--- a/server/src/testbench/testbench.c+++ b/server/src/testbench/testbench.c@@ -30,6 +30,7 @@#include <fcntl.h>#include <linux/input-event-codes.h>#include <poll.h>+#include <signal.h>#include <stdio.h>#include <stdlib.h>#include <string.h>@@ -754,6 +755,7 @@ int main(int argc, char **argv) {return 2;}}+ signal(SIGPIPE, SIG_IGN); /* a clipboard reader that hangs up must not end the bench (toolkits do the same) */dpy = wl_display_connect(NULL);if (!dpy) { fprintf(stderr, "lordos-testbench: no Wayland compositor (WAYLAND_DISPLAY)\n"); return 1; }xkb = xkb_context_new(XKB_CONTEXT_NO_FLAGS);diff --git a/server/src/wl/wl.c b/server/src/wl/wl.cindex fdc0948..bd0660c 100644--- a/server/src/wl/wl.c+++ b/server/src/wl/wl.c@@ -43,6 +43,7 @@#include "pointer-constraints-unstable-v1-protocol.h"#include "cursor-shape-v1-protocol.h"#include "fractional-scale-v1-protocol.h"+#include "idle-inhibit-unstable-v1-protocol.h"#include "xdg-output-unstable-v1-protocol.h"#include "primary-selection-unstable-v1-protocol.h"#include "xwm.h"@@ -1004,6 +1005,25 @@ static const struct wl_keyboard_interface keyboard_impl = { .release = res_releastatic const struct wl_touch_interface touch_impl = { .release = res_release };static void link_gone(struct wl_resource *r) { wl_list_remove(wl_resource_get_link(r)); }+/* ---- idle-inhibit: a video player or a presentation keeps the screen on while its surface is shown ---- */+static struct wl_list inhibitors;+static void inh_destroy(struct wl_client *c, struct wl_resource *r) { (void)c; wl_resource_destroy(r); }+static const struct zwp_idle_inhibitor_v1_interface inh_impl = { .destroy = inh_destroy };+static void iim_create(struct wl_client *c, struct wl_resource *r, uint32_t id, struct wl_resource *surface) {+ struct wl_resource *i = wl_resource_create(c, &zwp_idle_inhibitor_v1_interface, wl_resource_get_version(r), id);+ if (!i) { wl_client_post_no_memory(c); return; }+ wl_resource_set_implementation(i, &inh_impl, surface, link_gone); /* the surface, only compared below */+ wl_list_insert(&inhibitors, wl_resource_get_link(i));+}+static void iim_destroy(struct wl_client *c, struct wl_resource *r) { (void)c; wl_resource_destroy(r); }+static const struct zwp_idle_inhibit_manager_v1_interface iim_impl = { .destroy = iim_destroy, .create_inhibitor = iim_create };+static void bind_iim(struct wl_client *c, void *data, uint32_t ver, uint32_t id) {+ (void)data;+ struct wl_resource *r = wl_resource_create(c, &zwp_idle_inhibit_manager_v1_interface, (int)ver, id);+ if (!r) { wl_client_post_no_memory(c); return; }+ wl_resource_set_implementation(r, &iim_impl, NULL, NULL);+}+static void send_keymap(struct wl_resource *kb) {char *km = kb_keymap_string();if (!km) return;@@ -1273,7 +1293,8 @@ static void offer_gone(struct wl_resource *r) { free(wl_resource_get_user_data(rstatic void offer_selection(struct wl_resource *dev) {struct wl_client *c = wl_resource_get_client(dev);- if (selection && wl_resource_get_client(selection->res) == c) return; /* it is its own */+ /* the focused client gets every new selection, its own included (the protocol says so; its receive is+ * forwarded to its own source) */const char *t = term_clipboard();int image = !selection && clip_is_image && clip_png;if (!selection && !image && !t[0]) { wl_data_device_send_selection(dev, NULL); return; }@@ -1363,6 +1384,7 @@ static void dev_set_selection(struct wl_client *c, struct wl_resource *r, structselection = s;clip_offer_gen++;if (s) read_selection(s);+ offer_to_focus(); /* the new selection, to the client with the keyboard (the owner, usually) */}static const struct wl_data_device_interface device_impl = { .start_drag = dev_drag, .set_selection = dev_set_selection, .release = res_release };@@ -1448,7 +1470,6 @@ static void poffer_gone(struct wl_resource *r) { free(wl_resource_get_user_data(static void prim_offer_to(struct wl_resource *dev) {struct wl_client *c = wl_resource_get_client(dev);- if (prim_src && wl_resource_get_client(prim_src->res) == c) return; /* its own */if (!prim_text || !prim_len) { zwp_primary_selection_device_v1_send_selection(dev, NULL); return; }struct wl_resource *o = wl_resource_create(c, &zwp_primary_selection_offer_v1_interface, wl_resource_get_version(dev), 0);if (!o) return;@@ -3102,6 +3123,7 @@ int wl_start(void) {wl_global_create(dpy, &wl_seat_interface, 9, NULL, bind_seat); /* 8: axis_value120, 9: relative_direction */wl_global_create(dpy, &wl_data_device_manager_interface, 3, NULL, bind_ddm);wl_list_init(&prim_devices);+ wl_list_init(&inhibitors);wl_global_create(dpy, &zwp_primary_selection_device_manager_v1_interface, 1, NULL, bind_pdm); /* middle-click paste */wl_global_create(dpy, &xdg_wm_base_interface, 6, NULL, bind_wm_base);wl_global_create(dpy, &zxdg_decoration_manager_v1_interface, 1, NULL, bind_decm);@@ -3115,6 +3137,7 @@ int wl_start(void) {wl_global_create(dpy, &zwp_relative_pointer_manager_v1_interface, 1, NULL, bind_relm);wl_global_create(dpy, &zwp_pointer_constraints_v1_interface, 1, NULL, bind_consm);wl_global_create(dpy, &wp_cursor_shape_manager_v1_interface, 1, NULL, bind_csm); /* cursors by name */+ wl_global_create(dpy, &zwp_idle_inhibit_manager_v1_interface, 1, NULL, bind_iim); /* video keeps the screen on */wl_global_create(dpy, &kde_mgr_interface, 1, NULL, bind_kde_deco); /* theme frame for GTK 3 (Firefox) */wl_input_globals(dpy); /* zwp_pointer_gestures_v1 (wl_input.c) *//* inherited by apps opened from the LordOS terminal */@@ -3288,3 +3311,13 @@ const char *wlx_primary(size_t *n, unsigned *gen) {*gen = prim_gen;return prim_text ? prim_text : "";}++int wl_idle_inhibited(void) {+ if (!inhibitors.next) return 0; /* before wl_start */+ struct wl_resource *r;+ wl_resource_for_each(r, &inhibitors) {+ struct wl_resource *sr = wl_resource_get_user_data(r);+ for (int i = 0; i < MAX_SURF; i++) if (surfs[i] && surfs[i]->res == sr && surfs[i]->mapped) return 1;+ }+ return 0;+}diff --git a/server/src/wl/wl.h b/server/src/wl/wl.hindex d0eb46f..38f16f2 100644--- a/server/src/wl/wl.h+++ b/server/src/wl/wl.h@@ -39,6 +39,7 @@ void wl_close(int id); /* asks the app to close the window */void wl_set_state(int id, int maximized, int fullscreen);void wl_set_minimized(int id, int minimized); /* X11 windows: iconic and at the bottom of X's stack */int wl_count(void);+int wl_idle_inhibited(void); /* idle-inhibit: a shown surface asks the screen to stay on */void wl_output_resized(void); /* headless: one display of ui.width × ui.height */void wl_remap_all(void); /* a new JS context (theme switched): announce the open windows again *//* The displays (docs/DISPLAYS.md): one wl_output (+ xdg-output) each. x, y, w, h: logical rect in the