From 1c6ebadde64b2e0f416550f9fc806dfc3c80b5c1 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 21 Oct 2026 21:42:33 -0300 Subject: GUI pointer: the desktop's cursor theme on Linux --- src/CHANGELOG.md | 4 ++++ src/gui/gui.zig | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index 6f94b98f..6ebabb5b 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -36,6 +36,10 @@ pane's letter jumps straight to it. Ctrl-w h/j/k/l and SPC w h/j/k/l no longer move the focus at once; on a column or workspace tag Ctrl-w h/j/k/l still walk the tags. +- On Linux the GUI's pointer is the desktop's cursor theme (niri's or + XCURSOR_THEME's, at its size and scale): its default arrow, its hand + over a link, and its move cursor while a grip carries a pane, which + the plan9 theme draws as acme's box. Elsewhere acme's own bitmaps stay. - Built with Zig 0.17. A bare `zig build` still puts the binaries in `~/.local/bin`, now as a copy beside the prefix, which `--prefix` no diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 2abf9166..46d2cc78 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -2367,12 +2367,23 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, attach: ?[]const u defer c.SDL_DestroyWindow(window); updateDisplayScale(window); if (native_wayland) log.info("Wayland opacity: background-only transparent surface", .{}); - const arrow_cursor = c.SDL_CreateCursor(&p9_arrow_set, &p9_arrow_mask, 16, 16, 1, 1); + // On Linux the desktop's own cursor theme draws them (the compositor's + // cursor-shape protocol, else XCURSOR_THEME), at its size and scale: + // the arrow is its default, acme's box its move, as the plan9 theme + // has them. Elsewhere acme's bitmaps, at 16 pixels. + const themed_cursors = builtin.os.tag == .linux; + const arrow_cursor = if (themed_cursors) + c.SDL_CreateSystemCursor(c.SDL_SYSTEM_CURSOR_DEFAULT) + else + c.SDL_CreateCursor(&p9_arrow_set, &p9_arrow_mask, 16, 16, 1, 1); defer if (arrow_cursor) |cursor| c.SDL_DestroyCursor(cursor); const link_cursor = c.SDL_CreateSystemCursor(c.SDL_SYSTEM_CURSOR_POINTER); defer if (link_cursor) |cursor| c.SDL_DestroyCursor(cursor); // Its hot spot the middle, as acme's {-7, -7} offset puts it. - const box_cursor = c.SDL_CreateCursor(&p9_box_set, &p9_box_mask, 16, 16, 7, 7); + const box_cursor = if (themed_cursors) + c.SDL_CreateSystemCursor(c.SDL_SYSTEM_CURSOR_MOVE) + else + c.SDL_CreateCursor(&p9_box_set, &p9_box_mask, 16, 16, 7, 7); defer if (box_cursor) |cursor| c.SDL_DestroyCursor(cursor); if (arrow_cursor) |cur| { _ = c.SDL_SetCursor(cur); -- cgit v1.3