aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukasz Stanislawski <lukasz.stanislawski@gmail.com>2019-02-13 12:52:01 +0100
committerLukasz Stanislawski <lukasz.stanislawski@gmail.com>2019-02-13 13:47:57 +0100
commitfb3a6d06e01ed147f384b0ef06914538089e4853 (patch)
treeeeb511c535daa4a9a3d73be994fb8eaf74264c6f
parentefl_acces: add Efl.Access.Bridge class (diff)
downloadefl-fb3a6d06e01ed147f384b0ef06914538089e4853.tar.gz
efl_access: move Efl.Access.root property to Elm.Atspi.Bridge
-rw-r--r--src/lib/elementary/efl_access_object.c11
-rw-r--r--src/lib/elementary/efl_access_object.eo8
-rw-r--r--src/lib/elementary/efl_ui_win.c9
-rw-r--r--src/lib/elementary/elm_atspi_app_object.c23
-rw-r--r--src/lib/elementary/elm_atspi_app_object.eo10
-rw-r--r--src/lib/elementary/elm_atspi_bridge.c77
-rw-r--r--src/lib/elementary/elm_atspi_bridge.eo9
7 files changed, 92 insertions, 55 deletions
diff --git a/src/lib/elementary/efl_access_object.c b/src/lib/elementary/efl_access_object.c
index 2417a55e82..82175a7eed 100644
--- a/src/lib/elementary/efl_access_object.c
+++ b/src/lib/elementary/efl_access_object.c
@@ -129,8 +129,6 @@ struct _Efl_Access_Object_Data
typedef struct _Efl_Access_Object_Data Efl_Access_Object_Data;
-static Eo *root;
-
EOLIAN static int
_efl_access_object_index_in_parent_get(const Eo *obj, Efl_Access_Object_Data *pd EINA_UNUSED)
{
@@ -498,15 +496,6 @@ _efl_access_object_relationships_clear(Eo *obj EINA_UNUSED, Efl_Access_Object_Da
sd->relations = NULL;
}
-EOLIAN Eo*
-_efl_access_object_access_root_get(const Eo *class EINA_UNUSED, void *pd EINA_UNUSED)
-{
- if (!root)
- root = efl_add(ELM_ATSPI_APP_OBJECT_CLASS, efl_main_loop_get());
-
- return root;
-}
-
EOLIAN void
_efl_access_object_efl_object_invalidate(Eo *obj, Efl_Access_Object_Data *pd)
{
diff --git a/src/lib/elementary/efl_access_object.eo b/src/lib/elementary/efl_access_object.eo
index 7e01d40f61..d23ef155d9 100644
--- a/src/lib/elementary/efl_access_object.eo
+++ b/src/lib/elementary/efl_access_object.eo
@@ -402,14 +402,6 @@ mixin Efl.Access.Object requires Efl.Object
relationships_clear @beta {
[[Removes all relationships in accessible object.]]
}
- @property access_root @class @beta {
- get {
- [[Get root object of accessible object hierarchy]]
- values {
- ret: Efl.Object; [[Root object]]
- }
- }
- }
}
implements {
Efl.Object.destructor;
diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c
index 7884bad3bf..256a315fcb 100644
--- a/src/lib/elementary/efl_ui_win.c
+++ b/src/lib/elementary/efl_ui_win.c
@@ -17,6 +17,7 @@
#define EFL_UI_WIDGET_FOCUS_MANAGER_PROTECTED
#define EFL_PART_PROTECTED
#define IPA_YLNO_ESU_LANRETNI_MLE
+#define ELM_ATSPI_APP_OBJECT_BETA
#include <Elementary.h>
#include <Elementary_Cursor.h>
@@ -2371,9 +2372,8 @@ _efl_ui_win_show(Eo *obj, Efl_Ui_Win_Data *sd)
if (_elm_config->atspi_mode)
{
- Eo *root;
efl_access_window_created_signal_emit(obj);
- root = efl_access_object_access_root_get(EFL_ACCESS_OBJECT_MIXIN);
+ Eo *root = elm_atspi_app_object_instance_get(ELM_ATSPI_APP_OBJECT_CLASS);
if (root)
efl_access_children_changed_added_signal_emit(root, obj);
}
@@ -2441,8 +2441,7 @@ _efl_ui_win_hide(Eo *obj, Efl_Ui_Win_Data *sd)
if (_elm_config->atspi_mode)
{
- Eo *root;
- root = efl_access_object_access_root_get(EFL_ACCESS_OBJECT_MIXIN);
+ Eo *root = elm_atspi_app_object_instance_get(ELM_ATSPI_APP_OBJECT_CLASS);
efl_access_window_destroyed_signal_emit(obj);
if (root)
efl_access_children_changed_del_signal_emit(root, obj);
@@ -9058,7 +9057,7 @@ EOLIAN Efl_Access_Object*
_efl_ui_win_efl_access_object_access_parent_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd EINA_UNUSED)
{
// attach all kinds of windows directly to access root object
- return efl_access_object_access_root_get(EFL_ACCESS_OBJECT_MIXIN);
+ return elm_atspi_app_object_instance_get(ELM_ATSPI_APP_OBJECT_CLASS);
}
#include "efl_ui_win_legacy.eo.c"
diff --git a/src/lib/elementary/elm_atspi_app_object.c b/src/lib/elementary/elm_atspi_app_object.c
index 880b39b1ca..3f4261df57 100644
--- a/src/lib/elementary/elm_atspi_app_object.c
+++ b/src/lib/elementary/elm_atspi_app_object.c
@@ -9,6 +9,7 @@
#include "elm_priv.h"
extern Eina_List *_elm_win_list;
+static Elm_Atspi_App_Object *instance;
typedef struct _Elm_Atspi_App_Object_Data Elm_Atspi_App_Object_Data;
@@ -17,6 +18,20 @@ struct _Elm_Atspi_App_Object_Data
const char *descr;
};
+EOLIAN static Eo*
+_elm_atspi_app_object_efl_object_constructor(Eo *obj, Elm_Atspi_App_Object_Data *_pd EINA_UNUSED)
+{
+ if (instance)
+ {
+ ERR("Attempt to crete new instance of Elm_Atspi_App_Object.");
+ return NULL;
+ }
+ obj = efl_constructor(efl_super(obj, ELM_ATSPI_APP_OBJECT_CLASS));
+ instance = obj;
+
+ return obj;
+}
+
EOLIAN static void
_elm_atspi_app_object_efl_object_destructor(Eo *obj EINA_UNUSED, Elm_Atspi_App_Object_Data *_pd)
{
@@ -67,4 +82,12 @@ _elm_atspi_app_object_efl_access_object_role_get(const Eo *obj EINA_UNUSED, Elm_
return EFL_ACCESS_ROLE_APPLICATION;
}
+EOLIAN static Elm_Atspi_App_Object*
+_elm_atspi_app_object_instance_get(const Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED)
+{
+ if (!instance)
+ instance = efl_add(ELM_ATSPI_APP_OBJECT_CLASS, efl_main_loop_get());
+ return instance;
+}
+
#include "elm_atspi_app_object.eo.c"
diff --git a/src/lib/elementary/elm_atspi_app_object.eo b/src/lib/elementary/elm_atspi_app_object.eo
index e386f390e0..456c7f19d5 100644
--- a/src/lib/elementary/elm_atspi_app_object.eo
+++ b/src/lib/elementary/elm_atspi_app_object.eo
@@ -3,8 +3,18 @@ class Elm.Atspi.App.Object extends Efl.Object implements Efl.Access.Object
[[AT-SPI application object class]]
legacy_prefix: elm_atspi_app_object;
data: Elm_Atspi_App_Object_Data;
+ methods {
+ @property instance @class @beta {
+ get {
+ values {
+ obj: Elm.Atspi.App.Object;
+ }
+ }
+ }
+ }
implements {
Efl.Object.destructor;
+ Efl.Object.constructor;
Efl.Access.Object.i18n_name { get; }
Efl.Access.Object.description { get; set; }
Efl.Access.Object.role { get; }
diff --git a/src/lib/elementary/elm_atspi_bridge.c b/src/lib/elementary/elm_atspi_bridge.c
index 561390eceb..e2a559d709 100644
--- a/src/lib/elementary/elm_atspi_bridge.c
+++ b/src/lib/elementary/elm_atspi_bridge.c
@@ -12,6 +12,7 @@
#define EFL_ACCESS_ACTION_BETA
#define EFL_ACCESS_BRIDGE_PROTECTED
+#define ELM_ATSPI_APP_OBJECT_BETA
#include "atspi/atspi-constants.h"
@@ -97,6 +98,7 @@ typedef struct _Elm_Atspi_Bridge_Data
Eldbus_Service_Interface *value;
} interfaces;
Eina_Hash *event_hash;
+ Efl_Access_Object *root;
Eina_Bool connected : 1;
} Elm_Atspi_Bridge_Data;
@@ -133,7 +135,7 @@ static void _text_selection_changed_send(void *data, const Efl_Event *event);
// bridge private methods
static void _bridge_object_register(Eo *bridge, Eo *obj);
static void _bridge_object_unregister(Eo *bridge, Eo *obj);
-static const char * _path_from_object(const Eo *eo);
+static const char * _bridge_path_from_object(Eo *bridge, const Eo *eo);
static void _bridge_signal_send(Eo *bridge, Eo *obj, const char *ifc, const Eldbus_Signal *signal, const char *minor, unsigned int det1, unsigned int det2, const char *variant_sig, ...);
static Eo * _bridge_object_from_path(Eo *bridge, const char *path);
static void _bridge_iter_object_reference_append(Eo *bridge, Eldbus_Message_Iter *iter, const Eo *obj);
@@ -580,16 +582,16 @@ _accessible_get_application(const Eldbus_Service_Interface *iface, const Eldbus_
Eldbus_Message *ret;
const char *obj_path = eldbus_message_path_get(msg);
Eo *bridge = eldbus_service_object_data_get(iface, ELM_ATSPI_BRIDGE_CLASS_NAME);
- Eo *root, *obj = _bridge_object_from_path(bridge, obj_path);
+ Eo *obj = _bridge_object_from_path(bridge, obj_path);
ELM_ATSPI_OBJ_CHECK_OR_RETURN_DBUS_ERROR(obj, EFL_ACCESS_OBJECT_MIXIN, msg);
+ ELM_ATSPI_BRIDGE_DATA_GET_OR_RETURN_VAL(bridge, pd, NULL);
ret = eldbus_message_method_return_new(msg);
EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
Eldbus_Message_Iter *iter = eldbus_message_iter_get(ret);
- root = efl_access_object_access_root_get(EFL_ACCESS_OBJECT_MIXIN);
- _bridge_iter_object_reference_append(bridge, iter, root);
+ _bridge_iter_object_reference_append(bridge, iter, pd->root);
return ret;
}
@@ -2017,7 +2019,9 @@ _bridge_object_from_path(Eo *bridge, const char *path)
unsigned long long eo_ptr = 0;
Eo *eo = NULL;
const char *tmp = path;
- Eo *ret, *root;
+ Eo *ret;
+
+ ELM_ATSPI_BRIDGE_DATA_GET_OR_RETURN_VAL(bridge, pd, NULL);
int len = strlen(ELM_ACCESS_OBJECT_PATH_PREFIX);
if (strncmp(path, ELM_ACCESS_OBJECT_PATH_PREFIX, len))
@@ -2026,14 +2030,12 @@ _bridge_object_from_path(Eo *bridge, const char *path)
tmp = path + len; /* Skip over the prefix */
if (!strcmp(ELM_ACCESS_OBJECT_PATH_ROOT, tmp))
{
- root = efl_access_object_access_root_get(EFL_ACCESS_OBJECT_MIXIN);
- return root;
+ return pd->root;
}
sscanf(tmp, "%llu", &eo_ptr);
eo = (Eo *) (uintptr_t) eo_ptr;
- ELM_ATSPI_BRIDGE_DATA_GET_OR_RETURN_VAL(bridge, pd, NULL);
if (!eina_hash_find(pd->cache, &eo))
{
WRN("Request for non-registered object: %s", path);
@@ -2046,16 +2048,16 @@ _bridge_object_from_path(Eo *bridge, const char *path)
}
static const char *
-_path_from_object(const Eo *eo)
+_bridge_path_from_object(Eo *bridge, const Eo *eo)
{
static char path[64];
- Eo *root;
+
+ ELM_ATSPI_BRIDGE_DATA_GET_OR_RETURN_VAL(bridge, pd, ATSPI_DBUS_PATH_NULL);
if (!eo)
return ATSPI_DBUS_PATH_NULL;
- root = efl_access_object_access_root_get(EFL_ACCESS_OBJECT_MIXIN);
- if (eo == root)
+ if (eo == pd->root)
snprintf(path, sizeof(path), "%s%s", ELM_ACCESS_OBJECT_PATH_PREFIX, ELM_ACCESS_OBJECT_PATH_ROOT);
else
snprintf(path, sizeof(path), ELM_ACCESS_OBJECT_REFERENCE_TEMPLATE, (unsigned long long)(uintptr_t)eo);
@@ -3142,7 +3144,7 @@ _bridge_iter_object_reference_append(Eo *bridge, Eldbus_Message_Iter *iter, cons
ELM_ATSPI_BRIDGE_DATA_GET_OR_RETURN(bridge, pd);
Eldbus_Message_Iter *iter_struct = eldbus_message_iter_container_new(iter, 'r', NULL);
EINA_SAFETY_ON_NULL_RETURN(iter);
- const char *path = _path_from_object(obj);
+ const char *path = _bridge_path_from_object(bridge, obj);
eldbus_message_iter_basic_append(iter_struct, 's', eldbus_connection_unique_name_get(pd->a11y_bus));
eldbus_message_iter_basic_append(iter_struct, 'o', path);
eldbus_message_iter_container_close(iter, iter_struct);
@@ -3197,11 +3199,11 @@ _cache_item_reference_append_cb(Eo *bridge, Eo *data, Eldbus_Message_Iter *iter_
if (!efl_ref_count(data) || efl_destructed_is(data))
return EINA_TRUE;
+ ELM_ATSPI_BRIDGE_DATA_GET_OR_RETURN_VAL(bridge, pd, EINA_TRUE);
+
Eldbus_Message_Iter *iter_struct, *iter_sub_array;
Efl_Access_State_Set states;
Efl_Access_Role role;
- Eo *root;
- root = efl_access_object_access_root_get(EFL_ACCESS_OBJECT_MIXIN);
role = efl_access_object_role_get(data);
@@ -3212,7 +3214,7 @@ _cache_item_reference_append_cb(Eo *bridge, Eo *data, Eldbus_Message_Iter *iter_
_bridge_iter_object_reference_append(bridge, iter_struct, data);
/* Marshall application */
- _bridge_iter_object_reference_append(bridge, iter_struct, root);
+ _bridge_iter_object_reference_append(bridge, iter_struct, pd->root);
Eo *parent = NULL;
parent = efl_access_object_access_parent_get(data);
@@ -3284,7 +3286,6 @@ _cache_get_items(const Eldbus_Service_Interface *iface, const Eldbus_Message *ms
Eldbus_Message_Iter *iter, *iter_array;
Eldbus_Message *ret;
Eina_List *to_process;
- Eo *root;
Eo *bridge = eldbus_service_object_data_get(iface, ELM_ATSPI_BRIDGE_CLASS_NAME);
if (!bridge) return NULL;
@@ -3298,8 +3299,7 @@ _cache_get_items(const Eldbus_Service_Interface *iface, const Eldbus_Message *ms
iter_array = eldbus_message_iter_container_new(iter, 'a', CACHE_ITEM_SIGNATURE);
EINA_SAFETY_ON_NULL_GOTO(iter_array, fail);
- root = efl_access_object_access_root_get(EFL_ACCESS_OBJECT_MIXIN);
- to_process = eina_list_append(NULL, root);
+ to_process = eina_list_append(NULL, pd->root);
while (to_process)
{
@@ -3694,7 +3694,6 @@ _on_elm_atspi_bridge_app_register(void *data EINA_UNUSED, const Eldbus_Message *
EAPI Eina_Bool
_elm_atspi_bridge_app_register(Eo *bridge)
{
- Eo *root;
ELM_ATSPI_BRIDGE_DATA_GET_OR_RETURN_VAL(bridge, pd, EINA_FALSE);
Eldbus_Message *message = eldbus_message_method_call_new(ATSPI_DBUS_NAME_REGISTRY,
@@ -3703,8 +3702,7 @@ _elm_atspi_bridge_app_register(Eo *bridge)
"Embed");
Eldbus_Message_Iter *iter = eldbus_message_iter_get(message);
- root = efl_access_object_access_root_get(EFL_ACCESS_OBJECT_MIXIN);
- _bridge_iter_object_reference_append(bridge, iter, root);
+ _bridge_iter_object_reference_append(bridge, iter, pd->root);
eldbus_connection_send(pd->a11y_bus, message, _on_elm_atspi_bridge_app_register, NULL, -1);
return EINA_TRUE;
@@ -3713,18 +3711,15 @@ _elm_atspi_bridge_app_register(Eo *bridge)
EAPI Eina_Bool
_elm_atspi_bridge_app_unregister(Eo *bridge)
{
- Eo *root;
ELM_ATSPI_BRIDGE_DATA_GET_OR_RETURN_VAL(bridge, pd, EINA_FALSE);
- root = efl_access_object_access_root_get(EFL_ACCESS_OBJECT_MIXIN);
-
Eldbus_Message *message = eldbus_message_method_call_new(ATSPI_DBUS_NAME_REGISTRY,
ATSPI_DBUS_PATH_ROOT,
ATSPI_DBUS_INTERFACE_SOCKET,
"Unembed");
Eldbus_Message_Iter *iter = eldbus_message_iter_get(message);
- _bridge_iter_object_reference_append(bridge, iter, root);
+ _bridge_iter_object_reference_append(bridge, iter, pd->root);
eldbus_connection_send(pd->a11y_bus, message, NULL, NULL, -1);
return EINA_TRUE;
@@ -4105,7 +4100,7 @@ static void _bridge_signal_send(Eo *bridge, Eo *obj, const char *infc, const Eld
Eldbus_Message *msg;
Eldbus_Message_Iter *iter , *iter_stack[64], *iter_struct;
va_list va;
- Eo *atspi_obj, *root;
+ Eo *atspi_obj;
const char *path;
int top = 0;
@@ -4115,8 +4110,7 @@ static void _bridge_signal_send(Eo *bridge, Eo *obj, const char *infc, const Eld
EINA_SAFETY_ON_NULL_RETURN(obj);
ELM_ATSPI_BRIDGE_DATA_GET_OR_RETURN(bridge, pd);
- path = _path_from_object(obj);
- root = efl_access_object_access_root_get(EFL_ACCESS_OBJECT_MIXIN);
+ path = _bridge_path_from_object(bridge, obj);
msg = eldbus_message_signal_new(path, infc, signal->name);
if (!msg) return;
@@ -4147,7 +4141,7 @@ static void _bridge_signal_send(Eo *bridge, Eo *obj, const char *infc, const Eld
break;
case 'o':
atspi_obj = va_arg(va, Eo*);
- path = _path_from_object(atspi_obj);
+ path = _bridge_path_from_object(bridge, atspi_obj);
eldbus_message_iter_basic_append(iter_stack[top], 'o', path);
break;
case ')':
@@ -4174,7 +4168,7 @@ static void _bridge_signal_send(Eo *bridge, Eo *obj, const char *infc, const Eld
eldbus_message_iter_container_close(iter, iter_stack[0]);
iter_struct = eldbus_message_iter_container_new(iter, 'r', NULL);
- path = _path_from_object(root);
+ path = _bridge_path_from_object(bridge, pd->root);
eldbus_message_iter_basic_append(iter_struct, 's', eldbus_connection_unique_name_get(pd->a11y_bus));
eldbus_message_iter_basic_append(iter_struct, 'o', path);
eldbus_message_iter_container_close(iter, iter_struct);
@@ -4555,6 +4549,8 @@ _elm_atspi_bridge_init(void)
if (!_init_count)
{
_instance = efl_add_ref(ELM_ATSPI_BRIDGE_CLASS, NULL);
+ Eo *root = elm_atspi_app_object_instance_get(ELM_ATSPI_APP_OBJECT_CLASS);
+ elm_atspi_bridge_root_set(_instance, root);
_init_count = 1;
}
}
@@ -4807,7 +4803,26 @@ _elm_atspi_bridge_efl_object_destructor(Eo *obj, Elm_Atspi_Bridge_Data *pd)
if (pd->bus_obj) eldbus_object_unref(pd->bus_obj);
if (pd->session_bus) eldbus_connection_unref(pd->session_bus);
+ if (pd->root) efl_unref(pd->root);
+
efl_destructor(efl_super(obj, ELM_ATSPI_BRIDGE_CLASS));
}
+EOLIAN void
+_elm_atspi_bridge_root_set(Eo *obj EINA_UNUSED, Elm_Atspi_Bridge_Data *pd, Efl_Access_Object *root)
+{
+ if (pd->root)
+ efl_unref(pd->root);
+ if (root)
+ pd->root = efl_ref(root);
+ else
+ pd->root = NULL;
+}
+
+EOLIAN Efl_Access_Object*
+_elm_atspi_bridge_root_get(const Eo *obj EINA_UNUSED, Elm_Atspi_Bridge_Data *pd)
+{
+ return pd->root;
+}
+
#include "elm_atspi_bridge.eo.c"
diff --git a/src/lib/elementary/elm_atspi_bridge.eo b/src/lib/elementary/elm_atspi_bridge.eo
index f0549918ff..48057e3151 100644
--- a/src/lib/elementary/elm_atspi_bridge.eo
+++ b/src/lib/elementary/elm_atspi_bridge.eo
@@ -13,6 +13,15 @@ class Elm.Atspi.Bridge extends Efl.Access.Bridge
}
}
}
+ @property root {
+ get {
+ }
+ set {
+ }
+ values {
+ root: Efl.Access.Object;
+ }
+ }
}
implements {
Efl.Object.constructor;