From da71570570246bf28a2c811957cf6878445e0fe7 Mon Sep 17 00:00:00 2001 From: ruevs Date: Sun, 7 Jul 2024 17:03:57 +0300 Subject: [PATCH] GTK: Handle smooth scrolling according to the documentation --- src/platform/guigtk.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/platform/guigtk.cpp b/src/platform/guigtk.cpp index 9ee0571b..89a29d94 100644 --- a/src/platform/guigtk.cpp +++ b/src/platform/guigtk.cpp @@ -571,19 +571,22 @@ protected: bool on_scroll_event(GdkEventScroll *gdk_event) override { double dx, dy; GdkScrollDirection dir; + double delta; + // for gtk4 ?? // gdk_scroll_event_get_deltas((GdkEvent*)gdk_event, &dx, &dy); // gdk_scroll_event_get_direction((GdkEvent*)gdk_event, &dir); - gdk_event_get_scroll_direction((GdkEvent*)gdk_event, &dir); - gdk_event_get_scroll_deltas((GdkEvent*)gdk_event, &dx, &dy); - - double delta; - if(abs(dy) > 0) { + + if(gdk_event_get_scroll_deltas((GdkEvent*)gdk_event, &dx, &dy)) { delta = dy; - } else if(dir == GDK_SCROLL_UP) { - delta = 1; - } else if(dir == GDK_SCROLL_DOWN) { - delta = -1; + } else if(gdk_event_get_scroll_direction((GdkEvent*)gdk_event, &dir)) { + if(dir == GDK_SCROLL_UP) { + delta = 1; + } else if(dir == GDK_SCROLL_DOWN) { + delta = -1; + } else { + return false; + } } else { return false; }