From 3c7610ec2336a2ab2b264d73feca89afbcfc61d2 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Mon, 14 Aug 2023 16:56:24 +0200 Subject: Handle shift + mousewheel event on Wayland (STR 3521) Pressing the shift key while using the mousewheel changes horizontal to vertical scrolling and vice versa. This allows users with a standard mouse with only one scrollwheel to use it for both scrolling directions. This concludes "handling shift + mousewheel" for all supported platforms. --- src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx index 204a058ca..ba8f4c386 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx @@ -344,16 +344,26 @@ static void pointer_axis(void *data, if (!win) return; wld_event_time = time; int delta = wl_fixed_to_int(value) / 10; -//fprintf(stderr, "FL_MOUSEWHEEL: %c delta=%d\n", axis==WL_POINTER_AXIS_HORIZONTAL_SCROLL?'H':'V', delta); + // fprintf(stderr, "FL_MOUSEWHEEL: %c delta=%d\n", axis==WL_POINTER_AXIS_HORIZONTAL_SCROLL?'H':'V', delta); // allow both horizontal and vertical movements to be processed by the widget if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) { - Fl::e_dx = delta; - Fl::e_dy = 0; + if (Fl::event_shift()) { // shift key pressed: send vertical mousewheel event + Fl::e_dx = 0; + Fl::e_dy = delta; + } else { // shift key not pressed (normal behavior): send horizontal mousewheel event + Fl::e_dx = delta; + Fl::e_dy = 0; + } Fl::handle(FL_MOUSEWHEEL, win->top_window()); } if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) { - Fl::e_dx = 0; - Fl::e_dy = delta; + if (Fl::event_shift()) { // shift key pressed: send horizontal mousewheel event + Fl::e_dx = delta; + Fl::e_dy = 0; + } else {// shift key not pressed (normal behavior): send vertical mousewheel event + Fl::e_dx = 0; + Fl::e_dy = delta; + } Fl::handle(FL_MOUSEWHEEL, win->top_window()); } } -- cgit v1.2.3