Expand description
Wayland cursor shape to PNG resolution and the cursor delivery worker.
Wayland cursor shape resolution: converts a CursorImageStatus into a PNG image buffer
for the cursor sink. Uses xcursor to load the system cursor theme and render the
appropriate frame at the current scale.
Structs§
- Capped
Sprite 🔒 - A cursor sprite encoded at its delivered size: the straight-alpha PNG, the factor the
source was scaled by, and the payload’s dimensions. Hotspots are per-job rather than a
property of the pixels, so they are scaled against
scaleinstead of being stored here. - Cursor
- The loaded XCursor theme, held for the whole capture so cursor lookups stay cheap.
Enums§
- Cursor
Job - One unit of cursor-callback work handed from the calloop thread to the
wl-cursorworker. The calloop resolves everything renderer/surface-affine (SHM copies, dmabuf readbacks, hotspots); the worker does the PNG encode, the cache, and the call into the sink so none of that latency lands on the input/render thread. One channel keeps cursor updates ordered with sink (re)registration.
Constants§
- MAX_
SPRITE_ 🔒SIDE - Longest side of a cursor surface still read: an application’s own pointer can be well past what is delivered (the cap downscales it), but a surface this large is not a cursor at all and its copy is skipped.
- SPRITE_
CACHE_ 🔒MAX - Sprites retained before arbitrary eviction; an evicted sprite re-encodes on next appearance.
Functions§
- cap_
and_ 🔒encode - Apply the size cap to a premultiplied sprite and encode it as a straight-alpha PNG.
- capped_
job 🔒 - Cache wrapper for sprite jobs, keyed by
(sprite hash, cap)so a repeat of a sprite already delivered under the same cap is a plain clone of its PNG; a miss decodes the sprite, caps it, and encodes it once. Keying on the cap keeps a liveSetSizeCapfrom serving stale sizes. - decode_
gles_ 🔒cursor - Read a dmabuf sprite’s RGBA readback (stride recovered from the mapping length) into a premultiplied RGBA image.
- decode_
shm_ 🔒cursor - Read a wl_shm BGRA/XRGB sprite sub-image into a premultiplied RGBA image, the form
cap_and_encodemust resize before it unpremultiplies. Stride/offset are clamped non-negative with checked arithmetic so a garbage descriptor skips pixels instead of panicking; a sprite pastMAX_SPRITE_SIDEis ignored. - frame 🔒
- Pick which animation frame to show for the elapsed time, so animated cursors (a spinner, a progress ring) actually advance instead of freezing on frame zero; it maps the time onto the frames by cycling their cumulative delays.
- load_
icon 🔒 - Parse the named icon from the theme’s cursor file into its frames.
- nearest_
images 🔒 - All frames of the theme variant whose pixel size is closest to
size. XCursor files bundle the same cursor at several sizes, and choosing the nearest one avoids scaling a mismatched bitmap into a blurry or aliased cursor. - scaled_
hotspot 🔒 - Scale a source hotspot onto a delivered sprite. Consumers treat the hotspot as an offset INTO the bitmap, so the rounded coordinate is clamped to the payload rather than allowed to land one pixel past its right or bottom edge.
- spawn_
cursor_ worker - Spawn the cursor delivery worker; returns its job channel. The worker owns its own
theme handle, the PNG cache, and the sink until one replaces or withdraws it (like the
compositor thread itself);
SHUTDOWNgates every call into it.