From 01362effca53d0a3149e3f81f6374b1440cbe2cd Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 10 Sep 2010 11:42:11 +0100 Subject: [PATCH] actor: Add a method for querying key focus A simple convenience method on Clutter.Actor for checking whether it has key focus assigned on the Stage to which it belongs. --- clutter/clutter-actor.c | 24 ++++++++++++++++++++++ clutter/clutter-actor.h | 2 ++ doc/reference/clutter/clutter-sections.txt | 1 + 3 files changed, 27 insertions(+) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index edae92f08..82112abea 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -11643,3 +11643,27 @@ clutter_actor_clear_effects (ClutterActor *self) _clutter_meta_group_clear_metas (self->priv->effects); } + +/** + * clutter_actor_has_key_focus: + * @self: a #ClutterActor + * + * Checks whether @self is the #ClutterActor that has key focus + * + * Return value: %TRUE if the actor has key focus, and %FALSE otherwise + * + * Since: 1.4 + */ +gboolean +clutter_actor_has_key_focus (ClutterActor *self) +{ + ClutterActor *stage; + + g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE); + + stage = clutter_actor_get_stage_internal (self); + if (stage == NULL) + return FALSE; + + return clutter_stage_get_key_focus (CLUTTER_STAGE (stage)) == self; +} diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h index 830c982b0..0aac1011c 100644 --- a/clutter/clutter-actor.h +++ b/clutter/clutter-actor.h @@ -585,6 +585,8 @@ gboolean clutter_actor_has_allocation (ClutterActor *sel AtkObject * clutter_actor_get_accessible (ClutterActor *self); +gboolean clutter_actor_has_key_focus (ClutterActor *self); + G_END_DECLS #endif /* __CLUTTER_ACTOR_H__ */ diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index b3d911833..854c3ac2b 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -403,6 +403,7 @@ clutter_actor_set_shader_param_float clutter_actor_set_shader_param_int +clutter_actor_has_key_focus clutter_actor_grab_key_focus clutter_actor_get_pango_context clutter_actor_create_pango_context