Gestures support by app is checked when view content is changed 74/231174/2
authorLukasz Oleksak <l.oleksak@samsung.com>
Sun, 19 Apr 2020 21:20:38 +0000 (23:20 +0200)
committerLukasz Oleksak <l.oleksak@samsung.com>
Sun, 19 Apr 2020 21:30:14 +0000 (21:30 +0000)
This patch allows to update the policy of forwarding gestures
directly to application each time the navigation context is built,
not just when window:activate signal arrives. The policy is configured
basing on the root object of navigation context.

Change-Id: I1861021962e68a15db9882ef1d0ac6b17aeee22d

src/navigator.c
src/window_tracker.c

index 4a0a6a87bf3d0b1370963029a2461c9e1ecdf9fd..464dd968624b44ecb3cc27ab62225d207a2be74d 100644 (file)
@@ -3060,6 +3060,67 @@ static void on_gesture_detected(void *data, const Eldbus_Message *msg)
        g_free(info);
 }
 
+static void _send_app_gesture_support( const char* app_gesture_support )
+{
+       Eldbus_Connection *conn = NULL;
+       Eldbus_Object *dobj = NULL;
+       Eldbus_Proxy *proxy = NULL;
+
+       eldbus_init();
+       if ((conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM)) != NULL) {
+               if ((dobj = eldbus_object_get(conn, E_A11Y_SERVICE_BUS_NAME, E_A11Y_SERVICE_NAVI_OBJ_PATH)) != NULL) {
+                       if ((proxy = eldbus_proxy_get(dobj, E_A11Y_SERVICE_NAVI_IFC_NAME)) != NULL) {
+                               eldbus_proxy_call(proxy, "AppGestureSupport", NULL, NULL, -1, "s", app_gesture_support);
+                       }
+                       else
+                               ERROR("Failed to create proxy object for 'org.tizen.GestureNavigation'");
+                       eldbus_object_unref(dobj);
+               }
+               else
+                       ERROR("Failed to create eldbus object");
+               eldbus_connection_unref(conn);
+       }
+       else
+               ERROR("Connection to system bus failed");
+       eldbus_shutdown();
+
+}
+
+static void _check_app_gesture_support(AtspiAccessible *obj)
+{
+       Service_Data *sd = get_pointer_to_service_data_struct();
+       if (!sd) {
+               ERROR("Service Data is not available");
+               return;
+       }
+
+       GHashTable *hash_table = atspi_accessible_get_attributes(obj, NULL);
+       if (hash_table) {
+               gchar *app_gesture_support = g_hash_table_lookup(hash_table, "app_gesture_support");
+               if (app_gesture_support) {
+                       if (sd->supported_gestures && g_strcmp0(app_gesture_support, sd->supported_gestures) != 0) {
+                               _send_app_gesture_support(app_gesture_support);
+                               g_free(sd->supported_gestures);
+                               sd->supported_gestures = g_strdup(app_gesture_support);
+                       }
+               }
+               else {
+                       if ( !sd->supported_gestures || (sd->supported_gestures && g_strcmp0(sd->supported_gestures, "") != 0)) {
+                               _send_app_gesture_support("");
+                               g_free(sd->supported_gestures);
+                               sd->supported_gestures = g_strdup("");
+                       }
+               }
+               g_hash_table_unref(hash_table);
+       }
+       else
+               if ( !sd->supported_gestures || (sd->supported_gestures && g_strcmp0(sd->supported_gestures, "") == 0)) {
+                       _send_app_gesture_support("");
+                       g_free(sd->supported_gestures);
+                       sd->supported_gestures = g_strdup("");
+               }
+}
+
 static void _view_content_changed(AtspiAccessible *root, AtspiRole role, void *data, Eina_Bool default_label_enabled)
 {
        DEBUG("START");
@@ -3100,6 +3161,9 @@ static void _view_content_changed(AtspiAccessible *root, AtspiRole role, void *d
        default:
                break;
        }
+
+       _check_app_gesture_support(root);
+
        if (sound_feedback)
                smart_notification(WINDOW_STATE_CHANGE_NOTIFICATION_EVENT, 0, 0);
        DEBUG("END");
index 4d8c076bb81e31d112314b908c117b298346a5c5..1ba655295bae4fc02e163892215ce0e3ac88ed41 100644 (file)
@@ -92,67 +92,6 @@ fail_con:
 }
 #endif
 
-static void _send_app_gesture_support( const char* app_gesture_support )
-{
-       Eldbus_Connection *conn = NULL;
-       Eldbus_Object *dobj = NULL;
-       Eldbus_Proxy *proxy = NULL;
-
-       eldbus_init();
-       if ((conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM)) != NULL) {
-               if ((dobj = eldbus_object_get(conn, E_A11Y_SERVICE_BUS_NAME, E_A11Y_SERVICE_NAVI_OBJ_PATH)) != NULL) {
-                       if ((proxy = eldbus_proxy_get(dobj, E_A11Y_SERVICE_NAVI_IFC_NAME)) != NULL) {
-                               eldbus_proxy_call(proxy, "AppGestureSupport", NULL, NULL, -1, "s", app_gesture_support);
-                       }
-                       else
-                               ERROR("Failed to create proxy object for 'org.tizen.GestureNavigation'");
-                       eldbus_object_unref(dobj);
-               }
-               else
-                       ERROR("Failed to create eldbus object");
-               eldbus_connection_unref(conn);
-       }
-       else
-               ERROR("Connection to system bus failed");
-       eldbus_shutdown();
-
-}
-
-static void _check_app_gesture_support(AtspiAccessible *obj)
-{
-       Service_Data *sd = get_pointer_to_service_data_struct();
-       if (!sd) {
-               ERROR("Service Data is not available");
-               return;
-       }
-
-       GHashTable *hash_table = atspi_accessible_get_attributes(obj, NULL);
-       if (hash_table) {
-               gchar *app_gesture_support = g_hash_table_lookup(hash_table, "app_gesture_support");
-               if (app_gesture_support) {
-                       if (sd->supported_gestures && g_strcmp0(app_gesture_support, sd->supported_gestures) != 0) {
-                               _send_app_gesture_support(app_gesture_support);
-                               g_free(sd->supported_gestures);
-                               sd->supported_gestures = g_strdup(app_gesture_support);
-                       }
-               }
-               else {
-                       if ( !sd->supported_gestures || (sd->supported_gestures && g_strcmp0(sd->supported_gestures, "") != 0)) {
-                               _send_app_gesture_support("");
-                               g_free(sd->supported_gestures);
-                               sd->supported_gestures = g_strdup("");
-                       }
-               }
-               g_hash_table_unref(hash_table);
-       }
-       else
-               if ( !sd->supported_gestures || (sd->supported_gestures && g_strcmp0(sd->supported_gestures, "") == 0)) {
-                       _send_app_gesture_support("");
-                       g_free(sd->supported_gestures);
-                       sd->supported_gestures = g_strdup("");
-               }
-}
-
 static Eina_Bool _window_need_to_be_purged(Window_Info *wi)
 {
        if (!wi->window || object_has_defunct_state(wi->window)) {
@@ -415,9 +354,6 @@ static void _on_atspi_window_cb(const AtspiEvent *event)
                        g_free(name);
                        return;
                }
-
-               _check_app_gesture_support(event->source);
-
                _window_append(event->source, EINA_TRUE, EINA_FALSE, window_activate_info_type);
                subroot = NULL; //No need to keep subroot if any window gets activated
        } else if (!g_strcmp0(event->type, "window:deactivate")) {