[nautilus/wip/antoniof/flow-box-preparation: 10/14] 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: 10/14] view-icon-controller: Fix selection when scrolled
- Date: Fri, 10 Dec 2021 13:55:17 +0000 (UTC)
commit 7c36a0f6bc793e1cd72760160351696bf061548a
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 9eaa557d6..c1e885d14 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -720,6 +720,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);
@@ -729,8 +731,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;
@@ -778,6 +784,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);
@@ -786,8 +794,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]