-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add accessibility suport to Linux shell. (#19634)
Add accessibility support to the Linux shell
- Loading branch information
1 parent
22bb891
commit 20991a5
Showing
14 changed files
with
1,036 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ |
Oops, something went wrong.