Add MoveOuted signal
[platform/upstream/at-spi2-core.git] / atspi / atspi-component.c
index 3c84fb9..bdbe57c 100644 (file)
@@ -28,6 +28,7 @@
  */
 
 #include "atspi-private.h"
+#include "atspi-accessible-private.h"
 
 void
 atspi_rect_free (AtspiRect *rect)
@@ -84,7 +85,7 @@ atspi_component_contains (AtspiComponent *obj,
 
   g_return_val_if_fail (obj != NULL, FALSE);
 
-  _atspi_dbus_call (obj, atspi_interface_component, "Contains", error, "iin=>b", d_x, d_y, d_ctype, &retval);
+  _atspi_dbus_call (obj, atspi_interface_component, "Contains", error, "iiu=>b", d_x, d_y, d_ctype, &retval);
 
   return retval;
 }
@@ -99,9 +100,10 @@ atspi_component_contains (AtspiComponent *obj,
  *
  * Gets the accessible child at a given coordinate within an #AtspiComponent.
  *
- * Returns: (transfer full): a pointer to an #AtspiAccessible child of the
- *          specified component which contains the point (@x, @y), or NULL if
- *         no child contains the point.
+ * Returns: (nullable) (transfer full): a pointer to an
+ *          #AtspiAccessible child of the specified component which
+ *          contains the point (@x, @y), or NULL if no child contains
+ *          the point.
  **/
 AtspiAccessible *
 atspi_component_get_accessible_at_point (AtspiComponent *obj,
@@ -136,10 +138,21 @@ atspi_component_get_extents (AtspiComponent *obj,
 {
   dbus_uint32_t d_ctype = ctype;
   AtspiRect bbox;
+  AtspiAccessible *accessible;
 
   bbox.x = bbox.y = bbox.width = bbox.height = -1;
   g_return_val_if_fail (obj != NULL, atspi_rect_copy (&bbox));
 
+  accessible = ATSPI_ACCESSIBLE (obj);
+  if (accessible->priv->cache && ctype == ATSPI_COORD_TYPE_SCREEN)
+  {
+    GValue *val = g_hash_table_lookup (accessible->priv->cache, "Component.ScreenExtents");
+    if (val)
+    {
+      return g_value_dup_boxed (val);
+    }
+  }
+
   _atspi_dbus_call (obj, atspi_interface_component, "GetExtents", error, "u=>(iiii)", d_ctype, &bbox);
   return atspi_rect_copy (&bbox);
 }
@@ -258,6 +271,46 @@ atspi_component_grab_focus (AtspiComponent *obj, GError **error)
 }
 
 /**
+ * atspi_component_grab_highlight:
+ * @obj: a pointer to the #AtspiComponent on which to operate.
+ *
+ * Attempts to set highlight to the specified
+ *         #AtspiComponent.
+ *
+ * Returns: #TRUE if successful, #FALSE otherwise.
+ *
+ **/
+gboolean
+atspi_component_grab_highlight (AtspiComponent *obj, GError **error)
+{
+  dbus_bool_t retval = FALSE;
+
+  _atspi_dbus_call (obj, atspi_interface_component, "GrabHighlight", error, "=>b", &retval);
+
+  return retval;
+}
+
+/**
+ * atspi_component_clear_highlight:
+ * @obj: a pointer to the #AtspiComponent on which to operate.
+ *
+ * Attempts to clear highlight on the specified
+ *         #AtspiComponent.
+ *
+ * Returns: #TRUE if successful, #FALSE otherwise.
+ *
+ **/
+gboolean
+atspi_component_clear_highlight (AtspiComponent *obj, GError **error)
+{
+  dbus_bool_t retval = FALSE;
+
+  _atspi_dbus_call (obj, atspi_interface_component, "ClearHighlight", error, "=>b", &retval);
+
+  return retval;
+}
+
+/**
  * atspi_component_get_alpha:
  * @obj: The #AtspiComponent to be queried.
  *
@@ -307,10 +360,19 @@ atspi_component_set_extents (AtspiComponent *obj,
 
   g_return_val_if_fail (obj != NULL, FALSE);
 
+  if (!aobj->parent.app || !aobj->parent.app->bus_name)
+  {
+    g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_APPLICATION_GONE,
+                          _("The application no longer exists"));
+    return FALSE;
+  }
+
   message = dbus_message_new_method_call (aobj->parent.app->bus_name,
                                           aobj->parent.path,
                                           atspi_interface_component,
                                           "SetExtents");
+  if (!message)
+    return FALSE;
 
   dbus_message_iter_init_append (message, &iter);
   if (!dbus_message_iter_open_container (&iter, DBUS_TYPE_STRUCT, NULL, &iter_struct))
@@ -340,9 +402,9 @@ atspi_component_set_extents (AtspiComponent *obj,
  * @ctype: the coordinate system in which the position is specified.
  *         (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
  *
- * Returns: #TRUE if successful; #FALSE otherwise.
- *
  * Moves the component to the specified position.
+ *
+ * Returns: #TRUE if successful; #FALSE otherwise.
  **/
 gboolean
 atspi_component_set_position (AtspiComponent *obj,
@@ -369,9 +431,9 @@ atspi_component_set_position (AtspiComponent *obj,
  * @width: the width to which the component should be resized.
  * @height: the height to which the component should be resized.
  *
- * Returns: #TRUE if successful; #FALSE otherwise.
- *
  * Resizes the specified component to the given coordinates.
+ *
+ * Returns: #TRUE if successful; #FALSE otherwise.
  **/
 gboolean
 atspi_component_set_size (AtspiComponent *obj,
@@ -390,6 +452,23 @@ atspi_component_set_size (AtspiComponent *obj,
   return ret;
 }
 
+/**
+ * atspi_component_get_highlight_index
+ * @obj: a pointer to the #AtspiComponent to query.
+ *
+ * Returns: highlight index of object if (>0), 0 if highlight index is not set
+ *          or -1 if an error occured.
+ **/
+int
+atspi_component_get_highlight_index (AtspiComponent *obj, GError **error)
+{
+   gint ret = -1;
+   g_return_val_if_fail (obj != NULL, -1);
+   _atspi_dbus_get_property (obj, atspi_interface_component,
+                             "HighlightIndex", error, "i", &ret);
+   return ret;
+}
+
 static void
 atspi_component_base_init (AtspiComponent *klass)
 {