xorg: list the server's windows, and cut a window's screenshot from the screen (hq issue 344)

A reminder window that showed as transparent and empty could not be looked at: the window manager's
list leaves dialogs out and says nothing a compositor goes by, and xwd -id refused a window of a
32-bit visual with BadColor (X_QueryColors). xorg_windows answers every window with its class, and
on request its depth, type, state, role and own opacity; a window's screenshot is now cut from the
whole screen as the compositor shows it, and inline answers the image for a session that cannot
read the machine's files. Declares xorg-xwininfo, which both now use.
This commit is contained in:
2026-10-09 12:05:41 +02:00
parent 7339ce8556
commit 79f5f1e8ed
8 changed files with 494 additions and 13 deletions
+16 -3
View File
@@ -9,7 +9,7 @@ The X display server as a module (novox/hq ADR 0208, research 026, to-be 42 phas
- **Gated by the capability `seat`**, which the host reports for a machine with a graphics device
and a connected display. See *Blockers* for why not `graphical-session`.
- **Packages:** `xorg-server`, `xorg-xinit`, `xorg-xrandr`, `xorg-xset`, `xorg-xrdb`, `xorg-xinput`,
`xorg-setxkbmap`, `xorg-xwd` and `autorandr`. The GPU's driver is not here. It follows the machine,
`xorg-setxkbmap`, `xorg-xwd`, `xorg-xwininfo` and `autorandr`. The GPU's driver is not here. It follows the machine,
so it belongs to that machine model's hardware module.
## What it owns
@@ -71,7 +71,8 @@ which is a cpp directive error under plain `xrdb -merge` but is skipped here.
| `xorg_input_devices` | r | the input devices, and each pointer's libinput settings |
| `xorg_input_set` | a | tap, tap drag, natural scroll, disable while typing, left handed, middle emulation, enabled, acceleration, by device id or name |
| `xorg_keyboard` | r/a | the XKB map; set layout, variant, model, options |
| `xorg_screenshot` | d | a PNG of the screen, one output or one window, inside the home (default `~/Pictures/Screenshots/`) |
| `xorg_screenshot` | d | a PNG of the screen, one output or one window, inside the home (default `~/Pictures/Screenshots/`); with `inline`, the PNG in the answer as base64 (at most 4 MiB) |
| `xorg_windows` | r | the windows as the X server knows them, managed or not: id, name, instance and class, size and place; with a class or name filter (or `detail`), each one's depth (`argb`), visual, map state, override-redirect, types, states, role and own opacity |
| `xorg_x_log` | r | the X server's log for the running session: version, start, errors (and warnings) |
All answers are structured. Each tool that changes the running server says how long the change lasts.
@@ -90,7 +91,19 @@ The bus it hands on is the user manager's (`unix:path=/run/user/<uid>/bus`). Wit
answers `{"error": "no-graphical-session", "reason": …, "looked": […]}`.
The screenshot needs no screenshot program. `xwd` dumps the screen, and the module turns the dump
into a PNG itself.
into a PNG itself. **A window is cut from the dump of the whole screen** at the place `xwininfo` gives,
never dumped by its id: `xwd -id` asks the server for the window's colormap entries, which a window of
a 32-bit (alpha) visual refused with `BadColor (X_QueryColors)` on a workstation (2026-10-09), and the
cut shows the window as the compositor shows it, which is what a question about a window that looks
wrong needs. A window under another one shows what covers it. `inline` answers the image itself, for a
session that cannot read the machine's files.
`xorg_windows` exists because a window manager lists only the windows it manages, and says nothing a
compositor goes by. A window of depth 32 has an alpha channel: the compositor blends it with what is
behind it, so one whose program drew nothing looks transparent rather than black. Its details take
two commands per window (`xwininfo -all`, and `xprop` for the role and the window's own opacity), so
they are read for at most 40 windows. `xprop` is the `picom` module's package; without it the role and
opacity are left out.
## What it improves