diff options
author | Matthias Clasen <mclasen@redhat.com> | 2010-10-08 22:04:33 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2010-10-08 22:04:33 -0400 |
commit | 9d750ad13eec68baf5734907126aa8676516d7c9 (patch) | |
tree | 3a82be1ccd2c592a14be377bef35c61092995139 /gtk/gtkrange.c | |
parent | 2f8f0d8eabf8c6f447874f8991fb04f64d8c585b (diff) | |
download | gtk+-9d750ad13eec68baf5734907126aa8676516d7c9.tar.gz |
Fix a problem with 'resize grip avoidance' in scrollbars
We need to be a little more careful when determining the overlap
between the new allocation and the grip area. This was causing
vertical scrollbars in evince to overlap with the grip.
Diffstat (limited to 'gtk/gtkrange.c')
-rw-r--r-- | gtk/gtkrange.c | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index ab363419f6..1d0f296e39 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -1581,7 +1581,7 @@ modify_allocation_for_window_grip (GtkWidget *widget, { GtkRange *range = GTK_RANGE (widget); GtkRangePrivate *priv = range->priv; - GtkWidget *window; + GtkWidget *window, *parent; GdkRectangle grip_rect; GdkRectangle translated_rect; gint x; @@ -1600,35 +1600,51 @@ modify_allocation_for_window_grip (GtkWidget *widget, x = 0; y = 0; - /* Translate the stepper's area into window coords */ - if (gtk_widget_translate_coordinates (gtk_widget_get_parent (widget), - window, - allocation->x, - allocation->y, - &x, - &y)) + /* 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 (gtk_widget_get_parent (widget), + 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, NULL)) + /* If the stepper button intersects the window resize grip.. */ + if (gdk_rectangle_intersect (&grip_rect, &translated_rect, NULL)) + { + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { - 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; + 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; |