From 5e379370ae0653c229308e1d7af31a54739ccc7e Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 15 May 2012 16:23:10 +0200 Subject: Bug #671585 - Add support for smooth scrolling devices --- widgets/misc/e-web-view-gtkhtml.c | 22 +++++++++++++++++++++- widgets/misc/e-web-view.c | 22 +++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) (limited to 'widgets/misc') diff --git a/widgets/misc/e-web-view-gtkhtml.c b/widgets/misc/e-web-view-gtkhtml.c index be8b1c596f..bca66a72a3 100644 --- a/widgets/misc/e-web-view-gtkhtml.c +++ b/widgets/misc/e-web-view-gtkhtml.c @@ -852,7 +852,27 @@ web_view_gtkhtml_scroll_event (GtkWidget *widget, GdkEventScroll *event) { if (event->state & GDK_CONTROL_MASK) { - switch (event->direction) { + GdkScrollDirection direction = event->direction; + + #if GTK_CHECK_VERSION(3,3,18) + if (direction == GDK_SCROLL_SMOOTH) { + static gdouble total_delta_y = 0.0; + + total_delta_y += event->delta_y; + + if (total_delta_y >= 1.0) { + total_delta_y = 0.0; + direction = GDK_SCROLL_DOWN; + } else if (total_delta_y <= -1.0) { + total_delta_y = 0.0; + direction = GDK_SCROLL_UP; + } else { + return FALSE; + } + } + #endif + + switch (direction) { case GDK_SCROLL_UP: gtk_html_zoom_in (GTK_HTML (widget)); return TRUE; diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c index f58b5d44de..07f8357609 100644 --- a/widgets/misc/e-web-view.c +++ b/widgets/misc/e-web-view.c @@ -969,7 +969,27 @@ web_view_scroll_event (GtkWidget *widget, GdkEventScroll *event) { if (event->state & GDK_CONTROL_MASK) { - switch (event->direction) { + GdkScrollDirection direction = event->direction; + + #if GTK_CHECK_VERSION(3,3,18) + if (direction == GDK_SCROLL_SMOOTH) { + static gdouble total_delta_y = 0.0; + + total_delta_y += event->delta_y; + + if (total_delta_y >= 1.0) { + total_delta_y = 0.0; + direction = GDK_SCROLL_DOWN; + } else if (total_delta_y <= -1.0) { + total_delta_y = 0.0; + direction = GDK_SCROLL_UP; + } else { + return FALSE; + } + } + #endif + + switch (direction) { case GDK_SCROLL_UP: e_web_view_zoom_in (E_WEB_VIEW (widget)); return TRUE; -- cgit v1.2.3