r11077 tlsa - /trunk/netsurf/gtk/gtk_window.c

netsurf at semichrome.net netsurf at semichrome.net
Thu Dec 16 20:46:13 GMT 2010


Author: tlsa
Date: Thu Dec 16 14:46:13 2010
New Revision: 11077

URL: http://source.netsurf-browser.org?rev=11077&view=rev
Log:
Make drags less jerky.

Modified:
    trunk/netsurf/gtk/gtk_window.c

Modified: trunk/netsurf/gtk/gtk_window.c
URL: http://source.netsurf-browser.org/trunk/netsurf/gtk/gtk_window.c?rev=11077&r1=11076&r2=11077&view=diff
==============================================================================
--- trunk/netsurf/gtk/gtk_window.c (original)
+++ trunk/netsurf/gtk/gtk_window.c Thu Dec 16 14:46:13 2010
@@ -19,6 +19,7 @@
 
 #include <inttypes.h>
 #include <string.h>
+#include <limits.h>
 #include "content/hlcache.h"
 #include "gtk/gtk_window.h"
 #include "desktop/browser.h"
@@ -442,9 +443,19 @@
 	struct gui_window *g = data;
 	bool shift = event->state & GDK_SHIFT_MASK;
 	bool ctrl = event->state & GDK_CONTROL_MASK;
-	if ((abs(event->x - g->last_x) < 5) && (abs(event->y - g->last_y) < 5))
-		/* necessary for touch screens */
+
+	if ((abs(event->x - g->last_x) < 5) &&
+			(abs(event->y - g->last_y) < 5)) {
+		/* Mouse hasn't moved far enough from press coordinate for this
+		 * to be considered a drag. */
 		return FALSE;
+	} else {
+		/* This is a drag, ensure it's always treated as such, even if
+		 * we drag back over the press location */
+		g->last_x = INT_MIN;
+		g->last_y = INT_MIN;
+	}
+
 	if (g->mouse.state & BROWSER_MOUSE_PRESS_1){
 		/* Start button 1 drag */
 		browser_window_mouse_click(g->bw, BROWSER_MOUSE_DRAG_1,
@@ -471,9 +482,6 @@
 
 	browser_window_mouse_track(g->bw, g->mouse.state,
 			event->x / g->bw->scale, event->y / g->bw->scale);
-
-	g->last_x = event->x;
-	g->last_y = event->y;
 
 	return TRUE;
 }




More information about the netsurf-commits mailing list