File nautilus-fix-desktop-icon-smash.patch of Package nautilus

From d82b5bb6e06b6761bd5d5f3dc9a0762ce55517b4 Mon Sep 17 00:00:00 2001
From: Iain Lane <iain@orangesquash.org.uk>
Date: Fri, 7 Oct 2016 12:24:18 +0100
Subject: [PATCH] nautilus-canvas: Don't lay down desktop icons if we haven't

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://bugzilla.suse.com/show_bug.cgi?id=979072

https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/1611955

https://bugzilla.gnome.org/show_bug.cgi?id=765601

diff -Nura nautilus-3.20.3_orginal/libnautilus-private/nautilus-canvas-container.c nautilus-3.20.3_new/libnautilus-private/nautilus-canvas-container.c
--- nautilus-3.20.3_orginal/libnautilus-private/nautilus-canvas-container.c	2016-08-30 09:04:26.000000000 +0000
+++ nautilus-3.20.3_new/libnautilus-private/nautilus-canvas-container.c	2016-10-09 06:55:34.225215876 +0000
@@ -1263,6 +1263,9 @@
 
 	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 @@
 	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,13 @@
 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 +7038,18 @@
 	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;
 	
openSUSE Build Service is sponsored by