AtlatestRepositorysigil-ui

sigil-ui / tree / docswayland-cursors.md

Read it rendered

1# Wayland cursors
2
3The Wayland window owns cursor protocol objects and the latest pointer-enter
4serial. Requests never dispatch or create another display connection. Desired
5state survives pointer leave/re-entry; updates outside pointer focus are stored
6for the next entry. A subsurface request affects the entire shared connection.
7Embedding applications must route requests from their active view and reset
8the cursor when the pointer moves over chrome.
9
10Cursor configuration is opt-in. Until the first configure, name or image
11request, pointer entry keeps the existing compositor-default shape behavior;
12it does not load a theme or choose a client-side cursor size.
14```scheme
15(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```
21Theme names contain at most 255 UTF-8 bytes and no NUL. Explicit logical size is
221..128. An explicit size without a theme uses `XCURSOR_THEME` or default.
23Omitting the size or using 0 reads a valid
24`XCURSOR_SIZE` in 1..128, otherwise 24. Desktop preference selection belongs to the
25application. Naming a theme or a positive size marks the configuration explicit.
26Calling configure with both arguments omitted clears that preference again.
27Its library fallback then uses the default theme and the environment-selected
28size; mapped names continue to prefer the compositor.
29libwayland-cursor honors `XCURSOR_PATH` and its standard combined theme,
30inheritance, default-theme and builtin fallback. Its public API cannot identify
31which source supplied an image; backend `theme` includes builtin images.
32It is loaded optionally by soname;
33`SIGIL_UI_LIBWAYLAND_CURSOR` selects an explicit library path, like the existing
34Wayland/XKB library overrides. A window still opens when this library is absent.
36Named requests use CSS cursor names and conventional aliases such as left_ptr,
37hand2 and xterm. Selection follows this order:
391. After explicit theme or size configuration, try the configured library
40 loader, then the name's mapped compositor shape if the protocol is bound.
412. With a name alone, prefer its mapped compositor shape. The compositor
42 supplies the user's desktop theme. If the protocol is absent or the name
43 has no shape mapping, try the library's default theme and standard fallbacks.
443. If neither path supplies the cursor, return false. Unmapped names reach the
45 loader unchanged and are never replaced with the compositor's default shape.
47No separate decoder or builtin data is used. A missing optional library still
48permits mapped compositor shapes. Image requests keep their copied-image path,
49and `none` explicitly hides the cursor. On a miss,
50`wayland-cursor-backend` reports unavailable. Missing optional support emits no
51startup warning. A deferred request outside pointer focus returns true and
52reports unavailable until entry. Theme animation currently uses its first image.
54Theme images reload when the output scale changes. Their physical size is
55requested at logical size times output scale. If an image's dimensions do not
56divide that scale, it is presented at buffer scale 1 to avoid a Wayland protocol
57error; such a theme may appear larger. Theme decoding/allocation belongs to
58libwayland-cursor and is separate from the copied-image bounds below.
60`wayland-set-cursor-image!` accepts premultiplied native ARGB8888 bytes, width
61and height, with optional stride, hotspot-x, hotspot-y and scale. Stride defaults
62to width times 4. Dimensions are 1..512, stride is at most 2048 bytes, and scale
63is 1..8 and must divide both dimensions. The hotspot is in device pixels and
64must be strictly inside the image. The supplied bytevector must contain all
65stride times height bytes. At most 1 MiB is copied; later caller mutation is safe.
66Two reusable SHM buffers are retained. Busy buffers are never overwritten or
67re-attached, including unchanged configuration, scale updates and re-entry;
68if both are busy, only the latest pending pixel copy is kept and submitted
69after a release. Replacing desired state discards its old pending copy. Closing releases all cursor
70images, theme, surface and optional library ownership.
72`wayland-cursor-backend` observes unavailable, theme, shape, image or hidden
73without dispatching. The corresponding native operations are declared in
74native/wayland-bridge.h and reject calls from the wrong connection thread.
76`scripts/test-wayland-cursor-native.sgl` drives the native serial/ownership and
77validation controls. The live Wayland suite uses owned Xcursor files from
78`scripts/make-cursor-fixture.sgl`, captures the actual compositor cursor with
79grim, and checks theme/custom-image/hidden/re-entry behavior at scales 1/2.
80It also exercises compositor-shape fallback with the optional library absent,
81three custom-image updates without dispatch, and custom-image re-entry.
82The native gate reproduces a queued old release between unchanged
83configuration and replacement, and verifies that an application making no
84cursor call keeps the old default with the optional library available.
85It also controls shape-bound/unbound, explicit theme/size, unmapped-name and
86loader-miss branches. The live suite checks explicit images with shape support
87bound, inherited default-theme images without shape support, and an unmapped
88owned cursor with exact captured pixels.
89The existing test/wayland/run prepares these fixtures; custom runners supply
90`SIGIL_UI_TEST_CURSOR_ROOT`. Tests do not read or change an installed theme.