diff options
-rw-r--r-- | examples/compositor.c | 9 | ||||
-rw-r--r-- | include/wlr/types/wlr_seat.h | 3 | ||||
-rw-r--r-- | types/wlr_seat.c | 19 |
3 files changed, 27 insertions, 4 deletions
diff --git a/examples/compositor.c b/examples/compositor.c index 085cbb0e..ad3dd995 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -417,10 +417,11 @@ static void handle_cursor_motion_absolute(struct wl_listener *listener, } static void handle_cursor_axis(struct wl_listener *listener, void *data) { - //struct sample_state *sample = - //wl_container_of(listener, sample, cursor_axis); - //struct wlr_event_pointer_axis *event = data; - wlr_log(L_DEBUG, "TODO: handle cursor axis"); + struct sample_state *sample = + wl_container_of(listener, sample, cursor_axis); + struct wlr_event_pointer_axis *event = data; + wlr_seat_pointer_send_axis(sample->wl_seat, event->time_sec, + event->orientation, event->delta); } static void handle_cursor_button(struct wl_listener *listener, void *data) { diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 4b433ccb..f992b2f2 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -109,4 +109,7 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time, void wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time, uint32_t button, uint32_t state); +void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time, + enum wlr_axis_orientation orientation, double value); + #endif diff --git a/types/wlr_seat.c b/types/wlr_seat.c index 64f9e83b..54b55ba9 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -352,3 +352,22 @@ void wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time, serial, time, button, state); wl_pointer_send_frame(wlr_seat->pointer_state.focused_handle->pointer); } + +void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time, + enum wlr_axis_orientation orientation, double value) { + if (!wlr_seat_pointer_has_focus_resource(wlr_seat)) { + return; + } + + struct wl_resource *pointer = + wlr_seat->pointer_state.focused_handle->pointer; + + if (value) { + wl_pointer_send_axis(pointer, time, orientation, + wl_fixed_from_double(value)); + } else { + wl_pointer_send_axis_stop(pointer, time, orientation); + } + + wl_pointer_send_frame(pointer); +} |