From dd95939d260e19bac8119d430ff3d9b9279c0234 Mon Sep 17 00:00:00 2001 From: Raymond Liu Date: Thu, 7 May 2009 18:20:19 +0800 Subject: [PATCH] Emit key focus signal when stage state changes When the stage state changes between active/deactive, send out key-focus-in/key-focus-out signal for the current key focused actor on the stage. Fixes bug: http://bugzilla.openedhand.com/show_bug.cgi?id=1503 Signed-off-by: Emmanuele Bassi --- clutter/clutter-stage.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 22e891ad4..3d9dd5b3b 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -330,6 +330,33 @@ clutter_stage_hide (ClutterActor *self) clutter_actor_hide (priv->impl); } +static void +clutter_stage_emit_key_focus_event (ClutterStage *stage, + gboolean focus_in) +{ + ClutterStagePrivate *priv = stage->priv; + + if (priv->key_focused_actor == NULL) + return; + + if (focus_in) + g_signal_emit_by_name (priv->key_focused_actor, "key-focus-in"); + else + g_signal_emit_by_name (priv->key_focused_actor, "key-focus-out"); +} + +static void +clutter_stage_real_activate (ClutterStage *stage) +{ + clutter_stage_emit_key_focus_event (stage, TRUE); +} + +static void +clutter_stage_real_deactivate (ClutterStage *stage) +{ + clutter_stage_emit_key_focus_event (stage, FALSE); +} + static void clutter_stage_real_fullscreen (ClutterStage *stage) { @@ -822,6 +849,8 @@ clutter_stage_class_init (ClutterStageClass *klass) G_TYPE_NONE, 0); klass->fullscreen = clutter_stage_real_fullscreen; + klass->activate = clutter_stage_real_activate; + klass->deactivate = clutter_stage_real_deactivate; g_type_class_add_private (gobject_class, sizeof (ClutterStagePrivate)); }