+static gboolean
+modify_allocation_for_window_grip (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GtkRange *range = GTK_RANGE (widget);
+ GtkRangePrivate *priv = range->priv;
+ GtkWidget *window, *parent;
+ GdkRectangle grip_rect;
+ GdkRectangle translated_rect;
+ gint x;
+ gint y;
+
+ window = gtk_widget_get_toplevel (widget);
+ if (!GTK_IS_WINDOW (window))
+ return FALSE;
+
+ if (!gtk_window_resize_grip_is_visible (GTK_WINDOW (window)))
+ return FALSE;
+
+ /* Get the area of the window's corner grip */
+ gtk_window_get_resize_grip_area (GTK_WINDOW (window), &grip_rect);
+
+ x = 0;
+ y = 0;
+
+ /* Translate the stepper's area into window coords.
+ * This is slightly tricky. We can't just use
+ * gtk_widget_translate_coordinates (widget, window, 0, 0, &x, &y)
+ * since that translates wrt to the _current_ allocation
+ * and will lead to alternating between overlap and nonoverlap
+ * for successive allocations.
+ * Therefore, we find the window-widget to whose window allocation
+ * is relative, and translate from there upwards.
+ */
+ parent = widget;
+ while (gtk_widget_get_window (parent) == gtk_widget_get_window (widget) &&
+ parent != window)
+ {
+ parent = gtk_widget_get_parent (parent);
+ }
+
+ if (parent == window)
+ translated_rect = *allocation;
+ else
+ {
+ gtk_widget_translate_coordinates (parent,
+ window,
+ allocation->x, allocation->y,
+ &x, &y);
+ translated_rect.x = x;
+ translated_rect.y = y;
+ translated_rect.width = allocation->width;
+ translated_rect.height = allocation->height;
+ }
+
+ /* If the stepper button intersects the window resize grip.. */
+ if (gdk_rectangle_intersect (&grip_rect, &translated_rect, &grip_rect))
+ {
+ if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ allocation->width -= grip_rect.width;
+ if (gtk_widget_get_direction (window) == GTK_TEXT_DIR_RTL)
+ allocation->x += grip_rect.width;
+ }
+ else
+ {
+ allocation->height -= grip_rect.height;
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+gtk_range_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GtkRange *range = GTK_RANGE (widget);
+ GtkRangePrivate *priv = range->priv;
+
+ modify_allocation_for_window_grip (widget, allocation);
+ gtk_widget_set_allocation (widget, allocation);
+
+ priv->recalc_marks = TRUE;
+
+ priv->need_recalc = TRUE;
+ gtk_range_calc_layout (range, gtk_adjustment_get_value (priv->adjustment));