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




commit 8e7be9923eea20e642c7848081ac29e1219ab7dd
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 942e6b340..ee1c99a6a 100644
--- a/src/nautilus-list-base.c
+++ b/src/nautilus-list-base.c
@@ -541,6 +541,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;
@@ -573,6 +574,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]