-
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 initial accessibility support to the Linux shell
- Loading branch information
1 parent
c3c3ec6
commit e39e8db
Showing
12 changed files
with
871 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,57 @@ | ||
// 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 view_weak_notify_cb(gpointer user_data, GObject* object) { | ||
FlAccessibilityPlugin* self = FL_ACCESSIBILITY_PLUGIN(object); | ||
self->view = nullptr; | ||
} | ||
|
||
static void fl_accessibility_plugin_dispose(GObject* object) { | ||
FlAccessibilityPlugin* self = FL_ACCESSIBILITY_PLUGIN(object); | ||
|
||
if (self->view != nullptr) { | ||
g_object_weak_unref(G_OBJECT(self->view), view_weak_notify_cb, self); | ||
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_weak_ref(G_OBJECT(view), view_weak_notify_cb, self); | ||
|
||
return self; | ||
} | ||
|
||
void fl_accessibility_plugin_handle_update_semantics_node( | ||
FlAccessibilityPlugin* self, | ||
const FlutterSemanticsNode* node) { | ||
if (self->view != nullptr) { | ||
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.