[evolution] Bug #671585 - Add support for smooth scrolling devices
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug #671585 - Add support for smooth scrolling devices
- Date: Tue, 15 May 2012 14:24:47 +0000 (UTC)
commit 5e379370ae0653c229308e1d7af31a54739ccc7e
Author: Milan Crha <mcrha redhat com>
Date: Tue May 15 16:23:10 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-gtkhtml.c | 22 +++++++++++++++++-
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 ad7fd78..be096b5 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 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 4526570..c256c9a 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 be8b1c5..bca66a7 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 f58b5d4..07f8357 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]