Drop parent->realized => child->realized invariant

We already dropped this invariant in gtk_widget_verify_invariants()
because it was not true in all cases. Also, it is not really useful
these days as we extended what it means to be a "child" to also
include widgets in different toplevels.

For example, a popup in a popup button need not be realized just
because the button is in a realized window. The main invariants
we want are:

 * Parent is realized before child
 * Widget is realized before it is mapped

This sounds like its not a huge deal, but in fact it is a massive win
for things like menus, because when we go between menus in a menubar
each switch between two open menus involves a lot of intermingled
crossing events to different surfaces and for each of these the
tooltip window of the toplevel gets assigned to the new surface.  This
shouldn't be a huge deal, as the tooltip window is not even visible,
but due to the realized invariant it get re-realized each time it gets
re-assigned.
This commit is contained in:
Alexander Larsson 2020-04-28 14:32:57 +02:00
parent f66950f48c
commit c6104fe7fd

View File

@ -5901,11 +5901,7 @@ gtk_widget_reposition_after (GtkWidget *widget,
if (prev_parent == NULL)
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_PARENT]);
/* Enforce realized/mapped invariants
*/
if (_gtk_widget_get_realized (priv->parent))
gtk_widget_realize (widget);
/* Enforce mapped invariants */
if (_gtk_widget_get_visible (priv->parent) &&
_gtk_widget_get_visible (widget))
{