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 // mDbusServer.addInterface("/", desc, true);
38 void BridgeObject::EmitActiveDescendantChanged(Accessible* obj, Accessible* child)
41 auto index = child->GetIndexInParent();
43 auto addr = obj->GetAddress();
44 std::string path = addr ? ATSPI_PREFIX_PATH + addr.GetPath() : ATSPI_NULL_PATH;
46 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<Address>, Address>(
48 AtspiDbusInterfaceEventObject,
49 "ActiveDescendantChanged",
53 {child->GetAddress()},
57 void BridgeObject::Emit(Accessible* obj, Dali::Accessibility::ObjectPropertyChangeEvent ev)
60 const char* name = nullptr;
64 case ObjectPropertyChangeEvent::NAME:
66 name = "accessible-name";
69 case ObjectPropertyChangeEvent::DESCRIPTION:
71 name = "accessible-description";
74 case ObjectPropertyChangeEvent::VALUE:
76 name = "accessible-value";
79 case ObjectPropertyChangeEvent::PARENT:
81 name = "accessible-parent";
84 case ObjectPropertyChangeEvent::ROLE:
86 name = "accessible-role";
93 auto addr = obj->GetAddress();
94 std::string path = addr ? ATSPI_PREFIX_PATH + addr.GetPath() : ATSPI_NULL_PATH;
96 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
98 AtspiDbusInterfaceEventObject,
108 void BridgeObject::Emit(Accessible* obj, WindowEvent event, unsigned int detail)
111 const char* name = nullptr;
115 case WindowEvent::PROPERTY_CHANGE:
117 name = "PropertyChange";
120 case WindowEvent::MINIMIZE:
125 case WindowEvent::MAXIMIZE:
130 case WindowEvent::RESTORE:
135 case WindowEvent::CLOSE:
140 case WindowEvent::CREATE:
145 case WindowEvent::REPARENT:
150 case WindowEvent::DESKTOP_CREATE:
152 name = "DesktopCreate";
155 case WindowEvent::DESKTOP_DESTROY:
157 name = "DesktopDestroy";
160 case WindowEvent::DESTROY:
165 case WindowEvent::ACTIVATE:
170 case WindowEvent::DEACTIVATE:
175 case WindowEvent::RAISE:
180 case WindowEvent::LOWER:
185 case WindowEvent::MOVE:
190 case WindowEvent::RESIZE:
195 case WindowEvent::SHADE:
200 case WindowEvent::UU_SHADE:
205 case WindowEvent::RESTYLE:
214 auto addr = obj->GetAddress();
215 std::string path = addr ? ATSPI_PREFIX_PATH + addr.GetPath() : ATSPI_NULL_PATH;
217 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
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 auto addr = obj->GetAddress();
475 std::string path = addr ? ATSPI_PREFIX_PATH + addr.GetPath() : ATSPI_NULL_PATH;
477 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
479 AtspiDbusInterfaceEventObject,
489 void BridgeObject::EmitBoundsChanged(Accessible* obj, Dali::Rect<> rect)
491 if(!IsBoundsChangedEventAllowed) return;
493 auto addr = obj->GetAddress();
494 std::string path = addr ? ATSPI_PREFIX_PATH + addr.GetPath() : ATSPI_NULL_PATH;
496 DBus::EldbusVariant<std::tuple<int32_t, int32_t, int32_t, int32_t> > tmp{
497 std::tuple<int32_t, int32_t, int32_t, int32_t>{rect.x, rect.y, rect.width, rect.height}};
499 AddFilteredEvent(FilteredEvents::BOUNDS_CHANGED, obj, 1.0f, [=]() {
500 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<std::tuple<int32_t, int32_t, int32_t, int32_t> >, Address>(
502 AtspiDbusInterfaceEventObject,
512 void BridgeObject::EmitCursorMoved(Accessible* obj, unsigned int cursorPosition)
514 auto addr = obj->GetAddress();
515 std::string path = addr ? ATSPI_PREFIX_PATH + addr.GetPath() : ATSPI_NULL_PATH;
517 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
519 AtspiDbusInterfaceEventObject,
528 void BridgeObject::EmitTextChanged(Accessible* obj, TextChangedState state, unsigned int position, unsigned int length, const std::string& content)
530 const char* stateName = nullptr;
533 case TextChangedState::INSERTED:
535 stateName = "insert";
538 case TextChangedState::DELETED:
540 stateName = "delete";
543 case TextChangedState::MAX_COUNT:
551 auto addr = obj->GetAddress();
552 std::string path = addr ? ATSPI_PREFIX_PATH + addr.GetPath() : ATSPI_NULL_PATH;
554 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<std::string>, Address>(
556 AtspiDbusInterfaceEventObject,
566 void BridgeObject::EmitMovedOutOfScreen(Accessible* obj, ScreenRelativeMoveType type)
568 auto addr = obj->GetAddress();
569 std::string path = addr ? ATSPI_PREFIX_PATH + addr.GetPath() : ATSPI_NULL_PATH;
571 mDbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
573 AtspiDbusInterfaceEventObject,
576 static_cast<int>(type),