river: Implement cursor_shape_v1

This commit is contained in:
MaxVerevkin 2024-01-04 19:05:03 +02:00 committed by Isaac Freund
parent 9f0e0f2c0a
commit 9ce4525f08
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
3 changed files with 25 additions and 1 deletions

View File

@ -90,6 +90,7 @@ pub fn build(b: *Build) !void {
scanner.addSystemProtocol("unstable/pointer-gestures/pointer-gestures-unstable-v1.xml"); scanner.addSystemProtocol("unstable/pointer-gestures/pointer-gestures-unstable-v1.xml");
scanner.addSystemProtocol("unstable/pointer-constraints/pointer-constraints-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("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-control-unstable-v1.xml");
scanner.addCustomProtocol("protocol/river-status-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("zwp_pointer_constraints_v1", 1);
scanner.generate("zxdg_decoration_manager_v1", 1); scanner.generate("zxdg_decoration_manager_v1", 1);
scanner.generate("ext_session_lock_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_control_v1", 1);
scanner.generate("zriver_status_manager_v1", 4); scanner.generate("zriver_status_manager_v1", 4);

2
deps/zig-wlroots vendored

@ -1 +1 @@
Subproject commit 0644a408625e6d1f7d0631f43b95c6f38a595c7c Subproject commit 0ddfe81c5957fd36f8f8faf3d0870df974860661

View File

@ -33,6 +33,7 @@ const LayoutManager = @import("LayoutManager.zig");
const LockManager = @import("LockManager.zig"); const LockManager = @import("LockManager.zig");
const Output = @import("Output.zig"); const Output = @import("Output.zig");
const Root = @import("Root.zig"); const Root = @import("Root.zig");
const Seat = @import("Seat.zig");
const SceneNodeData = @import("SceneNodeData.zig"); const SceneNodeData = @import("SceneNodeData.zig");
const StatusManager = @import("StatusManager.zig"); const StatusManager = @import("StatusManager.zig");
const XdgDecoration = @import("XdgDecoration.zig"); const XdgDecoration = @import("XdgDecoration.zig");
@ -71,6 +72,8 @@ foreign_toplevel_manager: *wlr.ForeignToplevelManagerV1,
xdg_activation: *wlr.XdgActivationV1, xdg_activation: *wlr.XdgActivationV1,
request_activate: wl.Listener(*wlr.XdgActivationV1.event.RequestActivate), request_activate: wl.Listener(*wlr.XdgActivationV1.event.RequestActivate),
request_set_cursor_shape: wl.Listener(*wlr.CursorShapeManagerV1.event.RequestSetShape),
input_manager: InputManager, input_manager: InputManager,
root: Root, root: Root,
config: Config, config: Config,
@ -144,6 +147,10 @@ pub fn init(self: *Self) !void {
try self.idle_inhibitor_manager.init(); try self.idle_inhibitor_manager.init();
try self.lock_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 // These all free themselves when the wl_server is destroyed
_ = try wlr.DataDeviceManager.create(self.wl_server); _ = try wlr.DataDeviceManager.create(self.wl_server);
_ = try wlr.DataControlManagerV1.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);
}
}