forked from AuroraMiddleware/gtk
Merge branch 'win32-smooth-scrolling-gtk4' into 'master'
GDK W32: Support smooth scrolling (GTK4) See merge request GNOME/gtk!298
This commit is contained in:
commit
62b887e064
@ -2712,13 +2712,35 @@ gdk_event_translate (MSG *msg,
|
||||
|
||||
event = gdk_event_new (GDK_SCROLL);
|
||||
event->any.surface = 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->surface_scale;
|
||||
event->scroll.y = (gint16) point.y / impl->surface_scale;
|
||||
|
Loading…
Reference in New Issue
Block a user