[gimp] app: fix GimpControllerWheel for smooth scrolling events
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: fix GimpControllerWheel for smooth scrolling events
- Date: Sun, 15 Jul 2018 11:59:55 +0000 (UTC)
commit 8b71d326597c7cde985392859d4083fac8bb1ebf
Author: Michael Natterer <mitch gimp org>
Date: Sun Jul 15 13:56:44 2018 +0200
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.
app/widgets/gimpcontrollerwheel.c | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/app/widgets/gimpcontrollerwheel.c b/app/widgets/gimpcontrollerwheel.c
index 473bb6e8ce..a91f6a802f 100644
--- a/app/widgets/gimpcontrollerwheel.c
+++ b/app/widgets/gimpcontrollerwheel.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]