mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 06:21:14 +00:00
GDK W32: Support smooth scrolling
Set delta_x or delta_y for GdkScrollEvent. HIWORD (wParam) in WM_MOUSE(H)WHEEL is the scroll delta. A delta value of WHEEL_DELTA (which is 120) means scrolling one full unit of something (for example, a line). The delta should also be multiplied by the value that the SystemParametersInfo (SPI_GETWHEELSCROLL(LINES|CHARS), 0, &value, 0) call gives back, unless it gives back 0xffffffff, in which case it indicates that scrolling is page- or screen-based, not line-based (GDK doesn't support that at the moment). Also, all deltas should be inverted, since MS sends negative deltas when scrolling down (rotating the wheel back, in the direction of the user). With deltas set the mode should be set to GDK_SCROLL_SMOOTH. Fixes issue 1263.
This commit is contained in:
parent
9008f7702d
commit
359df028be
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user