2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/accessibility/tizen-wayland/atspi/bridge-component.h>
24 #define DBUS_INTERFACE_PROPERTIES "org.freedesktop.DBus.Properties"
26 using namespace Dali::Accessibility;
28 BridgeComponent::BridgeComponent()
32 void BridgeComponent::RegisterInterfaces()
34 DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceComponent};
35 AddFunctionToInterface( desc, "Contains", &BridgeComponent::Contains );
36 AddFunctionToInterface( desc, "GetAccessibleAtPoint", &BridgeComponent::GetAccessibleAtPoint );
37 AddFunctionToInterface( desc, "GetExtents", &BridgeComponent::GetExtents );
38 AddFunctionToInterface( desc, "GetPosition", &BridgeComponent::GetPosition );
39 AddFunctionToInterface( desc, "GetSize", &BridgeComponent::GetSize );
40 AddFunctionToInterface( desc, "GetLayer", &BridgeComponent::GetLayer );
41 AddFunctionToInterface( desc, "GetAlpha", &BridgeComponent::GetAlpha );
42 AddFunctionToInterface( desc, "GetMDIZOrder", &BridgeComponent::GetMdiZOrder );
43 AddFunctionToInterface( desc, "GrabHighlight", &BridgeComponent::GrabHighlight );
44 AddFunctionToInterface( desc, "GrabFocus", &BridgeComponent::GrabFocus );
45 AddFunctionToInterface( desc, "ClearHighlight", &BridgeComponent::ClearHighlight );
46 dbusServer.addInterface( "/", desc, true );
49 Component* BridgeComponent::FindSelf() const
51 auto s = BridgeBase::FindSelf();
53 auto s2 = dynamic_cast< Component* >( s );
55 throw std::domain_error{"object " + s->GetAddress().ToString() + " doesn't have Component interface"};
59 DBus::ValueOrError< bool > BridgeComponent::Contains( int32_t x, int32_t y, uint32_t coordType )
61 return FindSelf()->Contains( {x, y}, static_cast< CoordType >( coordType ) );
63 DBus::ValueOrError< Accessible* > BridgeComponent::GetAccessibleAtPoint( int32_t x, int32_t y, uint32_t coordType )
65 return FindSelf()->GetAccessibleAtPoint( {x, y}, static_cast< CoordType >( coordType ) );
67 DBus::ValueOrError< std::tuple< int32_t, int32_t, int32_t, int32_t > > BridgeComponent::GetExtents( uint32_t coordType )
69 auto p = FindSelf()->GetExtents( static_cast< CoordType >( coordType ) );
70 return std::tuple< int32_t, int32_t, int32_t, int32_t >{p.x, p.y, p.width, p.height};
72 DBus::ValueOrError< int32_t, int32_t > BridgeComponent::GetPosition( uint32_t coordType )
74 auto p = FindSelf()->GetExtents( static_cast< CoordType >( coordType ) );
75 return { static_cast<int32_t>(p.x), static_cast<int32_t>(p.y) };
77 DBus::ValueOrError< int32_t, int32_t > BridgeComponent::GetSize( uint32_t coordType )
79 auto p = FindSelf()->GetExtents( static_cast< CoordType >( coordType ) );
80 return { static_cast<int32_t>(p.width), static_cast<int32_t>(p.height) };
82 DBus::ValueOrError< ComponentLayer > BridgeComponent::GetLayer()
84 return FindSelf()->GetLayer();
86 DBus::ValueOrError< double > BridgeComponent::GetAlpha()
88 return FindSelf()->GetAlpha();
90 DBus::ValueOrError< bool > BridgeComponent::GrabFocus()
92 return FindSelf()->GrabFocus();
94 DBus::ValueOrError< bool > BridgeComponent::GrabHighlight()
96 return FindSelf()->GrabHighlight();
98 DBus::ValueOrError< bool > BridgeComponent::ClearHighlight()
100 return FindSelf()->ClearHighlight();
102 DBus::ValueOrError< int16_t > BridgeComponent::GetMdiZOrder()
104 return FindSelf()->GetMdiZOrder();