diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-07-24 21:36:57 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-07-24 21:36:57 +0200 |
commit | 2c69937ef581fdf434192201785cc3b32ad9b2e5 (patch) | |
tree | 72b87038f93a0a4011871e42599eaddd4043d798 /src | |
parent | 4e4ba6702567a366f2eb10e46fdde6fd064ee100 (diff) | |
download | tdv-2c69937ef581fdf434192201785cc3b32ad9b2e5.tar.gz tdv-2c69937ef581fdf434192201785cc3b32ad9b2e5.tar.xz tdv-2c69937ef581fdf434192201785cc3b32ad9b2e5.zip |
sdgui: use smooth scrolling
Diffstat (limited to 'src')
-rw-r--r-- | src/stardict-view.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/stardict-view.c b/src/stardict-view.c index 1e65b0c..a6f7733 100644 --- a/src/stardict-view.c +++ b/src/stardict-view.c @@ -395,9 +395,8 @@ stardict_view_realize (GtkWidget *widget) // but it merely seems to involve more work. .wclass = GDK_INPUT_OUTPUT, .visual = gtk_widget_get_visual (widget), - - // GDK_SMOOTH_SCROLL_MASK is useless, will stop sending UP/DOWN - .event_mask = gtk_widget_get_events (widget) | GDK_SCROLL_MASK, + .event_mask = gtk_widget_get_events (widget) | GDK_SCROLL_MASK + | GDK_SMOOTH_SCROLL_MASK, }; // We need this window to receive input events at all. @@ -487,9 +486,14 @@ stardict_view_scroll_event (GtkWidget *widget, GdkEventScroll *event) stardict_view_scroll (self, GTK_SCROLL_STEPS, +3); return TRUE; case GDK_SCROLL_SMOOTH: - self->top_offset += event->delta_y; - adjust_for_offset (self); + { + // On GDK/Wayland, the mouse wheel will typically create 1.5 deltas, + // after dividing a 15 degree click angle from libinput by 10. + // On X11, as libinput(4) indicates, the delta will always be 1.0. + double delta = CLAMP(event->delta_y, -1, +1); + stardict_view_scroll (self, GTK_SCROLL_STEPS, 3 * delta); return TRUE; + } default: return FALSE; } |