mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 16:01:27 +00:00
Add support for touch cancel events
This commit is contained in:
parent
db7638a0e5
commit
e8f7551e46
|
@ -53,6 +53,7 @@ struct sway_cursor {
|
||||||
|
|
||||||
struct wl_listener touch_down;
|
struct wl_listener touch_down;
|
||||||
struct wl_listener touch_up;
|
struct wl_listener touch_up;
|
||||||
|
struct wl_listener touch_cancel;
|
||||||
struct wl_listener touch_motion;
|
struct wl_listener touch_motion;
|
||||||
struct wl_listener touch_frame;
|
struct wl_listener touch_frame;
|
||||||
bool simulating_pointer_from_touch;
|
bool simulating_pointer_from_touch;
|
||||||
|
|
|
@ -44,6 +44,8 @@ struct sway_seatop_impl {
|
||||||
struct wlr_touch_up_event *event);
|
struct wlr_touch_up_event *event);
|
||||||
void (*touch_down)(struct sway_seat *seat,
|
void (*touch_down)(struct sway_seat *seat,
|
||||||
struct wlr_touch_down_event *event, double lx, double ly);
|
struct wlr_touch_down_event *event, double lx, double ly);
|
||||||
|
void (*touch_cancel)(struct sway_seat *seat,
|
||||||
|
struct wlr_touch_cancel_event *event);
|
||||||
void (*tablet_tool_motion)(struct sway_seat *seat,
|
void (*tablet_tool_motion)(struct sway_seat *seat,
|
||||||
struct sway_tablet_tool *tool, uint32_t time_msec);
|
struct sway_tablet_tool *tool, uint32_t time_msec);
|
||||||
void (*tablet_tool_tip)(struct sway_seat *seat, struct sway_tablet_tool *tool,
|
void (*tablet_tool_tip)(struct sway_seat *seat, struct sway_tablet_tool *tool,
|
||||||
|
@ -338,6 +340,9 @@ void seatop_touch_up(struct sway_seat *seat,
|
||||||
void seatop_touch_down(struct sway_seat *seat,
|
void seatop_touch_down(struct sway_seat *seat,
|
||||||
struct wlr_touch_down_event *event, double lx, double ly);
|
struct wlr_touch_down_event *event, double lx, double ly);
|
||||||
|
|
||||||
|
void seatop_touch_cancel(struct sway_seat *seat,
|
||||||
|
struct wlr_touch_cancel_event *event);
|
||||||
|
|
||||||
void seatop_rebase(struct sway_seat *seat, uint32_t time_msec);
|
void seatop_rebase(struct sway_seat *seat, uint32_t time_msec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -509,6 +509,24 @@ static void handle_touch_up(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_touch_cancel(struct wl_listener *listener, void *data) {
|
||||||
|
struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_cancel);
|
||||||
|
struct wlr_touch_cancel_event *event = data;
|
||||||
|
cursor_handle_activity_from_device(cursor, &event->touch->base);
|
||||||
|
|
||||||
|
struct sway_seat *seat = cursor->seat;
|
||||||
|
|
||||||
|
if (cursor->simulating_pointer_from_touch) {
|
||||||
|
if (cursor->pointer_touch_id == cursor->seat->touch_id) {
|
||||||
|
cursor->pointer_touch_up = true;
|
||||||
|
dispatch_cursor_button(cursor, &event->touch->base,
|
||||||
|
event->time_msec, BTN_LEFT, WLR_BUTTON_RELEASED);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
seatop_touch_cancel(seat, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_touch_motion(struct wl_listener *listener, void *data) {
|
static void handle_touch_motion(struct wl_listener *listener, void *data) {
|
||||||
struct sway_cursor *cursor =
|
struct sway_cursor *cursor =
|
||||||
wl_container_of(listener, cursor, touch_motion);
|
wl_container_of(listener, cursor, touch_motion);
|
||||||
|
@ -1100,6 +1118,7 @@ void sway_cursor_destroy(struct sway_cursor *cursor) {
|
||||||
wl_list_remove(&cursor->frame.link);
|
wl_list_remove(&cursor->frame.link);
|
||||||
wl_list_remove(&cursor->touch_down.link);
|
wl_list_remove(&cursor->touch_down.link);
|
||||||
wl_list_remove(&cursor->touch_up.link);
|
wl_list_remove(&cursor->touch_up.link);
|
||||||
|
wl_list_remove(&cursor->touch_cancel.link);
|
||||||
wl_list_remove(&cursor->touch_motion.link);
|
wl_list_remove(&cursor->touch_motion.link);
|
||||||
wl_list_remove(&cursor->touch_frame.link);
|
wl_list_remove(&cursor->touch_frame.link);
|
||||||
wl_list_remove(&cursor->tool_axis.link);
|
wl_list_remove(&cursor->tool_axis.link);
|
||||||
|
@ -1181,6 +1200,9 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) {
|
||||||
wl_signal_add(&wlr_cursor->events.touch_up, &cursor->touch_up);
|
wl_signal_add(&wlr_cursor->events.touch_up, &cursor->touch_up);
|
||||||
cursor->touch_up.notify = handle_touch_up;
|
cursor->touch_up.notify = handle_touch_up;
|
||||||
|
|
||||||
|
wl_signal_add(&wlr_cursor->events.touch_cancel, &cursor->touch_cancel);
|
||||||
|
cursor->touch_cancel.notify = handle_touch_cancel;
|
||||||
|
|
||||||
wl_signal_add(&wlr_cursor->events.touch_motion,
|
wl_signal_add(&wlr_cursor->events.touch_motion,
|
||||||
&cursor->touch_motion);
|
&cursor->touch_motion);
|
||||||
cursor->touch_motion.notify = handle_touch_motion;
|
cursor->touch_motion.notify = handle_touch_motion;
|
||||||
|
|
|
@ -1638,6 +1638,12 @@ void seatop_touch_down(struct sway_seat *seat, struct wlr_touch_down_event *even
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void seatop_touch_cancel(struct sway_seat *seat, struct wlr_touch_cancel_event *event) {
|
||||||
|
if (seat->seatop_impl->touch_cancel) {
|
||||||
|
seat->seatop_impl->touch_cancel(seat, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void seatop_tablet_tool_tip(struct sway_seat *seat,
|
void seatop_tablet_tool_tip(struct sway_seat *seat,
|
||||||
struct sway_tablet_tool *tool, uint32_t time_msec,
|
struct sway_tablet_tool *tool, uint32_t time_msec,
|
||||||
enum wlr_tablet_tool_tip_state state) {
|
enum wlr_tablet_tool_tip_state state) {
|
||||||
|
|
|
@ -104,6 +104,24 @@ static void handle_touch_down(struct sway_seat *seat,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_touch_cancel(struct sway_seat *seat,
|
||||||
|
struct wlr_touch_cancel_event *event) {
|
||||||
|
struct seatop_down_event *e = seat->seatop_data;
|
||||||
|
struct seatop_touch_point_event *point_event, *tmp;
|
||||||
|
|
||||||
|
wl_list_for_each_safe(point_event, tmp, &e->point_events, link) {
|
||||||
|
if (point_event->touch_id == event->touch_id) {
|
||||||
|
wl_list_remove(&point_event->link);
|
||||||
|
free(point_event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e->surface) {
|
||||||
|
wlr_seat_touch_notify_cancel(seat->wlr_seat, e->surface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_pointer_axis(struct sway_seat *seat,
|
static void handle_pointer_axis(struct sway_seat *seat,
|
||||||
struct wlr_pointer_axis_event *event) {
|
struct wlr_pointer_axis_event *event) {
|
||||||
struct sway_input_device *input_device =
|
struct sway_input_device *input_device =
|
||||||
|
@ -189,6 +207,7 @@ static const struct sway_seatop_impl seatop_impl = {
|
||||||
.touch_motion = handle_touch_motion,
|
.touch_motion = handle_touch_motion,
|
||||||
.touch_up = handle_touch_up,
|
.touch_up = handle_touch_up,
|
||||||
.touch_down = handle_touch_down,
|
.touch_down = handle_touch_down,
|
||||||
|
.touch_cancel = handle_touch_cancel,
|
||||||
.unref = handle_unref,
|
.unref = handle_unref,
|
||||||
.end = handle_end,
|
.end = handle_end,
|
||||||
.allow_set_cursor = true,
|
.allow_set_cursor = true,
|
||||||
|
|
Loading…
Reference in a new issue