diff --git a/build.zig b/build.zig index faa39c1..a9a7c1f 100644 --- a/build.zig +++ b/build.zig @@ -90,6 +90,7 @@ pub fn build(b: *Build) !void { scanner.addSystemProtocol("unstable/pointer-gestures/pointer-gestures-unstable-v1.xml"); scanner.addSystemProtocol("unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"); scanner.addSystemProtocol("unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"); + scanner.addSystemProtocol("staging/cursor-shape/cursor-shape-v1.xml"); scanner.addCustomProtocol("protocol/river-control-unstable-v1.xml"); scanner.addCustomProtocol("protocol/river-status-unstable-v1.xml"); @@ -114,6 +115,7 @@ pub fn build(b: *Build) !void { scanner.generate("zwp_pointer_constraints_v1", 1); scanner.generate("zxdg_decoration_manager_v1", 1); scanner.generate("ext_session_lock_manager_v1", 1); + scanner.generate("wp_cursor_shape_manager_v1", 1); scanner.generate("zriver_control_v1", 1); scanner.generate("zriver_status_manager_v1", 4); diff --git a/deps/zig-wlroots b/deps/zig-wlroots index 0644a40..0ddfe81 160000 --- a/deps/zig-wlroots +++ b/deps/zig-wlroots @@ -1 +1 @@ -Subproject commit 0644a408625e6d1f7d0631f43b95c6f38a595c7c +Subproject commit 0ddfe81c5957fd36f8f8faf3d0870df974860661 diff --git a/river/Server.zig b/river/Server.zig index c5b0b39..e1c8036 100644 --- a/river/Server.zig +++ b/river/Server.zig @@ -33,6 +33,7 @@ const LayoutManager = @import("LayoutManager.zig"); const LockManager = @import("LockManager.zig"); const Output = @import("Output.zig"); const Root = @import("Root.zig"); +const Seat = @import("Seat.zig"); const SceneNodeData = @import("SceneNodeData.zig"); const StatusManager = @import("StatusManager.zig"); const XdgDecoration = @import("XdgDecoration.zig"); @@ -71,6 +72,8 @@ foreign_toplevel_manager: *wlr.ForeignToplevelManagerV1, xdg_activation: *wlr.XdgActivationV1, request_activate: wl.Listener(*wlr.XdgActivationV1.event.RequestActivate), +request_set_cursor_shape: wl.Listener(*wlr.CursorShapeManagerV1.event.RequestSetShape), + input_manager: InputManager, root: Root, config: Config, @@ -144,6 +147,10 @@ pub fn init(self: *Self) !void { try self.idle_inhibitor_manager.init(); try self.lock_manager.init(); + const cursor_shape_manager = try wlr.CursorShapeManagerV1.create(self.wl_server, 1); + self.request_set_cursor_shape.setNotify(handleRequestSetCursorShape); + cursor_shape_manager.events.request_set_shape.add(&self.request_set_cursor_shape); + // These all free themselves when the wl_server is destroyed _ = try wlr.DataDeviceManager.create(self.wl_server); _ = try wlr.DataControlManagerV1.create(self.wl_server); @@ -298,3 +305,18 @@ fn handleRequestActivate( }, } } + +fn handleRequestSetCursorShape( + _: *wl.Listener(*wlr.CursorShapeManagerV1.event.RequestSetShape), + event: *wlr.CursorShapeManagerV1.event.RequestSetShape, +) void { + const focused_client = event.seat_client.seat.pointer_state.focused_client; + + // This can be sent by any client, so we check to make sure this one is + // actually has pointer focus first. + if (focused_client == event.seat_client) { + const seat: *Seat = @ptrFromInt(event.seat_client.seat.data); + const name = wlr.CursorShapeManagerV1.shapeName(event.shape); + seat.cursor.setXcursor(name); + } +}