[nautilus/wip/antoniof/gtk4-preparation-step-event-controllers: 2/22] list-view: Use coordinates passed by gesture




commit c72e76ac85c9d4450bd8f0d7758e094bb5513dd2
Author: António Fernandes <antoniof gnome org>
Date:   Wed Dec 22 01:29:29 2021 +0000

    list-view: Use coordinates passed by gesture
    
    We have coordinates right there in the gesture ::release signal, but
    are still getting coordinates from GdkEvent.
    
    This is because gtk_tree_view_get_path_at_pos() requires bin_window
    coordinates, which happened to be what the GdkEvent coordinates are
    (because bin_window is the event's GdkWindow).
    
    In order to use gesture coordinates, we need to translate them into
    bin coordinates.

 src/nautilus-list-view.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 1e5abf60b..3ae90ef8d 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -793,8 +793,8 @@ on_tree_view_multi_press_gesture_released (GtkGestureMultiPress *gesture,
     const GdkEvent *event;
     GtkTreeView *tree_view;
     GtkTreeSelection *selection;
-    gdouble event_x;
-    gdouble event_y;
+    gint x_in_bin;
+    gint y_in_bin;
     GtkTreePath *path;
     GdkModifierType state;
 
@@ -828,12 +828,12 @@ on_tree_view_multi_press_gesture_released (GtkGestureMultiPress *gesture,
     tree_view = view->details->tree_view;
     selection = gtk_tree_view_get_selection (tree_view);
 
-    if (!gdk_event_get_coords (event, &event_x, &event_y))
-    {
-        return;
-    }
 
-    if (!gtk_tree_view_get_path_at_pos (tree_view, event_x, event_y, &path, NULL, NULL, NULL))
+    gtk_tree_view_convert_widget_to_bin_window_coords (tree_view,
+                                                       x, y,
+                                                       &x_in_bin, &y_in_bin);
+
+    if (!gtk_tree_view_get_path_at_pos (tree_view, x_in_bin, y_in_bin, &path, NULL, NULL, NULL))
     {
         return;
     }


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