Commit 8b71d326 authored by Michael Natterer's avatar Michael Natterer

app: fix GimpControllerWheel for smooth scrolling events

gimp_controller_wheel_scroll(): attempt to translate smooth scroll
deltas to GdkScrollDirection, controller events are always discrete
steps.

Works fine on X11, no idea how it behaves on other backends, please
check and report.
parent 432a8847
......@@ -260,18 +260,42 @@ gboolean
gimp_controller_wheel_scroll (GimpControllerWheel *wheel,
const GdkEventScroll *sevent)
{
gint i;
GdkScrollDirection direction;
GdkModifierType state;
gint i;
g_return_val_if_fail (GIMP_IS_CONTROLLER_WHEEL (wheel), FALSE);
g_return_val_if_fail (sevent != NULL, FALSE);
gdk_event_get_state ((const GdkEvent *) sevent, &state);
if (! gdk_event_get_scroll_direction ((const GdkEvent *) sevent, &direction))
{
gdouble dx = 0.0;
gdouble dy = 0.0;
if (! gdk_event_get_scroll_deltas ((const GdkEvent *) sevent, &dx, &dy))
return FALSE;
if (dy <= -1.0)
direction = GDK_SCROLL_UP;
else if (dy >= 1.0)
direction = GDK_SCROLL_DOWN;
else if (dx <= -1.0)
direction = GDK_SCROLL_LEFT;
else if (dx >= 1.0)
direction = GDK_SCROLL_RIGHT;
else
return FALSE;
}
/* start with the last event because the last ones in the
* up,down,left,right groups have the most keyboard modifiers
*/
for (i = G_N_ELEMENTS (wheel_events) - 1; i >= 0; i--)
{
if (wheel_events[i].direction == sevent->direction &&
(wheel_events[i].modifiers & sevent->state) ==
if (wheel_events[i].direction == direction &&
(wheel_events[i].modifiers & state) ==
wheel_events[i].modifiers)
{
GimpControllerEvent controller_event;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment