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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3629>
This commit is contained in:
Carlos Garnacho 2024-03-01 22:33:18 +01:00 committed by Marge Bot
parent 525ed1166c
commit 6cee9410f5

View File

@ -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