From 51f850df676956d4085002afb401d2c649ffb93f Mon Sep 17 00:00:00 2001 From: Wonki Kim Date: Fri, 6 Apr 2018 01:07:17 +0900 Subject: [PATCH] efl_access_component: resolve property name conflicts this class is a giant FIXME for anyone looking to do refactoring work. the only reason it seems to exist is to provide wrappers around efl.gfx functions and provide screen position adjustments--something which isn't even viable under wayland note that a test was removed here due to the corresponding method being removed Change-Id: I6ee1c14c6a56945ff7f551af4e89705d216018ed --- src/lib/elementary/efl_access_component.c | 45 ++++-------------------------- src/lib/elementary/efl_access_component.eo | 36 ++---------------------- src/lib/elementary/efl_ui_widget.c | 18 ------------ src/lib/elementary/elm_atspi_bridge.c | 42 +++++++++++++++++++++------- src/lib/elementary/elm_widget_item.eo | 2 -- src/tests/elementary/elm_test_win.c | 27 ++---------------- 6 files changed, 42 insertions(+), 128 deletions(-) diff --git a/src/lib/elementary/efl_access_component.c b/src/lib/elementary/efl_access_component.c index 90555e4..dcf2435 100644 --- a/src/lib/elementary/efl_access_component.c +++ b/src/lib/elementary/efl_access_component.c @@ -21,45 +21,25 @@ typedef struct _Efl_Access_Component_Data Efl_Access_Component_Data; EOLIAN static void -_efl_access_component_position_get(Eo *obj EINA_UNUSED, Efl_Access_Component_Data *_pd EINA_UNUSED, Eina_Bool type, int *x, int *y) +_efl_access_component_screen_position_get(Eo *obj EINA_UNUSED, Efl_Access_Component_Data *_pd EINA_UNUSED, int *x, int *y) { Eina_Rect r; - r = efl_access_component_extents_get(obj, type); + r = efl_access_component_extents_get(obj, EINA_TRUE); if (x) *x = r.x; if (y) *y = r.y; } EOLIAN static Eina_Bool -_efl_access_component_position_set(Eo *obj EINA_UNUSED, Efl_Access_Component_Data *_pd EINA_UNUSED, Eina_Bool type, int x, int y) +_efl_access_component_screen_position_set(Eo *obj EINA_UNUSED, Efl_Access_Component_Data *_pd EINA_UNUSED, int x, int y) { Eina_Rect r; - r = efl_access_component_extents_get(obj, type); + r = efl_access_component_extents_get(obj, EINA_TRUE); r.x = x; r.y = y; - return efl_access_component_extents_set(obj, type, r); -} -EOLIAN static Eina_Bool -_efl_access_component_size_set(Eo *obj EINA_UNUSED, Efl_Access_Component_Data *_pd EINA_UNUSED, int w, int h) -{ - Eina_Rect r; - - r = efl_access_component_extents_get(obj, EINA_FALSE); - r.w = w; - r.h = h; - return efl_access_component_extents_set(obj, EINA_FALSE, r); -} - -EOLIAN static void -_efl_access_component_size_get(Eo *obj EINA_UNUSED, Efl_Access_Component_Data *_pd EINA_UNUSED, int *w, int *h) -{ - Eina_Rect r; - - r = efl_access_component_extents_get(obj, EINA_FALSE); - if (w) *w = r.w; - if (h) *h = r.h; + return efl_access_component_extents_set(obj, EINA_TRUE, r); } EOLIAN static Eina_Bool @@ -71,15 +51,6 @@ _efl_access_component_contains(Eo *obj EINA_UNUSED, Efl_Access_Component_Data *_ return eina_rectangle_coords_inside(&r.rect, x, y); } -EOLIAN static double -_efl_access_component_alpha_get(Eo *obj, Efl_Access_Component_Data *_pd EINA_UNUSED) -{ - int alpha; - - evas_object_color_get(obj, NULL, NULL, NULL, &alpha); - return (double)alpha / 255.0; -} - EOLIAN static Eo * _efl_access_component_accessible_at_point_get(Eo *obj, Efl_Access_Component_Data *_pd EINA_UNUSED, Eina_Bool screen_coords, int x, int y) { @@ -156,12 +127,6 @@ _efl_access_component_extents_set(Eo *obj, Efl_Access_Component_Data *_pd EINA_U } EOLIAN static int -_efl_access_component_layer_get(Eo *obj, Efl_Access_Component_Data *_pd EINA_UNUSED) -{ - return evas_object_layer_get(obj); -} - -EOLIAN static int _efl_access_component_z_order_get(Eo *obj EINA_UNUSED, Efl_Access_Component_Data *_pd EINA_UNUSED) { // Currently not used. diff --git a/src/lib/elementary/efl_access_component.eo b/src/lib/elementary/efl_access_component.eo index e9c40e6..1f1ca5a 100644 --- a/src/lib/elementary/efl_access_component.eo +++ b/src/lib/elementary/efl_access_component.eo @@ -1,38 +1,10 @@ import eina_types; -mixin Efl.Access.Component () +mixin Efl.Access.Component (Efl.Gfx, Efl.Gfx.Stack) { [[AT-SPI component mixin]] data: Efl_Access_Component_Data; methods { - @property size @protected @beta { - [[Size of accessible widget.]] - set { - return: bool; [[$true if size was set, $false otherwise]] - } - get { - } - values { - w: int; [[Width of the widget]] - h: int; [[Height of the widget]] - } - } - @property layer @protected @beta { - [[Evas layer of accessible widget.]] - get { - } - values { - layer: int; [[Evas layer of the widget]] - } - } - @property alpha @protected @beta { - [[Gets alpha of accessible widget.]] - get { - } - values { - alpha: double; [[Alpha value in [0, 1] range.]] - } - } @property z_order @protected @beta { [[Gets the depth at which the component is shown in relation to other components in the same container.]] @@ -57,17 +29,13 @@ mixin Efl.Access.Component () rect: Eina.Rect; [[The geometry.]] } } - @property position @protected @beta { + @property screen_position @protected @beta { [[Position of accessible widget.]] set { return: bool; [[$true if position was set, $false otherwise]] } get { } - keys { - screen_coords: bool; [[If $true x and y values will be relative to - screen origin, otherwise relative to canvas]] - } values { x: int; [[X coordinate]] y: int; [[Y coordinate]] diff --git a/src/lib/elementary/efl_ui_widget.c b/src/lib/elementary/efl_ui_widget.c index 56c1678..9a2f25a 100644 --- a/src/lib/elementary/efl_ui_widget.c +++ b/src/lib/elementary/efl_ui_widget.c @@ -6370,14 +6370,6 @@ _elm_widget_item_efl_access_component_extents_set(Eo *obj EINA_UNUSED, Elm_Widge return EINA_FALSE; } -EOLIAN static int -_elm_widget_item_efl_access_component_layer_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED) -{ - if (!sd->view) - return -1; - return evas_object_layer_get(sd->view); -} - EOLIAN static Eina_Bool _elm_widget_item_efl_access_component_focus_grab(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd EINA_UNUSED) { @@ -6434,16 +6426,6 @@ _elm_widget_item_efl_access_can_highlight_get(Eo *obj, Elm_Widget_Item_Data *_pd } // -EOLIAN static double -_elm_widget_item_efl_access_component_alpha_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED) -{ - int alpha; - - if (!sd->view) return -1.0; - evas_object_color_get(sd->view, NULL, NULL, NULL, &alpha); - return (double)alpha / 255.0; -} - EOLIAN static Efl_Object * _efl_ui_widget_efl_object_provider_find(const Eo *obj, Elm_Widget_Smart_Data *pd, const Efl_Object *klass) { diff --git a/src/lib/elementary/elm_atspi_bridge.c b/src/lib/elementary/elm_atspi_bridge.c index fa294f8..a9a1a52 100644 --- a/src/lib/elementary/elm_atspi_bridge.c +++ b/src/lib/elementary/elm_atspi_bridge.c @@ -5074,7 +5074,13 @@ _component_get_position(const Eldbus_Service_Interface *iface EINA_UNUSED, const return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type."); Eina_Bool type = coord_type == ATSPI_COORD_TYPE_SCREEN ? EINA_TRUE : EINA_FALSE; - efl_access_component_position_get(obj, type, &x, &y); + if (efl_gfx_visible_get(obj)) + { + if (type) + efl_access_component_screen_position_get(obj, &x, &y); + else + evas_object_geometry_get(obj, &x, &y, NULL, NULL); + } ret = eldbus_message_method_return_new(msg); EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL); @@ -5096,7 +5102,8 @@ _component_get_size(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eld ELM_ATSPI_OBJ_CHECK_OR_RETURN_DBUS_ERROR(obj, EFL_ACCESS_COMPONENT_MIXIN, msg); - efl_access_component_size_get(obj, &x, &y); + if (efl_gfx_visible_get(obj)) + evas_object_geometry_get(obj, NULL, NULL, &x, &y); ret = eldbus_message_method_return_new(msg); EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL); @@ -5123,13 +5130,14 @@ _component_get_layer(const Eldbus_Service_Interface *iface EINA_UNUSED, const El const char *obj_path = eldbus_message_path_get(msg); Eo *bridge = eldbus_service_object_data_get(iface, ELM_ATSPI_BRIDGE_CLASS_NAME); Eo *obj = _bridge_object_from_path(bridge, obj_path); - int layer = 0; + int layer = -1; Eldbus_Message *ret; AtspiComponentLayer atspi_layer; ELM_ATSPI_OBJ_CHECK_OR_RETURN_DBUS_ERROR(obj, EFL_ACCESS_COMPONENT_MIXIN, msg); - layer = efl_access_component_layer_get(obj); + if (efl_gfx_visible_get(obj)) + layer = evas_object_layer_get(obj); ret = eldbus_message_method_return_new(msg); EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL); @@ -5213,12 +5221,17 @@ _component_get_alpha(const Eldbus_Service_Interface *iface EINA_UNUSED, const El Eo *bridge = eldbus_service_object_data_get(iface, ELM_ATSPI_BRIDGE_CLASS_NAME); Eo *obj = _bridge_object_from_path(bridge, obj_path); Eldbus_Message *ret; - double alpha = 0; + double alpha = -1; + int a; if (!obj) return _dbus_invalid_ref_error_new(msg); - alpha = efl_access_component_alpha_get(obj); + if (efl_gfx_visible_get(obj)) + { + evas_object_color_get(obj, NULL, NULL, NULL, &a); + alpha = a / 255.0; + } ret = eldbus_message_method_return_new(msg); EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL); @@ -5261,7 +5274,7 @@ _component_set_position(const Eldbus_Service_Interface *iface EINA_UNUSED, const const char *obj_path = eldbus_message_path_get(msg); Eo *bridge = eldbus_service_object_data_get(iface, ELM_ATSPI_BRIDGE_CLASS_NAME); Eo *obj = _bridge_object_from_path(bridge, obj_path); - int x, y; + int x = -1, y = -1; Eina_Bool result = EINA_FALSE; AtspiCoordType coord_type; Eldbus_Message *ret; @@ -5272,7 +5285,16 @@ _component_set_position(const Eldbus_Service_Interface *iface EINA_UNUSED, const return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type."); Eina_Bool type = coord_type == ATSPI_COORD_TYPE_SCREEN ? EINA_TRUE : EINA_FALSE; - result = efl_access_component_position_set(obj, type, x, y); + if (efl_gfx_visible_get(obj)) + { + if (type) + result = efl_access_component_screen_position_set(obj, x, y); + else + { + result = EINA_TRUE; + evas_object_move(obj, x, y); + } + } ret = eldbus_message_method_return_new(msg); EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL); @@ -5289,7 +5311,7 @@ _component_set_size(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eld Eo *bridge = eldbus_service_object_data_get(iface, ELM_ATSPI_BRIDGE_CLASS_NAME); Eo *obj = _bridge_object_from_path(bridge, obj_path); int w, h; - Eina_Bool result; + Eina_Bool result = EINA_TRUE; Eldbus_Message *ret; ELM_ATSPI_OBJ_CHECK_OR_RETURN_DBUS_ERROR(obj, EFL_ACCESS_COMPONENT_MIXIN, msg); @@ -5297,7 +5319,7 @@ _component_set_size(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eld if (!eldbus_message_arguments_get(msg, "ii", &w, &h)) return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type."); - result = efl_access_component_size_set(obj, w, h); + evas_object_resize(obj, w, h); ret = eldbus_message_method_return_new(msg); EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL); diff --git a/src/lib/elementary/elm_widget_item.eo b/src/lib/elementary/elm_widget_item.eo index 2cac1d4..2abd1ca 100644 --- a/src/lib/elementary/elm_widget_item.eo +++ b/src/lib/elementary/elm_widget_item.eo @@ -556,8 +556,6 @@ class Elm.Widget.Item(Efl.Object, Efl.Access, Efl.Access.translation_domain { set; get;} // Efl.Access.Component.extents { get; set; } - Efl.Access.Component.alpha { get; } - Efl.Access.Component.layer { get; } Efl.Access.Component.focus_grab; //TIZEN_ONLY(20150709) : atspi relations api Efl.Access.relation_set { get; } diff --git a/src/tests/elementary/elm_test_win.c b/src/tests/elementary/elm_test_win.c index 22b894a..4dee633 100644 --- a/src/tests/elementary/elm_test_win.c +++ b/src/tests/elementary/elm_test_win.c @@ -99,7 +99,7 @@ START_TEST (elm_atspi_role_get) } END_TEST -START_TEST (elm_atspi_component_position) +START_TEST (elm_atspi_component_screen_position) { Eina_Bool ret; int x, y; @@ -108,7 +108,7 @@ START_TEST (elm_atspi_component_position) Eo *win = elm_win_add(NULL, "win", ELM_WIN_BASIC); - ret = efl_access_component_position_set(win, EINA_TRUE, 45, 45); + ret = efl_access_component_screen_position_set(win, 45, 45); ck_assert(ret == EINA_TRUE); Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(win)); @@ -121,26 +121,6 @@ START_TEST (elm_atspi_component_position) } END_TEST -START_TEST (elm_atspi_component_size) -{ - Eina_Bool ret; - int w, h; - - elm_init(0, NULL); - - Eo *win = elm_win_add(NULL, "win", ELM_WIN_BASIC); - evas_object_resize(win, 50, 50); - - ret = efl_access_component_size_set(win, 100, 100); - ck_assert(ret == EINA_TRUE); - - evas_object_geometry_get(win, NULL, NULL, &w, &h); - ck_assert((w == 100) && (h == 100)); - - elm_shutdown(); -} -END_TEST - START_TEST (elm_win_autohide) { elm_init(0, NULL); @@ -419,8 +399,7 @@ void elm_test_win(TCase *tc) { tcase_add_test(tc, elm_win_legacy_type_check); tcase_add_test(tc, elm_atspi_role_get); - tcase_add_test(tc, elm_atspi_component_position); - tcase_add_test(tc, elm_atspi_component_size); + tcase_add_test(tc, elm_atspi_component_screen_position); tcase_add_test(tc, elm_win_policy_quit_last_window_hidden); tcase_add_test(tc, efl_ui_win_multi_touch_inputs); #ifdef HAVE_ELEMENTARY_X -- 2.7.4