mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-26 06:35:58 +01:00
examples/touch: support touch cancel events
This commit is contained in:
parent
37f42e2df2
commit
12e28c3492
1 changed files with 17 additions and 0 deletions
|
@ -46,6 +46,7 @@ struct touch_state {
|
||||||
struct wl_listener down;
|
struct wl_listener down;
|
||||||
struct wl_listener up;
|
struct wl_listener up;
|
||||||
struct wl_listener motion;
|
struct wl_listener motion;
|
||||||
|
struct wl_listener cancel;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
@ -130,6 +131,19 @@ static void touch_motion_notify(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void touch_cancel_notify(struct wl_listener *listener, void *data) {
|
||||||
|
struct wlr_touch_cancel_event *event = data;
|
||||||
|
struct touch_state *tstate = wl_container_of(listener, tstate, cancel);
|
||||||
|
struct sample_state *sample = tstate->sample;
|
||||||
|
struct touch_point *point, *tmp;
|
||||||
|
wl_list_for_each_safe(point, tmp, &sample->touch_points, link) {
|
||||||
|
if (point->touch_id == event->touch_id) {
|
||||||
|
wl_list_remove(&point->link);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void touch_destroy_notify(struct wl_listener *listener, void *data) {
|
static void touch_destroy_notify(struct wl_listener *listener, void *data) {
|
||||||
struct touch_state *tstate = wl_container_of(listener, tstate, destroy);
|
struct touch_state *tstate = wl_container_of(listener, tstate, destroy);
|
||||||
wl_list_remove(&tstate->link);
|
wl_list_remove(&tstate->link);
|
||||||
|
@ -137,6 +151,7 @@ static void touch_destroy_notify(struct wl_listener *listener, void *data) {
|
||||||
wl_list_remove(&tstate->down.link);
|
wl_list_remove(&tstate->down.link);
|
||||||
wl_list_remove(&tstate->up.link);
|
wl_list_remove(&tstate->up.link);
|
||||||
wl_list_remove(&tstate->motion.link);
|
wl_list_remove(&tstate->motion.link);
|
||||||
|
wl_list_remove(&tstate->cancel.link);
|
||||||
free(tstate);
|
free(tstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,6 +246,8 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
|
||||||
wl_signal_add(&tstate->wlr_touch->events.motion, &tstate->motion);
|
wl_signal_add(&tstate->wlr_touch->events.motion, &tstate->motion);
|
||||||
tstate->up.notify = touch_up_notify;
|
tstate->up.notify = touch_up_notify;
|
||||||
wl_signal_add(&tstate->wlr_touch->events.up, &tstate->up);
|
wl_signal_add(&tstate->wlr_touch->events.up, &tstate->up);
|
||||||
|
tstate->cancel.notify = touch_cancel_notify;
|
||||||
|
wl_signal_add(&tstate->wlr_touch->events.cancel, &tstate->cancel);
|
||||||
wl_list_insert(&sample->touch, &tstate->link);
|
wl_list_insert(&sample->touch, &tstate->link);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue