5#include "flutter/shell/platform/linux/fl_view_accessible.h"
6#include "flutter/shell/platform/linux/fl_accessible_node.h"
7#include "flutter/shell/platform/linux/fl_accessible_text_field.h"
8#include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h"
9#include "flutter/shell/platform/linux/public/flutter_linux/fl_view.h"
24 GTK_TYPE_CONTAINER_ACCESSIBLE)
26static
void init_engine(FlViewAccessible*
self, FlEngine*
engine) {
27 g_assert(
self->engine ==
nullptr);
30 reinterpret_cast<gpointer*
>(&
self->engine));
34 if (
self->engine ==
nullptr) {
35 FlView* view = FL_VIEW(gtk_accessible_get_widget(GTK_ACCESSIBLE(
self)));
53 return FL_ACCESSIBLE_NODE(
54 g_hash_table_lookup(
self->semantics_nodes_by_id, GINT_TO_POINTER(
id)));
62 if (node !=
nullptr) {
67 if (semantics->
id == 0) {
69 g_signal_emit_by_name(
self,
"children-changed::add", 0, node,
nullptr);
71 g_hash_table_insert(
self->semantics_nodes_by_id,
72 GINT_TO_POINTER(semantics->
id),
73 reinterpret_cast<gpointer
>(node));
80 FlViewAccessible*
self = FL_VIEW_ACCESSIBLE(accessible);
83 if (node ==
nullptr) {
92 FlViewAccessible*
self = FL_VIEW_ACCESSIBLE(accessible);
95 if (i != 0 || node ==
nullptr) {
99 return ATK_OBJECT(g_object_ref(node));
104 return ATK_ROLE_PANEL;
112 FlViewAccessible*
self = FL_VIEW_ACCESSIBLE(
object);
115 init_engine(
self, FL_ENGINE(g_value_get_object(
value)));
118 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object,
prop_id,
pspec);
124 FlViewAccessible*
self = FL_VIEW_ACCESSIBLE(
object);
126 g_clear_pointer(&
self->semantics_nodes_by_id, g_hash_table_unref);
128 if (
self->engine !=
nullptr) {
129 g_object_remove_weak_pointer(
object,
130 reinterpret_cast<gpointer*
>(&
self->engine));
131 self->engine =
nullptr;
134 G_OBJECT_CLASS(fl_view_accessible_parent_class)->dispose(
object);
145 g_object_class_install_property(
148 "engine",
"engine",
"Flutter engine", fl_engine_get_type(),
149 static_cast<GParamFlags
>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
150 G_PARAM_STATIC_STRINGS)));
154 self->semantics_nodes_by_id = g_hash_table_new_full(
155 g_direct_hash, g_direct_equal,
nullptr, g_object_unref);
159 FlViewAccessible*
self,
161 g_autoptr(GHashTable) pending_children =
162 g_hash_table_new_full(g_direct_hash, g_direct_equal,
nullptr,
165 for (
size_t i = 0; i <
update->node_count; i++) {
183 g_hash_table_insert(pending_children, atk_node, children);
186 g_hash_table_foreach_remove(
191 FlAccessibleNode* parent = FL_ACCESSIBLE_NODE(
key);
194 const int32_t* children_in_traversal_order =
197 g_autoptr(GPtrArray) children = g_ptr_array_new();
198 for (
size_t i = 0; i < child_count; i++) {
199 FlAccessibleNode* child =
201 g_assert(child !=
nullptr);
203 g_ptr_array_add(children, child);
@ kFlutterSemanticsFlagIsTextField
Whether the semantic node represents a text field.
void fl_accessible_node_set_name(FlAccessibleNode *self, const gchar *name)
void fl_accessible_node_set_text_direction(FlAccessibleNode *self, FlutterTextDirection direction)
void fl_accessible_node_set_text_selection(FlAccessibleNode *self, gint base, gint extent)
void fl_accessible_node_set_actions(FlAccessibleNode *self, FlutterSemanticsAction actions)
void fl_accessible_node_set_children(FlAccessibleNode *self, GPtrArray *children)
void fl_accessible_node_set_extents(FlAccessibleNode *self, gint x, gint y, gint width, gint height)
void fl_accessible_node_set_value(FlAccessibleNode *self, const gchar *value)
void fl_accessible_node_set_flags(FlAccessibleNode *self, FlutterSemanticsFlag flags)
void fl_accessible_node_set_parent(FlAccessibleNode *self, AtkObject *parent, gint index)
FlAccessibleNode * fl_accessible_node_new(FlEngine *engine, int32_t id)
FlAccessibleNode * fl_accessible_text_field_new(FlEngine *engine, int32_t id)
guint const GValue GParamSpec * pspec
G_MODULE_EXPORT void fl_value_unref(FlValue *self)
G_MODULE_EXPORT FlValue * fl_value_new_int32_list(const int32_t *data, size_t data_length)
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
G_MODULE_EXPORT const int32_t * fl_value_get_int32_list(FlValue *self)
typedefG_BEGIN_DECLS struct _FlValue FlValue
G_MODULE_EXPORT FlEngine * fl_view_get_engine(FlView *self)
static void fl_view_accessible_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
static void fl_view_accessible_dispose(GObject *object)
g_object_add_weak_pointer(G_OBJECT(self), reinterpret_cast< gpointer * >(&self->engine))
static FlAccessibleNode * get_node(FlViewAccessible *self, FlutterSemanticsNode2 *semantics)
static void fl_view_accessible_init(FlViewAccessible *self)
static AtkRole fl_view_accessible_get_role(AtkObject *accessible)
static FlAccessibleNode * create_node(FlViewAccessible *self, FlutterSemanticsNode2 *semantics)
static AtkObject * fl_view_accessible_ref_child(AtkObject *accessible, gint i)
static gint fl_view_accessible_get_n_children(AtkObject *accessible)
static FlEngine * get_engine(FlViewAccessible *self)
static void fl_view_accessible_class_init(FlViewAccessibleClass *klass)
G_DEFINE_TYPE(FlViewAccessible, fl_view_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE) static void init_engine(FlViewAccessible *self
void fl_view_accessible_handle_update_semantics(FlViewAccessible *self, const FlutterSemanticsUpdate2 *update)
static FlAccessibleNode * lookup_node(FlViewAccessible *self, int32_t id)
const int32_t * children_in_traversal_order
Array of child node IDs in traversal order. Has length child_count.
int32_t text_selection_extent
The position at which the text selection terminates.
FlutterTextDirection text_direction
FlutterSemanticsAction actions
The set of semantics actions applicable to this node.
int32_t id
The unique identifier for this node.
FlutterRect rect
The bounding box for this node in its coordinate system.
FlutterTransformation transform
size_t child_count
The number of children this node has.
const char * label
A textual description of the node.
int32_t text_selection_base
The position at which the text selection originates.
const char * value
A textual description of the current value of the node.
FlutterSemanticsFlag flags
The set of semantics flags associated with this node.
A batch of updates to semantics nodes and custom actions.
GtkContainerAccessible parent_instance
GHashTable * semantics_nodes_by_id