diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index c050b9d64c..beaac53f49 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -3071,13 +3071,35 @@ gdk_event_translate (MSG *msg, event = gdk_event_new (GDK_SCROLL); event->scroll.window = window; + event->scroll.direction = GDK_SCROLL_SMOOTH; if (msg->message == WM_MOUSEWHEEL) - event->scroll.direction = (((short) HIWORD (msg->wParam)) > 0) ? - GDK_SCROLL_UP : GDK_SCROLL_DOWN; + { + UINT lines_multiplier = 3; + event->scroll.delta_y = (gdouble) GET_WHEEL_DELTA_WPARAM (msg->wParam) / (gdouble) WHEEL_DELTA; + /* -1 means that we should scroll in screens, not lines. + * Right now GDK doesn't support that. + */ + if (SystemParametersInfo (SPI_GETWHEELSCROLLLINES, 0, &lines_multiplier, 0) && + lines_multiplier != (UINT) -1) + event->scroll.delta_y *= (gdouble) lines_multiplier; + } else if (msg->message == WM_MOUSEHWHEEL) - event->scroll.direction = (((short) HIWORD (msg->wParam)) > 0) ? - GDK_SCROLL_RIGHT : GDK_SCROLL_LEFT; + { + UINT chars_multiplier = 3; + event->scroll.delta_x = (gdouble) GET_WHEEL_DELTA_WPARAM (msg->wParam) / (gdouble) WHEEL_DELTA; + /* There doesn't seem to be any indication that + * h-scroll has an equivalent of the "screen" mode, + * indicated by multiplier being (UINT) -1. + */ + if (SystemParametersInfo (SPI_GETWHEELSCROLLCHARS, 0, &chars_multiplier, 0)) + event->scroll.delta_x *= (gdouble) chars_multiplier; + } + /* It seems that delta values given by Windows are + * inverted (positive delta scrolls up, not down). + */ + event->scroll.delta_x *= -1.0; + event->scroll.delta_y *= -1.0; event->scroll.time = _gdk_win32_get_next_tick (msg->time); event->scroll.x = (gint16) point.x / impl->window_scale; event->scroll.y = (gint16) point.y / impl->window_scale;