2 * Copyright (c) 2021 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/bridge/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 // The second arguments below are the names (or signatures) of DBus methods.
35 // Screen Reader will call the methods with the exact names as specified in the AT-SPI Component interface:
36 // https://gitlab.gnome.org/GNOME/at-spi2-core/-/blob/master/xml/Component.xml
38 DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceComponent};
39 AddFunctionToInterface(desc, "Contains", &BridgeComponent::IsAccessibleContainedAtPoint);
40 AddFunctionToInterface(desc, "GetAccessibleAtPoint", &BridgeComponent::GetAccessibleAtPoint);
41 AddFunctionToInterface(desc, "GetExtents", &BridgeComponent::GetExtents);
42 AddFunctionToInterface(desc, "GetPosition", &BridgeComponent::GetPosition);
43 AddFunctionToInterface(desc, "GetSize", &BridgeComponent::GetSize);
44 AddFunctionToInterface(desc, "GetLayer", &BridgeComponent::GetLayer);
45 AddFunctionToInterface(desc, "GetAlpha", &BridgeComponent::GetAlpha);
46 AddFunctionToInterface(desc, "GetMDIZOrder", &BridgeComponent::GetMdiZOrder);
47 AddFunctionToInterface(desc, "GrabHighlight", &BridgeComponent::GrabHighlight);
48 AddFunctionToInterface(desc, "GrabFocus", &BridgeComponent::GrabFocus);
49 AddFunctionToInterface(desc, "ClearHighlight", &BridgeComponent::ClearHighlight);
50 dbusServer.addInterface("/", desc, true);
53 Component* BridgeComponent::FindSelf() const
55 auto s = BridgeBase::FindSelf();
57 auto s2 = dynamic_cast<Component*>(s);
59 throw std::domain_error{"object " + s->GetAddress().ToString() + " doesn't have Component interface"};
63 DBus::ValueOrError<bool> BridgeComponent::IsAccessibleContainedAtPoint(int32_t x, int32_t y, uint32_t coordType)
65 return FindSelf()->IsAccessibleContainedAtPoint({x, y}, static_cast<CoordinateType>(coordType));
67 DBus::ValueOrError<Accessible*> BridgeComponent::GetAccessibleAtPoint(int32_t x, int32_t y, uint32_t coordType)
69 return FindSelf()->GetAccessibleAtPoint({x, y}, static_cast<CoordinateType>(coordType));
71 DBus::ValueOrError<std::tuple<int32_t, int32_t, int32_t, int32_t> > BridgeComponent::GetExtents(uint32_t coordType)
73 auto p = FindSelf()->GetExtents(static_cast<CoordinateType>(coordType));
74 return std::tuple<int32_t, int32_t, int32_t, int32_t>{p.x, p.y, p.width, p.height};
76 DBus::ValueOrError<int32_t, int32_t> BridgeComponent::GetPosition(uint32_t coordType)
78 auto p = FindSelf()->GetExtents(static_cast<CoordinateType>(coordType));
79 return {static_cast<int32_t>(p.x), static_cast<int32_t>(p.y)};
81 DBus::ValueOrError<int32_t, int32_t> BridgeComponent::GetSize(uint32_t coordType)
83 auto p = FindSelf()->GetExtents(static_cast<CoordinateType>(coordType));
84 return {static_cast<int32_t>(p.width), static_cast<int32_t>(p.height)};
86 DBus::ValueOrError<ComponentLayer> BridgeComponent::GetLayer()
88 return FindSelf()->GetLayer();
90 DBus::ValueOrError<double> BridgeComponent::GetAlpha()
92 return FindSelf()->GetAlpha();
94 DBus::ValueOrError<bool> BridgeComponent::GrabFocus()
96 return FindSelf()->GrabFocus();
98 DBus::ValueOrError<bool> BridgeComponent::GrabHighlight()
100 return FindSelf()->GrabHighlight();
102 DBus::ValueOrError<bool> BridgeComponent::ClearHighlight()
104 return FindSelf()->ClearHighlight();
106 DBus::ValueOrError<int16_t> BridgeComponent::GetMdiZOrder()
108 return FindSelf()->GetMdiZOrder();