diff options
author | Simon Ser <contact@emersion.fr> | 2021-06-30 13:35:25 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-07-08 09:18:20 +0200 |
commit | 711403015921a931d5a5f2b93f53bf52ff52f0e3 (patch) | |
tree | d81ec72a0f9156b0b462f37d9d4eacab79ba42c7 | |
parent | Update wlr_box includes (diff) | |
download | sway-711403015921a931d5a5f2b93f53bf52ff52f0e3.tar.gz sway-711403015921a931d5a5f2b93f53bf52ff52f0e3.tar.zst sway-711403015921a931d5a5f2b93f53bf52ff52f0e3.zip |
Add support for touch frame events
Update for the breaking change in [1].
[1]: https://github.com/swaywm/wlroots/pull/3001
-rw-r--r-- | include/sway/input/cursor.h | 1 | ||||
-rw-r--r-- | sway/input/cursor.c | 19 |
2 files changed, 18 insertions, 2 deletions
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 6a38190b..b053b85f 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h | |||
@@ -52,6 +52,7 @@ struct sway_cursor { | |||
52 | struct wl_listener touch_down; | 52 | struct wl_listener touch_down; |
53 | struct wl_listener touch_up; | 53 | struct wl_listener touch_up; |
54 | struct wl_listener touch_motion; | 54 | struct wl_listener touch_motion; |
55 | struct wl_listener touch_frame; | ||
55 | bool simulating_pointer_from_touch; | 56 | bool simulating_pointer_from_touch; |
56 | int32_t pointer_touch_id; | 57 | int32_t pointer_touch_id; |
57 | 58 | ||
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 95edf7be..96b5b935 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -495,7 +495,6 @@ static void handle_touch_down(struct wl_listener *listener, void *data) { | |||
495 | pointer_motion(cursor, event->time_msec, event->device, dx, dy, dx, dy); | 495 | pointer_motion(cursor, event->time_msec, event->device, dx, dy, dx, dy); |
496 | dispatch_cursor_button(cursor, event->device, event->time_msec, | 496 | dispatch_cursor_button(cursor, event->device, event->time_msec, |
497 | BTN_LEFT, WLR_BUTTON_PRESSED); | 497 | BTN_LEFT, WLR_BUTTON_PRESSED); |
498 | wlr_seat_pointer_notify_frame(wlr_seat); | ||
499 | } | 498 | } |
500 | } | 499 | } |
501 | 500 | ||
@@ -511,7 +510,6 @@ static void handle_touch_up(struct wl_listener *listener, void *data) { | |||
511 | cursor->simulating_pointer_from_touch = false; | 510 | cursor->simulating_pointer_from_touch = false; |
512 | dispatch_cursor_button(cursor, event->device, event->time_msec, | 511 | dispatch_cursor_button(cursor, event->device, event->time_msec, |
513 | BTN_LEFT, WLR_BUTTON_RELEASED); | 512 | BTN_LEFT, WLR_BUTTON_RELEASED); |
514 | wlr_seat_pointer_notify_frame(wlr_seat); | ||
515 | } | 513 | } |
516 | } else { | 514 | } else { |
517 | wlr_seat_touch_notify_up(wlr_seat, event->time_msec, event->touch_id); | 515 | wlr_seat_touch_notify_up(wlr_seat, event->time_msec, event->touch_id); |
@@ -559,6 +557,19 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) { | |||
559 | } | 557 | } |
560 | } | 558 | } |
561 | 559 | ||
560 | static void handle_touch_frame(struct wl_listener *listener, void *data) { | ||
561 | struct sway_cursor *cursor = | ||
562 | wl_container_of(listener, cursor, touch_frame); | ||
563 | |||
564 | struct wlr_seat *wlr_seat = cursor->seat->wlr_seat; | ||
565 | |||
566 | if (cursor->simulating_pointer_from_touch) { | ||
567 | wlr_seat_pointer_notify_frame(wlr_seat); | ||
568 | } else { | ||
569 | wlr_seat_touch_notify_frame(wlr_seat); | ||
570 | } | ||
571 | } | ||
572 | |||
562 | static double apply_mapping_from_coord(double low, double high, double value) { | 573 | static double apply_mapping_from_coord(double low, double high, double value) { |
563 | if (isnan(value)) { | 574 | if (isnan(value)) { |
564 | return value; | 575 | return value; |
@@ -1044,6 +1055,7 @@ void sway_cursor_destroy(struct sway_cursor *cursor) { | |||
1044 | wl_list_remove(&cursor->touch_down.link); | 1055 | wl_list_remove(&cursor->touch_down.link); |
1045 | wl_list_remove(&cursor->touch_up.link); | 1056 | wl_list_remove(&cursor->touch_up.link); |
1046 | wl_list_remove(&cursor->touch_motion.link); | 1057 | wl_list_remove(&cursor->touch_motion.link); |
1058 | wl_list_remove(&cursor->touch_frame.link); | ||
1047 | wl_list_remove(&cursor->tool_axis.link); | 1059 | wl_list_remove(&cursor->tool_axis.link); |
1048 | wl_list_remove(&cursor->tool_tip.link); | 1060 | wl_list_remove(&cursor->tool_tip.link); |
1049 | wl_list_remove(&cursor->tool_button.link); | 1061 | wl_list_remove(&cursor->tool_button.link); |
@@ -1119,6 +1131,9 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) { | |||
1119 | &cursor->touch_motion); | 1131 | &cursor->touch_motion); |
1120 | cursor->touch_motion.notify = handle_touch_motion; | 1132 | cursor->touch_motion.notify = handle_touch_motion; |
1121 | 1133 | ||
1134 | wl_signal_add(&wlr_cursor->events.touch_frame, &cursor->touch_frame); | ||
1135 | cursor->touch_frame.notify = handle_touch_frame; | ||
1136 | |||
1122 | wl_signal_add(&wlr_cursor->events.tablet_tool_axis, | 1137 | wl_signal_add(&wlr_cursor->events.tablet_tool_axis, |
1123 | &cursor->tool_axis); | 1138 | &cursor->tool_axis); |
1124 | cursor->tool_axis.notify = handle_tool_axis; | 1139 | cursor->tool_axis.notify = handle_tool_axis; |