From 81b1d9195d65999050f103b1fbe9c3c7ce8c99c6 Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 20 Nov 2001 04:32:31 +0000 Subject: [PATCH] 2001-11-20 Michael Meeks * libspi/registry.c (impl_accessibility_registry_deregister_global_event_listener): segv. protection. * libspi/deviceeventcontroller.c (spi_device_event_controller_check_key_event): return FALSE on no virtual method. * libspi/*..h: make includes work on a correctly pathed install. * libspi/*.h: include glib/gmacros.h, use G_BEGIN / END _DECLS. * libspi/application.h: kill unused ( and whacked out ) gboolean *spi_application_set_id (AtkObject *app, long id); git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@101 e2bd861d-eb25-0410-b326-f6ed22b6b98c --- ChangeLog | 17 +++++++++++++++++ libspi/Makefile.am | 2 -- libspi/accessible.h | 12 ++++-------- libspi/accessibleeventlistener.h | 10 +++------- libspi/action.h | 11 +++-------- libspi/application.h | 21 ++++++++------------- libspi/component.h | 11 +++-------- libspi/desktop.h | 14 +++++--------- libspi/deviceeventcontroller.c | 24 +++++++++++------------- libspi/deviceeventcontroller.h | 14 +++++--------- libspi/editabletext.h | 13 ++++--------- libspi/eventlistener.h | 10 +++------- libspi/hyperlink.h | 11 +++-------- libspi/hypertext.h | 11 +++-------- libspi/image.h | 11 +++-------- libspi/keymasks.h | 12 ++++-------- libspi/keystrokelistener.h | 12 ++++-------- libspi/listener.h | 10 +++------- libspi/registry.c | 10 +++++++--- libspi/registry.h | 21 ++++++++------------- libspi/relation.h | 11 +++-------- libspi/selection.h | 11 +++-------- libspi/table.h | 11 +++-------- libspi/text.h | 13 ++++--------- libspi/value.h | 18 +++++------------- registryd/desktop.h | 14 +++++--------- registryd/deviceeventcontroller.c | 24 +++++++++++------------- registryd/deviceeventcontroller.h | 14 +++++--------- registryd/registry.c | 10 +++++++--- registryd/registry.h | 21 ++++++++------------- 30 files changed, 155 insertions(+), 249 deletions(-) diff --git a/ChangeLog b/ChangeLog index f9021cc..4446641 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,22 @@ 2001-11-20 Michael Meeks + * libspi/registry.c + (impl_accessibility_registry_deregister_global_event_listener): + segv. protection. + + * libspi/deviceeventcontroller.c + (spi_device_event_controller_check_key_event): return + FALSE on no virtual method. + + * libspi/*..h: make includes work on a correctly pathed install. + + * libspi/*.h: include glib/gmacros.h, use G_BEGIN / END _DECLS. + + * libspi/application.h: kill unused ( and whacked out ) + gboolean *spi_application_set_id (AtkObject *app, long id); + +2001-11-20 Michael Meeks + * libspi/*.[ch]: further convert to bonobo's type func macros, remove redundnant casts etc. diff --git a/libspi/Makefile.am b/libspi/Makefile.am index 5bf3880..d2179b2 100644 --- a/libspi/Makefile.am +++ b/libspi/Makefile.am @@ -2,8 +2,6 @@ lib_LTLIBRARIES = libspi.la INCLUDES = -I $(top_srcdir) \ -I $(top_builddir) \ - -I $(top_srcdir)/libspi \ - -I $(top_builddir)/libspi \ $(LIBSPI_CFLAGS) LDFLAGS = $(LIBSPI_LIBS) -lXtst @LT_VERSION_INFO@ diff --git a/libspi/accessible.h b/libspi/accessible.h index 0a4f117..9d85556 100644 --- a/libspi/accessible.h +++ b/libspi/accessible.h @@ -20,15 +20,13 @@ #ifndef SPI_ACCESSIBLE_H_ #define SPI_ACCESSIBLE_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - +#include #include #include #include +G_BEGIN_DECLS + #define SPI_ACCESSIBLE_TYPE (spi_accessible_get_type ()) #define SPI_ACCESSIBLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_ACCESSIBLE_TYPE, SpiAccessible)) #define SPI_ACCESSIBLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SPI_ACCESSIBLE_TYPE, SpiAccessibleClass)) @@ -49,8 +47,6 @@ GType spi_accessible_get_type (void); SpiAccessible *spi_accessible_new (AtkObject *o); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_ACCESSIBLE_H_ */ diff --git a/libspi/accessibleeventlistener.h b/libspi/accessibleeventlistener.h index 15722bf..44723b7 100644 --- a/libspi/accessibleeventlistener.h +++ b/libspi/accessibleeventlistener.h @@ -23,11 +23,9 @@ #ifndef SPI_ACCESSIBLE_EVENT_LISTENER_H_ #define SPI_ACCESSIBLE_EVENT_LISTENER_H_ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +#include -#include "listener.h" +G_BEGIN_DECLS #define SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE (spi_event_listener_get_type ()) #define SPI_ACCESSIBLE_EVENT_SPI_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE, SpiEventListener)) @@ -53,8 +51,6 @@ void spi_event_listener_add_callback (SpiEventListener *listener, void spi_event_listener_remove_callback (SpiEventListener *listener, VoidSpiEventListenerCB callback); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_ACCESSIBLE_EVENT_SPI_LISTENER_H_ */ diff --git a/libspi/action.h b/libspi/action.h index 58ebfe7..cb63045 100644 --- a/libspi/action.h +++ b/libspi/action.h @@ -20,15 +20,12 @@ #ifndef SPI_ACTION_H_ #define SPI_ACTION_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include #include +G_BEGIN_DECLS + #define SPI_ACTION_TYPE (spi_action_get_type ()) #define SPI_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_ACTION_TYPE, SpiAction)) #define SPI_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_ACTION_TYPE, SpiActionClass)) @@ -54,8 +51,6 @@ spi_action_get_type (void); SpiAction * spi_action_interface_new (AtkObject *obj); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_ACTION_H_ */ diff --git a/libspi/application.h b/libspi/application.h index 5cef788..b1c9140 100644 --- a/libspi/application.h +++ b/libspi/application.h @@ -23,15 +23,14 @@ #ifndef SPI_APPLICATION_H_ #define SPI_APPLICATION_H_ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - +#include #include -#include -#include +#include +#include #include +G_BEGIN_DECLS + #define SPI_APPLICATION_TYPE (spi_application_get_type ()) #define SPI_APPLICATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_APPLICATION_TYPE, SpiApplication)) #define SPI_APPLICATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SPI_APPLICATION_TYPE, SpiApplicationClass)) @@ -51,13 +50,9 @@ typedef struct { GHashTable *generic_event_names; } SpiApplicationClass; -GType spi_application_get_type (void); -gboolean *spi_application_set_id (AtkObject *app, long id); -SpiApplication *spi_application_new (AtkObject *app_root); - +GType spi_application_get_type (void); +SpiApplication *spi_application_new (AtkObject *app_root); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_APPLICATION_H_ */ diff --git a/libspi/component.h b/libspi/component.h index d7dd029..667b1fe 100644 --- a/libspi/component.h +++ b/libspi/component.h @@ -20,15 +20,12 @@ #ifndef SPI_COMPONENT_H_ #define SPI_COMPONENT_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include #include +G_BEGIN_DECLS + #define SPI_COMPONENT_TYPE (spi_component_get_type ()) #define SPI_COMPONENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_COMPONENT_TYPE, SpiComponent)) #define SPI_COMPONENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SPI_COMPONENT_TYPE, SpiComponentClass)) @@ -48,8 +45,6 @@ typedef struct { GType spi_component_get_type (void); SpiComponent *spi_component_interface_new (AtkObject *o); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_COMPONENT_H_ */ diff --git a/libspi/desktop.h b/libspi/desktop.h index fd94c28..7a4e290 100644 --- a/libspi/desktop.h +++ b/libspi/desktop.h @@ -23,16 +23,14 @@ #ifndef SPI_DESKTOP_H_ #define SPI_DESKTOP_H_ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include -#include -#include +#include +#include #include +G_BEGIN_DECLS + #define SPI_DESKTOP_TYPE (spi_desktop_get_type ()) #define SPI_DESKTOP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_DESKTOP_TYPE, SpiDesktop)) #define SPI_DESKTOP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SPI_DESKTOP_TYPE, SpiDesktopClass)) @@ -54,8 +52,6 @@ void spi_desktop_add_application (SpiApplication *app); void spi_desktop_remove_application (SpiApplication *app); SpiDesktop *spi_desktop_new (void); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_DESKTOP_H_ */ diff --git a/libspi/deviceeventcontroller.c b/libspi/deviceeventcontroller.c index 13d96f3..f4e19b3 100644 --- a/libspi/deviceeventcontroller.c +++ b/libspi/deviceeventcontroller.c @@ -227,7 +227,7 @@ _controller_register_with_devices (SpiDeviceEventController *controller) /* register with: keyboard hardware code handler */ /* register with: (translated) keystroke handler */ #ifdef SPI_DEBUG - fprintf (stderr, "About to request events on window %ld of display %x\n", + fprintf (stderr, "About to request events on window %ld of display %p\n", (unsigned long) GDK_ROOT_WINDOW(), GDK_DISPLAY()); #endif /* We must open a new connection to the server to avoid clashing with the GDK event loop */ @@ -265,13 +265,10 @@ static gboolean _check_key_event (SpiDeviceEventController *controller) { static gboolean initialized = FALSE; - static gboolean is_active = FALSE; XEvent *x_event = g_new0 (XEvent, 1); XKeyEvent *x_key_event; KeySym keysym; gboolean is_consumed = FALSE; - char key_name[16]; - int i; Accessibility_KeyStroke key_event; static CORBA_Environment ev; @@ -301,10 +298,10 @@ _check_key_event (SpiDeviceEventController *controller) (int) x_key_event->state); #endif #ifdef SPI_DEBUG - fprintf(stderr, "%s%c", - (x_key_event->state & Mod1Mask)?"Alt-":"", - ((x_key_event->state & ShiftMask)^(x_key_event->state & LockMask))? - (char) toupper((int) keysym) : (char) tolower((int)keysym)); + fprintf (stderr, "%s%c", + (x_key_event->state & Mod1Mask)?"Alt-":"", + ((x_key_event->state & ShiftMask)^(x_key_event->state & LockMask))? + g_ascii_toupper (keysym) : g_ascii_tolower (keysym)); #endif /* SPI_DEBUG */ } else @@ -511,11 +508,11 @@ impl_generate_key_event (PortableServer_Servant servant, * method implementation */ static void -impl_generate_mouse_event (PortableServer_Servant servant, - const CORBA_long x, - const CORBA_long y, - const CORBA_char * eventName, - CORBA_Environment *ev) +impl_generate_mouse_event (PortableServer_Servant servant, + const CORBA_long x, + const CORBA_long y, + const CORBA_char *eventName, + CORBA_Environment *ev) { #ifdef SPI_DEBUG fprintf (stderr, "generating mouse %s event at %ld, %ld\n", eventName, x, y); @@ -554,6 +551,7 @@ spi_device_event_controller_check_key_event (SpiDeviceEventController *controlle SpiDeviceEventControllerClass *klass = SPI_DEVICE_EVENT_CONTROLLER_GET_CLASS (controller); if (klass->check_key_event) return (klass->check_key_event) (controller); + return FALSE; } SpiDeviceEventController * diff --git a/libspi/deviceeventcontroller.h b/libspi/deviceeventcontroller.h index b8cfc77..e5e9e28 100644 --- a/libspi/deviceeventcontroller.h +++ b/libspi/deviceeventcontroller.h @@ -23,14 +23,12 @@ #ifndef SPI_DEVICE_EVENT_CONTROLLER_H_ #define SPI_DEVICE_EVENT_CONTROLLER_H_ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include -#include "keystrokelistener.h" -#include "registry.h" +#include +#include + +G_BEGIN_DECLS #define SPI_DEVICE_EVENT_CONTROLLER_TYPE (spi_device_event_controller_get_type ()) #define SPI_DEVICE_EVENT_CONTROLLER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_DEVICE_EVENT_CONTROLLER_TYPE, SpiDeviceEventController)) @@ -56,8 +54,6 @@ typedef struct { GType spi_device_event_controller_get_type (void); SpiDeviceEventController *spi_device_event_controller_new (void *registry); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* DEVICEEVENTCONTROLLER_H_ */ diff --git a/libspi/editabletext.h b/libspi/editabletext.h index 889b668..f61866f 100644 --- a/libspi/editabletext.h +++ b/libspi/editabletext.h @@ -20,15 +20,12 @@ #ifndef SPI_EDITABLE_TEXT_H_ #define SPI_EDITABLE_TEXT_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include #include -#include "text.h" +#include + +G_BEGIN_DECLS #define SPI_EDITABLE_TEXT_TYPE (spi_editable_text_get_type ()) #define SPI_EDITABLE_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_EDITABLE_TEXT_TYPE, SpiEditableText)) @@ -54,8 +51,6 @@ spi_editable_text_get_type (void); SpiEditableText * spi_editable_text_interface_new ( AtkObject *obj); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_EDITABLE_TEXT_H_ */ diff --git a/libspi/eventlistener.h b/libspi/eventlistener.h index 15722bf..44723b7 100644 --- a/libspi/eventlistener.h +++ b/libspi/eventlistener.h @@ -23,11 +23,9 @@ #ifndef SPI_ACCESSIBLE_EVENT_LISTENER_H_ #define SPI_ACCESSIBLE_EVENT_LISTENER_H_ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +#include -#include "listener.h" +G_BEGIN_DECLS #define SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE (spi_event_listener_get_type ()) #define SPI_ACCESSIBLE_EVENT_SPI_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE, SpiEventListener)) @@ -53,8 +51,6 @@ void spi_event_listener_add_callback (SpiEventListener *listener, void spi_event_listener_remove_callback (SpiEventListener *listener, VoidSpiEventListenerCB callback); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_ACCESSIBLE_EVENT_SPI_LISTENER_H_ */ diff --git a/libspi/hyperlink.h b/libspi/hyperlink.h index 6789517..d79c5e5 100644 --- a/libspi/hyperlink.h +++ b/libspi/hyperlink.h @@ -20,15 +20,12 @@ #ifndef SPI_HYPERLINK_H_ #define SPI_HYPERLINK_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include #include +G_BEGIN_DECLS + #define SPI_HYPERLINK_TYPE (spi_hyperlink_get_type ()) #define SPI_HYPERLINK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_HYPERLINK_TYPE, SpiHyperlink)) #define SPI_HYPERLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_HYPERLINK_TYPE, SpiHyperlinkClass)) @@ -54,8 +51,6 @@ spi_hyperlink_get_type (void); SpiHyperlink * spi_hyperlink_new (); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_HYPERLINK_H_ */ diff --git a/libspi/hypertext.h b/libspi/hypertext.h index 6c00d44..9245597 100644 --- a/libspi/hypertext.h +++ b/libspi/hypertext.h @@ -20,15 +20,12 @@ #ifndef SPI_HYPERTEXT_H_ #define SPI_HYPERTEXT_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include #include +G_BEGIN_DECLS + #define SPI_HYPERTEXT_TYPE (spi_hypertext_get_type ()) #define SPI_HYPERTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_HYPERTEXT_TYPE, SpiHypertext)) #define SPI_HYPERTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_HYPERTEXT_TYPE, SpiHypertextClass)) @@ -51,8 +48,6 @@ struct _HypertextClass { GType spi_hypertext_get_type (void); SpiHypertext *spi_hypertext_interface_new (AtkObject *obj); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_HYPERTEXT_H_ */ diff --git a/libspi/image.h b/libspi/image.h index eece399..71085e3 100644 --- a/libspi/image.h +++ b/libspi/image.h @@ -20,15 +20,12 @@ #ifndef SPI_IMAGE_H_ #define SPI_IMAGE_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include #include +G_BEGIN_DECLS + #define SPI_IMAGE_TYPE (spi_image_get_type ()) #define SPI_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_IMAGE_TYPE, SpiImage)) #define SPI_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_IMAGE_TYPE, SpiImageClass)) @@ -54,8 +51,6 @@ spi_image_get_type (void); SpiImage * spi_image_interface_new (AtkObject *obj); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_IMAGE_H_ */ diff --git a/libspi/keymasks.h b/libspi/keymasks.h index b8843f5..cd43911 100644 --- a/libspi/keymasks.h +++ b/libspi/keymasks.h @@ -1,11 +1,10 @@ #ifndef _SPI_KEYMASKS_H_ #define _SPI_KEYMASKS_H_ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include +#include + +G_BEGIN_DECLS typedef unsigned long SpiKeyMaskType; @@ -18,9 +17,6 @@ typedef unsigned long SpiKeyMaskType; #define SPI_KEYMASK_SHIFTLOCK LockMask #define SPI_KEYMASK_UNMODIFIED 0 -#ifdef __cplusplus -} -#endif /* __cplusplus */ - +G_END_DECLS #endif diff --git a/libspi/keystrokelistener.h b/libspi/keystrokelistener.h index a2b4c11..ea2052c 100644 --- a/libspi/keystrokelistener.h +++ b/libspi/keystrokelistener.h @@ -23,14 +23,12 @@ #ifndef SPI_KEYSTROKE_LISTENER_H_ #define SPI_KEYSTROKE_LISTENER_H_ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include #include -#include "keymasks.h" +#include + +G_BEGIN_DECLS #define SPI_KEYSTROKE_LISTENER_TYPE (spi_keystroke_listener_get_type ()) #define SPI_KEYSTROKE_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_KEYSTROKE_LISTENER_TYPE, SpiKeystrokeListener)) @@ -58,8 +56,6 @@ void spi_keystroke_listener_remove_callback (SpiKeystrokeListe BooleanKeystrokeListenerCB callback); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* KEYSTROKE_SPI_LISTENER_H_ */ diff --git a/libspi/listener.h b/libspi/listener.h index f9302fa..2c2533b 100644 --- a/libspi/listener.h +++ b/libspi/listener.h @@ -23,14 +23,12 @@ #ifndef SPI_LISTENER_H_ #define SPI_LISTENER_H_ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include #include +G_BEGIN_DECLS + #define SPI_LISTENER_TYPE (spi_listener_get_type ()) #define SPI_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_LISTENER_TYPE, SpiListener)) #define SPI_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SPI_LISTENER_TYPE, SpiListenerClass)) @@ -49,8 +47,6 @@ typedef struct { GType spi_listener_get_type (void); SpiListener *spi_listener_new (void); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_LISTENER_H_ */ diff --git a/libspi/registry.c b/libspi/registry.c index fc4fb86..7e278b5 100644 --- a/libspi/registry.c +++ b/libspi/registry.c @@ -33,6 +33,7 @@ * Anyone want to help? */ #include +#include #include #include @@ -186,7 +187,6 @@ compare_listener_corbaref (gconstpointer p1, gconstpointer p2) static void parse_event_type (EventTypeStruct *etype, char *event_name) { - guint nbytes = 0; gchar **split_string; split_string = g_strsplit(event_name, ":", 4); @@ -296,7 +296,6 @@ impl_accessibility_registry_register_global_event_listener ( 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); @@ -395,9 +394,13 @@ impl_accessibility_registry_deregister_global_event_listener ( 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); @@ -561,7 +564,8 @@ _registry_notify_listeners ( GList *listeners, } } -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; diff --git a/libspi/registry.h b/libspi/registry.h index b9df482..61b0ed9 100644 --- a/libspi/registry.h +++ b/libspi/registry.h @@ -23,15 +23,12 @@ #ifndef SPI_REGISTRY_H_ #define SPI_REGISTRY_H_ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include -#include -#include "listener.h" -#include "desktop.h" -#include "deviceeventcontroller.h" +#include +#include +#include + +G_BEGIN_DECLS #define SPI_REGISTRY_TYPE (spi_registry_get_type ()) #define SPI_REGISTRY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_REGISTRY_TYPE, SpiRegistry)) @@ -55,11 +52,9 @@ typedef struct { POA_Accessibility_Registry__epv epv; } SpiRegistryClass; -GType spi_registry_get_type (void); -SpiRegistry *spi_registry_new (void); +GType spi_registry_get_type (void); +SpiRegistry *spi_registry_new (void); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_REGISTRY_H_ */ diff --git a/libspi/relation.h b/libspi/relation.h index 59806af..b923557 100644 --- a/libspi/relation.h +++ b/libspi/relation.h @@ -21,15 +21,12 @@ #ifndef SPI_RELATION_H_ #define SPI_RELATION_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include #include +G_BEGIN_DECLS + #define SPI_RELATION_TYPE (spi_relation_get_type ()) #define SPI_RELATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_RELATION_TYPE, SpiRelation)) #define SPI_RELATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_RELATION_TYPE, SpiRelationClass)) @@ -55,8 +52,6 @@ spi_relation_get_type (void); SpiRelation * spi_relation_new (AtkRelation *relation); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_RELATION_H_ */ diff --git a/libspi/selection.h b/libspi/selection.h index 89b644b..7bf6736 100644 --- a/libspi/selection.h +++ b/libspi/selection.h @@ -20,15 +20,12 @@ #ifndef SPI_SELECTION_H_ #define SPI_SELECTION_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include #include +G_BEGIN_DECLS + #define SPI_SELECTION_TYPE (spi_selection_get_type ()) #define SPI_SELECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_SELECTION_TYPE, SpiSelection)) #define SPI_SELECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_SELECTION_TYPE, SpiSelectionClass)) @@ -54,8 +51,6 @@ spi_selection_get_type (void); SpiSelection * spi_selection_interface_new (AtkObject *obj); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_SELECTION_H_ */ diff --git a/libspi/table.h b/libspi/table.h index e8acfa4..29f4fcd 100644 --- a/libspi/table.h +++ b/libspi/table.h @@ -20,15 +20,12 @@ #ifndef SPI_TABLE_H_ #define SPI_TABLE_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include #include +G_BEGIN_DECLS + #define SPI_TABLE_TYPE (spi_table_get_type ()) #define SPI_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_TABLE_TYPE, SpiTable)) #define SPI_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_TABLE_TYPE, SpiTableClass)) @@ -54,8 +51,6 @@ spi_table_get_type (void); SpiTable * spi_table_interface_new (AtkObject *obj); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_TABLE_H_ */ diff --git a/libspi/text.h b/libspi/text.h index df70d92..f8fe59f 100644 --- a/libspi/text.h +++ b/libspi/text.h @@ -20,15 +20,12 @@ #ifndef SPI_TEXT_H_ #define SPI_TEXT_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include #include -#include "accessible.h" +#include + +G_BEGIN_DECLS #define SPI_TEXT_TYPE (spi_text_get_type ()) #define SPI_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_TEXT_TYPE, SpiText)) @@ -52,8 +49,6 @@ struct _SpiTextClass { GType spi_text_get_type (void); SpiText *spi_text_interface_new (AtkObject *obj); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_TEXT_H_ */ diff --git a/libspi/value.h b/libspi/value.h index 9c63c5d..2c841e5 100644 --- a/libspi/value.h +++ b/libspi/value.h @@ -20,15 +20,12 @@ #ifndef SPI_VALUE_H_ #define SPI_VALUE_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include #include +G_BEGIN_DECLS + #define SPI_VALUE_TYPE (spi_value_get_type ()) #define SPI_VALUE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_VALUE_TYPE, SpiValue)) #define SPI_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_VALUE_TYPE, SpiValueClass)) @@ -48,14 +45,9 @@ struct _ValueClass { POA_Accessibility_Value__epv epv; }; -GType -spi_value_get_type (void); - -SpiValue * -spi_value_interface_new (AtkObject *obj); +GType spi_value_get_type (void); +SpiValue *spi_value_interface_new (AtkObject *obj); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_VALUE_H_ */ diff --git a/registryd/desktop.h b/registryd/desktop.h index fd94c28..7a4e290 100644 --- a/registryd/desktop.h +++ b/registryd/desktop.h @@ -23,16 +23,14 @@ #ifndef SPI_DESKTOP_H_ #define SPI_DESKTOP_H_ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include -#include -#include +#include +#include #include +G_BEGIN_DECLS + #define SPI_DESKTOP_TYPE (spi_desktop_get_type ()) #define SPI_DESKTOP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_DESKTOP_TYPE, SpiDesktop)) #define SPI_DESKTOP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SPI_DESKTOP_TYPE, SpiDesktopClass)) @@ -54,8 +52,6 @@ void spi_desktop_add_application (SpiApplication *app); void spi_desktop_remove_application (SpiApplication *app); SpiDesktop *spi_desktop_new (void); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_DESKTOP_H_ */ diff --git a/registryd/deviceeventcontroller.c b/registryd/deviceeventcontroller.c index 13d96f3..f4e19b3 100644 --- a/registryd/deviceeventcontroller.c +++ b/registryd/deviceeventcontroller.c @@ -227,7 +227,7 @@ _controller_register_with_devices (SpiDeviceEventController *controller) /* register with: keyboard hardware code handler */ /* register with: (translated) keystroke handler */ #ifdef SPI_DEBUG - fprintf (stderr, "About to request events on window %ld of display %x\n", + fprintf (stderr, "About to request events on window %ld of display %p\n", (unsigned long) GDK_ROOT_WINDOW(), GDK_DISPLAY()); #endif /* We must open a new connection to the server to avoid clashing with the GDK event loop */ @@ -265,13 +265,10 @@ static gboolean _check_key_event (SpiDeviceEventController *controller) { static gboolean initialized = FALSE; - static gboolean is_active = FALSE; XEvent *x_event = g_new0 (XEvent, 1); XKeyEvent *x_key_event; KeySym keysym; gboolean is_consumed = FALSE; - char key_name[16]; - int i; Accessibility_KeyStroke key_event; static CORBA_Environment ev; @@ -301,10 +298,10 @@ _check_key_event (SpiDeviceEventController *controller) (int) x_key_event->state); #endif #ifdef SPI_DEBUG - fprintf(stderr, "%s%c", - (x_key_event->state & Mod1Mask)?"Alt-":"", - ((x_key_event->state & ShiftMask)^(x_key_event->state & LockMask))? - (char) toupper((int) keysym) : (char) tolower((int)keysym)); + fprintf (stderr, "%s%c", + (x_key_event->state & Mod1Mask)?"Alt-":"", + ((x_key_event->state & ShiftMask)^(x_key_event->state & LockMask))? + g_ascii_toupper (keysym) : g_ascii_tolower (keysym)); #endif /* SPI_DEBUG */ } else @@ -511,11 +508,11 @@ impl_generate_key_event (PortableServer_Servant servant, * method implementation */ static void -impl_generate_mouse_event (PortableServer_Servant servant, - const CORBA_long x, - const CORBA_long y, - const CORBA_char * eventName, - CORBA_Environment *ev) +impl_generate_mouse_event (PortableServer_Servant servant, + const CORBA_long x, + const CORBA_long y, + const CORBA_char *eventName, + CORBA_Environment *ev) { #ifdef SPI_DEBUG fprintf (stderr, "generating mouse %s event at %ld, %ld\n", eventName, x, y); @@ -554,6 +551,7 @@ spi_device_event_controller_check_key_event (SpiDeviceEventController *controlle SpiDeviceEventControllerClass *klass = SPI_DEVICE_EVENT_CONTROLLER_GET_CLASS (controller); if (klass->check_key_event) return (klass->check_key_event) (controller); + return FALSE; } SpiDeviceEventController * diff --git a/registryd/deviceeventcontroller.h b/registryd/deviceeventcontroller.h index b8cfc77..e5e9e28 100644 --- a/registryd/deviceeventcontroller.h +++ b/registryd/deviceeventcontroller.h @@ -23,14 +23,12 @@ #ifndef SPI_DEVICE_EVENT_CONTROLLER_H_ #define SPI_DEVICE_EVENT_CONTROLLER_H_ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include #include -#include "keystrokelistener.h" -#include "registry.h" +#include +#include + +G_BEGIN_DECLS #define SPI_DEVICE_EVENT_CONTROLLER_TYPE (spi_device_event_controller_get_type ()) #define SPI_DEVICE_EVENT_CONTROLLER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_DEVICE_EVENT_CONTROLLER_TYPE, SpiDeviceEventController)) @@ -56,8 +54,6 @@ typedef struct { GType spi_device_event_controller_get_type (void); SpiDeviceEventController *spi_device_event_controller_new (void *registry); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* DEVICEEVENTCONTROLLER_H_ */ diff --git a/registryd/registry.c b/registryd/registry.c index fc4fb86..7e278b5 100644 --- a/registryd/registry.c +++ b/registryd/registry.c @@ -33,6 +33,7 @@ * Anyone want to help? */ #include +#include #include #include @@ -186,7 +187,6 @@ compare_listener_corbaref (gconstpointer p1, gconstpointer p2) static void parse_event_type (EventTypeStruct *etype, char *event_name) { - guint nbytes = 0; gchar **split_string; split_string = g_strsplit(event_name, ":", 4); @@ -296,7 +296,6 @@ impl_accessibility_registry_register_global_event_listener ( 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); @@ -395,9 +394,13 @@ impl_accessibility_registry_deregister_global_event_listener ( 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); @@ -561,7 +564,8 @@ _registry_notify_listeners ( GList *listeners, } } -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; diff --git a/registryd/registry.h b/registryd/registry.h index b9df482..61b0ed9 100644 --- a/registryd/registry.h +++ b/registryd/registry.h @@ -23,15 +23,12 @@ #ifndef SPI_REGISTRY_H_ #define SPI_REGISTRY_H_ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - #include -#include -#include "listener.h" -#include "desktop.h" -#include "deviceeventcontroller.h" +#include +#include +#include + +G_BEGIN_DECLS #define SPI_REGISTRY_TYPE (spi_registry_get_type ()) #define SPI_REGISTRY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_REGISTRY_TYPE, SpiRegistry)) @@ -55,11 +52,9 @@ typedef struct { POA_Accessibility_Registry__epv epv; } SpiRegistryClass; -GType spi_registry_get_type (void); -SpiRegistry *spi_registry_new (void); +GType spi_registry_get_type (void); +SpiRegistry *spi_registry_new (void); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* SPI_REGISTRY_H_ */ -- 2.7.4