[evolution/gnome-3-4] Bug #671585 - Add support for smooth scrolling devices
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-3-4] Bug #671585 - Add support for smooth scrolling devices
- Date: Tue, 15 May 2012 14:25:15 +0000 (UTC)
commit 9cc518864da6dc5898617be0b17bfdc59f892811
Author: Milan Crha <mcrha redhat com>
Date: Tue May 15 16:24:48 2012 +0200
Bug #671585 - Add support for smooth scrolling devices
calendar/gui/e-day-view.c | 32 +++++++++++++++++++++++++-
calendar/gui/e-week-view.c | 8 ++++++
libgnomecanvas/gnome-canvas.c | 1 +
modules/calendar/e-cal-shell-view-private.c | 31 ++++++++++++++++++++++---
widgets/misc/e-web-view.c | 22 +++++++++++++++++-
5 files changed, 87 insertions(+), 7 deletions(-)
---
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 8969450..af9e723 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -3273,6 +3273,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;
}
@@ -3292,9 +3300,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
@@ -3316,9 +3334,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 3feaccc..dd419d2 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 1b4019b..ba49c09 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 37cdc07..1758e8a 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.c b/widgets/misc/e-web-view.c
index 26c9224..3b49c48 100644
--- a/widgets/misc/e-web-view.c
+++ b/widgets/misc/e-web-view.c
@@ -877,7 +877,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:
gtk_html_zoom_in (GTK_HTML (widget));
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]