mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
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.
This commit is contained in:
parent
432a884715
commit
8b71d32659
1 changed files with 27 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue