GTK: Handle smooth scrolling according to the documentation

pull/1470/head
ruevs 2024-07-07 17:03:57 +03:00
parent a431c8b474
commit da71570570
1 changed files with 12 additions and 9 deletions

View File

@ -571,22 +571,25 @@ protected:
bool on_scroll_event(GdkEventScroll *gdk_event) override { bool on_scroll_event(GdkEventScroll *gdk_event) override {
double dx, dy; double dx, dy;
GdkScrollDirection dir; GdkScrollDirection dir;
double delta;
// for gtk4 ?? // for gtk4 ??
// gdk_scroll_event_get_deltas((GdkEvent*)gdk_event, &dx, &dy); // gdk_scroll_event_get_deltas((GdkEvent*)gdk_event, &dx, &dy);
// gdk_scroll_event_get_direction((GdkEvent*)gdk_event, &dir); // 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(gdk_event_get_scroll_deltas((GdkEvent*)gdk_event, &dx, &dy)) {
if(abs(dy) > 0) {
delta = dy; delta = dy;
} else if(dir == GDK_SCROLL_UP) { } else if(gdk_event_get_scroll_direction((GdkEvent*)gdk_event, &dir)) {
if(dir == GDK_SCROLL_UP) {
delta = 1; delta = 1;
} else if(dir == GDK_SCROLL_DOWN) { } else if(dir == GDK_SCROLL_DOWN) {
delta = -1; delta = -1;
} else { } else {
return false; return false;
} }
} else {
return false;
}
double x,y; double x,y;
gdk_event_get_coords((GdkEvent*)gdk_event, &x, &y); gdk_event_get_coords((GdkEvent*)gdk_event, &x, &y);