From 6dabdec10ea4d5a256d90b48695adf0669883d51 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 26 Jul 2022 13:53:21 +0200 Subject: [PATCH] clutter/stage: Add function to maybe invalidate pointers on an actor The function that currently invalidates pointers over an specific actor also asserts for the situations where this invalidation makes sense to happen (i.e. the actor became unmapped, or non-reactive). We want to have a function that is more forgiving, and that doesn't enforce any guarantees about the pointer focus actually changing. Part-of: --- clutter/clutter/clutter-stage-private.h | 3 +++ clutter/clutter/clutter-stage.c | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/clutter/clutter/clutter-stage-private.h b/clutter/clutter/clutter-stage-private.h index b1a8105d2..72917853f 100644 --- a/clutter/clutter/clutter-stage-private.h +++ b/clutter/clutter/clutter-stage-private.h @@ -159,6 +159,9 @@ void clutter_stage_unlink_grab (ClutterStage *self, void clutter_stage_invalidate_focus (ClutterStage *self, ClutterActor *actor); +void clutter_stage_maybe_invalidate_focus (ClutterStage *self, + ClutterActor *actor); + G_END_DECLS #endif /* __CLUTTER_STAGE_PRIVATE_H__ */ diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index e97cd54a3..17186c229 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -3175,8 +3175,8 @@ clutter_stage_set_actor_needs_immediate_relayout (ClutterStage *stage) } void -clutter_stage_invalidate_focus (ClutterStage *self, - ClutterActor *actor) +clutter_stage_maybe_invalidate_focus (ClutterStage *self, + ClutterActor *actor) { ClutterStagePrivate *priv = self->priv; GHashTableIter iter; @@ -3185,8 +3185,6 @@ clutter_stage_invalidate_focus (ClutterStage *self, if (CLUTTER_ACTOR_IN_DESTRUCTION (self)) return; - g_assert (!clutter_actor_is_mapped (actor) || !clutter_actor_get_reactive (actor)); - g_hash_table_iter_init (&iter, priv->pointer_devices); while (g_hash_table_iter_next (&iter, NULL, &value)) { @@ -3220,6 +3218,18 @@ clutter_stage_invalidate_focus (ClutterStage *self, entry->coords, CLUTTER_CURRENT_TIME); } +} + +void +clutter_stage_invalidate_focus (ClutterStage *self, + ClutterActor *actor) +{ + if (CLUTTER_ACTOR_IN_DESTRUCTION (self)) + return; + + g_assert (!clutter_actor_is_mapped (actor) || !clutter_actor_get_reactive (actor)); + + clutter_stage_maybe_invalidate_focus (self, actor); if (actor != CLUTTER_ACTOR (self)) g_assert (!clutter_actor_has_pointer (actor));