Re: [g-a-devel]active-descendant-changed signal and at-spi



I have managed to add support to at-spi for active-descendat-changed signal 
which does not crash the application. Comments requested.

Padraig

> Subject: Re: [g-a-devel]active-descendant-changed signal and at-spi
> To: "Padraig O'Briain" <Padraig Obriain sun com>
> Cc: michael ximian com, gnome-accessibility-devel gnome org
> Mime-Version: 1.0
> 
> On Thu, 2002-12-05 at 11:14, Padraig O'Briain wrote:
> > I have started trying to add support for active-descendant-changed in the 
bridge 
> > and I have hit a problem.
> > 
> > The any_data field in Accessibility_Event is a CORBA_any and the function 
> > spi_init_any_object() returns a CORBA_any for a CORBA_object. I have an 
> > AtkObject. I can create an SpiAccessible from it but how do I get a 
> > CORBA_object?
> 
> Padraig:
> 
> spi_init_any_object returns null; but of course it does 'return' a
> CORBA_Any in an 'inout' param, so to speak.  Since an SpiAccessible is
> an instance of BonoboObject, you can use BONOBO_OBJREF () for this.
> Of course the usual concerns about duplicating refs before marshalling
> them via CORBA apply.
> 
> I should have you look at my current patch for cspi's (now private)
> method cspi_internal_event_get_object () to make sure everything adds up
> in this context.  At the moment it uses a 
> borrow-ref-return sequence to ensure that the "Accessible *" (pointer to
> a corba object reference) which it returns is either live or a NULL
> pointer (if the object in question is dead by the time it's
> demarshalled).  However this patch requires that cspi_dup_ref passes the
> cspi_ev() environment variable to the bonobo_object_dup_ref() call
> rather than the current NULL pointer, so I wanted to get Michael's
> opinion before going further with this patch.
> 
> regards,
> 
> Bill
> 
> (patch attached)
> 
> 
> 
> 
> > Padraig
> > 
> > > > The only interesting thing in the active-descendant-changed signal is 
the 
> > object 
> > > > which is the new active descendant.
> > > > 
> > > > Do I need to call BONOBO_OBJECT_REF (spi_accessible_new()) on it and 
stick 
> > it 
> > > > into the any_data field?
> > > 
> > > If you did, you of course would need to unref it again after the event
> > > emission since at the moment listeners are not guaranteed to do the
> > > unref (and it would be more traffic over the wire anyway).  
> > > 
> > > You will note that at the moment the code to do this lives in
> > > spi_atk_signal_emit_event (and, in turn, in spi_init_any_object () which
> > > it calls); there's some commented-out stuff for the child-changed
> > > signal, and presumably we'd need to add code to handle the
> > > active-descendant-changed signal as well.  As Michael has pointed out
> > > recently, the existing code is not the correct way of doing this (see
> > > below), which is the main reason the implementation is commented out
> > > until somebody has time to do this thoughtfully and properly.
> > > 
> > > For the cases where the Any contains an object reference I think we
> > > should not take ownership of the reference or increment it; this has the
> > > disadvantage that the listener must make sure the object is still alive
> > > before using the reference, but the advantage of preventing leaks and
> > > extra CORBA traffic if the listening client doesn't choose to use the
> > > reference.
> > > 
> > > In the meantime if you just add the signal listener, we can handle the
> > > any_data initialization in the emission handler (above), just as we
> > > intend to for child-changed events once we get spi_init_any_object()
> > > fixed.
> > > 
> > > -Bill
> > > 
> > > > Padraig
> > > > 
> > > > > Subject: Re: [g-a-devel]active-descendant-changed signal and at-spi
> > > > > To: "Padraig O'Briain" <Padraig Obriain Sun COM>
> > > > > Cc: accessibility mailing list <gnome-accessibility-devel gnome org>
> > > > > Mime-Version: 1.0
> > > > > Content-Transfer-Encoding: 7bit
> > > > > 
> > > > > Hi Padraig,
> > > > > 
> > > > > On Wed, 2002-11-27 at 11:48, Padraig O'Briain wrote:
> > > > > > I am trying to figure out what needs to change in at-spi to support 
> > > > > > active-descendant-changed signal.
> > > > > > 
> > > > > > It looks like a signal handler for it needs to be added to the 
bridge.
> > > > > 
> > > > > 	Quite.
> > > > > 
> > > > > > What should happen when the signal is emitted?
> > > > > 
> > > > > 	You get to make up some string name for it; ram whatever detail 
you
> > > > > think is useful into the event structure; and do an emitv of some sort
> > > > > in the handler.
> > > > > 
> > > > > 	HTH,
> > > > > 
> > > > > 		Michael.
> > > > > 
> > > > > -- 
> > > > >  mmeeks gnu org  <><, Pseudo Engineer, itinerant idiot
> > > > > 
> > > > 
> > > > _______________________________________________
> > > > Gnome-accessibility-devel mailing list
> > > > Gnome-accessibility-devel gnome org
> > > > http://mail.gnome.org/mailman/listinfo/gnome-accessibility-devel
> > > 
> > > 
> > > _______________________________________________
> > > Gnome-accessibility-devel mailing list
> > > Gnome-accessibility-devel gnome org
> > > http://mail.gnome.org/mailman/listinfo/gnome-accessibility-devel
> > 
> 
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/at-spi/ChangeLog,v
retrieving revision 1.265
diff -u -p -r1.265 ChangeLog
--- ChangeLog	2 Dec 2002 17:25:55 -0000	1.265
+++ ChangeLog	6 Dec 2002 09:56:07 -0000
@@ -1,3 +1,22 @@
+2002-12-06  Padraig O'Briain  <padraig obriain sun com>
+
+	* atk-bridge/bridge.c:
+	(spi_atk_bridge_init_event_type_consts): Store signal id for
+	active-descendant-changed signal.
+	(spi_atk_register_event_listeners): Add signal listener for
+	active-descendant-changed signal,
+	(spi_atk_bridge_signal_listener): Move code in function 
+	spi_atk-signal_emit_event() into this function.
+	Add support for active-descendant-changed
+	Update support for child-changed signal.
+	(spi_bridge_window_event_listener): Silence warning.
+
+	* libspi/spi_private.[ch]:
+	(spi_init_any_object): Change second parameter from CORBA_Object to
+	CORBA_Object*.
+	Omit call to CORBA_Object_duplicate(). 
+	Set CORBA_any's _value to CORBA_Obvejct*.	
+
 2002-12-02  Bill Haneman  <bill haneman sun com>
 
 	Removed some of the more dangerous workarounds from
Index: atk-bridge/bridge.c
===================================================================
RCS file: /cvs/gnome/at-spi/atk-bridge/bridge.c,v
retrieving revision 1.54
diff -u -p -r1.54 bridge.c
--- atk-bridge/bridge.c	24 Nov 2002 14:49:50 -0000	1.54
+++ atk-bridge/bridge.c	6 Dec 2002 09:56:08 -0000
@@ -30,6 +30,7 @@
 #include <atk/atkobject.h>
 #include <atk/atknoopobject.h>
 #include <libspi/Accessibility.h>
+#include <libspi/spi-private.h>
 #include "accessible.h"
 #include "application.h"
 
@@ -62,10 +63,10 @@ static guint toplevel_handler;
 
 static guint atk_signal_text_changed;
 static guint atk_signal_child_changed;
+static guint atk_signal_active_descendant_changed;
 
 /* NOT YET USED
    static guint atk_signal_text_selection_changed;
-   static guint atk_signal_active_descendant_changed;
    static guint atk_signal_row_reordered;
    static guint atk_signal_row_inserted;
    static guint atk_signal_row_deleted;
@@ -128,6 +129,9 @@ spi_atk_bridge_init_event_type_consts ()
 					      ATK_TYPE_OBJECT);
   atk_signal_text_changed = g_signal_lookup ("text_changed", 
 					     ATK_TYPE_TEXT);
+  atk_signal_active_descendant_changed = 
+         g_signal_lookup ("active_descendant_changed", 
+		          ATK_TYPE_OBJECT);
 }
 
 static int
@@ -317,6 +321,7 @@ spi_atk_register_event_listeners (void)
 
   add_signal_listener ("Gtk:AtkObject:children-changed");
   add_signal_listener ("Gtk:AtkObject:visible-data-changed");
+  add_signal_listener ("Gtk:AtkObject:active-descendant-changed");
   add_signal_listener ("Gtk:AtkSelection:selection-changed");
   add_signal_listener ("Gtk:AtkText:text-selection-changed");
   add_signal_listener ("Gtk:AtkText:text-changed");
@@ -488,7 +493,7 @@ spi_atk_emit_eventv (const GObject      
       e.detail2 = detail2;
       if (any) e.any_data = *any;
       else spi_init_any_nil (&e.any_data);
-      
+
 #ifdef SPI_BRIDGE_DEBUG
       s = Accessibility_Accessible__get_name (BONOBO_OBJREF (source), &ev);
       g_warning ("Emitting event '%s' (%lu, %lu) on %s",
@@ -586,7 +591,6 @@ spi_atk_bridge_state_event_listener (GSi
   return TRUE;
 }
 
-
 static void
 spi_init_keystroke_from_atk_key_event (Accessibility_DeviceEvent  *keystroke,
 				       AtkKeyEventStruct          *event)
@@ -673,59 +677,6 @@ spi_atk_bridge_key_listener (AtkKeyEvent
   return result;
 }
 
-
-static void
-spi_atk_signal_emit_event (const GObject *gobject, 
-			   const GSignalQuery *signal_query,
-			   long detail1, 
-			   long detail2,
-			   const gchar *name, 
-			   const gchar *detail)
-{
-  CORBA_any any;
-  CORBA_char *sp = NULL;
-  AtkObject *ao;
-
-  if (signal_query->signal_id == atk_signal_text_changed)
-    {
-      sp = atk_text_get_text (ATK_TEXT (gobject),
-			      detail1,
-			      detail1+detail2);
-      spi_init_any_string (&any, &sp);
-    }
-#ifdef EXTENDED_OBJECT_EVENTS_ARE_WORKING
-  else if ((signal_query->signal_id == atk_signal_child_changed) && gobject)
-    {
-      ao = atk_object_ref_accessible_child (ATK_OBJECT (gobject), 
-					    detail1);
-      if (ao) 
-	{
-	  spi_init_any_object (&any, ao); 
-	  atk_object_unref (ao);
-	}
-      else
-	{
-	  spi_init_any_nil (&any);
-	}
-    }
-#endif
-  else
-    {
-      spi_init_any_nil (&any);
-    }
-
-  if (detail)
-    spi_atk_emit_eventv (gobject, detail1, detail2, &any,
-			 "object:%s:%s", name, detail);
-  else
-    spi_atk_emit_eventv (gobject, detail1, detail2, &any,
-			 "object:%s", name);
-  if (sp)
-    g_free (sp);
-}
-
-
-
 static gboolean
 spi_atk_bridge_signal_listener (GSignalInvocationHint *signal_hint,
 				guint n_param_values,
@@ -736,9 +687,12 @@ spi_atk_bridge_signal_listener (GSignalI
   GSignalQuery signal_query;
   const gchar *name;
   const gchar *detail;
-  CORBA_char *sp;
-  
+  CORBA_any any;
+  CORBA_Object c_obj;
+  char *sp = NULL;
+  AtkObject *ao;
   gint detail1 = 0, detail2 = 0;
+  SpiAccessible *s_ao = NULL;
 #ifdef SPI_BRIDGE_DEBUG
   const gchar *s, *s2;
 #endif 
@@ -760,14 +714,66 @@ spi_atk_bridge_signal_listener (GSignalI
 #endif
   
   gobject = g_value_get_object (param_values + 0);
-  if (G_VALUE_TYPE (param_values + 1) == G_TYPE_INT)
-    detail1 = g_value_get_int (param_values + 1);
-  if (G_VALUE_TYPE (param_values + 2) == G_TYPE_INT)
-    detail2 = g_value_get_int (param_values + 2);
-  
-  spi_atk_signal_emit_event (gobject, &signal_query,
-			     detail2, detail2,
-			     name, detail);
+
+  if (signal_query.signal_id == atk_signal_active_descendant_changed)
+    {
+      gpointer child = g_value_get_pointer (param_values + 1);
+
+      g_return_val_if_fail (ATK_IS_OBJECT (child), TRUE);
+
+      ao = ATK_OBJECT (child);
+
+      detail1 = atk_object_get_index_in_parent (ao);
+      s_ao = spi_accessible_new (ao);
+      c_obj = BONOBO_OBJREF (s_ao);
+      spi_init_any_object (&any, &c_obj);
+    }
+  else
+    {
+      if (G_VALUE_TYPE (param_values + 1) == G_TYPE_INT)
+        detail1 = g_value_get_int (param_values + 1);
+      if (G_VALUE_TYPE (param_values + 2) == G_TYPE_INT)
+        detail2 = g_value_get_int (param_values + 2);
+
+      if (signal_query.signal_id == atk_signal_text_changed)
+        {
+          sp = atk_text_get_text (ATK_TEXT (gobject),
+	    		          detail1,
+			          detail1+detail2);
+          spi_init_any_string (&any, &sp);
+        }
+      else if ((signal_query.signal_id == atk_signal_child_changed) && gobject)
+        {
+          ao = atk_object_ref_accessible_child (ATK_OBJECT (gobject), 
+					        detail1);
+          if (ao) 
+	    {
+              s_ao = spi_accessible_new (ao);
+              c_obj = BONOBO_OBJREF (s_ao);
+              spi_init_any_object (&any, &c_obj);
+	      g_object_unref (ao);
+	    }
+          else
+	    {
+	      spi_init_any_nil (&any);
+	    }
+        }
+      else
+        {
+	  spi_init_any_nil (&any);
+        }
+    }
+
+  if (detail)
+    spi_atk_emit_eventv (gobject, detail1, detail2, &any,
+			 "object:%s:%s", name, detail);
+  else
+    spi_atk_emit_eventv (gobject, detail1, detail2, &any,
+			 "object:%s", name);
+
+  if (sp)
+    g_free (sp);
+
   return TRUE;
 }
 
@@ -799,7 +805,7 @@ spi_atk_bridge_window_event_listener (GS
   gobject = g_value_get_object (param_values + 0);
 
   s = atk_object_get_name (ATK_OBJECT (gobject));
-  spi_init_any_string (&any, &s);
+  spi_init_any_string (&any, (char **) &s);
   
   spi_atk_emit_eventv (gobject, 0, 0, &any,
 		       "window:%s", name);
Index: libspi/spi-private.h
===================================================================
RCS file: /cvs/gnome/at-spi/libspi/spi-private.h,v
retrieving revision 1.6
diff -u -p -r1.6 spi-private.h
--- libspi/spi-private.h	20 Nov 2002 00:17:13 -0000	1.6
+++ libspi/spi-private.h	6 Dec 2002 09:56:08 -0000
@@ -47,7 +47,7 @@ void spi_re_entrant_list_foreach     (GL
 				      gpointer        user_data);
 void spi_init_any_nil                (CORBA_any *any);
 void spi_init_any_string             (CORBA_any *any, char **string);
-void spi_init_any_object             (CORBA_any *any, CORBA_Object o);
+void spi_init_any_object             (CORBA_any *any, CORBA_Object *o);
 
 G_END_DECLS
 
Index: libspi/util.c
===================================================================
RCS file: /cvs/gnome/at-spi/libspi/util.c,v
retrieving revision 1.5
diff -u -p -r1.5 util.c
--- libspi/util.c	19 Nov 2002 20:04:20 -0000	1.5
+++ libspi/util.c	6 Dec 2002 09:56:08 -0000
@@ -114,12 +114,13 @@ spi_init_any_nil (CORBA_any *any)
 }
 
 void 
-spi_init_any_object (CORBA_any *any, CORBA_Object o)
+spi_init_any_object (CORBA_any *any, CORBA_Object *o)
 {
   CORBA_Environment ev;
   CORBA_exception_init (&ev);
+  
   any->_type = TC_CORBA_Object;
-  any->_value = CORBA_Object_duplicate (o, &ev);
+  any->_value = o;
   any->_release = FALSE;
   CORBA_exception_free (&ev);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]