From 579a9a2665b402405820585dacba137984700110 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 1 Feb 2010 11:04:59 +0000 Subject: [PATCH] stage: Add :key-focus property ClutterStage has both set_key_focus() and get_key_focus() methods, but there is no :key-focus property. This means that it is not possible to get notifications when the key-focus has changes except by connecting to both the ::key-focus-in and ::key-focus-out signals and do additional bookkeeping. http://bugzilla.openedhand.com/show_bug.cgi?id=1956 Signed-off-by: Emmanuele Bassi --- clutter/clutter-stage.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 518d181c7..38abc7480 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -113,7 +113,8 @@ enum PROP_USER_RESIZE, PROP_USE_FOG, PROP_FOG, - PROP_USE_ALPHA + PROP_USE_ALPHA, + PROP_KEY_FOCUS }; enum @@ -694,6 +695,10 @@ clutter_stage_set_property (GObject *object, clutter_stage_set_use_alpha (stage, g_value_get_boolean (value)); break; + case PROP_KEY_FOCUS: + clutter_stage_set_key_focus (stage, g_value_get_object (value)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -750,6 +755,10 @@ clutter_stage_get_property (GObject *gobject, g_value_set_boolean (value, priv->use_alpha); break; + case PROP_KEY_FOCUS: + g_value_set_object (value, priv->key_focused_actor); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; @@ -994,6 +1003,23 @@ clutter_stage_class_init (ClutterStageClass *klass) CLUTTER_PARAM_READWRITE); g_object_class_install_property (gobject_class, PROP_USE_ALPHA, pspec); + /** + * ClutterStage:key-focus: + * + * The #ClutterActor that will receive key events from the underlying + * windowing system. + * + * If %NULL, the #ClutterStage will receive the events. + * + * Since: 1.2 + */ + pspec = g_param_spec_object ("key-focus", + "Key Focus", + "The currently key focused actor", + CLUTTER_TYPE_ACTOR, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (gobject_class, PROP_KEY_FOCUS, pspec); + /** * ClutterStage::fullscreen * @stage: the stage which was fullscreened @@ -1749,6 +1775,8 @@ clutter_stage_set_key_focus (ClutterStage *stage, } else g_signal_emit_by_name (stage, "key-focus-in"); + + g_object_notify (G_OBJECT (stage), "key-focus"); } /**