2002-03-04 Michael Meeks <michael@ximian.com>
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_registry.c
index 6771576..cc0dca2 100644 (file)
@@ -219,10 +219,11 @@ SPI_getDesktop (int i)
 
 /**
  * SPI_getDesktopList:
- * @list: a pointer to an array of #Accessible objects.
+ * @desktop_list: a pointer to an array of #Accessible references.
  *
  * Get the list of virtual desktops.  On return, @list will point
- *     to a newly-created array of virtual desktop pointers.
+ *     to a newly-created, NULL terminated array of virtual desktop
+ *     pointers.
  *     It is the responsibility of the caller to free this array when
  *     it is no longer needed.
  *
@@ -233,10 +234,55 @@ SPI_getDesktop (int i)
  *          placed in the list pointed to by parameter @list.
  **/
 int
-SPI_getDesktopList (Accessible **list)
+SPI_getDesktopList (Accessible ***desktop_list)
 {
-  *list = NULL;
-  return 0;
+  int i;
+  Accessible **list;
+  Accessibility_DesktopSeq *desktops;
+
+  if (!desktop_list)
+         return 0;
+
+  *desktop_list = NULL;
+
+  desktops = Accessibility_Registry_getDesktopList (cspi_registry (),
+                                                   cspi_ev ());
+
+  cspi_return_val_if_ev ("getting desktop list", 0);
+
+  list = g_new0 (Accessible *, desktops->_length + 1);
+
+  for (i = 0; i < desktops->_length; i++)
+    {
+      list [i] = cspi_object_add (
+             CORBA_Object_duplicate (desktops->_buffer [i], cspi_ev ()));
+    }
+  list [i] = NULL;
+
+  CORBA_free (desktops);
+
+  *desktop_list = list;
+
+  return i;
+}
+
+/**
+ * SPI_freeDesktopList:
+ * @desktop_list: a pointer to an array of #Accessible objects
+ * as returned from @SPI_getDesktopList
+ * 
+ * This routine frees the memory associated with the list.
+ **/
+void
+SPI_freeDesktopList (Accessible **desktop_list)
+{
+  Accessible **p;
+  
+  for (p = desktop_list; p && *p; p++)
+    {
+      cspi_object_unref (*p);
+    }
+  g_free (desktop_list);
 }
 
 /**
@@ -264,10 +310,10 @@ SPI_getDesktopList (Accessible **list)
  * Returns: #TRUE if successful, otherwise #FALSE.
  **/
 SPIBoolean
-SPI_registerAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener,
-                                        AccessibleKeySet *keys,
-                                        AccessibleKeyMaskType modmask,
-                                        AccessibleKeyEventMask eventmask,
+SPI_registerAccessibleKeystrokeListener (AccessibleKeystrokeListener  *listener,
+                                        AccessibleKeySet             *keys,
+                                        AccessibleKeyMaskType         modmask,
+                                        AccessibleKeyEventMask        eventmask,
                                         AccessibleKeyListenerSyncType sync_type)
 {
   gint                                i, mask;
@@ -370,7 +416,7 @@ SPI_registerAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener,
  **/
 SPIBoolean
 SPI_deregisterAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener,
-                                          AccessibleKeyMaskType modmask)
+                                          AccessibleKeyMaskType        modmask)
 {
   Accessibility_ControllerEventMask   controller_event_mask;
   Accessibility_KeySet                key_set;
@@ -412,6 +458,11 @@ SPI_deregisterAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener
  * SPI_generateKeyboardEvent:
  * @keyval: a long integer indicating the keycode or keysym of the key event
  *           being synthesized.
+ * @keystring: an (optional) UTF-8 string which, if @keyval is NULL,
+ *           indicates a 'composed' keyboard input string which is 
+ *           being synthesized; this type of keyboard event synthesis does
+ *           not emulate hardware keypresses but injects the string 
+ *           as though a composing input method (such as XIM) were used.
  * @synth_type: a #AccessibleKeySynthType flag indicating whether @keyval
  *           is to be interpreted as a keysym rather than a keycode
  *           (CSPI_KEYSYM), or whether to synthesize
@@ -455,6 +506,8 @@ SPI_generateKeyboardEvent (long int keyval,
       case SPI_KEY_STRING:
          keysynth_type = Accessibility_KEY_STRING;
          break;
+      default:
+          return FALSE;
     }
 
   Accessibility_DeviceEventController_generateKeyboardEvent (device_event_controller,
@@ -475,18 +528,31 @@ SPI_generateKeyboardEvent (long int keyval,
  * @x: a #long indicating the screen x coordinate of the mouse event.
  * @y: a #long indicating the screen y coordinate of the mouse event.
  * @name: a string indicating which mouse event to be synthesized
- *        (e.g. "button1", "button2", "mousemove").
+ *        (e.g. "b1p", "b1c", "b2r", "rel", "abs").
  *
  * Synthesize a mouse event at a specific screen coordinate.
  * Most AT clients should use the #AccessibleAction interface when
  * tempted to generate mouse events, rather than this method.
- * Not Yet Implemented.
+ * Event names: b1p = button 1 press; b2r = button 2 release;
+ *              b3c = button 3 click; b2d = button 2 double-click;
+ *              abs = absolute motion; rel = relative motion.
  *
  * Returns: #TRUE if successful, otherwise #FALSE.
  **/
 SPIBoolean
 SPI_generateMouseEvent (long x, long y, char *name)
 {
-  return FALSE;
+  Accessibility_DeviceEventController device_event_controller = 
+         Accessibility_Registry_getDeviceEventController (cspi_registry (), cspi_ev ());
+
+  cspi_return_val_if_ev ("getting event controller for mouse event gen", FALSE);
+
+  Accessibility_DeviceEventController_generateMouseEvent (device_event_controller,
+                                                         x, y, name, cspi_ev ());
+  cspi_return_val_if_ev ("generating mouse event", FALSE);
+
+  cspi_release_unref (device_event_controller);
+
+  return TRUE;
 }