diff options
27 files changed, 77 insertions, 54 deletions
diff --git a/docs/reference/gtk/running.md b/docs/reference/gtk/running.md index d0da90a5df..2b338bd148 100644 --- a/docs/reference/gtk/running.md +++ b/docs/reference/gtk/running.md @@ -293,6 +293,24 @@ CSD is always used for windows with a custom titlebar widget set, as the WM should not draw another titlebar or other decorations around the custom one. +### GTK_A11Y + +If set, selects the accessibility backend to use. The following +backends can be selected, provided they are included in the GTK +library you are using: + +help + : Prints information about available options +atspi + : Selects the AT-SPI accessibility backend +test + : Selects the test backend +none + : Disables the accessibility backend + +The `test` accessibility backend is recommended for test suites and remote +continuous integration pipelines. + ### XDG_DTA_HOME, XDG_DATA_DIRS GTK uses these environment variables to locate icon themes diff --git a/gtk/gtkatcontext.c b/gtk/gtkatcontext.c index 96b466a87e..afdf478067 100644 --- a/gtk/gtkatcontext.c +++ b/gtk/gtkatcontext.c @@ -448,17 +448,19 @@ gtk_at_context_get_display (GtkATContext *self) static const struct { const char *name; + const char *env_name; GtkATContext * (* create_context) (GtkAccessibleRole accessible_role, GtkAccessible *accessible, GdkDisplay *display); } a11y_backends[] = { #if defined(GDK_WINDOWING_WAYLAND) - { "AT-SPI (Wayland)", gtk_at_spi_create_context }, + { "AT-SPI (Wayland)", "atspi", gtk_at_spi_create_context }, #endif #if defined(GDK_WINDOWING_X11) - { "AT-SPI (X11)", gtk_at_spi_create_context }, + { "AT-SPI (X11)", "atspi", gtk_at_spi_create_context }, #endif - { NULL, NULL }, + { "Test", "test", gtk_test_at_context_new }, + { NULL, NULL, NULL }, }; /** @@ -480,36 +482,32 @@ gtk_at_context_create (GtkAccessibleRole accessible_role, GtkAccessible *accessible, GdkDisplay *display) { - static const char *gtk_test_accessible; - static const char *gtk_no_a11y; + static const char *gtk_a11y_env; - if (G_UNLIKELY (gtk_test_accessible == NULL)) + if (gtk_a11y_env == NULL) { - const char *env = g_getenv ("GTK_TEST_ACCESSIBLE"); - - if (env != NULL && *env !='\0') - gtk_test_accessible = "1"; - else - gtk_test_accessible = "0"; + gtk_a11y_env = g_getenv ("GTK_A11Y"); + if (gtk_a11y_env == NULL) + gtk_a11y_env = "0"; } - if (G_UNLIKELY (gtk_no_a11y == NULL)) + /* Short-circuit disabling the accessibility support */ + if (g_ascii_strcasecmp (gtk_a11y_env, "none") == 0) + return NULL; + + if (g_ascii_strcasecmp (gtk_a11y_env, "help") == 0) { - const char *env = g_getenv ("GTK_NO_A11Y"); + g_print ("Supported arguments for GTK_A11Y environment variable:\n"); - if (env != NULL && *env != '\0') - gtk_no_a11y = "1"; - else - gtk_no_a11y = "0"; +#if defined(GDK_WINDOWING_X11) || defined(GDK_WINDOWING_WAYLAND) + g_print (" atspi - Use the AT-SPI accessibility backend\n"); +#endif + g_print (" test - Use the test accessibility backend\n"); + g_print (" none - Disable the accessibility backend\n"); + g_print (" help - Print this help\n\n"); + g_print ("Other arguments will cause a warning and be ignored.\n"); } - /* Shortcut everything if we're running with the test AT context */ - if (gtk_test_accessible[0] == '1') - return gtk_test_at_context_new (accessible_role, accessible); - - if (gtk_no_a11y[0] == '1') - return NULL; - GtkATContext *res = NULL; for (guint i = 0; i < G_N_ELEMENTS (a11y_backends); i++) @@ -517,7 +515,8 @@ gtk_at_context_create (GtkAccessibleRole accessible_role, if (a11y_backends[i].name == NULL) break; - if (a11y_backends[i].create_context != NULL) + if (a11y_backends[i].create_context != NULL && + (*gtk_a11y_env == '0' || g_ascii_strcasecmp (a11y_backends[i].env_name, gtk_a11y_env) == 0)) { res = a11y_backends[i].create_context (accessible_role, accessible, display); if (res != NULL) @@ -525,6 +524,9 @@ gtk_at_context_create (GtkAccessibleRole accessible_role, } } + if (*gtk_a11y_env != '0' && res == NULL) + g_warning ("Unrecognized accessibility backend \"%s\". Try GTK_A11Y=help", gtk_a11y_env); + /* Fall back to the test context, so we can get debugging data */ if (res == NULL) res = g_object_new (GTK_TYPE_TEST_AT_CONTEXT, @@ -533,7 +535,6 @@ gtk_at_context_create (GtkAccessibleRole accessible_role, "display", display, NULL); - /* FIXME: Add GIOExtension for AT contexts */ return res; } diff --git a/gtk/gtktestatcontext.c b/gtk/gtktestatcontext.c index fdcd7fcc9e..4812bc38ae 100644 --- a/gtk/gtktestatcontext.c +++ b/gtk/gtktestatcontext.c @@ -95,6 +95,7 @@ gtk_test_at_context_init (GtkTestATContext *self) * gtk_test_at_context_new: * @accessible_role: the #GtkAccessibleRole for the AT context * @accessible: the #GtkAccessible instance which owns the AT context + * @display: a #GdkDisplay * * Creates a new #GtkTestATContext instance for @accessible, using the * given @accessible_role. @@ -103,11 +104,13 @@ gtk_test_at_context_init (GtkTestATContext *self) */ GtkATContext * gtk_test_at_context_new (GtkAccessibleRole accessible_role, - GtkAccessible *accessible) + GtkAccessible *accessible, + GdkDisplay *display) { return g_object_new (GTK_TYPE_TEST_AT_CONTEXT, "accessible-role", accessible_role, "accessible", accessible, + "display", display, NULL); } diff --git a/gtk/gtktestatcontextprivate.h b/gtk/gtktestatcontextprivate.h index edafb76c4c..ae464ea266 100644 --- a/gtk/gtktestatcontextprivate.h +++ b/gtk/gtktestatcontextprivate.h @@ -31,6 +31,7 @@ G_DECLARE_FINAL_TYPE (GtkTestATContext, gtk_test_at_context, GTK, TEST_AT_CONTEX GtkATContext * gtk_test_at_context_new (GtkAccessibleRole accessible_role, - GtkAccessible *accessible); + GtkAccessible *accessible, + GdkDisplay *display); G_END_DECLS diff --git a/testsuite/a11y/meson.build b/testsuite/a11y/meson.build index 8ebfd032cd..a431d3ab2b 100644 --- a/testsuite/a11y/meson.build +++ b/testsuite/a11y/meson.build @@ -50,7 +50,7 @@ foreach flag: common_cflags endforeach test_env = environment() -test_env.set('GTK_TEST_ACCESSIBLE', '1') +test_env.set('GTK_A11Y', 'test') test_env.set('GSK_RENDERER', 'cairo') test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) diff --git a/testsuite/css/api.test.in b/testsuite/css/api.test.in index d1d25a1bc1..a55d3a4e0d 100644 --- a/testsuite/css/api.test.in +++ b/testsuite/css/api.test.in @@ -1,4 +1,4 @@ [Test] -Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_TEST_ACCESSIBLE=1 @libexecdir@/installed-tests/gtk-4.0/css/api --tap -k" +Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @libexecdir@/installed-tests/gtk-4.0/css/api --tap -k" Type=session Output=TAP diff --git a/testsuite/css/change/change.test.in b/testsuite/css/change/change.test.in index 9906e9f95b..207c98ba2a 100644 --- a/testsuite/css/change/change.test.in +++ b/testsuite/css/change/change.test.in @@ -1,4 +1,4 @@ [Test] -Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_TEST_ACCESSIBLE=1 @libexecdir@/installed-tests/gtk-4.0/css/change/test-css-change --tap -k" +Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @libexecdir@/installed-tests/gtk-4.0/css/change/test-css-change --tap -k" Type=session Output=TAP diff --git a/testsuite/css/change/meson.build b/testsuite/css/change/meson.build index a52fc5348e..01a6829fbd 100644 --- a/testsuite/css/change/meson.build +++ b/testsuite/css/change/meson.build @@ -1,5 +1,5 @@ changetest_env = environment() -changetest_env.set('GTK_TEST_ACCESSIBLE', '1') +changetest_env.set('GTK_A11Y', 'test') changetest_env.set('GSK_RENDERER', 'cairo') changetest_env.set('G_TEST_SRCDIR', meson.current_source_dir()) changetest_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) diff --git a/testsuite/css/meson.build b/testsuite/css/meson.build index 931502bef7..525de29652 100644 --- a/testsuite/css/meson.build +++ b/testsuite/css/meson.build @@ -1,5 +1,5 @@ csstest_env = environment() -csstest_env.set('GTK_TEST_ACCESSIBLE', '1') +csstest_env.set('GTK_A11Y', 'test') csstest_env.set('GSK_RENDERER', 'cairo') csstest_env.set('G_TEST_SRCDIR', meson.current_source_dir()) csstest_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) diff --git a/testsuite/css/nodes/meson.build b/testsuite/css/nodes/meson.build index 313e06a112..97a739f1b3 100644 --- a/testsuite/css/nodes/meson.build +++ b/testsuite/css/nodes/meson.build @@ -1,5 +1,5 @@ nodetest_env = environment() -nodetest_env.set('GTK_TEST_ACCESSIBLE', '1') +nodetest_env.set('GTK_A11Y', 'test') nodetest_env.set('GSK_RENDERER', 'cairo') nodetest_env.set('G_TEST_SRCDIR', meson.current_source_dir()) nodetest_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) diff --git a/testsuite/css/nodes/nodes.test.in b/testsuite/css/nodes/nodes.test.in index e662b746b6..e3f5f0d3cf 100644 --- a/testsuite/css/nodes/nodes.test.in +++ b/testsuite/css/nodes/nodes.test.in @@ -1,4 +1,4 @@ [Test] -Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_TEST_ACCESSIBLE=1 @libexecdir@/installed-tests/gtk-4.0/css/nodes/test-css-nodes --tap -k" +Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @libexecdir@/installed-tests/gtk-4.0/css/nodes/test-css-nodes --tap -k" Type=session Output=TAP diff --git a/testsuite/css/parser/parser.test.in b/testsuite/css/parser/parser.test.in index 91bb6d20f6..91d1dbdfa6 100644 --- a/testsuite/css/parser/parser.test.in +++ b/testsuite/css/parser/parser.test.in @@ -1,4 +1,4 @@ [Test] -Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_TEST_ACCESSIBLE=1 @libexecdir@/installed-tests/gtk-4.0/css/parser/test-css-parser --tap -k" +Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @libexecdir@/installed-tests/gtk-4.0/css/parser/test-css-parser --tap -k" Type=session Output=TAP diff --git a/testsuite/css/style/meson.build b/testsuite/css/style/meson.build index a7af27deb3..4026c5f3be 100644 --- a/testsuite/css/style/meson.build +++ b/testsuite/css/style/meson.build @@ -1,5 +1,5 @@ styletest_env = environment() -styletest_env.set('GTK_TEST_ACCESSIBLE', '1') +styletest_env.set('GTK_A11Y', 'test') styletest_env.set('GSK_RENDERER', 'cairo') styletest_env.set('G_TEST_SRCDIR', meson.current_source_dir()) styletest_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) diff --git a/testsuite/css/style/style.test.in b/testsuite/css/style/style.test.in index 6cce32a0a0..edfb555e82 100644 --- a/testsuite/css/style/style.test.in +++ b/testsuite/css/style/style.test.in @@ -1,4 +1,4 @@ [Test] -Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_TEST_ACCESSIBLE=1 @libexecdir@/installed-tests/gtk-4.0/css/style/test-css-style --tap -k" +Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @libexecdir@/installed-tests/gtk-4.0/css/style/test-css-style --tap -k" Type=session Output=TAP diff --git a/testsuite/gdk/gdk.test.in b/testsuite/gdk/gdk.test.in index ad90aa61ed..9784de8542 100644 --- a/testsuite/gdk/gdk.test.in +++ b/testsuite/gdk/gdk.test.in @@ -1,4 +1,4 @@ [Test] -Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_TEST_ACCESSIBLE=1 @testexecdir@/@test@ --tap -k --verbose" +Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @testexecdir@/@test@ --tap -k --verbose" Type=session Output=TAP diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build index 07b2d05955..0fe09619c8 100644 --- a/testsuite/gsk/meson.build +++ b/testsuite/gsk/meson.build @@ -101,7 +101,7 @@ foreach renderer : renderers join_paths(meson.current_source_dir(), 'compare', test + '.png')], env: [ 'GSK_RENDERER=' + renderer[0], - 'GTK_TEST_ACCESSIBLE=1', + 'GTK_A11Y=test', 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) ], @@ -179,7 +179,7 @@ foreach test : node_parser_tests ], env: [ 'GSK_RENDERER=opengl', - 'GTK_TEST_ACCESSIBLE=1', + 'GTK_A11Y=test', 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) ], @@ -213,7 +213,7 @@ foreach t : tests protocol: 'tap', env: [ 'GSK_RENDERER=cairo', - 'GTK_TEST_ACCESSIBLE=1', + 'GTK_A11Y=test', 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) ], diff --git a/testsuite/gsk/render-nodes-cairo.test.in b/testsuite/gsk/render-nodes-cairo.test.in index 8976ff03d8..8498a2909a 100644 --- a/testsuite/gsk/render-nodes-cairo.test.in +++ b/testsuite/gsk/render-nodes-cairo.test.in @@ -1,4 +1,4 @@ [Test] -Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GSK_RENDERER=cairo GTK_TEST_ACCESSIBLE=1 @libexecdir@/installed-tests/gtk-4.0/gsk/test-render-nodes --tap -k --verbose" +Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GSK_RENDERER=cairo GTK_A11Y=test @libexecdir@/installed-tests/gtk-4.0/gsk/test-render-nodes --tap -k --verbose" Type=session Output=TAP diff --git a/testsuite/gsk/render-nodes-vulkan.test.in b/testsuite/gsk/render-nodes-vulkan.test.in index 4ad9523ed4..f1b17ff4ef 100644 --- a/testsuite/gsk/render-nodes-vulkan.test.in +++ b/testsuite/gsk/render-nodes-vulkan.test.in @@ -1,4 +1,4 @@ [Test] -Exec=/bin/sh -c "env GTK_TEST_ACCESSIBLE=1 GSK_RENDERER=vulkan @libexecdir@/installed-tests/gtk-4.0/gsk/test-render-nodes --tap -k --verbose" +Exec=/bin/sh -c "env GTK_A11Y=test GSK_RENDERER=vulkan @libexecdir@/installed-tests/gtk-4.0/gsk/test-render-nodes --tap -k --verbose" Type=session Output=TAP diff --git a/testsuite/gtk/gtk.test.in b/testsuite/gtk/gtk.test.in index ad90aa61ed..9784de8542 100644 --- a/testsuite/gtk/gtk.test.in +++ b/testsuite/gtk/gtk.test.in @@ -1,4 +1,4 @@ [Test] -Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_TEST_ACCESSIBLE=1 @testexecdir@/@test@ --tap -k --verbose" +Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @testexecdir@/@test@ --tap -k --verbose" Type=session Output=TAP diff --git a/testsuite/gtk/meson.build b/testsuite/gtk/meson.build index 6b973c1d9b..1b58238665 100644 --- a/testsuite/gtk/meson.build +++ b/testsuite/gtk/meson.build @@ -147,7 +147,7 @@ is_debug = get_option('buildtype').startswith('debug') test_cargs = [] test_env = environment() -test_env.set('GTK_TEST_ACCESSIBLE', '1') +test_env.set('GTK_A11Y', 'test') test_env.set('GSK_RENDERER', 'cairo') test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) diff --git a/testsuite/reftests/meson.build b/testsuite/reftests/meson.build index da1edd67c8..8df36fab93 100644 --- a/testsuite/reftests/meson.build +++ b/testsuite/reftests/meson.build @@ -451,7 +451,7 @@ xfails = [ ] reftest_env = environment() -reftest_env.set('GTK_TEST_ACCESSIBLE', '1') +reftest_env.set('GTK_A11Y', 'test') reftest_env.set('GSK_RENDERER', 'opengl') reftest_env.set('G_TEST_SRCDIR', meson.current_source_dir()) reftest_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) diff --git a/testsuite/reftests/reftests-dark.test.in b/testsuite/reftests/reftests-dark.test.in index d30a4f2099..f461521bf6 100644 --- a/testsuite/reftests/reftests-dark.test.in +++ b/testsuite/reftests/reftests-dark.test.in @@ -1,4 +1,4 @@ [Test] -Exec=/bin/sh -c "env GTK_THEME=Adwaita:dark GTK_TEST_ACCESSIBLE=1 G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests" +Exec=/bin/sh -c "env GTK_THEME=Adwaita:dark GTK_A11Y=test G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests" Type=session-exclusive Output=TAP diff --git a/testsuite/reftests/reftests-hc.test.in b/testsuite/reftests/reftests-hc.test.in index 88627b7ae4..000ff96570 100644 --- a/testsuite/reftests/reftests-hc.test.in +++ b/testsuite/reftests/reftests-hc.test.in @@ -1,4 +1,4 @@ [Test] -Exec=/bin/sh -c "env GTK_THEME=HighContrast GTK_TEST_ACCESSIBLE=1 G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests" +Exec=/bin/sh -c "env GTK_THEME=HighContrast GTK_A11Y=test G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests" Type=session-exclusive Output=TAP diff --git a/testsuite/reftests/reftests-hci.test.in b/testsuite/reftests/reftests-hci.test.in index 24e785551c..887862a9a8 100644 --- a/testsuite/reftests/reftests-hci.test.in +++ b/testsuite/reftests/reftests-hci.test.in @@ -1,4 +1,4 @@ [Test] -Exec=/bin/sh -c "env GTK_THEME=HighContrastInverse GTK_TEST_ACCESSIBLE=1 G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests" +Exec=/bin/sh -c "env GTK_THEME=HighContrastInverse GTK_A11Y=test G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests" Type=session-exclusive Output=TAP diff --git a/testsuite/reftests/reftests.test.in b/testsuite/reftests/reftests.test.in index 53971961d6..d2f199f097 100644 --- a/testsuite/reftests/reftests.test.in +++ b/testsuite/reftests/reftests.test.in @@ -1,4 +1,4 @@ [Test] -Exec=/bin/sh -c "env GTK_TEST_ACCESSIBLE=1 G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests" +Exec=/bin/sh -c "env GTK_A11Y=test G_ENABLE_DIAGNOSTIC=0 @libexecdir@/installed-tests/gtk-4.0/gtk-reftest -k --verbose --tap --output $(pwd) --directory @libexecdir@/installed-tests/gtk-4.0/reftests" Type=session-exclusive Output=TAP diff --git a/testsuite/tools/meson.build b/testsuite/tools/meson.build index 54b9312e7a..ad59b43245 100644 --- a/testsuite/tools/meson.build +++ b/testsuite/tools/meson.build @@ -23,7 +23,7 @@ if bash.found() env: [ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), - 'GTK_TEST_ACCESSIBLE=1', + 'GTK_A11Y=test', 'GTK_BUILDER_TOOL=@0@'.format(get_variable('gtk4_builder_tool').full_path()), 'GTK_QUERY_SETTINGS=@0@'.format(get_variable('gtk4_query_settings').full_path()) ], diff --git a/testsuite/tools/tools.test.in b/testsuite/tools/tools.test.in index d0f3810a44..2ded62665c 100644 --- a/testsuite/tools/tools.test.in +++ b/testsuite/tools/tools.test.in @@ -1,4 +1,4 @@ [Test] -Exec=/bin/sh -c "env GTK_TEST_ACCESSIBLE=1 G_ENABLE_DIAGNOSTIC=0 TEST_DATA_DIR=@testexecdir@/@test@-data @testexecdir@/@test@" +Exec=/bin/sh -c "env GTK_A11Y=test G_ENABLE_DIAGNOSTIC=0 TEST_DATA_DIR=@testexecdir@/@test@-data @testexecdir@/@test@" Type=session Output=TAP |