Fix the failure to emit Accessibility::WindowEvent::CREATE event. 78/298478/3
authorWonsik Jung <sidein@samsung.com>
Thu, 7 Sep 2023 11:20:56 +0000 (20:20 +0900)
committerWonsik Jung <sidein@samsung.com>
Wed, 13 Sep 2023 11:23:17 +0000 (20:23 +0900)
Fixing the failure to emit Accessibility::WindowEvent::CREATE event.
This event can be sent the at-spi dbus should be enabled.
So, This event can be sent when accessibility is enabled.

Change-Id: I9ec22fee5d7db958c583971e6f0e48bda72f3252

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/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-impl.h

index 22dbb5e..38ccd70 100644 (file)
@@ -160,6 +160,13 @@ struct DALI_ADAPTOR_API Bridge
   virtual Accessible* FindByPath(const std::string& path) const = 0;
 
   /**
+   * @brief Notifies accessibility dbus that window has just been created.
+   *
+   * @param[in] window The window to be created
+   */
+  virtual void WindowCreated(Window window) = 0;
+
+  /**
    * @brief Notifies accessibility dbus that window has just been shown.
    *
    * @param[in] window The window to be shown
index f76a0ea..2ebc048 100644 (file)
@@ -368,6 +368,21 @@ public:
   }
 
   /**
+   * @brief Sends a signal to dbus that the window is created.
+   *
+   * @param[in] window The window to be created
+   * @see BridgeObject::Emit()
+   */
+  void EmitCreated(Dali::Window window)
+  {
+    auto windowAccessible = mApplication.GetWindowAccessible(window);
+    if(windowAccessible)
+    {
+      windowAccessible->Emit(WindowEvent::CREATE, 0);
+    }
+  }
+
+  /**
    * @brief Sends a signal to dbus that the window is shown.
    *
    * @param[in] window The window to be shown
@@ -474,6 +489,17 @@ public:
   }
 
   /**
+   * @copydoc Dali::Accessibility::Bridge::WindowCreated()
+   */
+  void WindowCreated(Dali::Window window) override
+  {
+    if(IsUp())
+    {
+      EmitCreated(window);
+    }
+  }
+
+  /**
    * @copydoc Dali::Accessibility::Bridge::WindowShown()
    */
   void WindowShown(Dali::Window window) override
index 447ba4d..9e0035a 100644 (file)
@@ -77,6 +77,10 @@ struct DummyBridge : Dali::Accessibility::Bridge
     return nullptr;
   }
 
+  void WindowCreated(Window window) override
+  {
+  }
+
   void WindowShown(Window window) override
   {
   }
index 99fab49..dc0c18d 100644 (file)
@@ -107,7 +107,8 @@ Window::Window()
   mWindowRotationAcknowledgement(false),
   mFocused(false),
   mIsWindowRotating(false),
-  mIsEnabledUserGeometry(false)
+  mIsEnabledUserGeometry(false),
+  mIsEmittedWindowCreatedEvent(false)
 {
 }
 
@@ -229,20 +230,19 @@ void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
 
   // Add Window to bridge for ATSPI
   auto bridge = Accessibility::Bridge::GetCurrentBridge();
-  if(bridge->IsUp())
-  {
-    auto rootLayer  = mScene.GetRootLayer();
-    auto accessible = Accessibility::Accessible::Get(rootLayer);
-    bridge->AddTopLevelWindow(accessible);
-
-    // Emit Window create event
-    // Create and Destory signal only emit in multi-window environment, so it does not emit on default layer.
-    bridge->Emit(accessible, Accessibility::WindowEvent::CREATE);
-  }
 
   bridge->EnabledSignal().Connect(this, &Window::OnAccessibilityEnabled);
   bridge->DisabledSignal().Connect(this, &Window::OnAccessibilityDisabled);
 
+  if(bridge->IsUp())
+  {
+    OnAccessibilityEnabled();
+  }
+  else
+  {
+    OnAccessibilityDisabled();
+  }
+
   // If you call the 'Show' before creating the adaptor, the application cannot know the app resource id.
   // The show must be called after the adaptor is initialized.
   Show();
@@ -1168,16 +1168,26 @@ void Window::OnAccessibilityEnabled()
   auto accessible = Accessibility::Accessible::Get(rootLayer);
   bridge->AddTopLevelWindow(accessible);
 
+  DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is enabled\n", this, mNativeWindowId);
+
+  Dali::Window handle(this);
+  if(!mIsEmittedWindowCreatedEvent)
+  {
+    DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Created Event\n", this, mNativeWindowId);
+    bridge->WindowCreated(handle);
+    mIsEmittedWindowCreatedEvent = true;
+  }
+
   if(!mVisible || mIconified)
   {
     return;
   }
 
-  Dali::Window handle(this);
   bridge->WindowShown(handle);
 
   if(mFocused)
   {
+    DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Emit Accessbility Window Focused Event\n", this, mNativeWindowId);
     bridge->WindowFocused(handle);
   }
 }
@@ -1188,6 +1198,7 @@ void Window::OnAccessibilityDisabled()
   auto rootLayer  = mScene.GetRootLayer();
   auto accessible = Accessibility::Accessible::Get(rootLayer);
   bridge->RemoveTopLevelWindow(accessible);
+  DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Accessibility is disabled\n", this, mNativeWindowId);
 }
 
 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
index 6bee6d3..e566c17 100644 (file)
@@ -964,6 +964,7 @@ private:
   bool mFocused : 1;
   bool mIsWindowRotating : 1;      ///< The window rotating flag.
   bool mIsEnabledUserGeometry : 1; ///< The user geometry enable flag.
+  bool mIsEmittedWindowCreatedEvent : 1; ///< The Window Created Event emit flag for accessibility.
 };
 
 } // namespace Adaptor