[nautilus] icon-view: fix wheel scrolling for compact view



commit 0832acdb4371fc7de957303e220e899c8fdcdf5c
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Mar 16 16:47:34 2012 -0400

    icon-view: fix wheel scrolling for compact view
    
    If the smooth scroll event we get is an emulated scroll wheel, we have
    to emulate a right/left scroll, like we do for regular UP/DOWN events.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=672185

 src/nautilus-icon-view.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/nautilus-icon-view.c b/src/nautilus-icon-view.c
index c6f0675..a44feb7 100644
--- a/src/nautilus-icon-view.c
+++ b/src/nautilus-icon-view.c
@@ -1775,21 +1775,32 @@ nautilus_icon_view_scroll_event (GtkWidget *widget,
 
 	if (icon_view->details->compact &&
 	    (scroll_event->direction == GDK_SCROLL_UP ||
-	     scroll_event->direction == GDK_SCROLL_DOWN)) {
+	     scroll_event->direction == GDK_SCROLL_DOWN ||
+	     scroll_event->direction == GDK_SCROLL_SMOOTH)) {
 		ret = nautilus_view_handle_scroll_event (NAUTILUS_VIEW (icon_view), scroll_event);
 		if (!ret) {
 			/* in column-wise layout, re-emit vertical mouse scroll events as horizontal ones,
 			 * if they don't bump zoom */
 			event_copy = gdk_event_copy ((GdkEvent *) scroll_event);
-
 			scroll_event_copy = (GdkEventScroll *) event_copy;
+
+			/* transform vertical integer smooth scroll events into horizontal events */
+			if (scroll_event_copy->direction == GDK_SCROLL_SMOOTH &&
+				   scroll_event_copy->delta_x == 0) {
+				if (scroll_event_copy->delta_y == 1.0) {
+					scroll_event_copy->direction = GDK_SCROLL_DOWN;
+				} else if (scroll_event_copy->delta_y == -1.0) {
+					scroll_event_copy->direction = GDK_SCROLL_UP;
+				}
+			}
+
 			if (scroll_event_copy->direction == GDK_SCROLL_UP) {
 				scroll_event_copy->direction = GDK_SCROLL_LEFT;
-			} else {
+			} else if (scroll_event_copy->direction == GDK_SCROLL_DOWN) {
 				scroll_event_copy->direction = GDK_SCROLL_RIGHT;
 			}
 
-			ret = gtk_widget_event (widget, event_copy);
+			ret = GTK_WIDGET_CLASS (nautilus_icon_view_parent_class)->scroll_event (widget, scroll_event_copy);
 			gdk_event_free (event_copy);
 		}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]