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;
27 BridgeObject::BridgeObject()
31 void BridgeObject::RegisterInterfaces()
33 // DBus::DBusInterfaceDescription desc{ AtspiDbusInterfaceEventObject };
34 // stateChanged = addSignal<std::string, int, int, DBus::EldbusVariant<int>, Accessible*>(desc, "StateChanged");
35 // dbusServer.addInterface("/", desc, true);
38 void BridgeObject::EmitActiveDescendantChanged(Accessible* obj, Accessible* child)
41 auto index = child->GetIndexInParent();
43 auto addr = obj->GetAddress();
44 const auto prefixPath = "/org/a11y/atspi/accessible/";
45 const auto nullPath = "/org/a11y/atspi/null";
48 p = prefixPath + addr.GetPath();
51 dbusServer.emit2<std::string, int, int, DBus::EldbusVariant<Address>, Address>(
53 AtspiDbusInterfaceEventObject,
54 "ActiveDescendantChanged",
58 {child->GetAddress()},
62 void BridgeObject::Emit(Accessible* obj, Dali::Accessibility::ObjectPropertyChangeEvent ev)
65 const char* name = nullptr;
68 case ObjectPropertyChangeEvent::NAME:
70 name = "accessible-name";
73 case ObjectPropertyChangeEvent::DESCRIPTION:
75 name = "accessible-description";
78 case ObjectPropertyChangeEvent::VALUE:
80 name = "accessible-value";
83 case ObjectPropertyChangeEvent::PARENT:
85 name = "accessible-parent";
88 case ObjectPropertyChangeEvent::ROLE:
90 name = "accessible-role";
96 auto addr = obj->GetAddress();
99 p = ATSPI_PREFIX_PATH + addr.GetPath();
102 dbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
104 AtspiDbusInterfaceEventObject,
114 void BridgeObject::Emit(Accessible* obj, WindowEvent event, unsigned int detail)
117 const char* name = nullptr;
120 case WindowEvent::PROPERTY_CHANGE:
122 name = "PropertyChange";
125 case WindowEvent::MINIMIZE:
130 case WindowEvent::MAXIMIZE:
135 case WindowEvent::RESTORE:
140 case WindowEvent::CLOSE:
145 case WindowEvent::CREATE:
150 case WindowEvent::REPARENT:
155 case WindowEvent::DESKTOP_CREATE:
157 name = "DesktopCreate";
160 case WindowEvent::DESKTOP_DESTROY:
162 name = "DesktopDestroy";
165 case WindowEvent::DESTROY:
170 case WindowEvent::ACTIVATE:
175 case WindowEvent::DEACTIVATE:
180 case WindowEvent::RAISE:
185 case WindowEvent::LOWER:
190 case WindowEvent::MOVE:
195 case WindowEvent::RESIZE:
200 case WindowEvent::SHADE:
205 case WindowEvent::UU_SHADE:
210 case WindowEvent::RESTYLE:
218 auto addr = obj->GetAddress();
221 p = ATSPI_PREFIX_PATH + addr.GetPath();
224 dbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
226 AtspiDbusInterfaceEventWindow,
236 void BridgeObject::EmitStateChanged(Accessible* obj, State state, int newValue, int reserved)
239 const char* stateName = nullptr;
244 stateName = "invalid";
249 stateName = "active";
264 stateName = "checked";
267 case State::COLLAPSED:
269 stateName = "collapsed";
274 stateName = "defunct";
277 case State::EDITABLE:
279 stateName = "editable";
284 stateName = "enabled";
287 case State::EXPANDABLE:
289 stateName = "expandable";
292 case State::EXPANDED:
294 stateName = "expanded";
297 case State::FOCUSABLE:
299 stateName = "focusable";
304 stateName = "focused";
307 case State::HAS_TOOLTIP:
309 stateName = "has-tooltip";
312 case State::HORIZONTAL:
314 stateName = "horizontal";
317 case State::ICONIFIED:
319 stateName = "iconified";
327 case State::MULTI_LINE:
329 stateName = "multi-line";
332 case State::MULTI_SELECTABLE:
334 stateName = "multiselectable";
339 stateName = "opaque";
344 stateName = "pressed";
347 case State::RESIZEABLE:
349 stateName = "resizable";
352 case State::SELECTABLE:
354 stateName = "selectable";
357 case State::SELECTED:
359 stateName = "selected";
362 case State::SENSITIVE:
364 stateName = "sensitive";
369 stateName = "showing";
372 case State::SINGLE_LINE:
374 stateName = "single-line";
382 case State::TRANSIENT:
384 stateName = "transient";
387 case State::VERTICAL:
389 stateName = "vertical";
394 stateName = "visible";
397 case State::MANAGES_DESCENDANTS:
399 stateName = "manages-descendants";
402 case State::INDETERMINATE:
404 stateName = "indeterminate";
407 case State::REQUIRED:
409 stateName = "required";
412 case State::TRUNCATED:
414 stateName = "truncated";
417 case State::ANIMATED:
419 stateName = "animated";
422 case State::INVALID_ENTRY:
424 stateName = "invalid-entry";
427 case State::SUPPORTS_AUTOCOMPLETION:
429 stateName = "supports-autocompletion";
432 case State::SELECTABLE_TEXT:
434 stateName = "selectable-text";
437 case State::IS_DEFAULT:
439 stateName = "is-default";
444 stateName = "visited";
447 case State::CHECKABLE:
449 stateName = "checkable";
452 case State::HAS_POPUP:
454 stateName = "has-popup";
457 case State::READ_ONLY:
459 stateName = "read-only";
462 case State::HIGHLIGHTED:
464 stateName = "highlighted";
467 case State::HIGHLIGHTABLE:
469 stateName = "highlightable";
472 case State::MAX_COUNT:
479 auto addr = obj->GetAddress();
482 p = ATSPI_PREFIX_PATH + addr.GetPath();
485 dbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
487 AtspiDbusInterfaceEventObject,
497 void BridgeObject::EmitBoundsChanged(Accessible* obj, Dali::Rect<> rect)
499 if(!allowObjectBoundsChangedEvent) return;
501 auto addr = obj->GetAddress();
502 const auto prefixPath = "/org/a11y/atspi/accessible/";
503 const auto nullPath = "/org/a11y/atspi/null";
506 p = prefixPath + addr.GetPath();
509 DBus::EldbusVariant<std::tuple<int32_t, int32_t, int32_t, int32_t> > tmp{
510 std::tuple<int32_t, int32_t, int32_t, int32_t>{rect.x, rect.y, rect.width, rect.height}};
511 addFilteredEvent(FilteredEvents::boundsChanged, obj, 1.0f, [=]() {
512 dbusServer.emit2<std::string, int, int, DBus::EldbusVariant<std::tuple<int32_t, int32_t, int32_t, int32_t> >, Address>(
514 AtspiDbusInterfaceEventObject,
524 void BridgeObject::EmitCursorMoved(Accessible* obj, unsigned int cursorPosition)
526 auto addr = obj->GetAddress();
527 std::string p = addr ? ATSPI_PREFIX_PATH + addr.GetPath() : ATSPI_NULL_PATH;
528 dbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
530 AtspiDbusInterfaceEventObject,
539 void BridgeObject::EmitTextChanged(Accessible* obj, TextChangedState state, unsigned int position, unsigned int length, const std::string& content)
541 const char* stateName = nullptr;
544 case TextChangedState::INSERTED:
546 stateName = "insert";
549 case TextChangedState::DELETED:
551 stateName = "delete";
554 case TextChangedState::MAX_COUNT:
561 auto addr = obj->GetAddress();
562 std::string p = addr ? ATSPI_PREFIX_PATH + addr.GetPath() : ATSPI_NULL_PATH;
563 dbusServer.emit2<std::string, int, int, DBus::EldbusVariant<std::string>, Address>(
565 AtspiDbusInterfaceEventObject,
575 void BridgeObject::EmitMovedOutOfScreen(Accessible* obj, ScreenRelativeMoveType type)
577 auto addr = obj->GetAddress();
578 std::string p = addr ? ATSPI_PREFIX_PATH + addr.GetPath() : ATSPI_NULL_PATH;
579 dbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
581 AtspiDbusInterfaceEventObject,
584 static_cast<int>(type),