libaurum: Update accessibility event handling to use shared pointers 18/322718/2
authorHosang Kim <hosang12.kim@samsung.com>
Thu, 10 Apr 2025 05:37:11 +0000 (14:37 +0900)
committerHosang Kim <hosang12.kim@samsung.com>
Fri, 18 Apr 2025 02:28:06 +0000 (11:28 +0900)
Changed the EventHandler typedef to use std::function with a shared pointer to AccessibleNode instead of a string package name.
Updated the A11yEventHandler operator() to accept a shared pointer to AccessibleNode instead of a string package name.
Updated the AtspiAccessibleWatcher processCallback method to accept an optional AtspiAccessible pointer and create a shared pointer to AtspiAccessibleNode when available.

Change-Id: I4911407a203a73c3c65d80fbc3843ac8762d9903

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

index 7687308624a3613a5d1dea542b03f56a88a852bf..87e83b88f86dc15377818dade32b37829741c56a 100644 (file)
 #define _A11Y_EVENT_HANDLER_H_
 
 #include "A11yEvent.h"
+#include <functional>
 
 namespace Aurum {
 
-typedef bool (*EventHandler)(void *data, const A11yEvent type, std::string pkg);
+using EventHandler = std::function<bool(void *, const A11yEvent, std::shared_ptr<AccessibleNode>)>;
 
 /**
  * @class A11yEventHandler
@@ -62,7 +63,7 @@ public:
     *
     * @since_tizen 7.5
     */
-    bool operator() (std::string pkg);
+    bool operator() (std::shared_ptr<AccessibleNode> node);
 
 private:
     A11yEvent mType;
index 56706a2509eb20b01c3d522f1adf065884f10ae4..32f26c42fa6479f9d9e620ccd7ac2513eab49715 100644 (file)
@@ -163,7 +163,7 @@ private:
     void appendApp(AtspiAccessible *app, char *pkg, int pid);
     void removeApp(char *pkg, int pid);
     void setXMLsync();
-    void processCallback(char *type, char *name, char *pkg);
+    void processCallback(char *type, char *name, char *pkg, AtspiAccessible *node = nullptr);
     void processWindowEvent(AtspiEvent *event);
     void processPostRender();
 
index b0cb63dbc626f58a1267aadb4f85d52f4cf637ac..9bf1a8fbd4f1a22c75e8ab12b53ec1665fcce6c1 100644 (file)
@@ -27,8 +27,7 @@ A11yEvent A11yEventHandler::getType() const
 {
     return mType;
 }
-bool A11yEventHandler::operator() (std::string pkg)
+bool A11yEventHandler::operator() (std::shared_ptr<AccessibleNode> node)
 {
-    return mCb(mData, mType, pkg);
+    return mCb(mData, mType, node);
 }
-
index 3579329b6ca3e2544612a1265d56f91703a38c91..72b5499fc94f537e0d3ead7047fac1a20addabe4 100644 (file)
@@ -298,7 +298,7 @@ gpointer AtspiAccessibleWatcher::timerThread(gpointer data)
     return NULL;
 }
 
-void AtspiAccessibleWatcher::processCallback(char *type, char *name, char *pkg)
+void AtspiAccessibleWatcher::processCallback(char *type, char *name, char *pkg, AtspiAccessible *node)
 {
     mMutex.lock();
     auto a11yEvent = std::make_shared<A11yEventInfo>(std::string(type), std::string(name), std::string(pkg));
@@ -313,7 +313,8 @@ void AtspiAccessibleWatcher::processCallback(char *type, char *name, char *pkg)
         {
             LOGI("Callback call type %s pkg %s", type, pkg);
             auto handler = *it;
-            bool res = (*handler)(std::string(pkg));
+            if (node) g_object_ref(node);
+            bool res = (*handler)(std::make_shared<AtspiAccessibleNode>(node));
             if (!res) it = list.erase(it);
             else ++it;
         }
@@ -420,7 +421,7 @@ void AtspiAccessibleWatcher::onAtspiEvents(AtspiEvent *event, void *watcher)
         char *name = NULL, *pkg = NULL;
         name = AtspiWrapper::Atspi_accessible_get_name(event->source, NULL);
         pkg = AtspiWrapper::Atspi_accessible_get_name(event->sender, NULL);
-        instance->processCallback(event->type, name, pkg);
+        instance->processCallback(event->type, name, pkg, event->source);
         if (name) g_free(name);
         if (pkg) g_free(pkg);
     }