From abf22e3edda214dcf572cb9c2dfd13cccc2619c6 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 18 Sep 2023 19:42:41 +0200 Subject: [PATCH] gtkwindow: Pick a suitable widget to continue the implicit grab When a widget in the GtkPointerFocus stack becomes insensitive, we've so far broken the implicit grab entirely. This has the side effect of breaking accounting of the active state on the widgets that are ancestors of the widget that became insensitive. The easiest, and most consistent thing to do (i.e. giving widgets in the GtkPointerFocus stack certain level of isolation wrt state changes in other widgets) is to transfer the implicit grab to the topmost actor of the GtkPointerFocus stack that can keep handling events. This fixes the unbalanced accounting of active state on ancestors of widgets becoming insensitive, and avoids thorny questions about how to handle implicit active state with broken implicit grabs. --- gtk/gtkwindow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 9c94d9726f..2eb94d6f7e 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -6554,7 +6554,8 @@ gtk_window_update_pointer_focus_on_state_change (GtkWindow *window, gtk_widget_is_ancestor (focus->grab_widget, widget))) { clear_widget_active_state (focus->grab_widget, widget); - gtk_pointer_focus_set_implicit_grab (focus, NULL); + gtk_pointer_focus_set_implicit_grab (focus, + gtk_widget_get_parent (widget)); } if (GTK_WIDGET (focus->toplevel) == widget) -- 2.30.2