Skip to content

Commit

Permalink
WindowSwitcher: set accessible properties (#2030)
Browse files Browse the repository at this point in the history
  • Loading branch information
lenemter committed Aug 20, 2024
1 parent 70e4642 commit be8b8a3
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/Widgets/WindowSwitcher/WindowSwitcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down Expand Up @@ -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,
Expand All @@ -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 () {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 ();
Expand Down
7 changes: 7 additions & 0 deletions src/Widgets/WindowSwitcher/WindowSwitcherIcon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
11 changes: 11 additions & 0 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ namespace Gala {

show_stage ();

init_a11y ();

AccessDialog.watch_portal ();

unowned Meta.Display display = get_display ();
Expand Down Expand Up @@ -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 ();

Expand Down
6 changes: 6 additions & 0 deletions vapi/atk-bridge-2.0.vapi
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit be8b8a3

Please sign in to comment.