WM: handle multiple wheel events from GHOST
Scrolling the mouse wheel fast can generate multiple click-steps which were ignored by window manager events. This meant scrolling fast with a trackpad (with "Multi-touch gestures" disabled) for e.g. would zoom less than the gesture made more slowly.
This commit is contained in:
parent
c4745a24b2
commit
c9a79f9a3c
@ -3879,9 +3879,8 @@ static void pointer_handle_frame(void *data, wl_pointer * /*wl_pointer*/)
|
||||
if (seat->pointer_scroll.discrete_xy[1]) {
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl.surface_window) {
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
const int32_t discrete = seat->pointer_scroll.discrete_xy[1];
|
||||
seat->system->pushEvent_maybe_pending(
|
||||
new GHOST_EventWheel(event_ms, win, std::signbit(discrete) ? +1 : -1));
|
||||
new GHOST_EventWheel(event_ms, win, seat->pointer_scroll.discrete_xy[1]));
|
||||
}
|
||||
}
|
||||
seat->pointer_scroll.discrete_xy[0] = 0;
|
||||
|
@ -5872,15 +5872,28 @@ void wm_event_add_ghostevent(wmWindowManager *wm,
|
||||
const GHOST_TEventWheelData *wheelData = static_cast<const GHOST_TEventWheelData *>(
|
||||
customdata);
|
||||
|
||||
int click_step;
|
||||
if (wheelData->z > 0) {
|
||||
event.type = WHEELUPMOUSE;
|
||||
click_step = wheelData->z;
|
||||
}
|
||||
else {
|
||||
event.type = WHEELDOWNMOUSE;
|
||||
click_step = -wheelData->z;
|
||||
}
|
||||
BLI_assert(click_step != 0);
|
||||
|
||||
/* Avoid generating a large number of events.
|
||||
* In practice this values is typically 1, sometimes 2-3, even 32 is very high
|
||||
* although this could happen if the system freezes. */
|
||||
click_step = std::min(click_step, 32);
|
||||
|
||||
/* TODO: support a wheel event that includes the number of steps
|
||||
* instead of generating multiple events. */
|
||||
event.val = KM_PRESS;
|
||||
wm_event_add(win, &event);
|
||||
for (int i = 0; i < click_step; i++) {
|
||||
wm_event_add(win, &event);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user