Commit 41c7cb2a authored by Alexander Larsson's avatar Alexander Larsson

icon-view: Only resort during relayout if necessary

We don't need to resort unless e.g. a file changed or was added.

Additionally, for weird reason this makes the keyboard focus handling
work when deleting a file (file after deleted gets focus). This was
broken due to a relayout happening due to a size_allocate due to
a style set due to a focus change when going to/from the "are you sure"
dialog.
parent 31546b50
......@@ -2147,7 +2147,10 @@ redo_layout_internal (NautilusIconContainer *container)
*/
if (container->details->auto_layout
&& container->details->drag_state != DRAG_STATE_STRETCH) {
resort (container);
if (container->details->needs_resort) {
resort (container);
container->details->needs_resort = FALSE;
}
lay_down_icons (container, container->details->icons, 0);
}
......@@ -7193,6 +7196,8 @@ nautilus_icon_container_add (NautilusIconContainer *container,
g_hash_table_insert (details->icon_set, data, icon);
details->needs_resort = TRUE;
/* Run an idle function to add the icons. */
schedule_redo_layout (container);
......@@ -7265,6 +7270,7 @@ nautilus_icon_container_request_update (NautilusIconContainer *container,
if (icon != NULL) {
nautilus_icon_container_update_icon (container, icon);
container->details->needs_resort = TRUE;
schedule_redo_layout (container);
}
}
......@@ -7329,6 +7335,7 @@ nautilus_icon_container_request_update_all (NautilusIconContainer *container)
nautilus_icon_container_update_icon (container, icon);
}
container->details->needs_resort = TRUE;
redo_layout (container);
}
......@@ -7896,6 +7903,7 @@ nautilus_icon_container_set_auto_layout (NautilusIconContainer *container,
nautilus_icon_container_freeze_icon_positions (container);
}
container->details->needs_resort = TRUE;
redo_layout (container);
g_signal_emit (container, signals[LAYOUT_CHANGED], 0);
......@@ -7962,6 +7970,7 @@ nautilus_icon_container_set_layout_mode (NautilusIconContainer *container,
container->details->layout_mode = mode;
invalidate_labels (container);
container->details->needs_resort = TRUE;
redo_layout (container);
g_signal_emit (container, signals[LAYOUT_CHANGED], 0);
......@@ -8023,6 +8032,7 @@ nautilus_icon_container_sort (NautilusIconContainer *container)
container->details->auto_layout = TRUE;
reset_scroll_region_if_not_empty (container);
container->details->needs_resort = TRUE;
redo_layout (container);
if (changed) {
......
......@@ -274,6 +274,7 @@ struct NautilusIconContainerDetails {
GQueue* a11y_item_action_queue;
eel_boolean_bit is_loading : 1;
eel_boolean_bit needs_resort : 1;
eel_boolean_bit store_layout_timestamps : 1;
eel_boolean_bit store_layout_timestamps_when_finishing_new_icons : 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment