From 2f49c85d0c1ab9db3a47fa74d53c6acdfe44e9bd Mon Sep 17 00:00:00 2001 From: billh Date: Thu, 17 Jan 2002 12:17:40 +0000 Subject: [PATCH] Bugfix for keygrab regression (registryd was holding keygrabs after they should have been de-registered/released). git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@226 e2bd861d-eb25-0410-b326-f6ed22b6b98c --- ChangeLog | 21 +++++++++++++++++++++ cspi/spi_registry.c | 2 +- libspi/spi-private.h | 18 +++++++++--------- libspi/util.c | 10 +++++----- registryd/deviceeventcontroller.c | 37 +++++++++++++++++++++++++++++++------ registryd/registry.c | 18 +++++++++--------- 6 files changed, 76 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 04501bc..4d7b532 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,26 @@ 2002-01-16 Bill Haneman + * registryd/deviceeventcontroller.c: + Regression fix for keylistener de-registration; global keygrabs + were not being released when deregisterKeystrokeListener was + called in cspi, since + Accessibility_DeviceEventController_deregisterKeystrokeListener + was called with a zero-length keyset. That is because the cspi + method, SPI_deregisterKeystrokeListener, does not take a keyset + parameter but instead should remove all the key grabs held be a + keystroke listener. + The code in impl_deregister_keystroke_listener was changed to copy + the keylist from the listener instance previously registered with + the DeviceEventController before releasing the grabs. + + * registryd/registry.c: + * registryd/deviceeventcontroller.c: + * libspi/spi-private.h: + * libspi/util.c: + Changed spelling of "re-enterant" to "re-entrant" globally. + +2002-01-16 Bill Haneman + * test/test-simple.c: Changed key listeners test - the test was slightly mis-using the (admittedly poorly documented) SPI_generateKeyboardEvent API. diff --git a/cspi/spi_registry.c b/cspi/spi_registry.c index 58f7e7b..18f5dc8 100644 --- a/cspi/spi_registry.c +++ b/cspi/spi_registry.c @@ -416,7 +416,7 @@ SPI_registerAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener, **/ SPIBoolean SPI_deregisterAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener, - AccessibleKeyMaskType modmask) + AccessibleKeyMaskType modmask) { Accessibility_ControllerEventMask controller_event_mask; Accessibility_KeySet key_set; diff --git a/libspi/spi-private.h b/libspi/spi-private.h index f69f8a8..bffb151 100644 --- a/libspi/spi-private.h +++ b/libspi/spi-private.h @@ -6,17 +6,17 @@ G_BEGIN_DECLS typedef enum { - SPI_RE_ENTERANT_CONTINUE = 0, - SPI_RE_ENTERANT_TERMINATE -} SpiReEnterantContinue; + SPI_RE_ENTRANT_CONTINUE = 0, + SPI_RE_ENTRANT_TERMINATE +} SpiReEntrantContinue; -typedef SpiReEnterantContinue (*SpiReEnterantFn) (GList * const *list, - gpointer user_data); +typedef SpiReEntrantContinue (*SpiReEntrantFn) (GList * const *list, + gpointer user_data); -void spi_re_enterant_list_delete_link (GList * const *element_ptr); -void spi_re_enterant_list_foreach (GList **list, - SpiReEnterantFn func, - gpointer user_data); +void spi_re_entrant_list_delete_link (GList * const *element_ptr); +void spi_re_entrant_list_foreach (GList **list, + SpiReEntrantFn func, + gpointer user_data); G_END_DECLS diff --git a/libspi/util.c b/libspi/util.c index ea6873c..33473b7 100644 --- a/libspi/util.c +++ b/libspi/util.c @@ -11,12 +11,12 @@ typedef struct { static GSList *working_list = NULL; /* of Iteration */ /* - * deletes an element from the list - in a re-enterant + * deletes an element from the list - in a re-entrant * safe fashion; advances the element pointer to the next * element. */ void -spi_re_enterant_list_delete_link (GList * const *element_ptr) +spi_re_entrant_list_delete_link (GList * const *element_ptr) { GSList *l; GList *next; @@ -52,9 +52,9 @@ spi_re_enterant_list_delete_link (GList * const *element_ptr) } void -spi_re_enterant_list_foreach (GList **list, - SpiReEnterantFn func, - gpointer user_data) +spi_re_entrant_list_foreach (GList **list, + SpiReEntrantFn func, + gpointer user_data) { Iteration i; diff --git a/registryd/deviceeventcontroller.c b/registryd/deviceeventcontroller.c index 4338cb8..3f7731c 100644 --- a/registryd/deviceeventcontroller.c +++ b/registryd/deviceeventcontroller.c @@ -709,7 +709,7 @@ typedef struct { DEControllerKeyListener *key_listener; } RemoveKeyListenerClosure; -static SpiReEnterantContinue +static SpiReEntrantContinue remove_key_listener_cb (GList * const *list, gpointer user_data) { @@ -719,11 +719,29 @@ remove_key_listener_cb (GList * const *list, if (CORBA_Object_is_equivalent (ctx->key_listener->listener.object, key_listener->listener.object, ctx->ev)) { - spi_re_enterant_list_delete_link (list); + spi_re_entrant_list_delete_link (list); spi_dec_key_listener_free (key_listener, ctx->ev); } - return SPI_RE_ENTERANT_CONTINUE; + return SPI_RE_ENTRANT_CONTINUE; +} + +static SpiReEntrantContinue +copy_key_listener_cb (GList * const *list, + gpointer user_data) +{ + DEControllerKeyListener *key_listener = (*list)->data; + RemoveKeyListenerClosure *ctx = user_data; + + if (CORBA_Object_is_equivalent (ctx->key_listener->listener.object, + key_listener->listener.object, ctx->ev)) + { + /* TODO: FIXME aggregate keys in case the listener is registered twice */ + CORBA_free (ctx->key_listener->keys); + ctx->key_listener->keys = ORBit_copy_value (key_listener->keys, TC_Accessibility_KeySet); + } + + return SPI_RE_ENTRANT_CONTINUE; } /* @@ -751,12 +769,19 @@ impl_deregister_keystroke_listener (PortableServer_Servant serv (void *) l, (unsigned long) mask->value); #endif - spi_controller_deregister_global_keygrabs (controller, key_listener); - ctx.ev = ev; ctx.key_listener = key_listener; - spi_re_enterant_list_foreach (&controller->key_listeners, + /* special case, copy keyset from existing controller list entry */ + if (keys->_length == 0) + { + spi_re_entrant_list_foreach (&controller->key_listeners, + copy_key_listener_cb, &ctx); + } + + spi_controller_deregister_global_keygrabs (controller, key_listener); + + spi_re_entrant_list_foreach (&controller->key_listeners, remove_key_listener_cb, &ctx); spi_dec_key_listener_free (key_listener, ev); diff --git a/registryd/registry.c b/registryd/registry.c index f05a6cd..0224e8a 100644 --- a/registryd/registry.c +++ b/registryd/registry.c @@ -348,7 +348,7 @@ impl_accessibility_registry_register_global_event_listener ( } } -static SpiReEnterantContinue +static SpiReEntrantContinue remove_listener_cb (GList * const *list, gpointer user_data) { SpiListenerStruct *ls = (SpiListenerStruct *) (*list)->data; @@ -359,13 +359,13 @@ remove_listener_cb (GList * const *list, gpointer user_data) if (CORBA_Object_is_equivalent (ls->listener, listener, &ev)) { - spi_re_enterant_list_delete_link (list); + spi_re_entrant_list_delete_link (list); spi_listener_struct_free (ls, &ev); } CORBA_exception_free (&ev); - return SPI_RE_ENTERANT_CONTINUE; + return SPI_RE_ENTRANT_CONTINUE; } /* @@ -387,7 +387,7 @@ impl_accessibility_registry_deregister_global_event_listener_all ( for (i = 0; i < sizeof (lists) / sizeof (lists[0]); i++) { - spi_re_enterant_list_foreach (lists [i], remove_listener_cb, listener); + spi_re_entrant_list_foreach (lists [i], remove_listener_cb, listener); } } @@ -409,7 +409,7 @@ impl_accessibility_registry_deregister_global_event_listener ( parse_event_type (&etype, (char *) event_name); - spi_re_enterant_list_foreach (get_listener_list (registry, etype.type_cat), + spi_re_entrant_list_foreach (get_listener_list (registry, etype.type_cat), remove_listener_cb, listener); } @@ -506,7 +506,7 @@ typedef struct { Accessibility_Event e_out; } NotifyContext; -static SpiReEnterantContinue +static SpiReEntrantContinue notify_listeners_cb (GList * const *list, gpointer user_data) { SpiListenerStruct *ls; @@ -535,7 +535,7 @@ notify_listeners_cb (GList * const *list, gpointer user_data) ctx->e_out.source = bonobo_object_dup_ref (ctx->source, ctx->ev); if (BONOBO_EX (ctx->ev)) { - return SPI_RE_ENTERANT_CONTINUE;; + return SPI_RE_ENTRANT_CONTINUE;; } if ((*list) && (*list)->data == ls) @@ -555,7 +555,7 @@ notify_listeners_cb (GList * const *list, gpointer user_data) } } - return SPI_RE_ENTERANT_CONTINUE; + return SPI_RE_ENTRANT_CONTINUE; } static void @@ -580,7 +580,7 @@ impl_registry_notify_event (PortableServer_Servant servant, ctx.source = e->source; parse_event_type (&ctx.etype, e->type); - spi_re_enterant_list_foreach (list, notify_listeners_cb, &ctx); + spi_re_entrant_list_foreach (list, notify_listeners_cb, &ctx); } if (e->source != CORBA_OBJECT_NIL) -- 2.7.4