window: Don't focus invisible widgets

Only clear a queued move_focus if the widget
we are focusing is actually visible.

This was happening in some cases when popovers
are dismissed by clicking outside, and it was
causing us to miss proper focus updates that
were already queued.
This commit is contained in:
Matthias Clasen 2022-10-17 15:10:51 -04:00
parent 100605ef0c
commit f5063c1435

View File

@ -2004,7 +2004,9 @@ gtk_window_root_set_focus (GtkRoot *root,
if (focus == priv->focus_widget)
{
priv->move_focus = FALSE;
if (priv->move_focus &&
focus && gtk_widget_is_visible (focus))
priv->move_focus = FALSE;
return;
}
@ -2024,7 +2026,9 @@ gtk_window_root_set_focus (GtkRoot *root,
g_clear_object (&old_focus);
priv->move_focus = FALSE;
if (priv->move_focus &&
focus && gtk_widget_is_visible (focus))
priv->move_focus = FALSE;
g_object_notify (G_OBJECT (self), "focus-widget");
}
@ -4689,7 +4693,7 @@ maybe_unset_focus_and_default (GtkWindow *window)
break;
}
parent = _gtk_widget_get_parent (parent);
parent = _gtk_widget_get_parent (parent);
}
}