GTK: Handle smooth scrolling according to the documentation
parent
a431c8b474
commit
da71570570
|
@ -571,19 +571,22 @@ 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);
|
if(gdk_event_get_scroll_deltas((GdkEvent*)gdk_event, &dx, &dy)) {
|
||||||
|
|
||||||
double delta;
|
|
||||||
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)) {
|
||||||
delta = 1;
|
if(dir == GDK_SCROLL_UP) {
|
||||||
} else if(dir == GDK_SCROLL_DOWN) {
|
delta = 1;
|
||||||
delta = -1;
|
} else if(dir == GDK_SCROLL_DOWN) {
|
||||||
|
delta = -1;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue