From 351e5ed6d7983f011d81835e4be10f5d7631ac9d Mon Sep 17 00:00:00 2001 From: Tadeo Kondrak Date: Sun, 29 Dec 2019 04:10:51 -0700 Subject: [PATCH] Add support for cursor axis and frame events (#15) For scrolling support. --- include/input/cursor.h | 2 ++ kiwmi/input/cursor.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/input/cursor.h b/include/input/cursor.h index df06f1f..532afcd 100644 --- a/include/input/cursor.h +++ b/include/input/cursor.h @@ -18,6 +18,8 @@ struct kiwmi_cursor { struct wl_listener cursor_motion; struct wl_listener cursor_motion_absolute; struct wl_listener cursor_button; + struct wl_listener cursor_axis; + struct wl_listener cursor_frame; }; struct kiwmi_cursor *cursor_create( diff --git a/kiwmi/input/cursor.c b/kiwmi/input/cursor.c index 91fc8df..2277be6 100644 --- a/kiwmi/input/cursor.c +++ b/kiwmi/input/cursor.c @@ -110,6 +110,35 @@ cursor_button_notify(struct wl_listener *listener, void *data) } } +static void +cursor_axis_notify(struct wl_listener *listener, void *data) +{ + struct kiwmi_cursor *cursor = + wl_container_of(listener, cursor, cursor_axis); + struct kiwmi_server *server = cursor->server; + struct kiwmi_input *input = &server->input; + struct wlr_event_pointer_axis *event = data; + + wlr_seat_pointer_notify_axis( + input->seat, + event->time_msec, + event->orientation, + event->delta, + event->delta_discrete, + event->source); +} + +static void +cursor_frame_notify(struct wl_listener *listener, void *UNUSED(data)) +{ + struct kiwmi_cursor *cursor = + wl_container_of(listener, cursor, cursor_frame); + struct kiwmi_server *server = cursor->server; + struct kiwmi_input *input = &server->input; + + wlr_seat_pointer_notify_frame(input->seat); +} + struct kiwmi_cursor * cursor_create( struct kiwmi_server *server, @@ -147,5 +176,11 @@ cursor_create( cursor->cursor_button.notify = cursor_button_notify; wl_signal_add(&cursor->cursor->events.button, &cursor->cursor_button); + cursor->cursor_axis.notify = cursor_axis_notify; + wl_signal_add(&cursor->cursor->events.axis, &cursor->cursor_axis); + + cursor->cursor_frame.notify = cursor_frame_notify; + wl_signal_add(&cursor->cursor->events.frame, &cursor->cursor_frame); + return cursor; }