"Unfixed" some things :-). cleaned up and made some of the namespace changes more...
[platform/core/uifw/at-spi2-atk.git] / libspi / deviceeventcontroller.c
index 6098395..04f0371 100644 (file)
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #endif
 
+#include <stdlib.h> /* for getenv() */
 #include <X11/Xlib.h>
 #include <X11/extensions/XTest.h>
 #include <config.h>
@@ -69,8 +70,9 @@ static gboolean _controller_grab_keyboard (SpiDeviceEventController *controller)
 
 static void _controller_register_device_listener (SpiDeviceEventController *controller,
                                                  const CORBA_Object l,
-                                                 const Accessibility_ControllerEventMask *mask,
                                                  DeviceTypeCategory type,
+                                                 const Accessibility_KeySet *keys,
+                                                 const Accessibility_ControllerEventMask *mask,
                                                  CORBA_Environment *ev);
 
 /*
@@ -107,8 +109,9 @@ _eventmask_compare_value (gconstpointer p1, gconstpointer p2)
 static void
 _controller_register_device_listener (SpiDeviceEventController *controller,
                                      const CORBA_Object l,
-                                     const Accessibility_ControllerEventMask *mask,
                                      DeviceTypeCategory type,
+                                     const Accessibility_KeySet *keys,
+                                     const Accessibility_ControllerEventMask *mask,
                                      CORBA_Environment *ev)
 {
   Accessibility_ControllerEventMask *mask_ptr = NULL;
@@ -346,7 +349,7 @@ spi_device_event_controller_object_finalize (GObject *object)
 }
 
 /*
- * CORBA Accessibility::SpiDeviceEventController::registerKeystrokeListener
+ * CORBA Accessibility::DeviceEventController::registerKeystrokeListener
  *     method implementation
  */
 static void
@@ -355,7 +358,7 @@ impl_register_keystroke_listener (PortableServer_Servant     servant,
                                  const Accessibility_KeySet *keys,
                                  const Accessibility_ControllerEventMask *mask,
                                  const Accessibility_KeyEventTypeSeq *type,
-                                 const CORBA_boolean is_synchronous,
+                                 const CORBA_boolean is_system_global,
                                  CORBA_Environment         *ev)
 {
        SpiDeviceEventController *controller = SPI_DEVICE_EVENT_CONTROLLER (
@@ -364,14 +367,15 @@ impl_register_keystroke_listener (PortableServer_Servant     servant,
        fprintf (stderr, "registering keystroke listener %p with maskVal %lu\n",
                 (void *) l, (unsigned long) mask->value);
 #endif
-        /* TODO: change this to an enum, indicating if event can be consumed */
-       if (is_synchronous)
-       _controller_register_device_listener(controller, l, mask, DEVICE_TYPE_KBD, ev);
+        /* TODO: change this to an enum, indicating if event is caught at OS level */
+       if (is_system_global)
+       _controller_register_device_listener(controller, l, DEVICE_TYPE_KBD, keys, mask, ev);
        else
        ; /* register with toolkit instead */   
 }
+
 /*
- * CORBA Accessibility::SpiDeviceEventController::deregisterKeystrokeListener
+ * CORBA Accessibility::DeviceEventController::deregisterKeystrokeListener
  *     method implementation
  */
 static void
@@ -393,7 +397,7 @@ impl_deregister_keystroke_listener (PortableServer_Servant     servant,
 }
 
 /*
- * CORBA Accessibility::SpiDeviceEventController::registerMouseListener
+ * CORBA Accessibility::DeviceEventController::registerMouseListener
  *     method implementation
  */
 /*
@@ -407,7 +411,7 @@ impl_register_mouse_listener (PortableServer_Servant     servant,
 #ifdef SPI_DEBUG
        fprintf (stderr, "registering mouse listener %p\n", l);
 #endif
-       _controller_register_device_listener(controller, l, mask, DEVICE_TYPE_MOUSE, ev);
+       _controller_register_device_listener(controller, DEVICE_TYPE_MOUSE, l, keys, mask, ev);
 }
 */
 
@@ -418,13 +422,13 @@ keycode_for_keysym (long keysym)
 }
 
 /*
- * CORBA Accessibility::SpiDeviceEventController::registerKeystrokeListener
+ * CORBA Accessibility::DeviceEventController::registerKeystrokeListener
  *     method implementation
  */
 static void
 impl_generate_key_event (PortableServer_Servant     servant,
                         const CORBA_long           keycode,
-                        const CORBA_long           synth_type,
+                        const Accessibility_KeySynthType synth_type,
                         CORBA_Environment          *ev)
 {
        long key_synth_code;
@@ -459,7 +463,7 @@ impl_generate_key_event (PortableServer_Servant     servant,
 }
 
 /*
- * CORBA Accessibility::SpiDeviceEventController::generateMouseEvent
+ * CORBA Accessibility::DeviceEventController::generateMouseEvent
  *     method implementation
  */
 static void
@@ -478,7 +482,7 @@ static void
 spi_device_event_controller_class_init (SpiDeviceEventControllerClass *klass)
 {
         GObjectClass * object_class = (GObjectClass *) klass;
-        POA_Accessibility_SpiDeviceEventController__epv *epv = &klass->epv;
+        POA_Accessibility_DeviceEventController__epv *epv = &klass->epv;
         spi_device_event_controller_parent_class = g_type_class_ref (BONOBO_OBJECT_TYPE);
 
         object_class->finalize = spi_device_event_controller_object_finalize;
@@ -507,6 +511,17 @@ gboolean spi_device_event_controller_check_key_event (SpiDeviceEventController *
                return (klass->check_key_event) (controller);
 }
 
+SpiDeviceEventController *
+spi_device_event_controller_new (void *registryp)
+{
+  SpiRegistry *registry = SPI_REGISTRY (registryp);    
+  SpiDeviceEventController *retval = 
+         SPI_DEVICE_EVENT_CONTROLLER (g_object_new (SPI_DEVICE_EVENT_CONTROLLER_TYPE, NULL));
+  retval->registry = registry;
+  bonobo_object_ref (registry);
+  return retval;
+}
+
 GType
 spi_device_event_controller_get_type (void)
 {
@@ -533,7 +548,7 @@ spi_device_event_controller_get_type (void)
                  */
                 type = bonobo_type_unique (
                         PARENT_TYPE,
-                        POA_Accessibility_SpiDeviceEventController__init,
+                        POA_Accessibility_DeviceEventController__init,
                         NULL,
                         G_STRUCT_OFFSET (SpiDeviceEventControllerClass, epv),
                         &tinfo,