Bugfixes for
authorbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Thu, 13 Jun 2002 22:31:32 +0000 (22:31 +0000)
committerbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Thu, 13 Jun 2002 22:31:32 +0000 (22:31 +0000)
#79865
#81139
#85205
#84735

git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@318 e2bd861d-eb25-0410-b326-f6ed22b6b98c

ChangeLog
atk-bridge/bridge.c
cspi/bonobo/cspi-bonobo-listener.c
cspi/spi-private.h
cspi/spi_main.c
libspi/base.c
registryd/deviceeventcontroller.c

index 89b31e7..0141215 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,46 @@
+2002-06-13  Bill Haneman  <bill.haneman@sun.com>
+
+       * registryd/deviceeventcontroller.c:
+       (spi_controller_update_key_grabs):
+       Fix for #84735, subsequent keygrab listeners not informed of
+       registration failure.
+
+       * libspi/base.c:
+       (spi_base_construct):
+       Add an assertion on construct, to make sure the GObject passed in
+       is really a GObject.
+       (spi_base_init):
+       Explicitly initialize object->gobj pointer to NULL;
+
+       * cspi/bonobo/cspi-bonobo-listener.c:
+       (cspi_object_add_ref):
+       New method, can specify whether to dup-ref a bonobo object passed
+       in if it's newly added to the object cache.
+       (cspi_object_add):
+       Now calls cspi_object_add_ref with second param of "FALSE".  This
+       prevents us from doing a pointless dup-ref followed by
+       release-unref for all those cases where the object is already in
+       our object cache (fix for #85205).
+
+       * atk-bridge/bridge.c:
+       (spi_atk_bridge_idle_init):
+       Removed this method, we don't need to initialize in an idle
+       handler anymore;
+       (atk_bridge_init):
+       Changed to call spi_atk_register_event_listeners directly, not via an
+       idle handler. (fix for #81139)
+       (gnome_accessibility_module_shutdown):
+       Removed conditional around deregistration of listeners, since we
+       don't use the idle handler and thus have always registered when
+       shutdown is called.
+       (spi_init_keystroke_from_atk_key_event):
+       Changed references to Accessibility_KEY_PRESSED to 
+       Accessibility_KEY_PRESSED_EVENT, etc. (fix for #79865).
+       
 2002-06-12  Bill Haneman  <bill.haneman@sun.com>
 
+       (TAGGED AND BRANCHED for gnome-2-0-0 after this commit)
+       
        * configure.in:
        Revved to 1.0.1
 
index 974b483..7cb489d 100644 (file)
@@ -42,7 +42,6 @@ static SpiApplication *this_app = NULL;
 
 static void     spi_atk_bridge_exit_func               (void);
 static void     spi_atk_register_event_listeners       (void);
-static gboolean spi_atk_bridge_idle_init               (gpointer               user_data);
 static void     spi_atk_bridge_focus_tracker           (AtkObject             *object);
 static gboolean spi_atk_bridge_property_event_listener (GSignalInvocationHint *signal_hint,
                                                        guint                  n_param_values,
@@ -72,7 +71,6 @@ extern void gnome_accessibility_module_shutdown (void);
 static int     atk_bridge_initialized = FALSE;
 static guint   atk_bridge_focus_tracker_id = 0;
 static guint   atk_bridge_key_event_listener_id = 0;
-static guint   idle_init_id = 0;
 static GArray *listener_ids = NULL;
 
 /*
@@ -139,7 +137,9 @@ atk_bridge_init (gint *argc, gchar **argv[])
 
   g_atexit (spi_atk_bridge_exit_func);
 
-  idle_init_id = g_idle_add (spi_atk_bridge_idle_init, NULL);
+  spi_atk_register_event_listeners ();
+
+  fprintf (stderr, "Application registered & listening\n");
 
   return 0;
 }
@@ -150,18 +150,6 @@ gtk_module_init (gint *argc, gchar **argv[])
        return atk_bridge_init (argc, argv);
 }
 
-static gboolean
-spi_atk_bridge_idle_init (gpointer user_data)
-{
-  idle_init_id = 0;
-
-  spi_atk_register_event_listeners ();
-
-  fprintf (stderr, "Application registered & listening\n");
-
-  return FALSE;
-}
-
 static void
 add_signal_listener (const char *signal_name)
 {
@@ -302,7 +290,9 @@ void
 gnome_accessibility_module_shutdown (void)
 {
   BonoboObject *app = (BonoboObject *) this_app;
-
+  int     i;
+  GArray *ids = listener_ids;
+  
   if (!atk_bridge_initialized)
     {
       return;
@@ -312,26 +302,15 @@ gnome_accessibility_module_shutdown (void)
 
   g_print("Atk Accessibilty bridge shutdown\n");
 
-  if (idle_init_id)
-    {
-      g_source_remove (idle_init_id);
-      idle_init_id = 0;
-    }
-  else
-    {
-      int     i;
-      GArray *ids = listener_ids;
-
-      listener_ids = NULL;
-      atk_remove_focus_tracker (atk_bridge_focus_tracker_id);
-      
-      for (i = 0; ids && i < ids->len; i++)
-        {
+  listener_ids = NULL;
+  atk_remove_focus_tracker (atk_bridge_focus_tracker_id);
+  
+  for (i = 0; ids && i < ids->len; i++)
+  {
           atk_remove_global_event_listener (g_array_index (ids, guint, i));
-       }
-
-      atk_remove_key_event_listener (atk_bridge_key_event_listener_id);
-    }
+  }
+  
+  atk_remove_key_event_listener (atk_bridge_key_event_listener_id);
 
   deregister_application (app);
 }
@@ -513,10 +492,10 @@ spi_init_keystroke_from_atk_key_event (Accessibility_DeviceEvent  *keystroke,
   switch (event->type)
     {
     case (ATK_KEY_EVENT_PRESS):
-      keystroke->type = Accessibility_KEY_PRESSED;
+      keystroke->type = Accessibility_KEY_PRESSED_EVENT;
       break;
     case (ATK_KEY_EVENT_RELEASE):
-      keystroke->type = Accessibility_KEY_RELEASED;
+      keystroke->type = Accessibility_KEY_RELEASED_EVENT;
       break;
     default:
       keystroke->type = 0;
@@ -535,7 +514,12 @@ spi_atk_bridge_key_listener (AtkKeyEventStruct *event, gpointer data)
 {
   CORBA_boolean             result;
   Accessibility_DeviceEvent key_event;
-  Accessibility_DeviceEventController controller =
+  Accessibility_DeviceEventController controller;
+       
+  if (BONOBO_EX (&ev))
+       g_warning ("failure: pre-listener get dec\n");
+
+  controller =
     Accessibility_Registry_getDeviceEventController (registry, &ev);
 
   if (BONOBO_EX (&ev))
index fe6c9b4..0c200f8 100644 (file)
@@ -93,7 +93,7 @@ cspi_event (SpiEventListener    *listener,
   AccessibleEvent    aevent;
   Accessible        *source;
 
-  source = cspi_object_add (bonobo_object_dup_ref (event->source, cspi_ev ()));
+  source = cspi_object_add_ref (event->source, TRUE);
 
   aevent.type    = event->type;
   aevent.source  = source;
index 22f9423..7ed7d6e 100644 (file)
@@ -42,6 +42,8 @@ CORBA_Environment     *cspi_ev               (void);
 SPIBoolean             cspi_exception        (void);
 Accessibility_Registry cspi_registry         (void);
 Accessible            *cspi_object_add       (CORBA_Object         corba_object);
+Accessible            *cspi_object_add_ref   (CORBA_Object         corba_object,
+                                             gboolean             do_ref);
 void                   cspi_object_ref       (Accessible          *accessible);
 void                   cspi_object_unref     (Accessible          *accessible);
 SPIBoolean             cspi_accessible_is_a  (Accessible          *obj,
index 471fe5f..346a7d1 100644 (file)
@@ -159,6 +159,12 @@ cspi_exception (void)
 Accessible *
 cspi_object_add (CORBA_Object corba_object)
 {
+       return cspi_object_add_ref (corba_object, FALSE);
+}
+
+Accessible *
+cspi_object_add_ref (CORBA_Object corba_object, gboolean do_ref)
+{
   Accessible *ref;
 
   if (corba_object == CORBA_OBJECT_NIL)
@@ -175,7 +181,8 @@ cspi_object_add (CORBA_Object corba_object)
         {
           g_assert (ref->ref_count > 0);
          ref->ref_count++;
-          cspi_release_unref (corba_object);
+          if (!do_ref) 
+               cspi_release_unref (corba_object);
 #ifdef DEBUG_OBJECTS
           g_print ("returning cached %p => %p\n", ref, ref->objref);
 #endif
@@ -187,8 +194,14 @@ cspi_object_add (CORBA_Object corba_object)
 #ifdef DEBUG_OBJECTS
           g_print ("allocating %p => %p\n", ref, corba_object);
 #endif
-
-          ref->objref = corba_object;
+         if (do_ref) {
+#ifdef JAVA_BRIDGE_BUG_IS_FIXED
+                 g_assert (CORBA_Object_is_a (corba_object,
+                                               "IDL:Bonobo/Unknown:1.0", cspi_ev ()));
+#endif
+                 ref->objref = bonobo_object_dup_ref (corba_object, cspi_ev ());
+         } else 
+                 ref->objref = corba_object;
           ref->ref_count = 1;
 
           g_hash_table_insert (cspi_get_live_refs (), ref->objref, ref);
index 7c602d6..577a385 100644 (file)
@@ -63,6 +63,7 @@ spi_base_class_init (SpiBaseClass *klass)
 static void
 spi_base_init (SpiBase *object)
 {
+       object->gobj = NULL;
 }
 
 BONOBO_TYPE_FUNC (SpiBase, PARENT_TYPE, spi_base);
@@ -70,7 +71,8 @@ BONOBO_TYPE_FUNC (SpiBase, PARENT_TYPE, spi_base);
 void
 spi_base_construct (SpiBase *object, GObject *gobject)
 {
-  object->gobj = g_object_ref (gobject);
+ g_assert (G_IS_OBJECT (gobject));
+ object->gobj = g_object_ref (gobject);
 }
 
 void
index df45578..f8e4982 100644 (file)
@@ -678,7 +678,8 @@ spi_controller_update_key_grabs (SpiDEController           *controller,
                                 Accessibility_DeviceEvent *recv)
 {
   GList *l, *next;
-
+  gboolean   update_failed = FALSE;
+  
   g_return_val_if_fail (controller != NULL, FALSE);
 
   /*
@@ -736,7 +737,6 @@ spi_controller_update_key_grabs (SpiDEController           *controller,
 #ifdef SPI_DEBUG
          fprintf (stderr, "grab with mask %x\n", grab_mask->mod_mask);
 #endif
-         XSynchronize (spi_get_display(), True);
           XGrabKey (spi_get_display (),
                    grab_mask->key_val,
                    grab_mask->mod_mask,
@@ -744,7 +744,12 @@ spi_controller_update_key_grabs (SpiDEController           *controller,
                    True,
                    GrabModeAsync,
                    GrabModeAsync);
-         XSynchronize (spi_get_display(), False);
+         XSync (spi_get_display (), False);
+         update_failed = spi_clear_error_state ();
+         if (update_failed) {
+                 while (grab_mask->ref_count > 0) --grab_mask->ref_count;
+                 do_remove = TRUE;
+         }
        }
 
       grab_mask->pending_add = FALSE;
@@ -762,7 +767,7 @@ spi_controller_update_key_grabs (SpiDEController           *controller,
 
     } 
 
-  return ! spi_clear_error_state ();
+  return ! update_failed;
 }
 
 /*