[Tizen][AT-SPI] Track application lifecycle 96/309096/1 accepted/tizen/7.0/unified/20240411.100459
authorArtur Świgoń <a.swigon@samsung.com>
Thu, 4 Apr 2024 11:53:58 +0000 (13:53 +0200)
committerArtur Świgoń <a.swigon@samsung.com>
Thu, 4 Apr 2024 13:29:49 +0000 (15:29 +0200)
This allows to postpone the initalization of most infrastructure until the
application is acutally running from the UX point of view.

Change-Id: I451b70fe90568f0df66f75b9b0a889b75849f0c4

dali/devel-api/adaptor-framework/accessibility-bridge.h
dali/internal/accessibility/bridge/bridge-impl.cpp
dali/internal/accessibility/bridge/dummy/dummy-atspi.h
dali/internal/adaptor/common/application-impl.cpp

index 58a98fe..2ad9d38 100644 (file)
@@ -195,6 +195,16 @@ struct DALI_ADAPTOR_API Bridge
   virtual void WindowUnfocused(Window window) = 0;
 
   /**
+   * @brief Tells the bridge that the application is not running
+   */
+  virtual void ApplicationPaused() = 0;
+
+  /**
+   * @brief Tells the bridge that the application is running
+    */
+  virtual void ApplicationResumed() = 0;
+
+  /**
    * @brief Initializes accessibility bus.
    */
   virtual void Initialize() = 0;
index 46c30c7..00c60a6 100644 (file)
@@ -82,6 +82,7 @@ class BridgeImpl : public virtual BridgeBase,
   DBus::DBusClient                                              mDirectReadingClient;
   bool                                                          mIsScreenReaderEnabled = false;
   bool                                                          mIsEnabled             = false;
+  bool                                                          mIsApplicationRunning  = false;
   std::unordered_map<int32_t, std::function<void(std::string)>> mDirectReadingCallbacks;
   Dali::Actor                                                   mHighlightedActor;
   std::function<void(Dali::Actor)>                              mHighlightClearAction;
@@ -495,6 +496,24 @@ public:
   }
 
   /**
+   * @copydoc Dali::Accessibility::Bridge::ApplicationPaused()
+   */
+  void ApplicationPaused() override
+  {
+    mIsApplicationRunning = false;
+    SwitchBridge();
+  }
+
+  /**
+   * @copydoc Dali::Accessibility::Bridge::ApplicationResumed()
+   */
+  void ApplicationResumed() override
+  {
+    mIsApplicationRunning = true;
+    SwitchBridge();
+  }
+
+  /**
    * @copydoc Dali::Accessibility::Bridge::SuppressScreenReader()
    */
   void SuppressScreenReader(bool suppress) override
@@ -509,7 +528,9 @@ public:
 
   void SwitchBridge()
   {
-    if((!mIsScreenReaderSuppressed && mIsScreenReaderEnabled) || mIsEnabled)
+    bool isScreenReaderEnabled = mIsScreenReaderEnabled && !mIsScreenReaderSuppressed;
+
+    if((isScreenReaderEnabled || mIsEnabled) && mIsApplicationRunning)
     {
       ForceUp();
     }
index 195fa6e..c56e29a 100644 (file)
@@ -97,6 +97,14 @@ struct DummyBridge : Dali::Accessibility::Bridge
   {
   }
 
+  void ApplicationPaused() override
+  {
+  }
+
+  void ApplicationResumed() override
+  {
+  }
+
   void Initialize() override
   {
   }
index 0a8e122..d3e8bd3 100644 (file)
@@ -333,6 +333,8 @@ void Application::OnTerminate()
 
 void Application::OnPause()
 {
+  Accessibility::Bridge::GetCurrentBridge()->ApplicationPaused();
+
   // A DALi app should handle Pause/Resume events.
   // DALi just delivers the framework Pause event to the application, but not actually pause DALi core.
   // Pausing DALi core only occurs on the Window Hidden framework event
@@ -342,6 +344,8 @@ void Application::OnPause()
 
 void Application::OnResume()
 {
+  Accessibility::Bridge::GetCurrentBridge()->ApplicationResumed();
+
   // Emit the signal first so the application can queue any messages before we do an update/render
   // This ensures we do not just redraw the last frame before pausing if that's not required
   Dali::Application application(this);