Use window resource id 55/274855/3 submit/tizen/20220520.004100
authorShinwoo Kim <cinoo.kim@samsung.com>
Wed, 11 May 2022 03:14:28 +0000 (12:14 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Thu, 19 May 2022 10:59:17 +0000 (19:59 +0900)
We need to support multi window case.
Using window resource id would be more correct way to get window
under x, y position.

This will work well only with following patch.

https://review.tizen.org/gerrit/#/c/platform/core/uifw/e-mod-tizen-screen-reader/+/274553/

and patch of each toolkit providing window attribute "ResID".

Change-Id: I4bae851422858e2db76611d8c3e959ed657984a2

include/app_tracker.h
include/utils.h
include/window_info.h
include/window_tracker.h
src/app_tracker.c
src/navigator.c
src/window_tracker.c

index af58bb8f601a513362b84534c1a1120da89a88cd..0b039447ef876cecf623822f19faa853a76a5319 100644 (file)
@@ -66,6 +66,13 @@ AtspiAccessible* app_tracker_top_window_get(App_Tracker_Data *atd);
  */
 AtspiAccessible* app_tracker_at_point_window_get(App_Tracker_Data *atd, int x, int y);
 
+/**
+ * @brief This function allows access to submodule functinality of app_tracker.
+ *
+ * @param atd internal data of app tracker module
+ */
+AtspiAccessible* app_tracker_resource_id_window_get(App_Tracker_Data *atd, uint32_t resource_id);
+
 /**
  * @brief This function allows access to submodule functinality of app_tracker.
  *
index 27cf9a87a862bce03ef3840eff112718440ed630..b0d3198fda872ed6f5896d8ff7cda211076f49ac 100644 (file)
@@ -78,7 +78,7 @@ typedef struct {
        pid_t pid;            // pid of process on which gesture took place.
        int state;            // 0 - begin, 1 - ongoing, 2 - ended, 3 - aborted
        int event_time;
-       int resource_id;      // unique value identifying the window on which gesture took place in multi-window environment
+       uint32_t resource_id; // unique value identifying the window on which gesture took place in multi-window environment
 } Gesture_Info;
 
 typedef void (*GestureCB)(void *data, const Eldbus_Message *msg);
index 84eaf0c44a9ded369500df6bd28bc165944f3cb9..514f3d3d1c6fe495bf9546d68c1b0babfa783e7e 100644 (file)
@@ -17,6 +17,7 @@ typedef struct {
        Eina_Bool keyboard_window_is;
        Eina_Bool view_change_need; /* Would be not necessary, keep this for later usage */
        WindowActivateInfoType window_activate_info_type;
+       uint32_t resource_id;
 } WindowInfo;
 
 #endif
index 6ae9f965493a8a71ee456a5682aa7ca9c4cb7bc8..9e327f1909f6463da3570eb16a73c1ff3fb32cb3 100644 (file)
@@ -67,6 +67,11 @@ void window_tracker_window_remove(WindowTrackerData *wtd, AtspiAccessible *windo
  */
 AtspiAccessible *window_tracker_at_point_window_get(WindowTrackerData *wtd, int x, int y);
 
+/*
+ * @brief Returns window of resource id
+ */
+AtspiAccessible *window_tracker_resource_id_window_get(WindowTrackerData *wtd, uint32_t resource_id);
+
 /*
  * @brief Removes keyboard window from window list
  */
index 5c1210a75efe384d1b56b49a907249271f8ca3a0..f6070cefe70168991dab3b469adf818c4ee7b22a 100644 (file)
@@ -824,6 +824,11 @@ AtspiAccessible* app_tracker_at_point_window_get(App_Tracker_Data *atd, int x, i
        return atd ? window_tracker_at_point_window_get(atd->window_tracker_data, x, y) : NULL;
 }
 
+AtspiAccessible* app_tracker_resource_id_window_get(App_Tracker_Data *atd, uint32_t resource_id)
+{
+       return atd ? window_tracker_resource_id_window_get(atd->window_tracker_data, resource_id) : NULL;
+}
+
 WindowInfo* app_tracker_top_window_info_get(App_Tracker_Data *atd)
 {
        return atd ? window_tracker_top_window_info_get(atd->window_tracker_data) : NULL;
index 548df15d67e24569cc4d745f23b7d39bfcdbfd41..04335063a71c04c11a472401b339ac9763548e1d 100644 (file)
@@ -535,6 +535,8 @@ void test_debug(AtspiAccessible *current_widget)
        g_object_unref(parent);
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-function"
 /* change context root if bus name of window at point is different from bus name of context root */
 TIZEN_PROD_STATIC void _window_at_point_check(NavigatorData *nd, int x, int y)
 {
@@ -564,13 +566,33 @@ TIZEN_PROD_STATIC void _window_at_point_check(NavigatorData *nd, int x, int y)
        g_free(touched_window_bus_name);
        g_free(context_root_bus_name);
 }
+#pragma GCC diagnostic pop
+
+TIZEN_PROD_STATIC void _window_of_resource_id_check(NavigatorData *nd, uint32_t resource_id)
+{
+       AtspiAccessible *touched_window = NULL;
+       AtspiAccessible *context_root = NULL;
+
+       touched_window = app_tracker_resource_id_window_get(nd->app_tracker_data, resource_id);
+       context_root = flat_navi_context_root_get(nd->flat_navi_context);
+
+       if (!touched_window || !context_root) return;
+
+       if (touched_window && !atspi_accessible_is_equal(touched_window, context_root)) {
+               gchar *id = atspi_accessible_get_unique_id(touched_window, NULL);
+               gchar *id2 = atspi_accessible_get_unique_id(context_root, NULL);
+               DEBUG("Changing navigation context root FROM: %s TO: %s (touched window with resID: %u)", id2, id, resource_id);
+               g_free(id);
+               g_free(id2);
+               flat_navi_context_root_change(nd->flat_navi_context, touched_window);
+       }
+}
 
 TIZEN_PROD_STATIC void _focus_widget(NavigatorData *nd, Gesture_Info *info)
 {
        DEBUG("START");
        AtspiAccessible *obj = NULL;
-       // TODO: use info->resource_id instead of (x_beg, y_beg) in order to determine window
-       _window_at_point_check(nd, info->x_beg, info->y_beg);
+       _window_of_resource_id_check(nd, info->resource_id);
 
        if ((nd->last_focus.x == info->x_beg) && (nd->last_focus.y == info->y_beg))
                return;
@@ -2261,7 +2283,7 @@ TIZEN_PROD_STATIC void on_gesture_detected(void *data, const Eldbus_Message *msg
                return;
        }
        info->type = (Gesture)g_type;
-       DEBUG("Incoming gesture name is %s : %d %d %d %d %d %d", utils_enum_to_string(info->type),
+       DEBUG("Incoming gesture name is %s : %d %d %d %d %d %u", utils_enum_to_string(info->type),
                  info->x_beg, info->y_beg, info->x_end, info->y_end, info->state, info->resource_id);
 
        _on_auto_review_stop(nd);
index 9598bcd7a6781a233d2c4adb2812ad0670aa8561..0dd51cc408ab3f571e08186b1d6344b40bd6b7ff 100644 (file)
@@ -183,6 +183,24 @@ static Eina_Bool _is_window_in_stack(WindowTrackerData *wtd, AtspiAccessible *wi
        return EINA_FALSE;
 }
 
+static uint32_t _window_resource_id_get(AtspiAccessible *window)
+{
+       uint32_t resource_id = 0;
+       GHashTable *hash_table = atspi_accessible_get_attributes(window, NULL);
+       if (hash_table) {
+               gchar *resID = g_hash_table_lookup(hash_table, "resID");
+               if (resID) {
+                       DEBUG("Resource id: %s", resID);
+                       resource_id = (uint32_t)atoi(resID);
+               }
+               else
+                       ERROR("Window does not have Resource id");
+
+               g_hash_table_unref(hash_table);
+       }
+       return resource_id;
+}
+
 static void _window_append(WindowTrackerData *wtd, AtspiAccessible *window, Eina_Bool view_change_need,
                                                   Eina_Bool keyboard_window_is, WindowActivateInfoType window_activate_info_type)
 {
@@ -224,6 +242,7 @@ static void _window_append(WindowTrackerData *wtd, AtspiAccessible *window, Eina
        wi->keyboard_window_is = keyboard_window_is;
        wi->view_change_need = view_change_need;
        wi->window_activate_info_type = window_activate_info_type;
+       wi->resource_id = _window_resource_id_get(window);
 
        wtd->window_infos = eina_list_append(wtd->window_infos, wi);
 
@@ -659,6 +678,29 @@ AtspiAccessible *window_tracker_at_point_window_get(WindowTrackerData *wtd, int
        return NULL;
 }
 
+AtspiAccessible *window_tracker_resource_id_window_get(WindowTrackerData *wtd, uint32_t resource_id)
+{
+       WindowInfo *wi;
+       Eina_List *l;
+
+       DEBUG("Number of window: %d, resource id: %u", eina_list_count(wtd->window_infos), resource_id);
+
+       EINA_LIST_REVERSE_FOREACH(wtd->window_infos, l, wi) {
+               if (!wi) continue;
+               AtspiRect *rect = wi->rect;
+               gchar *id = atspi_accessible_get_unique_id(wi->window, NULL);
+               DEBUG("Window: %s (%d, %d, %d, %d), view change need: %d, keyboard window: %d, resource id: %u",
+                         id, rect->x, rect->y, rect->width, rect->height,
+                         wi->view_change_need, wi->keyboard_window_is, wi->resource_id);
+               g_free(id);
+
+               if (wi->resource_id == resource_id) {
+                       return wi->window;
+               }
+       }
+       return NULL;
+}
+
 void window_tracker_keyboard_window_remove(WindowTrackerData *wtd)
 {
        WindowInfo *wi;