diff options
author | Corey Berla <corey@berla.me> | 2022-08-08 12:14:24 -0700 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2022-08-12 15:02:57 +0000 |
commit | adce60cf9a5902b0aaaddf6e1edde9820b1f52e7 (patch) | |
tree | 1ba6541d51689859afcdc894fd3aa214b6507048 /src/nautilus-list-base.c | |
parent | 65da6b94701702b4918c43817377d689cf9294fd (diff) | |
download | nautilus-adce60cf9a5902b0aaaddf6e1edde9820b1f52e7.tar.gz |
dnd: Make "change location on hover" a little bit less aggressive
Reset the hover timeout if the x,y passes the GTK drag threshold
before the HOVER_TIMEOUT. This makes it less likely that a location
will occur if the drag is merely happening over an item. In GTK4
the cells cover a bigger space so this is even more likely to occur.
Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/1526
Diffstat (limited to 'src/nautilus-list-base.c')
-rw-r--r-- | src/nautilus-list-base.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/nautilus-list-base.c b/src/nautilus-list-base.c index 4bd754b8e..9b283473d 100644 --- a/src/nautilus-list-base.c +++ b/src/nautilus-list-base.c @@ -49,6 +49,7 @@ struct _NautilusListBasePrivate GdkDragAction drag_item_action; GdkDragAction drag_view_action; + graphene_point_t hover_start_point; guint hover_timer_id; GtkDropTarget *view_drop_target; }; @@ -586,6 +587,26 @@ on_item_drag_hover_leave (GtkDropControllerMotion *controller, g_clear_handle_id (&priv->hover_timer_id, g_source_remove); } +static void +on_item_drag_hover_motion (GtkDropControllerMotion *controller, + gdouble x, + gdouble y, + gpointer user_data) +{ + NautilusViewCell *cell = user_data; + g_autoptr (NautilusListBase) self = nautilus_view_cell_get_view (cell); + NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self); + graphene_point_t start = priv->hover_start_point; + + if (gtk_drag_check_threshold (GTK_WIDGET (cell), start.x, start.y, x, y)) + { + g_clear_handle_id (&priv->hover_timer_id, g_source_remove); + priv->hover_timer_id = g_timeout_add (HOVER_TIMEOUT, hover_timer, cell); + priv->hover_start_point.x = x; + priv->hover_start_point.y = y; + } +} + static GdkDragAction get_preferred_action (NautilusFile *target_file, const GValue *value) @@ -886,6 +907,7 @@ setup_cell_common (GtkListItem *listitem, gtk_widget_add_controller (GTK_WIDGET (cell), controller); g_signal_connect (controller, "enter", G_CALLBACK (on_item_drag_hover_enter), cell); g_signal_connect (controller, "leave", G_CALLBACK (on_item_drag_hover_leave), cell); + g_signal_connect (controller, "motion", G_CALLBACK (on_item_drag_hover_motion), cell); } static void |