GimpPopup: Ignore grabs from windows / menus shown by internal widgets

Fixes https://gitlab.gnome.org/GNOME/gimp/-/issues/6989
This commit is contained in:
Luca Bacci 2023-12-31 18:05:46 +01:00
parent e4e3dcca6b
commit 0532e1b0ea
1 changed files with 20 additions and 1 deletions

View File

@ -116,13 +116,32 @@ static void
gimp_popup_grab_notify (GtkWidget *widget,
gboolean was_grabbed)
{
GtkWidget *grab_widget;
GtkWidget *iter;
if (was_grabbed)
return;
grab_widget = gtk_grab_get_current ();
/* ignore grabs on one of our children, like a scrollbar */
if (gtk_widget_is_ancestor (gtk_grab_get_current (), widget))
if (gtk_widget_is_ancestor (grab_widget, widget))
return;
/* ignore grabs from windows / menus shown by
* internal widgets */
iter = gtk_widget_get_toplevel (grab_widget);
while (iter)
{
if (iter == widget)
return;
if (GTK_IS_WINDOW (iter))
iter = (GtkWidget*) gtk_window_get_transient_for ((GtkWindow*) iter);
else
break;
}
g_signal_emit (widget, popup_signals[CANCEL], 0);
}