aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-11-12 17:34:32 -0500
committerTony Crisci <tony@dubstepdish.com>2017-11-15 08:34:48 -0500
commitcbb6fd7352ea98d60d380ce376da4b76fe7f4740 (patch)
tree2a6c9a3d1494f202beb1f9016130981879063882
parent469729d3af214ebe3bce5f924d1aee9bf4c130f1 (diff)
wlr-seat: touch grab begin and end
-rw-r--r--include/wlr/types/wlr_seat.h16
-rw-r--r--types/wlr_seat.c23
2 files changed, 39 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h
index afa460ec..f429fb8e 100644
--- a/include/wlr/types/wlr_seat.h
+++ b/include/wlr/types/wlr_seat.h
@@ -175,6 +175,9 @@ struct wlr_seat {
struct wl_signal keyboard_grab_begin;
struct wl_signal keyboard_grab_end;
+ struct wl_signal touch_grab_begin;
+ struct wl_signal touch_grab_end;
+
struct wl_signal request_set_cursor;
struct wl_signal selection;
@@ -372,6 +375,19 @@ void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat,
void wlr_seat_keyboard_clear_focus(struct wlr_seat *wlr_seat);
/**
+ * Start a grab of the touch device of this seat. The grabber is responsible for
+ * handling all touch events until the grab ends.
+ */
+void wlr_seat_touch_start_grab(struct wlr_seat *wlr_seat,
+ struct wlr_seat_touch_grab *grab);
+
+/**
+ * End the grab of the touch device of this seat. This reverts the grab back to
+ * the default grab for the touch device.
+ */
+void wlr_seat_touch_end_grab(struct wlr_seat *wlr_seat);
+
+/**
* Get the active touch point with the given `touch_id`. If the touch point does
* not exist or is no longer active, returns NULL.
*/
diff --git a/types/wlr_seat.c b/types/wlr_seat.c
index a33e19df..2d6d800f 100644
--- a/types/wlr_seat.c
+++ b/types/wlr_seat.c
@@ -407,6 +407,9 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
wl_signal_init(&wlr_seat->events.keyboard_grab_begin);
wl_signal_init(&wlr_seat->events.keyboard_grab_end);
+ wl_signal_init(&wlr_seat->events.touch_grab_begin);
+ wl_signal_init(&wlr_seat->events.touch_grab_end);
+
return wlr_seat;
}
@@ -867,6 +870,26 @@ void wlr_seat_keyboard_notify_key(struct wlr_seat *seat, uint32_t time,
grab->interface->key(grab, time, key, state);
}
+void wlr_seat_touch_start_grab(struct wlr_seat *wlr_seat,
+ struct wlr_seat_touch_grab *grab) {
+ grab->seat = wlr_seat;
+ wlr_seat->touch_state.grab = grab;
+
+ wl_signal_emit(&wlr_seat->events.touch_grab_begin, grab);
+}
+
+void wlr_seat_touch_end_grab(struct wlr_seat *wlr_seat) {
+ struct wlr_seat_touch_grab *grab = wlr_seat->touch_state.grab;
+
+ if (grab != wlr_seat->touch_state.default_grab) {
+ wlr_seat->touch_state.grab = wlr_seat->touch_state.default_grab;
+ wl_signal_emit(&wlr_seat->events.touch_grab_end, grab);
+ if (grab->interface->cancel) {
+ grab->interface->cancel(grab);
+ }
+ }
+}
+
static void touch_point_destroy(struct wlr_touch_point *point) {
wl_list_remove(&point->surface_destroy.link);
wl_list_remove(&point->resource_destroy.link);