mirror of
https://github.com/swaywm/sway.git
synced 2024-11-10 20:44:01 +01:00
Add support for touch frame events
Update for the breaking change in [1]. [1]: https://github.com/swaywm/wlroots/pull/3001
This commit is contained in:
parent
4832fc937f
commit
7114030159
@ -52,6 +52,7 @@ struct sway_cursor {
|
||||
struct wl_listener touch_down;
|
||||
struct wl_listener touch_up;
|
||||
struct wl_listener touch_motion;
|
||||
struct wl_listener touch_frame;
|
||||
bool simulating_pointer_from_touch;
|
||||
int32_t pointer_touch_id;
|
||||
|
||||
|
@ -495,7 +495,6 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
|
||||
pointer_motion(cursor, event->time_msec, event->device, dx, dy, dx, dy);
|
||||
dispatch_cursor_button(cursor, event->device, event->time_msec,
|
||||
BTN_LEFT, WLR_BUTTON_PRESSED);
|
||||
wlr_seat_pointer_notify_frame(wlr_seat);
|
||||
}
|
||||
}
|
||||
|
||||
@ -511,7 +510,6 @@ static void handle_touch_up(struct wl_listener *listener, void *data) {
|
||||
cursor->simulating_pointer_from_touch = false;
|
||||
dispatch_cursor_button(cursor, event->device, event->time_msec,
|
||||
BTN_LEFT, WLR_BUTTON_RELEASED);
|
||||
wlr_seat_pointer_notify_frame(wlr_seat);
|
||||
}
|
||||
} else {
|
||||
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) {
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_touch_frame(struct wl_listener *listener, void *data) {
|
||||
struct sway_cursor *cursor =
|
||||
wl_container_of(listener, cursor, touch_frame);
|
||||
|
||||
struct wlr_seat *wlr_seat = cursor->seat->wlr_seat;
|
||||
|
||||
if (cursor->simulating_pointer_from_touch) {
|
||||
wlr_seat_pointer_notify_frame(wlr_seat);
|
||||
} else {
|
||||
wlr_seat_touch_notify_frame(wlr_seat);
|
||||
}
|
||||
}
|
||||
|
||||
static double apply_mapping_from_coord(double low, double high, double value) {
|
||||
if (isnan(value)) {
|
||||
return value;
|
||||
@ -1044,6 +1055,7 @@ void sway_cursor_destroy(struct sway_cursor *cursor) {
|
||||
wl_list_remove(&cursor->touch_down.link);
|
||||
wl_list_remove(&cursor->touch_up.link);
|
||||
wl_list_remove(&cursor->touch_motion.link);
|
||||
wl_list_remove(&cursor->touch_frame.link);
|
||||
wl_list_remove(&cursor->tool_axis.link);
|
||||
wl_list_remove(&cursor->tool_tip.link);
|
||||
wl_list_remove(&cursor->tool_button.link);
|
||||
@ -1119,6 +1131,9 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) {
|
||||
&cursor->touch_motion);
|
||||
cursor->touch_motion.notify = handle_touch_motion;
|
||||
|
||||
wl_signal_add(&wlr_cursor->events.touch_frame, &cursor->touch_frame);
|
||||
cursor->touch_frame.notify = handle_touch_frame;
|
||||
|
||||
wl_signal_add(&wlr_cursor->events.tablet_tool_axis,
|
||||
&cursor->tool_axis);
|
||||
cursor->tool_axis.notify = handle_tool_axis;
|
||||
|
Loading…
Reference in New Issue
Block a user