[epiphany-extensions] push-scroller: update to Epiphany master



commit 2a42e9335d526355800ef0cb8acd7ba86399d903
Author: Diego Escalante Urrelo <descalante igalia com>
Date:   Fri Jan 22 12:32:18 2010 -0500

    push-scroller: update to Epiphany master
    
    Update to Epiphany master and also fix the ugly "jump when drag starts" bug.
    
    Bug #605702

 .../push-scroller/ephy-push-scroller-extension.c   |    6 +--
 extensions/push-scroller/ephy-push-scroller.c      |   40 +++++++++++++------
 extensions/push-scroller/ephy-push-scroller.h      |    4 +-
 3 files changed, 31 insertions(+), 19 deletions(-)
---
diff --git a/extensions/push-scroller/ephy-push-scroller-extension.c b/extensions/push-scroller/ephy-push-scroller-extension.c
index 06de1e7..8e750fc 100644
--- a/extensions/push-scroller/ephy-push-scroller-extension.c
+++ b/extensions/push-scroller/ephy-push-scroller-extension.c
@@ -63,7 +63,7 @@ dom_mouse_down_cb (EphyWebView *view,
 	EphyPushScroller *scroller;
 	EphyEmbed *embed;
 	guint context;
-	guint button, x, y;
+	guint button;
 	WebKitHitTestResult *hit_test;
 
 	embed = EPHY_EMBED (EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (GTK_WIDGET (view)));
@@ -81,9 +81,7 @@ dom_mouse_down_cb (EphyWebView *view,
 	scroller = ensure_push_scroller (window);
 	g_return_val_if_fail (scroller != NULL, FALSE);
 
-	x = (guint)event->x;
-	y = (guint)event->y;
-	ephy_push_scroller_start (scroller, embed, x, y);
+	ephy_push_scroller_start (scroller, embed, event->x_root, event->y_root);
 
 	return TRUE;
 }
diff --git a/extensions/push-scroller/ephy-push-scroller.c b/extensions/push-scroller/ephy-push-scroller.c
index 63c9add..ea1286b 100644
--- a/extensions/push-scroller/ephy-push-scroller.c
+++ b/extensions/push-scroller/ephy-push-scroller.c
@@ -72,16 +72,32 @@ ephy_push_scroller_scroll_pixels (EphyEmbed *embed, int scroll_x, int scroll_y)
 {
 	GtkAdjustment *adj;
 	gdouble value;
+	gdouble new_value;
+	gdouble page_size;
+	gdouble upper;
+	gdouble lower;
+	GtkWidget *sw;
+
+	sw = gtk_widget_get_parent (GTK_WIDGET (ephy_embed_get_web_view (embed)));
+	g_return_if_fail (GTK_IS_SCROLLED_WINDOW (sw));
+
+	adj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (sw));
+	upper = gtk_adjustment_get_upper (adj);
+	lower = gtk_adjustment_get_lower (adj);
+	value = gtk_adjustment_get_value (adj);
+	page_size = gtk_adjustment_get_page_size (adj);
 
-	g_return_if_fail (GTK_IS_SCROLLED_WINDOW (embed));
+	new_value = CLAMP (value - scroll_x, lower, upper - page_size);
+	gtk_adjustment_set_value (adj, new_value);
 
-	adj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (embed));
+	adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw));
+	upper = gtk_adjustment_get_upper (adj);
+	lower = gtk_adjustment_get_lower (adj);
 	value = gtk_adjustment_get_value (adj);
-	gtk_adjustment_set_value (adj, value + scroll_x);
+	page_size = gtk_adjustment_get_page_size (adj);
 
-	adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (embed));
-	value = gtk_adjustment_get_value (adj);
-	gtk_adjustment_set_value (adj, value + scroll_y);
+	new_value = CLAMP (value - scroll_y, lower, upper - page_size);
+	gtk_adjustment_set_value (adj, new_value);
 }
 
 static gboolean
@@ -90,7 +106,7 @@ ephy_push_scroller_motion_cb (GtkWidget *widget,
 			      EphyPushScroller *scroller)
 {
 	EphyPushScrollerPrivate *priv = scroller->priv;
-	int x_dist, x_dist_abs, y_dist, y_dist_abs;
+	int x_dist, y_dist;
 
 	if (!priv->active)
 	{
@@ -98,10 +114,8 @@ ephy_push_scroller_motion_cb (GtkWidget *widget,
 	}
 
 	/* get distance between last known cursor position and cursor */
-	x_dist = priv->start_x - event->x_root;
-	x_dist_abs = abs (x_dist);
-	y_dist = priv->start_y - event->y_root;
-	y_dist_abs = abs (y_dist);
+	x_dist = event->x_root - priv->start_x;
+	y_dist = event->y_root - priv->start_y ;
 
 	/* scroll */
 	ephy_push_scroller_scroll_pixels (priv->embed, x_dist, y_dist);
@@ -183,8 +197,8 @@ ephy_push_scroller_grab_notify_cb (GtkWidget *widget,
 void
 ephy_push_scroller_start (EphyPushScroller *scroller,
 			  EphyEmbed *embed,
-			  int x,
-			  int y)
+			  gdouble x,
+			  gdouble y)
 {
 	EphyPushScrollerPrivate *priv = scroller->priv;
 	GtkWidget *widget, *child;
diff --git a/extensions/push-scroller/ephy-push-scroller.h b/extensions/push-scroller/ephy-push-scroller.h
index 9ecd39c..ea75ca7 100644
--- a/extensions/push-scroller/ephy-push-scroller.h
+++ b/extensions/push-scroller/ephy-push-scroller.h
@@ -62,8 +62,8 @@ EphyPushScroller       *ephy_push_scroller_new		 (EphyWindow *window);
 
 void			ephy_push_scroller_start	 (EphyPushScroller *scroller,
 							  EphyEmbed *embed,
-							  int x,
-							  int y);
+							  gdouble x,
+							  gdouble y);
 
 void			ephy_push_scroller_stop		 (EphyPushScroller *scroller,
 							  guint32 timestamp);



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