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
Xwayland docs (WAYLAND, PRIVACY, FIREWALL, LAYERS, ARCHITECTURE, ROADMAP, VM-SETUP), CHANGELOG 0.8.3, screenshots, keysnoop test; XWM debug log behind LORD_XWM_DEBUG
Federico Pereira945eacce6be3
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a24e5a3..42124c6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,38 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),## [Unreleased]+## [0.8.3] - Unreleased++### Added++- **X11 apps.** Programs that only speak X11 (xterm, Java/Swing apps, many games and older tools)+ now open in LordOS through Xwayland (the `xwayland` package), with the theme's window frame, their+ icon in the Dock (matched to their launcher by `WM_CLASS`), menus and tooltips above everything,+ fullscreen, minimize and close, and LordOS's cursor. Xwayland only starts when an X11 app+ connects and stops 10 seconds after the last one closes. LordOS's own X window manager is+ written in C and speaks the X11 protocol itself, without new libraries in `lord-server`.+- **Clipboard with X11 apps**, both ways, for the normal clipboard and the primary selection+ (select to copy, middle click to paste); large copies and images included.+- **Primary selection for Wayland apps** (middle-click paste between GTK, Qt and other apps).++### Security++- X11 apps run in their app's scope, so per-app firewall rules and the Monitor apply to them.+- X11 apps never see Wayland apps, LordOS's screen, Passwords or the keyring prompt, nor the keys+ typed into them; what is copied outside X enters X only while an X window has the keyboard, and+ passwords copied in Passwords never do. Synthetic input between X11 apps (XTEST) is off.+ Xwayland runs without network, in its own scope. X11 apps can still see each other, as in any X11+ desktop (see the privacy documentation).+- Apps with device or "no files" restrictions get no X display.+- Clipboard offers to Wayland apps are bound to the selection they were made for and to the app+ with the keyboard.++### Fixed++- Typing into search, the app launcher or a system prompt while a Linux app was in front sent the+ keys to that app instead.+- Java (AWT/Swing) windows were blank or shifted (non-reparenting window manager).+## [0.8.2] - Unreleased### Addeddiff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex c42fbeb..3347889 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -95,6 +95,11 @@ Besides the kernel and libc, only these are allowed:| EFF word list, 10k common passwords | passphrase generator and the offline "breached" check (CC BY 3.0 US / MIT), embedded in `lord-vault` | `third_party/wordlists` || Inter, JetBrains Mono | interface and terminal fonts (OFL) | `assets/fonts` |+**Xwayland** (Debian's `xwayland` package, 0.8.3) is not linked by anything: it is a separate+program that `lord-server` starts on demand for X11 apps (`WAYLAND.md`, "X11 apps (Xwayland)").+The X window manager inside `lord-server` speaks the X11 protocol itself (`server/src/wl/xwm.c`,+`x11wire.c`): no libxcb or libX11. Without the package, X11 apps simply don't open.+React (`react`, `react-reconciler`) is a dependency **of the theme**, not of the system: it is bundledwith esbuild inside the theme's `.js`. Since 0.7.0 it is React 19.3.1 with `react-reconciler` 0.34(the default theme weighs 367 KB with all the apps; React 18 was ~40 KB less). Node.js is onlydiff --git a/docs/FIREWALL.md b/docs/FIREWALL.mdindex 5d9f3dc..2a23179 100644--- a/docs/FIREWALL.md+++ b/docs/FIREWALL.md@@ -312,7 +312,9 @@ scoping (no abstract unix socket and no signal outside it). So it can't create onor start anything outside its scope, and the device program and the PipeWire guard always findit by its scope. It costs the app the session bus: notifications, portals and the like overD-Bus don't work for it. Applied at launch: restart the app to apply. Without Landlock ABI 6-(kernel 6.12 or later) a restricted app isn't started at all, and the launcher says why.+(kernel 6.12 or later) a restricted app isn't started at all, and the launcher says why. Such a view has no X display either (no X socket in its private `/tmp`, no `DISPLAY`): X11+apps share one display and could watch or drive each other, so a restricted app must speak Wayland+(`PRIVACY.md`, "X11 apps").**No access to your files.** Applied by the launcher's child after it entered its scope and rightbefore `execve`, so a restriction set while the app runs applies at its next launch (Settingsdiff --git a/docs/LAYERS.md b/docs/LAYERS.mdindex 92a981b..0a0504b 100644--- a/docs/LAYERS.md+++ b/docs/LAYERS.md@@ -80,6 +80,11 @@ import { Layer, Overlay, LAYERS } from '@lordos/sdk';- Used today by: the shell's menus, the SDK's `MenuButton`, the «fill from Passwords» button(`AutofillButton`), Settings' pop-up buttons and Passwords' pop-up menus. Calendar, Contacts andReminders keep their own per-window popover host; the Terminal's preferences use an inline list.+- **The keyboard.** While anything shows in the `overlay`, `modal` or `system` layers (search, the+ launcher, sheets, system prompts), no Linux app (Wayland or X11) gets the keys: `runtime/index.js`+ counts each layer's children after every commit and `sdk/wayland.js` gives the compositor focus 0+ (0.8.3; `PRIVACY.md`, "X11 apps"). `popover` (menus, the clipboard and emoji panels, which paste into+ the app in front) keeps the app's keyboard.- **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.diff --git a/docs/PRIVACY.md b/docs/PRIVACY.mdindex bad8048..1210fd2 100644--- a/docs/PRIVACY.md+++ b/docs/PRIVACY.md@@ -556,6 +556,66 @@ package keeps its plain owner while a user `.lpk` with the same id does not reacprocess itself has no network at all. Certificate warnings that happened while Mail was closed areshown again on the next connection attempt (the account shows its error meanwhile).+## X11 apps (0.8.3)++X11 apps run through Xwayland (`WAYLAND.md`, "X11 apps (Xwayland)"). X11 was designed for programs+that trust each other, and LordOS doesn't pretend otherwise:++**What X11 apps can do to each other (inherent, not fixed).** All X11 apps of a session share one X+display. Any of them can read the others' windows (`XGetImage` on another app's window), their+window titles and properties, the X keyboard state while an X window has the keyboard (a keylogger+polling `XQueryKeymap` sees what is typed into xterm), and the X selections (any X client can ask+for the CLIPBOARD and PRIMARY while they are in X, and read the property they are pasted into).+The window manager refuses paste requests that come from a window of a client other than the+focused one, but that is only a hint: X11 doesn't authenticate who sends a request, so it is not a+boundary between X apps. **If two programs must not see each other, at least one of them should be+a Wayland app.**++**What LordOS controls: the border between X11 and the rest.**++- **Screen and windows.** Xwayland is a Wayland client like any other: it only ever gets the+ buffers of its own windows, never another app's surface or LordOS's screen (there is no+ screen-copy protocol). `xwd -root` fails (`BadMatch`: rootless Xwayland has no root picture) and+ the X window tree only holds X windows, so **Passwords, the keyring prompt and every other+ Wayland or LordOS window are invisible to X11 apps** (`xwayland-protected.png`).+- **Keyboard.** Xwayland receives keys only while one of its windows has the keyboard. Global X+ grabs and keyloggers inside X see nothing typed into a LordOS or Wayland window: with Passwords+ focused, `tests/xwayland/keysnoop.sh` sampled the X keyboard 958 times while a passphrase was typed+ and saw no key down (the same run with xterm focused saw them). Search, the app launcher, shell+ sheets and system prompts (keyring, permissions, the file chooser) also take the keyboard from+ any Linux app while they are open (they are in the overlay, modal and system layers;+ `runtime/index.js`, `sdk/wayland.js`) — this also fixed keys reaching a Wayland app behind the+ search panel. The compositor doesn't offer Xwayland's keyboard-grab protocol.+- **Clipboard.** What is copied in LordOS or a Wayland app enters X only while an X window has the+ keyboard, and leaves when the keyboard goes back (the window manager gives the selection up), so+ an X app in the background never reads it. What Passwords copies (marked sensitive) **never**+ enters X. In the other direction, an X app's copy is read once, when it is made, and becomes+ LordOS's.+- **Synthetic input.** Xwayland starts with XTEST disabled, so an X app can't type or click into+ another X app (e.g. a terminal) with synthetic events.+- **Xwayland itself** runs in `lordos-xwayland.scope` (not lord-server's), without network (its own+ empty network namespace) and with `no_new_privs`; it is started only by a connection to the+ session's X socket (mode 0600, no abstract socket, no TCP) and stopped 10 s after the last X app.++**Per-app identity.** An X11 app launched from LordOS is placed in its app scope+(`app-lordos-<desktop id>.scope`) before it runs, exactly like a Wayland app, so the per-app+firewall and the Monitor apply to it (tested: XTerm with "no internet" can't connect;+`xwayland-firewall.png`). Its window is grouped in the Dock by `WM_CLASS`.++**Restricted apps get no X display.** A Linux app with a device or "no files" restriction runs in+its own view (private `/tmp`, see `FIREWALL.md`), and LordOS doesn't put the X socket there and+removes `DISPLAY`: given the shared display above, a restricted X11 app could watch or drive the+other X apps. Such an app must speak Wayland (most GTK/Qt apps do); an X11-only app with one of+those restrictions doesn't open. Isolated `.lpk` apps never get X either (their seccomp filter+refuses new unix sockets, and `DISPLAY` is removed). *Not done:* a separate Xwayland per restricted+app, or "untrusted" X connections (the SECURITY extension), which would let such apps run with X+isolated from the rest; tracked for a later version.++| |+|---|+|  |+| From XTerm, with Passwords open behind it: `xwd -root` fails, the X window tree holds only XTerm, and the keylogger test run while typing into Passwords saw 0 keys |+## Root-owned app scopesThe session's cgroup subtree used to be delegated to the user (`chown`), so a Linux app without adiff --git a/docs/ROADMAP.md b/docs/ROADMAP.mdindex 1b02a65..005d823 100644--- a/docs/ROADMAP.md+++ b/docs/ROADMAP.md@@ -516,19 +516,23 @@ Details in `MAIL.md`. Tested on VM 123 against local Dovecot, Postfix and Radica`tryboot` (phase 3), Debian packages as system extensions and delta updates (phase 4), `/etc` andexecution hardening (phase 5). The classic edition stays as it is.-- [ ] **Xwayland** (X11 app compatibility). Today LordOS runs Wayland apps only, so programs that- speak only X11 don't start. Plan:- - start `Xwayland` on demand (rootless) when an X11 client connects, with its own `DISPLAY`- socket; the compositor (`server/src/wl/`) acts as the X window manager (XWM: map, stack,- focus, move and resize, titles and icons, transient/popup windows, our window frame);- - clipboard and drag and drop bridged between X11 and Wayland;- - HiDPI and fractional scaling for X11 windows, multi-monitor positions;- - the same per-app identity as Wayland apps (cgroup scope, firewall, Dock grouping), so X11 apps- get the per-app network and device restrictions too;- - security: X11 apps can read each other's input and windows by design; X11 clients are isolated- from Wayland apps and protected windows (Passwords) are never exposed to them; documented in+- [x] **Xwayland** (X11 app compatibility) — 0.8.3, see `WAYLAND.md` ("X11 apps (Xwayland)") and+ `PRIVACY.md` ("X11 apps"):+ - [x] `Xwayland` on demand (rootless), started by the first connection to the session's X socket+ and stopped 10 s after the last X app; our own X window manager in C (map, stacking, focus,+ move and resize, titles, `WM_CLASS` → `.desktop`, override-redirect menus and tooltips,+ fullscreen, minimize, close, our window frame and cursor);+ - [x] clipboard and primary selection bridged both ways (and `zwp_primary_selection_v1` for+ Wayland apps); drag and drop X11 ↔ Wayland: not yet (LordOS has no Wayland drag and drop yet);+ - [x] HiDPI policy (scale 1, scaled by the compositor) and positions across displays; not tested on+ a HiDPI display;+ - [x] the same per-app identity as Wayland apps (scope, firewall, Dock grouping); restricted apps+ get no X display;+ - [x] X11 apps never see Wayland apps, protected windows or keys typed into them; documented in`PRIVACY.md`;- - tests with real X11 apps (an xterm-style terminal, a Java/Swing app, a game) and screenshots.+ - [x] tests with real X11 apps (XTerm, xeyes, a Swing app, Neverball), CPU and GPU paths.+ - [ ] later: a separate or "untrusted" X display for restricted apps; X11 ↔ Wayland drag and drop;+ sharp X11 apps on HiDPI displays.- [ ] **Turn the "Classic" theme into a second full appearance** (Settings → Themes), for people coming from themost common desktop layout: a centered taskbar with a start menu, pinned and running apps, asystem tray with quick settings and a notification panel, snap layouts for windows, roundeddiff --git a/docs/VM-SETUP.md b/docs/VM-SETUP.mdindex 0c4a111..83b7831 100644--- a/docs/VM-SETUP.md+++ b/docs/VM-SETUP.md@@ -1247,3 +1247,26 @@ removed, so `diff -r` against the backup is empty). Sessions were the autologintests) restored from the backup, the Mail restriction in `firewall.json` removed, and the testdata deleted (`~/.config/lordos/mail`, `~/.local/share/lordos/mail`, the four apps'`appdata` folders, two files in `~/Documents`). Nothing in the network configuration was touched.++## Step 34 — 0.8.3: X11 apps with Xwayland (VM 118 `lordos-notes`, October 19)++See `WAYLAND.md` ("X11 apps (Xwayland)") and `PRIVACY.md` ("X11 apps"). Installed with+`--no-install-recommends`:++| Package | What for |+|---|---|+| `xwayland` 2:24.1.6 | X11 apps (the only one LordOS needs; it brings `xserver-common`, `x11-xkb-utils`) |+| `xterm`, `x11-apps` (xeyes, xwd), `x11-utils` (xprop, xwininfo, xev) | test apps and X inspection |+| `xclip`, `xinput`, `xdotool` | clipboard tests, the keyboard-snoop test (`tests/xwayland/keysnoop.sh`) and reading the X pointer (XTEST is off, so `xdotool` can't type) |+| `openjdk-21-jdk-headless`, `openjdk-21-jre` | the Swing test app (`~/xwl-tests/SwingTest.java`, a `.desktop` with `StartupWMClass=SwingTest`, removed after the tests) |+| `neverball` | an SDL game (`SDL_VIDEODRIVER=x11`) |++- Build: `make -C server` (no new build dependency: the primary-selection XML is in+ `wayland-protocols`), plus `make -C server build/clip-offers` for `tests/xwayland/selections.sh`.+- The GPU path was tested with a temporary `lordos.service.d` drop-in `Environment=LORD_GPU=1`+ (llvmpipe), removed afterwards.+- Input: a uinput tablet+keyboard (`~/uinput-xwl-118.py`, the same as the earlier steps' scripts)+ mapped to the whole desktop (2987×1067 on this VM's two displays).+- The installed LordOS was backed up to `~/xwayland-backup-20261019` and restored after the tests;+ `firewall.json` was restored too.+diff --git a/docs/WAYLAND.md b/docs/WAYLAND.mdindex 6efd2cf..acbec97 100644--- a/docs/WAYLAND.md+++ b/docs/WAYLAND.md@@ -1,10 +1,12 @@# Linux apps in LordOS (Wayland)lord-server is also a **Wayland compositor**: GTK, Qt and any other app that speaks Wayland open-as LordOS windows, inside the theme, next to the native apps. There's no X11, Weston, wlroots or-Mutter: only `libwayland-server` (it serializes the protocol; it's been in the dependency policy+as LordOS windows, inside the theme, next to the native apps. There's no X server of its own, Weston,+wlroots or Mutter: only `libwayland-server` (it serializes the protocol; it's been in the dependency policysince M1) and the code `wayland-scanner` generates from the `wayland-protocols` XML files. Thecompositor lives in `server/src/wl/wl.c`.+Apps that only speak X11 open through Xwayland, started on demand, with our own X window manager+(see "X11 apps (Xwayland)" below).## Screenshots (VM, real lord-server)@@ -32,6 +34,7 @@ compositor lives in `server/src/wl/wl.c`.| `wl_seat` | 9 | pointer (enter, leave, motion, buttons, wheel with `axis_source` and `axis_value120`; fine touchpad scrolling with `axis_source finger`, `axis_stop` and `axis_relative_direction` for natural scrolling), keyboard with LordOS's XKB keymap (`keyboard.c`), modifiers and repeat, and `wl_touch` if there's a touchscreen || `zwp_pointer_gestures_v1` | 3 | touchpad gestures: pinch (zoom in Chromium, GTK, Firefox), swipe and hold (`wl_input.c`, see `TRACKPAD.md`) || `wl_data_device_manager` | 3 | clipboard shared with LordOS's in both directions (see below) |+| `zwp_primary_selection_device_manager_v1` | 1 | primary selection: select to copy, middle click to paste (0.8.3, see "X11 apps") || `xdg_wm_base` | 6 | windows (`xdg_toplevel`: title, move, resize, maximize, minimize, close) and popup menus (`xdg_popup` with `xdg_positioner`: anchor, gravity, flip and slide within the screen) || `zxdg_decoration_manager_v1` | 1 | apps that use it (Qt, foot, Kitty, Alacritty) leave the frame to the theme || `wp_cursor_shape_manager_v1` | 1 | the app asks for the cursor by name (Chromium, GTK 4, Qt 6) and LordOS draws its own (`cursor.c`, see `WINDOWS.md`) |@@ -208,6 +211,125 @@ resizing (see `WINDOWS.md`).Tested in VM 118 with Chromium 155, Firefox ESR 153, Mousepad (GTK 3) and GNOME Calculator(GTK 4, libadwaita).+## X11 apps (Xwayland)++Apps that only speak X11 (xterm, Java/Swing, many games and older tools) open through **Xwayland**+(Debian's `xwayland` package), started only when one of them connects. They get the theme's frame,+their icon in the Dock, LordOS's cursor and the shared clipboard, and they run in their app's scope+like any other Linux app.++| | |+|---|---|+|  |  |+| XTerm opened from search: the theme's frame, its icon in the Dock (`StartupWMClass=XTerm`), the menu bar, and its process in `app-lordos-debian-xterm.scope` | XTerm's Ctrl+click menu: an override-redirect X window, drawn above the Dock |+|  |  |+| A Swing app (OpenJDK 21): pasted with Ctrl+V what a Wayland app copied | Its list, the pointer at the right place |+|  |  |+| Neverball with `SDL_VIDEODRIVER=x11` (OpenGL through Mesa) | Its "Fullscreen" option: `_NET_WM_STATE_FULLSCREEN`, presented by the compositor |+|  |  |+| The same on the GPU composition path (`LORD_GPU=1`) | XTerm restricted to no internet (Settings → Firewall): its `curl` is refused, the per-app rules apply to X11 apps |++### How it starts (`server/src/wl/xwayland.c`)++- At the start of a user session (not the login screen, not app mode), if `/usr/bin/Xwayland`+ exists, lord-server reserves a display: the lock file `/tmp/.X<n>-lock` and the socket+ `/tmp/.X11-unix/X<n>` with mode **0600** (only this user's programs can connect; no abstract+ socket, no TCP). It sets `DISPLAY=:<n>` (and `_JAVA_AWT_WM_NONREPARENTING=1`, see below) for the+ apps it starts. **Nothing else runs.**+- When the first X11 client connects, lord-server starts Xwayland with a fixed argument list:++ ```+ /usr/bin/Xwayland :<n> -rootless -listenfd 3 -wm 5 -nolisten tcp -extension XTEST+ ```++ fd 3 is the listening socket (Xwayland accepts that first connection), fd 4 its Wayland connection+ (`WAYLAND_SOCKET`, a socketpair, so the compositor knows which client is Xwayland) and fd 5 the+ window manager's connection. This is the fourth launcher exception (`AGENTS.md`): the binary must+ be a root-owned file nobody else can write; there are no arguments from JS or from anyone; the+ only trigger is a connection to the session's own X socket.+- Xwayland runs in its own scope (`lordos-xwayland.scope`, never lord-server's), in an empty network+ namespace inside a user namespace that maps only the user (it has no network at all), with+ `no_new_privs`, a minimal environment and its log in `~/.cache/lordos/xwayland.log`. **XTEST is+ off**: an X11 app can't type or click into another one with synthetic input.+- **Off when unused.** The window manager is an X client too, so Xwayland's own `-terminate` never+ fires: 10 s after the last X window closes, the window manager asks the X-Resource extension+ whether any other client is still connected (a clipboard tool without windows) and, if none,+ stops Xwayland. The socket stays in lord-server, so the next X11 app starts it again (about a+ second). Three failed starts in a row → X11 apps are refused for a minute (logged).++### The window manager (`server/src/wl/xwm.c`, `x11wire.c`)++Our own, in C: it speaks the X11 protocol itself (no libxcb or libX11, dependency policy), fully+asynchronously, so lord-server never waits on Xwayland while Xwayland waits on the compositor.++- **Windows.** It redirects the root's children (Composite, manual: rootless Xwayland then gives each+ top-level window a `wl_surface` and says which with `WL_SURFACE_ID`), takes SubstructureRedirect+ and maps the windows that ask. A normal window becomes a LordOS window (`linux#<surface>`, like+ Wayland apps) with its title (`_NET_WM_NAME` or `WM_NAME`, Latin-1 converted), and its app from+ `WM_CLASS`: the class, or the instance if only that names a `.desktop` (`StartupWMClass` or the+ desktop id), so the Dock groups it with its launcher icon. Motif "no decorations" (or a splash)+ gets no theme frame. Override-redirect windows and menus, tooltips, combo lists, notifications+ and drag icons are drawn above everything at the place X gave them.+- **Place, stacking and focus.** The X position of a window is its content's position on screen+ (updated as the theme moves it), so Xwayland routes the pointer right; the focused window is put+ on top of X's stack and a minimized one at the bottom (iconic). Focus uses `SetInputFocus` and+ `WM_TAKE_FOCUS` (ICCCM); an X app can't move the keyboard to another X app's window (that+ `FocusIn` is reverted); `_NET_ACTIVE_WINDOW` from an app is ignored (no focus stealing).+- **Requests.** Close (`WM_DELETE_WINDOW`, else `KillClient`), maximize and fullscreen+ (`_NET_WM_STATE`, also set before mapping), minimize (`WM_CHANGE_STATE`), and moves and resizes+ asked by apps that draw their own frame (`_NET_WM_MOVERESIZE`) go to the theme like a Wayland+ app's. A resize of the frame becomes `ConfigureWindow`; an app may change its own size, never its+ place.+- **Cursor.** The root window's cursor is LordOS's arrow (a Render ARGB cursor), so X apps that+ don't set one show ours; those that do (xterm's I-beam) show theirs, like Wayland apps.+- **Java.** AWT guesses the insets of a reparenting window manager; ours doesn't reparent, so+ `_JAVA_AWT_WM_NONREPARENTING=1` is set for the session's apps (without it Swing windows are blank).++### Clipboard and primary selection++Both ways, for **CLIPBOARD** and **PRIMARY** (select to copy, middle click to paste):++- **X11 → LordOS.** XFixes tells when an X app takes a selection; the window manager reads it once+ (`TARGETS`, then the best text — `UTF8_STRING`, `text/plain;charset=utf-8`, `STRING` — or+ `image/png`; `INCR` for large ones, up to 16 MB) and it becomes LordOS's: the Wayland apps, the+ Terminal and the history (with the X app's class as its source) see it.+- **LordOS → X11.** LordOS's selection is put in X **only while an X window has the keyboard** and+ only if it's newer than what an X app copied; when the keyboard goes to a LordOS or Wayland+ window, the window manager gives the selection up. Large pastes go in `INCR` chunks.+- **Secrets never go to X.** What Passwords (or a password field) copies is marked sensitive and is+ not offered to X11 apps at all: in X, the pasted text is written to a window property any X client+ can read.+- **Primary selection for Wayland apps** (`zwp_primary_selection_v1`, new in 0.8.3): what the app+ with the keyboard selects is kept and offered to the app that gets the keyboard next, and to X.+- **Offers are bound to their selection.** A `wl_data_offer` (and a primary offer) carries the+ generation it was made for and only gives data for that selection, and only to its client while+ it has the keyboard: an app can't keep an old offer to read later copies (`build/clip-offers`).+- **Drag and drop** between X11 and Wayland apps: not yet (LordOS has no Wayland drag and drop+ yet). Inside X (X app to X app) it's X's own protocol; not tested.++### HiDPI and displays++X11 apps work in logical pixels at scale 1: the X screen is the bounding box of the displays'+logical rectangles (Xwayland reads them from `xdg_output`), and on a display above 100 % the+compositor scales their buffers up (sharp text needs the app's own scaling, e.g. `GDK_SCALE`, Java's+`-Dsun.java2d.uiScale`). Tested at 100 % on two displays (2987×1067 logical); not tested on a HiDPI+display.++### Tests++- `build/xwm-test` (in `make -C server test`): request encoding, the setup reply, packet framing,+ sequence numbers, `WM_CLASS`, titles (UTF-8, Latin-1, invalid), Motif hints, size hints,+ `WM_HINTS`, `_NET_WM_MOVERESIZE`, text targets, the same-client check and the display choice.+- `tests/xwayland/selections.sh` (inside a session on a test VM, with `build/clip-offers`): X11 →+ Wayland for both selections, offers bound to their selection, and a Wayland copy not readable by+ X apps while no X window has the keyboard.+- `tests/xwayland/keysnoop.sh`: an X keylogger (polling the X keyboard state) sees the keys typed+ into an X window, and **none** of those typed into Passwords.+- On VM 118 (CPU path and `LORD_GPU=1` with llvmpipe): xeyes, XTerm, a Swing app (OpenJDK 21),+ Neverball with `SDL_VIDEODRIVER=x11` (windowed and fullscreen), menus, move and resize from the+ frame, close, the Dock icons, Xwayland stopping 10 s after the last app and starting again, the+ firewall restriction on XTerm, and the protected-window checks in `PRIVACY.md`.+## Pending- SVG app icons (most modern GTK/Qt apps only ship SVG).@@ -215,7 +337,6 @@ Tested in VM 118 with Chromium 155, Firefox ESR 153, Mousepad (GTK 3) and GNOME- Already done (see `GPU.md`): `linux-dmabuf` v4, GPU composition (Mesa, optional), directfullscreen scanout, `wp_presentation`, `wp_viewporter`, `relative-pointer`,`pointer-constraints`, real fullscreen (❖Esc exits) and app cursors (image or hidden).-- Drag and drop, primary selection (middle click), `text-input` (LordOS input methods inside- Wayland apps), activation (`xdg-activation`). (Fractional scale and several outputs: done, see- `DISPLAYS.md`.)-- Xwayland, for apps that only speak X11.+- Drag and drop, `text-input` (LordOS input methods inside Wayland apps), activation+ (`xdg-activation`). (Fractional scale and several outputs: done, see `DISPLAYS.md`; primary+ selection and Xwayland: done in 0.8.3, above.)diff --git a/docs/xwayland-firewall.png b/docs/xwayland-firewall.pngnew file mode 100644index 0000000..b8a6a57Binary files /dev/null and b/docs/xwayland-firewall.png differdiff --git a/docs/xwayland-gpu.png b/docs/xwayland-gpu.pngnew file mode 100644index 0000000..2a8c896Binary files /dev/null and b/docs/xwayland-gpu.png differdiff --git a/docs/xwayland-neverball-fullscreen.png b/docs/xwayland-neverball-fullscreen.pngnew file mode 100644index 0000000..14619acBinary files /dev/null and b/docs/xwayland-neverball-fullscreen.png differdiff --git a/docs/xwayland-neverball.png b/docs/xwayland-neverball.pngnew file mode 100644index 0000000..e241864Binary files /dev/null and b/docs/xwayland-neverball.png differdiff --git a/docs/xwayland-protected.png b/docs/xwayland-protected.pngnew file mode 100644index 0000000..3bf719aBinary files /dev/null and b/docs/xwayland-protected.png differdiff --git a/docs/xwayland-swing-clipboard.png b/docs/xwayland-swing-clipboard.pngnew file mode 100644index 0000000..c6c3db5Binary files /dev/null and b/docs/xwayland-swing-clipboard.png differdiff --git a/docs/xwayland-swing-combo.png b/docs/xwayland-swing-combo.pngnew file mode 100644index 0000000..499c794Binary files /dev/null and b/docs/xwayland-swing-combo.png differdiff --git a/docs/xwayland-xterm-menu.png b/docs/xwayland-xterm-menu.pngnew file mode 100644index 0000000..117904cBinary files /dev/null and b/docs/xwayland-xterm-menu.png differdiff --git a/docs/xwayland-xterm.png b/docs/xwayland-xterm.pngnew file mode 100644index 0000000..f77bee3Binary files /dev/null and b/docs/xwayland-xterm.png differdiff --git a/server/src/wl/xwm.c b/server/src/wl/xwm.cindex 94ddab9..42b2ab1 100644--- a/server/src/wl/xwm.c+++ b/server/src/wl/xwm.c@@ -6,7 +6,9 @@* FIFO of callbacks.** What it does:- * - takes SubstructureRedirect on the root and maps the windows that ask (MapRequest); reads their+ * - redirects the root's children (Composite, manual: rootless Xwayland only gives redirected+ * windows a wl_surface), takes SubstructureRedirect on the root and maps the windows that ask+ * (MapRequest); reads their* title, class (WM_CLASS → the app's .desktop), protocols, hints, Motif decorations, window type* and transient parent; WL_SURFACE_ID tells which wl_surface shows each one;* - keeps every X window where LordOS shows it (the X position is the content's position on@@ -18,8 +20,12 @@* client is reverted);* - the clipboard: CLIPBOARD and PRIMARY both ways (XFixes tells when an X app copies; the copy is* read once and becomes LordOS's; LordOS's is offered to X only while an X window has the- * keyboard, so a background X app can't read what was copied elsewhere);- * - the root window's cursor is LordOS's arrow (Render cursor).+ * keyboard, so a background X app can't read what was copied elsewhere, and a secret copied in+ * Passwords never is);+ * - the root window's cursor is LordOS's arrow (Render cursor);+ * - 10 s after the last X window closes, if X-Resource shows no other client, Xwayland stops.+ * X11 apps on one display can always see each other; what this guards is the border with Wayland+ * apps and LordOS (docs/PRIVACY.md, "X11 apps").* See docs/WAYLAND.md, "X11 apps (Xwayland)". */#include "xwm.h"#include "x11wire.h"@@ -580,7 +586,10 @@ static void sel_request(const uint8_t *p) {target = x11_get32(p + 20), prop = x11_get32(p + 24);int k = sel_index(selection);if (!prop) prop = target; /* obsolete clients */- /* only the X app the user is in (the requestor window is that client's) may read it */+ /* LordOS's selection is in X only while an X window has the keyboard (clip_sync). Asking from+ * a window of the focused client is a hint, not a boundary: the requestor id isn't+ * authenticated in X11 and X apps on one display can read each other's selections anyway+ * (docs/PRIVACY.md, "X11 apps") */if (k < 0 || owner != X.wmwin || !X.sel[k].owned || !X.focus || !same_client(requestor, X.focus->id) || !lord_has(k)) {notify_requestor(time_, requestor, selection, target, 0);return;@@ -1048,7 +1057,7 @@ static int on_fd(int fd, uint32_t mask, void *data) {int xwm_start(int fd, struct wl_event_loop *loop) {xwm_stop();- X.debug = 1; /* XWMDEBUG-TEMP */+ X.debug = getenv("LORD_XWM_DEBUG") != NULL; /* every window, copy and X error in the session log */X.fd = fd;X.loop = loop;X.ev = wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE, on_fd, NULL);diff --git a/server/tests/xwayland/keysnoop.sh b/server/tests/xwayland/keysnoop.shnew file mode 100755index 0000000..2923686--- /dev/null+++ b/server/tests/xwayland/keysnoop.sh@@ -0,0 +1,14 @@+#!/bin/sh+# keysnoop.sh SECONDS — what an X11 keylogger sees: polls the X keyboard's key state (the classic+# XQueryKeymap trick, through `xinput query-state`) and prints how many samples had a key down.+# Run it while typing into a Wayland window (Passwords): it must print 0. Run it while typing into+# an X11 window: it sees the keys (X11 apps share one display). Needs xinput. docs/PRIVACY.md.+secs=${1:-8}+dev=$(xinput list --id-only "xwayland-keyboard:6" 2>/dev/null || xinput list --short | sed -n 's/.*xwayland-keyboard[^=]*id=\([0-9]*\).*/\1/p' | head -1)+[ -n "$dev" ] || { echo "no Xwayland keyboard device"; exit 2; }+end=$(( $(date +%s) + secs )); down=0; samples=0+while [ "$(date +%s)" -lt "$end" ]; do+ samples=$((samples + 1))+ xinput query-state "$dev" 2>/dev/null | grep -q '=down' && down=$((down + 1))+done+echo "samples=$samples with-a-key-down=$down"diff --git a/server/tests/xwayland/selections.sh b/server/tests/xwayland/selections.shindex eb3b328..db2184b 100755--- a/server/tests/xwayland/selections.sh+++ b/server/tests/xwayland/selections.sh@@ -7,8 +7,8 @@## 1. An X11 app's copy (CLIPBOARD and PRIMARY) reaches Wayland apps.# 2. Offers are bound to their selection: a Wayland app can't read later copies through an old offer.-# 3. A Wayland copy is not readable by a background X11 app (no X window has the keyboard), nor by-# another X11 client while an X window has it (only the focused window's client may paste).+# 3. A Wayland copy is not readable by an X11 app while no X window has the keyboard; while one has+# it, a request from another client's window is refused (a hint only: X11 apps share a display).cd "$(dirname "$0")/../.." || exit 1fails=0ok() { printf ' ok %s\n' "$1"; }@@ -39,7 +39,8 @@ got=$(timeout 3 xclip -o -selection clipboard 2>/dev/null)setsid -f xterm -title selections-test >/dev/null 2>&1 </dev/nullsleep 3got=$(timeout 3 xclip -o -selection clipboard 2>/dev/null)-[ "$got" != "wayland secret-ish" ] && ok "another X11 client can't read it while xterm has the keyboard" || bad "another X11 client read it"+# (best effort, not a boundary: X11 doesn't authenticate the requestor; see docs/PRIVACY.md)+[ "$got" != "wayland secret-ish" ] && ok "a paste request from another client's window is refused (best effort)" || bad "another client's window got it"pkill -f "xterm -title selections-test"[ $fails -eq 0 ] && echo "selections: PASSED" || echo "selections: $fails FAILED"