Index: panel-toplevel.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-toplevel.c,v
retrieving revision 1.50
diff -u -p -r1.50 panel-toplevel.c
--- panel-toplevel.c	28 Nov 2003 08:59:28 -0000	1.50
+++ panel-toplevel.c	1 Dec 2003 13:32:58 -0000
@@ -48,16 +48,16 @@
 
 #define PANEL_TOPLEVEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_TOPLEVEL, PanelToplevelPrivate))
 
-#define DEFAULT_SIZE              48
-#define DEFAULT_AUTO_HIDE_SIZE    6
-#define DEFAULT_HIDE_DELAY        500
-#define DEFAULT_UNHIDE_DELAY      500
-#define MINIMUM_WIDTH             100
-#define SNAP_TOLERANCE            20
-#define HIDE_BUTTON_SIZE          20
-#define HANDLE_SIZE               10
-#define N_ATTACH_TOPLEVEL_SIGNALS 5
-#define N_ATTACH_WIDGET_SIGNALS   5
+#define DEFAULT_SIZE                            48
+#define DEFAULT_AUTO_HIDE_SIZE                  6
+#define DEFAULT_HIDE_DELAY                      500
+#define DEFAULT_UNHIDE_DELAY                    500
+#define MINIMUM_WIDTH                           100
+#define DRAG_THRESHOLD_TO_SNAP_TOLERANCE_FACTOR 6
+#define HIDE_BUTTON_SIZE                        20
+#define HANDLE_SIZE                             10
+#define N_ATTACH_TOPLEVEL_SIGNALS               5
+#define N_ATTACH_WIDGET_SIGNALS                 5
 
 typedef enum {
 	PANEL_GRAB_OP_NONE,
@@ -245,6 +245,21 @@ panel_toplevel_is_last_unattached (Panel
 }
 
 
+static int
+panel_toplevel_get_snap_tolerance (PanelToplevel *toplevel)
+{
+	GtkSettings *settings;
+	int          threshold;
+
+	settings = gtk_widget_get_settings (GTK_WIDGET (toplevel->priv->panel_widget));
+
+	threshold = 8;
+	g_object_get (G_OBJECT (settings), "gtk-dnd-drag-threshold",
+		      &threshold, NULL);
+
+	return (threshold * DRAG_THRESHOLD_TO_SNAP_TOLERANCE_FACTOR);
+}
+
 static GdkScreen *
 panel_toplevel_get_screen_geometry (PanelToplevel *toplevel,
 				    int           *width,
@@ -654,6 +669,7 @@ panel_toplevel_move_to (PanelToplevel *t
 	int               width, height;
 	int               new_monitor;
 	int               x, y;
+	int               snap_tolerance;
 
 	screen = panel_toplevel_get_screen_geometry (
 			toplevel, &screen_width, &screen_height);
@@ -666,19 +682,21 @@ panel_toplevel_move_to (PanelToplevel *t
 
 	new_orientation = toplevel->priv->orientation;
 
-	if (new_x <= SNAP_TOLERANCE &&
+	snap_tolerance = panel_toplevel_get_snap_tolerance (toplevel);
+
+	if (new_x <= snap_tolerance &&
 	    toplevel->priv->orientation & PANEL_VERTICAL_MASK)
 		new_orientation = PANEL_ORIENTATION_LEFT;
 
-	else if ((new_x + width) >= (screen_width - SNAP_TOLERANCE) &&
+	else if ((new_x + width) >= (screen_width - snap_tolerance) &&
 		 toplevel->priv->orientation & PANEL_VERTICAL_MASK)
 		new_orientation = PANEL_ORIENTATION_RIGHT;
 
-	if (new_y <= SNAP_TOLERANCE &&
+	if (new_y <= snap_tolerance &&
 	    toplevel->priv->orientation & PANEL_HORIZONTAL_MASK)
 		new_orientation = PANEL_ORIENTATION_TOP;
 
-	else if ((new_y + height) >= (screen_height - SNAP_TOLERANCE) &&
+	else if ((new_y + height) >= (screen_height - snap_tolerance) &&
 		 toplevel->priv->orientation & PANEL_HORIZONTAL_MASK)
 		new_orientation = PANEL_ORIENTATION_BOTTOM;
 
@@ -697,14 +715,14 @@ panel_toplevel_move_to (PanelToplevel *t
 		y_centered = FALSE;
 		if (new_y == 0 || new_y == (screen_height - height))
 			x_centered = abs (x - ((monitor_width - width) / 2))
-								<= SNAP_TOLERANCE;
+								<= snap_tolerance;
 		else
 			x_centered = FALSE;
 	} else {
 		x_centered = FALSE;
 		if (new_x == 0 || new_x == (screen_width - width))
 			y_centered = abs (y - ((monitor_height - height) / 2))
-								<= SNAP_TOLERANCE;
+								<= snap_tolerance;
 		else
 			y_centered = FALSE;
 	}
@@ -742,6 +760,7 @@ panel_toplevel_rotate_to_pointer (PanelT
 	GdkScreen *screen;
 	int        x_diff, y_diff;
 	int        x, y;
+	int        snap_tolerance;
 
 	widget = GTK_WIDGET (toplevel);
 
@@ -753,20 +772,22 @@ panel_toplevel_rotate_to_pointer (PanelT
 	x_diff = pointer_x - (x + toplevel->priv->geometry.width / 2);
 	y_diff = pointer_y - (y + toplevel->priv->geometry.height / 2);
 
-	if (((-y_diff > x_diff + SNAP_TOLERANCE) && x_diff > 0 && y_diff < 0) ||
-	    (( y_diff < x_diff + SNAP_TOLERANCE) && x_diff < 0 && y_diff < 0))
+	snap_tolerance = panel_toplevel_get_snap_tolerance (toplevel);
+
+	if (((-y_diff > x_diff + snap_tolerance) && x_diff > 0 && y_diff < 0) ||
+	    (( y_diff < x_diff + snap_tolerance) && x_diff < 0 && y_diff < 0))
 		panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_RIGHT);
 
-	else if (((-x_diff < y_diff - SNAP_TOLERANCE) && x_diff > 0 && y_diff < 0) ||
-	         (( x_diff > y_diff - SNAP_TOLERANCE) && x_diff > 0 && y_diff > 0))
+	else if (((-x_diff < y_diff - snap_tolerance) && x_diff > 0 && y_diff < 0) ||
+	         (( x_diff > y_diff - snap_tolerance) && x_diff > 0 && y_diff > 0))
 		panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_BOTTOM);
 
-	else if ((( y_diff > x_diff + SNAP_TOLERANCE) && x_diff > 0 && y_diff > 0) ||
-	         ((-y_diff < x_diff + SNAP_TOLERANCE) && x_diff < 0 && y_diff > 0))
+	else if ((( y_diff > x_diff + snap_tolerance) && x_diff > 0 && y_diff > 0) ||
+	         ((-y_diff < x_diff + snap_tolerance) && x_diff < 0 && y_diff > 0))
 		panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_LEFT);
 
-	else if (((-x_diff > y_diff - SNAP_TOLERANCE) && x_diff < 0 && y_diff > 0) ||
-	         (( x_diff < y_diff - SNAP_TOLERANCE) && x_diff < 0 && y_diff < 0))
+	else if (((-x_diff > y_diff - snap_tolerance) && x_diff < 0 && y_diff > 0) ||
+	         (( x_diff < y_diff - snap_tolerance) && x_diff < 0 && y_diff < 0))
 		panel_toplevel_set_orientation (toplevel, PANEL_ORIENTATION_TOP);
 }
 
@@ -996,6 +1017,7 @@ panel_toplevel_calc_floating (PanelTople
 	GdkScreen *screen;
 	int        screen_width, screen_height;
 	int        x, y;
+	int        snap_tolerance;
 
 	if (toplevel->priv->expand) {
 		toplevel->priv->floating = FALSE;
@@ -1008,12 +1030,14 @@ panel_toplevel_calc_floating (PanelTople
 	x = panel_multiscreen_x (screen, toplevel->priv->monitor) + toplevel->priv->x;
 	y = panel_multiscreen_y (screen, toplevel->priv->monitor) + toplevel->priv->y;
 
+	snap_tolerance = panel_toplevel_get_snap_tolerance (toplevel);
+
 	if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK)
 		toplevel->priv->floating =
-			(y > SNAP_TOLERANCE) && (y < (screen_height - toplevel->priv->geometry.height - SNAP_TOLERANCE));
+			(y > snap_tolerance) && (y < (screen_height - toplevel->priv->geometry.height - snap_tolerance));
 	else
 		toplevel->priv->floating =
-			(x > SNAP_TOLERANCE) && (x < (screen_width - toplevel->priv->geometry.width - SNAP_TOLERANCE));
+			(x > snap_tolerance) && (x < (screen_width - toplevel->priv->geometry.width - snap_tolerance));
 }
 
 static void 
@@ -1632,6 +1656,7 @@ panel_toplevel_update_normal_position (P
 	GtkWidget *widget;
 	int        monitor_width, monitor_height;
 	int        width, height;
+	int        snap_tolerance;
 
 	g_assert (x != NULL && y != NULL);
 
@@ -1651,14 +1676,16 @@ panel_toplevel_update_normal_position (P
 	*x = CLAMP (*x, 0, monitor_width  - width);
 	*y = CLAMP (*y, 0, monitor_height - height);
 
-	if (*x <= SNAP_TOLERANCE)
+	snap_tolerance = panel_toplevel_get_snap_tolerance (toplevel);
+
+	if (*x <= snap_tolerance)
 		*x = 0;
-	else if ((*x + width) >= (monitor_width - SNAP_TOLERANCE))
+	else if ((*x + width) >= (monitor_width - snap_tolerance))
 		*x = monitor_width - width;
 
-	if (*y <= SNAP_TOLERANCE)
+	if (*y <= snap_tolerance)
 		*y = 0;
-	else if ((*y + height) >= (monitor_height - SNAP_TOLERANCE))
+	else if ((*y + height) >= (monitor_height - snap_tolerance))
 		*y = monitor_height - height;
 }
 
