clutter: Undo actor grabs along with ::unrealize

If an actor is being unrealized or otherwise unparented, it's a good
indication that its grabs are now stale and possibly harmful. Ensure
these are dropped when the actor is unparented.

This is now an unlikely event, since there is code to also dismiss
grabs when a visible grabbed actor goes unmapped. But that may be
prevented from happening, or the ordering of circumstances allow a
grab to be created and an actor destroyed without going unmapped
first. This grab dismission on unmap stays as it matches the UI-level
expectatives that an actor must be visible to be grabbed.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2475
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2669>
This commit is contained in:
Carlos Garnacho 2022-10-18 12:06:17 +02:00
parent 92a90774a4
commit e3df7b3384

View File

@ -2141,11 +2141,17 @@ unrealize_actor_before_children_cb (ClutterActor *self,
int depth,
void *user_data)
{
ClutterActor *stage;
/* If an actor is already unrealized we know its children have also
* already been unrealized... */
if (!CLUTTER_ACTOR_IS_REALIZED (self))
return CLUTTER_ACTOR_TRAVERSE_VISIT_SKIP_CHILDREN;
stage = _clutter_actor_get_stage_internal (self);
if (stage != NULL)
clutter_actor_clear_grabs (self);
g_signal_emit (self, actor_signals[UNREALIZE], 0);
return CLUTTER_ACTOR_TRAVERSE_VISIT_CONTINUE;
@ -5620,7 +5626,7 @@ clutter_actor_finalize (GObject *object)
_clutter_actor_get_debug_name ((ClutterActor *) object),
g_type_name (G_OBJECT_TYPE (object)));
/* No new grabs should have happened after unmapping */
/* No new grabs should have happened after unrealizing */
g_assert (priv->grabs == NULL);
g_free (priv->name);