#include <dali/internal/accessibility/bridge/bridge-base.h>
// EXTERNAL INCLUDES
+#include <dali/devel-api/common/stage.h>
#include <atomic>
#include <cstdlib>
#include <memory>
static Dali::Timer tickTimer;
-BridgeBase::~BridgeBase()
+BridgeBase::BridgeBase()
{
}
-BridgeBase::BridgeBase()
+BridgeBase::~BridgeBase()
{
+ mApplication.mChildren.clear();
}
-void BridgeBase::addFilteredEvent(FilteredEvents kind, Dali::Accessibility::Accessible* obj, float delay, std::function<void()> functor)
+void BridgeBase::AddFilteredEvent(FilteredEvents kind, Dali::Accessibility::Accessible* obj, float delay, std::function<void()> functor)
{
if(delay < 0)
{
delay = 0;
}
- auto it = filteredEvents.insert({{kind, obj}, {static_cast<unsigned int>(delay * 10), {}}});
+ auto it = mFilteredEvents.insert({{kind, obj}, {static_cast<unsigned int>(delay * 10), {}}});
if(it.second)
{
functor();
if(!tickTimer)
{
tickTimer = Dali::Timer::New(100);
- tickTimer.TickSignal().Connect(this, &BridgeBase::tickFilteredEvents);
+ tickTimer.TickSignal().Connect(this, &BridgeBase::TickFilteredEvents);
}
}
-bool BridgeBase::tickFilteredEvents()
+bool BridgeBase::TickFilteredEvents()
{
- for(auto it = filteredEvents.begin(); it != filteredEvents.end();)
+ for(auto it = mFilteredEvents.begin(); it != mFilteredEvents.end();)
{
if(it->second.first)
{
}
else
{
- it = filteredEvents.erase(it);
+ it = mFilteredEvents.erase(it);
continue;
}
}
++it;
}
- return !filteredEvents.empty();
+ return !mFilteredEvents.empty();
}
-void BridgeBase::RegisteredEventsUpdate()
+void BridgeBase::UpdateRegisteredEvents()
{
using ReturnType = std::vector<std::tuple<std::string, std::string>>;
- registry.method<DBus::ValueOrError<ReturnType>()>( "GetRegisteredEvents" ).asyncCall([this](DBus::ValueOrError<ReturnType> msg) {
+ mRegistry.method<DBus::ValueOrError<ReturnType>()>("GetRegisteredEvents").asyncCall([this](DBus::ValueOrError<ReturnType> msg) {
if(!msg)
{
LOG() << "Get registered events failed";
return;
}
- allowObjectBoundsChangedEvent = false;
+ IsBoundsChangedEventAllowed = 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"))
+ if(!std::get<1>(values[i]).compare("Object:BoundsChanged"))
{
- allowObjectBoundsChangedEvent = true;
+ IsBoundsChangedEventAllowed = true;
}
}
});
throw std::domain_error{std::string("failed at call '") + dbusLocators::atspi::GET_ADDRESS + "': " + addr.getError().message};
}
- con = DBusWrapper::Installed()->eldbus_address_connection_get_impl(std::get<0>(addr));
- data->busName = DBus::getConnectionName(con);
- dbusServer = {con};
+ mConnectionPtr = DBusWrapper::Installed()->eldbus_address_connection_get_impl(std::get<0>(addr));
+ mData->mBusName = DBus::getConnectionName(mConnectionPtr);
+ mDbusServer = {mConnectionPtr};
{
- DBus::DBusInterfaceDescription desc{"org.a11y.atspi.Cache"};
+ DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceCache};
AddFunctionToInterface(desc, "GetItems", &BridgeBase::GetItems);
- dbusServer.addInterface("/org/a11y/atspi/cache", desc);
+ mDbusServer.addInterface(AtspiDbusPathCache, desc);
}
{
- DBus::DBusInterfaceDescription desc{"org.a11y.atspi.Application"};
- AddGetSetPropertyToInterface(desc, "Id", &BridgeBase::IdGet, &BridgeBase::IdSet);
- dbusServer.addInterface(AtspiPath, desc);
+ DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceApplication};
+ AddGetSetPropertyToInterface(desc, "Id", &BridgeBase::GetId, &BridgeBase::SetId);
+ mDbusServer.addInterface(AtspiPath, desc);
}
- registry = {AtspiDbusNameRegistry, AtspiDbusPathRegistry, AtspiDbusInterfaceRegistry, con};
+ mRegistry = {AtspiDbusNameRegistry, AtspiDbusPathRegistry, AtspiDbusInterfaceRegistry, mConnectionPtr};
- RegisteredEventsUpdate();
+ UpdateRegisteredEvents();
- registry.addSignal<void(void)>("EventListenerRegistered", [this](void) {
- RegisteredEventsUpdate();
+ mRegistry.addSignal<void(void)>("EventListenerRegistered", [this](void) {
+ UpdateRegisteredEvents();
});
- registry.addSignal<void(void)>("EventListenerDeregistered", [this](void) {
- RegisteredEventsUpdate();
+ mRegistry.addSignal<void(void)>("EventListenerDeregistered", [this](void) {
+ UpdateRegisteredEvents();
});
return ForceUpResult::JUST_STARTED;
void BridgeBase::ForceDown()
{
Bridge::ForceDown();
- registry = {};
- dbusServer = {};
- con = {};
+ mRegistry = {};
+ mDbusServer = {};
+ mConnectionPtr = {};
}
const std::string& BridgeBase::GetBusName() const
{
static std::string empty;
- return data ? data->busName : empty;
+ return mData ? mData->mBusName : empty;
}
Accessible* BridgeBase::FindByPath(const std::string& name) const
}
}
-void BridgeBase::AddPopup(Accessible* obj)
+void BridgeBase::AddPopup(Accessible* object)
{
- if(std::find(popups.begin(), popups.end(), obj) != popups.end())
+ if(std::find(mPopups.begin(), mPopups.end(), object) != mPopups.end())
{
return;
}
- popups.push_back(obj);
+ mPopups.push_back(object);
if(IsUp())
{
- obj->Emit(WindowEvent::ACTIVATE, 0);
+ object->Emit(WindowEvent::ACTIVATE, 0);
}
}
-void BridgeBase::RemovePopup(Accessible* obj)
+void BridgeBase::RemovePopup(Accessible* object)
{
- auto it = std::find(popups.begin(), popups.end(), obj);
- if(it == popups.end())
+ auto it = std::find(mPopups.begin(), mPopups.end(), object);
+ if(it == mPopups.end())
{
return;
}
- popups.erase(it);
+ mPopups.erase(it);
+
if(IsUp())
{
- obj->Emit(WindowEvent::DEACTIVATE, 0);
- if(popups.empty())
+ object->Emit(WindowEvent::DEACTIVATE, 0);
+ if(mPopups.empty())
{
- application.children.back()->Emit(WindowEvent::ACTIVATE, 0);
+ mApplication.mChildren.back()->Emit(WindowEvent::ACTIVATE, 0);
}
else
{
- popups.back()->Emit(WindowEvent::ACTIVATE, 0);
+ mPopups.back()->Emit(WindowEvent::ACTIVATE, 0);
}
}
}
-void BridgeBase::AddTopLevelWindow(Accessible* root)
+void BridgeBase::AddTopLevelWindow(Accessible* windowAccessible)
{
- application.children.push_back(root);
- SetIsOnRootLevel(root);
+ if(windowAccessible->GetInternalActor() == nullptr)
+ {
+ return;
+ }
+
+ // Prevent adding the default window twice.
+ if(!mApplication.mChildren.empty() &&
+ mApplication.mChildren[0]->GetInternalActor() == windowAccessible->GetInternalActor())
+ {
+ return;
+ }
+
+ // Adds Window to a list of Windows.
+ mApplication.mChildren.push_back(windowAccessible);
+ SetIsOnRootLevel(windowAccessible);
}
-void BridgeBase::RemoveTopLevelWindow(Accessible* root)
+void BridgeBase::RemoveTopLevelWindow(Accessible* windowAccessible)
{
- for(auto i = 0u; i < application.children.size(); ++i)
+ for(auto i = 0u; i < mApplication.mChildren.size(); ++i)
{
- if(application.children[i] == root)
+ if(mApplication.mChildren[i] == windowAccessible)
{
- application.children.erase(application.children.begin() + i);
+ mApplication.mChildren.erase(mApplication.mChildren.begin() + i);
break;
}
}
{
if(path == "root")
{
- return &application;
+ return &mApplication;
}
- void* p;
+
+ void* accessible;
std::istringstream tmp{path};
- if(!(tmp >> p))
+ if(!(tmp >> accessible))
{
throw std::domain_error{"invalid path '" + path + "'"};
}
- auto it = data->knownObjects.find(static_cast<Accessible*>(p));
- if(it == data->knownObjects.end())
+
+ auto it = mData->mKnownObjects.find(static_cast<Accessible*>(accessible));
+ if(it == mData->mKnownObjects.end())
{
throw std::domain_error{"unknown object '" + path + "'"};
}
- return static_cast<Accessible*>(p);
+
+ return static_cast<Accessible*>(accessible);
}
Accessible* BridgeBase::Find(const Address& ptr) const
{
- assert(ptr.GetBus() == data->busName);
+ assert(ptr.GetBus() == mData->mBusName);
return Find(ptr.GetPath());
}
Accessible* BridgeBase::FindSelf() const
{
- auto pth = DBus::DBusServer::getCurrentObjectPath();
+ auto path = DBus::DBusServer::getCurrentObjectPath();
auto size = strlen(AtspiPath);
- if(pth.size() <= size)
+ if(path.size() <= size)
{
- throw std::domain_error{"invalid path '" + pth + "'"};
+ throw std::domain_error{"invalid path '" + path + "'"};
}
- if(pth.substr(0, size) != AtspiPath)
+ if(path.substr(0, size) != AtspiPath)
{
- throw std::domain_error{"invalid path '" + pth + "'"};
+ throw std::domain_error{"invalid path '" + path + "'"};
}
- if(pth[size] != '/')
+ if(path[size] != '/')
{
- throw std::domain_error{"invalid path '" + pth + "'"};
+ throw std::domain_error{"invalid path '" + path + "'"};
}
- return Find(StripPrefix(pth));
+ return Find(StripPrefix(path));
}
-void BridgeBase::IdSet(int id)
+void BridgeBase::SetId(int id)
{
- this->id = id;
+ this->mId = id;
}
-int BridgeBase::IdGet()
+int BridgeBase::GetId()
{
- return this->id;
+ return this->mId;
}
-auto BridgeBase::GetItems() -> DBus::ValueOrError<std::vector<CacheElementType> >
+auto BridgeBase::GetItems() -> DBus::ValueOrError<std::vector<CacheElementType>>
{
- auto root = &application;
+ auto root = &mApplication;
std::vector<CacheElementType> res;
return {};
}
- auto root = &application;
+ auto root = &mApplication;
auto parent = item->GetParent();
std::vector<Address> children;