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 | |
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
-rw-r--r-- | calendar/gui/e-day-view.c | 32 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 8 | ||||
-rw-r--r-- | libgnomecanvas/gnome-canvas.c | 1 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-view-private.c | 31 | ||||
-rw-r--r-- | widgets/misc/e-web-view-gtkhtml.c | 22 | ||||
-rw-r--r-- | widgets/misc/e-web-view.c | 22 |
6 files changed, 108 insertions, 8 deletions
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index ad7fd78cd3..be096b5e6b 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -3276,6 +3276,14 @@ e_day_view_on_main_canvas_scroll (GtkWidget *widget, case GDK_SCROLL_DOWN: e_day_view_scroll (day_view, -E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE); return TRUE; + #if GTK_CHECK_VERSION(3,3,18) + case GDK_SCROLL_SMOOTH: + if (scroll->delta_y < -0.001 || scroll->delta_y > 0.001) { + e_day_view_scroll (day_view, -E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE * scroll->delta_y); + return TRUE; + } + break; + #endif default: break; } @@ -3295,9 +3303,19 @@ e_day_view_on_top_canvas_scroll (GtkWidget *widget, case GDK_SCROLL_DOWN: e_day_view_top_scroll (day_view, -E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE); return TRUE; + #if GTK_CHECK_VERSION(3,3,18) + case GDK_SCROLL_SMOOTH: + if (scroll->delta_y < -0.001 || scroll->delta_y > 0.001) { + e_day_view_top_scroll (day_view, -E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE * scroll->delta_y); + return TRUE; + } + break; + #endif default: - return FALSE; + break; } + + return FALSE; } static gboolean @@ -3319,9 +3337,19 @@ e_day_view_on_time_canvas_scroll (GtkWidget *widget, case GDK_SCROLL_DOWN: e_day_view_scroll (day_view, -E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE); return TRUE; + #if GTK_CHECK_VERSION(3,3,18) + case GDK_SCROLL_SMOOTH: + if (scroll->delta_y < -0.001 || scroll->delta_y > 0.001) { + e_day_view_scroll (day_view, -E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE * scroll->delta_y); + return TRUE; + } + break; + #endif default: - return FALSE; + break; } + + return FALSE; } static gboolean diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 3feacccfda..dd419d289c 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -2532,6 +2532,14 @@ e_week_view_on_scroll (GtkWidget *widget, case GDK_SCROLL_DOWN: new_value = value + page_increment; break; + #if GTK_CHECK_VERSION(3,3,18) + case GDK_SCROLL_SMOOTH: + if (scroll->delta_y < -0.001 || scroll->delta_y > 0.001) { + new_value = value + scroll->delta_y; + break; + } + return FALSE; + #endif default: return FALSE; } diff --git a/libgnomecanvas/gnome-canvas.c b/libgnomecanvas/gnome-canvas.c index 1b4019b7b4..ba49c09caf 100644 --- a/libgnomecanvas/gnome-canvas.c +++ b/libgnomecanvas/gnome-canvas.c @@ -2027,6 +2027,7 @@ gnome_canvas_realize (GtkWidget *widget) gdk_window_set_events (bin_window, (gdk_window_get_events (bin_window) | GDK_EXPOSURE_MASK + | GDK_SCROLL_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c index 4526570202..c256c9aebe 100644 --- a/modules/calendar/e-cal-shell-view-private.c +++ b/modules/calendar/e-cal-shell-view-private.c @@ -202,19 +202,40 @@ cal_shell_view_date_navigator_selection_changed_cb (ECalShellView *cal_shell_vie gnome_calendar_notify_dates_shown_changed (calendar); } -static void +static gboolean cal_shell_view_date_navigator_scroll_event_cb (ECalShellView *cal_shell_view, GdkEventScroll *event, ECalendar *date_navigator) { ECalendarItem *calitem; GDate start_date, end_date; + GdkScrollDirection direction; calitem = date_navigator->calitem; if (!e_calendar_item_get_selection (calitem, &start_date, &end_date)) - return; + return FALSE; + + 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; - switch (event->direction) { + 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: g_date_subtract_months (&start_date, 1); g_date_subtract_months (&end_date, 1); @@ -226,7 +247,7 @@ cal_shell_view_date_navigator_scroll_event_cb (ECalShellView *cal_shell_view, break; default: - g_return_if_reached (); + g_return_val_if_reached (FALSE); } /* XXX Does ECalendarItem emit a signal for this? If so, maybe @@ -235,6 +256,8 @@ cal_shell_view_date_navigator_scroll_event_cb (ECalShellView *cal_shell_view, cal_shell_view_date_navigator_selection_changed_cb ( cal_shell_view, calitem); + + return TRUE; } static void 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; |