Skip to content

Commit 0725070

Browse files
authored
mcpplibs.mwrap.accesskit 0.23.1: accesskit-m (AccessKit's C bindings as a C++23 module) (#644)
Descriptor pkgs/mwrap/accesskit.lua (the immutable mwrap-0.23.1 release asset), consumer tests/mwrap/accesskit-tree (a window and its button built through the module, read back, and on Linux served by an AT-SPI adapter), and the installed-template check in validate.yml. Signed-off-by: Sunrisepeak <speakshen@163.com>
1 parent 30142aa commit 0725070

5 files changed

Lines changed: 103 additions & 0 deletions

File tree

‎.github/workflows/validate.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,6 +1616,11 @@ jobs:
16161616
shell: bash
16171617
run: python3 tests/mwrap/check_installed_template.py --mcpp "$MCPP" --package mcpplibs.mwrap.md4c@0.5.3
16181618

1619+
- name: Installed accesskit wrapper archive and actual default tree template
1620+
if: contains(format(' {0} ', env.MEMBERS), ' accesskit-tree ') && matrix.toolchain == 'default'
1621+
shell: bash
1622+
run: python3 tests/mwrap/check_installed_template.py --mcpp "$MCPP" --package mcpplibs.mwrap.accesskit@0.23.1
1623+
16191624
- name: Installed Lua wrapper archive and actual default script template
16201625
if: contains(format(' {0} ', env.MEMBERS), ' lua-embed ') && matrix.toolchain == 'default'
16211626
shell: bash

‎mcpp.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ members = [
1717
"tests/mwrap/ffmpeg-cpu",
1818
"tests/mwrap/imgui-headless",
1919
"tests/mwrap/md4c-render",
20+
"tests/mwrap/accesskit-tree",
2021
"tests/mwrap/lua-embed",
2122
"tests/mwrap/quickjs-embed",
2223
"tests/mwrap/pocketpy-embed",

‎pkgs/mwrap/accesskit.lua‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
-- Immutable upstream-aligned mwrap source release (accesskit-m mwrap-0.23.1).
2+
-- The CN mirror is added by a maintainer with mcpp-res access; until then CN
3+
-- users fall back to the GitHub release (docs/cn-mirror.md).
4+
package = {
5+
spec = "1",
6+
namespace = "mcpplibs.mwrap",
7+
name = "accesskit",
8+
description = "accesskit-m: AccessKit's C bindings as a C++23 module (one accessibility tree served to UIA, NSAccessibility and AT-SPI)",
9+
licenses = { "Apache-2.0" },
10+
repo = "https://github.com/mcpplibs/accesskit-m",
11+
type = "package",
12+
extensions = {
13+
autoupdate = {
14+
tag = "mwrap-${version}",
15+
url = "https://github.com/mcpplibs/accesskit-m/releases/download/${tag}/accesskit-m-${version}.tar.gz",
16+
},
17+
},
18+
xpm = {
19+
linux = {
20+
["0.23.1"] = {
21+
url = "https://github.com/mcpplibs/accesskit-m/releases/download/mwrap-0.23.1/accesskit-m-0.23.1.tar.gz",
22+
sha256 = "799928a7914f3eef7808f358f6bd14c8b18b141e0cd4f34eff99ea8b282fe893",
23+
},
24+
},
25+
macosx = {
26+
["0.23.1"] = {
27+
url = "https://github.com/mcpplibs/accesskit-m/releases/download/mwrap-0.23.1/accesskit-m-0.23.1.tar.gz",
28+
sha256 = "799928a7914f3eef7808f358f6bd14c8b18b141e0cd4f34eff99ea8b282fe893",
29+
},
30+
},
31+
windows = {
32+
["0.23.1"] = {
33+
url = "https://github.com/mcpplibs/accesskit-m/releases/download/mwrap-0.23.1/accesskit-m-0.23.1.tar.gz",
34+
sha256 = "799928a7914f3eef7808f358f6bd14c8b18b141e0cd4f34eff99ea8b282fe893",
35+
},
36+
},
37+
},
38+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "accesskit-tree"
3+
version = "0.23.1"
4+
description = "Consume the immutable accesskit wrapper: build a tree update through the module and read it back"
5+
6+
[indices]
7+
# Use the complete candidate built-in index prepared by tests/run_members.sh.
8+
# An explicit empty table overrides the legacy workspace redirect.
9+
10+
[dependencies]
11+
"mcpplibs.mwrap.accesskit" = "0.23.1"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Through the module: a window holding a button built, read back through the
2+
// library's debug view, and on Linux served by an AT-SPI adapter. The names
3+
// are AccessKit's own (no namespace of this package's).
4+
import std;
5+
import mcpplibs.mwrap.accesskit;
6+
7+
namespace {
8+
9+
accesskit_tree_update* tree(void*) {
10+
accesskit_node* window = accesskit_node_new(ACCESSKIT_ROLE_WINDOW);
11+
accesskit_node_set_label(window, "Settings");
12+
accesskit_node_push_child(window, 2);
13+
accesskit_node* button = accesskit_node_new(ACCESSKIT_ROLE_BUTTON);
14+
accesskit_node_set_label(button, "Save");
15+
accesskit_node_add_action(button, ACCESSKIT_ACTION_CLICK);
16+
accesskit_node_set_toggled(button, ACCESSKIT_TOGGLED_FALSE);
17+
accesskit_tree_update* update = accesskit_tree_update_with_capacity_and_focus(2, 2);
18+
accesskit_tree_update_set_tree_info(update, accesskit_tree_info_new(1));
19+
accesskit_tree_update_push_node(update, 1, window);
20+
accesskit_tree_update_push_node(update, 2, button);
21+
return update;
22+
}
23+
24+
} // namespace
25+
26+
int main() {
27+
accesskit_tree_update* update = tree(nullptr);
28+
char* debug = accesskit_tree_update_debug(update);
29+
const bool named = debug && std::string_view(debug).contains("Save") && std::string_view(debug).contains("Settings");
30+
if (debug) accesskit_string_free(debug);
31+
accesskit_tree_update_free(update);
32+
if (!named) {
33+
std::println(std::cerr, "the update does not hold the window and its button");
34+
return 1;
35+
}
36+
#if defined(__linux__)
37+
accesskit_unix_adapter* adapter = accesskit_unix_adapter_new(
38+
tree, nullptr, [](accesskit_action_request* r, void*) { accesskit_action_request_free(r); }, nullptr, [](void*) {}, nullptr);
39+
if (!adapter) {
40+
std::println(std::cerr, "no AT-SPI adapter");
41+
return 1;
42+
}
43+
accesskit_unix_adapter_update_window_focus_state(adapter, true);
44+
accesskit_unix_adapter_free(adapter);
45+
#endif
46+
std::println("accesskit through its module: a window and its button");
47+
return 0;
48+
}

0 commit comments

Comments
 (0)