Skip to content

Commit

Permalink
GTK: Handle smooth scrolling according to the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ruevs committed Aug 17, 2024
1 parent 31d0c27 commit a17fb15
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/platform/guigtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,19 +571,22 @@ class GtkGLWidget : public Gtk::GLArea {
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;
}
Expand Down

0 comments on commit a17fb15

Please sign in to comment.