Blame SOURCES/nautilus-canvas-container-Remove-the-include-visible.patch

82f35c
From a7a31137aee8c4af81d7d447ceb83ccdb2ddadc0 Mon Sep 17 00:00:00 2001
82f35c
From: Xiang Fan <sfanxiang@gmail.com>
82f35c
Date: Fri, 13 Jul 2018 11:49:09 -0700
82f35c
Subject: [PATCH] nautilus-canvas-container: Remove the "include visible area"
82f35c
 logic.
82f35c
82f35c
canvas_set_scroll_region_include_visible_area() was added in
82f35c
ec054c80981e26b71c8bb2e6853b035dc2063e7d to fix
82f35c
https://bugzilla.gnome.org/show_bug.cgi?id=42068 ("Dragging icons
82f35c
adjusts scroll area in a way that causes immediate scrolling"). This is
82f35c
no longer the case, because now icons remain in place when being dragged
82f35c
and are not allowed to be rearranged.
82f35c
82f35c
ec054c80981e26b71c8bb2e6853b035dc2063e7d causes issues relating to extra
82f35c
scrolling space (#340), hence the removal.
82f35c
82f35c
Fixes #340.
82f35c
---
82f35c
 src/nautilus-canvas-container.c | 79 +--------------------------------
82f35c
 src/nautilus-canvas-container.h |  1 -
82f35c
 src/nautilus-canvas-private.h   |  3 --
82f35c
 src/nautilus-canvas-view.c      |  6 ---
82f35c
 4 files changed, 1 insertion(+), 88 deletions(-)
82f35c
82f35c
diff --git a/src/nautilus-canvas-container.c b/src/nautilus-canvas-container.c
82f35c
index 09acd47fc..bd05a3a2d 100644
82f35c
--- a/src/nautilus-canvas-container.c
82f35c
+++ b/src/nautilus-canvas-container.c
82f35c
@@ -968,45 +968,6 @@ get_all_icon_bounds (NautilusCanvasContainer       *container,
82f35c
                                        x1, y1, x2, y2, usage);
82f35c
 }
82f35c
 
82f35c
-/* Don't preserve visible white space the next time the scroll region
82f35c
- * is recomputed when the container is not empty. */
82f35c
-void
82f35c
-nautilus_canvas_container_reset_scroll_region (NautilusCanvasContainer *container)
82f35c
-{
82f35c
-    container->details->reset_scroll_region_trigger = TRUE;
82f35c
-}
82f35c
-
82f35c
-/* Set a new scroll region without eliminating any of the currently-visible area. */
82f35c
-static void
82f35c
-canvas_set_scroll_region_include_visible_area (EelCanvas *canvas,
82f35c
-                                               double     x1,
82f35c
-                                               double     y1,
82f35c
-                                               double     x2,
82f35c
-                                               double     y2)
82f35c
-{
82f35c
-    double old_x1, old_y1, old_x2, old_y2;
82f35c
-    double old_scroll_x, old_scroll_y;
82f35c
-    double height, width;
82f35c
-    GtkAllocation allocation;
82f35c
-
82f35c
-    eel_canvas_get_scroll_region (canvas, &old_x1, &old_y1, &old_x2, &old_y2);
82f35c
-    gtk_widget_get_allocation (GTK_WIDGET (canvas), &allocation);
82f35c
-
82f35c
-    width = (allocation.width) / canvas->pixels_per_unit;
82f35c
-    height = (allocation.height) / canvas->pixels_per_unit;
82f35c
-
82f35c
-    old_scroll_x = gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas)));
82f35c
-    old_scroll_y = gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas)));
82f35c
-
82f35c
-    x1 = MIN (x1, old_x1 + old_scroll_x);
82f35c
-    y1 = MIN (y1, old_y1 + old_scroll_y);
82f35c
-    x2 = MAX (x2, old_x1 + old_scroll_x + width);
82f35c
-    y2 = MAX (y2, old_y1 + old_scroll_y + height);
82f35c
-
82f35c
-    eel_canvas_set_scroll_region
82f35c
-        (canvas, x1, y1, x2, y2);
82f35c
-}
82f35c
-
82f35c
 void
82f35c
 nautilus_canvas_container_update_scroll_region (NautilusCanvasContainer *container)
82f35c
 {
82f35c
@@ -1014,24 +975,10 @@ nautilus_canvas_container_update_scroll_region (NautilusCanvasContainer *contain
82f35c
     double pixels_per_unit;
82f35c
     GtkAdjustment *hadj, *vadj;
82f35c
     float step_increment;
82f35c
-    gboolean reset_scroll_region;
82f35c
     GtkAllocation allocation;
82f35c
 
82f35c
     pixels_per_unit = EEL_CANVAS (container)->pixels_per_unit;
82f35c
 
82f35c
-    reset_scroll_region = container->details->reset_scroll_region_trigger
82f35c
-                          || nautilus_canvas_container_is_empty (container);
82f35c
-
82f35c
-    /* The trigger is only cleared when container is non-empty, so
82f35c
-     * callers can reliably reset the scroll region when an item
82f35c
-     * is added even if extraneous relayouts are called when the
82f35c
-     * window is still empty.
82f35c
-     */
82f35c
-    if (!nautilus_canvas_container_is_empty (container))
82f35c
-    {
82f35c
-        container->details->reset_scroll_region_trigger = FALSE;
82f35c
-    }
82f35c
-
82f35c
     get_all_icon_bounds (container, &x1, &y1, &x2, &y2, BOUNDS_USAGE_FOR_ENTIRE_ITEM);
82f35c
 
82f35c
     /* Add border at the "end"of the layout (i.e. after the icons), to
82f35c
@@ -1053,18 +1000,7 @@ nautilus_canvas_container_update_scroll_region (NautilusCanvasContainer *contain
82f35c
     y2 -= 1;
82f35c
     y2 = MAX (y1, y2);
82f35c
 
82f35c
-    if (reset_scroll_region)
82f35c
-    {
82f35c
-        eel_canvas_set_scroll_region
82f35c
-            (EEL_CANVAS (container),
82f35c
-            x1, y1, x2, y2);
82f35c
-    }
82f35c
-    else
82f35c
-    {
82f35c
-        canvas_set_scroll_region_include_visible_area
82f35c
-            (EEL_CANVAS (container),
82f35c
-            x1, y1, x2, y2);
82f35c
-    }
82f35c
+    eel_canvas_set_scroll_region (EEL_CANVAS (container), x1, y1, x2, y2);
82f35c
 
82f35c
     hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container));
82f35c
     vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container));
82f35c
@@ -5722,23 +5658,10 @@ nautilus_canvas_container_get_icon_drop_target_uri (NautilusCanvasContainer *con
82f35c
     return uri;
82f35c
 }
82f35c
 
82f35c
-/* Call to reset the scroll region only if the container is not empty,
82f35c
- * to avoid having the flag linger until the next file is added.
82f35c
- */
82f35c
-static void
82f35c
-reset_scroll_region_if_not_empty (NautilusCanvasContainer *container)
82f35c
-{
82f35c
-    if (!nautilus_canvas_container_is_empty (container))
82f35c
-    {
82f35c
-        nautilus_canvas_container_reset_scroll_region (container);
82f35c
-    }
82f35c
-}
82f35c
-
82f35c
 /* Re-sort, switching to automatic layout if it was in manual layout. */
82f35c
 void
82f35c
 nautilus_canvas_container_sort (NautilusCanvasContainer *container)
82f35c
 {
82f35c
-    reset_scroll_region_if_not_empty (container);
82f35c
     container->details->needs_resort = TRUE;
82f35c
     redo_layout (container);
82f35c
 }
82f35c
diff --git a/src/nautilus-canvas-container.h b/src/nautilus-canvas-container.h
82f35c
index a370bba26..33929375d 100644
82f35c
--- a/src/nautilus-canvas-container.h
82f35c
+++ b/src/nautilus-canvas-container.h
82f35c
@@ -271,7 +271,6 @@ void              nautilus_canvas_container_set_single_click_mode         (Nauti
82f35c
 									   gboolean                single_click_mode);
82f35c
 void              nautilus_canvas_container_enable_linger_selection       (NautilusCanvasContainer  *view,
82f35c
 									   gboolean                enable);
82f35c
-void              nautilus_canvas_container_reset_scroll_region           (NautilusCanvasContainer  *container);
82f35c
 void              nautilus_canvas_container_set_font                      (NautilusCanvasContainer  *container,
82f35c
 									   const char             *font); 
82f35c
 void              nautilus_canvas_container_set_margins                   (NautilusCanvasContainer  *container,
82f35c
diff --git a/src/nautilus-canvas-private.h b/src/nautilus-canvas-private.h
82f35c
index dd5e79060..e60e86299 100644
82f35c
--- a/src/nautilus-canvas-private.h
82f35c
+++ b/src/nautilus-canvas-private.h
82f35c
@@ -192,9 +192,6 @@ struct NautilusCanvasContainerDetails {
82f35c
 
82f35c
 	int size_allocation_count;
82f35c
 	guint size_allocation_count_id;
82f35c
-	
82f35c
-	/* Ignore the visible area the next time the scroll region is recomputed */
82f35c
-	gboolean reset_scroll_region_trigger;
82f35c
 
82f35c
 	/* a11y items used by canvas items */
82f35c
 	guint a11y_item_action_idle_handler;
82f35c
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
82f35c
index f74ea06db..bd3a7ae5d 100644
82f35c
--- a/src/nautilus-canvas-view.c
82f35c
+++ b/src/nautilus-canvas-view.c
82f35c
@@ -355,12 +355,6 @@ nautilus_canvas_view_add_files (NautilusFilesView *view,
82f35c
     canvas_view = NAUTILUS_CANVAS_VIEW (view);
82f35c
     canvas_container = get_canvas_container (canvas_view);
82f35c
 
82f35c
-    /* Reset scroll region for the first canvas added when loading a directory. */
82f35c
-    if (nautilus_files_view_get_loading (view) && nautilus_canvas_container_is_empty (canvas_container))
82f35c
-    {
82f35c
-        nautilus_canvas_container_reset_scroll_region (canvas_container);
82f35c
-    }
82f35c
-
82f35c
     for (l = files; l != NULL; l = l->next)
82f35c
     {
82f35c
         if (nautilus_canvas_container_add (canvas_container,
82f35c
-- 
82f35c
2.37.1
82f35c