git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commitb111e71932d760c2f9c7a635620660db24adfca7
parent6398737d77
authorIsaac Freund <[email protected]>
date2020-07-17 20:40
cursor: ensure theme loaded on output creation

 river/Cursor.zig | 3 ++-
 river/Output.zig | 9 +++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/river/Cursor.zig b/river/Cursor.zig
index a8d2a21..90b9225 100644
--- a/river/Cursor.zig
+++ b/river/Cursor.zig
@@ -118,7 +118,8 @@ pub fn deinit(self: *Self) void {
 }
 
 /// Set the cursor theme for the given seat, as well as the xwayland theme if
-/// this is the default seat.
+/// this is the default seat. Either argument may be null, in which case a
+/// default will be used.
 pub fn setTheme(self: *Self, theme: ?[*:0]const u8, _size: ?u32) !void {
     const server = self.seat.input_manager.server;
     const size = _size orelse default_size;
diff --git a/river/Output.zig b/river/Output.zig
index fdefb0f..86e8514 100644
--- a/river/Output.zig
+++ b/river/Output.zig
@@ -142,6 +142,15 @@ pub fn init(self: *Self, root: *Root, wlr_output: *c.wlr_output) !void {
         // layout. This automatically creates an output global on the wl_display.
         c.wlr_output_layout_add_auto(root.wlr_output_layout, wlr_output);
 
+        // Ensure that a cursor image at the output's scale factor is loaded
+        // for each seat.
+        var it = root.server.input_manager.seats.first;
+        while (it) |node| : (it = node.next) {
+            const seat = &node.data;
+            if (!c.wlr_xcursor_manager_load(seat.cursor.wlr_xcursor_manager, wlr_output.scale))
+                log.err(.cursor, "failed to load xcursor theme at scale {}", .{wlr_output.scale});
+        }
+
         var width: c_int = undefined;
         var height: c_int = undefined;
         c.wlr_output_effective_resolution(wlr_output, &width, &height);