kranewl

A wlroots-based dynamic Wayland compositor, written in C++, configurable with Lua
git clone git://git.deurzen.net/kranewl
Log | Files | Refs | LICENSE

commit 525244b9d582743727fc1fa841de2b882d242942
parent ec0a8ba81c947462274ba3764cb37b7167b8ce23
Author: deurzen <max@deurzen.net>
Date:   Sun, 29 May 2022 09:37:48 +0200

relays axis events to cursor binding handler

Diffstat:
Msrc/kranewl/input/cursor.cc | 42++++++++++++++++++++++++++++++++++--------
1 file changed, 34 insertions(+), 8 deletions(-)

diff --git a/src/kranewl/input/cursor.cc b/src/kranewl/input/cursor.cc @@ -365,14 +365,40 @@ Cursor::handle_cursor_axis(struct wl_listener* listener, void* data) struct wlr_event_pointer_axis* event = reinterpret_cast<struct wlr_event_pointer_axis*>(data); - wlr_seat_pointer_notify_axis( - cursor->mp_seat->mp_wlr_seat, - event->time_msec, - event->orientation, - event->delta, - event->delta_discrete, - event->source - ); + struct wlr_keyboard* keyboard + = wlr_seat_get_keyboard(cursor->mp_seat->mp_wlr_seat); + + uint32_t button; + uint32_t modifiers = keyboard + ? wlr_keyboard_get_modifiers(keyboard) + : 0; + + if (modifiers) + switch (event->orientation) { + case WLR_AXIS_ORIENTATION_VERTICAL: + { + button = event->delta < 0 + ? CursorInput::Button::ScrollUp + : CursorInput::Button::ScrollDown; + break; + } + case WLR_AXIS_ORIENTATION_HORIZONTAL: + button = event->delta < 0 + ? CursorInput::Button::ScrollLeft + : CursorInput::Button::ScrollRight; + break; + default: button = 0; break; + } + + if (!process_cursorbinding(cursor, button, modifiers)) + wlr_seat_pointer_notify_axis( + cursor->mp_seat->mp_wlr_seat, + event->time_msec, + event->orientation, + event->delta, + event->delta_discrete, + event->source + ); } void