#include <dali/internal/accessibility/bridge/bridge-collection.h>
#include <dali/internal/accessibility/bridge/bridge-component.h>
#include <dali/internal/accessibility/bridge/bridge-editable-text.h>
+#include <dali/internal/accessibility/bridge/bridge-hypertext.h>
+#include <dali/internal/accessibility/bridge/bridge-hyperlink.h>
#include <dali/internal/accessibility/bridge/bridge-object.h>
#include <dali/internal/accessibility/bridge/bridge-selection.h>
#include <dali/internal/accessibility/bridge/bridge-text.h>
using namespace Dali::Accessibility;
+namespace // unnamed namespace
+{
+
+const int RETRY_INTERVAL = 1000;
+
+} // unnamed namespace
+
/**
* @brief The BridgeImpl class is to implement some Bridge functions.
*/
public BridgeText,
public BridgeEditableText,
public BridgeSelection,
- public BridgeApplication
+ public BridgeApplication,
+ public BridgeHypertext,
+ public BridgeHyperlink
{
DBus::DBusClient mAccessibilityStatusClient;
DBus::DBusClient mRegistryClient;
Dali::Actor mHighlightedActor;
std::function<void(Dali::Actor)> mHighlightClearAction;
Dali::CallbackBase* mIdleCallback = NULL;
+ Dali::Timer mInitializeTimer;
+ Dali::Timer mReadIsEnabledTimer;
+ Dali::Timer mReadScreenReaderEnabledTimer;
public:
BridgeImpl()
}
mData->mCurrentlyHighlightedActor = {};
mData->mHighlightActor = {};
+
+ mDisabledSignal.Emit();
}
mHighlightedActor = {};
mHighlightClearAction = {};
mRegistryClient = {};
mDirectReadingClient = {};
mDirectReadingCallbacks.clear();
+ mApplication.mChildren.clear();
+ mApplication.mWindows.clear();
+ }
+
+ void StopTimer()
+ {
+ if(mInitializeTimer)
+ {
+ mInitializeTimer.Stop();
+ }
+
+ if(mReadIsEnabledTimer)
+ {
+ mReadIsEnabledTimer.Stop();
+ }
+
+ if(mReadScreenReaderEnabledTimer)
+ {
+ mReadScreenReaderEnabledTimer.Stop();
+ }
}
/**
mData->mHighlightActor = {};
}
ForceDown();
+ StopTimer();
if((NULL != mIdleCallback) && Dali::Adaptor::IsAvailable())
{
Dali::Adaptor::Get().RemoveIdle(mIdleCallback);
BridgeEditableText::RegisterInterfaces();
BridgeSelection::RegisterInterfaces();
BridgeApplication::RegisterInterfaces();
+ BridgeHypertext::RegisterInterfaces();
+ BridgeHyperlink::RegisterInterfaces();
RegisterOnBridge(&mApplication);
assert(res);
mApplication.mParent.SetAddress(std::move(std::get<0>(res)));
+
+ mEnabledSignal.Emit();
+
if(mIsShown)
{
- EmitActivate();
+ auto rootLayer = Dali::Stage::GetCurrent().GetRootLayer();
+ auto window = Dali::DevelWindow::Get(rootLayer);
+ EmitActivate(window); // Currently, sends a signal that the default window is activated here.
}
+
return ForceUpResult::JUST_STARTED;
}
/**
- * @brief Sends a signal to dbus that the default window is activated.
+ * @brief Sends a signal to dbus that the window is shown.
*
- * TODO : This is subject to change if/when we implement multi-window support.
- * @see BridgeObject::Emit()
+ * @param[in] window The window to be shown
+ * @see Accessible::EmitShowing() and BridgeObject::EmitStateChanged()
*/
- void EmitActivate()
+ void EmitShown(Dali::Window window)
{
- auto win = mApplication.GetActiveWindow();
- if(win)
+ auto windowAccessible = mApplication.GetWindowAccessible(window);
+ if(windowAccessible)
{
- win->Emit(WindowEvent::ACTIVATE, 0);
+ windowAccessible->EmitShowing(true);
}
}
/**
- * @brief Sends a signal to dbus that the default window is deactivated.
+ * @brief Sends a signal to dbus that the window is hidden.
*
- * TODO : This is subject to change if/when we implement multi-window support.
+ * @param[in] window The window to be hidden
+ * @see Accessible::EmitShowing() and BridgeObject::EmitStateChanged()
+ */
+ void EmitHidden(Dali::Window window)
+ {
+ auto windowAccessible = mApplication.GetWindowAccessible(window);
+ if(windowAccessible)
+ {
+ windowAccessible->EmitShowing(false);
+ }
+ }
+
+ /**
+ * @brief Sends a signal to dbus that the window is activated.
+ *
+ * @param[in] window The window to be activated
* @see BridgeObject::Emit()
*/
- void EmitDeactivate()
+ void EmitActivate(Dali::Window window)
{
- auto win = mApplication.GetActiveWindow();
- if(win)
+ auto windowAccessible = mApplication.GetWindowAccessible(window);
+ if(windowAccessible)
{
- win->Emit(WindowEvent::DEACTIVATE, 0);
+ windowAccessible->Emit(WindowEvent::ACTIVATE, 0);
}
}
/**
- * @copydoc Dali::Accessibility::Bridge::WindowHidden()
+ * @brief Sends a signal to dbus that the window is deactivated.
+ *
+ * @param[in] window The window to be deactivated
+ * @see BridgeObject::Emit()
*/
- void WindowHidden() override
+ void EmitDeactivate(Dali::Window window)
{
- if(mIsShown && IsUp())
+ auto windowAccessible = mApplication.GetWindowAccessible(window);
+ if(windowAccessible)
{
- EmitDeactivate();
+ windowAccessible->Emit(WindowEvent::DEACTIVATE, 0);
}
- mIsShown = false;
}
/**
* @copydoc Dali::Accessibility::Bridge::WindowShown()
*/
- void WindowShown() override
+ void WindowShown(Dali::Window window) override
{
if(!mIsShown && IsUp())
{
- EmitActivate();
+ EmitShown(window);
}
mIsShown = true;
}
- void ReadAndListenProperty()
+ /**
+ * @copydoc Dali::Accessibility::Bridge::WindowHidden()
+ */
+ void WindowHidden(Dali::Window window) override
{
- // read property
- auto enabled = mAccessibilityStatusClient.property<bool>("ScreenReaderEnabled").get();
- if(enabled)
+ if(mIsShown && IsUp())
{
- mIsScreenReaderEnabled = std::get<0>(enabled);
+ EmitHidden(window);
}
+ mIsShown = false;
+ }
- enabled = mAccessibilityStatusClient.property<bool>("IsEnabled").get();
- if(enabled)
+ /**
+ * @copydoc Dali::Accessibility::Bridge::WindowFocused()
+ */
+ void WindowFocused(Dali::Window window) override
+ {
+ if(mIsShown && IsUp())
{
- mIsEnabled = std::get<0>(enabled);
+ EmitActivate(window);
}
+ }
- if(mIsScreenReaderEnabled || mIsEnabled)
+ /**
+ * @copydoc Dali::Accessibility::Bridge::WindowUnfocused()
+ */
+ void WindowUnfocused(Dali::Window window) override
+ {
+ if(mIsShown && IsUp())
{
- ForceUp();
+ EmitDeactivate(window);
}
+ }
- // listen property change
- mAccessibilityStatusClient.addPropertyChangedEvent<bool>("ScreenReaderEnabled", [this](bool res) {
- mIsScreenReaderEnabled = res;
+ bool ReadIsEnabledTimerCallback()
+ {
+ ReadIsEnabledProperty();
+ return false;
+ }
+
+ void ReadIsEnabledProperty()
+ {
+ mAccessibilityStatusClient.property<bool>("IsEnabled").asyncGet([this](DBus::ValueOrError<bool> msg) {
+ if(!msg)
+ {
+ DALI_LOG_ERROR("Get IsEnabled property error: %s\n", msg.getError().message.c_str());
+ if(msg.getError().errorType == DBus::ErrorType::INVALID_REPLY)
+ {
+ if(!mReadIsEnabledTimer)
+ {
+ mReadIsEnabledTimer = Dali::Timer::New(RETRY_INTERVAL);
+ mReadIsEnabledTimer.TickSignal().Connect(this, &BridgeImpl::ReadIsEnabledTimerCallback);
+ }
+ mReadIsEnabledTimer.Start();
+ }
+ return;
+ }
+ mIsEnabled = std::get<0>(msg);
+ if(mIsEnabled)
+ {
+ ForceUp();
+ }
+ });
+ }
+
+ void ListenIsEnabledProperty()
+ {
+ mAccessibilityStatusClient.addPropertyChangedEvent<bool>("IsEnabled", [this](bool res) {
+ mIsEnabled = res;
if(mIsScreenReaderEnabled || mIsEnabled)
{
ForceUp();
ForceDown();
}
});
+ }
- mAccessibilityStatusClient.addPropertyChangedEvent<bool>("IsEnabled", [this](bool res) {
- mIsEnabled = res;
+ bool ReadScreenReaderEnabledTimerCallback()
+ {
+ ReadScreenReaderEnabledProperty();
+ return false;
+ }
+
+ void ReadScreenReaderEnabledProperty()
+ {
+ mAccessibilityStatusClient.property<bool>("ScreenReaderEnabled").asyncGet([this](DBus::ValueOrError<bool> msg) {
+ if(!msg)
+ {
+ DALI_LOG_ERROR("Get ScreenReaderEnabled property error: %s\n", msg.getError().message.c_str());
+ if(msg.getError().errorType == DBus::ErrorType::INVALID_REPLY)
+ {
+ if(!mReadScreenReaderEnabledTimer)
+ {
+ mReadScreenReaderEnabledTimer = Dali::Timer::New(RETRY_INTERVAL);
+ mReadScreenReaderEnabledTimer.TickSignal().Connect(this, &BridgeImpl::ReadScreenReaderEnabledTimerCallback);
+ }
+ mReadScreenReaderEnabledTimer.Start();
+ }
+ return;
+ }
+ mIsScreenReaderEnabled = std::get<0>(msg);
+ if(mIsScreenReaderEnabled)
+ {
+ ForceUp();
+ }
+ });
+ }
+
+ void ListenScreenReaderEnabledProperty()
+ {
+ mAccessibilityStatusClient.addPropertyChangedEvent<bool>("ScreenReaderEnabled", [this](bool res) {
+ mIsScreenReaderEnabled = res;
if(mIsScreenReaderEnabled || mIsEnabled)
{
ForceUp();
});
}
+ void ReadAndListenProperties()
+ {
+ ReadIsEnabledProperty();
+ ListenIsEnabledProperty();
+
+ ReadScreenReaderEnabledProperty();
+ ListenScreenReaderEnabledProperty();
+ }
+
bool InitializeAccessibilityStatusClient()
{
mAccessibilityStatusClient = DBus::DBusClient{A11yDbusName, A11yDbusPath, A11yDbusStatusInterface, DBus::ConnectionType::SESSION};
return true;
}
+ bool InitializeTimerCallback()
+ {
+ if ( InitializeAccessibilityStatusClient() )
+ {
+ ReadAndListenProperties();
+ return false;
+ }
+ return true;
+ }
+
bool OnIdleSignal()
{
if ( InitializeAccessibilityStatusClient() )
{
- ReadAndListenProperty();
+ ReadAndListenProperties();
mIdleCallback = NULL;
return false;
}
- return true;
+ if(!mInitializeTimer)
+ {
+ mInitializeTimer = Dali::Timer::New(RETRY_INTERVAL);
+ mInitializeTimer.TickSignal().Connect(this, &BridgeImpl::InitializeTimerCallback);
+ }
+ mInitializeTimer.Start();
+
+ mIdleCallback = NULL;
+ return false;
}
/**
{
if ( InitializeAccessibilityStatusClient() )
{
- ReadAndListenProperty();
+ ReadAndListenProperties();
return;
}
return;
}
- auto rootLayer = Dali::Stage::GetCurrent().GetRootLayer();
+ auto rootLayer = Dali::Stage::GetCurrent().GetRootLayer(); // A root layer of the default window.
auto window = Dali::DevelWindow::Get(rootLayer);
auto applicationName = Dali::Internal::Adaptor::Adaptor::GetApplicationPackageName();
+ auto accessible = Accessibility::Accessible::Get(rootLayer, true);
+
auto* bridge = Bridge::GetCurrentBridge();
- bridge->AddTopLevelWindow(Dali::Accessibility::Accessible::Get(rootLayer, true));
+ bridge->AddTopLevelWindow(accessible);
bridge->SetApplicationName(applicationName);
bridge->Initialize();
if(window && window.IsVisible())
{
- bridge->WindowShown();
+ bridge->WindowShown(window);
}
}