2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
26 * AtspiComponent function implementations
30 #include "atspi-private.h"
31 #include "atspi-accessible-private.h"
34 atspi_rect_free (AtspiRect *rect)
40 atspi_rect_copy (AtspiRect *src)
42 AtspiRect *dst = g_new (AtspiRect, 1);
45 dst->height = src->height;
46 dst->width = src->width;
50 G_DEFINE_BOXED_TYPE (AtspiRect, atspi_rect, atspi_rect_copy, atspi_rect_free)
53 atspi_point_copy (AtspiPoint *src)
55 AtspiPoint *dst = g_new (AtspiPoint, 1);
61 G_DEFINE_BOXED_TYPE (AtspiPoint, atspi_point, atspi_point_copy, g_free)
64 * atspi_component_contains:
65 * @obj: a pointer to the #AtspiComponent to query.
66 * @x: a #gint specifying the x coordinate in question.
67 * @y: a #gint specifying the y coordinate in question.
68 * @ctype: the desired coordinate system of the point (@x, @y)
69 * (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN).
71 * Queries whether a given #AtspiComponent contains a particular point.
73 * Returns: #TRUE if the specified component contains the point (@x, @y),
77 atspi_component_contains (AtspiComponent *obj,
80 AtspiCoordType ctype, GError **error)
82 dbus_bool_t retval = FALSE;
83 dbus_int32_t d_x = x, d_y = y;
84 dbus_uint32_t d_ctype = ctype;
86 g_return_val_if_fail (obj != NULL, FALSE);
88 _atspi_dbus_call (obj, atspi_interface_component, "Contains", error, "iiu=>b", d_x, d_y, d_ctype, &retval);
94 * atspi_component_get_accessible_at_point:
95 * @obj: a pointer to the #AtspiComponent to query.
96 * @x: a #gint specifying the x coordinate of the point in question.
97 * @y: a #gint specifying the y coordinate of the point in question.
98 * @ctype: the coordinate system of the point (@x, @y)
99 * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
101 * Gets the accessible child at a given coordinate within an #AtspiComponent.
103 * Returns: (nullable) (transfer full): a pointer to an
104 * #AtspiAccessible child of the specified component which
105 * contains the point (@x, @y), or NULL if no child contains
109 atspi_component_get_accessible_at_point (AtspiComponent *obj,
112 AtspiCoordType ctype, GError **error)
114 dbus_int32_t d_x = x, d_y = y;
115 dbus_uint32_t d_ctype = ctype;
118 g_return_val_if_fail (obj != NULL, FALSE);
120 reply = _atspi_dbus_call_partial (obj, atspi_interface_component, "GetAccessibleAtPoint", error, "iiu", d_x, d_y, d_ctype);
122 return _atspi_dbus_return_accessible_from_message (reply);
126 * atspi_component_get_extents:
127 * @obj: a pointer to the #AtspiComponent to query.
128 * @ctype: the desired coordinate system into which to return the results,
129 * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
131 * Gets the bounding box of the specified #AtspiComponent.
133 * Returns: An #AtspiRect giving the accessible's extents.
136 atspi_component_get_extents (AtspiComponent *obj,
137 AtspiCoordType ctype, GError **error)
139 dbus_uint32_t d_ctype = ctype;
141 AtspiAccessible *accessible;
143 bbox.x = bbox.y = bbox.width = bbox.height = -1;
144 g_return_val_if_fail (obj != NULL, atspi_rect_copy (&bbox));
146 accessible = ATSPI_ACCESSIBLE (obj);
147 if (accessible->priv->cache && ctype == ATSPI_COORD_TYPE_SCREEN)
149 GValue *val = g_hash_table_lookup (accessible->priv->cache, "Component.ScreenExtents");
152 return g_value_dup_boxed (val);
156 _atspi_dbus_call (obj, atspi_interface_component, "GetExtents", error, "u=>(iiii)", d_ctype, &bbox);
157 return atspi_rect_copy (&bbox);
161 * atspi_component_get_position:
162 * @obj: a pointer to the #AtspiComponent to query.
163 * @ctype: the desired coordinate system into which to return the results,
164 * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
166 * Gets the minimum x and y coordinates of the specified #AtspiComponent.
168 * returns: An #AtspiPoint giving the @obj's position.
171 atspi_component_get_position (AtspiComponent *obj,
172 AtspiCoordType ctype, GError **error)
174 dbus_int32_t d_x, d_y;
175 dbus_uint32_t d_ctype = ctype;
181 return atspi_point_copy (&ret);
183 _atspi_dbus_call (obj, atspi_interface_component, "GetPosition", error, "u=>ii", d_ctype, &d_x, &d_y);
187 return atspi_point_copy (&ret);
191 * atspi_component_get_size:
192 * @obj: a pointer to the #AtspiComponent to query.
194 * Gets the size of the specified #AtspiComponent.
196 * returns: An #AtspiPoint giving the @obj's size.
199 atspi_component_get_size (AtspiComponent *obj, GError **error)
201 dbus_int32_t d_w, d_h;
206 return atspi_point_copy (&ret);
208 _atspi_dbus_call (obj, atspi_interface_component, "GetSize", error, "=>ii", &d_w, &d_h);
211 return atspi_point_copy (&ret);
215 * atspi_component_get_layer:
216 * @obj: a pointer to the #AtspiComponent to query.
218 * Queries which layer the component is painted into, to help determine its
219 * visibility in terms of stacking order.
221 * Returns: the #AtspiComponentLayer into which this component is painted.
224 atspi_component_get_layer (AtspiComponent *obj, GError **error)
226 dbus_uint32_t zlayer = -1;
228 _atspi_dbus_call (obj, atspi_interface_component, "GetLayer", error, "=>u", &zlayer);
234 * atspi_component_get_mdi_z_order:
235 * @obj: a pointer to the #AtspiComponent to query.
237 * Queries the z stacking order of a component which is in the MDI or window
238 * layer. (Bigger z-order numbers mean nearer the top)
240 * Returns: a #gshort indicating the stacking order of the component
241 * in the MDI layer, or -1 if the component is not in the MDI layer.
244 atspi_component_get_mdi_z_order (AtspiComponent *obj, GError **error)
246 dbus_uint16_t retval = -1;
248 _atspi_dbus_call (obj, atspi_interface_component, "GetMDIZOrder", error, "=>n", &retval);
254 * atspi_component_grab_focus:
255 * @obj: a pointer to the #AtspiComponent on which to operate.
257 * Attempts to set the keyboard input focus to the specified
260 * Returns: #TRUE if successful, #FALSE otherwise.
264 atspi_component_grab_focus (AtspiComponent *obj, GError **error)
266 dbus_bool_t retval = FALSE;
268 _atspi_dbus_call (obj, atspi_interface_component, "GrabFocus", error, "=>b", &retval);
274 * atspi_component_get_alpha:
275 * @obj: The #AtspiComponent to be queried.
277 * Gets the opacity/alpha value of a component, if alpha blending is in use.
279 * Returns: the opacity value of a component, as a #gdouble between 0.0 and 1.0.
282 atspi_component_get_alpha (AtspiComponent *obj, GError **error)
286 _atspi_dbus_call (obj, atspi_interface_component, "GetAlpha", error, "=>d", &retval);
292 * atspi_component_set_extents:
293 * @obj: a pointer to the #AtspiComponent to move.
294 * @x: the new vertical position to which the component should be moved.
295 * @y: the new horizontal position to which the component should be moved.
296 * @width: the width to which the component should be resized.
297 * @height: the height to which the component should be resized.
298 * @ctype: the coordinate system in which the position is specified.
299 * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
301 * Moves and resizes the specified component.
303 * Returns: #TRUE if successful; #FALSE otherwise.
306 atspi_component_set_extents (AtspiComponent *obj,
311 AtspiCoordType ctype,
314 dbus_int32_t d_x = x, d_y = y, d_width = width, d_height = height;
315 dbus_uint32_t d_ctype = ctype;
316 DBusMessageIter iter, iter_struct;
317 DBusMessage *message, *reply;
318 dbus_bool_t retval = FALSE;
319 AtspiAccessible *aobj = ATSPI_ACCESSIBLE (obj);
321 g_return_val_if_fail (obj != NULL, FALSE);
323 if (!aobj->parent.app || !aobj->parent.app->bus_name)
325 g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_APPLICATION_GONE,
326 _("The application no longer exists"));
330 message = dbus_message_new_method_call (aobj->parent.app->bus_name,
332 atspi_interface_component,
337 dbus_message_iter_init_append (message, &iter);
338 if (!dbus_message_iter_open_container (&iter, DBUS_TYPE_STRUCT, NULL, &iter_struct))
340 dbus_message_unref (message);
343 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_INT32, &d_x);
344 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_INT32, &d_y);
345 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_INT32, &d_width);
346 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_INT32, &d_height);
347 dbus_message_iter_close_container (&iter, &iter_struct);
348 dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &d_ctype);
350 reply = _atspi_dbus_send_with_reply_and_block (message, error);
351 dbus_message_get_args (reply, NULL, DBUS_TYPE_BOOLEAN, &retval,
353 dbus_message_unref (reply);
358 * atspi_component_set_position:
359 * @obj: a pointer to the #AtspiComponent to move.
360 * @x: the new vertical position to which the component should be moved.
361 * @y: the new horizontal position to which the component should be moved.
362 * @ctype: the coordinate system in which the position is specified.
363 * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
365 * Moves the component to the specified position.
367 * Returns: #TRUE if successful; #FALSE otherwise.
370 atspi_component_set_position (AtspiComponent *obj,
373 AtspiCoordType ctype,
376 dbus_int32_t d_x = x, d_y = y;
377 dbus_uint32_t d_ctype = ctype;
378 dbus_bool_t ret = FALSE;
380 g_return_val_if_fail (obj != NULL, FALSE);
382 _atspi_dbus_call (obj, atspi_interface_component, "SetPosition", error,
383 "iiu=>b", d_x, d_y, d_ctype, &ret);
389 * atspi_component_set_size:
390 * @obj: a pointer to the #AtspiComponent to query.
391 * @width: the width to which the component should be resized.
392 * @height: the height to which the component should be resized.
394 * Resizes the specified component to the given coordinates.
396 * Returns: #TRUE if successful; #FALSE otherwise.
399 atspi_component_set_size (AtspiComponent *obj,
404 dbus_int32_t d_width = width, d_height = height;
405 dbus_bool_t ret = FALSE;
407 g_return_val_if_fail (obj != NULL, FALSE);
409 _atspi_dbus_call (obj, atspi_interface_component, "SetSize", error, "ii=>b",
410 d_width, d_height, &ret);
416 atspi_component_base_init (AtspiComponent *klass)
421 atspi_component_get_type (void)
423 static GType type = 0;
426 static const GTypeInfo tinfo =
428 sizeof (AtspiComponent),
429 (GBaseInitFunc) atspi_component_base_init,
430 (GBaseFinalizeFunc) NULL,
433 type = g_type_register_static (G_TYPE_INTERFACE, "AtspiComponent", &tinfo, 0);