[nautilus/gnome-3-20] nautilus-canvas: Don't lay down desktop icons if we haven't been allocated size yet



commit 4bd2be2e53a071c6693540a4cd285eaecb464ea2
Author: Iain Lane <iain orangesquash org uk>
Date:   Fri Oct 7 12:24:18 2016 +0100

    nautilus-canvas: Don't lay down desktop icons if we haven't been allocated size yet
    
    Sometimes we were trying to lay down icons before size_allocate had been
    run. When this has happened, gtk_widget_get_allocation returns 1×1 as
    our size. This messes up the algorithm and causes icons to be
    overlapping on the canvas.
    
    This case happens when using Nautilus as the desktop in early-startup
    (e.g. from its XDG autostart file). It can happen that we have read the
    desktop files before the allocation has happened.
    
    We fix this by noticing if we're called before size_allocate and then
    deferring icon layout until later on, after size_allocate has happened.
    
    This behaviour was introduced in commit
    e0081be7cd65de6422529d831f7882009ce00a9d, which sorts and freezes the
    desktop in early-startup.
    
    https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/1611955
    
    https://bugzilla.gnome.org/show_bug.cgi?id=765601

 libnautilus-private/nautilus-canvas-container.c |   24 ++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/libnautilus-private/nautilus-canvas-container.c b/libnautilus-private/nautilus-canvas-container.c
index e02f886..1dc70c0 100644
--- a/libnautilus-private/nautilus-canvas-container.c
+++ b/libnautilus-private/nautilus-canvas-container.c
@@ -1263,6 +1263,9 @@ lay_down_icons_horizontal (NautilusCanvasContainer *container,
 
        g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container));
 
+       /* We can't get the right allocation if the size hasn't been allocated yet */
+       g_return_if_fail (container->details->has_been_allocated);
+
        if (icons == NULL) {
                return;
        }
@@ -1724,6 +1727,9 @@ lay_down_icons_vertical_desktop (NautilusCanvasContainer *container, GList *icon
        EelDRect icon_rect;
        GtkAllocation allocation;
 
+       /* We can't get the right allocation if the size hasn't been allocated yet */
+       g_return_if_fail (container->details->has_been_allocated);
+
        /* Get container dimensions */
        gtk_widget_get_allocation (GTK_WIDGET (container), &allocation);
        height = CANVAS_HEIGHT(container, allocation);
@@ -1974,7 +1980,12 @@ static void
 redo_layout (NautilusCanvasContainer *container)
 {
        unschedule_redo_layout (container);
-       redo_layout_internal (container);
+       /* We can't lay out if the size hasn't been allocated yet; wait for it to
+        * be and then we will be called again from size_allocate ()
+        */
+       if (container->details->has_been_allocated) {
+               redo_layout_internal (container);
+       }
 }
 
 static void
@@ -7026,6 +7037,17 @@ nautilus_canvas_container_freeze_icon_positions (NautilusCanvasContainer *contai
        NautilusCanvasIcon *icon;
        NautilusCanvasPosition position;
 
+       /* This early-exit avoids freezing the icons before they have been properly
+        * positioned, since we won't re-layout if auto_layout is FALSE.
+        *
+        * The container will freeze the icons after it lays them out once we've
+        * been allocated (e.g. in lay_out_icons_vertical_desktop).
+        */
+       if (!container->details->has_been_allocated) {
+               g_debug ("Not freezing icon positions yet; we haven't been allocated");
+               return;
+       }
+
        changed = container->details->auto_layout;
        container->details->auto_layout = FALSE;
        


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