libaurum: Support focus skipped window 67/273767/2 accepted/tizen/6.5/unified/20220418.141310 submit/tizen/20220415.071011 submit/tizen_6.5/20220415.071022
authorWoochanlee <wc0917.lee@samsung.com>
Wed, 13 Apr 2022 10:21:53 +0000 (19:21 +0900)
committerWoochanlee <wc0917.lee@samsung.com>
Thu, 14 Apr 2022 01:20:03 +0000 (10:20 +0900)
Some of VD application want to use Aurum on focus skipped window such as volume, tv-viewer

Change-Id: Ic2377d30930fb13cee3e4abcd73c8395a91b46cb

libaurum/inc/Impl/Accessibility/AtspiAccessibleWatcher.h
libaurum/src/Accessibility/AccessibleApplication.cc
libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc

index 2f8e54a..90c88a4 100644 (file)
@@ -155,6 +155,8 @@ private:
     void addEventListener(AtspiEventListener *listener, A11yEvent type);
     void removeEventListener(AtspiEventListener *listener, A11yEvent type);
     static gpointer eventThreadLoop(gpointer data);
+    void appendApp(AtspiAccessibleWatcher *instance, AtspiAccessible *app, char *pkg);
+    void removeApp(AtspiAccessibleWatcher *instance, AtspiAccessible *app, char *pkg);
 
 private:
     GDBusProxy *mDbusProxy;
@@ -167,6 +169,7 @@ private:
     static std::vector<std::shared_ptr<A11yEventInfo>> mEventQueue;
     static std::mutex mMutex;
     static GMainLoop *mLoop;
+    bool isTv;
 };
 
 }
index bbccc78..21c8fd0 100644 (file)
@@ -46,7 +46,7 @@ std::vector<std::shared_ptr<AccessibleWindow>> AccessibleApplication::getActiveW
     auto children = getWindows();
 
     children.erase(std::remove_if(children.begin(), children.end(), [](auto child){
-                        return !(child->isActive() && child->isShowing()); // && child->isShowing() && child->isVisible());
+                        return !(child->isShowing()); // Active, Showing are same meaning currently
                     }), children.end());
 
     return children;
index 515acb6..ffc46ed 100644 (file)
@@ -27,6 +27,7 @@
 #include <chrono>
 #include <thread>
 #include <iostream>
+#include <system_info.h>
 
 using namespace Aurum;
 using namespace AurumInternal;
@@ -123,7 +124,7 @@ gpointer AtspiAccessibleWatcher::eventThreadLoop(gpointer data)
 }
 
 AtspiAccessibleWatcher::AtspiAccessibleWatcher()
-: mDbusProxy{nullptr}
+: mDbusProxy{nullptr}, isTv{false}
 {
     GVariant *result = nullptr;
     GError *error = nullptr;
@@ -145,6 +146,20 @@ AtspiAccessibleWatcher::AtspiAccessibleWatcher()
 
     g_variant_unref(result);
     if (error) g_error_free(error);
+
+    int vconfRet;
+    char *value;
+
+    vconfRet = system_info_get_platform_string("http://tizen.org/feature/profile", &value);
+    if (vconfRet != SYSTEM_INFO_ERROR_NONE) LOGE("Fail to get system profile infomation");
+    else {
+        if (!strncmp("tv", value, 2)) {
+            LOGI("Aurum is working on TV profile");
+            isTv = true;
+        }
+
+        free(value);
+    }
 }
 
 AtspiAccessibleWatcher::~AtspiAccessibleWatcher()
@@ -166,6 +181,43 @@ AtspiAccessibleWatcher::~AtspiAccessibleWatcher()
     atspi_exit();
 }
 
+void AtspiAccessibleWatcher::appendApp(AtspiAccessibleWatcher *instance, AtspiAccessible *app, char *pkg)
+{
+    AtspiWrapper::Atspi_accessible_set_cache_mask(app, ATSPI_CACHE_ALL);
+    LOGI("window activated in app(%s)", pkg);
+    if (!instance->mActiveAppMap.count(app)) {
+        LOGI("add activated window's app in map");
+        instance->mActiveAppMap.insert(std::pair<AtspiAccessible *, std::shared_ptr<AccessibleApplication>>(app,
+                std::make_shared<AtspiAccessibleApplication>(std::make_shared<AtspiAccessibleNode>(app))));
+    }
+    else {
+        LOGI("app(%s) is already in map", pkg);
+    }
+
+    if (!instance->mXMLDocMap.count(std::string(pkg))) {
+        instance->mXMLDocMap.insert(std::pair<std::string, std::shared_ptr<AurumXML>>(std::string(pkg),
+                             std::make_shared<AurumXML>(std::make_shared<AtspiAccessibleNode>(app))));
+    }
+}
+
+void AtspiAccessibleWatcher::removeApp(AtspiAccessibleWatcher *instance, AtspiAccessible *app, char *pkg)
+{
+    LOGI("window deactivate in app(%s)", pkg);
+    if (instance->mActiveAppMap.count(app)) {
+        LOGI("window deactivated delete app(%s) in map", pkg);
+        instance->mActiveAppMap.erase(app);
+    }
+    else {
+        LOGE("deactivated window's app(%s) is not in map", pkg);
+    }
+
+    if (instance->mXMLDocMap.count(std::string(pkg))) {
+        instance->mXMLDocMap.erase(std::string(pkg));
+    }
+
+    g_object_unref(app);
+}
+
 void AtspiAccessibleWatcher::onAtspiEvents(AtspiEvent *event, void *watcher)
 {
     if (!event->source)
@@ -177,41 +229,18 @@ void AtspiAccessibleWatcher::onAtspiEvents(AtspiEvent *event, void *watcher)
     name = AtspiWrapper::Atspi_accessible_get_name(event->source, NULL);
 
     AtspiAccessible *app = AtspiWrapper::Atspi_accessible_get_application(event->source, NULL);
-    if (app)
+    if (name && app)
     {
         pkg = AtspiWrapper::Atspi_accessible_get_name(app, NULL);
-        if (!strncmp(event->type, "window:activate", 15)) {
-            AtspiWrapper::Atspi_accessible_set_cache_mask(app, ATSPI_CACHE_ALL);
-            LOGI("window activated in app(%s)", pkg);
-            if (!instance->mActiveAppMap.count(app)) {
-                LOGI("add activated window's app in map");
-                instance->mActiveAppMap.insert(std::pair<AtspiAccessible *, std::shared_ptr<AccessibleApplication>>(app,
-                                     std::make_shared<AtspiAccessibleApplication>(std::make_shared<AtspiAccessibleNode>(app))));
-            }
-            else {
-                LOGI("app(%s) is already in map", pkg);
-            }
-
-            if (!instance->mXMLDocMap.count(std::string(pkg))) {
-                instance->mXMLDocMap.insert(std::pair<std::string, std::shared_ptr<AurumXML>>(std::string(pkg),
-                                     std::make_shared<AurumXML>(std::make_shared<AtspiAccessibleNode>(app))));
-            }
-        }
-        else if (!strncmp(event->type, "window:deactivate", 16)) {
-            LOGI("window deactivate in app(%s)", pkg);
-            if (instance->mActiveAppMap.count(app)) {
-                LOGI("window deactivated delete app(%s) in map", pkg);
-                instance->mActiveAppMap.erase(app);
-            }
-            else {
-                LOGE("deactivated window's app(%s) is not in map", pkg);
-            }
-
-            if (instance->mXMLDocMap.count(std::string(pkg))) {
-                instance->mXMLDocMap.erase(std::string(pkg));
-            }
-
-            g_object_unref(app);
+        if (!strncmp(event->type, "window:activate", 15)) instance->appendApp(instance, app, pkg);
+        else if (!strncmp(event->type, "window:deactivate", 16)) instance->removeApp(instance, app, pkg);
+
+        // To support focus skipped window
+        if (instance->isTv) {
+            if (!strncmp(event->type, "window:restore", 14) && (!strncmp(name, "volume-app", 10) || !strncmp(name, "tv-viewer", 9)))
+                instance->appendApp(instance, app, pkg);
+            else if (!strncmp(event->type, "window:minimize", 15) && (!strncmp(name, "volume-app", 10) || !strncmp(name, "tv-viewer", 9)))
+                instance->removeApp(instance, app, pkg);
         }
     }
     else