Browse Source

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.
pull/767/head
Albrecht Schlosser 2 years ago
parent
commit
3c7610ec23
  1. 10
      src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx

10
src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx

@ -347,13 +347,23 @@ static void pointer_axis(void *data,
// 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 // allow both horizontal and vertical movements to be processed by the widget
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) { if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
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_dx = delta;
Fl::e_dy = 0; Fl::e_dy = 0;
}
Fl::handle(FL_MOUSEWHEEL, win->top_window()); Fl::handle(FL_MOUSEWHEEL, win->top_window());
} }
if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) { if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) {
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_dx = 0;
Fl::e_dy = delta; Fl::e_dy = delta;
}
Fl::handle(FL_MOUSEWHEEL, win->top_window()); Fl::handle(FL_MOUSEWHEEL, win->top_window());
} }
} }

Loading…
Cancel
Save