[nautilus/wip/antoniof/flowbox-to-gridview: 1/16] view-icon-controller: Properly translate coordinates




commit e4fb00388e99e93633dc024d2ae2d0d8e7c6f284
Author: António Fernandes <antoniof gnome org>
Date:   Tue Feb 1 00:53:23 2022 +0000

    view-icon-controller: Properly translate coordinates
    
    Adding/subtracting adjustment values is error-prone and ignore
    padding/margins.
    
    Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2095

 src/nautilus-view-icon-controller.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index f46044034..51ff19df6 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -676,18 +676,18 @@ get_rectangle_for_item_ui (NautilusViewIconController *self,
 {
     GdkRectangle *rectangle;
     GtkWidget *content_widget;
-    GtkAdjustment *vadjustment;
-    GtkAdjustment *hadjustment;
+    gdouble view_x;
+    gdouble view_y;
 
     rectangle = g_new0 (GdkRectangle, 1);
     gtk_widget_get_allocation (item_ui, rectangle);
 
     content_widget = nautilus_files_view_get_content_widget (NAUTILUS_FILES_VIEW (self));
-    vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (content_widget));
-    hadjustment = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (content_widget));
-
-    rectangle->x -= gtk_adjustment_get_value (hadjustment);
-    rectangle->y -= gtk_adjustment_get_value (vadjustment);
+    gtk_widget_translate_coordinates (GTK_WIDGET (self->view_ui), content_widget,
+                                      rectangle->x, rectangle->y,
+                                      &view_x, &view_y);
+    rectangle->x = view_x;
+    rectangle->y = view_y;
 
     return rectangle;
 }


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