AtlatestRepositorysigil-ui
1
# Wayland cursors3
The Wayland window owns cursor protocol objects and the latest pointer-enter4
serial. Requests never dispatch or create another display connection. Desired5
state survives pointer leave/re-entry; updates outside pointer focus are stored6
for the next entry. A subsurface request affects the entire shared connection.7
Embedding applications must route requests from their active view and reset8
the cursor when the pointer moves over chrome.10
Cursor configuration is opt-in. Until the first configure, name or image11
request, pointer entry keeps the existing compositor-default shape behavior;12
it does not load a theme or choose a client-side cursor size.14
```scheme15
(wayland-cursor-configure! surface theme: "Adwaita" size: 24)16
(wayland-set-cursor! surface "pointer")17
(wayland-set-cursor! surface "text")18
(wayland-set-cursor! surface "none")19
```21
Theme names contain at most 255 UTF-8 bytes and no NUL. Explicit logical size is22
1..128. An explicit size without a theme uses `XCURSOR_THEME` or default.23
Omitting the size or using 0 reads a valid24
`XCURSOR_SIZE` in 1..128, otherwise 24. Desktop preference selection belongs to the25
application. Naming a theme or a positive size marks the configuration explicit.26
Calling configure with both arguments omitted clears that preference again.27
Its library fallback then uses the default theme and the environment-selected28
size; mapped names continue to prefer the compositor.29
libwayland-cursor honors `XCURSOR_PATH` and its standard combined theme,30
inheritance, default-theme and builtin fallback. Its public API cannot identify31
which source supplied an image; backend `theme` includes builtin images.32
It is loaded optionally by soname;33
`SIGIL_UI_LIBWAYLAND_CURSOR` selects an explicit library path, like the existing34
Wayland/XKB library overrides. A window still opens when this library is absent.36
Named requests use CSS cursor names and conventional aliases such as left_ptr,37
hand2 and xterm. Selection follows this order:39
1. After explicit theme or size configuration, try the configured library40
loader, then the name's mapped compositor shape if the protocol is bound.41
2. With a name alone, prefer its mapped compositor shape. The compositor42
supplies the user's desktop theme. If the protocol is absent or the name43
has no shape mapping, try the library's default theme and standard fallbacks.44
3. If neither path supplies the cursor, return false. Unmapped names reach the45
loader unchanged and are never replaced with the compositor's default shape.47
No separate decoder or builtin data is used. A missing optional library still48
permits mapped compositor shapes. Image requests keep their copied-image path,49
and `none` explicitly hides the cursor. On a miss,50
`wayland-cursor-backend` reports unavailable. Missing optional support emits no51
startup warning. A deferred request outside pointer focus returns true and52
reports unavailable until entry. Theme animation currently uses its first image.54
Theme images reload when the output scale changes. Their physical size is55
requested at logical size times output scale. If an image's dimensions do not56
divide that scale, it is presented at buffer scale 1 to avoid a Wayland protocol57
error; such a theme may appear larger. Theme decoding/allocation belongs to58
libwayland-cursor and is separate from the copied-image bounds below.60
`wayland-set-cursor-image!` accepts premultiplied native ARGB8888 bytes, width61
and height, with optional stride, hotspot-x, hotspot-y and scale. Stride defaults62
to width times 4. Dimensions are 1..512, stride is at most 2048 bytes, and scale63
is 1..8 and must divide both dimensions. The hotspot is in device pixels and64
must be strictly inside the image. The supplied bytevector must contain all65
stride times height bytes. At most 1 MiB is copied; later caller mutation is safe.66
Two reusable SHM buffers are retained. Busy buffers are never overwritten or67
re-attached, including unchanged configuration, scale updates and re-entry;68
if both are busy, only the latest pending pixel copy is kept and submitted69
after a release. Replacing desired state discards its old pending copy. Closing releases all cursor70
images, theme, surface and optional library ownership.72
`wayland-cursor-backend` observes unavailable, theme, shape, image or hidden73
without dispatching. The corresponding native operations are declared in74
native/wayland-bridge.h and reject calls from the wrong connection thread.76
`scripts/test-wayland-cursor-native.sgl` drives the native serial/ownership and77
validation controls. The live Wayland suite uses owned Xcursor files from78
`scripts/make-cursor-fixture.sgl`, captures the actual compositor cursor with79
grim, and checks theme/custom-image/hidden/re-entry behavior at scales 1/2.80
It also exercises compositor-shape fallback with the optional library absent,81
three custom-image updates without dispatch, and custom-image re-entry.82
The native gate reproduces a queued old release between unchanged83
configuration and replacement, and verifies that an application making no84
cursor call keeps the old default with the optional library available.85
It also controls shape-bound/unbound, explicit theme/size, unmapped-name and86
loader-miss branches. The live suite checks explicit images with shape support87
bound, inherited default-theme images without shape support, and an unmapped88
owned cursor with exact captured pixels.89
The existing test/wayland/run prepares these fixtures; custom runners supply90
`SIGIL_UI_TEST_CURSOR_ROOT`. Tests do not read or change an installed theme.