[totem/gnome-3-4] main: Handle smooth scroll events



commit a060948183552d86ec788a5fc300b1b482c4fe47
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jun 28 16:30:12 2012 +0100

    main: Handle smooth scroll events
    
    And restrict ourselves to handling smooth events on the left side
    of the pane, stopping us from capturing scroll events meant for scroll
    window, such as the playlist.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=674355

 data/totem.ui      |    2 +-
 src/totem-object.c |   23 ++++++++++++++++-------
 2 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/data/totem.ui b/data/totem.ui
index 83c0bc6..c241cfe 100644
--- a/data/totem.ui
+++ b/data/totem.ui
@@ -2112,7 +2112,6 @@
   <signal name="window-state-event" handler="window_state_event_cb"/>
   <signal name="key-press-event" handler="window_key_press_event_cb"/>
   <signal name="key-release-event" handler="window_key_press_event_cb"/>
-  <signal name="scroll-event" handler="window_scroll_event_cb"/>
 
   <child>
     <object class="GtkVBox" id="totem_main_vbox">
@@ -2157,6 +2156,7 @@
 	      <property name="homogeneous">False</property>
 	      <property name="spacing">0</property>
               <property name="orientation">vertical</property>
+              <signal name="scroll-event" handler="window_scroll_event_cb"/>
 
 	      <child>
 	        <object class="GtkEventBox" id="tmw_bvw_box">
diff --git a/src/totem-object.c b/src/totem-object.c
index 111f210..18db1be 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -108,7 +108,7 @@ G_MODULE_EXPORT void seek_slider_changed_cb (GtkAdjustment *adj, TotemObject *to
 G_MODULE_EXPORT gboolean seek_slider_released_cb (GtkWidget *widget, GdkEventButton *event, TotemObject *totem);
 G_MODULE_EXPORT void volume_button_value_changed_cb (GtkScaleButton *button, gdouble value, TotemObject *totem);
 G_MODULE_EXPORT gboolean window_key_press_event_cb (GtkWidget *win, GdkEventKey *event, TotemObject *totem);
-G_MODULE_EXPORT int window_scroll_event_cb (GtkWidget *win, GdkEventScroll *event, TotemObject *totem);
+G_MODULE_EXPORT int window_scroll_event_cb (GtkWidget *win, GdkEvent *event, TotemObject *totem);
 G_MODULE_EXPORT void main_pane_size_allocated (GtkWidget *main_pane, GtkAllocation *allocation, TotemObject *totem);
 G_MODULE_EXPORT void fs_exit1_activate_cb (GtkButton *button, TotemObject *totem);
 
@@ -3770,13 +3770,24 @@ totem_action_handle_key_press (TotemObject *totem, GdkEventKey *event)
 }
 
 static gboolean
-totem_action_handle_scroll (TotemObject *totem, GdkScrollDirection direction)
+totem_action_handle_scroll (TotemObject    *totem,
+			    const GdkEvent *event)
 {
 	gboolean retval = TRUE;
+	GdkEventScroll *sevent = (GdkEventScroll *) event;
+	GdkScrollDirection direction;
+
+	direction = sevent->direction;
 
 	if (totem_fullscreen_is_fullscreen (totem->fs) != FALSE)
 		totem_fullscreen_show_popups (totem->fs, TRUE);
 
+	if (direction == GDK_SCROLL_SMOOTH) {
+		gdouble y;
+		gdk_event_get_scroll_deltas (event, NULL, &y);
+		direction = y >= 0.0 ? GDK_SCROLL_DOWN : GDK_SCROLL_UP;
+	}
+
 	switch (direction) {
 	case GDK_SCROLL_UP:
 		totem_action_seek_relative (totem, SEEK_FORWARD_SHORT_OFFSET * 1000, FALSE);
@@ -3784,8 +3795,6 @@ totem_action_handle_scroll (TotemObject *totem, GdkScrollDirection direction)
 	case GDK_SCROLL_DOWN:
 		totem_action_seek_relative (totem, SEEK_BACKWARD_SHORT_OFFSET * 1000, FALSE);
 		break;
-	case GDK_SCROLL_LEFT:
-	case GDK_SCROLL_RIGHT:
 	default:
 		retval = FALSE;
 	}
@@ -3881,9 +3890,9 @@ window_key_press_event_cb (GtkWidget *win, GdkEventKey *event, TotemObject *tote
 }
 
 gboolean
-window_scroll_event_cb (GtkWidget *win, GdkEventScroll *event, TotemObject *totem)
+window_scroll_event_cb (GtkWidget *win, GdkEvent *event, TotemObject *totem)
 {
-	return totem_action_handle_scroll (totem, event->direction);
+	return totem_action_handle_scroll (totem, event);
 }
 
 static void
@@ -4149,7 +4158,7 @@ totem_callback_connect (TotemObject *totem)
 	gtk_widget_add_events (totem->win, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
 
 	/* Connect the mouse wheel */
-	gtk_widget_add_events (totem->win, GDK_SCROLL_MASK);
+	gtk_widget_add_events (GTK_WIDGET (gtk_builder_get_object (totem->xml, "tmw_main_vbox")), GDK_SCROLL_MASK);
 	gtk_widget_add_events (totem->seek, GDK_SCROLL_MASK);
 	gtk_widget_add_events (totem->fs->seek, GDK_SCROLL_MASK);
 



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