From 4dd135e751374a5e2b2d88ae4c60db4084999837 Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Tue, 14 Mar 2023 13:21:46 +0100 Subject: [PATCH] Revert "list-base: Remove rubberband hack" This reverts commit c1c7ccb0e23772d8cfb509eb133d7e522706c697 as it turned out that the workaround is still needed. I've only updated the obsolete comment a bit. The issue was initially fixed by the https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4831 merge request, but it has been broken later. Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/5670 Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2844 --- src/nautilus-list-base.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/nautilus-list-base.c b/src/nautilus-list-base.c index 827a3e1de..8d16c682e 100644 --- a/src/nautilus-list-base.c +++ b/src/nautilus-list-base.c @@ -312,6 +312,28 @@ open_context_menu_on_press (NautilusListBase *self, view_x, view_y); } +static void +rubberband_set_state (NautilusListBase *self, + gboolean enabled) +{ + /* This is a temporary workaround to deal with the rubberbanding issues + * during a drag and drop. Disable rubberband on item press and enable + * rubberband on item release/stop. See: + * https://gitlab.gnome.org/GNOME/gtk/-/issues/5670 */ + + GtkWidget *view; + + view = NAUTILUS_LIST_BASE_CLASS (G_OBJECT_GET_CLASS (self))->get_view_ui (self); + if (GTK_IS_GRID_VIEW (view)) + { + gtk_grid_view_set_enable_rubberband (GTK_GRID_VIEW (view), enabled); + } + else if (GTK_IS_COLUMN_VIEW (view)) + { + gtk_column_view_set_enable_rubberband (GTK_COLUMN_VIEW (view), enabled); + } +} + static void on_item_click_pressed (GtkGestureClick *gesture, gint n_press, @@ -337,6 +359,8 @@ on_item_click_pressed (GtkGestureClick *gesture, n_press == 1 && !selection_mode); + rubberband_set_state (self, FALSE); + /* It's safe to claim event sequence on press in the following cases because * they don't interfere with touch scrolling. */ if (button == GDK_BUTTON_PRIMARY && n_press == 2 && !priv->single_click_mode) @@ -395,6 +419,7 @@ on_item_click_released (GtkGestureClick *gesture, activate_selection_on_click (self, FALSE); } + rubberband_set_state (self, TRUE); priv->activate_on_release = FALSE; priv->deny_background_click = FALSE; } @@ -407,6 +432,7 @@ on_item_click_stopped (GtkGestureClick *gesture, g_autoptr (NautilusListBase) self = nautilus_view_cell_get_view (cell); NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self); + rubberband_set_state (self, TRUE); priv->activate_on_release = FALSE; priv->deny_background_click = FALSE; } @@ -978,6 +1004,9 @@ real_begin_loading (NautilusFilesView *files_view) NautilusListBase *self = NAUTILUS_LIST_BASE (files_view); NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self); + /* Temporary workaround */ + rubberband_set_state (self, TRUE); + /*TODO move this to the files view class begin_loading and hook up? */ -- 2.40.0