Repository navigation
Linux: cursor overlay parity with macOS and Windows on GNOME Wayland, Xwayland windows and X11 #695
sungyongcho
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
On Linux the cursor overlay draws far less than it does on macOS and Windows, and on GNOME Wayland it draws nothing. I'd like to close that gap in every Linux environment the adapter supports: native Wayland windows, Xwayland windows on a Wayland session, and X11 sessions. The goal is the same overlay on all three: the cursor travels along core's
CursorMotionpath, the click ripple and element outline play, the label and--image/--pointer-imageshow, and a typing caret followstype,set-valueandpress.Native Wayland is the part that needs a design decision. A Wayland client cannot draw above other windows or learn where any window sits, so the proposal adds a GNOME Shell extension that does both. All five steps of the plan below are implemented, and their pull requests are open so the approach can be judged on real code. I'd like agreement on the approach, the extension above all, before any of them merges.
Current behavior
Measured with agent-desktop 1.3.1 on Ubuntu 26.04.1, GNOME Shell 50.1. The X11 column comes from
crates/linux/src/system/overlay/.cursor-overlay enablerendered: false, nothing drawnrendered: false, nothing drawnrendered: true--image,--pointer-imagecustom cursor images on X11list-windowspositionx: 0, y: 0for every windowWhy native Wayland needs a GNOME Shell extension
org.gnome.Shell.Introspect.GetWindowsanswersAccessDeniedto an ordinary session-bus client, and no Wayland protocol GNOME implements lets a client place a surface above other windows. Code running inside gnome-shell can do both:Meta.Window.get_frame_rect()andget_buffer_rect()give each window's place, and an actor onMain.layoutManager.uiGroupdraws above every window.The extension,
agent-desktop@agent-browser.dev, lives incrates/linux/gnome-shell-extension/. The adapter talks to it on the session bus through a versioned protocol it checks on every call, so a CLI and an extension from different releases fail closed withrendered: falseinstead of drawing in the wrong place.CursorMotionat 60 Hz and sends the frames; the extension plays them on the compositor clock and answers a travel only when the cursor arrives, so the action dispatches with the cursor on its target, as on macOS and Windows. Withorg.gnome.desktop.interface enable-animationsoff, the cursor jumps to each target.GetCharacterExtentsat the caret offset in screen coordinates, then in window coordinates, and moves the caret's offset from the node's own rectangle in that same coordinate type onto the node's screen rectangle. Chromium's window coordinates for characters disagree with its own extents, and GTK 4 text views answer window coordinates only, so both read correctly this way. A GTK 4 entry reports no character positions at all and keeps the element outline instead.press. AT-SPI has no call that names the focused node. The adapter searches eachACTIVEframe throughorg.a11y.atspi.Collection(GTK 3, Chromium) and walks theSHOWINGnodes where Collection is missing (GTK 4). One focused caret read took 14 to 22 ms on GTK 3 and 30 to 44 ms on GTK 4, inside core's 150 ms read.Xwayland windows
On a Wayland session the extension draws on the shell stage, above Xwayland windows as well as native ones, but an Xwayland toolkit reports X11 coordinates. With a fractional monitor scale Xwayland scales its clients, so at 125% every position a GTK 3 or Chromium window reports is twice its place on the stage, with or without
xwayland-native-scaling. This is the same kind of mismatch #464 reports on X11.The extension also reports each Xwayland window's frame through
Meta.Window.stage_to_protocol_rect. The adapter maps every X11 rectangle of that process onto the stage by the two readings of the frame, so an untitled popup maps the same way as its main window. A process with a native Wayland window, or whose windows disagree, is not mapped. With the map,list-windows,snapshot --include-bounds,get, the overlay's travel and the caret land within 1 px of the pixels at 100% and 125% for GTK 3 and Chrome running under X11.X11 sessions
The X11 overlay placed a fixed arrow window at each destination. Step 5 replaces it with a renderer process that plays the same requests the extension plays, as the macOS and Windows renderers do.
locateandupdaterequests as one JSON line per connection on a 0700 Unix socket under$XDG_RUNTIME_DIR/agent-desktop, and answers a travel only when the cursor arrives.ab_glyphin the semibold sans-serif fontfc-matchnames. Without a compositing manager, each part is drawn solid and cut to its opaque pixels.screenshotconceals the cursors while it captures, with conceals counted as in the extension. The renderer exits 30 s after its last cursor goes.#464 (element bounds at 200% scale) still affects where all of it lands on a scaled X11 screen and should be settled alongside.
Plan
Each pull request is one logical change and passes the gates on its own:
list-windows,snapshot --include-boundsandget.screenshot.presscaret follow for native Wayland windows. The caret path branches on the display path, so X11 sessions refuse with their own message until step 5 fills it in.list-windows,snapshotandgetat fractional scales, and with them the overlay and the typing caret.All five steps are implemented and verified, with their probes recorded in
probes/linux/FINDINGS.md.Verification so far
Steps 1 to 3 were driven with the built CLI against GTK 3, GTK 4 and Chromium in a headless GNOME 50 Wayland shell and in a
gnome-shell --devkitshell. Every effect was checked by independent observation: cursor actor state read throughorg.gnome.Shell.Eval,UpdateCursorrequests captured withdbus-monitor, and screen crops. For example, aftertype, the caret sat immediately after the typed text in every crop, andpress End,Left,Left,Homemoved it to each new insertion point. Step 4 was checked the same way at monitor scales 1 and 1.25 with Xwayland enabled. Step 5 was driven on Xvfb with and withoutxcompmgr, and under openbox with a GTK 3 entry: positions read withxwininfo, pixels from root grabs. Aftertype "hello world"the caret sat right of the last glyph, andpress Homeandpress Endmoved it to each end. The rows are L43-1 to L43-11 and L44-1 to L44-4 inprobes/linux/FINDINGS.md. fmt, clippy with-D warnings, the source-rule and architecture checks, and every test target on the Linux package set pass; the release CLI is 7.36 MiB.Questions for maintainers
gnome-extensions packandgnome-extensions install, and GNOME loads it at the next login. A packed zip attached to each release would remove the clone step.ListWindowsreturns the process id, title and rectangles of every window. I can replace it before merge with a call that takes a process id, title and size and returns only the matching window, so a caller learns nothing about windows it cannot already name. Should the extension also restrict callers?ab_glyph0.2.32, with default features off, to rasterize the label, and one entry inLISTENER_ALLOWLISTofscripts/check_architecture.pyfor the renderer's socket listener. Are both acceptable?XDG_DATA_HOMEthe right way to cover steps 1 to 4, with step 5 covered on its Xvfb tier?Pull requests
The pull requests for steps 1 to 5 are stacked. Each one contains the commits before it, so review them in order:
presscaret followAll reactions