Add navigator_set_context_switch_cb 39/277639/6
authorArtur Świgoń <a.swigon@samsung.com>
Mon, 11 Jul 2022 09:17:00 +0000 (11:17 +0200)
committerArtur Świgoń <a.swigon@samsung.com>
Tue, 26 Jul 2022 16:18:34 +0000 (18:18 +0200)
This callback allows to plug in a custom context_switch action. Also,
useless assignments in navigator_init are removed (calloc is used). The
legacy function _window_at_point_check is also removed.

Change-Id: I50106cc25a322c9ac60389936366a2ba38c864f0

include/navigator.h
src/app_tracker.c
src/navigator.c

index 96d7b7333e33d4be15669ee9af34cbceea48f635..35983f0ce9ca27cd0d68d1d3fbd56fb90a081abb 100644 (file)
@@ -52,6 +52,9 @@ void sound_n_vibration_feedback_generate(AtspiAccessible *obj);
 typedef void(*read_quickpanel_cb_t)(void*);
 void navigator_set_read_quickpanel_cb(NavigatorData *nd, read_quickpanel_cb_t callback, void *user_data, read_quickpanel_cb_t deleter);
 
+typedef void (*NavigatorContextSwitchCb)(void *, AtspiAccessible *);
+void navigator_set_context_switch_cb(NavigatorData *nd, NavigatorContextSwitchCb callback, void *user_data);
+
 /* This is required by app_tracker */
 FlatNaviContext* navigator_get_flat_navi_context(NavigatorData *nd);
 
index 689589b9af6295a3206aa77000b679c6540acab7..9a3801f9b8d1a68bb246d92a109e25e17bead2d9 100644 (file)
@@ -664,6 +664,7 @@ app_tracker_init(AppTrackerEventWithDefaultLabelInfoCB view_content_changed_cb,
        DEBUG("Registering app_tracker_context_switch=%p, for atd=%p", app_tracker_context_switch, atd);
        window_tracker_register(atd->window_tracker_data, app_tracker_context_switch, atd);
        window_tracker_active_window_request(atd->window_tracker_data);
+       navigator_set_context_switch_cb(nd, app_tracker_context_switch, atd);
 #endif
 
        atd->new_obj_highlighted_callback = NULL;
index 91a8ec5069abae45bf09850ee38731024ee373fa..8fd1fe22983856aa1680d5ded8ef6b7b8de948b6 100644 (file)
@@ -102,6 +102,8 @@ struct _NavigatorData {
        unsigned char quickpanel_info;
        Ecore_Timer *move_outed_timer;
        AtspiMoveOutedType move_outed_type;
+       NavigatorContextSwitchCb context_switch_cb;
+       void *context_switch_data;
 };
 
 char *state_to_char(AtspiStateType state)
@@ -535,57 +537,16 @@ 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)
-{
-       AtspiAccessible *touched_window = NULL;
-       AtspiAccessible *context_root = NULL;
-       gchar *touched_window_bus_name;
-       gchar *context_root_bus_name;
-
-       touched_window = app_tracker_at_point_window_get(nd->app_tracker_data, x, y);
-       context_root = flat_navi_context_root_get(nd->flat_navi_context);
-
-       if (!touched_window || !context_root) return;
-
-       touched_window_bus_name = atspi_accessible_get_bus_name(touched_window, NULL);
-       context_root_bus_name = atspi_accessible_get_bus_name(context_root, NULL);
-
-       if (touched_window && !atspi_accessible_is_equal(touched_window, context_root) &&
-                       g_strcmp0(touched_window_bus_name, context_root_bus_name)) {
-               gchar *id = atspi_accessible_get_unique_id(touched_window, NULL);
-               gchar *id2 = atspi_accessible_get_unique_id(context_root, NULL);
-               DEBUG("Window at point: %p (%s) context root: %p (%s)", touched_window, touched_window_bus_name, context_root, context_root_bus_name);
-               g_free(id);
-               g_free(id2);
-               flat_navi_context_root_change(nd->flat_navi_context, touched_window);
-       }
-
-       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) 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);
-       }
+       if (nd->context_switch_cb)
+               nd->context_switch_cb(nd->context_switch_data, touched_window);
 }
 
 TIZEN_PROD_STATIC void _focus_widget(NavigatorData *nd, Gesture_Info *info)
@@ -2737,16 +2698,6 @@ NavigatorData *navigator_init(void)
        nd->last_pos = (point_t) { .x = -1, .y = -1};
        nd->last_hover_event_time = -1;
        nd->last_slider_hover_event_time = -1;
-       nd->auto_review_on = false;
-       nd->slider_offset = 0;
-       nd->is_text_selection_mode = EINA_FALSE;
-       nd->ignore_keyboard_feedback = EINA_FALSE;
-       nd->flat_navi_context = NULL;
-       nd->supported_gestures = NULL;
-       nd->read_quickpanel_cb = NULL;
-       nd->read_quickpanel_data = NULL;
-       nd->read_quickpanel_deleter = NULL;
-       nd->connection = NULL;
 
        tw_set_utterance_cb(_on_utterance, nd, NULL);
 
@@ -2822,6 +2773,12 @@ void navigator_set_read_quickpanel_cb(
        nd->read_quickpanel_deleter = deleter;
 }
 
+void navigator_set_context_switch_cb(NavigatorData *nd, NavigatorContextSwitchCb callback, void *user_data)
+{
+       nd->context_switch_cb = callback;
+       nd->context_switch_data = user_data;
+}
+
 FlatNaviContext* navigator_get_flat_navi_context(NavigatorData *nd) {
        if (!nd) { ERROR("NavigatorData is NULL!"); }
        return nd ? nd->flat_navi_context : NULL;