netsurf: branch master updated. release/3.0-34-g85030ea

NetSurf Browser Project (Commit Mailer) no-reply at netsurf-browser.org
Sat May 4 19:42:29 BST 2013


Gitweb links:

...log http://git.netsurf-browser.org/netsurf.git/shortlog/85030ea2de02c16258e3d32a486af3d9fcf23c7b
...commit http://git.netsurf-browser.org/netsurf.git/commit/85030ea2de02c16258e3d32a486af3d9fcf23c7b
...tree http://git.netsurf-browser.org/netsurf.git/tree/85030ea2de02c16258e3d32a486af3d9fcf23c7b

The branch, master has been updated
       via  85030ea2de02c16258e3d32a486af3d9fcf23c7b (commit)
      from  30b1fc1dbd8eb5adbf1d2703ba360bf5b32e0751 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=85030ea2de02c16258e3d32a486af3d9fcf23c7b
commit 85030ea2de02c16258e3d32a486af3d9fcf23c7b
Author: Vincent Sanders <vince at netsurf-browser.org>
Commit: Vincent Sanders <vince at netsurf-browser.org>

    Fix mouse wheel scrolling on gtk3 by implementing the smooth scroll direction
    Fix mouse wheel scrolling on gtk2 by setting a reasonable default step

diff --git a/gtk/res/tabcontents.gtk2.ui b/gtk/res/tabcontents.gtk2.ui
index e87249e..63e290e 100644
--- a/gtk/res/tabcontents.gtk2.ui
+++ b/gtk/res/tabcontents.gtk2.ui
@@ -79,13 +79,13 @@
       </object>
   <object class="GtkAdjustment" id="layouthadjustment">
     <property name="upper">100</property>
-    <property name="step_increment">1</property>
+    <property name="step_increment">30</property>
     <property name="page_increment">10</property>
     <property name="page_size">10</property>
   </object>
   <object class="GtkAdjustment" id="layoutvadjustment">
     <property name="upper">100</property>
-    <property name="step_increment">1</property>
+    <property name="step_increment">30</property>
     <property name="page_increment">10</property>
     <property name="page_size">10</property>
   </object>
diff --git a/gtk/window.c b/gtk/window.c
index 7642e3b..663ff32 100644
--- a/gtk/window.c
+++ b/gtk/window.c
@@ -384,105 +384,91 @@ static gboolean nsgtk_window_button_release_event(GtkWidget *widget,
 	return TRUE;
 }
 
-static gboolean nsgtk_window_scroll_event(GtkWidget *widget,
-				GdkEventScroll *event, gpointer data)
+static gboolean
+nsgtk_window_scroll_event(GtkWidget *widget,
+			  GdkEventScroll *event,
+			  gpointer data)
 {
 	struct gui_window *g = data;
 	double value;
+	double deltax = 0;
+	double deltay = 0;
 	GtkAdjustment *vscroll = nsgtk_layout_get_vadjustment(g->layout);
 	GtkAdjustment *hscroll = nsgtk_layout_get_hadjustment(g->layout);
 	GtkAllocation alloc;
 
-	LOG(("%d", event->direction));
 	switch (event->direction) {
 	case GDK_SCROLL_LEFT:
-		if (browser_window_scroll_at_point(g->bw,
-				event->x / g->bw->scale,
-				event->y / g->bw->scale,
-				-100, 0) != true) {
-			/* core did not handle event do horizontal scroll */
-
-			value = gtk_adjustment_get_value(hscroll) -
-				(nsgtk_adjustment_get_step_increment(hscroll) *2);
-
-			if (value < nsgtk_adjustment_get_lower(hscroll)) {
-				value = nsgtk_adjustment_get_lower(hscroll);
-			}
-
-			gtk_adjustment_set_value(hscroll, value);
-		}
+		deltax = -1.0;
 		break;
 
 	case GDK_SCROLL_UP:
-		if (browser_window_scroll_at_point(g->bw,
-				event->x / g->bw->scale,
-				event->y / g->bw->scale,
-				0, -100) != true) {
-			/* core did not handle event change vertical
-			 * adjustment. 
-			 */
+		deltay = -1.0;
+		break;
 
-			value = gtk_adjustment_get_value(vscroll) -
-				(nsgtk_adjustment_get_step_increment(vscroll) * 2);
+	case GDK_SCROLL_RIGHT:
+		deltax = 1.0;
+		break;
 
-			if (value < nsgtk_adjustment_get_lower(vscroll)) {
-				value = nsgtk_adjustment_get_lower(vscroll);
-			}
+	case GDK_SCROLL_DOWN:
+		deltay = 1.0;
+		break;
 
-			gtk_adjustment_set_value(vscroll, value);
-		}
+#if GTK_CHECK_VERSION(3,4,0)
+	case GDK_SCROLL_SMOOTH:
+		gdk_event_get_scroll_deltas((GdkEvent *)event, &deltax, &deltay);
 		break;
+#endif
+	default:
+		LOG(("Unhandled mouse scroll direction"));
+		return TRUE;
+	}
 
-	case GDK_SCROLL_RIGHT:
-		if (browser_window_scroll_at_point(g->bw,
-				event->x / g->bw->scale,
-				event->y / g->bw->scale,
-				100, 0) != true) {
+	deltax *= nsgtk_adjustment_get_step_increment(hscroll);
+	deltay *= nsgtk_adjustment_get_step_increment(vscroll);
+
+	LOG(("Scrolling %f, %f", deltax, deltay));
 
-			/* core did not handle event change horizontal
-			 * adjustment. 
-			 */
+	if (browser_window_scroll_at_point(g->bw,
+					   event->x / g->bw->scale,
+					   event->y / g->bw->scale,
+					   deltax, deltay) != true) {
 
-			value = gtk_adjustment_get_value(hscroll) +
-				(nsgtk_adjustment_get_step_increment(hscroll) * 2);
+		/* core did not handle event so change adjustments */
+
+		/* Horizontal */
+		if (deltax != 0) {
+			value = gtk_adjustment_get_value(hscroll) + deltax;
 
 			/* @todo consider gtk_widget_get_allocated_width() */
 			nsgtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc);
 
 			if (value > nsgtk_adjustment_get_upper(hscroll) - alloc.width) {
-				value = nsgtk_adjustment_get_upper(hscroll) - 
-					alloc.width;
+				value = nsgtk_adjustment_get_upper(hscroll) - alloc.width;
+			}
+			if (value < nsgtk_adjustment_get_lower(hscroll)) {
+				value = nsgtk_adjustment_get_lower(hscroll);
 			}
 
 			gtk_adjustment_set_value(hscroll, value);
 		}
-		break;
 
-	case GDK_SCROLL_DOWN:
-		if (browser_window_scroll_at_point(g->bw,
-				event->x / g->bw->scale,
-				event->y / g->bw->scale,
-				0, 100) != true) {
-			/* core did not handle event change vertical
-			 * adjustment. 
-			 */
-
-			value = gtk_adjustment_get_value(vscroll) +
-				(nsgtk_adjustment_get_step_increment(vscroll) * 2);
+		/* Vertical */
+		if (deltay != 0) {
+			value = gtk_adjustment_get_value(vscroll) + deltay;
+
 			/* @todo consider gtk_widget_get_allocated_height */
 			nsgtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc);
 
-			if (value > nsgtk_adjustment_get_upper(vscroll) - alloc.height) {
-				value = nsgtk_adjustment_get_upper(vscroll) - 
-					alloc.height;
+			if (value > (nsgtk_adjustment_get_upper(vscroll) - alloc.height)) {
+				value = nsgtk_adjustment_get_upper(vscroll) - alloc.height;
+			}
+			if (value < nsgtk_adjustment_get_lower(vscroll)) {
+				value = nsgtk_adjustment_get_lower(vscroll);
 			}
 
 			gtk_adjustment_set_value(vscroll, value);
 		}
-		break;
-
-	default:
-		break;
 	}
 
 	return TRUE;


-----------------------------------------------------------------------

Summary of changes:
 gtk/res/tabcontents.gtk2.ui |    4 +-
 gtk/window.c                |  112 +++++++++++++++++++------------------------
 2 files changed, 51 insertions(+), 65 deletions(-)

diff --git a/gtk/res/tabcontents.gtk2.ui b/gtk/res/tabcontents.gtk2.ui
index e87249e..63e290e 100644
--- a/gtk/res/tabcontents.gtk2.ui
+++ b/gtk/res/tabcontents.gtk2.ui
@@ -79,13 +79,13 @@
       </object>
   <object class="GtkAdjustment" id="layouthadjustment">
     <property name="upper">100</property>
-    <property name="step_increment">1</property>
+    <property name="step_increment">30</property>
     <property name="page_increment">10</property>
     <property name="page_size">10</property>
   </object>
   <object class="GtkAdjustment" id="layoutvadjustment">
     <property name="upper">100</property>
-    <property name="step_increment">1</property>
+    <property name="step_increment">30</property>
     <property name="page_increment">10</property>
     <property name="page_size">10</property>
   </object>
diff --git a/gtk/window.c b/gtk/window.c
index 7642e3b..663ff32 100644
--- a/gtk/window.c
+++ b/gtk/window.c
@@ -384,105 +384,91 @@ static gboolean nsgtk_window_button_release_event(GtkWidget *widget,
 	return TRUE;
 }
 
-static gboolean nsgtk_window_scroll_event(GtkWidget *widget,
-				GdkEventScroll *event, gpointer data)
+static gboolean
+nsgtk_window_scroll_event(GtkWidget *widget,
+			  GdkEventScroll *event,
+			  gpointer data)
 {
 	struct gui_window *g = data;
 	double value;
+	double deltax = 0;
+	double deltay = 0;
 	GtkAdjustment *vscroll = nsgtk_layout_get_vadjustment(g->layout);
 	GtkAdjustment *hscroll = nsgtk_layout_get_hadjustment(g->layout);
 	GtkAllocation alloc;
 
-	LOG(("%d", event->direction));
 	switch (event->direction) {
 	case GDK_SCROLL_LEFT:
-		if (browser_window_scroll_at_point(g->bw,
-				event->x / g->bw->scale,
-				event->y / g->bw->scale,
-				-100, 0) != true) {
-			/* core did not handle event do horizontal scroll */
-
-			value = gtk_adjustment_get_value(hscroll) -
-				(nsgtk_adjustment_get_step_increment(hscroll) *2);
-
-			if (value < nsgtk_adjustment_get_lower(hscroll)) {
-				value = nsgtk_adjustment_get_lower(hscroll);
-			}
-
-			gtk_adjustment_set_value(hscroll, value);
-		}
+		deltax = -1.0;
 		break;
 
 	case GDK_SCROLL_UP:
-		if (browser_window_scroll_at_point(g->bw,
-				event->x / g->bw->scale,
-				event->y / g->bw->scale,
-				0, -100) != true) {
-			/* core did not handle event change vertical
-			 * adjustment. 
-			 */
+		deltay = -1.0;
+		break;
 
-			value = gtk_adjustment_get_value(vscroll) -
-				(nsgtk_adjustment_get_step_increment(vscroll) * 2);
+	case GDK_SCROLL_RIGHT:
+		deltax = 1.0;
+		break;
 
-			if (value < nsgtk_adjustment_get_lower(vscroll)) {
-				value = nsgtk_adjustment_get_lower(vscroll);
-			}
+	case GDK_SCROLL_DOWN:
+		deltay = 1.0;
+		break;
 
-			gtk_adjustment_set_value(vscroll, value);
-		}
+#if GTK_CHECK_VERSION(3,4,0)
+	case GDK_SCROLL_SMOOTH:
+		gdk_event_get_scroll_deltas((GdkEvent *)event, &deltax, &deltay);
 		break;
+#endif
+	default:
+		LOG(("Unhandled mouse scroll direction"));
+		return TRUE;
+	}
 
-	case GDK_SCROLL_RIGHT:
-		if (browser_window_scroll_at_point(g->bw,
-				event->x / g->bw->scale,
-				event->y / g->bw->scale,
-				100, 0) != true) {
+	deltax *= nsgtk_adjustment_get_step_increment(hscroll);
+	deltay *= nsgtk_adjustment_get_step_increment(vscroll);
+
+	LOG(("Scrolling %f, %f", deltax, deltay));
 
-			/* core did not handle event change horizontal
-			 * adjustment. 
-			 */
+	if (browser_window_scroll_at_point(g->bw,
+					   event->x / g->bw->scale,
+					   event->y / g->bw->scale,
+					   deltax, deltay) != true) {
 
-			value = gtk_adjustment_get_value(hscroll) +
-				(nsgtk_adjustment_get_step_increment(hscroll) * 2);
+		/* core did not handle event so change adjustments */
+
+		/* Horizontal */
+		if (deltax != 0) {
+			value = gtk_adjustment_get_value(hscroll) + deltax;
 
 			/* @todo consider gtk_widget_get_allocated_width() */
 			nsgtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc);
 
 			if (value > nsgtk_adjustment_get_upper(hscroll) - alloc.width) {
-				value = nsgtk_adjustment_get_upper(hscroll) - 
-					alloc.width;
+				value = nsgtk_adjustment_get_upper(hscroll) - alloc.width;
+			}
+			if (value < nsgtk_adjustment_get_lower(hscroll)) {
+				value = nsgtk_adjustment_get_lower(hscroll);
 			}
 
 			gtk_adjustment_set_value(hscroll, value);
 		}
-		break;
 
-	case GDK_SCROLL_DOWN:
-		if (browser_window_scroll_at_point(g->bw,
-				event->x / g->bw->scale,
-				event->y / g->bw->scale,
-				0, 100) != true) {
-			/* core did not handle event change vertical
-			 * adjustment. 
-			 */
-
-			value = gtk_adjustment_get_value(vscroll) +
-				(nsgtk_adjustment_get_step_increment(vscroll) * 2);
+		/* Vertical */
+		if (deltay != 0) {
+			value = gtk_adjustment_get_value(vscroll) + deltay;
+
 			/* @todo consider gtk_widget_get_allocated_height */
 			nsgtk_widget_get_allocation(GTK_WIDGET(g->layout), &alloc);
 
-			if (value > nsgtk_adjustment_get_upper(vscroll) - alloc.height) {
-				value = nsgtk_adjustment_get_upper(vscroll) - 
-					alloc.height;
+			if (value > (nsgtk_adjustment_get_upper(vscroll) - alloc.height)) {
+				value = nsgtk_adjustment_get_upper(vscroll) - alloc.height;
+			}
+			if (value < nsgtk_adjustment_get_lower(vscroll)) {
+				value = nsgtk_adjustment_get_lower(vscroll);
 			}
 
 			gtk_adjustment_set_value(vscroll, value);
 		}
-		break;
-
-	default:
-		break;
 	}
 
 	return TRUE;


-- 
NetSurf Browser



More information about the netsurf-commits mailing list