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-object.h>
25 using namespace Dali::Accessibility;
29 inline std::string GetAccessiblePath(Accessible* accessible)
31 auto address = accessible->GetAddress();
32 return address ? ATSPI_PREFIX_PATH + address.GetPath() : ATSPI_NULL_PATH;
36 BridgeObject::BridgeObject()
40 void BridgeObject::RegisterInterfaces()
42 // DBus::DBusInterfaceDescription desc{ AtspiDbusInterfaceEventObject };
43 // stateChanged = addSignal<std::string, int, int, DBus::EldbusVariant<int>, Accessible*>(desc, "StateChanged");
44 // mDbusServer.addInterface("/", desc, true);
47 void BridgeObject::EmitActiveDescendantChanged(Accessible* obj, Accessible* child)
50 auto index = child->GetIndexInParent();
52 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<Address>, Address>(
53 GetAccessiblePath(obj),
54 AtspiDbusInterfaceEventObject,
55 "ActiveDescendantChanged",
59 {child->GetAddress()},
63 void BridgeObject::Emit(Accessible* obj, Dali::Accessibility::ObjectPropertyChangeEvent ev)
66 const char* name = nullptr;
70 case ObjectPropertyChangeEvent::NAME:
72 name = "accessible-name";
75 case ObjectPropertyChangeEvent::DESCRIPTION:
77 name = "accessible-description";
80 case ObjectPropertyChangeEvent::VALUE:
82 name = "accessible-value";
85 case ObjectPropertyChangeEvent::PARENT:
87 name = "accessible-parent";
90 case ObjectPropertyChangeEvent::ROLE:
92 name = "accessible-role";
99 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
100 GetAccessiblePath(obj),
101 AtspiDbusInterfaceEventObject,
111 void BridgeObject::Emit(Accessible* obj, WindowEvent event, unsigned int detail)
114 const char* name = nullptr;
118 case WindowEvent::PROPERTY_CHANGE:
120 name = "PropertyChange";
123 case WindowEvent::MINIMIZE:
128 case WindowEvent::MAXIMIZE:
133 case WindowEvent::RESTORE:
138 case WindowEvent::CLOSE:
143 case WindowEvent::CREATE:
148 case WindowEvent::REPARENT:
153 case WindowEvent::DESKTOP_CREATE:
155 name = "DesktopCreate";
158 case WindowEvent::DESKTOP_DESTROY:
160 name = "DesktopDestroy";
163 case WindowEvent::DESTROY:
168 case WindowEvent::ACTIVATE:
173 case WindowEvent::DEACTIVATE:
178 case WindowEvent::RAISE:
183 case WindowEvent::LOWER:
188 case WindowEvent::MOVE:
193 case WindowEvent::RESIZE:
198 case WindowEvent::SHADE:
203 case WindowEvent::UU_SHADE:
208 case WindowEvent::RESTYLE:
217 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
218 GetAccessiblePath(obj),
219 AtspiDbusInterfaceEventWindow,
229 void BridgeObject::EmitStateChanged(Accessible* obj, State state, int newValue, int reserved)
232 const char* stateName = nullptr;
238 stateName = "invalid";
243 stateName = "active";
258 stateName = "checked";
261 case State::COLLAPSED:
263 stateName = "collapsed";
268 stateName = "defunct";
271 case State::EDITABLE:
273 stateName = "editable";
278 stateName = "enabled";
281 case State::EXPANDABLE:
283 stateName = "expandable";
286 case State::EXPANDED:
288 stateName = "expanded";
291 case State::FOCUSABLE:
293 stateName = "focusable";
298 stateName = "focused";
301 case State::HAS_TOOLTIP:
303 stateName = "has-tooltip";
306 case State::HORIZONTAL:
308 stateName = "horizontal";
311 case State::ICONIFIED:
313 stateName = "iconified";
321 case State::MULTI_LINE:
323 stateName = "multi-line";
326 case State::MULTI_SELECTABLE:
328 stateName = "multiselectable";
333 stateName = "opaque";
338 stateName = "pressed";
341 case State::RESIZEABLE:
343 stateName = "resizable";
346 case State::SELECTABLE:
348 stateName = "selectable";
351 case State::SELECTED:
353 stateName = "selected";
356 case State::SENSITIVE:
358 stateName = "sensitive";
363 stateName = "showing";
366 case State::SINGLE_LINE:
368 stateName = "single-line";
376 case State::TRANSIENT:
378 stateName = "transient";
381 case State::VERTICAL:
383 stateName = "vertical";
388 stateName = "visible";
391 case State::MANAGES_DESCENDANTS:
393 stateName = "manages-descendants";
396 case State::INDETERMINATE:
398 stateName = "indeterminate";
401 case State::REQUIRED:
403 stateName = "required";
406 case State::TRUNCATED:
408 stateName = "truncated";
411 case State::ANIMATED:
413 stateName = "animated";
416 case State::INVALID_ENTRY:
418 stateName = "invalid-entry";
421 case State::SUPPORTS_AUTOCOMPLETION:
423 stateName = "supports-autocompletion";
426 case State::SELECTABLE_TEXT:
428 stateName = "selectable-text";
431 case State::IS_DEFAULT:
433 stateName = "is-default";
438 stateName = "visited";
441 case State::CHECKABLE:
443 stateName = "checkable";
446 case State::HAS_POPUP:
448 stateName = "has-popup";
451 case State::READ_ONLY:
453 stateName = "read-only";
456 case State::HIGHLIGHTED:
458 stateName = "highlighted";
461 case State::HIGHLIGHTABLE:
463 stateName = "highlightable";
466 case State::MAX_COUNT:
474 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
475 GetAccessiblePath(obj),
476 AtspiDbusInterfaceEventObject,
486 void BridgeObject::EmitBoundsChanged(Accessible* obj, Dali::Rect<> rect)
488 if(!IsBoundsChangedEventAllowed) return;
490 DBus::EldbusVariant<std::tuple<int32_t, int32_t, int32_t, int32_t> > tmp{
491 std::tuple<int32_t, int32_t, int32_t, int32_t>{rect.x, rect.y, rect.width, rect.height}};
493 AddFilteredEvent(FilteredEvents::BOUNDS_CHANGED, obj, 1.0f, [=]() {
494 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<std::tuple<int32_t, int32_t, int32_t, int32_t> >, Address>(
495 GetAccessiblePath(obj),
496 AtspiDbusInterfaceEventObject,
506 void BridgeObject::EmitCursorMoved(Accessible* obj, unsigned int cursorPosition)
508 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
509 GetAccessiblePath(obj),
510 AtspiDbusInterfaceEventObject,
519 void BridgeObject::EmitTextChanged(Accessible* obj, TextChangedState state, unsigned int position, unsigned int length, const std::string& content)
521 const char* stateName = nullptr;
524 case TextChangedState::INSERTED:
526 stateName = "insert";
529 case TextChangedState::DELETED:
531 stateName = "delete";
534 case TextChangedState::MAX_COUNT:
542 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<std::string>, Address>(
543 GetAccessiblePath(obj),
544 AtspiDbusInterfaceEventObject,
554 void BridgeObject::EmitMovedOutOfScreen(Accessible* obj, ScreenRelativeMoveType type)
556 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
557 GetAccessiblePath(obj),
558 AtspiDbusInterfaceEventObject,
561 static_cast<int>(type),