diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2023-08-14 16:56:24 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2023-08-14 16:57:33 +0200 |
| commit | 3c7610ec2336a2ab2b264d73feca89afbcfc61d2 (patch) | |
| tree | ac5c7226d57aba55934c3b85fd75b9f5ad33c88b | |
| parent | 847901623a55d69fc8c0c4b7770ec33698402e3a (diff) | |
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.
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 20 |
1 files 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()); } } |
