#define MAX_ACCURACY 3
+#define INVALID_EXTENTS ((AtspiRect){ .x = -1, .y = -1, .width = -1, .height = -1 })
+
#ifndef TIZEN_GTEST
#define TIZEN_PROD_STATIC static
#else
Eina_Bool object_has_modal_role(AtspiRole role);
Eina_Bool object_has_defunct_state(AtspiAccessible *obj);
Eina_Bool object_has_highlighted_state(AtspiAccessible *obj);
+Eina_Bool object_get_extents(AtspiAccessible *object, AtspiRect *extents);
int get_percent_value(double value, double lower, double upper);
Eldbus_Connection *conn;
Eldbus_Object *dobj;
Eldbus_Proxy *proxy;
- AtspiRect *rect = NULL;
- AtspiComponent *comp = NULL;
- int highlighted_object_x = -1;
- int highlighted_object_y = -1;
+ int highlighted_object_x = INVALID_EXTENTS.x;
+ int highlighted_object_y = INVALID_EXTENTS.y;
if (!atd->scroll_gesture_required_obj && !(obj))
return;
}
if (obj) {
- comp = atspi_accessible_get_component_iface(obj);
- rect = atspi_component_get_extents(comp, ATSPI_COORD_TYPE_SCREEN, NULL);
- g_object_unref(comp);
- highlighted_object_x = rect->x + rect->width / 2;
- highlighted_object_y = rect->y + rect->height / 2;
- g_free(rect);
+ AtspiRect extents;
+ object_get_extents(obj, &extents);
+ highlighted_object_x = extents.x + extents.width / 2;
+ highlighted_object_y = extents.y + extents.height / 2;
}
atd->scroll_gesture_required_obj = obj;
}
Eina_Bool ret = EINA_FALSE;
AtspiStateSet *ss = NULL;
- AtspiComponent *component;
- AtspiRect *extent;
gchar *role = NULL;
AtspiRole r = atspi_accessible_get_role(obj, NULL);
}
}
} else {
+ AtspiRect extents;
/* Extent of candidate object could be 0 */
- component = atspi_accessible_get_component_iface(obj);
- extent = atspi_component_get_extents(component, ATSPI_COORD_TYPE_SCREEN, NULL);
- g_object_unref(component);
-
- if (extent->width <= 0 || extent->height <= 0) {
- g_free(extent);
+ if (!object_get_extents(obj, &extents) || extents.width <= 0 || extents.height <= 0) {
g_object_unref(ss);
DEBUG("END - object rejected because of size = 0");
return EINA_FALSE;
}
- g_free(extent);
//When content is not in scroller
ret = atspi_state_set_contains(ss, ATSPI_STATE_SHOWING);
Eldbus_Connection *conn;
Eldbus_Object *dobj;
Eldbus_Proxy *proxy;
- int highlighted_object_x = -1;
- int highlighted_object_y = -1;
+ int highlighted_object_x = INVALID_EXTENTS.x;
+ int highlighted_object_y = INVALID_EXTENTS.y;
AtspiRole role = -1;
if (!(conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM))) {
role = atspi_accessible_get_role(obj, NULL);
/* when you change this condition, check _current_highlight_object_set */
if (role != ATSPI_ROLE_POPUP_MENU && role != ATSPI_ROLE_DIALOG) { /* ctxpopup outline does not show highlight frame */
- AtspiComponent *comp = atspi_accessible_get_component_iface(obj);
- AtspiRect *rect = atspi_component_get_extents(comp, ATSPI_COORD_TYPE_SCREEN, NULL);
-
- highlighted_object_x = rect->x + rect->width / 2;
- highlighted_object_y = rect->y + rect->height / 2;
-
- g_boxed_free(ATSPI_TYPE_RECT, rect);
- g_object_unref(comp);
+ AtspiRect extents;
+ object_get_extents(obj, &extents);
+ highlighted_object_x = extents.x + extents.width / 2;
+ highlighted_object_y = extents.y + extents.height / 2;
}
keyboard_status = keyboard_event_status(nd->keyboard_tracker_data, info->resource_id);
}
if (gi->state == 0) {
- AtspiComponent *comp = atspi_accessible_get_component_iface(obj);
- if (!comp) {
- ERROR("that slider do not have component interface");
+ AtspiRect extents;
+ if (!object_get_extents(obj, &extents)) {
+ ERROR("that slider do not have component interface or extents");
nd->prepared = false;
g_object_unref(obj);
return;
}
- AtspiRect *rect = atspi_component_get_extents(comp, ATSPI_COORD_TYPE_SCREEN, NULL);
-
- DEBUG("Current object is in:%d %d", rect->x, rect->y);
- DEBUG("Current object has size:%d %d", rect->width, rect->height);
+ DEBUG("Current object is in:%d %d", extents.x, extents.y);
+ DEBUG("Current object has size:%d %d", extents.width, extents.height);
AtspiValue *value_interface = atspi_accessible_get_value_iface(obj);
gdouble max = atspi_value_get_maximum_value(value_interface, NULL);
gdouble min = atspi_value_get_minimum_value(value_interface, NULL);
- if (rect->width > rect->height)
- total_distance = rect->width;
+ if (extents.width > extents.height)
+ total_distance = extents.width;
else
- total_distance = rect->height;
+ total_distance = extents.height;
if (total_distance)
nd->slider_offset = ((max - min) / total_distance);
else
nd->slider_offset = 0.0;
g_object_unref(value_interface);
- g_free(rect);
- g_object_unref(comp);
}
if (gi->state == 1) {
if (!nd) { ERROR("NavigatorData is NULL!"); }
return nd ? nd->is_text_selection_mode : EINA_FALSE;
}
-
return ret;
}
+Eina_Bool object_get_extents(AtspiAccessible *object, AtspiRect *extents)
+{
+ if (!object || !extents)
+ return EINA_FALSE;
+
+ *extents = INVALID_EXTENTS;
+
+ AtspiComponent *comp = atspi_accessible_get_component_iface(object);
+ if (!comp) {
+ DEBUG("object is not a component");
+ return EINA_FALSE;
+ }
+
+ AtspiRect *rect = atspi_component_get_extents(comp, ATSPI_COORD_TYPE_SCREEN, NULL);
+ g_object_unref(comp);
+ if (!rect) {
+ DEBUG("object has no extents");
+ return EINA_FALSE;
+ }
+
+ *extents = *rect;
+ g_free(rect);
+
+ return EINA_TRUE;
+}
+
int get_percent_value(double value, double lower, double upper)
{
double add_for_rounding = 0.5f;
DEBUG("purging %p because of defunct state or window doesn't exist", wi->window);
return EINA_TRUE;
}
- AtspiComponent *comp = atspi_accessible_get_component_iface(wi->window);
- if (!comp) {
- DEBUG("purging %p because of not component", wi->window);
- return EINA_TRUE;
- }
- GError *err = NULL;
- AtspiRect *rect = atspi_component_get_extents(comp, ATSPI_COORD_TYPE_SCREEN, &err);
- g_object_unref(comp);
- GERROR_CHECK(err);
- if (!rect) {
- DEBUG("purging because failed to get extents");
+
+ AtspiRect extents;
+ if (!object_get_extents(wi->window, &extents)) {
+ DEBUG("purging %p because failed to get extents", wi->window);
return EINA_TRUE;
}
- g_free(rect);
+
return EINA_FALSE;
}
}
}
-static bool _window_extents_get(AtspiAccessible *window, AtspiRect *extents)
-{
- AtspiComponent *comp = atspi_accessible_get_component_iface(window);
- if (!comp) {
- DEBUG("window is not a component");
- return false;
- }
- AtspiRect *rect = atspi_component_get_extents(comp, ATSPI_COORD_TYPE_SCREEN, NULL);
- g_object_unref(comp);
- if (!rect) {
- DEBUG("window has no extents");
- return false;
- }
- *extents = *rect;
- g_free(rect);
- return true;
-}
-
static void _window_info_print(WindowInfo *wi)
{
if (!wi) return;
gchar *id = atspi_accessible_get_unique_id(wi->window, NULL);
AtspiRect extents;
- if (_window_extents_get(wi->window, &extents)) {
+ if (object_get_extents(wi->window, &extents)) {
DEBUG("Window: %s (%d, %d, %d, %d) view change need: %d, keyboard window: %d",
id, extents.x, extents.y, extents.width, extents.height,
wi->view_change_need, wi->keyboard_window_is);
if (!wi) continue;
_window_info_print(wi);
AtspiRect extents;
- if (!_window_extents_get(wi->window, &extents)) continue;
+ if (!object_get_extents(wi->window, &extents)) continue;
if ((extents.x <= x && extents.x + extents.width >= x) &&
(extents.y <= y && extents.y + extents.height >= y)) {
return wi->window;