aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorLibravatar hrdl <31923882+hrdl-github@users.noreply.github.com>2023-05-04 01:13:33 +0200
committerLibravatar Simon Ser <contact@emersion.fr>2023-05-04 13:30:57 +0200
commite8f7551e46052a8df04b630bf06565ca77f830fb (patch)
tree00a8dd81570767262252188f183fac647bfa253b /sway/input/cursor.c
parentDon't crash if there is no damage during render (diff)
downloadsway-e8f7551e46052a8df04b630bf06565ca77f830fb.tar.gz
sway-e8f7551e46052a8df04b630bf06565ca77f830fb.tar.zst
sway-e8f7551e46052a8df04b630bf06565ca77f830fb.zip
Add support for touch cancel events
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 75d055cd..d8ec11ac 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -509,6 +509,24 @@ static void handle_touch_up(struct wl_listener *listener, void *data) {
509 } 509 }
510} 510}
511 511
512static void handle_touch_cancel(struct wl_listener *listener, void *data) {
513 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_cancel);
514 struct wlr_touch_cancel_event *event = data;
515 cursor_handle_activity_from_device(cursor, &event->touch->base);
516
517 struct sway_seat *seat = cursor->seat;
518
519 if (cursor->simulating_pointer_from_touch) {
520 if (cursor->pointer_touch_id == cursor->seat->touch_id) {
521 cursor->pointer_touch_up = true;
522 dispatch_cursor_button(cursor, &event->touch->base,
523 event->time_msec, BTN_LEFT, WLR_BUTTON_RELEASED);
524 }
525 } else {
526 seatop_touch_cancel(seat, event);
527 }
528}
529
512static void handle_touch_motion(struct wl_listener *listener, void *data) { 530static void handle_touch_motion(struct wl_listener *listener, void *data) {
513 struct sway_cursor *cursor = 531 struct sway_cursor *cursor =
514 wl_container_of(listener, cursor, touch_motion); 532 wl_container_of(listener, cursor, touch_motion);
@@ -1100,6 +1118,7 @@ void sway_cursor_destroy(struct sway_cursor *cursor) {
1100 wl_list_remove(&cursor->frame.link); 1118 wl_list_remove(&cursor->frame.link);
1101 wl_list_remove(&cursor->touch_down.link); 1119 wl_list_remove(&cursor->touch_down.link);
1102 wl_list_remove(&cursor->touch_up.link); 1120 wl_list_remove(&cursor->touch_up.link);
1121 wl_list_remove(&cursor->touch_cancel.link);
1103 wl_list_remove(&cursor->touch_motion.link); 1122 wl_list_remove(&cursor->touch_motion.link);
1104 wl_list_remove(&cursor->touch_frame.link); 1123 wl_list_remove(&cursor->touch_frame.link);
1105 wl_list_remove(&cursor->tool_axis.link); 1124 wl_list_remove(&cursor->tool_axis.link);
@@ -1181,6 +1200,9 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) {
1181 wl_signal_add(&wlr_cursor->events.touch_up, &cursor->touch_up); 1200 wl_signal_add(&wlr_cursor->events.touch_up, &cursor->touch_up);
1182 cursor->touch_up.notify = handle_touch_up; 1201 cursor->touch_up.notify = handle_touch_up;
1183 1202
1203 wl_signal_add(&wlr_cursor->events.touch_cancel, &cursor->touch_cancel);
1204 cursor->touch_cancel.notify = handle_touch_cancel;
1205
1184 wl_signal_add(&wlr_cursor->events.touch_motion, 1206 wl_signal_add(&wlr_cursor->events.touch_motion,
1185 &cursor->touch_motion); 1207 &cursor->touch_motion);
1186 cursor->touch_motion.notify = handle_touch_motion; 1208 cursor->touch_motion.notify = handle_touch_motion;