aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarten Ringwelski <git@maringuu.de>2021-02-14 19:32:04 +0100
committerIsaac Freund <ifreund@ifreund.xyz>2021-02-15 18:18:18 +0100
commit870f0b746eb28c51a75b6c8c7521abd7143902d4 (patch)
tree228046ed4801a008eb392863c769c96f0ba18d75
parent6470d8c776343fed30032ad96f75f7d78aac0a18 (diff)
downloadriver-870f0b746eb28c51a75b6c8c7521abd7143902d4.tar.gz
river-870f0b746eb28c51a75b6c8c7521abd7143902d4.tar.xz
Implement pointer-gestures-unstable-v1
-rw-r--r--build.zig1
m---------deps/zig-wayland0
m---------deps/zig-wlroots0
-rw-r--r--river/Cursor.zig96
4 files changed, 97 insertions, 0 deletions
diff --git a/build.zig b/build.zig
index b8e847e..9d16c7b 100644
--- a/build.zig
+++ b/build.zig
@@ -40,6 +40,7 @@ pub fn build(b: *zbs.Builder) !void {
const scanner = ScanProtocolsStep.create(b);
scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml");
+ scanner.addSystemProtocol("unstable/pointer-gestures/pointer-gestures-unstable-v1.xml");
scanner.addSystemProtocol("unstable/xdg-output/xdg-output-unstable-v1.xml");
scanner.addProtocolPath("protocol/river-control-unstable-v1.xml");
scanner.addProtocolPath("protocol/river-options-unstable-v1.xml");
diff --git a/deps/zig-wayland b/deps/zig-wayland
-Subproject 6880196f57df7f4d8b783bbab94b1bf5c3e3845
+Subproject 5def9c58107c4803847e37511d16c15ff294b62
diff --git a/deps/zig-wlroots b/deps/zig-wlroots
-Subproject 5bc7fcf94e1d488a8e2316ff7ebdd0ca193d030
+Subproject b38d3d5d2d9a5e4c748b8c01ed0d3861241661a
diff --git a/river/Cursor.zig b/river/Cursor.zig
index 0f72868..4ec84ed 100644
--- a/river/Cursor.zig
+++ b/river/Cursor.zig
@@ -57,6 +57,7 @@ mode: Mode = .passthrough,
seat: *Seat,
wlr_cursor: *wlr.Cursor,
+pointer_gestures: *wlr.PointerGesturesV1,
xcursor_manager: *wlr.XcursorManager,
/// Number of distinct buttons currently pressed
@@ -71,8 +72,20 @@ motion_absolute: wl.Listener(*wlr.Pointer.event.MotionAbsolute) =
wl.Listener(*wlr.Pointer.event.MotionAbsolute).init(handleMotionAbsolute),
motion: wl.Listener(*wlr.Pointer.event.Motion) =
wl.Listener(*wlr.Pointer.event.Motion).init(handleMotion),
+pinch_begin: wl.Listener(*wlr.Pointer.event.PinchBegin) =
+ wl.Listener(*wlr.Pointer.event.PinchBegin).init(handlePinchBegin),
+pinch_update: wl.Listener(*wlr.Pointer.event.PinchUpdate) =
+ wl.Listener(*wlr.Pointer.event.PinchUpdate).init(handlePinchUpdate),
+pinch_end: wl.Listener(*wlr.Pointer.event.PinchEnd) =
+ wl.Listener(*wlr.Pointer.event.PinchEnd).init(handlePinchEnd),
request_set_cursor: wl.Listener(*wlr.Seat.event.RequestSetCursor) =
wl.Listener(*wlr.Seat.event.RequestSetCursor).init(handleRequestSetCursor),
+swipe_begin: wl.Listener(*wlr.Pointer.event.SwipeBegin) =
+ wl.Listener(*wlr.Pointer.event.SwipeBegin).init(handleSwipeBegin),
+swipe_update: wl.Listener(*wlr.Pointer.event.SwipeUpdate) =
+ wl.Listener(*wlr.Pointer.event.SwipeUpdate).init(handleSwipeUpdate),
+swipe_end: wl.Listener(*wlr.Pointer.event.SwipeEnd) =
+ wl.Listener(*wlr.Pointer.event.SwipeEnd).init(handleSwipeEnd),
// zig fmt: on
pub fn init(self: *Self, seat: *Seat) !void {
@@ -89,6 +102,7 @@ pub fn init(self: *Self, seat: *Seat) !void {
self.* = .{
.seat = seat,
.wlr_cursor = wlr_cursor,
+ .pointer_gestures = try wlr.PointerGesturesV1.create(seat.input_manager.server.wl_server),
.xcursor_manager = xcursor_manager,
};
try self.setTheme(null, null);
@@ -104,6 +118,12 @@ pub fn init(self: *Self, seat: *Seat) !void {
wlr_cursor.events.frame.add(&self.frame);
wlr_cursor.events.motion_absolute.add(&self.motion_absolute);
wlr_cursor.events.motion.add(&self.motion);
+ wlr_cursor.events.swipe_begin.add(&self.swipe_begin);
+ wlr_cursor.events.swipe_update.add(&self.swipe_update);
+ wlr_cursor.events.swipe_end.add(&self.swipe_end);
+ wlr_cursor.events.pinch_begin.add(&self.pinch_begin);
+ wlr_cursor.events.pinch_update.add(&self.pinch_update);
+ wlr_cursor.events.pinch_end.add(&self.pinch_end);
seat.wlr_seat.events.request_set_cursor.add(&self.request_set_cursor);
}
@@ -240,6 +260,82 @@ fn handleButton(listener: *wl.Listener(*wlr.Pointer.event.Button), event: *wlr.P
}
}
+fn handlePinchBegin(
+ listener: *wl.Listener(*wlr.Pointer.event.PinchBegin),
+ event: *wlr.Pointer.event.PinchBegin,
+) void {
+ const self = @fieldParentPtr(Self, "pinch_begin", listener);
+ self.pointer_gestures.sendPinchBegin(
+ self.seat.wlr_seat,
+ event.time_msec,
+ event.fingers,
+ );
+}
+
+fn handlePinchUpdate(
+ listener: *wl.Listener(*wlr.Pointer.event.PinchUpdate),
+ event: *wlr.Pointer.event.PinchUpdate,
+) void {
+ const self = @fieldParentPtr(Self, "pinch_update", listener);
+ self.pointer_gestures.sendPinchUpdate(
+ self.seat.wlr_seat,
+ event.time_msec,
+ event.dx,
+ event.dy,
+ event.scale,
+ event.rotation,
+ );
+}
+
+fn handlePinchEnd(
+ listener: *wl.Listener(*wlr.Pointer.event.PinchEnd),
+ event: *wlr.Pointer.event.PinchEnd,
+) void {
+ const self = @fieldParentPtr(Self, "pinch_end", listener);
+ self.pointer_gestures.sendPinchEnd(
+ self.seat.wlr_seat,
+ event.time_msec,
+ event.cancelled,
+ );
+}
+
+fn handleSwipeBegin(
+ listener: *wl.Listener(*wlr.Pointer.event.SwipeBegin),
+ event: *wlr.Pointer.event.SwipeBegin,
+) void {
+ const self = @fieldParentPtr(Self, "swipe_begin", listener);
+ self.pointer_gestures.sendSwipeBegin(
+ self.seat.wlr_seat,
+ event.time_msec,
+ event.fingers,
+ );
+}
+
+fn handleSwipeUpdate(
+ listener: *wl.Listener(*wlr.Pointer.event.SwipeUpdate),
+ event: *wlr.Pointer.event.SwipeUpdate,
+) void {
+ const self = @fieldParentPtr(Self, "swipe_update", listener);
+ self.pointer_gestures.sendSwipeUpdate(
+ self.seat.wlr_seat,
+ event.time_msec,
+ event.dx,
+ event.dy,
+ );
+}
+
+fn handleSwipeEnd(
+ listener: *wl.Listener(*wlr.Pointer.event.SwipeEnd),
+ event: *wlr.Pointer.event.SwipeEnd,
+) void {
+ const self = @fieldParentPtr(Self, "swipe_end", listener);
+ self.pointer_gestures.sendSwipeEnd(
+ self.seat.wlr_seat,
+ event.time_msec,
+ event.cancelled,
+ );
+}
+
/// Handle the mapping for the passed button if any. Returns true if there
/// was a mapping and the button was handled.
fn handlePointerMapping(self: *Self, event: *wlr.Pointer.event.Button, view: *View) bool {