From a9690a4a5e8604652048f32e2ea188aa40e0ae95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= Date: Wed, 10 Aug 2011 13:02:26 +0200 Subject: [PATCH 1/3] a11y: Using AtkWindow on cally-stage --- clutter/cally/cally-stage.c | 112 ++++++------------------------------ configure.ac | 2 +- 2 files changed, 18 insertions(+), 96 deletions(-) diff --git a/clutter/cally/cally-stage.c b/clutter/cally/cally-stage.c index 9a986c2c1..6c2c3b58e 100644 --- a/clutter/cally/cally-stage.c +++ b/clutter/cally/cally-stage.c @@ -38,16 +38,6 @@ #include "cally-stage.h" #include "cally-actor-private.h" -enum { - ACTIVATE, - CREATE, - DEACTIVATE, - DESTROY, - LAST_SIGNAL -}; - -static guint cally_stage_signals [LAST_SIGNAL] = { 0, }; - static void cally_stage_class_init (CallyStageClass *klass); static void cally_stage_init (CallyStage *stage); @@ -56,6 +46,9 @@ static void cally_stage_real_initialize (AtkObject *obj, gpointer data); static AtkStateSet* cally_stage_ref_state_set (AtkObject *obj); +/* AtkWindow */ +static void cally_stage_window_interface_init (AtkWindowIface *iface); + /* Auxiliar */ static void cally_stage_activate_cb (ClutterStage *stage, gpointer data); @@ -63,7 +56,11 @@ static void cally_stage_deactivate_cb (ClutterStage *stage, gpointer data); -G_DEFINE_TYPE (CallyStage, cally_stage, CALLY_TYPE_GROUP); +G_DEFINE_TYPE_WITH_CODE (CallyStage, + cally_stage, + CALLY_TYPE_GROUP, + G_IMPLEMENT_INTERFACE (ATK_TYPE_WINDOW, + cally_stage_window_interface_init)); #define CALLY_STAGE_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CALLY_TYPE_STAGE, CallyStagePrivate)) @@ -85,88 +82,6 @@ cally_stage_class_init (CallyStageClass *klass) class->ref_state_set = cally_stage_ref_state_set; g_type_class_add_private (gobject_class, sizeof (CallyStagePrivate)); - - /** - * CallyStage::activate: - * @cally_actor: the object which received the signal - * - * The ::activate signal is emitted when the stage receives the key - * focus from the underlying window system. - * - * Toolkit implementation note: it is used when anyone adds a global - * event listener to "window:activate" - * - * Since: 1.4 - */ - cally_stage_signals [ACTIVATE] = - g_signal_new ("activate", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, /* default signal handler */ - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /** - * CallyStage::create: - * @cally_actor: the object which received the signal - * - * The ::create signal is emitted when the stage is created. - * - * Toolkit implementation note: it is used when anyone adds a global - * event listener to "window:create" - * - * Since: 1.4 - */ - cally_stage_signals [CREATE] = - g_signal_new ("create", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, /* default signal handler */ - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /** - * CallyStage::deactivate: - * @cally_actor: the object which received the signal - * - * The ::deactivate signal is emitted when the stage loses key focus - * from the underlying window system. - * - * Toolkit implementation note: it is used when anyone adds a global - * event listener to "window:deactivate" - * - * Since: 1.4 - */ - cally_stage_signals [DEACTIVATE] = - g_signal_new ("deactivate", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, /* default signal handler */ - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /** - * CallyStage::destroy: - * @cally_actor: the object which received the signal - * - * The ::destroy signal is emitted when the stage is destroyed. - * - * Toolkit implementation note: it is used when anyone adds a global - * event listener to "window:destroy" - * - * Since: 1.4 - */ - cally_stage_signals [DESTROY] = - g_signal_new ("destroy", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, /* default signal handler */ - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); } static void @@ -246,6 +161,13 @@ cally_stage_ref_state_set (AtkObject *obj) return state_set; } +/* AtkWindow */ +static void +cally_stage_window_interface_init (AtkWindowIface *iface) +{ + /* At this moment AtkWindow is just about signals */ +} + /* Auxiliar */ static void cally_stage_activate_cb (ClutterStage *stage, @@ -262,7 +184,7 @@ cally_stage_activate_cb (ClutterStage *stage, atk_object_notify_state_change (ATK_OBJECT (cally_stage), ATK_STATE_ACTIVE, TRUE); - g_signal_emit (cally_stage, cally_stage_signals [ACTIVATE], 0); + g_signal_emit_by_name (cally_stage, "activate", 0); } static void @@ -280,5 +202,5 @@ cally_stage_deactivate_cb (ClutterStage *stage, atk_object_notify_state_change (ATK_OBJECT (cally_stage), ATK_STATE_ACTIVE, FALSE); - g_signal_emit (cally_stage, cally_stage_signals [DEACTIVATE], 0); + g_signal_emit_by_name (cally_stage, "deactivate", 0); } diff --git a/configure.ac b/configure.ac index e0bae747c..150acc58d 100644 --- a/configure.ac +++ b/configure.ac @@ -116,7 +116,7 @@ AC_HEADER_STDC m4_define([glib_req_version], [2.26.0]) m4_define([cogl_req_version], [1.7.6]) m4_define([json_glib_req_version], [0.12.0]) -m4_define([atk_req_version], [1.17]) +m4_define([atk_req_version], [2.1.5]) m4_define([cairo_req_version], [1.10]) m4_define([pango_req_version], [1.20]) m4_define([gi_req_version], [0.9.5]) From 7635cb6f171514ba3422c058d97ba48cc18a1a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= Date: Wed, 10 Aug 2011 13:06:14 +0200 Subject: [PATCH 2/3] a11y: We don't need to explicitly manage window events --- clutter/cally/cally-util.c | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/clutter/cally/cally-util.c b/clutter/cally/cally-util.c index cb3365458..744e97209 100644 --- a/clutter/cally/cally-util.c +++ b/clutter/cally/cally-util.c @@ -89,7 +89,6 @@ static void insert_hf (gpointer k gpointer value, gpointer data); static AtkKeyEventStruct * atk_key_event_from_clutter_event_key (ClutterKeyEvent *event); -static void do_window_event_initialization (void); /* This is just a copy of the Gail one, a shared library or place to @@ -184,33 +183,7 @@ cally_util_add_global_event_listener (GSignalEmissionHook listener, split_string = g_strsplit (event_type, ":", 3); - if (split_string) - { - if (!strcmp ("window", split_string[0])) - { - /* Using ClutterStage as the window equivalent, although - several methods (move, etc) are missing. This would be - probably defined for other window-related classes (MxWindow) - - FIXME: for this reason, this process should be extendable - on the future.*/ - static gboolean initialized = FALSE; - - if (initialized == FALSE) - { - do_window_event_initialization (); - initialized = TRUE; - } - - rc = add_listener (listener, "CallyStage", split_string[1], event_type); - } - else - { - rc = add_listener (listener, split_string[1], split_string[2], event_type); - } - - g_strfreev (split_string); - } + rc = add_listener (listener, split_string[1], split_string[2], event_type); return rc; } @@ -543,12 +516,3 @@ cally_util_stage_removed_cb (ClutterStageManager *stage_manager, g_signal_handlers_disconnect_by_func (stage, cally_key_snooper_cb, NULL); } - -static void -do_window_event_initialization (void) -{ - /* - * Ensure that CallyStageClass exists. - */ - g_type_class_unref (g_type_class_ref (CALLY_TYPE_STAGE)); -} From 663bfd0e85852aee23726c1a590daf54779cd40f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= Date: Wed, 10 Aug 2011 19:19:33 +0200 Subject: [PATCH 3/3] a11y: Using proper way to register to window events --- tests/accessibility/cally-atkevents-example.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/accessibility/cally-atkevents-example.c b/tests/accessibility/cally-atkevents-example.c index fc23e6f2e..0fb3943a8 100644 --- a/tests/accessibility/cally-atkevents-example.c +++ b/tests/accessibility/cally-atkevents-example.c @@ -31,6 +31,7 @@ */ #include #include +#include #include "cally-examples-util.h" @@ -163,10 +164,10 @@ main (int argc, char *argv[]) atk_remove_key_event_listener (id_2); /* event listeners */ - atk_add_global_event_listener (window_event_listener, "window:create"); - atk_add_global_event_listener (window_event_listener, "window:destroy"); - atk_add_global_event_listener (window_event_listener, "window:activate"); - atk_add_global_event_listener (window_event_listener, "window:deactivate"); + atk_add_global_event_listener (window_event_listener, "Atk:AtkWindow:create"); + atk_add_global_event_listener (window_event_listener, "Atk:AtkWindow:destroy"); + atk_add_global_event_listener (window_event_listener, "Atk:AtkWindow:activate"); + atk_add_global_event_listener (window_event_listener, "Atk:AtkWindow:deactivate"); stage = clutter_stage_get_default (); make_ui (stage);