3 using namespace Dali::Accessibility;
5 std::vector< std::string > Accessible::GetInterfaces()
7 std::vector< std::string > tmp;
8 tmp.push_back( ATSPI_DBUS_INTERFACE_ACCESSIBLE );
9 if( dynamic_cast< Collection* >( this ) )
10 tmp.push_back( ATSPI_DBUS_INTERFACE_COLLECTION );
11 if( dynamic_cast< Text* >( this ) )
12 tmp.push_back( ATSPI_DBUS_INTERFACE_TEXT );
13 if( dynamic_cast< Value* >( this ) )
14 tmp.push_back( ATSPI_DBUS_INTERFACE_VALUE );
15 if( dynamic_cast< Component* >( this ) )
16 tmp.push_back( ATSPI_DBUS_INTERFACE_COMPONENT );
17 if( auto d = dynamic_cast< Action* >( this ) )
19 if( d->GetActionCount() > 0 )
20 tmp.push_back( ATSPI_DBUS_INTERFACE_ACTION );
25 thread_local std::atomic< Bridge* > threadLocalBridge{};
26 std::atomic< Bridge* > allThreads{};
28 Bridge* Bridge::GetCurrentBridge()
30 auto p = threadLocalBridge.load();
32 p = allThreads.load();
36 Accessible::Accessible()
40 Accessible::~Accessible()
42 auto b = bridgeData.lock();
44 b->objects.erase( it );
47 void Bridge::MakePublic( Visibility vis )
50 Bridge* expected = this;
54 case Visibility::hidden:
56 threadLocalBridge.compare_exchange_strong( expected, nullptr );
57 allThreads.compare_exchange_strong( expected, nullptr );
60 case Visibility::thisThreadOnly:
62 res = threadLocalBridge.exchange( this );
66 case Visibility::allThreads:
68 res = allThreads.exchange( this );
75 void Accessible::EmitShowing( bool showing )
77 if( auto b = GetBridgeData() )
79 b->bridge->EmitStateChanged( this, State::Showing, showing ? 1 : 0, 0 );
83 void Accessible::EmitVisible( bool visible )
85 if( auto b = GetBridgeData() )
87 b->bridge->EmitStateChanged( this, State::Visible, visible ? 1 : 0, 0 );
91 void Accessible::EmitHighlighted( bool set )
93 if( auto b = GetBridgeData() )
95 b->bridge->EmitStateChanged( this, State::Highlighted, set ? 1 : 0, 0 );
99 void Accessible::Emit( WindowEvent we, unsigned int detail1 )
101 if( auto b = GetBridgeData() )
103 b->bridge->Emit( this, we, detail1 );
107 std::vector< Accessible* > Accessible::GetChildren()
109 std::vector< Accessible* > tmp( GetChildCount() );
110 for( auto i = 0u; i < tmp.size(); ++i )
112 tmp[i] = GetChildAtIndex( i );
117 std::shared_ptr< Bridge::Data > Accessible::GetBridgeData()
119 auto b = bridgeData.lock();
122 auto p = Bridge::GetCurrentBridge();
130 Address Accessible::GetAddress()
132 auto b = bridgeData.lock();
137 b->bridge->RegisterOnBridge( this );
139 return {b->busName, b->root == this ? "root" : std::to_string( it->first )};
142 void Bridge::RegisterOnBridge( Accessible* obj )
144 assert( !obj->bridgeData.lock() || obj->bridgeData.lock() == data );
145 if( !obj->bridgeData.lock() )
148 auto oid = ++data->objectId;
149 obj->it = data->objects.insert( {oid, obj} ).first;
150 obj->bridgeData = data;
154 bool Accessible::IsProxy()