[nautilus/wip/corey/dnd_features: 76/80] list-base: Fix hotspot for DnD drag icon




commit 2bed5adac49dcf05f7d320df9b6faefc1931cc04
Author: Corey Berla <corey berla me>
Date:   Thu Aug 18 10:23:31 2022 -0700

    list-base: Fix hotspot for DnD drag icon
    
    We use a fixed size drag icon so we need to scale the drag icon
    accordingly.  The hotspot doesn't make sense for listview,
    and can produce very strange results, so simply set to 0,0.

 src/nautilus-list-base.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/src/nautilus-list-base.c b/src/nautilus-list-base.c
index db0ff2df7..f5955ea89 100644
--- a/src/nautilus-list-base.c
+++ b/src/nautilus-list-base.c
@@ -545,6 +545,7 @@ on_item_drag_prepare (GtkDragSource *source,
 {
     NautilusViewCell *cell = user_data;
     NautilusListBase *self = NAUTILUS_LIST_BASE (nautilus_view_cell_get_view (cell));
+    GtkWidget *view_ui;
     g_autolist (NautilusFile) selection = NULL;
     g_autoslist (GFile) file_list = NULL;
     g_autoptr (GdkPaintable) paintable = NULL;
@@ -577,6 +578,19 @@ on_item_drag_prepare (GtkDragSource *source,
 
     scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));
     paintable = get_paintable_for_drag_selection (selection, scale_factor);
+
+    view_ui = NAUTILUS_LIST_BASE_CLASS (G_OBJECT_GET_CLASS (self))->get_view_ui (self);
+    if (GTK_IS_GRID_VIEW (view_ui))
+    {
+        x = x * NAUTILUS_DRAG_SURFACE_ICON_SIZE / nautilus_list_base_get_icon_size (self);
+        y = y * NAUTILUS_DRAG_SURFACE_ICON_SIZE / nautilus_list_base_get_icon_size (self);
+    }
+    else
+    {
+        x = 0;
+        y = 0;
+    }
+
     gtk_drag_source_set_icon (source, paintable, x, y);
 
     return gdk_content_provider_new_typed (GDK_TYPE_FILE_LIST, file_list);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]