* Boston, MA 02111-1307, USA.
*/
-/*
- * registry.c: the main accessibility service registry implementation
- */
+/* registry.c: the main accessibility service registry implementation */
+#include <config.h>
#ifdef SPI_DEBUG
-#include <stdio.h>
+# include <stdio.h>
#endif
-#include <config.h>
-#include <bonobo/Bonobo.h>
-
-/*
- * This pulls the CORBA definitions for the "Accessibility::Registry" server
- */
-#include <libspi/Accessibility.h>
/*
* We'd like to replace the dependance on X-isms with a wrapper layer,
* Anyone want to help?
*/
#include <X11/Xlib.h>
+#include <gdk/gdk.h>
#include <gdk/gdkx.h>
-/*
- * This pulls the definition for the BonoboObject (GType)
- */
-#include "registry.h"
+#include <libspi/registry.h>
-/*
- * Our parent GObject type
- */
+/* Our parent GObject type */
#define PARENT_TYPE SPI_LISTENER_TYPE
-/*
- * A pointer to our parent object class
- */
+/* A pointer to our parent object class */
static SpiListenerClass *spi_registry_parent_class;
typedef enum {
ETYPE_PROPERTY,
ETYPE_WINDOW,
ETYPE_TOOLKIT,
+ ETYPE_KEYBOARD,
+
ETYPE_LAST_DEFINED
} EventTypeCategory;
} SpiListenerStruct;
/* 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 void
parse_event_type (EventTypeStruct *etype, char *event_name)
{
- guint nbytes = 0;
gchar **split_string;
split_string = g_strsplit(event_name, ":", 4);
CORBA_Environment * ev)
{
SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
- GList *list = g_list_find_custom (registry->desktop->applications, &application, compare_corba_objects);
+ GList *list = g_list_find_custom (registry->desktop->applications, application, compare_corba_objects);
#ifdef SPI_DEBUG
gint i;
registry->desktop->applications = g_list_delete_link (registry->desktop->applications, list);
#ifdef SPI_DEBUG
fprintf (stderr, "there are now %d apps registered.\n", g_list_length (registry->desktop->applications));
- for (i = 0; i < g_list_length (registry->desktop->applications); ++i) {
+ for (i = 0; i < g_list_length (registry->desktop->applications); ++i)
+ {
fprintf (stderr, "getting application %d\n", i);
fprintf (stderr, "object address %p\n",
- g_list_nth_data (registry->desktop->applications, i));
- }
+ g_list_nth_data (registry->desktop->applications, i));
+ }
#endif
}
else
- fprintf (stderr, "could not deregister application\n");
+ {
+ fprintf (stderr, "could not deregister application %p\n", application);
+ }
}
/*
SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
SpiListenerStruct *ls = g_malloc (sizeof (SpiListenerStruct));
EventTypeStruct etype;
- gboolean is_toolkit_specific = TRUE;
fprintf(stderr, "registering for events of type %s\n", event_name);
listeners = ®istry->toolkit_listeners;
break;
default:
+ listeners = NULL;
break;
}
+ if (!listeners)
+ return;
+
ls.event_type_hash = etype.hash;
list = g_list_find_custom (*listeners, &ls, compare_listener_hash);
case (ETYPE_TOOLKIT) :
_registry_notify_listeners (registry->toolkit_listeners, e, ev);
break;
+ case (ETYPE_KEYBOARD) :
default:
break;
}
}
static void
-_registry_notify_listeners ( GList *listeners,
- const Accessibility_Event *e,
+_registry_notify_listeners (GList *listeners,
+ const Accessibility_Event *e_in,
CORBA_Environment *ev)
{
int n;
int len;
SpiListenerStruct *ls;
EventTypeStruct etype;
+ Accessibility_Event *e_out;
guint minor_hash;
- parse_event_type (&etype, e->type);
+ parse_event_type (&etype, e_in->type);
minor_hash = g_str_hash (g_strconcat (etype.major, etype.minor, NULL));
len = g_list_length (listeners);
{
#ifdef SPI_DEBUG
fprintf(stderr, "notifying listener #%d\n", n);
- fprintf(stderr, "event source name %s\n", Accessibility_Accessible__get_name(e->source, ev));
+ fprintf(stderr, "event source name %s\n", Accessibility_Accessible__get_name(e_in->source, ev));
#endif
- e->source = CORBA_Object_duplicate (e->source, ev);
- Accessibility_Accessible_ref ( e->source, ev);
+ e_out = ORBit_copy_value (e_in, TC_Accessibility_Event);
+ e_out->source = CORBA_Object_duplicate (e_in->source, ev);
+ Accessibility_Accessible_ref ( e_out->source, ev);
Accessibility_EventListener_notifyEvent ((Accessibility_EventListener) ls->listener,
- e,
+ e_out,
ev);
+ /* is it safe to free e_out now ? notifyEvent is a oneway... */
+ CORBA_free (e_out);
if (ev->_major != CORBA_NO_EXCEPTION) {
fprintf(stderr,
("Accessibility app error: exception during event notification: %s\n"),
}
}
-static gboolean _device_event_controller_hook (gpointer p)
+static gboolean
+_device_event_controller_hook (gpointer p)
{
SpiRegistry *registry = (SpiRegistry *)p;
SpiDeviceEventController *controller = registry->device_event_controller;
registry->kbd_event_hook = _device_event_controller_hook;
}
-GType
-spi_registry_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo tinfo = {
- sizeof (SpiRegistryClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) spi_registry_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class data */
- sizeof (SpiRegistry),
- 0, /* n preallocs */
- (GInstanceInitFunc) spi_registry_init,
- NULL /* value table */
- };
- /*
- * Here we use bonobo_type_unique instead of
- * gtk_type_unique, this auto-generates a load of
- * CORBA structures for us. All derived types must
- * use bonobo_type_unique.
- */
- type = bonobo_type_unique (
- PARENT_TYPE,
- POA_Accessibility_Registry__init,
- NULL,
- G_STRUCT_OFFSET (SpiRegistryClass, epv),
- &tinfo,
- "SpiRegistry");
- }
-
- return type;
-}
+BONOBO_TYPE_FUNC_FULL (SpiRegistry,
+ Accessibility_Registry,
+ PARENT_TYPE,
+ spi_registry);
SpiRegistry *
spi_registry_new (void)
{
- SpiRegistry *retval =
- SPI_REGISTRY (g_object_new (spi_registry_get_type (), NULL));
+ SpiRegistry *retval = g_object_new (SPI_REGISTRY_TYPE, NULL);
return retval;
}