WindowSwitcher: set accessible properties (#2030)

This commit is contained in:
Leo 2024-08-21 04:59:52 +09:00 committed by GitHub
parent 70e4642f89
commit be8b8a3a60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 35 additions and 2 deletions

View File

@ -31,7 +31,7 @@ jobs:
- name: Install Dependencies - name: Install Dependencies
run: | run: |
apt update 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 - name: Build
env: env:
DESTDIR: out DESTDIR: out

View File

@ -13,6 +13,7 @@ basic_command = [
'--package-version', '0.0.0', '--package-version', '0.0.0',
'--driver', vala.version(), '--driver', vala.version(),
mutter_packages_command, mutter_packages_command,
'--pkg', 'atk-bridge-2.0',
'--pkg', 'gnome-desktop-3.0', '--pkg', 'gnome-desktop-3.0',
'--pkg', 'gtk+-3.0', '--pkg', 'gtk+-3.0',
'--pkg', 'gee-0.8', '--pkg', 'gee-0.8',

View File

@ -79,6 +79,7 @@ add_project_arguments([
glib_version_required = '2.74.0' glib_version_required = '2.74.0'
gtk_version_required = '3.10.0' gtk_version_required = '3.10.0'
atk_bridge_dep = dependency('atk-bridge-2.0')
canberra_dep = dependency('libcanberra') canberra_dep = dependency('libcanberra')
glib_dep = dependency('glib-2.0', version: '>= @0@'.format(glib_version_required)) glib_dep = dependency('glib-2.0', version: '>= @0@'.format(glib_version_required))
gobject_dep = dependency('gobject-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_arguments(vala_flags, language: 'vala')
add_project_link_arguments(['-Wl,-rpath,@0@'.format(mutter_typelib_dir)], language: 'c') 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') if get_option('systemd')
gala_base_dep += systemd_dep gala_base_dep += systemd_dep

View File

@ -42,6 +42,7 @@ public class Gala.WindowSwitcher : CanvasActor {
_current_icon = value; _current_icon = value;
if (_current_icon != null) { if (_current_icon != null) {
_current_icon.selected = true; _current_icon.selected = true;
_current_icon.grab_key_focus ();
} }
update_caption_text (); update_caption_text ();
@ -69,6 +70,9 @@ public class Gala.WindowSwitcher : CanvasActor {
#endif #endif
}; };
get_accessible ().accessible_name = _("Window switcher");
container.get_accessible ().accessible_role = LIST;
caption = new Clutter.Text () { caption = new Clutter.Text () {
font_name = CAPTION_FONT_NAME, font_name = CAPTION_FONT_NAME,
ellipsize = END, ellipsize = END,
@ -78,6 +82,7 @@ public class Gala.WindowSwitcher : CanvasActor {
add_child (container); add_child (container);
add_child (caption); add_child (caption);
reactive = true;
visible = false; visible = false;
opacity = 0; opacity = 0;
layout_manager = new Clutter.BoxLayout () { layout_manager = new Clutter.BoxLayout () {
@ -355,6 +360,7 @@ public class Gala.WindowSwitcher : CanvasActor {
private void add_icon (WindowSwitcherIcon icon) { private void add_icon (WindowSwitcherIcon icon) {
container.add_child (icon); container.add_child (icon);
icon.get_accessible ().accessible_parent = container.get_accessible ();
icon.motion_event.connect ((_icon, event) => { icon.motion_event.connect ((_icon, event) => {
if (current_icon != _icon && !handling_gesture) { if (current_icon != _icon && !handling_gesture) {
@ -404,6 +410,7 @@ public class Gala.WindowSwitcher : CanvasActor {
push_modal (); push_modal ();
} else { } else {
wm.pop_modal (modal_proxy); wm.pop_modal (modal_proxy);
get_stage ().set_key_focus (null);
} }
save_easing_state (); save_easing_state ();

View File

@ -40,6 +40,10 @@ public class Gala.WindowSwitcherIcon : CanvasActor {
icon.add_constraint (new Clutter.AlignConstraint (this, Clutter.AlignAxis.BOTH, 0.5f)); icon.add_constraint (new Clutter.AlignConstraint (this, Clutter.AlignAxis.BOTH, 0.5f));
add_child (icon); 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; reactive = true;
this.scale_factor = scale_factor; this.scale_factor = scale_factor;
@ -76,5 +80,8 @@ public class Gala.WindowSwitcherIcon : CanvasActor {
ctx.restore (); ctx.restore ();
} }
get_accessible ().notify_state_change (Atk.StateType.SELECTED, selected);
get_accessible ().notify_state_change (Atk.StateType.FOCUSED, selected);
} }
} }

View File

@ -149,6 +149,8 @@ namespace Gala {
show_stage (); show_stage ();
init_a11y ();
AccessDialog.watch_portal (); AccessDialog.watch_portal ();
unowned Meta.Display display = get_display (); 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 () { private void update_ui_group_size () {
unowned var display = get_display (); unowned var display = get_display ();

6
vapi/atk-bridge-2.0.vapi Normal file
View File

@ -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);
}