diff options
author | Milan Crha <mcrha@redhat.com> | 2012-05-15 22:23:10 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2012-05-15 22:24:29 +0800 |
commit | 5e379370ae0653c229308e1d7af31a54739ccc7e (patch) | |
tree | a9079e286e9e6a006d58ffa064d53d50091aab03 /widgets | |
parent | 0f7f848300bb2282cde20777c26168bdffe2d955 (diff) | |
download | gsoc2013-evolution-5e379370ae0653c229308e1d7af31a54739ccc7e.tar gsoc2013-evolution-5e379370ae0653c229308e1d7af31a54739ccc7e.tar.gz gsoc2013-evolution-5e379370ae0653c229308e1d7af31a54739ccc7e.tar.bz2 gsoc2013-evolution-5e379370ae0653c229308e1d7af31a54739ccc7e.tar.lz gsoc2013-evolution-5e379370ae0653c229308e1d7af31a54739ccc7e.tar.xz gsoc2013-evolution-5e379370ae0653c229308e1d7af31a54739ccc7e.tar.zst gsoc2013-evolution-5e379370ae0653c229308e1d7af31a54739ccc7e.zip |
Bug #671585 - Add support for smooth scrolling devices
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/misc/e-web-view-gtkhtml.c | 22 | ||||
-rw-r--r-- | widgets/misc/e-web-view.c | 22 |
2 files changed, 42 insertions, 2 deletions
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; |