From 11518985294fd3a6847eac04c2dbde88f8e0d8b1 Mon Sep 17 00:00:00 2001 From: billh Date: Mon, 20 Aug 2001 13:04:36 +0000 Subject: [PATCH] Changed "ID" attribute of Accessible to long (from string). Added partial implementation of Component interface. Added Component query to simple-at test, demonstrating Component interface and interface queries. git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@42 e2bd861d-eb25-0410-b326-f6ed22b6b98c --- idl/Accessibility_Application.idl | 2 +- idl/Application.idl | 2 +- libspi/application.c | 10 ++--- libspi/application.h | 4 +- libspi/component.c | 81 +++++++++++++++++++++++++++++++++++++++ libspi/listener.c | 4 +- libspi/registry.c | 23 +++++++---- registryd/registry.c | 23 +++++++---- test/simple-at.c | 10 +++++ 9 files changed, 135 insertions(+), 24 deletions(-) diff --git a/idl/Accessibility_Application.idl b/idl/Accessibility_Application.idl index 033b24d..a41db3a 100644 --- a/idl/Accessibility_Application.idl +++ b/idl/Accessibility_Application.idl @@ -48,7 +48,7 @@ module Accessibility { * Get the application instance's unique ID as assigned by the registry. * **/ - attribute string id; + attribute long id; /** * Register with this application's toolkit for "toolkit" event notifications. diff --git a/idl/Application.idl b/idl/Application.idl index 033b24d..a41db3a 100644 --- a/idl/Application.idl +++ b/idl/Application.idl @@ -48,7 +48,7 @@ module Accessibility { * Get the application instance's unique ID as assigned by the registry. * **/ - attribute string id; + attribute long id; /** * Register with this application's toolkit for "toolkit" event notifications. diff --git a/libspi/application.c b/libspi/application.c index 6bba3a4..8c31dd7 100644 --- a/libspi/application.c +++ b/libspi/application.c @@ -85,19 +85,19 @@ impl_accessibility_application_get_version (PortableServer_Servant servant, return retval; } -static CORBA_string +static CORBA_long impl_accessibility_application_get_id (PortableServer_Servant servant, - CORBA_Environment *ev) + CORBA_Environment *ev) { - CORBA_char *retval; + CORBA_long retval; Application *application = APPLICATION (bonobo_object_from_servant (servant)); - retval = CORBA_string_dup (application->id); + retval = (CORBA_long) application->id; return retval; } static void impl_accessibility_application_set_id (PortableServer_Servant servant, - const CORBA_char *id, + const CORBA_long id, CORBA_Environment *ev) { Application *application = APPLICATION (bonobo_object_from_servant (servant)); diff --git a/libspi/application.h b/libspi/application.h index f7b76ac..110cdda 100644 --- a/libspi/application.h +++ b/libspi/application.h @@ -40,7 +40,7 @@ extern "C" { typedef struct { Accessible parent; - char *id; + long id; } Application; typedef struct { @@ -49,7 +49,7 @@ typedef struct { } ApplicationClass; GType application_get_type (void); -gboolean *application_set_id (AtkObject *app, char *id); +gboolean *application_set_id (AtkObject *app, long id); Application *application_new (AtkObject *app_root); diff --git a/libspi/component.c b/libspi/component.c index eb7ed37..c035bed 100644 --- a/libspi/component.c +++ b/libspi/component.c @@ -38,6 +38,7 @@ * This pulls the definition for the BonoboObject (Gtk Type) */ #include "component.h" +#include "accessible.h" /* * Our parent Gtk object type @@ -82,6 +83,82 @@ impl_accessibility_component_contains (PortableServer_Servant servant, return retval; } +/* + * CORBA Accessibility::Component::getAccessibleAtPoint method implementation + */ +static Accessibility_Accessible +impl_accessibility_component_get_accessible_at_point (PortableServer_Servant servant, + const CORBA_long x, + const CORBA_long y, + CORBA_short coord_type, + CORBA_Environment *ev) +{ + Accessibility_Accessible retval; + Component *component = COMPONENT (bonobo_object_from_servant (servant)); + AtkObject *child; + child = atk_component_ref_accessible_at_point (ATK_COMPONENT (component->atko), + (gint) x, (gint) y, + (AtkCoordType) coord_type); + retval = bonobo_object_corba_objref (bonobo_object (accessible_new (child))); + return retval; +} + +/* + * CORBA Accessibility::Component::getExtents method implementation + */ +static void +impl_accessibility_component_get_extents (PortableServer_Servant servant, + CORBA_long * x, + CORBA_long * y, + CORBA_long * width, + CORBA_long * height, + const CORBA_short coord_type, + CORBA_Environment *ev) +{ + Component *component = COMPONENT (bonobo_object_from_servant (servant)); + gint ix, iy, iw, ih; + atk_component_get_extents (ATK_COMPONENT (component->atko), &ix, &iy, &iw, &ih, + (AtkCoordType) coord_type); + *x = (CORBA_long) ix; + *y = (CORBA_long) iy; + *width = (CORBA_long) iw; + *height = (CORBA_long) ih; +} + +/* + * CORBA Accessibility::Component::getPosition method implementation + */ +static void +impl_accessibility_component_get_position (PortableServer_Servant servant, + CORBA_long * x, + CORBA_long * y, + const CORBA_short coord_type, + CORBA_Environment *ev) +{ + Component *component = COMPONENT (bonobo_object_from_servant (servant)); + gint ix, iy; + atk_component_get_position (ATK_COMPONENT (component->atko), &ix, &iy, + (AtkCoordType) coord_type); + *x = (CORBA_long) ix; + *y = (CORBA_long) iy; +} + +/* + * CORBA Accessibility::Component::getSize method implementation + */ +static void +impl_accessibility_component_get_size (PortableServer_Servant servant, + CORBA_long * width, + CORBA_long * height, + CORBA_Environment *ev) +{ + Component *component = COMPONENT (bonobo_object_from_servant (servant)); + gint iw, ih; + atk_component_get_size (ATK_COMPONENT (component->atko), &iw, &ih); + *width = (CORBA_long) iw; + *height = (CORBA_long) ih; +} + static void accessibility_component_class_init (ComponentClass *klass) { @@ -92,6 +169,10 @@ accessibility_component_class_init (ComponentClass *klass) object_class->finalize = accessibility_component_object_finalize; epv->contains = impl_accessibility_component_contains; + epv->getAccessibleAtPoint = impl_accessibility_component_get_accessible_at_point; + epv->getExtents = impl_accessibility_component_get_extents; + epv->getPosition = impl_accessibility_component_get_position; + epv->getSize = impl_accessibility_component_get_size; } static void diff --git a/libspi/listener.c b/libspi/listener.c index fb0778a..5492ed7 100644 --- a/libspi/listener.c +++ b/libspi/listener.c @@ -81,12 +81,14 @@ impl_notify_event (PortableServer_Servant servant, CORBA_exception_id(ev)); exit(-1); } + /* fprintf (stderr, "source is component ? : %s\n", Accessibility_Accessible_queryInterface (e->source, "IDL:Accessibility/Component:1.0", ev) ? "yes" : "no"); - + */ + /* TODO: free/deref the returned interface! */ #endif bonobo_object_release_unref (e->source, ev); diff --git a/libspi/registry.c b/libspi/registry.c index 269365a..a8b318c 100644 --- a/libspi/registry.c +++ b/libspi/registry.c @@ -74,10 +74,12 @@ typedef struct { } ListenerStruct; /* static function prototypes */ -static void registry_notify_listeners ( GList *listeners, +static void _registry_notify_listeners ( GList *listeners, const Accessibility_Event *e, CORBA_Environment *ev); +static long _get_unique_id(); + /* * Implemented GObject::finalize */ @@ -113,8 +115,8 @@ impl_accessibility_registry_register_application (PortableServer_Servant servant registry->desktop->applications = g_list_append (registry->desktop->applications, CORBA_Object_duplicate (application, ev)); - /* TODO: create unique string here (with libuuid call ?) */ - Accessibility_Application__set_id (application, "test-some-unique-string", ev); + /* TODO: create unique string here (with libuuid call ?) and hash ? */ + Accessibility_Application__set_id (application, _get_unique_id(), ev); /* * TODO: change the implementation below to a WM-aware one; @@ -450,13 +452,13 @@ impl_registry_notify_event (PortableServer_Servant servant, switch (etype.type_cat) { case (ETYPE_FOCUS) : - registry_notify_listeners (registry->focus_listeners, e, ev); + _registry_notify_listeners (registry->focus_listeners, e, ev); break; case (ETYPE_WINDOW) : - registry_notify_listeners (registry->window_listeners, e, ev); + _registry_notify_listeners (registry->window_listeners, e, ev); break; case (ETYPE_TOOLKIT) : - registry_notify_listeners (registry->toolkit_listeners, e, ev); + _registry_notify_listeners (registry->toolkit_listeners, e, ev); break; default: break; @@ -464,8 +466,15 @@ impl_registry_notify_event (PortableServer_Servant servant, bonobo_object_release_unref (e->source, ev); } +static long +_get_unique_id () +{ + static long id = 0; + return ++id; +} + static void -registry_notify_listeners ( GList *listeners, +_registry_notify_listeners ( GList *listeners, const Accessibility_Event *e, CORBA_Environment *ev) { diff --git a/registryd/registry.c b/registryd/registry.c index 269365a..a8b318c 100644 --- a/registryd/registry.c +++ b/registryd/registry.c @@ -74,10 +74,12 @@ typedef struct { } ListenerStruct; /* static function prototypes */ -static void registry_notify_listeners ( GList *listeners, +static void _registry_notify_listeners ( GList *listeners, const Accessibility_Event *e, CORBA_Environment *ev); +static long _get_unique_id(); + /* * Implemented GObject::finalize */ @@ -113,8 +115,8 @@ impl_accessibility_registry_register_application (PortableServer_Servant servant registry->desktop->applications = g_list_append (registry->desktop->applications, CORBA_Object_duplicate (application, ev)); - /* TODO: create unique string here (with libuuid call ?) */ - Accessibility_Application__set_id (application, "test-some-unique-string", ev); + /* TODO: create unique string here (with libuuid call ?) and hash ? */ + Accessibility_Application__set_id (application, _get_unique_id(), ev); /* * TODO: change the implementation below to a WM-aware one; @@ -450,13 +452,13 @@ impl_registry_notify_event (PortableServer_Servant servant, switch (etype.type_cat) { case (ETYPE_FOCUS) : - registry_notify_listeners (registry->focus_listeners, e, ev); + _registry_notify_listeners (registry->focus_listeners, e, ev); break; case (ETYPE_WINDOW) : - registry_notify_listeners (registry->window_listeners, e, ev); + _registry_notify_listeners (registry->window_listeners, e, ev); break; case (ETYPE_TOOLKIT) : - registry_notify_listeners (registry->toolkit_listeners, e, ev); + _registry_notify_listeners (registry->toolkit_listeners, e, ev); break; default: break; @@ -464,8 +466,15 @@ impl_registry_notify_event (PortableServer_Servant servant, bonobo_object_release_unref (e->source, ev); } +static long +_get_unique_id () +{ + static long id = 0; + return ++id; +} + static void -registry_notify_listeners ( GList *listeners, +_registry_notify_listeners ( GList *listeners, const Accessibility_Event *e, CORBA_Environment *ev) { diff --git a/test/simple-at.c b/test/simple-at.c index f7472c7..d243447 100644 --- a/test/simple-at.c +++ b/test/simple-at.c @@ -68,6 +68,16 @@ report_focus_event (void *p) AccessibleEvent *ev = (AccessibleEvent *) p; fprintf (stderr, "%s event from %s\n", ev->type, Accessible_getName (&ev->source)); + if (Accessible_isComponent (&ev->source)) + { + long x, y, width, height; + AccessibleComponent *component = Accessible_getComponent (&ev->source); + fprintf (stderr, "Source implements IDL:Accessibility/Component:1.0\n"); + AccessibleComponent_getExtents (component, &x, &y, &width, &height, + COORD_TYPE_SCREEN); + fprintf (stderr, "Bounding box: (%ld, %ld) ; (%ld, %ld)\n", + x, y, x+width, y+height); + } } void -- 2.7.4