From e99f157740660e6ef28f1bba7560cb9d52d5d1ad Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Tue, 30 May 2023 10:39:01 +0200 Subject: windows: Fix UI accessibility (#704) Use real frames for a semantic UI so GTK and screen readers can set up and figure out accessibility relationships between the frame label and the content automatically. Also properly add relationships between the movement keys descriptive label and the key radio items so a screen reader can pick it up. As a bonus, it also prevents Orca from erroneously announcing the label when the window comes up because it thinks this long orphaned label is probably a general description for the window. Fixes #703. --- capplets/windows/mate-window-properties.c | 22 +++ capplets/windows/window-properties.ui | 306 +++++++++++------------------- 2 files changed, 135 insertions(+), 193 deletions(-) (limited to 'capplets/windows') diff --git a/capplets/windows/mate-window-properties.c b/capplets/windows/mate-window-properties.c index 9757c42c..ccccb03c 100644 --- a/capplets/windows/mate-window-properties.c +++ b/capplets/windows/mate-window-properties.c @@ -113,6 +113,7 @@ static GtkWidget *focus_mode_mouse_checkbutton; static GtkWidget *autoraise_checkbutton; static GtkWidget *autoraise_delay_spinbutton; static GtkWidget *autoraise_delay_hbox; +static GtkWidget *movement_description_label; static GtkWidget *alt_click_vbox; /* Placement */ @@ -402,6 +403,7 @@ main (int argc, char **argv) autoraise_delay_hbox = GET_WIDGET ("autoraise_delay_hbox"); autoraise_checkbutton = GET_WIDGET ("autoraise_checkbutton"); autoraise_delay_spinbutton = GET_WIDGET ("autoraise_delay_spinbutton"); + movement_description_label = GET_WIDGET ("movement_description_label"); alt_click_vbox = GET_WIDGET ("alt_click_vbox"); /* Placement */ @@ -543,6 +545,7 @@ reload_mouse_modifiers (void) gboolean have_super; int min_keycode, max_keycode; int mod_meta, mod_super, mod_hyper; + AtkObject *label_accessible; XDisplayKeycodes (gdk_x11_display_get_xdisplay(gdk_display_get_default()), &min_keycode, @@ -655,4 +658,23 @@ reload_mouse_modifiers (void) fill_radio (i == 0 ? NULL : GTK_RADIO_BUTTON (mouse_modifiers[i-1].radio), &mouse_modifiers[i]); ++i; } + + /* set up accessibility relationships between the main label and each + * radio button, because GTK doesn't do it for us (usually, it expects the + * label of the radio button to be enough, but our case is better served + * with associating the main label as well). */ + label_accessible = gtk_widget_get_accessible (movement_description_label); + if (ATK_IS_OBJECT (label_accessible)) { + for (i = 0; i < n_mouse_modifiers; i++) { + AtkObject *radio_accessible = gtk_widget_get_accessible (mouse_modifiers[i].radio); + if (ATK_IS_OBJECT (radio_accessible)) { + atk_object_add_relationship (label_accessible, + ATK_RELATION_LABEL_FOR, + radio_accessible); + atk_object_add_relationship (radio_accessible, + ATK_RELATION_LABELLED_BY, + label_accessible); + } + } + } } diff --git a/capplets/windows/window-properties.ui b/capplets/windows/window-properties.ui index b4035d36..140ab21b 100644 --- a/capplets/windows/window-properties.ui +++ b/capplets/windows/window-properties.ui @@ -1,5 +1,5 @@ -