GNOME Bugzilla – Bug 657259
Window events should be registered as any other event
Last modified: 2011-08-29 21:45:55 UTC
Bug 638924 was solved, so we don't need to keep registering to window events as a exception.
Created attachment 194628 [details] [review] Using the proper format to register the events This patch is conservative, as it also tries to register to the window events with the old format. I think that this is required until all ATK implementors moves to the new format. In order to do that I just try to register using the old format. If it was a success we assume that the ATK implementor is "old". This should work, although the bad news is that you would get a warning with an updated ATK implementor.
Comment on attachment 194628 [details] [review] Using the proper format to register the events >From cb2f09781d865393ed7866f9499fa65ce819a04d Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= <apinheiro@igalia.com> >Date: Tue, 23 Aug 2011 17:07:02 +0200 >Subject: [PATCH] Using new format to register to window events > >Now ATK has AtkWindow, so the format to register to window events >is like any other ATK event > >We check if we need to register using the old format, assuming that >if you are able to register to a window event using the old format >is because the ATK implementor is still using the old one. This >check should be temporal. >--- > atk-adaptor/event.c | 48 +++++++++++++++++++++++++++++++++++++++--------- > configure.ac | 2 +- > 2 files changed, 40 insertions(+), 10 deletions(-) > >diff --git a/atk-adaptor/event.c b/atk-adaptor/event.c >index f5a2d2d..af1943b 100644 >--- a/atk-adaptor/event.c >+++ b/atk-adaptor/event.c >@@ -2,6 +2,7 @@ > * AT-SPI - Assistive Technology Service Provider Interface > * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) > * >+ * Copyright 2011, F123 Consulting & Mais Diferenças > * Copyright 2008, 2009, Codethink Ltd. > * Copyright 2001, 2002, 2003 Sun Microsystems Inc., > * Copyright 2001, 2002, 2003 Ximian, Inc. >@@ -1068,13 +1069,17 @@ generic_event_listener (GSignalInvocationHint * signal_hint, > * and stores the signal id returned so that the function may be > * de-registered later. > */ >-static void >+static guint > add_signal_listener (GSignalEmissionHook listener, const char *signal_name) > { > guint id; > > id = atk_add_global_event_listener (listener, signal_name); >- g_array_append_val (listener_ids, id); >+ >+ if (id > 0) /* id == 0 is a failure */ >+ g_array_append_val (listener_ids, id); >+ >+ return id; > } > > /* >@@ -1091,6 +1096,7 @@ spi_atk_register_event_listeners (void) > */ > GObject *ao = g_object_new (ATK_TYPE_OBJECT, NULL); > AtkObject *bo = atk_no_op_object_new (ao); >+ guint id = 0; > > g_object_unref (G_OBJECT (bo)); > g_object_unref (ao); >@@ -1108,13 +1114,37 @@ spi_atk_register_event_listeners (void) > > add_signal_listener (property_event_listener, > "Gtk:AtkObject:property-change"); >- add_signal_listener (window_event_listener, "window:create"); >- add_signal_listener (window_event_listener, "window:destroy"); >- add_signal_listener (window_event_listener, "window:minimize"); >- add_signal_listener (window_event_listener, "window:maximize"); >- add_signal_listener (window_event_listener, "window:restore"); >- add_signal_listener (window_event_listener, "window:activate"); >- add_signal_listener (window_event_listener, "window:deactivate"); >+ >+ /* window events: we tentative try to register using the old format */ >+ id = add_signal_listener (window_event_listener, "window:create"); >+ >+ if (id != 0) >+ { >+ /* If we are able to register using the old format, we assume >+ * that the ATK implementor is managing window events without >+ * AtkWindow. We can't use the opposite test because after >+ * including AtkWindow on ATK you would be able to register to >+ * that event, although the ATK implementor could or not use it. >+ */ >+ >+ add_signal_listener (window_event_listener, "window:destroy"); >+ add_signal_listener (window_event_listener, "window:minimize"); >+ add_signal_listener (window_event_listener, "window:maximize"); >+ add_signal_listener (window_event_listener, "window:restore"); >+ add_signal_listener (window_event_listener, "window:activate"); >+ add_signal_listener (window_event_listener, "window:deactivate"); >+ } >+ else >+ { >+ add_signal_listener (window_event_listener, "Atk:AtkWindow:create"); >+ add_signal_listener (window_event_listener, "Atk:AtkWindow:destroy"); >+ add_signal_listener (window_event_listener, "Atk:AtkWindow:minimize"); >+ add_signal_listener (window_event_listener, "Atk:AtkWindow:maximize"); >+ add_signal_listener (window_event_listener, "Atk:AtkWindow:restore"); >+ add_signal_listener (window_event_listener, "Atk:AtkWindow:activate"); >+ add_signal_listener (window_event_listener, "Atk:AtkWindow:deactivate"); >+ } >+ > add_signal_listener (document_event_listener, > "Gtk:AtkDocument:load-complete"); > add_signal_listener (document_event_listener, "Gtk:AtkDocument:reload"); >diff --git a/configure.ac b/configure.ac >index 096e98e..91c2497 100644 >--- a/configure.ac >+++ b/configure.ac >@@ -51,7 +51,7 @@ PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.0.0]) > AC_SUBST(GMODULE_LIBS) > AC_SUBST(GMODULE_CFLAGS) > >-PKG_CHECK_MODULES(ATK, [atk >= 2.1.0]) >+PKG_CHECK_MODULES(ATK, [atk >= 2.1.5]) > AC_SUBST(ATK_LIBS) > AC_SUBST(ATK_CFLAGS) > >-- >1.7.5.4 >
Sorry for the delay--this slipped my mind until now. The patch seemed okay to me from my brief testing, so I've committed it for the release.