From be8b8a3a6003440647227c08ae96250d1ffb9134 Mon Sep 17 00:00:00 2001 From: Leo Date: Wed, 21 Aug 2024 04:59:52 +0900 Subject: [PATCH] WindowSwitcher: set accessible properties (#2030) --- .github/workflows/main.yml | 2 +- docs/meson.build | 1 + meson.build | 3 ++- src/Widgets/WindowSwitcher/WindowSwitcher.vala | 7 +++++++ src/Widgets/WindowSwitcher/WindowSwitcherIcon.vala | 7 +++++++ src/WindowManager.vala | 11 +++++++++++ vapi/atk-bridge-2.0.vapi | 6 ++++++ 7 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 vapi/atk-bridge-2.0.vapi diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7618a82d..f994fa94 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,7 +31,7 @@ jobs: - name: Install Dependencies run: | apt update - apt install -y gettext gnome-settings-daemon-dev gsettings-desktop-schemas-dev libcanberra-dev libclutter-1.0-dev libgee-0.8-dev libglib2.0-dev libgnome-desktop-3-dev libgranite-dev libgtk-3-dev ${{ matrix.mutter_pkg }} libxml2-utils libsqlite3-dev meson valac valadoc + apt install -y gettext gsettings-desktop-schemas-dev libatk-bridge2.0-dev libcanberra-dev libclutter-1.0-dev libgee-0.8-dev libglib2.0-dev libgnome-desktop-3-dev libgranite-dev libgtk-3-dev ${{ matrix.mutter_pkg }} libxml2-utils libsqlite3-dev meson valac valadoc - name: Build env: DESTDIR: out diff --git a/docs/meson.build b/docs/meson.build index e1e6022c..6636e38a 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -13,6 +13,7 @@ basic_command = [ '--package-version', '0.0.0', '--driver', vala.version(), mutter_packages_command, + '--pkg', 'atk-bridge-2.0', '--pkg', 'gnome-desktop-3.0', '--pkg', 'gtk+-3.0', '--pkg', 'gee-0.8', diff --git a/meson.build b/meson.build index d79e9de5..90a3d145 100644 --- a/meson.build +++ b/meson.build @@ -79,6 +79,7 @@ add_project_arguments([ glib_version_required = '2.74.0' gtk_version_required = '3.10.0' +atk_bridge_dep = dependency('atk-bridge-2.0') canberra_dep = dependency('libcanberra') glib_dep = dependency('glib-2.0', version: '>= @0@'.format(glib_version_required)) gobject_dep = dependency('gobject-2.0', version: '>= @0@'.format(glib_version_required)) @@ -170,7 +171,7 @@ endif add_project_arguments(vala_flags, language: 'vala') add_project_link_arguments(['-Wl,-rpath,@0@'.format(mutter_typelib_dir)], language: 'c') -gala_base_dep = [canberra_dep, glib_dep, gobject_dep, gio_dep, gio_unix_dep, gmodule_dep, gee_dep, gtk_dep, mutter_dep, gnome_desktop_dep, m_dep, posix_dep, sqlite3_dep, config_dep] +gala_base_dep = [atk_bridge_dep, canberra_dep, glib_dep, gobject_dep, gio_dep, gio_unix_dep, gmodule_dep, gee_dep, gtk_dep, mutter_dep, gnome_desktop_dep, m_dep, posix_dep, sqlite3_dep, config_dep] if get_option('systemd') gala_base_dep += systemd_dep diff --git a/src/Widgets/WindowSwitcher/WindowSwitcher.vala b/src/Widgets/WindowSwitcher/WindowSwitcher.vala index 14986ad3..4cf6d689 100644 --- a/src/Widgets/WindowSwitcher/WindowSwitcher.vala +++ b/src/Widgets/WindowSwitcher/WindowSwitcher.vala @@ -42,6 +42,7 @@ public class Gala.WindowSwitcher : CanvasActor { _current_icon = value; if (_current_icon != null) { _current_icon.selected = true; + _current_icon.grab_key_focus (); } update_caption_text (); @@ -69,6 +70,9 @@ public class Gala.WindowSwitcher : CanvasActor { #endif }; + get_accessible ().accessible_name = _("Window switcher"); + container.get_accessible ().accessible_role = LIST; + caption = new Clutter.Text () { font_name = CAPTION_FONT_NAME, ellipsize = END, @@ -78,6 +82,7 @@ public class Gala.WindowSwitcher : CanvasActor { add_child (container); add_child (caption); + reactive = true; visible = false; opacity = 0; layout_manager = new Clutter.BoxLayout () { @@ -355,6 +360,7 @@ public class Gala.WindowSwitcher : CanvasActor { private void add_icon (WindowSwitcherIcon icon) { container.add_child (icon); + icon.get_accessible ().accessible_parent = container.get_accessible (); icon.motion_event.connect ((_icon, event) => { if (current_icon != _icon && !handling_gesture) { @@ -404,6 +410,7 @@ public class Gala.WindowSwitcher : CanvasActor { push_modal (); } else { wm.pop_modal (modal_proxy); + get_stage ().set_key_focus (null); } save_easing_state (); diff --git a/src/Widgets/WindowSwitcher/WindowSwitcherIcon.vala b/src/Widgets/WindowSwitcher/WindowSwitcherIcon.vala index 8b594e98..c85a12cd 100644 --- a/src/Widgets/WindowSwitcher/WindowSwitcherIcon.vala +++ b/src/Widgets/WindowSwitcher/WindowSwitcherIcon.vala @@ -40,6 +40,10 @@ public class Gala.WindowSwitcherIcon : CanvasActor { icon.add_constraint (new Clutter.AlignConstraint (this, Clutter.AlignAxis.BOTH, 0.5f)); add_child (icon); + get_accessible ().accessible_name = window.title; + get_accessible ().accessible_role = LIST_ITEM; + get_accessible ().notify_state_change (Atk.StateType.FOCUSABLE, true); + reactive = true; this.scale_factor = scale_factor; @@ -76,5 +80,8 @@ public class Gala.WindowSwitcherIcon : CanvasActor { ctx.restore (); } + + get_accessible ().notify_state_change (Atk.StateType.SELECTED, selected); + get_accessible ().notify_state_change (Atk.StateType.FOCUSED, selected); } } diff --git a/src/WindowManager.vala b/src/WindowManager.vala index f73b510d..7dba0a2b 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -149,6 +149,8 @@ namespace Gala { show_stage (); + init_a11y (); + AccessDialog.watch_portal (); unowned Meta.Display display = get_display (); @@ -379,6 +381,15 @@ namespace Gala { }); } + private void init_a11y () { + if (!Clutter.get_accessibility_enabled ()) { + warning ("Clutter has no accessibility enabled"); + return; + } + + AtkBridge.adaptor_init (0, {}); + } + private void update_ui_group_size () { unowned var display = get_display (); diff --git a/vapi/atk-bridge-2.0.vapi b/vapi/atk-bridge-2.0.vapi new file mode 100644 index 00000000..5ab6bfca --- /dev/null +++ b/vapi/atk-bridge-2.0.vapi @@ -0,0 +1,6 @@ +[CCode (lower_case_cprefix = "atk_bridge_")] +namespace AtkBridge { + public static int adaptor_init (int argc, char[] argv); + public static void adaptor_cleanup (); + public static void set_event_context (GLib.MainContext cnx); +}