From f7cbef42359a25f29be9b5524749d8fd857ed090 Mon Sep 17 00:00:00 2001 From: Woochan Lee Date: Thu, 11 May 2023 18:18:16 +0900 Subject: [PATCH] libaurum: Support EVENT_WINDOW_RENDER_POST event for application Signed-off-by: Woochan Lee Change-Id: I56fee29e6ae23175cc205e83841e28371eea1ebb --- .../Accessibility/AtspiAccessibleWatcher.h | 1 + libaurum/src/A11yEvent.cc | 2 +- .../Accessibility/AtspiAccessibleWatcher.cc | 47 +++++++++++-------- libaurum/src/Impl/TizenDeviceImpl.cc | 1 + 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/libaurum/inc/Impl/Accessibility/AtspiAccessibleWatcher.h b/libaurum/inc/Impl/Accessibility/AtspiAccessibleWatcher.h index cefbf64..e827d95 100644 --- a/libaurum/inc/Impl/Accessibility/AtspiAccessibleWatcher.h +++ b/libaurum/inc/Impl/Accessibility/AtspiAccessibleWatcher.h @@ -173,6 +173,7 @@ private: void appendApp(AtspiAccessibleWatcher *instance, AtspiAccessible *app, char *pkg); void removeApp(AtspiAccessibleWatcher *instance, AtspiAccessible *app, char *pkg); void setXMLsync(); + void processCallback(char *type, char *name, char *pkg); private: GDBusProxy *mDbusProxy; diff --git a/libaurum/src/A11yEvent.cc b/libaurum/src/A11yEvent.cc index f594804..42053af 100644 --- a/libaurum/src/A11yEvent.cc +++ b/libaurum/src/A11yEvent.cc @@ -51,7 +51,7 @@ static std::unordered_map const table = { {"window:create {"window:lower", A11yEvent::EVENT_WINDOW_LOWER}, {"window:resize", A11yEvent::EVENT_WINDOW_RESIZE}, {"window:move", A11yEvent::EVENT_WINDOW_MOVE}, - {"window:renderpost", A11yEvent::EVENT_WINDOW_RENDER_POST}, + {"window:post-render", A11yEvent::EVENT_WINDOW_RENDER_POST}, {"object:text-changed:insert", A11yEvent::EVENT_TEXT_CHANGED_INSERT}, {"object:text-changed:delete", A11yEvent::EVENT_TEXT_CHANGED_DELETE}, {"object:state-changed:VISIBLE", A11yEvent::EVENT_STATE_CHANGED_VISIBLE}, diff --git a/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc b/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc index 9774412..0eba532 100644 --- a/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc +++ b/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc @@ -42,7 +42,7 @@ GMainLoop *AtspiAccessibleWatcher::mLoop = nullptr; GThread *AtspiAccessibleWatcher::mTimerThread = nullptr; std::chrono::system_clock::time_point AtspiAccessibleWatcher::mStartTime; IdleEventState AtspiAccessibleWatcher::isIdle = IdleEventState::IDLE_LISTEN_READY; -static const unsigned int WAIT_FOR_IDLE_MILLI_SEC = 3000; // 3sec +static const unsigned int WAIT_FOR_IDLE_MILLI_SEC = 1000; // 1sec int AtspiAccessibleWatcher::mRenderCount = 10; static bool iShowingNode(AtspiAccessible *node) @@ -248,6 +248,29 @@ gpointer AtspiAccessibleWatcher::timerThread(gpointer data) return NULL; } +void AtspiAccessibleWatcher::processCallback(char *type, char *name, char *pkg) +{ + mMutex.lock(); + auto a11yEvent = std::make_shared(std::string(type), std::string(name), std::string(pkg)); + mEventQueue.push_back(a11yEvent); + mMutex.unlock(); + + if (this->mHandlers.count(a11yEvent->getEvent())) { + auto &list = this->mHandlers[a11yEvent->getEvent()]; + auto it = list.begin(); + + while (it != list.end()) + { + LOGI("Callback call type %s pkg %s", type, pkg); + auto handler = *it; + bool res = (*handler)(std::string(pkg)); + if (!res) it = list.erase(it); + else ++it; + } + } + +} + void AtspiAccessibleWatcher::onAtspiEvents(AtspiEvent *event, void *watcher) { if (!event->source) @@ -280,6 +303,8 @@ void AtspiAccessibleWatcher::onAtspiEvents(AtspiEvent *event, void *watcher) if (name) free(name); return; } + else if (isIdle == IdleEventState::IDLE_LISTEN_DONE && !strncmp(event->type, "window:post-render", 18)) + return; AtspiAccessible *app = AtspiWrapper::Atspi_accessible_get_application(event->source, NULL); if (name && app) @@ -300,24 +325,7 @@ void AtspiAccessibleWatcher::onAtspiEvents(AtspiEvent *event, void *watcher) else pkg = strdup(""); - mMutex.lock(); - auto a11yEvent = std::make_shared(std::string(event->type), std::string(name), std::string(pkg)); - mEventQueue.push_back(a11yEvent); - mMutex.unlock(); - - if (instance->mHandlers.count(a11yEvent->getEvent())) { - auto &list = instance->mHandlers[a11yEvent->getEvent()]; - auto it = list.begin(); - - while (it != list.end()) - { - LOGI("Callback call type %s pkg %s", event->type, pkg); - auto handler = *it; - bool res = (*handler)(std::string(pkg)); - if (!res) it = list.erase(it); - else ++it; - } - } + instance->processCallback(event->type, name, pkg); if (!strcmp(event->type, "object:state-changed:defunct")) { instance->onObjectDefunct( @@ -431,6 +439,7 @@ bool AtspiAccessibleWatcher::executeAndWaitForEvents(const Runnable *cmd, const if (isIdle == IdleEventState::IDLE_LISTEN_DONE) { isIdle = IdleEventState::IDLE_LISTEN_READY; + processCallback((char *)"window:post-render", (char *)"", (char *)""); return true; } else { diff --git a/libaurum/src/Impl/TizenDeviceImpl.cc b/libaurum/src/Impl/TizenDeviceImpl.cc index a9ef8ad..768b63b 100644 --- a/libaurum/src/Impl/TizenDeviceImpl.cc +++ b/libaurum/src/Impl/TizenDeviceImpl.cc @@ -247,6 +247,7 @@ bool TizenDeviceImpl::pressPower(KeyRequestType type) bool TizenDeviceImpl::pressKeyCode(std::string keycode, KeyRequestType type) { + LOGI("pressKeyCode(%s)", keycode.c_str()); if (type == KeyRequestType::STROKE) return strokeKeyCode(keycode, INTV_SHORTSTROKE); else if (type == KeyRequestType::LONG_STROKE) -- 2.34.1