Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add accessibility suport to Linux shell. #19634

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,11 @@ FILE: ../../../flutter/shell/platform/glfw/text_input_plugin.h
FILE: ../../../flutter/shell/platform/linux/egl_utils.cc
FILE: ../../../flutter/shell/platform/linux/egl_utils.h
FILE: ../../../flutter/shell/platform/linux/egl_utils_test.cc
FILE: ../../../flutter/shell/platform/linux/fl_accessibility_plugin.cc
FILE: ../../../flutter/shell/platform/linux/fl_accessibility_plugin.h
FILE: ../../../flutter/shell/platform/linux/fl_accessible_node.cc
FILE: ../../../flutter/shell/platform/linux/fl_accessible_node.h
FILE: ../../../flutter/shell/platform/linux/fl_accessible_node_test.cc
FILE: ../../../flutter/shell/platform/linux/fl_basic_message_channel.cc
FILE: ../../../flutter/shell/platform/linux/fl_basic_message_channel_test.cc
FILE: ../../../flutter/shell/platform/linux/fl_binary_codec.cc
Expand Down Expand Up @@ -1388,6 +1393,8 @@ FILE: ../../../flutter/shell/platform/linux/fl_text_input_plugin.h
FILE: ../../../flutter/shell/platform/linux/fl_value.cc
FILE: ../../../flutter/shell/platform/linux/fl_value_test.cc
FILE: ../../../flutter/shell/platform/linux/fl_view.cc
FILE: ../../../flutter/shell/platform/linux/fl_view_accessible.cc
FILE: ../../../flutter/shell/platform/linux/fl_view_accessible.h
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_basic_message_channel.h
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_binary_codec.h
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h
Expand Down
4 changes: 4 additions & 0 deletions shell/platform/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ source_set("flutter_linux_sources") {

sources = [
"egl_utils.cc",
"fl_accessibility_plugin.cc",
"fl_accessible_node.cc",
"fl_basic_message_channel.cc",
"fl_binary_codec.cc",
"fl_binary_messenger.cc",
Expand Down Expand Up @@ -118,6 +120,7 @@ source_set("flutter_linux_sources") {
"fl_text_input_plugin.cc",
"fl_value.cc",
"fl_view.cc",
"fl_view_accessible.cc",
]

# Set flag to stop headers being directly included (library users should not do this)
Expand Down Expand Up @@ -159,6 +162,7 @@ executable("flutter_linux_unittests") {

sources = [
"egl_utils_test.cc",
"fl_accessible_node_test.cc",
"fl_basic_message_channel_test.cc",
"fl_binary_codec_test.cc",
"fl_binary_messenger_test.cc",
Expand Down
56 changes: 56 additions & 0 deletions shell/platform/linux/fl_accessibility_plugin.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/shell/platform/linux/fl_accessibility_plugin.h"
#include "flutter/shell/platform/linux/fl_view_accessible.h"

struct _FlAccessibilityPlugin {
GObject parent_instance;

FlView* view;
};

G_DEFINE_TYPE(FlAccessibilityPlugin, fl_accessibility_plugin, G_TYPE_OBJECT)

static void fl_accessibility_plugin_dispose(GObject* object) {
FlAccessibilityPlugin* self = FL_ACCESSIBILITY_PLUGIN(object);

if (self->view != nullptr) {
g_object_remove_weak_pointer(G_OBJECT(self),
reinterpret_cast<gpointer*>(&(self->view)));
self->view = nullptr;
}

G_OBJECT_CLASS(fl_accessibility_plugin_parent_class)->dispose(object);
}

static void fl_accessibility_plugin_class_init(
FlAccessibilityPluginClass* klass) {
G_OBJECT_CLASS(klass)->dispose = fl_accessibility_plugin_dispose;
}

static void fl_accessibility_plugin_init(FlAccessibilityPlugin* self) {}

FlAccessibilityPlugin* fl_accessibility_plugin_new(FlView* view) {
FlAccessibilityPlugin* self = FL_ACCESSIBILITY_PLUGIN(
g_object_new(fl_accessibility_plugin_get_type(), nullptr));

self->view = view;
g_object_add_weak_pointer(G_OBJECT(self),
reinterpret_cast<gpointer*>(&(self->view)));

return self;
}

void fl_accessibility_plugin_handle_update_semantics_node(
FlAccessibilityPlugin* self,
const FlutterSemanticsNode* node) {
if (self->view == nullptr) {
return;
}

AtkObject* accessible = gtk_widget_get_accessible(GTK_WIDGET(self->view));
fl_view_accessible_handle_update_semantics_node(
FL_VIEW_ACCESSIBLE(accessible), node);
}
robert-ancell marked this conversation as resolved.
Show resolved Hide resolved
50 changes: 50 additions & 0 deletions shell/platform/linux/fl_accessibility_plugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_ACCESSIBILITY_PLUGIN_H_
#define FLUTTER_SHELL_PLATFORM_LINUX_FL_ACCESSIBILITY_PLUGIN_H_

#include "flutter/shell/platform/linux/public/flutter_linux/fl_view.h"

#include "flutter/shell/platform/embedder/embedder.h"

G_BEGIN_DECLS

G_DECLARE_FINAL_TYPE(FlAccessibilityPlugin,
fl_accessibility_plugin,
FL,
ACCESSIBILITY_PLUGIN,
GObject);

/**
* FlAccessibilityPlugin:
*
* #FlAccessibilityPlugin is a plugin that handles semantic node updates and
* converts them to ATK events.
*/

/**
* fl_accessibility_plugin_new:
* @view: an #FlView to export accessibility information to.
*
* Creates a new plugin handles semantic node updates.
*
* Returns: a new #FlAccessibilityPlugin.
*/
FlAccessibilityPlugin* fl_accessibility_plugin_new(FlView* view);

/**
* fl_accessibility_plugin_handle_update_semantics_node:
* @plugin: an #FlAccessibilityPlugin.
* @node: semantic node information.
*
* Handle a semantics node update.
*/
void fl_accessibility_plugin_handle_update_semantics_node(
FlAccessibilityPlugin* plugin,
const FlutterSemanticsNode* node);

G_END_DECLS

#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_ACCESSIBILITY_PLUGIN_H_
Loading