[nautilus/wip/antoniof/flow-box-preparation: 19/29] view-icon-controller: Fix selection when scrolled
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/flow-box-preparation: 19/29] view-icon-controller: Fix selection when scrolled
- Date: Fri, 10 Dec 2021 14:05:47 +0000 (UTC)
commit 735219f14ecd32486be8420fc0bf1cceabfdb6a3
Author: António Fernandes <antoniof gnome org>
Date: Wed Dec 8 23:25:56 2021 +0000
view-icon-controller: Fix selection when scrolled
We add a click gesture to the scrolled window, not the view itself,
because we need to get background context menus on whitespace around
the flowbox (not only padding but bottom whitespace when the rows
don't fill the whole height).
Because of that, the selected item may not be the one which the user
had selected (e.g. if the view is scrolled away from the top).
Translate the coordinates properly to properly select the item where
the user had clicked. Do the same for the longpress gesture.
src/nautilus-view-icon-controller.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index a51f4e4f9..c12a8d4da 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -698,6 +698,8 @@ on_button_press_event (GtkGestureMultiPress *gesture,
GdkEventSequence *sequence;
const GdkEvent *event;
g_autolist (NautilusFile) selection = NULL;
+ gint view_x;
+ gint view_y;
GtkWidget *child_at_pos;
self = NAUTILUS_VIEW_ICON_CONTROLLER (user_data);
@@ -707,8 +709,12 @@ on_button_press_event (GtkGestureMultiPress *gesture,
/* Need to update the selection so the popup has the right actions enabled */
selection = nautilus_view_get_selection (NAUTILUS_VIEW (self));
+
+ gtk_widget_translate_coordinates (gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)),
+ GTK_WIDGET (self->view_ui),
+ x, y, &view_x, &view_y);
child_at_pos = GTK_WIDGET (gtk_flow_box_get_child_at_pos (self->view_ui,
- x, y));
+ view_x, view_y));
if (child_at_pos != NULL)
{
NautilusFile *selected_file;
@@ -756,6 +762,8 @@ on_longpress_gesture_pressed_callback (GtkGestureLongPress *gesture,
GtkWidget *child_at_pos;
GdkEventSequence *event_sequence;
GdkEvent *event;
+ gint view_x;
+ gint view_y;
event_sequence = gtk_gesture_get_last_updated_sequence (GTK_GESTURE (gesture));
event = (GdkEvent *) gtk_gesture_get_last_event (GTK_GESTURE (gesture), event_sequence);
@@ -764,8 +772,11 @@ on_longpress_gesture_pressed_callback (GtkGestureLongPress *gesture,
/* Need to update the selection so the popup has the right actions enabled */
selection = nautilus_view_get_selection (NAUTILUS_VIEW (self));
+ gtk_widget_translate_coordinates (gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)),
+ GTK_WIDGET (self->view_ui),
+ x, y, &view_x, &view_y);
child_at_pos = GTK_WIDGET (gtk_flow_box_get_child_at_pos (self->view_ui,
- x, y));
+ view_x, view_y));
if (child_at_pos != NULL)
{
NautilusFile *selected_file;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]