Don't call gtk_root_get_focus when we already have
the GtkWindowPrivate struct at hand. And use
gtk_window_set_focus to update the focus, like the
old code did.
This commit is contained in:
Matthias Clasen 2020-10-05 21:53:05 -04:00
parent 38547120b2
commit ac164d240b

View File

@ -5190,14 +5190,14 @@ gtk_window_css_changed (GtkWidget *widget,
} }
} }
/** /*
* _gtk_window_unset_focus_and_default: * _gtk_window_unset_focus_and_default:
* @window: a #GtkWindow * @window: a #GtkWindow
* @widget: a widget inside of @window * @widget: a widget inside of @window
* *
* Checks whether the focus and default widgets of @window are * Checks whether the focus and default widgets of @window are
* @widget or a descendent of @widget, and if so, unset them. * @widget or a descendent of @widget, and if so, unset them.
**/ */
void void
_gtk_window_unset_focus_and_default (GtkWindow *window, _gtk_window_unset_focus_and_default (GtkWindow *window,
GtkWidget *widget) GtkWidget *widget)
@ -5211,15 +5211,16 @@ _gtk_window_unset_focus_and_default (GtkWindow *window,
g_object_ref (window); g_object_ref (window);
g_object_ref (widget); g_object_ref (widget);
parent = _gtk_widget_get_parent (widget); focus = priv->focus_widget;
focus = gtk_root_get_focus (GTK_ROOT (window));
if (focus && (focus == widget || gtk_widget_is_ancestor (focus, widget))) if (focus && (focus == widget || gtk_widget_is_ancestor (focus, widget)))
{ {
parent = _gtk_widget_get_parent (widget);
while (parent) while (parent)
{ {
if (_gtk_widget_get_visible (parent)) if (_gtk_widget_get_visible (parent))
{ {
gtk_widget_grab_focus (parent); gtk_window_set_focus (window, parent);
break; break;
} }