aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxVerevkin <maxxverrr@gmail.com>2024-01-04 19:05:03 +0200
committerIsaac Freund <mail@isaacfreund.com>2024-01-04 14:14:00 -0600
commit9ce4525f082d3474667853b28deff5a44c56f552 (patch)
tree64eb0a1762e2bb604c466909588fcd12db50d895
parent9f0e0f2c0a4c24ebdd54982b824a382b1836c165 (diff)
downloadriver-9ce4525f082d3474667853b28deff5a44c56f552.tar.gz
river-9ce4525f082d3474667853b28deff5a44c56f552.tar.xz
river: Implement cursor_shape_v1
-rw-r--r--build.zig2
m---------deps/zig-wlroots0
-rw-r--r--river/Server.zig22
3 files changed, 24 insertions, 0 deletions
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
-Subproject 0644a408625e6d1f7d0631f43b95c6f38a595c7
+Subproject 0ddfe81c5957fd36f8f8faf3d0870df97486066
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);
+ }
+}