[mutter/wip/carlosg/grabs-pt1: 87/93] clutter: Notify grab changes on the key focus
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/grabs-pt1: 87/93] clutter: Notify grab changes on the key focus
- Date: Tue, 7 Dec 2021 21:33:01 +0000 (UTC)
commit c1d9ccdbc1a8bda42480d651c18a19b8146e3ec1
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Oct 27 18:00:25 2021 +0200
clutter: Notify grab changes on the key focus
Dissociate clutter_stage_set_key_focus() from the actors focused
state, so that it obeys stage grabs. The key focus actor state may
also change due to grab changes, add the code to notify about this.
clutter/clutter/clutter-stage.c | 49 ++++++++++++++++++++++++++++++++++++-----
1 file changed, 44 insertions(+), 5 deletions(-)
---
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 8b29197579..f1e8c4a4fb 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -2026,13 +2026,23 @@ clutter_stage_set_key_focus (ClutterStage *stage,
* intended. The order of events would be:
* 1st focus-out, 2nd focus-out (on stage), 2nd focus-in, 1st focus-in
*/
- if (actor != NULL)
+ priv->key_focused_actor = actor;
+
+ /* If the key focused actor is allowed to receive key events according
+ * to the given grab (or there is none) set key focus on it, otherwise
+ * key focus is delayed until there are grabbing conditions that allow
+ * it to get key focus.
+ */
+ if (!priv->grabs ||
+ priv->grabs->actor == CLUTTER_ACTOR (stage) ||
+ priv->grabs->actor == actor ||
+ (actor && clutter_actor_contains (priv->grabs->actor, actor)))
{
- priv->key_focused_actor = actor;
- _clutter_actor_set_has_key_focus (actor, TRUE);
+ if (actor != NULL)
+ _clutter_actor_set_has_key_focus (actor, TRUE);
+ else
+ _clutter_actor_set_has_key_focus (CLUTTER_ACTOR (stage), TRUE);
}
- else
- _clutter_actor_set_has_key_focus (CLUTTER_ACTOR (stage), TRUE);
g_object_notify_by_pspec (G_OBJECT (stage), obj_props[PROP_KEY_FOCUS]);
}
@@ -3754,6 +3764,33 @@ clutter_stage_notify_grab_on_entry (ClutterStage *stage,
}
}
+static void
+clutter_stage_notify_grab_on_key_focus (ClutterStage *stage,
+ ClutterActor *grab_actor,
+ ClutterActor *old_grab_actor)
+{
+ ClutterStagePrivate *priv = stage->priv;
+ ClutterActor *key_focus;
+ gboolean focus_in_grab, focus_in_old_grab;
+
+ key_focus = priv->key_focused_actor ?
+ priv->key_focused_actor : CLUTTER_ACTOR (stage);
+
+ focus_in_grab =
+ !grab_actor ||
+ grab_actor == key_focus ||
+ clutter_actor_contains (grab_actor, key_focus);
+ focus_in_old_grab =
+ !old_grab_actor ||
+ old_grab_actor == key_focus ||
+ clutter_actor_contains (old_grab_actor, key_focus);
+
+ if (focus_in_grab && !focus_in_old_grab)
+ _clutter_actor_set_has_key_focus (CLUTTER_ACTOR (key_focus), TRUE);
+ else if (!focus_in_grab && focus_in_old_grab)
+ _clutter_actor_set_has_key_focus (CLUTTER_ACTOR (key_focus), FALSE);
+}
+
static void
clutter_stage_notify_grab (ClutterStage *stage,
ClutterGrab *cur,
@@ -3792,6 +3829,8 @@ clutter_stage_notify_grab (ClutterStage *stage,
cur_actor,
old_actor);
}
+
+ clutter_stage_notify_grab_on_key_focus (stage, cur_actor, old_actor);
}
ClutterGrab *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]