srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/core/src/window.rs
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2024-06-01 11:15:00 +0200
committersrdusr <[email protected]>2024-06-01 11:15:00 +0200
commit20cdd47b39f09aa19317d9d29fef6511b98c1233 (patch)
treee369fb583a66867cf13ddb2ee0ca782ac98014c3 /crates/core/src/window.rs
parentae056d17d137463b70f34862b9e33a9813c4b381 (diff)
downloadsrdwm-20cdd47b39f09aa19317d9d29fef6511b98c1233.tar.gz
srdwm-20cdd47b39f09aa19317d9d29fef6511b98c1233.zip
cursor: load the real XCursor theme arrow instead of always drawing the built-in bitmap
The compositor's own pointer - over decorations and the desktop, and as the fallback for any named shape with no dedicated art - was always the hand-rasterized 24px ARROW bitmap, regardless of what theme the rest of the session was using. Confirmed live (by the AGS peer session) that this machine's actual GTK cursor theme is Sweet-cursors at size 24 (both gtk-3.0 and gtk-4.0 settings.ini, and gsettings, agree), installed and present, but nothing read it - XCURSOR_THEME/XCURSOR_SIZE aren't set on this work either, so even naive env-based theme loading would have found nothing. load_theme_arrow (cursor.rs) now resolves a theme name and size -- XCURSOR_THEME/XCURSOR_SIZE first, falling back to GTK's own gtk-cursor-theme-name/-size out of settings.ini, since that's what's actually authoritative in practice here - and loads left_ptr via the `xcursor` crate (the same one anvil and other smithay compositors use), picking whichever nominal size the theme ships is closest to the target. XCursor pixel data comes back as straight RGBA off disk; only the channel order needs converting to the BGRA every other buffer in this file uses for Fourcc::Argb8888 (see arrow_bitmap's own byte order) - the data is already premultiplied alpha per the file format spec, same as everything else built here, so no premultiplication step. Falls back to the existing built-in bitmap arrow on any failure (theme/icon missing, corrupt file, a pixel count that doesn't match the declared dimensions) - same "always present beats prettier but sometimes absent" reasoning the built-in arrow's own doc comment already gave for not doing this at all, kept intact as the fallback rather than replaced. The built-in arrow's hotspot was implicitly (0, 0) - its tip, baked into where render_elements positioned it. A real theme's hotspot is data (CursorBuffers::arrow_hotspot), not necessarily the bitmap's corner, so both `_ =>` arrow arms in render_elements now subtract it like every other named shape already does. Verified live on this machine: resolves theme="Sweet-cursors" size=24 from settings.ini, loads a real 30x30 left_ptr image with hotspot (4,4) -- checked with a temporary probe test, removed before committing. Two lightweight unit tests (rgba_to_bgra_*) cover the channel-reorder byte math without needing a theme installed, so they run everywhere. cargo build --workspace, cargo clippy -p srdwm-wayland (0 new warnings), cargo test -p srdwm-wayland cursor (13/13), cargo test -p srdwm-core (111/111) all pass. Known remaining gap, not addressed here: the loaded size still doesn't track output scale (a HiDPI output gets whatever size settings.ini says regardless of scale factor) - MemoryRenderBuffer's own scale param is hardcoded to 1 throughout this file already, a pre-existing limitation this change doesn't touch.
Diffstat (limited to 'crates/core/src/window.rs')
0 files changed, 0 insertions, 0 deletions