From 6cee9410f55d637cd923f7ed31cee6d4c80a99cc Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 1 Mar 2024 22:33:18 +0100 Subject: [PATCH] clutter: Bypass priv->has_key_focus when unsetting focus from self This is conditionally toggled by grabs on the current key focus depending on whether the current key focus actor would receive events according to the grab or not. Which means it's no longer a reliable method for an actor to know it does have focus, without asking the stage about it. Avoid this check and ask the stage for the key focus, in order to make key focus actors able to unset themselves despite the presence of grabs. Part-of: --- clutter/clutter/clutter-actor.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index b3897987b..f9487b99e 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -1502,13 +1502,14 @@ maybe_unset_key_focus (ClutterActor *self) { ClutterActor *stage; - if (!self->priv->has_key_focus) + stage = _clutter_actor_get_stage_internal (self); + if (!stage) return; - stage = _clutter_actor_get_stage_internal (self); + if (self != clutter_stage_get_key_focus (CLUTTER_STAGE (stage))) + return; - if (stage) - clutter_stage_set_key_focus (CLUTTER_STAGE (stage), NULL); + clutter_stage_set_key_focus (CLUTTER_STAGE (stage), NULL); } static void