virtual void StopReading(bool alsoNonDiscardable) = 0;
/**
- * @brief Suppresses reading of screen-reader
- *
- * @param suppress whether to suppress reading of screen-reader
- */
- virtual void SuppressScreenReader(bool suppress) = 0;
-
- /**
* @brief Get screen reader status.
*/
virtual bool GetScreenReaderEnabled() = 0;
**/
static Bridge* GetCurrentBridge();
- /**
- * @brief Blocks auto-initialization of AT-SPI bridge
- *
- * Use this only if your application starts before DBus does, and call it early in main()
- * (before GetCurrentBridge() is called by anyone). GetCurrentBridge() will then return an
- * instance of DummyBridge.
- *
- * When DBus is ready, call EnableAutoInit(). Please note that GetCurrentBridge() may still
- * return an instance of DummyBridge if AT-SPI was disabled at compile time or using an
- * environment variable, or if creating the real bridge failed.
- *
- * @see Dali::Accessibility::DummyBridge
- * @see Dali::Accessibility::Bridge::EnableAutoInit
- */
- static void DisableAutoInit();
-
- /**
- * @brief Re-enables auto-initialization of AT-SPI bridge
- *
- * Normal applications do not have to call this function. GetCurrentBridge() tries to
- * initialize the AT-SPI bridge when it is called for the first time.
- *
- * @see Dali::Accessibility::Bridge::DisableAutoInit
- * @see Dali::Accessibility::Bridge::AddTopLevelWindow
- * @see Dali::Accessibility::Bridge::SetApplicationName
- */
- static void EnableAutoInit();
-
protected:
struct Data
{
std::shared_ptr<Data> data;
friend class Accessible;
- enum class AutoInitState
- {
- DISABLED,
- ENABLED
- };
- inline static AutoInitState autoInitState = AutoInitState::ENABLED;
-
/**
* @brief Registers accessible object to be known in bridge object
*
}
}
-bool Dali::AtspiAccessibility::SuppressScreenReader(bool suppress)
-{
- if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
- {
- bridge->SuppressScreenReader(suppress);
- return true;
- }
-
- return false;
-}
-
void Dali::AtspiAccessibility::Say(const std::string& text, bool discardable, std::function<void(std::string)> callback)
{
if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
DALI_ADAPTOR_API void StopReading(bool alsoNonDiscardable = false);
/**
- * @brief Suppresses reading of screen-reader
- *
- * @param suppress whether to suppress reading of screen-reader
- * @return true on success, false otherwise
- */
-DALI_ADAPTOR_API bool SuppressScreenReader(bool suppress);
-
-/**
* @brief Set ATSPI to be turned On or Off forcibly.
*
* @param[in] turnOn true to turn on, false to turn off.
#define A11yDbusPath "/org/a11y/bus"
#define A11yDbusStatusInterface "org.a11y.Status"
#define AtspiDbusNameRegistry "org.a11y.atspi.Registry"
-#define AtspiDbusPathRegistry "/org/a11y/atspi/registry"
-#define AtspiDbusInterfaceRegistry "org.a11y.atspi.Registry"
#define AtspiDbusPathRoot "/org/a11y/atspi/accessible/root"
#define AtspiDbusInterfaceSocket "org.a11y.atspi.Socket"
#define AtspiPath "/org/a11y/atspi/accessible"
describedByObject};
}
-void BridgeAccessible::SuppressScreenReader(bool suppress)
-{
- suppressScreenReader = suppress;
-}
-
DBus::ValueOrError<bool> BridgeAccessible::DoGesture(Dali::Accessibility::Gesture type, int32_t xBeg, int32_t yBeg, int32_t xEnd, int32_t yEnd, Dali::Accessibility::GestureState state, uint32_t eventTime)
{
return FindSelf()->DoGesture(Dali::Accessibility::GestureInfo{type, xBeg, xEnd, yBeg, yEnd, state, eventTime});
}
DBus::ValueOrError<std::unordered_map<std::string, std::string>> BridgeAccessible::GetAttributes()
{
- std::unordered_map<std::string, std::string> attributes = FindSelf()->GetAttributes();
- if(suppressScreenReader)
- {
- attributes.insert({"suppress-screen-reader", "true"});
- }
-
- return attributes;
+ return FindSelf()->GetAttributes();
}
DBus::ValueOrError<std::vector<std::string>> BridgeAccessible::GetInterfaces()
{
BridgeAccessible();
void RegisterInterfaces();
- bool suppressScreenReader = false;
public:
enum class GetNeighborSearchMode
>;
ReadingMaterialType GetReadingMaterial();
- void SuppressScreenReader(bool) override;
DBus::ValueOrError<bool> DoGesture(Dali::Accessibility::Gesture type, int32_t xBeg, int32_t yBeg, int32_t xEnd, int32_t yEnd, Dali::Accessibility::GestureState state, uint32_t eventTime);
return !filteredEvents.empty();
}
-void BridgeBase::RegisteredEventsUpdate()
-{
- using ReturnType = std::vector<std::tuple<std::string, std::string>>;
- registry.method<DBus::ValueOrError<ReturnType>()>( "GetRegisteredEvents" ).asyncCall([this](DBus::ValueOrError<ReturnType> msg) {
- if(!msg)
- {
- LOG() << "Get registered events failed";
- return;
- }
-
- allowObjectBoundsChangedEvent = false;
-
- ReturnType values = std::get<ReturnType>(msg.getValues());
- for(long unsigned int i = 0; i < values.size(); i++)
- {
- if (!std::get<1>(values[i]).compare("Object:BoundsChanged"))
- {
- allowObjectBoundsChangedEvent = true;
- }
- }
- });
-}
-
BridgeBase::ForceUpResult BridgeBase::ForceUp()
{
if(Bridge::ForceUp() == ForceUpResult::ALREADY_UP)
dbusServer.addInterface(AtspiPath, desc);
}
- registry = {AtspiDbusNameRegistry, AtspiDbusPathRegistry, AtspiDbusInterfaceRegistry, con};
-
- RegisteredEventsUpdate();
-
- registry.addSignal<void(void)>("EventListenerRegistered", [this](void) {
- RegisteredEventsUpdate();
- });
-
- registry.addSignal<void(void)>("EventListenerDeregistered", [this](void) {
- RegisteredEventsUpdate();
- });
-
return ForceUpResult::JUST_STARTED;
}
void BridgeBase::ForceDown()
{
Bridge::ForceDown();
- registry = {};
dbusServer = {};
con = {};
}
private:
void IdSet(int id);
int IdGet();
- void RegisteredEventsUpdate();
using CacheElementType = std::tuple<
Dali::Accessibility::Address,
DBus::DBusServer dbusServer;
DBusWrapper::ConnectionPtr con;
int id = 0;
- DBus::DBusClient registry;
- bool allowObjectBoundsChangedEvent;
};
#endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_BASE_H
// CLASS HEADER
// EXTERNAL INCLUDES
-#include <dali/public-api/actors/layer.h>
-#include <dali/devel-api/common/stage.h>
#include <dali/integration-api/debug.h>
#include <iostream>
#include <unordered_map>
#include <dali/internal/accessibility/bridge/bridge-text.h>
#include <dali/internal/accessibility/bridge/bridge-value.h>
#include <dali/internal/accessibility/bridge/dummy-atspi.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/system/common/environment-variables.h>
#include <dali/devel-api/adaptor-framework/environment-variable.h>
-#include <dali/devel-api/adaptor-framework/window-devel.h>
using namespace Dali::Accessibility;
}
};
-static bool bridgeInitialized;
-
static Bridge* CreateBridge()
{
- bridgeInitialized = true;
-
try
{
/* check environment variable first */
Bridge* Bridge::GetCurrentBridge()
{
- static Bridge* bridge;
-
- if (bridge)
- {
- return bridge;
- }
- else if (autoInitState == AutoInitState::ENABLED)
- {
- bridge = CreateBridge();
-
- /* check environment variable for suppressing screen-reader */
- const char *envSuppressScreenReader = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_SUPPRESS_SCREEN_READER);
- if (envSuppressScreenReader && std::atoi(envSuppressScreenReader) != 0)
- {
- bridge->SuppressScreenReader(true);
- }
-
- return bridge;
- }
-
- return Dali::Accessibility::DummyBridge::GetInstance();
-}
-
-void Bridge::DisableAutoInit()
-{
- if (bridgeInitialized)
- {
- DALI_LOG_ERROR("Bridge::DisableAutoInit() called after bridge auto-initialization");
- }
-
- autoInitState = AutoInitState::DISABLED;
-}
-
-void Bridge::EnableAutoInit()
-{
- autoInitState = AutoInitState::ENABLED;
-
- if (bridgeInitialized)
- {
- return;
- }
-
- auto rootLayer = Dali::Stage::GetCurrent().GetRootLayer();
- auto window = Dali::DevelWindow::Get(rootLayer);
- auto applicationName = Dali::Internal::Adaptor::Adaptor::GetApplicationPackageName();
-
- auto* bridge = Bridge::GetCurrentBridge();
- bridge->AddTopLevelWindow(Dali::Accessibility::Accessible::Get(rootLayer, true));
- bridge->SetApplicationName(applicationName);
- bridge->Initialize();
-
- if(window && window.IsVisible())
- {
- bridge->ApplicationShown();
- }
+ static Bridge* bridge = CreateBridge();
+ return bridge;
}
void BridgeObject::EmitBoundsChanged(Accessible* obj, Dali::Rect<> rect)
{
- if(!allowObjectBoundsChangedEvent) return;
-
auto addr = obj->GetAddress();
const auto prefixPath = "/org/a11y/atspi/accessible/";
const auto nullPath = "/org/a11y/atspi/null";
return Accessibility::DummyBridge::GetInstance();
}
-void Accessibility::Bridge::DisableAutoInit()
-{
-}
-
-void Accessibility::Bridge::EnableAutoInit()
-{
-}
-
void Accessibility::Accessible::EmitStateChanged(Accessibility::State state, int newValue1, int newValue2)
{
}
{
}
- void SuppressScreenReader(bool suppress) override
- {
- }
-
bool GetScreenReaderEnabled() override
{
return false;
#define DALI_ENV_DISABLE_ATSPI "DALI_DISABLE_ATSPI"
-#define DALI_ENV_SUPPRESS_SCREEN_READER "DALI_SUPPRESS_SCREEN_READER"
-
} // namespace Adaptor
} // namespace Internal