diff --git a/examples/pointer.c b/examples/pointer.c index 6eb328ac2..a8f60e629 100644 --- a/examples/pointer.c +++ b/examples/pointer.c @@ -363,16 +363,16 @@ int main(int argc, char *argv[]) { state.cursor_axis.notify = handle_cursor_axis; // touch events - wl_signal_add(&state.cursor->events.touch_up, &state.touch_up); + wl_signal_add(&state.cursor->touch.events.up, &state.touch_up); state.touch_up.notify = handle_touch_up; - wl_signal_add(&state.cursor->events.touch_down, &state.touch_down); + wl_signal_add(&state.cursor->touch.events.down, &state.touch_down); state.touch_down.notify = handle_touch_down; - wl_signal_add(&state.cursor->events.touch_motion, &state.touch_motion); + wl_signal_add(&state.cursor->touch.events.motion, &state.touch_motion); state.touch_motion.notify = handle_touch_motion; - wl_signal_add(&state.cursor->events.touch_cancel, &state.touch_cancel); + wl_signal_add(&state.cursor->touch.events.cancel, &state.touch_cancel); state.touch_cancel.notify = handle_touch_cancel; wl_signal_add(&wlr->events.new_input, &state.new_input); diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h index 06ae2f1f0..999525517 100644 --- a/include/wlr/types/wlr_cursor.h +++ b/include/wlr/types/wlr_cursor.h @@ -12,6 +12,7 @@ #include #include #include +#include struct wlr_input_device; @@ -33,6 +34,8 @@ struct wlr_cursor { struct wlr_cursor_state *state; double x, y; + struct wlr_touch touch; + /** * The interpretation of these signals is the responsibility of the * compositor, but some helpers are provided for your benefit. If you @@ -62,12 +65,6 @@ struct wlr_cursor { struct wl_signal hold_begin; struct wl_signal hold_end; - struct wl_signal touch_up; - 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; struct wl_signal tablet_tool_tip; diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index d38d279ef..0a8f19bf1 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -3,13 +3,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include #include #include "util/signal.h" @@ -70,6 +70,10 @@ struct wlr_cursor_state { struct wl_listener layout_destroy; }; +static const struct wlr_touch_impl touch_impl = { + .name = "wlr-cursor", +}; + struct wlr_cursor *wlr_cursor_create(void) { struct wlr_cursor *cur = calloc(1, sizeof(struct wlr_cursor)); if (!cur) { @@ -90,6 +94,8 @@ struct wlr_cursor *wlr_cursor_create(void) { wl_list_init(&cur->state->devices); wl_list_init(&cur->state->output_cursors); + wlr_touch_init(&cur->touch, &touch_impl, "cursor"); + // pointer signals wl_signal_init(&cur->events.motion); wl_signal_init(&cur->events.motion_absolute); @@ -105,13 +111,6 @@ struct wlr_cursor *wlr_cursor_create(void) { wl_signal_init(&cur->events.hold_begin); wl_signal_init(&cur->events.hold_end); - // touch signals - wl_signal_init(&cur->events.touch_up); - 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); wl_signal_init(&cur->events.tablet_tool_axis); @@ -192,6 +191,8 @@ void wlr_cursor_destroy(struct wlr_cursor *cur) { cursor_device_destroy(device); } + wlr_touch_finish(&cur->touch); + free(cur->state); free(cur); } @@ -513,7 +514,7 @@ static void handle_touch_up(struct wl_listener *listener, void *data) { struct wlr_touch_up_event *event = data; struct wlr_cursor_device *device; device = wl_container_of(listener, device, touch_up); - wlr_signal_emit_safe(&device->cursor->events.touch_up, event); + wlr_signal_emit_safe(&device->cursor->touch.events.up, event); } static void handle_touch_down(struct wl_listener *listener, void *data) { @@ -526,7 +527,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) { if (output) { apply_output_transform(&event->x, &event->y, output->transform); } - wlr_signal_emit_safe(&device->cursor->events.touch_down, event); + wlr_signal_emit_safe(&device->cursor->touch.events.down, event); } static void handle_touch_motion(struct wl_listener *listener, void *data) { @@ -539,20 +540,20 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) { if (output) { apply_output_transform(&event->x, &event->y, output->transform); } - wlr_signal_emit_safe(&device->cursor->events.touch_motion, event); + wlr_signal_emit_safe(&device->cursor->touch.events.motion, event); } static void handle_touch_cancel(struct wl_listener *listener, void *data) { struct wlr_touch_cancel_event *event = data; struct wlr_cursor_device *device; device = wl_container_of(listener, device, touch_cancel); - wlr_signal_emit_safe(&device->cursor->events.touch_cancel, event); + wlr_signal_emit_safe(&device->cursor->touch.events.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); + wlr_signal_emit_safe(&device->cursor->touch.events.frame, NULL); } static void handle_tablet_tool_tip(struct wl_listener *listener, void *data) {