Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git
Cursor: never set XCURSOR_* env variables
Setting these environment variables to match the cursor theme cannot be
handled by river since river no longer starts any processes other than
the init script.
Currently, the only effect of this code is to override any XCURSOR_*
values set by the user before starting river, which is undesirable.
protocol/river-window-management-v1.xml | 3 +++
river/Cursor.zig | 10 ++--------
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/protocol/river-window-management-v1.xml b/protocol/river-window-management-v1.xml
index f1bafe2..15f7e12 100644
--- a/protocol/river-window-management-v1.xml
+++ b/protocol/river-window-management-v1.xml
@@ -1543,6 +1543,9 @@
Set the XCursor theme for the seat. This theme is used for cursors
rendered by the compositor, but not necessarily for cursors rendered by
clients.
+
+ Note: The window manager may also wish to set the XCURSOR_THEME and
+ XCURSOR_SIZE environment variable for programs it starts.
</description>
<arg name="name" type="string"/>
<arg name="size" type="uint"/>
diff --git a/river/Cursor.zig b/river/Cursor.zig
index fa639da..b3679da 100644
--- a/river/Cursor.zig
+++ b/river/Cursor.zig
@@ -13,7 +13,6 @@ const wayland = @import("wayland");
const wl = wayland.server.wl;
const zwlr = wayland.server.zwlr;
-const c = @import("c.zig").c;
const server = &@import("main.zig").server;
const util = @import("util.zig");
@@ -209,14 +208,9 @@ pub fn setTheme(cursor: *Cursor, theme: ?[*:0]const u8, _size: ?u32) !void {
const xcursor_manager = try wlr.XcursorManager.create(theme, size);
errdefer xcursor_manager.destroy();
- // If this cursor belongs to the default seat, set the xcursor environment
- // variables as well as the xwayland cursor theme.
+ // If this cursor belongs to the default seat, update the Xwayland cursor to match the theme.
+ // This cursor is communicated to Xwayland clients through the XCB_CW_CURSOR window attribute.
if (cursor.seat == server.input_manager.defaultSeat()) {
- const size_str = try std.fmt.allocPrintSentinel(util.gpa, "{}", .{size}, 0);
- defer util.gpa.free(size_str);
- if (c.setenv("XCURSOR_SIZE", size_str.ptr, 1) < 0) return error.OutOfMemory;
- if (theme) |t| if (c.setenv("XCURSOR_THEME", t, 1) < 0) return error.OutOfMemory;
-
if (build_options.xwayland) {
if (server.xwayland) |xwayland| {
try xcursor_manager.load(1);