From 92c2c68c7b9692f5d4292f21a96a5a3b913ff52e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 3 Feb 2023 14:16:40 +0100 Subject: [PATCH] filechooser: Fix context menus We only want to show the file list context menu when we are over the file list. Fixes: #5554 --- gtk/gtkfilechooserwidget.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 38b674dbce..b6382ccdba 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -7222,16 +7222,21 @@ popup_menu (GtkWidget *widget, } static void -file_chooser_widget_clicked (GtkEventController *controller, - int n_press, - double x, - double y, - gpointer user_data) +file_chooser_widget_clicked (GtkEventController *controller, + int n_press, + double x, + double y, + GtkFileChooserWidget *impl) { - GtkWidget *widget = user_data; + GtkWidget *widget = GTK_WIDGET (impl); + GtkWidget *child; - gtk_gesture_set_state (GTK_GESTURE (controller), GTK_EVENT_SEQUENCE_CLAIMED); - popup_menu (widget, x, y); + child = gtk_widget_pick (widget, x, y, 0); + if (gtk_widget_is_ancestor (child, impl->browse_files_stack)) + { + gtk_gesture_set_state (GTK_GESTURE (controller), GTK_EVENT_SEQUENCE_CLAIMED); + popup_menu (widget, x, y); + } } static void