From 22fd411bc3e77da5ec2e866b6e52e1bf16f69815 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 30 Jun 2021 11:40:15 +0200 Subject: [PATCH] cursor: add touch frame event --- include/wlr/types/wlr_cursor.h | 1 + types/wlr_cursor.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h index 71eddc43..f5a016f4 100644 --- a/include/wlr/types/wlr_cursor.h +++ b/include/wlr/types/wlr_cursor.h @@ -63,6 +63,7 @@ struct wlr_cursor { struct wl_signal touch_down; struct wl_signal touch_motion; struct wl_signal touch_cancel; + struct wl_signal touch_frame; struct wl_signal tablet_tool_axis; struct wl_signal tablet_tool_proximity; diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index 2bc22668..3d75505b 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -37,6 +37,7 @@ struct wlr_cursor_device { struct wl_listener touch_up; struct wl_listener touch_motion; struct wl_listener touch_cancel; + struct wl_listener touch_frame; struct wl_listener tablet_tool_axis; struct wl_listener tablet_tool_proximity; @@ -105,6 +106,7 @@ struct wlr_cursor *wlr_cursor_create(void) { wl_signal_init(&cur->events.touch_down); wl_signal_init(&cur->events.touch_motion); wl_signal_init(&cur->events.touch_cancel); + wl_signal_init(&cur->events.touch_frame); // tablet tool signals wl_signal_init(&cur->events.tablet_tool_tip); @@ -163,6 +165,7 @@ static void cursor_device_destroy(struct wlr_cursor_device *c_device) { wl_list_remove(&c_device->touch_up.link); wl_list_remove(&c_device->touch_motion.link); wl_list_remove(&c_device->touch_cancel.link); + wl_list_remove(&c_device->touch_frame.link); } else if (dev->type == WLR_INPUT_DEVICE_TABLET_TOOL) { wl_list_remove(&c_device->tablet_tool_axis.link); wl_list_remove(&c_device->tablet_tool_proximity.link); @@ -525,6 +528,12 @@ static void handle_touch_cancel(struct wl_listener *listener, void *data) { wlr_signal_emit_safe(&device->cursor->events.touch_cancel, event); } +static void handle_touch_frame(struct wl_listener *listener, void *data) { + struct wlr_cursor_device *device = + wl_container_of(listener, device, touch_frame); + wlr_signal_emit_safe(&device->cursor->events.touch_frame, NULL); +} + static void handle_tablet_tool_tip(struct wl_listener *listener, void *data) { struct wlr_event_tablet_tool_tip *event = data; struct wlr_cursor_device *device; @@ -663,6 +672,9 @@ static struct wlr_cursor_device *cursor_device_create( wl_signal_add(&device->touch->events.cancel, &c_device->touch_cancel); c_device->touch_cancel.notify = handle_touch_cancel; + + wl_signal_add(&device->touch->events.frame, &c_device->touch_frame); + c_device->touch_frame.notify = handle_touch_frame; } else if (device->type == WLR_INPUT_DEVICE_TABLET_TOOL) { wl_signal_add(&device->tablet->events.tip, &c_device->tablet_tool_tip);