diff options
author | Ernestas Kulik <ernestask@gnome.org> | 2018-07-19 10:26:00 +0300 |
---|---|---|
committer | Ernestas Kulik <ekulik@redhat.com> | 2019-06-29 14:33:41 +0200 |
commit | c401ef1fccc97a4df0ebcd9048d90218e17cd7c6 (patch) | |
tree | 49efb509e42e955cd19e31997b8742d576573520 | |
parent | fceddc5df440735b7962fae3aeaaabb354e04c05 (diff) | |
download | nautilus-c401ef1fccc97a4df0ebcd9048d90218e17cd7c6.tar.gz |
canvas-container: Unconditionally redo layout
The ::size-allocate handler only redoes its layout if the allocation
had changed and if there isn’t an allocation loop. There used to be a
bug, which caused that to happen in certain cases, but the workarounds
break in GTK+ 4, and it doesn’t seem likely that the bug will manifest
itself again.
-rw-r--r-- | src/nautilus-canvas-container.c | 64 | ||||
-rw-r--r-- | src/nautilus-canvas-private.h | 3 |
2 files changed, 1 insertions, 66 deletions
diff --git a/src/nautilus-canvas-container.c b/src/nautilus-canvas-container.c index 943a160fb..54349c886 100644 --- a/src/nautilus-canvas-container.c +++ b/src/nautilus-canvas-container.c @@ -2713,12 +2713,6 @@ destroy (GtkWidget *object) container->details->selection_changed_id = 0; } - if (container->details->size_allocation_count_id != 0) - { - g_source_remove (container->details->size_allocation_count_id); - container->details->size_allocation_count_id = 0; - } - GTK_WIDGET_CLASS (nautilus_canvas_container_parent_class)->destroy (object); } @@ -2758,19 +2752,6 @@ finalize (GObject *object) /* GtkWidget methods. */ -static gboolean -clear_size_allocation_count (gpointer data) -{ - NautilusCanvasContainer *container; - - container = NAUTILUS_CANVAS_CONTAINER (data); - - container->details->size_allocation_count_id = 0; - container->details->size_allocation_count = 0; - - return FALSE; -} - static void size_allocate (GtkWidget *widget, int width, @@ -2778,59 +2759,16 @@ size_allocate (GtkWidget *widget, int baseline) { NautilusCanvasContainer *container; - gboolean need_layout_redone; - GtkAllocation wid_allocation; GtkWidgetClass *widget_class; container = NAUTILUS_CANVAS_CONTAINER (widget); - - need_layout_redone = !container->details->has_been_allocated; - gtk_widget_get_allocation (widget, &wid_allocation); - - if (allocation->width != wid_allocation.width) - { - need_layout_redone = TRUE; - } - - if (allocation->height != wid_allocation.height) - { - need_layout_redone = TRUE; - } - - /* Under some conditions we can end up in a loop when size allocating. - * This happens when the icons don't fit without a scrollbar, but fits - * when a scrollbar is added (bug #129963 for details). - * We keep track of this looping by increasing a counter in size_allocate - * and clearing it in a high-prio idle (the only way to detect the loop is - * done). - * When we've done at more than two iterations (with/without scrollbar) - * we terminate this looping by not redoing the layout when the width - * is wider than the current one (i.e when removing the scrollbar). - */ - if (container->details->size_allocation_count_id == 0) - { - container->details->size_allocation_count_id = - g_idle_add_full (G_PRIORITY_HIGH, - clear_size_allocation_count, - container, NULL); - } - container->details->size_allocation_count++; - if (container->details->size_allocation_count > 2 && - allocation->width >= wid_allocation.width) - { - need_layout_redone = FALSE; - } - widget_class = GTK_WIDGET_CLASS (nautilus_canvas_container_parent_class); widget_class->size_allocate (widget, width, height, baseline); container->details->has_been_allocated = TRUE; - if (need_layout_redone) - { - redo_layout (container); - } + redo_layout (container); } static GtkSizeRequestMode diff --git a/src/nautilus-canvas-private.h b/src/nautilus-canvas-private.h index 0c1347098..497049560 100644 --- a/src/nautilus-canvas-private.h +++ b/src/nautilus-canvas-private.h @@ -194,9 +194,6 @@ struct NautilusCanvasContainerDetails { /* Set to TRUE after first allocation has been done */ gboolean has_been_allocated; - int size_allocation_count; - guint size_allocation_count_id; - /* a11y items used by canvas items */ guint a11y_item_action_idle_handler; GQueue* a11y_item_action_queue; |