#define DALI_ADAPTOR_ACCESSIBILITY_BRIDGE_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// EXTERNAL INCLUDES
#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/events/key-event.h>
#include <dali/public-api/math/rect.h>
#include <functional>
#include <memory>
namespace Accessibility
{
class Accessible;
+class ProxyAccessible;
/**
* @brief Base class for different accessibility bridges.
* that could be read by screen-reader immediately after the navigation context has changed
* (window activates, popup shows up, tab changes) and before first UI element is highlighted.
*
+ * @param[in] root The root of the navigation context for which to retrieve the default label.
+ *
* @return The handler to accessibility object
* @note This is a Tizen only feature not present in upstream ATSPI.
* Feature can be enabled/disabled for particular context root object
* Following strings are valid values for "default_label" attribute: "enabled", "disabled".
* Any other value will be interpreted as "enabled".
*/
- virtual Accessible* GetDefaultLabel() const = 0;
+ virtual Accessible* GetDefaultLabel(Accessible* root) const = 0;
/**
* @brief Sets name of current application which will be visible on accessibility bus.
virtual void SetApplicationName(std::string name) = 0;
/**
+ * @brief Sets the name of the GUI toolkit that AT-SPI clients can query.
+ *
+ * The default name is "dali".
+ *
+ * @param toolkitName The toolkit name
+ */
+ virtual void SetToolkitName(std::string_view toolkitName) = 0;
+
+ /**
* @brief Gets object being root of accessibility tree.
*
* @return handler to accessibility object
virtual Accessible* FindByPath(const std::string& path) const = 0;
/**
+ * @brief Notifies accessibility dbus that window has just been created.
+ *
+ * @param[in] window The window to be created
+ */
+ virtual void WindowCreated(Window window) = 0;
+
+ /**
* @brief Notifies accessibility dbus that window has just been shown.
*
* @param[in] window The window to be shown
virtual void WindowUnfocused(Window window) = 0;
/**
+ * @brief Notifies accessibility dbus that window has just been minimized.
+ *
+ * @param[in] window The window to be minimized
+ */
+ virtual void WindowMinimized(Window window) = 0;
+
+ /**
+ * @brief Notifies accessibility dbus that window has just been restored.
+ *
+ * @param[in] window The window to be restored
+ * @param[in] detail Restored window state
+ */
+ virtual void WindowRestored(Window window, WindowRestoreType detail) = 0;
+
+ /**
+ * @brief Notifies accessibility dbus that window has just been maximized.
+ *
+ * @param[in] window The window to be maximized
+ */
+ virtual void WindowMaximized(Window window) = 0;
+
+ /**
* @brief Initializes accessibility bus.
*/
virtual void Initialize() = 0;
virtual void EmitMovedOutOfScreen(Accessible* obj, ScreenRelativeMoveType type) = 0;
/**
+ * @brief Emits "org.a11y.atspi.Socket.Available" event on AT-SPI bus.
+ *
+ * @param obj Accessible object
+ */
+ virtual void EmitSocketAvailable(Accessible* obj) = 0;
+
+ /**
+ * @brief Emits ScrollStarted event on at-spi bus.
+ *
+ * @param obj Accessible Object
+ */
+ virtual void EmitScrollStarted(Accessible *obj) = 0;
+
+ /**
+ * @brief Emits ScrollFinished event on at-spi bus.
+ *
+ * @param obj Accessible Object
+ */
+ virtual void EmitScrollFinished(Accessible *obj) = 0;
+
+ /**
* @brief Emits state-changed event on at-spi bus.
*
* @param[in] obj The accessible object
virtual void EmitBoundsChanged(Accessible* obj, Rect<> rect) = 0;
/**
+ * @brief Emits org.a11y.atspi.Event.Window.PostRender on the AT-SPI bus.
+ *
+ * @param[in] obj The Accessible sender object
+ *
+ * The sender of this event is expected to be an Accessible object that
+ * represents a top-level window.
+ *
+ * The actual number of events emitted during a given time interval may be smaller
+ * than the number of calls to this method, but at least one is guaranteed.
+ */
+ virtual void EmitPostRender(Accessible *obj) = 0;
+
+ /**
* @brief Emits key event on at-spi bus.
*
* Screen-reader might receive this event and reply, that given keycode is consumed. In that case
* further processing of the keycode should be ignored.
*
- * @param[in] type Key event type
- * @param[in] keyCode Key code
- * @param[in] keyName Key name
- * @param[in] timeStamp Time stamp
- * @param[in] isText Whether it's text or not
- * @return Whether this event is consumed or not
- **/
- virtual Consumed Emit(KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText) = 0;
+ * @param[in] keyEvent The key event
+ * @param[in] callback Notification if the event was consumed
+ * @return true if the event was emitted
+ */
+ virtual bool EmitKeyEvent(Dali::KeyEvent keyEvent, std::function<void(Dali::KeyEvent, bool)> callback) = 0;
/**
* @brief Reads given text by screen reader
virtual bool IsEnabled() = 0;
/**
+ * @brief Calls socket.Embed(plug) via D-Bus.
+ *
+ * @param[in] plug The plug
+ * @param[in] socket The socket
+ *
+ * @return Address returned by the D-Bus call.
+ *
+ * @note Remote object pointed to by 'socket' must implement 'org.a11y.atspi.Socket'.
+ * @see UnembedSocket()
+ */
+ virtual Address EmbedSocket(const Address& plug, const Address& socket) = 0;
+
+ /**
+ * @brief Calls socket.Embedded(plug) via D-Bus.
+ *
+ * The "Embedded" D-Bus method is an ATK extension.
+ * See 'impl_Embedded' in AT_SPI2_ATK/atk-adaptor/adaptors/socket-adaptor.c for more information.
+ *
+ * @param[in] plug The plug
+ * @param[in] socket The socket
+ */
+ virtual void EmbedAtkSocket(const Address& plug, const Address& socket) = 0;
+
+ /**
+ * @brief Calls socket.Unmbed(plug) via D-Bus.
+ *
+ * @param[in] plug The plug
+ * @param[in] socket The socket
+ *
+ * @note Remote object pointed to by 'socket' must implement 'org.a11y.atspi.Socket'.
+ * @see EmbedSocket()
+ */
+ virtual void UnembedSocket(const Address& plug, const Address& socket) = 0;
+
+ /**
+ * @brief Calls socket.SetOffset(x, y) via D-Bus.
+ *
+ * The "SetOffset" D-Bus method is a DALi extension. It can be used to inform a DALi widget about
+ * its position on the screen.
+ *
+ * @param[in] socket The socket
+ * @param[in] x Horizontal offset
+ * @param[in] y Vertical offset
+ *
+ * @note Remote object pointed to by 'socket' must implement 'org.a11y.atspi.Socket'.
+ * @see EmbedSocket()
+ * @see SetExtentsOffset()
+ */
+ virtual void SetSocketOffset(ProxyAccessible* socket, std::int32_t x, std::int32_t y) = 0;
+
+ /**
+ * @brief Sets the global extents offset.
+ *
+ * This offset will be added during serialization of GetExtents() return value to D-Bus.
+ * Local calls to GetExtents() are unaffected.
+ *
+ * @param[in] x Horizontal offset
+ * @param[in] y Vertical offset
+ *
+ * @see SetSocketOffset()
+ * @see Dali::Accessibility::Component::GetExtents()
+ */
+ virtual void SetExtentsOffset(std::int32_t x, std::int32_t y) = 0;
+
+ /**
+ * @brief Sets the preferred bus name.
+ *
+ * If the Bridge is enabled, it will immediately release the previous name and request the new one.
+ *
+ * Otherwise, the Bridge will request this name on AT-SPI activation (and release it on deactivation).
+ * It is up to the caller to determine whether a given name will be available in the system.
+ *
+ * @param preferredBusName The preferred bus name
+ */
+ virtual void SetPreferredBusName(std::string_view preferredBusName) = 0;
+
+ /**
* @brief Returns instance of bridge singleton object.
*
* @return The current bridge object
*/
static void EnableAutoInit();
+ /**
+ * @brief Encodes a widget ID as a usable bus name.
+ *
+ * @param widgetInstanceId The instance ID of a widget
+ * @return std::string Encoded bus name
+ *
+ * @see SetPreferredBusName
+ */
+ static std::string MakeBusNameForWidget(std::string_view widgetInstanceId);
+
static Signal<void()>& EnabledSignal()
{
return mEnabledSignal;
return mDisabledSignal;
}
+ static Signal<void()>& ScreenReaderEnabledSignal()
+ {
+ return mScreenReaderEnabledSignal;
+ }
+
+ static Signal<void()>& ScreenReaderDisabledSignal()
+ {
+ return mScreenReaderDisabledSignal;
+ }
+
protected:
struct Data
{
Bridge* mBridge = nullptr;
Actor mHighlightActor;
Actor mCurrentlyHighlightedActor;
+ std::pair<std::int32_t, std::int32_t> mExtentsOffset{0, 0};
};
std::shared_ptr<Data> mData;
friend class Accessible;
inline static Signal<void()> mEnabledSignal;
inline static Signal<void()> mDisabledSignal;
+ inline static Signal<void()> mScreenReaderEnabledSignal;
+ inline static Signal<void()> mScreenReaderDisabledSignal;
/**
* @brief Registers accessible object to be known in bridge object.