diff --git a/.clang-format b/.clang-format deleted file mode 100644 index aeb5bb20..00000000 --- a/.clang-format +++ /dev/null @@ -1,200 +0,0 @@ ---- -Language: Cpp -# BasedOnStyle: Google -AccessModifierOffset: -1 -AlignAfterOpenBracket: Align -AlignConsecutiveMacros: None -AlignConsecutiveAssignments: None -AlignConsecutiveBitFields: None -AlignConsecutiveDeclarations: None -AlignEscapedNewlines: Left -AlignOperands: Align -AlignTrailingComments: true -AllowAllArgumentsOnNextLine: true -AllowAllConstructorInitializersOnNextLine: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortEnumsOnASingleLine: true -AllowShortBlocksOnASingleLine: Never -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: All -AllowShortLambdasOnASingleLine: All -AllowShortIfStatementsOnASingleLine: WithoutElse -AllowShortLoopsOnASingleLine: true -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: true -AlwaysBreakTemplateDeclarations: Yes -AttributeMacros: - - __capability -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterCaseLabel: false - AfterClass: false - AfterControlStatement: Never - AfterEnum: false - AfterFunction: false - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - BeforeCatch: false - BeforeElse: false - BeforeLambdaBody: false - BeforeWhile: false - IndentBraces: false - SplitEmptyFunction: true - SplitEmptyRecord: true - SplitEmptyNamespace: true -BreakBeforeBinaryOperators: None -BreakBeforeConceptDeclarations: true -BreakBeforeBraces: Attach -BreakBeforeInheritanceComma: false -BreakInheritanceList: BeforeColon -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeColon -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: true -ColumnLimit: 80 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: true -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DeriveLineEnding: true -DerivePointerAlignment: true -DisableFormat: false -EmptyLineBeforeAccessModifier: LogicalBlock -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: true -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH -StatementAttributeLikeMacros: - - Q_EMIT -IncludeBlocks: Regroup -IncludeCategories: - - Regex: '^' - Priority: 2 - SortPriority: 0 - CaseSensitive: false - - Regex: '^<.*\.h>' - Priority: 1 - SortPriority: 0 - CaseSensitive: false - - Regex: '^<.*' - Priority: 2 - SortPriority: 0 - CaseSensitive: false - - Regex: '.*' - Priority: 3 - SortPriority: 0 - CaseSensitive: false -IncludeIsMainRegex: '([-_](test|unittest))?$' -IncludeIsMainSourceRegex: '' -IndentCaseLabels: true -IndentCaseBlocks: false -IndentGotoLabels: true -IndentPPDirectives: None -IndentExternBlock: AfterExternBlock -IndentRequires: false -IndentWidth: 2 -IndentWrappedFunctionNames: false -InsertTrailingCommas: None -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: false -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBinPackProtocolList: Never -ObjCBlockIndentWidth: 2 -ObjCBreakBeforeNestedBlockParam: true -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 1 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyBreakTemplateDeclaration: 10 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 200 -PenaltyIndentedWhitespace: 0 -PointerAlignment: Left -RawStringFormats: - - Language: Cpp - Delimiters: - - cc - - CC - - cpp - - Cpp - - CPP - - 'c++' - - 'C++' - CanonicalDelimiter: '' - BasedOnStyle: google - - Language: TextProto - Delimiters: - - pb - - PB - - proto - - PROTO - EnclosingFunctions: - - EqualsProto - - EquivToProto - - PARSE_PARTIAL_TEXT_PROTO - - PARSE_TEST_PROTO - - PARSE_TEXT_PROTO - - ParseTextOrDie - - ParseTextProtoOrDie - - ParseTestProto - - ParsePartialTestProto - CanonicalDelimiter: '' - BasedOnStyle: google -ReflowComments: true -SortIncludes: true -SortJavaStaticImport: Before -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCaseColon: false -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -SpaceAroundPointerQualifiers: Default -SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyBlock: false -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 2 -SpacesInAngles: false -SpacesInConditionalStatement: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -SpaceBeforeSquareBrackets: false -BitFieldColonSpacing: Both -Standard: Auto -StatementMacros: - - Q_UNUSED - - QT_REQUIRE_VERSION -TabWidth: 8 -UseCRLF: false -UseTab: Never -WhitespaceSensitiveMacros: - - STRINGIZE - - PP_STRINGIZE - - BOOST_PP_STRINGIZE - - NS_SWIFT_NAME - - CF_SWIFT_NAME -... - diff --git a/.github/workflows/c-bindings.yml b/.github/workflows/c-bindings.yml deleted file mode 100644 index cda38ee8..00000000 --- a/.github/workflows/c-bindings.yml +++ /dev/null @@ -1,103 +0,0 @@ -on: - push: - tags: - - 'accesskit_c-v*' - -name: Publish C bindings - -jobs: - build-binaries: - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: macOS-latest - target: aarch64-apple-darwin - cmake-options: -DCMAKE_OSX_ARCHITECTURES=arm64 - path: macos/arm64 - - os: macOS-latest - target: x86_64-apple-darwin - cmake-options: -DCMAKE_OSX_ARCHITECTURES=x86_64 - path: macos/x86_64 - - os: windows-2019 - target: aarch64-pc-windows-msvc - setup-step: 'cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsamd64_x86.bat" `& powershell' - cmake-options: -A ARM64 - path: windows/arm64/msvc - - os: windows-2019 - target: i686-pc-windows-msvc - setup-step: 'cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat" `& powershell' - cmake-options: -A Win32 - path: windows/x86/msvc - - os: windows-2019 - target: x86_64-pc-windows-msvc - setup-step: 'cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" `& powershell' - path: windows/x86_64/msvc - - os: ubuntu-latest - target: i686-pc-windows-gnu - setup-step: sudo apt update && sudo apt install -y mingw-w64 - cmake-options: -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=x86 -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ - path: windows/x86/mingw - - os: ubuntu-latest - target: x86_64-pc-windows-gnu - setup-step: sudo apt update && sudo apt install -y mingw-w64 - cmake-options: -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ - path: windows/x86_64/mingw - - os: ubuntu-latest - target: i686-unknown-linux-gnu - setup-step: sudo apt update && sudo apt install -y gcc-multilib g++-multilib - cmake-options: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 - path: linux/x86 - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - path: linux/x86_64 - - name: Build - steps: - - uses: actions/checkout@v4 - - - name: install stable toolchain - uses: dtolnay/rust-toolchain@master - with: - toolchain: stable - target: ${{ matrix.target }} - - - name: build libraries - run: | - ${{ matrix.setup-step || '' }} - cmake -S bindings/c -B build -DRust_CARGO_TARGET=${{ matrix.target }} ${{ matrix.cmake-options || '' }} ${{ !contains(matrix.target, 'msvc') && '-DCMAKE_BUILD_TYPE=Release' || '' }} - cmake --build build ${{ contains(matrix.target, 'msvc') && '--config Release' || '' }} - cmake --install build ${{ contains(matrix.target, 'msvc') && '--config Release' || '' }} - - - name: Upload binaries - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.target }} - path: bindings/c/lib - - publish: - needs: [build-binaries] - runs-on: ubuntu-latest - name: Publish - steps: - - uses: actions/checkout@v4 - - - uses: actions/download-artifact@v3 - with: - path: artifacts - - - run: | - mkdir -p accesskit_c/lib - cp -r artifacts/*/* accesskit_c/lib - cp -r bindings/c/examples bindings/c/include accesskit_c/ - cp bindings/c/accesskit*.cmake accesskit_c/ - cp bindings/c/*.md accesskit_c/ - cp LICENSE* accesskit_c/ - mv accesskit_c ${{ github.ref_name }} - zip -r ${{ github.ref_name }}.zip ${{ github.ref_name }} - - - uses: AButler/upload-release-assets@v2.0 - with: - files: ${{ github.ref_name }}.zip - repo-token: ${{ secrets.GITHUB_TOKEN }} - release-tag: ${{ github.ref_name }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33fd1ba0..cf31f526 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,20 +22,6 @@ jobs: - name: cargo fmt run: cargo fmt --all -- --check - - name: clang-format - uses: jidicula/clang-format-action@v4.11.0 - with: - clang-format-version: 15 - check-path: bindings/c - - - name: ruff format - uses: chartboost/ruff-action@v1 - with: - args: format --check - - - name: ruff check - uses: chartboost/ruff-action@v1 - cargo-deny: runs-on: ubuntu-22.04 steps: @@ -56,11 +42,6 @@ jobs: with: components: clippy - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.8' - - name: restore cache uses: Swatinem/rust-cache@v2 @@ -91,11 +72,6 @@ jobs: with: toolchain: ${{ needs.find-msrv.outputs.version }} - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.8' - - name: restore cache uses: Swatinem/rust-cache@v2 @@ -105,19 +81,3 @@ jobs: - name: cargo test -p accesskit_windows if: matrix.os == 'windows-2019' run: cargo test -p accesskit_windows - - check-c-header: - runs-on: ubuntu-latest - name: Check committed C header - steps: - - uses: actions/checkout@v4 - - - name: install nightly toolchain - uses: dtolnay/rust-toolchain@nightly - - - uses: dtolnay/install@master - with: - crate: cbindgen - - run: cmake -S bindings/c -B build -DACCESSKIT_BUILD_HEADERS=ON -DACCESSKIT_BUILD_LIBRARIES=OFF - - run: cmake --build build - - run: cmp build/accesskit.h bindings/c/include/accesskit.h diff --git a/.github/workflows/python-bindings.yml b/.github/workflows/python-bindings.yml deleted file mode 100644 index 2f40f313..00000000 --- a/.github/workflows/python-bindings.yml +++ /dev/null @@ -1,143 +0,0 @@ -on: - push: - tags: - - 'accesskit_python-v*' - -name: Publish Python bindings - -env: - MIN_PYTHON_VERSION: 3.8 - -jobs: - macos-wheels: - runs-on: macos-latest - strategy: - fail-fast: false - matrix: - target: [universal2-apple-darwin] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v5 - with: - python-version: ${{ env.MIN_PYTHON_VERSION }} - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.target }} - args: --release --out dist - sccache: 'true' - - name: Test wheel installation - run: | - pip install accesskit --no-index --find-links dist --force-reinstall - python -c "import accesskit" - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - name: wheels - path: dist - - linux-wheels: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - target: [x86_64, x86, aarch64, armv7] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v5 - with: - python-version: ${{ env.MIN_PYTHON_VERSION }} - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.target }} - args: --release --out dist - sccache: 'true' - manylinux: auto - - name: Test wheel installation - if: matrix.target == 'x86_64' - run: | - pip install accesskit --no-index --find-links dist --force-reinstall - python -c "import accesskit" - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - name: wheels - path: dist - - windows-wheels: - runs-on: windows-latest - strategy: - fail-fast: false - matrix: - target: [x64, x86] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v5 - with: - python-version: ${{ env.MIN_PYTHON_VERSION }} - architecture: ${{ matrix.target }} - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.target }} - args: --release --out dist - sccache: 'true' - - name: Test wheel installation - run: | - pip install accesskit --no-index --find-links dist --force-reinstall - python -c "import accesskit" - - name: Upload wheels - uses: actions/upload-artifact@v3 - with: - name: wheels - path: dist - - sdist: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Build sdist - uses: PyO3/maturin-action@v1 - with: - command: sdist - args: --out dist - - name: Upload sdist - uses: actions/upload-artifact@v3 - with: - name: wheels - path: dist - - pypi-release: - name: Publish to PyPI - environment: release - permissions: - id-token: write - if: "startsWith(github.ref, 'refs/tags/')" - needs: [macos-wheels, linux-wheels, windows-wheels, sdist] - runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v3 - with: - name: wheels - - uses: PyO3/maturin-action@v1 - with: - command: upload - args: --non-interactive --skip-existing * - - github-release: - name: Add to GitHub release - if: "startsWith(github.ref, 'refs/tags/')" - needs: [macos-wheels, linux-wheels, windows-wheels, sdist] - runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v3 - with: - name: wheels - path: dist - - - uses: AButler/upload-release-assets@v2.0 - with: - files: "dist/*" - repo-token: ${{ secrets.GITHUB_TOKEN }} - release-tag: ${{ github.ref_name }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index f65f9374..0389da4a 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -10,4 +10,3 @@ jobs: - uses: GoogleCloudPlatform/release-please-action@v3 with: command: manifest - token: ${{ secrets.RELEASE_PLEASE_TOKEN }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f17374cf..6f454f25 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1 +1 @@ -{"common":"0.16.0","consumer":"0.24.0","platforms/macos":"0.17.0","platforms/windows":"0.22.0","platforms/winit":"0.22.0","platforms/unix":"0.12.0","bindings/c":"0.12.0","bindings/python":"0.5.0","platforms/atspi-common":"0.9.0"} \ No newline at end of file +{"common":"0.16.0","consumer":"0.24.0","platforms/macos":"0.17.0","platforms/windows":"0.22.0","platforms/winit":"0.22.0","platforms/unix":"0.12.0","platforms/atspi-common":"0.9.0"} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index e31e2747..f3379731 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,17 +40,6 @@ dependencies = [ "zvariant", ] -[[package]] -name = "accesskit_c" -version = "0.12.0" -dependencies = [ - "accesskit", - "accesskit_macos", - "accesskit_unix", - "accesskit_windows", - "paste", -] - [[package]] name = "accesskit_consumer" version = "0.24.0" @@ -71,17 +60,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "accesskit_python" -version = "0.5.0" -dependencies = [ - "accesskit", - "accesskit_macos", - "accesskit_unix", - "accesskit_windows", - "pyo3", -] - [[package]] name = "accesskit_unix" version = "0.12.0" @@ -992,12 +970,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "inventory" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1be380c410bf0595e94992a648ea89db4dd3f3354ba54af206fd2a68cf5ac8e" - [[package]] name = "io-lifetimes" version = "1.0.7" @@ -1494,7 +1466,6 @@ checksum = "e82ad98ce1991c9c70c3464ba4187337b9c45fcbbb060d46dca15f0c075e14e2" dependencies = [ "cfg-if", "indoc", - "inventory", "libc", "memoffset 0.9.0", "parking_lot", diff --git a/Cargo.toml b/Cargo.toml index c4437fd9..0d0287d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,16 +8,12 @@ members = [ "platforms/unix", "platforms/windows", "platforms/winit", - "bindings/c", - "bindings/python", ] default-members = [ "common", "consumer", "platforms/atspi-common", "platforms/winit", - "bindings/c", - "bindings/python", ] [workspace.package] diff --git a/README.md b/README.md index 69c35873..1b735f2d 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,9 @@ While we expect GUI toolkit developers to eventually integrate AccessKit into th UI toolkit developers who merely want to use AccessKit should not be required to use Rust directly. -AccessKit provides a C API covering both the core data structures and all platform adapters. This C API can be used from a variety of languages. The Rust source for the C bindings is in [the `bindings/c directory`](https://github.com/AccessKit/accesskit/tree/main/bindings/c). The AccessKit project also provides a pre-built package, including a header file, both dynamic and static libraries, and sample code, for the C API, so toolkit developers won't need to deal with Rust at all. The latest pre-built package can be found in [AccessKit's GitHub releases](https://github.com/AccessKit/accesskit/releases); search for the name "accesskit_c". +AccessKit provides a C API covering both the core data structures and all platform adapters. This C API can be used from a variety of languages. The Rust source for the C bindings is in the [accesskit-c](https://github.com/AccessKit/accesskit-c) repository. The AccessKit project also provides a pre-built package, including a header file, both dynamic and static libraries, and sample code, for the C API, so toolkit developers won't need to deal with Rust at all. The latest pre-built package can be found in [accesskit-c GitHub releases](https://github.com/AccessKit/accesskit-c/releases). -Bindings for the Python programming language are also available. Rust source code is in [the `bindings/python directory`](https://github.com/AccessKit/accesskit/tree/main/bindings/python). Releases can be found on [PyPI](https://pypi.org/project/accesskit/) and can be included in your project using `pip`. +Bindings for the Python programming language are also available. Rust source code is in the [accesskit-python](https://github.com/AccessKit/accesskit-python) repository. Releases can be found on [PyPI](https://pypi.org/project/accesskit/) and can be included in your project using `pip`. While many languages can use a C API, we also plan to provide libraries that make it easier to safely use AccessKit from languages other than Rust and C. In particular, we're planning to provide such a library for Java and other JVM-based languages. diff --git a/bindings/c/.cargo/config.toml b/bindings/c/.cargo/config.toml deleted file mode 100644 index fae35804..00000000 --- a/bindings/c/.cargo/config.toml +++ /dev/null @@ -1,13 +0,0 @@ -[target.aarch64-apple-darwin] -rustflags = [ - "-C", "link-arg=-Wl,-install_name,@rpath/libaccesskit.dylib", -] - -[target.x86_64-apple-darwin] -rustflags = [ - "-C", "link-arg=-Wl,-install_name,@rpath/libaccesskit.dylib", -] - -[profile.release] -panic = "abort" -debug = true diff --git a/bindings/c/.gitignore b/bindings/c/.gitignore deleted file mode 100644 index a76bc149..00000000 --- a/bindings/c/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -build -lib diff --git a/bindings/c/CHANGELOG.md b/bindings/c/CHANGELOG.md deleted file mode 100644 index 62ba842a..00000000 --- a/bindings/c/CHANGELOG.md +++ /dev/null @@ -1,379 +0,0 @@ -# Changelog - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.13.3 to 0.14.0 - * accesskit_macos bumped from 0.6.3 to 0.7.0 - * accesskit_unix bumped from 0.3.3 to 0.4.0 - -* The following workspace dependencies were updated - * dependencies - * accesskit_unix bumped from 0.4.0 to 0.5.0 - -* The following workspace dependencies were updated - * dependencies - * accesskit_macos bumped from 0.7.0 to 0.7.1 - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.14.2 to 0.14.3 - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.12.0 to 0.12.1 - * accesskit_windows bumped from 0.15.0 to 0.15.1 - * accesskit_macos bumped from 0.10.0 to 0.10.1 - * accesskit_unix bumped from 0.6.0 to 0.6.1 - -* The following workspace dependencies were updated - * dependencies - * accesskit_unix bumped from 0.6.1 to 0.6.2 - -* The following workspace dependencies were updated - * dependencies - * accesskit_unix bumped from 0.7.0 to 0.7.1 - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.16.0 to 0.16.1 - * accesskit_unix bumped from 0.7.1 to 0.7.2 - -* The following workspace dependencies were updated - * dependencies - * accesskit_unix bumped from 0.7.2 to 0.7.3 - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.16.1 to 0.16.2 - -* The following workspace dependencies were updated - * dependencies - * accesskit_unix bumped from 0.7.4 to 0.7.5 - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.16.3 to 0.16.4 - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.18.1 to 0.18.2 - * accesskit_macos bumped from 0.13.1 to 0.13.2 - * accesskit_unix bumped from 0.9.1 to 0.9.2 - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.18.2 to 0.19.0 - * accesskit_macos bumped from 0.13.2 to 0.14.0 - * accesskit_unix bumped from 0.9.2 to 0.10.0 - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.19.0 to 0.20.0 - * accesskit_macos bumped from 0.14.0 to 0.15.0 - * accesskit_unix bumped from 0.10.0 to 0.10.1 - -* The following workspace dependencies were updated - * dependencies - * accesskit_unix bumped from 0.11.0 to 0.11.1 - -## [0.12.0](https://github.com/AccessKit/accesskit/compare/accesskit_c-v0.11.1...accesskit_c-v0.12.0) (2024-06-29) - - -### ⚠ BREAKING CHANGES - -* Rename the `StaticText` role to `Label` ([#434](https://github.com/AccessKit/accesskit/issues/434)) - -### Features - -* Pre-generate the C header file ([#439](https://github.com/AccessKit/accesskit/issues/439)) ([c765cf0](https://github.com/AccessKit/accesskit/commit/c765cf09cf2e5be8529a76fb9e0268ca64aa5980)) - - -### Code Refactoring - -* Rename the `StaticText` role to `Label` ([#434](https://github.com/AccessKit/accesskit/issues/434)) ([7086bc0](https://github.com/AccessKit/accesskit/commit/7086bc0fad446d3ed4a0fd5eff641a1e75f6c599)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.15.0 to 0.16.0 - * accesskit_windows bumped from 0.21.0 to 0.22.0 - * accesskit_macos bumped from 0.16.0 to 0.17.0 - * accesskit_unix bumped from 0.11.1 to 0.12.0 - -## [0.11.0](https://github.com/AccessKit/accesskit/compare/accesskit_c-v0.10.3...accesskit_c-v0.11.0) (2024-06-09) - - -### ⚠ BREAKING CHANGES - -* Transfer ownership of action requests in the C API ([#429](https://github.com/AccessKit/accesskit/issues/429)) - -### Features - -* Add `author_id` property ([#424](https://github.com/AccessKit/accesskit/issues/424)) ([0d1c56f](https://github.com/AccessKit/accesskit/commit/0d1c56f0bdde58715e1c69f6015df600cb7cb8c1)) - - -### Code Refactoring - -* Transfer ownership of action requests in the C API ([#429](https://github.com/AccessKit/accesskit/issues/429)) ([d1daa2a](https://github.com/AccessKit/accesskit/commit/d1daa2a2e9819e1817f6d8e169471a07e1caf98b)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.14.0 to 0.15.0 - * accesskit_windows bumped from 0.20.0 to 0.21.0 - * accesskit_macos bumped from 0.15.0 to 0.16.0 - * accesskit_unix bumped from 0.10.1 to 0.11.0 - -## [0.10.0](https://github.com/AccessKit/accesskit/compare/accesskit_c-v0.9.0...accesskit_c-v0.10.0) (2024-05-11) - - -### ⚠ BREAKING CHANGES - -* Rename `accesskit_builder_set_text_selection` to `accesskit_node_builder_set_text_selection` ([#407](https://github.com/AccessKit/accesskit/issues/407)) - -### Bug Fixes - -* Explicitly set macOS CI build architecture for C bindings ([#406](https://github.com/AccessKit/accesskit/issues/406)) ([64857e8](https://github.com/AccessKit/accesskit/commit/64857e8747a8eb7b51d321b0f1b98ac76292a8b6)) -* Fix dead code warning on Unix platforms ([#403](https://github.com/AccessKit/accesskit/issues/403)) ([09d9157](https://github.com/AccessKit/accesskit/commit/09d91577dd88743e379a1fdea34b25a94726d0fb)) -* Rename `accesskit_builder_set_text_selection` to `accesskit_node_builder_set_text_selection` ([#407](https://github.com/AccessKit/accesskit/issues/407)) ([79eb0a4](https://github.com/AccessKit/accesskit/commit/79eb0a4019c4ef7e4b5b7509be68b960ec17b9e0)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.18.0 to 0.18.1 - * accesskit_macos bumped from 0.13.0 to 0.13.1 - * accesskit_unix bumped from 0.9.0 to 0.9.1 - -## [0.9.0](https://github.com/AccessKit/accesskit/compare/accesskit_c-v0.8.0...accesskit_c-v0.9.0) (2024-04-30) - - -### ⚠ BREAKING CHANGES - -* Clean up table roles and properties ([#393](https://github.com/AccessKit/accesskit/issues/393)) -* Rename `hierarchical_level` to `level` ([#390](https://github.com/AccessKit/accesskit/issues/390)) -* Drop `NodeClassSet` ([#389](https://github.com/AccessKit/accesskit/issues/389)) -* Rename `Checked` to `Toggled`; drop `ToggleButton` role ([#388](https://github.com/AccessKit/accesskit/issues/388)) - -### Features - -* Add the `owns` relation ([#392](https://github.com/AccessKit/accesskit/issues/392)) ([fd668dd](https://github.com/AccessKit/accesskit/commit/fd668ddc4b64cb05ab3600972b3d3823a037f2d5)) - - -### Bug Fixes - -* Increase minimum supported Rust version to `1.70` ([#396](https://github.com/AccessKit/accesskit/issues/396)) ([a8398b8](https://github.com/AccessKit/accesskit/commit/a8398b847aa003de91042ac45e33126fc2cae053)) - - -### Code Refactoring - -* Clean up table roles and properties ([#393](https://github.com/AccessKit/accesskit/issues/393)) ([e34dad9](https://github.com/AccessKit/accesskit/commit/e34dad94448a5321ece9def3f2e054aa5f62dd79)) -* Drop `NodeClassSet` ([#389](https://github.com/AccessKit/accesskit/issues/389)) ([1b153ed](https://github.com/AccessKit/accesskit/commit/1b153ed51f8421cdba2dc98beca2e8f5f8c781bc)) -* Rename `Checked` to `Toggled`; drop `ToggleButton` role ([#388](https://github.com/AccessKit/accesskit/issues/388)) ([6bc040b](https://github.com/AccessKit/accesskit/commit/6bc040b7cf75cdbd6a019cc380d8dbce804b3c81)) -* Rename `hierarchical_level` to `level` ([#390](https://github.com/AccessKit/accesskit/issues/390)) ([2d61e01](https://github.com/AccessKit/accesskit/commit/2d61e01fffff1265b348c141715f6f9b6fe4081b)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.13.0 to 0.14.0 - * accesskit_windows bumped from 0.17.0 to 0.18.0 - * accesskit_macos bumped from 0.12.0 to 0.13.0 - * accesskit_unix bumped from 0.8.0 to 0.9.0 - -## [0.8.0](https://github.com/AccessKit/accesskit/compare/accesskit_c-v0.7.7...accesskit_c-v0.8.0) (2024-04-14) - - -### ⚠ BREAKING CHANGES - -* New approach to lazy initialization ([#375](https://github.com/AccessKit/accesskit/issues/375)) - -### Bug Fixes - -* Remove unused `BoxCastPtr::set_mut_ptr` in the C bindings ([#378](https://github.com/AccessKit/accesskit/issues/378)) ([3db0fdb](https://github.com/AccessKit/accesskit/commit/3db0fdb6fcd0078c5480fb3a5bf7d5332aad82e5)) -* Set INTERFACE_INCLUDE_DIRECTORIES in CMake config ([#379](https://github.com/AccessKit/accesskit/issues/379)) ([2b52701](https://github.com/AccessKit/accesskit/commit/2b52701995816ba45dc9d91e401a6548e77bbb2a)) -* Update Corrosion to 0.4.7 ([#380](https://github.com/AccessKit/accesskit/issues/380)) ([0efcfb1](https://github.com/AccessKit/accesskit/commit/0efcfb140cef4c98ccc943f0ab692045d49bbb40)) - - -### Code Refactoring - -* New approach to lazy initialization ([#375](https://github.com/AccessKit/accesskit/issues/375)) ([9baebdc](https://github.com/AccessKit/accesskit/commit/9baebdceed7300389b6768815d7ae48f1ce401e4)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.12.3 to 0.13.0 - * accesskit_windows bumped from 0.16.4 to 0.17.0 - * accesskit_macos bumped from 0.11.1 to 0.12.0 - * accesskit_unix bumped from 0.7.5 to 0.8.0 - -## [0.7.5](https://github.com/AccessKit/accesskit/compare/accesskit_c-v0.7.4...accesskit_c-v0.7.5) (2024-03-07) - - -### Bug Fixes - -* Spelling of `transferred` in C bindings documentation ([#361](https://github.com/AccessKit/accesskit/issues/361)) ([f27ce99](https://github.com/AccessKit/accesskit/commit/f27ce99860b02c64367065c6b7dad6e9cbd11f74)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.12.2 to 0.12.3 - * accesskit_windows bumped from 0.16.2 to 0.16.3 - * accesskit_macos bumped from 0.11.0 to 0.11.1 - * accesskit_unix bumped from 0.7.3 to 0.7.4 - -## [0.7.0](https://github.com/AccessKit/accesskit/compare/accesskit_c-v0.6.2...accesskit_c-v0.7.0) (2024-01-03) - - -### ⚠ BREAKING CHANGES - -* Lazily activate Unix adapters ([#324](https://github.com/AccessKit/accesskit/issues/324)) - -### Bug Fixes - -* Lazily activate Unix adapters ([#324](https://github.com/AccessKit/accesskit/issues/324)) ([54ed036](https://github.com/AccessKit/accesskit/commit/54ed036c99d87428a8eb5bb03fd77e9e31562d4c)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.12.1 to 0.12.2 - * accesskit_windows bumped from 0.15.1 to 0.16.0 - * accesskit_macos bumped from 0.10.1 to 0.11.0 - * accesskit_unix bumped from 0.6.2 to 0.7.0 - -## [0.6.0](https://github.com/AccessKit/accesskit/compare/accesskit_c-v0.5.1...accesskit_c-v0.6.0) (2023-09-27) - - -### ⚠ BREAKING CHANGES - -* Allow providing app_name, toolkit_name and toolkit_version in Tree, remove parameters from unix adapter constructor ([#291](https://github.com/AccessKit/accesskit/issues/291)) -* Make `ActionHandler::do_action` take `&mut self` ([#296](https://github.com/AccessKit/accesskit/issues/296)) -* Clean up roles and properties ([#289](https://github.com/AccessKit/accesskit/issues/289)) -* Drop next/previous focus properties ([#288](https://github.com/AccessKit/accesskit/issues/288)) -* Drop `Tree::root_scroller` ([#279](https://github.com/AccessKit/accesskit/issues/279)) -* Decouple in-tree focus from host window/view focus ([#278](https://github.com/AccessKit/accesskit/issues/278)) -* Switch to simple unsigned 64-bit integer for node IDs ([#276](https://github.com/AccessKit/accesskit/issues/276)) - -### Features - -* Allow providing app_name, toolkit_name and toolkit_version in Tree, remove parameters from unix adapter constructor ([#291](https://github.com/AccessKit/accesskit/issues/291)) ([5313860](https://github.com/AccessKit/accesskit/commit/531386023257150f49b5e4be942f359855fb7cb6)) - - -### Bug Fixes - -* Drop `Tree::root_scroller` ([#279](https://github.com/AccessKit/accesskit/issues/279)) ([fc6c4e0](https://github.com/AccessKit/accesskit/commit/fc6c4e0091d5b257a3869a468fca144a1453cebc)) -* Drop next/previous focus properties ([#288](https://github.com/AccessKit/accesskit/issues/288)) ([d35c7c1](https://github.com/AccessKit/accesskit/commit/d35c7c149a650dfedf1b031c0668adad585659fa)) - - -### Code Refactoring - -* Clean up roles and properties ([#289](https://github.com/AccessKit/accesskit/issues/289)) ([4fc9c55](https://github.com/AccessKit/accesskit/commit/4fc9c55c91812472593923d93ff89d75ff305ee4)) -* Decouple in-tree focus from host window/view focus ([#278](https://github.com/AccessKit/accesskit/issues/278)) ([d360d20](https://github.com/AccessKit/accesskit/commit/d360d20cf951e7643b81a5303006c9f7daa5bd56)) -* Make `ActionHandler::do_action` take `&mut self` ([#296](https://github.com/AccessKit/accesskit/issues/296)) ([4fc7846](https://github.com/AccessKit/accesskit/commit/4fc7846d732d61fb45c023060ebab96801a0053e)) -* Switch to simple unsigned 64-bit integer for node IDs ([#276](https://github.com/AccessKit/accesskit/issues/276)) ([3eadd48](https://github.com/AccessKit/accesskit/commit/3eadd48ec47854faa94a94ebf910ec08f514642f)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.11.2 to 0.12.0 - * accesskit_windows bumped from 0.14.3 to 0.15.0 - * accesskit_macos bumped from 0.9.0 to 0.10.0 - * accesskit_unix bumped from 0.5.2 to 0.6.0 - -## [0.5.0](https://github.com/AccessKit/accesskit/compare/accesskit_c-v0.4.0...accesskit_c-v0.5.0) (2023-08-08) - - -### Features - -* Add an SDL example to the C bindings ([#250](https://github.com/AccessKit/accesskit/issues/250)) ([1f5cd1f](https://github.com/AccessKit/accesskit/commit/1f5cd1f7a94a762edeb73188f0ab4fd352c36b3d)) -* Workaround for libraries that put the macOS keyboard focus on the window rather than the content view ([#266](https://github.com/AccessKit/accesskit/issues/266)) ([c2db1b0](https://github.com/AccessKit/accesskit/commit/c2db1b0424e905d87691f8148f28b77405f29926)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.11.1 to 0.11.2 - * accesskit_windows bumped from 0.14.1 to 0.14.2 - * accesskit_macos bumped from 0.8.0 to 0.9.0 - * accesskit_unix bumped from 0.5.1 to 0.5.2 - -## [0.4.0](https://github.com/AccessKit/accesskit/compare/accesskit_c-v0.3.2...accesskit_c-v0.4.0) (2023-07-30) - - -### ⚠ BREAKING CHANGES - -* New C API for tree updates ([#263](https://github.com/AccessKit/accesskit/issues/263)) - -### Features - -* Add CMake support to C bindings ([#247](https://github.com/AccessKit/accesskit/issues/247)) ([3f556c9](https://github.com/AccessKit/accesskit/commit/3f556c995e8c5eae6831a89b0173809134c1b4e7)) -* Add window-based constructor to macOS subclassing adapter ([#253](https://github.com/AccessKit/accesskit/issues/253)) ([022ef04](https://github.com/AccessKit/accesskit/commit/022ef045b9f28262b738ee1ca29a4c7303061fb3)) - - -### Code Refactoring - -* New C API for tree updates ([#263](https://github.com/AccessKit/accesskit/issues/263)) ([b260a86](https://github.com/AccessKit/accesskit/commit/b260a860e6f47cf7ef4e10c407123d91c5b35297)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.11.0 to 0.11.1 - * accesskit_windows bumped from 0.14.0 to 0.14.1 - * accesskit_macos bumped from 0.7.1 to 0.8.0 - * accesskit_unix bumped from 0.5.0 to 0.5.1 - -## [0.3.0](https://github.com/AccessKit/accesskit/compare/accesskit_c-v0.2.0...accesskit_c-v0.3.0) (2023-04-25) - - -### ⚠ BREAKING CHANGES - -* Remove objc and Core Foundation types from C bindings public API ([#243](https://github.com/AccessKit/accesskit/issues/243)) - -### Bug Fixes - -* Remove objc and Core Foundation types from C bindings public API ([#243](https://github.com/AccessKit/accesskit/issues/243)) ([3ae1c11](https://github.com/AccessKit/accesskit/commit/3ae1c116abcf4593c8540f0d25d154828a69a388)) - -## [0.2.0](https://github.com/AccessKit/accesskit/compare/accesskit_c-v0.1.1...accesskit_c-v0.2.0) (2023-04-01) - - -### ⚠ BREAKING CHANGES - -* Improve C bindings package directory structure ([#239](https://github.com/AccessKit/accesskit/issues/239)) - -### Bug Fixes - -* Improve C bindings package directory structure ([#239](https://github.com/AccessKit/accesskit/issues/239)) ([44c27e7](https://github.com/AccessKit/accesskit/commit/44c27e76f242154a44d907ac4ca0a35bf807caaf)) - -## 0.1.0 (2023-03-29) - - -### Features - -* Add C bindings ([#230](https://github.com/AccessKit/accesskit/issues/230)) ([7f7f4c7](https://github.com/AccessKit/accesskit/commit/7f7f4c755890ab8210a5a8bf8e237ba6a51dd205)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.10.1 to 0.11.0 - * accesskit_windows bumped from 0.13.2 to 0.13.3 - * accesskit_macos bumped from 0.6.2 to 0.6.3 - * accesskit_unix bumped from 0.3.2 to 0.3.3 diff --git a/bindings/c/CMakeLists.txt b/bindings/c/CMakeLists.txt deleted file mode 100644 index b82899ee..00000000 --- a/bindings/c/CMakeLists.txt +++ /dev/null @@ -1,66 +0,0 @@ -cmake_minimum_required(VERSION 3.20) - -project(accesskit_c) - -option(ACCESSKIT_BUILD_HEADERS "Whether to build header files" OFF) -option(ACCESSKIT_BUILD_LIBRARIES "Whether to build libraries" ON) - -if (ACCESSKIT_BUILD_LIBRARIES) - include(FetchContent) - - FetchContent_Declare( - Corrosion - GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git - GIT_TAG v0.4.7 - ) - FetchContent_MakeAvailable(Corrosion) - - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - corrosion_import_crate(MANIFEST_PATH Cargo.toml) -endif() - -if (ACCESSKIT_BUILD_HEADERS) - find_program(RUSTUP rustup) - find_program(CBINDGEN cbindgen) - find_program(CLANG_FORMAT clang-format) - - add_custom_target(headers ALL - COMMAND ${RUSTUP} run nightly ${CBINDGEN} --crate accesskit_c --output accesskit.hpp "${CMAKE_SOURCE_DIR}" - COMMAND ${CLANG_FORMAT} -i accesskit.hpp - COMMAND ${CMAKE_COMMAND} -E rename accesskit.hpp accesskit.h - BYPRODUCTS accesskit.h - ) - - if (ACCESSKIT_BUILD_LIBRARIES) - add_dependencies(cargo-prebuild_accesskit headers) - endif() -endif() - -include("accesskit.cmake") - -if (ACCESSKIT_BUILD_HEADERS) - install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/accesskit.h" - DESTINATION "${ACCESSKIT_INCLUDE_DIR}" - ) -endif() - -if (ACCESSKIT_BUILD_LIBRARIES) - install(FILES - "$" - DESTINATION "${ACCESSKIT_LIBRARIES_DIR}/static" - ) - - install(FILES - "$" - "$<$:${CMAKE_CURRENT_BINARY_DIR}/accesskit.pdb>" - DESTINATION "${ACCESSKIT_LIBRARIES_DIR}/shared" - ) - install(FILES - "$<$,>>:$>" - RENAME "libaccesskit.a" - DESTINATION "${ACCESSKIT_LIBRARIES_DIR}/shared" - ) -endif() diff --git a/bindings/c/Cargo.toml b/bindings/c/Cargo.toml deleted file mode 100644 index cfb1299b..00000000 --- a/bindings/c/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "accesskit_c" -version = "0.12.0" -authors.workspace = true -license.workspace = true -publish = false -edition.workspace = true - -[lib] -name = "accesskit" -crate-type = ["cdylib", "staticlib"] -doc = false - -[features] -cbindgen = [] - -[dependencies] -accesskit = { version = "0.16.0", path = "../../common" } -paste = "1.0" - -[target.'cfg(target_os = "windows")'.dependencies] -accesskit_windows = { version = "0.22.0", path = "../../platforms/windows" } - -[target.'cfg(target_os = "macos")'.dependencies] -accesskit_macos = { version = "0.17.0", path = "../../platforms/macos" } - -[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies] -accesskit_unix = { version = "0.12.0", path = "../../platforms/unix" } diff --git a/bindings/c/README.md b/bindings/c/README.md deleted file mode 100644 index 3e6cad34..00000000 --- a/bindings/c/README.md +++ /dev/null @@ -1,70 +0,0 @@ -# AccessKit C bindings - -These are the bindings to use AccessKit from other languages through FFI such as in C. - -## How to use in a CMake project - -Decompress an accesskit_c release and place the resulting folder somewhere either: - -- already known by CMake, -- listed in your `CMAKE_PREFIX_PATH`, -- indicated by the `ACCESSKIT_DIR` option. - -You can then require AccessKit as a dependency by adding this to your `CMakeLists.txt`: - -```cmake -find_package(ACCESSKIT REQUIRED) -``` - -Finally, link the library to your executable: - -```cmake -target_link_libraries(hello_world PUBLIC accesskit) -``` - -See [the `examples` directory](https://github.com/AccessKit/accesskit/tree/main/bindings/c/examples) for project integration examples. - -## Building from source - -Prerequisites: - -- [Rust](https://rustup.rs/) -- [CMake](https://cmake.org/), version 3.20 or higher - -Once inside the `bindings/c` directory, CMake can be used like this to build the project: - -```bash -cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -cmake --build build -cmake --install build -``` - -### Notes on cross-compiling - -On Windows, you will need to pass the `-A` flag when configuring the project. For instance, to target ARM64: - -```bash -cmake -S . -B build -A ARM64 -``` - -On other platforms you will have to specify which Rust target to use, as well as tell CMake for which architecture to compile. Here is how you would cross-compile for Linux X86 from Linux AMD64: - -```bash -cmake -S . -B build -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DRust_CARGO_TARGET=i686-unknown-linux-gnu -``` - -### Regenerating the header file - -If you modify the C bindings, you need to regenerate the header file and commit it. To do this, in addition to the above requirements, you will need: - -- A nightly Rust toolchain: `rustup install nightly` -- [cbindgen](https://github.com/mozilla/cbindgen): `cargo install cbindgen` -- [clang-format](https://releases.llvm.org/14.0.0/tools/clang/docs/ClangFormat.html), version 14 or higher - -Once you have these requirements, the process of regenerating the header file is similar to building and installing from source with CMake, but using different configuration options: - -```bash -cmake -S . -B build -DACCESSKIT_BUILD_HEADERS=ON -DACCESSKIT_BUILD_LIBRARIES=OFF -cmake --build build -cmake --install build -``` diff --git a/bindings/c/accesskit-config.cmake b/bindings/c/accesskit-config.cmake deleted file mode 100644 index 8ff92f22..00000000 --- a/bindings/c/accesskit-config.cmake +++ /dev/null @@ -1,51 +0,0 @@ -include("${CMAKE_CURRENT_LIST_DIR}/accesskit.cmake") - -add_library(accesskit INTERFACE) - -add_library(accesskit-static STATIC IMPORTED GLOBAL) -find_library(_accesskit_static_lib accesskit "${ACCESSKIT_LIBRARIES_DIR}/static") -set_property( - TARGET accesskit-static - PROPERTY IMPORTED_LOCATION "${_accesskit_static_lib}" -) -set_property( - TARGET accesskit-static - PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${ACCESSKIT_INCLUDE_DIR}" -) -if (_accesskit_os STREQUAL "macos") - target_link_libraries(accesskit-static INTERFACE "-framework AppKit" "-framework Foundation" "-framework CoreFoundation" objc c++) -elseif (_accesskit_os STREQUAL "linux") - target_link_libraries(accesskit-static INTERFACE -static-libgcc m) -elseif (_accesskit_os STREQUAL "windows") - target_link_libraries(accesskit-static INTERFACE bcrypt ntdll uiautomationcore userenv ws2_32) -endif() - -add_library(accesskit-shared SHARED IMPORTED GLOBAL) -if (_accesskit_os STREQUAL "windows") - find_library(_accesskit_implib accesskit "${ACCESSKIT_LIBRARIES_DIR}/shared") - set_property( - TARGET accesskit-shared - PROPERTY IMPORTED_IMPLIB "${_accesskit_implib}" - ) -endif() -if (_accesskit_os STREQUAL "macos") - set(_accesskit_shared_lib "libaccesskit.dylib") -elseif (_accesskit_os STREQUAL "linux") - set(_accesskit_shared_lib "libaccesskit.so") -elseif (_accesskit_os STREQUAL "windows") - set(_accesskit_shared_lib "accesskit.dll") -endif() -set_property( - TARGET accesskit-shared - PROPERTY IMPORTED_LOCATION "${ACCESSKIT_LIBRARIES_DIR}/shared/${_accesskit_shared_lib}" -) -set_property( - TARGET accesskit-shared - PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${ACCESSKIT_INCLUDE_DIR}" -) - -if (BUILD_SHARED_LIBS) - target_link_libraries(accesskit INTERFACE accesskit-shared) -else() - target_link_libraries(accesskit INTERFACE accesskit-static) -endif() diff --git a/bindings/c/accesskit.cmake b/bindings/c/accesskit.cmake deleted file mode 100644 index 3c6eb48a..00000000 --- a/bindings/c/accesskit.cmake +++ /dev/null @@ -1,46 +0,0 @@ -set(ACCESSKIT_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}/include") -set(_accesskit_toolchain "") - -if (APPLE) - set(_accesskit_os "macos") - if (CMAKE_OSX_ARCHITECTURES MATCHES "(ARM64|arm64|aarch64)") - set(_accesskit_arch "arm64") - elseif (CMAKE_OSX_ARCHITECTURES MATCHES "(AMD64|amd64|x86_64)") - set(_accesskit_arch "x86_64") - endif() -elseif (UNIX) - set(_accesskit_os "linux") -elseif (WIN32) - set(_accesskit_os "windows") - if (MINGW) - set(_accesskit_toolchain "mingw") - else() - set(_accesskit_toolchain "msvc") - endif() - - if (CMAKE_VS_PLATFORM_NAME) - string(TOLOWER "${CMAKE_VS_PLATFORM_NAME}" LOWER_VS_PLATFORM_NAME) - if ("${LOWER_VS_PLATFORM_NAME}" STREQUAL "win32") - set(_accesskit_arch x86) - elseif("${LOWER_VS_PLATFORM_NAME}" STREQUAL "x64") - set(_accesskit_arch x86_64) - elseif ("${LOWER_VS_PLATFORM_NAME}" STREQUAL "arm64") - set(_accesskit_arch "arm64") - endif() - endif() -endif() - -if (NOT _accesskit_arch) - if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(AMD64|amd64|x86_64)$") - set(_accesskit_arch x86_64) - elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(ARM64|arm64|aarch64)$") - set(_accesskit_arch arm64) - elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(X86|x86|i686)$") - set(_accesskit_arch x86) - endif() -endif() - -set(ACCESSKIT_LIBRARIES_DIR "${CMAKE_CURRENT_LIST_DIR}/lib/${_accesskit_os}/${_accesskit_arch}") -if (_accesskit_toolchain) - string(APPEND ACCESSKIT_LIBRARIES_DIR "/${_accesskit_toolchain}") -endif() diff --git a/bindings/c/cbindgen.toml b/bindings/c/cbindgen.toml deleted file mode 100644 index 4b587243..00000000 --- a/bindings/c/cbindgen.toml +++ /dev/null @@ -1,85 +0,0 @@ -language = "C" -header = """/** - * Copyright 2023 The AccessKit Authors. All rights reserved. - * Licensed under the Apache License, Version 2.0 (found in - * the LICENSE-APACHE file) or the MIT license (found in - * the LICENSE-MIT file), at your option. - */""" - -include_guard = "ACCESSKIT_H" -cpp_compat = true -after_includes = """#ifdef _WIN32 -#include -#endif""" - -usize_is_size_t = true - -[export] -include = ["Size", "Vec2"] -prefix = "accesskit_" -renaming_overrides_prefixing = true - -[defines] -"target_os = linux" = "__linux__" -"target_os = dragonfly" = "__DragonFly__" -"target_os = freebsd" = "__FreeBSD__" -"target_os = netbsd" = "__NetBSD__" -"target_os = openbsd" = "__OpenBSD__" -"target_os = macos" = "__APPLE__" -"target_os = windows" = "_WIN32" - -[export.rename] -"Action" = "accesskit_action" -"ActionHandlerCallback" = "accesskit_action_handler_callback" -"ActivationHandlerCallback" = "accesskit_activation_handler_callback" -"Affine" = "accesskit_affine" -"AriaCurrent" = "accesskit_aria_current" -"AutoComplete" = "accesskit_auto_complete" -"DeactivationHandlerCallback" = "accesskit_deactivation_handler_callback" -"DefaultActionVerb" = "accesskit_default_action_verb" -"HWND" = "HWND" -"HasPopup" = "accesskit_has_popup" -"Invalid" = "accesskit_invalid" -"LPARAM" = "LPARAM" -"LRESULT" = "LRESULT" -"ListStyle" = "accesskit_list_style" -"Live" = "accesskit_live" -"Orientation" = "accesskit_orientation" -"Point" = "accesskit_point" -"Rect" = "accesskit_rect" -"Role" = "accesskit_role" -"Size" = "accesskit_size" -"SortDirection" = "accesskit_sort_direction" -"TextAlign" = "accesskit_text_align" -"TextDecoration" = "accesskit_text_decoration" -"TextDirection" = "accesskit_text_direction" -"Toggled" = "accesskit_toggled" -"Vec2" = "accesskit_vec2" -"VerticalOffset" = "accesskit_vertical_offset" -"WPARAM" = "WPARAM" -"opt_AriaCurrent" = "accesskit_opt_aria_current" -"opt_AutoComplete" = "accesskit_opt_auto_complete" -"opt_DefaultActionVerb" = "accesskit_opt_default_action_verb" -"opt_HasPopup" = "accesskit_opt_has_popup" -"opt_Invalid" = "accesskit_opt_invalid" -"opt_ListStyle" = "accesskit_opt_list_style" -"opt_Live" = "accesskit_opt_live" -"opt_Orientation" = "accesskit_opt_orientation" -"opt_SortDirection" = "accesskit_opt_sort_direction" -"opt_TextAlign" = "accesskit_opt_text_align" -"opt_TextDecoration" = "accesskit_opt_text_decoration" -"opt_TextDirection" = "accesskit_opt_text_direction" -"opt_Toggled" = "accesskit_opt_toggled" -"opt_VerticalOffset" = "accesskit_opt_vertical_offset" - -[enum] -rename_variants = "ScreamingSnakeCase" -prefix_with_name = true - -[parse] -parse_deps = true -include = ["accesskit"] - -[parse.expand] -crates = ["accesskit_c"] -features = ["cbindgen"] diff --git a/bindings/c/examples/sdl/.gitignore b/bindings/c/examples/sdl/.gitignore deleted file mode 100644 index 378eac25..00000000 --- a/bindings/c/examples/sdl/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build diff --git a/bindings/c/examples/sdl/CMakeLists.txt b/bindings/c/examples/sdl/CMakeLists.txt deleted file mode 100644 index 0f7036d3..00000000 --- a/bindings/c/examples/sdl/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required(VERSION 3.20) - -project(sdl_example) - -find_package(SDL2 REQUIRED) -include_directories(${SDL2_INCLUDE_DIRS}) -find_package(ACCESSKIT REQUIRED) - -add_executable(hello_world hello_world.c) -target_link_libraries(hello_world PUBLIC ${SDL2_LIBRARIES}) -target_link_libraries(hello_world PUBLIC accesskit) -target_compile_definitions(hello_world PRIVATE -DUNICODE -D_UNICODE) diff --git a/bindings/c/examples/sdl/README.md b/bindings/c/examples/sdl/README.md deleted file mode 100644 index ea272000..00000000 --- a/bindings/c/examples/sdl/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# AccessKit cross-platform SDL example - -This example demonstrates how to make use of the C bindings to create cross-platform applications. - -## Building - -The process will vary based on your operating system. - -### Windows: - -First download an SDL2 development package from the project's [GitHub release page](https://github.com/libsdl-org/SDL/releases) (SDL2-devel-2.x.y-VC.zip for MSVC) and extract it. - -```bash -cmake -S . -B build -DACCESSKIT_DIR="../.." -DSDL2_DIR="/cmake" -cmake --build build --config Release -``` - -You will then need to copy `SDL2.dll` into the `build/Release` folder. - -### Linux - -Make sure to install SDL2 and its development package. - -```bash -cmake -S . -B build -DACCESSKIT_DIR="../.." -DCMAKE_BUILD_TYPE=Release -cmake --build build -``` - -### macOS - -First download an SDL2 package from the project's [GitHub release page](https://github.com/libsdl-org/SDL/releases) (SDL2-2.x.y.dmg) and copy `SDL2.framework` to `/Library/Frameworks`. - -```bash -cmake -S . -B build -DACCESSKIT_DIR="../.." -DCMAKE_BUILD_TYPE=Release -cmake --build build -``` diff --git a/bindings/c/examples/sdl/hello_world.c b/bindings/c/examples/sdl/hello_world.c deleted file mode 100644 index 22d0d0c7..00000000 --- a/bindings/c/examples/sdl/hello_world.c +++ /dev/null @@ -1,387 +0,0 @@ -#include -#include -#include -#include - -#include "accesskit.h" - -#if (defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ - defined(__NetBSD__) || defined(__OpenBSD__)) -#define UNIX -#endif - -const char WINDOW_TITLE[] = "Hello world"; - -const accesskit_node_id WINDOW_ID = 0; -const accesskit_node_id BUTTON_1_ID = 1; -const accesskit_node_id BUTTON_2_ID = 2; -const accesskit_node_id ANNOUNCEMENT_ID = 3; -#define INITIAL_FOCUS BUTTON_1_ID - -const accesskit_rect BUTTON_1_RECT = {20.0, 20.0, 100.0, 60.0}; - -const accesskit_rect BUTTON_2_RECT = {20.0, 60.0, 100.0, 100.0}; - -const Sint32 SET_FOCUS_MSG = 0; -const Sint32 DO_DEFAULT_ACTION_MSG = 1; - -accesskit_node *build_button(accesskit_node_id id, const char *name) { - accesskit_rect rect; - if (id == BUTTON_1_ID) { - rect = BUTTON_1_RECT; - } else { - rect = BUTTON_2_RECT; - } - - accesskit_node_builder *builder = - accesskit_node_builder_new(ACCESSKIT_ROLE_BUTTON); - accesskit_node_builder_set_bounds(builder, rect); - accesskit_node_builder_set_name(builder, name); - accesskit_node_builder_add_action(builder, ACCESSKIT_ACTION_FOCUS); - accesskit_node_builder_set_default_action_verb( - builder, ACCESSKIT_DEFAULT_ACTION_VERB_CLICK); - return accesskit_node_builder_build(builder); -} - -accesskit_node *build_announcement(const char *text) { - accesskit_node_builder *builder = - accesskit_node_builder_new(ACCESSKIT_ROLE_LABEL); - accesskit_node_builder_set_name(builder, text); - accesskit_node_builder_set_live(builder, ACCESSKIT_LIVE_POLITE); - return accesskit_node_builder_build(builder); -} - -struct accesskit_sdl_adapter { -#if defined(__APPLE__) - accesskit_macos_subclassing_adapter *adapter; -#elif defined(UNIX) - accesskit_unix_adapter *adapter; -#elif defined(_WIN32) - accesskit_windows_subclassing_adapter *adapter; -#endif -}; - -void accesskit_sdl_adapter_init( - struct accesskit_sdl_adapter *adapter, SDL_Window *window, - accesskit_activation_handler_callback activation_handler, - void *activation_handler_userdata, - accesskit_action_handler_callback action_handler, - void *action_handler_userdata, - accesskit_deactivation_handler_callback deactivation_handler, - void *deactivation_handler_userdata) { -#if defined(__APPLE__) - accesskit_macos_add_focus_forwarder_to_window_class("SDLWindow"); - SDL_SysWMinfo wmInfo; - SDL_VERSION(&wmInfo.version); - SDL_GetWindowWMInfo(window, &wmInfo); - adapter->adapter = accesskit_macos_subclassing_adapter_for_window( - (void *)wmInfo.info.cocoa.window, activation_handler, - activation_handler_userdata, action_handler, action_handler_userdata); -#elif defined(UNIX) - adapter->adapter = accesskit_unix_adapter_new( - activation_handler, activation_handler_userdata, action_handler, - action_handler_userdata, deactivation_handler, - deactivation_handler_userdata); -#elif defined(_WIN32) - SDL_SysWMinfo wmInfo; - SDL_VERSION(&wmInfo.version); - SDL_GetWindowWMInfo(window, &wmInfo); - adapter->adapter = accesskit_windows_subclassing_adapter_new( - wmInfo.info.win.window, activation_handler, activation_handler_userdata, - action_handler, action_handler_userdata); -#endif -} - -void accesskit_sdl_adapter_destroy(struct accesskit_sdl_adapter *adapter) { - if (adapter->adapter != NULL) { -#if defined(__APPLE__) - accesskit_macos_subclassing_adapter_free(adapter->adapter); -#elif defined(UNIX) - accesskit_unix_adapter_free(adapter->adapter); -#elif defined(_WIN32) - accesskit_windows_subclassing_adapter_free(adapter->adapter); -#endif - } -} - -void accesskit_sdl_adapter_update_if_active( - struct accesskit_sdl_adapter *adapter, - accesskit_tree_update_factory update_factory, - void *update_factory_userdata) { -#if defined(__APPLE__) - accesskit_macos_queued_events *events = - accesskit_macos_subclassing_adapter_update_if_active( - adapter->adapter, update_factory, update_factory_userdata); - if (events != NULL) { - accesskit_macos_queued_events_raise(events); - } -#elif defined(UNIX) - accesskit_unix_adapter_update_if_active(adapter->adapter, update_factory, - update_factory_userdata); -#elif defined(_WIN32) - accesskit_windows_queued_events *events = - accesskit_windows_subclassing_adapter_update_if_active( - adapter->adapter, update_factory, update_factory_userdata); - if (events != NULL) { - accesskit_windows_queued_events_raise(events); - } -#endif -} - -void accesskit_sdl_adapter_update_window_focus_state( - struct accesskit_sdl_adapter *adapter, bool is_focused) { -#if defined(__APPLE__) - accesskit_macos_queued_events *events = - accesskit_macos_subclassing_adapter_update_view_focus_state( - adapter->adapter, is_focused); - if (events != NULL) { - accesskit_macos_queued_events_raise(events); - } -#elif defined(UNIX) - accesskit_unix_adapter_update_window_focus_state(adapter->adapter, - is_focused); -#endif - /* On Windows, the subclassing adapter takes care of this. */ -} - -void accesskit_sdl_adapter_update_root_window_bounds( - struct accesskit_sdl_adapter *adapter, SDL_Window *window) { -#if defined(UNIX) - int x, y, width, height; - SDL_GetWindowPosition(window, &x, &y); - SDL_GetWindowSize(window, &width, &height); - int top, left, bottom, right; - SDL_GetWindowBordersSize(window, &top, &left, &bottom, &right); - accesskit_rect outer_bounds = {x - left, y - top, x + width + right, - y + height + bottom}; - accesskit_rect inner_bounds = {x, y, x + width, y + height}; - accesskit_unix_adapter_set_root_window_bounds(adapter->adapter, outer_bounds, - inner_bounds); -#endif -} - -struct window_state { - accesskit_node_id focus; - const char *announcement; - SDL_mutex *mutex; -}; - -void window_state_init(struct window_state *state) { - state->focus = INITIAL_FOCUS; - state->announcement = NULL; - state->mutex = SDL_CreateMutex(); -} - -void window_state_destroy(struct window_state *state) { - SDL_DestroyMutex(state->mutex); -} - -void window_state_lock(struct window_state *state) { - SDL_LockMutex(state->mutex); -} - -void window_state_unlock(struct window_state *state) { - SDL_UnlockMutex(state->mutex); -} - -accesskit_node *window_state_build_root(const struct window_state *state) { - accesskit_node_builder *builder = - accesskit_node_builder_new(ACCESSKIT_ROLE_WINDOW); - accesskit_node_builder_push_child(builder, BUTTON_1_ID); - accesskit_node_builder_push_child(builder, BUTTON_2_ID); - if (state->announcement != NULL) { - accesskit_node_builder_push_child(builder, ANNOUNCEMENT_ID); - } - accesskit_node_builder_set_name(builder, WINDOW_TITLE); - return accesskit_node_builder_build(builder); -} - -accesskit_tree_update *window_state_build_initial_tree( - const struct window_state *state) { - accesskit_node *root = window_state_build_root(state); - accesskit_node *button_1 = build_button(BUTTON_1_ID, "Button 1"); - accesskit_node *button_2 = build_button(BUTTON_2_ID, "Button 2"); - accesskit_tree_update *result = accesskit_tree_update_with_capacity_and_focus( - (state->announcement != NULL) ? 4 : 3, state->focus); - accesskit_tree *tree = accesskit_tree_new(WINDOW_ID); - accesskit_tree_set_app_name(tree, "Hello World"); - accesskit_tree_update_set_tree(result, tree); - accesskit_tree_update_push_node(result, WINDOW_ID, root); - accesskit_tree_update_push_node(result, BUTTON_1_ID, button_1); - accesskit_tree_update_push_node(result, BUTTON_2_ID, button_2); - if (state->announcement != NULL) { - accesskit_node *announcement = build_announcement(state->announcement); - accesskit_tree_update_push_node(result, ANNOUNCEMENT_ID, announcement); - } - return result; -} - -accesskit_tree_update *build_tree_update_for_button_press(void *userdata) { - struct window_state *state = userdata; - accesskit_node *announcement = build_announcement(state->announcement); - accesskit_node *root = window_state_build_root(state); - accesskit_tree_update *update = - accesskit_tree_update_with_capacity_and_focus(2, state->focus); - accesskit_tree_update_push_node(update, ANNOUNCEMENT_ID, announcement); - accesskit_tree_update_push_node(update, WINDOW_ID, root); - return update; -} - -void window_state_press_button(struct window_state *state, - struct accesskit_sdl_adapter *adapter, - accesskit_node_id id) { - const char *text; - if (id == BUTTON_1_ID) { - text = "You pressed button 1"; - } else { - text = "You pressed button 2"; - } - state->announcement = text; - accesskit_sdl_adapter_update_if_active( - adapter, build_tree_update_for_button_press, state); -} - -accesskit_tree_update *build_tree_update_for_focus_update(void *userdata) { - struct window_state *state = userdata; - accesskit_tree_update *update = - accesskit_tree_update_with_focus(state->focus); - return update; -} - -void window_state_set_focus(struct window_state *state, - struct accesskit_sdl_adapter *adapter, - accesskit_node_id focus) { - state->focus = focus; - accesskit_sdl_adapter_update_if_active( - adapter, build_tree_update_for_focus_update, state); -} - -struct action_handler_state { - Uint32 event_type; - Uint32 window_id; -}; - -void do_action(accesskit_action_request *request, void *userdata) { - struct action_handler_state *state = userdata; - SDL_Event event; - SDL_zero(event); - event.type = state->event_type; - event.user.windowID = state->window_id; - event.user.data1 = (void *)((uintptr_t)(request->target)); - if (request->action == ACCESSKIT_ACTION_FOCUS) { - event.user.code = SET_FOCUS_MSG; - SDL_PushEvent(&event); - } else if (request->action == ACCESSKIT_ACTION_DEFAULT) { - event.user.code = DO_DEFAULT_ACTION_MSG; - SDL_PushEvent(&event); - } - accesskit_action_request_free(request); -} - -accesskit_tree_update *build_initial_tree(void *userdata) { - struct window_state *state = userdata; - window_state_lock(state); - accesskit_tree_update *update = window_state_build_initial_tree(state); - window_state_unlock(state); - return update; -} - -void deactivate_accessibility(void *userdata) { - /* There's nothing in the state that depends on whether the adapter - is active, so there's nothing to do here. */ -} - -int main(int argc, char *argv[]) { - printf("This example has no visible GUI, and a keyboard interface:\n"); - printf("- [Tab] switches focus between two logical buttons.\n"); - printf( - "- [Space] 'presses' the button, adding static text in a live region " - "announcing that it was pressed.\n"); -#if defined(_WIN32) - printf( - "Enable Narrator with [Win]+[Ctrl]+[Enter] (or [Win]+[Enter] on older " - "versions of Windows).\n"); -#elif defined(UNIX) - printf("Enable Orca with [Super]+[Alt]+[S].\n"); -#endif - if (SDL_Init(SDL_INIT_VIDEO) != 0) { - fprintf(stderr, "SDL initialization failed: (%s)\n", SDL_GetError()); - return -1; - } - Uint32 user_event = SDL_RegisterEvents(1); - if (user_event == (Uint32)-1) { - fprintf(stderr, "Couldn't register user event: (%s)\n", SDL_GetError()); - return -1; - } - - struct window_state state; - window_state_init(&state); - SDL_Window *window = - SDL_CreateWindow(WINDOW_TITLE, SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_HIDDEN); - Uint32 window_id = SDL_GetWindowID(window); - struct action_handler_state action_handler = {user_event, window_id}; - struct accesskit_sdl_adapter adapter; - accesskit_sdl_adapter_init(&adapter, window, build_initial_tree, &state, - do_action, &action_handler, - deactivate_accessibility, &state); - SDL_ShowWindow(window); - - SDL_Event event; - while (SDL_WaitEvent(&event)) { - if (event.type == SDL_QUIT) { - break; - } else if (event.type == SDL_WINDOWEVENT && - event.window.windowID == window_id) { - switch (event.window.event) { - case SDL_WINDOWEVENT_FOCUS_GAINED: - accesskit_sdl_adapter_update_window_focus_state(&adapter, true); - break; - case SDL_WINDOWEVENT_FOCUS_LOST: - accesskit_sdl_adapter_update_window_focus_state(&adapter, false); - break; - case SDL_WINDOWEVENT_MAXIMIZED: - case SDL_WINDOWEVENT_MOVED: - case SDL_WINDOWEVENT_RESIZED: - case SDL_WINDOWEVENT_RESTORED: - case SDL_WINDOWEVENT_SIZE_CHANGED: - case SDL_WINDOWEVENT_SHOWN: - accesskit_sdl_adapter_update_root_window_bounds(&adapter, window); - break; - } - } else if (event.type == SDL_KEYDOWN && event.key.windowID == window_id) { - switch (event.key.keysym.sym) { - case SDLK_TAB: - window_state_lock(&state); - accesskit_node_id new_focus = - (state.focus == BUTTON_1_ID) ? BUTTON_2_ID : BUTTON_1_ID; - window_state_set_focus(&state, &adapter, new_focus); - window_state_unlock(&state); - break; - case SDLK_SPACE: - window_state_lock(&state); - accesskit_node_id id = state.focus; - window_state_press_button(&state, &adapter, id); - window_state_unlock(&state); - break; - } - } else if (event.type == user_event && event.user.windowID == window_id) { - accesskit_node_id target = - (accesskit_node_id)((uintptr_t)(event.user.data1)); - if (target == BUTTON_1_ID || target == BUTTON_2_ID) { - window_state_lock(&state); - if (event.user.code == SET_FOCUS_MSG) { - window_state_set_focus(&state, &adapter, target); - } else if (event.user.code == DO_DEFAULT_ACTION_MSG) { - window_state_press_button(&state, &adapter, target); - } - window_state_unlock(&state); - } - } - } - - accesskit_sdl_adapter_destroy(&adapter); - window_state_destroy(&state); - SDL_Quit(); - return 0; -} diff --git a/bindings/c/examples/windows/.gitignore b/bindings/c/examples/windows/.gitignore deleted file mode 100644 index 378eac25..00000000 --- a/bindings/c/examples/windows/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build diff --git a/bindings/c/examples/windows/CMakeLists.txt b/bindings/c/examples/windows/CMakeLists.txt deleted file mode 100644 index 1335686b..00000000 --- a/bindings/c/examples/windows/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.20) - -project(windows_example) - -find_package(ACCESSKIT REQUIRED) - -add_executable(hello_world hello_world.c) -target_link_libraries(hello_world PUBLIC accesskit) -target_compile_definitions(hello_world PRIVATE -DUNICODE -D_UNICODE) diff --git a/bindings/c/examples/windows/README.md b/bindings/c/examples/windows/README.md deleted file mode 100644 index 8e5b343e..00000000 --- a/bindings/c/examples/windows/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# AccessKit Windows example - -This example demonstrates how to integrate AccessKit into a C/C++ project using CMake. - -## Building - -```bash -cmake -S . -B build -DACCESSKIT_DIR="../.." -cmake --build build --config Release -``` diff --git a/bindings/c/examples/windows/hello_world.c b/bindings/c/examples/windows/hello_world.c deleted file mode 100644 index 8228829c..00000000 --- a/bindings/c/examples/windows/hello_world.c +++ /dev/null @@ -1,296 +0,0 @@ -#include -#include - -#include "accesskit.h" - -const WCHAR CLASS_NAME[] = L"AccessKitTest"; - -const WCHAR WINDOW_TITLE[] = L"Hello world"; - -const accesskit_node_id WINDOW_ID = 0; -const accesskit_node_id BUTTON_1_ID = 1; -const accesskit_node_id BUTTON_2_ID = 2; -const accesskit_node_id ANNOUNCEMENT_ID = 3; -#define INITIAL_FOCUS BUTTON_1_ID - -const accesskit_rect BUTTON_1_RECT = {20.0, 20.0, 100.0, 60.0}; - -const accesskit_rect BUTTON_2_RECT = {20.0, 60.0, 100.0, 100.0}; - -const uint32_t SET_FOCUS_MSG = WM_USER; -const uint32_t DO_DEFAULT_ACTION_MSG = WM_USER + 1; - -accesskit_node *build_button(accesskit_node_id id, const char *name) { - accesskit_rect rect; - if (id == BUTTON_1_ID) { - rect = BUTTON_1_RECT; - } else { - rect = BUTTON_2_RECT; - } - - accesskit_node_builder *builder = - accesskit_node_builder_new(ACCESSKIT_ROLE_BUTTON); - accesskit_node_builder_set_bounds(builder, rect); - accesskit_node_builder_set_name(builder, name); - accesskit_node_builder_add_action(builder, ACCESSKIT_ACTION_FOCUS); - accesskit_node_builder_set_default_action_verb( - builder, ACCESSKIT_DEFAULT_ACTION_VERB_CLICK); - return accesskit_node_builder_build(builder); -} - -accesskit_node *build_announcement(const char *text) { - accesskit_node_builder *builder = - accesskit_node_builder_new(ACCESSKIT_ROLE_LABEL); - accesskit_node_builder_set_name(builder, text); - accesskit_node_builder_set_live(builder, ACCESSKIT_LIVE_POLITE); - return accesskit_node_builder_build(builder); -} - -struct window_state { - accesskit_windows_adapter *adapter; - accesskit_node_id focus; - const char *announcement; -}; - -void window_state_free(struct window_state *state) { - accesskit_windows_adapter_free(state->adapter); - free(state); -} - -accesskit_node *window_state_build_root(struct window_state *state) { - accesskit_node_builder *builder = - accesskit_node_builder_new(ACCESSKIT_ROLE_WINDOW); - accesskit_node_builder_push_child(builder, BUTTON_1_ID); - accesskit_node_builder_push_child(builder, BUTTON_2_ID); - if (state->announcement != NULL) { - accesskit_node_builder_push_child(builder, ANNOUNCEMENT_ID); - } - return accesskit_node_builder_build(builder); -} - -accesskit_tree_update *build_initial_tree(void *userdata) { - struct window_state *state = userdata; - accesskit_node *root = window_state_build_root(state); - accesskit_node *button_1 = build_button(BUTTON_1_ID, "Button 1"); - accesskit_node *button_2 = build_button(BUTTON_2_ID, "Button 2"); - accesskit_tree_update *result = accesskit_tree_update_with_capacity_and_focus( - (state->announcement != NULL) ? 4 : 3, state->focus); - accesskit_tree *tree = accesskit_tree_new(WINDOW_ID); - accesskit_tree_set_app_name(tree, "Hello World"); - accesskit_tree_update_set_tree(result, tree); - accesskit_tree_update_push_node(result, WINDOW_ID, root); - accesskit_tree_update_push_node(result, BUTTON_1_ID, button_1); - accesskit_tree_update_push_node(result, BUTTON_2_ID, button_2); - if (state->announcement != NULL) { - accesskit_node *announcement = build_announcement(state->announcement); - accesskit_tree_update_push_node(result, ANNOUNCEMENT_ID, announcement); - } - return result; -} - -void do_action(accesskit_action_request *request, void *userdata) { - HWND window = userdata; - if (request->action == ACCESSKIT_ACTION_FOCUS) { - LPARAM lparam = (LPARAM)(request->target); - PostMessage((HWND)window, SET_FOCUS_MSG, 0, lparam); - } else if (request->action == ACCESSKIT_ACTION_DEFAULT) { - LPARAM lparam = (LPARAM)(request->target); - PostMessage((HWND)window, DO_DEFAULT_ACTION_MSG, 0, lparam); - } - accesskit_action_request_free(request); -} - -accesskit_tree_update *build_tree_update_for_focus_update(void *userdata) { - struct window_state *state = userdata; - accesskit_tree_update *update = - accesskit_tree_update_with_focus(state->focus); - return update; -} - -void window_state_set_focus(struct window_state *state, - accesskit_node_id focus) { - state->focus = focus; - accesskit_windows_queued_events *events = - accesskit_windows_adapter_update_if_active( - state->adapter, build_tree_update_for_focus_update, state); - if (events != NULL) { - accesskit_windows_queued_events_raise(events); - } -} - -accesskit_tree_update *build_tree_update_for_button_press(void *userdata) { - struct window_state *state = userdata; - accesskit_node *announcement = build_announcement(state->announcement); - accesskit_node *root = window_state_build_root(state); - accesskit_tree_update *update = - accesskit_tree_update_with_capacity_and_focus(2, state->focus); - accesskit_tree_update_push_node(update, ANNOUNCEMENT_ID, announcement); - accesskit_tree_update_push_node(update, WINDOW_ID, root); - return update; -} - -void window_state_press_button(struct window_state *state, - accesskit_node_id id) { - const char *text; - if (id == BUTTON_1_ID) { - text = "You pressed button 1"; - } else { - text = "You pressed button 2"; - } - state->announcement = text; - accesskit_windows_queued_events *events = - accesskit_windows_adapter_update_if_active( - state->adapter, build_tree_update_for_button_press, state); - if (events != NULL) { - accesskit_windows_queued_events_raise(events); - } -} - -struct window_state *get_window_state(HWND window) { - return (struct window_state *)(GetWindowLongPtr(window, GWLP_USERDATA)); -} - -void update_window_focus_state(HWND window, bool is_focused) { - struct window_state *state = get_window_state(window); - accesskit_windows_queued_events *events = - accesskit_windows_adapter_update_window_focus_state(state->adapter, - is_focused); - if (events != NULL) { - accesskit_windows_queued_events_raise(events); - } -} - -struct window_create_params { - accesskit_node_id initial_focus; -}; - -LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - if (msg == WM_NCCREATE) { - CREATESTRUCT *create_struct = (CREATESTRUCT *)lParam; - struct window_create_params *create_params = - (struct window_create_params *)create_struct->lpCreateParams; - struct window_state *state = malloc(sizeof(struct window_state)); - state->adapter = - accesskit_windows_adapter_new(hwnd, false, do_action, (void *)hwnd); - state->focus = create_params->initial_focus; - state->announcement = NULL; - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)state); - return DefWindowProc(hwnd, msg, wParam, lParam); - } else if (msg == WM_PAINT) { - ValidateRect(hwnd, NULL); - } else if (msg == WM_DESTROY) { - LONG_PTR ptr = SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); - if (ptr != 0) { - struct window_state *state = (struct window_state *)ptr; - window_state_free(state); - } - PostQuitMessage(0); - } else if (msg == WM_GETOBJECT) { - struct window_state *state = get_window_state(hwnd); - if (state == NULL) { - // We need to be prepared to gracefully handle WM_GETOBJECT - // while the window is being destroyed; this can happen if - // the thread is using a COM STA. - return DefWindowProc(hwnd, msg, wParam, lParam); - } - accesskit_opt_lresult result = - accesskit_windows_adapter_handle_wm_getobject( - state->adapter, wParam, lParam, build_initial_tree, state); - if (result.has_value) { - return result.value; - } else { - return DefWindowProc(hwnd, msg, wParam, lParam); - } - } else if (msg == WM_SETFOCUS || msg == WM_EXITMENULOOP || - msg == WM_EXITSIZEMOVE) { - update_window_focus_state(hwnd, true); - } else if (msg == WM_KILLFOCUS || msg == WM_ENTERMENULOOP || - msg == WM_ENTERSIZEMOVE) { - update_window_focus_state(hwnd, false); - } else if (msg == WM_KEYDOWN) { - if (wParam == VK_TAB) { - struct window_state *state = get_window_state(hwnd); - accesskit_node_id new_focus = - (state->focus == BUTTON_1_ID) ? BUTTON_2_ID : BUTTON_1_ID; - window_state_set_focus(state, new_focus); - } else if (wParam == VK_SPACE) { - struct window_state *state = get_window_state(hwnd); - accesskit_node_id id = state->focus; - window_state_press_button(state, id); - } else { - return DefWindowProc(hwnd, msg, wParam, lParam); - } - } else if (msg == SET_FOCUS_MSG) { - accesskit_node_id id = (accesskit_node_id)lParam; - if (id == BUTTON_1_ID || id == BUTTON_2_ID) { - struct window_state *state = get_window_state(hwnd); - window_state_set_focus(state, id); - } - } else if (msg == DO_DEFAULT_ACTION_MSG) { - accesskit_node_id id = (accesskit_node_id)lParam; - if (id == BUTTON_1_ID || id == BUTTON_2_ID) { - struct window_state *state = get_window_state(hwnd); - window_state_press_button(state, id); - } - } else { - return DefWindowProc(hwnd, msg, wParam, lParam); - } - return 0; -} - -HWND create_window(const WCHAR *title, accesskit_node_id initial_focus) { - struct window_create_params create_params; - create_params.initial_focus = initial_focus; - - return CreateWindowEx(WS_EX_CLIENTEDGE, CLASS_NAME, title, - WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, - GetModuleHandle(NULL), &create_params); -} - -int main() { - printf("This example has no visible GUI, and a keyboard interface:\n"); - printf("- [Tab] switches focus between two logical buttons.\n"); - printf( - "- [Space] 'presses' the button, adding static text in a live region " - "announcing that it was pressed.\n"); - printf( - "Enable Narrator with [Win]+[Ctrl]+[Enter] (or [Win]+[Enter] on older " - "versions of Windows).\n"); - - WNDCLASSEX wc; - HWND hwnd; - MSG Msg; - - wc.cbSize = sizeof(WNDCLASSEX); - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = GetModuleHandle(NULL); - wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wc.lpszMenuName = NULL; - wc.lpszClassName = CLASS_NAME; - wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); - - if (!RegisterClassEx(&wc)) { - return 0; - } - - hwnd = create_window(WINDOW_TITLE, INITIAL_FOCUS); - - if (hwnd == NULL) { - return 0; - } - - ShowWindow(hwnd, SW_SHOW); - UpdateWindow(hwnd); - - while (GetMessage(&Msg, NULL, 0, 0) > 0) { - TranslateMessage(&Msg); - DispatchMessage(&Msg); - } - return Msg.wParam; -} diff --git a/bindings/c/include/accesskit.h b/bindings/c/include/accesskit.h deleted file mode 100644 index c96cd64c..00000000 --- a/bindings/c/include/accesskit.h +++ /dev/null @@ -1,2901 +0,0 @@ -/** - * Copyright 2023 The AccessKit Authors. All rights reserved. - * Licensed under the Apache License, Version 2.0 (found in - * the LICENSE-APACHE file) or the MIT license (found in - * the LICENSE-MIT file), at your option. - */ - -#ifndef ACCESSKIT_H -#define ACCESSKIT_H - -#include -#include -#include -#include -#include -#ifdef _WIN32 -#include -#endif - -/** - * An action to be taken on an accessibility node. - * - * In contrast to [`DefaultActionVerb`], these describe what happens to the - * object, e.g. "focus". - */ -enum accesskit_action -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - /** - * Do the default action for an object, typically this means "click". - */ - ACCESSKIT_ACTION_DEFAULT, - ACCESSKIT_ACTION_FOCUS, - ACCESSKIT_ACTION_BLUR, - ACCESSKIT_ACTION_COLLAPSE, - ACCESSKIT_ACTION_EXPAND, - /** - * Requires [`ActionRequest::data`] to be set to [`ActionData::CustomAction`]. - */ - ACCESSKIT_ACTION_CUSTOM_ACTION, - /** - * Decrement a numeric value by one step. - */ - ACCESSKIT_ACTION_DECREMENT, - /** - * Increment a numeric value by one step. - */ - ACCESSKIT_ACTION_INCREMENT, - ACCESSKIT_ACTION_HIDE_TOOLTIP, - ACCESSKIT_ACTION_SHOW_TOOLTIP, - /** - * Delete any selected text in the control's text value and - * insert the specified value in its place, like when typing or pasting. - * Requires [`ActionRequest::data`] to be set to [`ActionData::Value`]. - */ - ACCESSKIT_ACTION_REPLACE_SELECTED_TEXT, - ACCESSKIT_ACTION_SCROLL_BACKWARD, - ACCESSKIT_ACTION_SCROLL_DOWN, - ACCESSKIT_ACTION_SCROLL_FORWARD, - ACCESSKIT_ACTION_SCROLL_LEFT, - ACCESSKIT_ACTION_SCROLL_RIGHT, - ACCESSKIT_ACTION_SCROLL_UP, - /** - * Scroll any scrollable containers to make the target object visible - * on the screen. Optionally set [`ActionRequest::data`] to - * [`ActionData::ScrollTargetRect`]. - */ - ACCESSKIT_ACTION_SCROLL_INTO_VIEW, - /** - * Scroll the given object to a specified point in the tree's container - * (e.g. window). Requires [`ActionRequest::data`] to be set to - * [`ActionData::ScrollToPoint`]. - */ - ACCESSKIT_ACTION_SCROLL_TO_POINT, - /** - * Requires [`ActionRequest::data`] to be set to - * [`ActionData::SetScrollOffset`]. - */ - ACCESSKIT_ACTION_SET_SCROLL_OFFSET, - /** - * Requires [`ActionRequest::data`] to be set to - * [`ActionData::SetTextSelection`]. - */ - ACCESSKIT_ACTION_SET_TEXT_SELECTION, - /** - * Don't focus this node, but set it as the sequential focus navigation - * starting point, so that pressing Tab moves to the next element - * following this one, for example. - */ - ACCESSKIT_ACTION_SET_SEQUENTIAL_FOCUS_NAVIGATION_STARTING_POINT, - /** - * Replace the value of the control with the specified value and - * reset the selection, if applicable. Requires [`ActionRequest::data`] - * to be set to [`ActionData::Value`] or [`ActionData::NumericValue`]. - */ - ACCESSKIT_ACTION_SET_VALUE, - ACCESSKIT_ACTION_SHOW_CONTEXT_MENU, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_action; -#endif // __cplusplus - -enum accesskit_aria_current -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - ACCESSKIT_ARIA_CURRENT_FALSE, - ACCESSKIT_ARIA_CURRENT_TRUE, - ACCESSKIT_ARIA_CURRENT_PAGE, - ACCESSKIT_ARIA_CURRENT_STEP, - ACCESSKIT_ARIA_CURRENT_LOCATION, - ACCESSKIT_ARIA_CURRENT_DATE, - ACCESSKIT_ARIA_CURRENT_TIME, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_aria_current; -#endif // __cplusplus - -enum accesskit_auto_complete -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - ACCESSKIT_AUTO_COMPLETE_INLINE, - ACCESSKIT_AUTO_COMPLETE_LIST, - ACCESSKIT_AUTO_COMPLETE_BOTH, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_auto_complete; -#endif // __cplusplus - -/** - * Describes the action that will be performed on a given node when - * executing the default action, which is a click. - * - * In contrast to [`Action`], these describe what the user can do on the - * object, e.g. "press", not what happens to the object as a result. - * Only one verb can be used at a time to describe the default action. - */ -enum accesskit_default_action_verb -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - ACCESSKIT_DEFAULT_ACTION_VERB_CLICK, - ACCESSKIT_DEFAULT_ACTION_VERB_FOCUS, - ACCESSKIT_DEFAULT_ACTION_VERB_CHECK, - ACCESSKIT_DEFAULT_ACTION_VERB_UNCHECK, - /** - * A click will be performed on one of the node's ancestors. - * This happens when the node itself is not clickable, but one of its - * ancestors has click handlers attached which are able to capture the click - * as it bubbles up. - */ - ACCESSKIT_DEFAULT_ACTION_VERB_CLICK_ANCESTOR, - ACCESSKIT_DEFAULT_ACTION_VERB_JUMP, - ACCESSKIT_DEFAULT_ACTION_VERB_OPEN, - ACCESSKIT_DEFAULT_ACTION_VERB_PRESS, - ACCESSKIT_DEFAULT_ACTION_VERB_SELECT, - ACCESSKIT_DEFAULT_ACTION_VERB_UNSELECT, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_default_action_verb; -#endif // __cplusplus - -enum accesskit_has_popup -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - ACCESSKIT_HAS_POPUP_TRUE, - ACCESSKIT_HAS_POPUP_MENU, - ACCESSKIT_HAS_POPUP_LISTBOX, - ACCESSKIT_HAS_POPUP_TREE, - ACCESSKIT_HAS_POPUP_GRID, - ACCESSKIT_HAS_POPUP_DIALOG, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_has_popup; -#endif // __cplusplus - -/** - * Indicates if a form control has invalid input or if a web DOM element has an - * [`aria-invalid`] attribute. - * - * [`aria-invalid`]: https://www.w3.org/TR/wai-aria-1.1/#aria-invalid - */ -enum accesskit_invalid -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - ACCESSKIT_INVALID_TRUE, - ACCESSKIT_INVALID_GRAMMAR, - ACCESSKIT_INVALID_SPELLING, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_invalid; -#endif // __cplusplus - -enum accesskit_list_style -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - ACCESSKIT_LIST_STYLE_CIRCLE, - ACCESSKIT_LIST_STYLE_DISC, - ACCESSKIT_LIST_STYLE_IMAGE, - ACCESSKIT_LIST_STYLE_NUMERIC, - ACCESSKIT_LIST_STYLE_SQUARE, - /** - * Language specific ordering (alpha, roman, cjk-ideographic, etc...) - */ - ACCESSKIT_LIST_STYLE_OTHER, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_list_style; -#endif // __cplusplus - -enum accesskit_live -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - ACCESSKIT_LIVE_OFF, - ACCESSKIT_LIVE_POLITE, - ACCESSKIT_LIVE_ASSERTIVE, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_live; -#endif // __cplusplus - -enum accesskit_orientation -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - /** - * E.g. most toolbars and separators. - */ - ACCESSKIT_ORIENTATION_HORIZONTAL, - /** - * E.g. menu or combo box. - */ - ACCESSKIT_ORIENTATION_VERTICAL, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_orientation; -#endif // __cplusplus - -/** - * The type of an accessibility node. - * - * The majority of these roles come from the ARIA specification. Reference - * the latest draft for proper usage. - * - * Like the AccessKit schema as a whole, this list is largely taken - * from Chromium. However, unlike Chromium's alphabetized list, this list - * is ordered roughly by expected usage frequency (with the notable exception - * of [`Role::Unknown`]). This is more efficient in serialization formats - * where integers use a variable-length encoding. - */ -enum accesskit_role -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - ACCESSKIT_ROLE_UNKNOWN, - ACCESSKIT_ROLE_INLINE_TEXT_BOX, - ACCESSKIT_ROLE_CELL, - ACCESSKIT_ROLE_LABEL, - ACCESSKIT_ROLE_IMAGE, - ACCESSKIT_ROLE_LINK, - ACCESSKIT_ROLE_ROW, - ACCESSKIT_ROLE_LIST_ITEM, - /** - * Contains the bullet, number, or other marker for a list item. - */ - ACCESSKIT_ROLE_LIST_MARKER, - ACCESSKIT_ROLE_TREE_ITEM, - ACCESSKIT_ROLE_LIST_BOX_OPTION, - ACCESSKIT_ROLE_MENU_ITEM, - ACCESSKIT_ROLE_MENU_LIST_OPTION, - ACCESSKIT_ROLE_PARAGRAPH, - /** - * A generic container that should be ignored by assistive technologies - * and filtered out of platform accessibility trees. Equivalent to the ARIA - * `none` or `presentation` role, or to an HTML `div` with no role. - */ - ACCESSKIT_ROLE_GENERIC_CONTAINER, - ACCESSKIT_ROLE_CHECK_BOX, - ACCESSKIT_ROLE_RADIO_BUTTON, - ACCESSKIT_ROLE_TEXT_INPUT, - ACCESSKIT_ROLE_BUTTON, - ACCESSKIT_ROLE_DEFAULT_BUTTON, - ACCESSKIT_ROLE_PANE, - ACCESSKIT_ROLE_ROW_HEADER, - ACCESSKIT_ROLE_COLUMN_HEADER, - ACCESSKIT_ROLE_ROW_GROUP, - ACCESSKIT_ROLE_LIST, - ACCESSKIT_ROLE_TABLE, - ACCESSKIT_ROLE_LAYOUT_TABLE_CELL, - ACCESSKIT_ROLE_LAYOUT_TABLE_ROW, - ACCESSKIT_ROLE_LAYOUT_TABLE, - ACCESSKIT_ROLE_SWITCH, - ACCESSKIT_ROLE_MENU, - ACCESSKIT_ROLE_MULTILINE_TEXT_INPUT, - ACCESSKIT_ROLE_SEARCH_INPUT, - ACCESSKIT_ROLE_DATE_INPUT, - ACCESSKIT_ROLE_DATE_TIME_INPUT, - ACCESSKIT_ROLE_WEEK_INPUT, - ACCESSKIT_ROLE_MONTH_INPUT, - ACCESSKIT_ROLE_TIME_INPUT, - ACCESSKIT_ROLE_EMAIL_INPUT, - ACCESSKIT_ROLE_NUMBER_INPUT, - ACCESSKIT_ROLE_PASSWORD_INPUT, - ACCESSKIT_ROLE_PHONE_NUMBER_INPUT, - ACCESSKIT_ROLE_URL_INPUT, - ACCESSKIT_ROLE_ABBR, - ACCESSKIT_ROLE_ALERT, - ACCESSKIT_ROLE_ALERT_DIALOG, - ACCESSKIT_ROLE_APPLICATION, - ACCESSKIT_ROLE_ARTICLE, - ACCESSKIT_ROLE_AUDIO, - ACCESSKIT_ROLE_BANNER, - ACCESSKIT_ROLE_BLOCKQUOTE, - ACCESSKIT_ROLE_CANVAS, - ACCESSKIT_ROLE_CAPTION, - ACCESSKIT_ROLE_CARET, - ACCESSKIT_ROLE_CODE, - ACCESSKIT_ROLE_COLOR_WELL, - ACCESSKIT_ROLE_COMBO_BOX, - ACCESSKIT_ROLE_EDITABLE_COMBO_BOX, - ACCESSKIT_ROLE_COMPLEMENTARY, - ACCESSKIT_ROLE_COMMENT, - ACCESSKIT_ROLE_CONTENT_DELETION, - ACCESSKIT_ROLE_CONTENT_INSERTION, - ACCESSKIT_ROLE_CONTENT_INFO, - ACCESSKIT_ROLE_DEFINITION, - ACCESSKIT_ROLE_DESCRIPTION_LIST, - ACCESSKIT_ROLE_DESCRIPTION_LIST_DETAIL, - ACCESSKIT_ROLE_DESCRIPTION_LIST_TERM, - ACCESSKIT_ROLE_DETAILS, - ACCESSKIT_ROLE_DIALOG, - ACCESSKIT_ROLE_DIRECTORY, - ACCESSKIT_ROLE_DISCLOSURE_TRIANGLE, - ACCESSKIT_ROLE_DOCUMENT, - ACCESSKIT_ROLE_EMBEDDED_OBJECT, - ACCESSKIT_ROLE_EMPHASIS, - ACCESSKIT_ROLE_FEED, - ACCESSKIT_ROLE_FIGURE_CAPTION, - ACCESSKIT_ROLE_FIGURE, - ACCESSKIT_ROLE_FOOTER, - ACCESSKIT_ROLE_FOOTER_AS_NON_LANDMARK, - ACCESSKIT_ROLE_FORM, - ACCESSKIT_ROLE_GRID, - ACCESSKIT_ROLE_GROUP, - ACCESSKIT_ROLE_HEADER, - ACCESSKIT_ROLE_HEADER_AS_NON_LANDMARK, - ACCESSKIT_ROLE_HEADING, - ACCESSKIT_ROLE_IFRAME, - ACCESSKIT_ROLE_IFRAME_PRESENTATIONAL, - ACCESSKIT_ROLE_IME_CANDIDATE, - ACCESSKIT_ROLE_KEYBOARD, - ACCESSKIT_ROLE_LEGEND, - ACCESSKIT_ROLE_LINE_BREAK, - ACCESSKIT_ROLE_LIST_BOX, - ACCESSKIT_ROLE_LOG, - ACCESSKIT_ROLE_MAIN, - ACCESSKIT_ROLE_MARK, - ACCESSKIT_ROLE_MARQUEE, - ACCESSKIT_ROLE_MATH, - ACCESSKIT_ROLE_MENU_BAR, - ACCESSKIT_ROLE_MENU_ITEM_CHECK_BOX, - ACCESSKIT_ROLE_MENU_ITEM_RADIO, - ACCESSKIT_ROLE_MENU_LIST_POPUP, - ACCESSKIT_ROLE_METER, - ACCESSKIT_ROLE_NAVIGATION, - ACCESSKIT_ROLE_NOTE, - ACCESSKIT_ROLE_PLUGIN_OBJECT, - ACCESSKIT_ROLE_PORTAL, - ACCESSKIT_ROLE_PRE, - ACCESSKIT_ROLE_PROGRESS_INDICATOR, - ACCESSKIT_ROLE_RADIO_GROUP, - ACCESSKIT_ROLE_REGION, - ACCESSKIT_ROLE_ROOT_WEB_AREA, - ACCESSKIT_ROLE_RUBY, - ACCESSKIT_ROLE_RUBY_ANNOTATION, - ACCESSKIT_ROLE_SCROLL_BAR, - ACCESSKIT_ROLE_SCROLL_VIEW, - ACCESSKIT_ROLE_SEARCH, - ACCESSKIT_ROLE_SECTION, - ACCESSKIT_ROLE_SLIDER, - ACCESSKIT_ROLE_SPIN_BUTTON, - ACCESSKIT_ROLE_SPLITTER, - ACCESSKIT_ROLE_STATUS, - ACCESSKIT_ROLE_STRONG, - ACCESSKIT_ROLE_SUGGESTION, - ACCESSKIT_ROLE_SVG_ROOT, - ACCESSKIT_ROLE_TAB, - ACCESSKIT_ROLE_TAB_LIST, - ACCESSKIT_ROLE_TAB_PANEL, - ACCESSKIT_ROLE_TERM, - ACCESSKIT_ROLE_TIME, - ACCESSKIT_ROLE_TIMER, - ACCESSKIT_ROLE_TITLE_BAR, - ACCESSKIT_ROLE_TOOLBAR, - ACCESSKIT_ROLE_TOOLTIP, - ACCESSKIT_ROLE_TREE, - ACCESSKIT_ROLE_TREE_GRID, - ACCESSKIT_ROLE_VIDEO, - ACCESSKIT_ROLE_WEB_VIEW, - ACCESSKIT_ROLE_WINDOW, - ACCESSKIT_ROLE_PDF_ACTIONABLE_HIGHLIGHT, - ACCESSKIT_ROLE_PDF_ROOT, - ACCESSKIT_ROLE_GRAPHICS_DOCUMENT, - ACCESSKIT_ROLE_GRAPHICS_OBJECT, - ACCESSKIT_ROLE_GRAPHICS_SYMBOL, - ACCESSKIT_ROLE_DOC_ABSTRACT, - ACCESSKIT_ROLE_DOC_ACKNOWLEDGEMENTS, - ACCESSKIT_ROLE_DOC_AFTERWORD, - ACCESSKIT_ROLE_DOC_APPENDIX, - ACCESSKIT_ROLE_DOC_BACK_LINK, - ACCESSKIT_ROLE_DOC_BIBLIO_ENTRY, - ACCESSKIT_ROLE_DOC_BIBLIOGRAPHY, - ACCESSKIT_ROLE_DOC_BIBLIO_REF, - ACCESSKIT_ROLE_DOC_CHAPTER, - ACCESSKIT_ROLE_DOC_COLOPHON, - ACCESSKIT_ROLE_DOC_CONCLUSION, - ACCESSKIT_ROLE_DOC_COVER, - ACCESSKIT_ROLE_DOC_CREDIT, - ACCESSKIT_ROLE_DOC_CREDITS, - ACCESSKIT_ROLE_DOC_DEDICATION, - ACCESSKIT_ROLE_DOC_ENDNOTE, - ACCESSKIT_ROLE_DOC_ENDNOTES, - ACCESSKIT_ROLE_DOC_EPIGRAPH, - ACCESSKIT_ROLE_DOC_EPILOGUE, - ACCESSKIT_ROLE_DOC_ERRATA, - ACCESSKIT_ROLE_DOC_EXAMPLE, - ACCESSKIT_ROLE_DOC_FOOTNOTE, - ACCESSKIT_ROLE_DOC_FOREWORD, - ACCESSKIT_ROLE_DOC_GLOSSARY, - ACCESSKIT_ROLE_DOC_GLOSS_REF, - ACCESSKIT_ROLE_DOC_INDEX, - ACCESSKIT_ROLE_DOC_INTRODUCTION, - ACCESSKIT_ROLE_DOC_NOTE_REF, - ACCESSKIT_ROLE_DOC_NOTICE, - ACCESSKIT_ROLE_DOC_PAGE_BREAK, - ACCESSKIT_ROLE_DOC_PAGE_FOOTER, - ACCESSKIT_ROLE_DOC_PAGE_HEADER, - ACCESSKIT_ROLE_DOC_PAGE_LIST, - ACCESSKIT_ROLE_DOC_PART, - ACCESSKIT_ROLE_DOC_PREFACE, - ACCESSKIT_ROLE_DOC_PROLOGUE, - ACCESSKIT_ROLE_DOC_PULLQUOTE, - ACCESSKIT_ROLE_DOC_QNA, - ACCESSKIT_ROLE_DOC_SUBTITLE, - ACCESSKIT_ROLE_DOC_TIP, - ACCESSKIT_ROLE_DOC_TOC, - /** - * Behaves similar to an ARIA grid but is primarily used by Chromium's - * `TableView` and its subclasses, so they can be exposed correctly - * on certain platforms. - */ - ACCESSKIT_ROLE_LIST_GRID, - /** - * This is just like a multi-line document, but signals that assistive - * technologies should implement behavior specific to a VT-100-style - * terminal. - */ - ACCESSKIT_ROLE_TERMINAL, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_role; -#endif // __cplusplus - -enum accesskit_sort_direction -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - ACCESSKIT_SORT_DIRECTION_ASCENDING, - ACCESSKIT_SORT_DIRECTION_DESCENDING, - ACCESSKIT_SORT_DIRECTION_OTHER, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_sort_direction; -#endif // __cplusplus - -enum accesskit_text_align -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - ACCESSKIT_TEXT_ALIGN_LEFT, - ACCESSKIT_TEXT_ALIGN_RIGHT, - ACCESSKIT_TEXT_ALIGN_CENTER, - ACCESSKIT_TEXT_ALIGN_JUSTIFY, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_text_align; -#endif // __cplusplus - -enum accesskit_text_decoration -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - ACCESSKIT_TEXT_DECORATION_SOLID, - ACCESSKIT_TEXT_DECORATION_DOTTED, - ACCESSKIT_TEXT_DECORATION_DASHED, - ACCESSKIT_TEXT_DECORATION_DOUBLE, - ACCESSKIT_TEXT_DECORATION_WAVY, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_text_decoration; -#endif // __cplusplus - -enum accesskit_text_direction -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - ACCESSKIT_TEXT_DIRECTION_LEFT_TO_RIGHT, - ACCESSKIT_TEXT_DIRECTION_RIGHT_TO_LEFT, - ACCESSKIT_TEXT_DIRECTION_TOP_TO_BOTTOM, - ACCESSKIT_TEXT_DIRECTION_BOTTOM_TO_TOP, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_text_direction; -#endif // __cplusplus - -enum accesskit_toggled -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - ACCESSKIT_TOGGLED_FALSE, - ACCESSKIT_TOGGLED_TRUE, - ACCESSKIT_TOGGLED_MIXED, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_toggled; -#endif // __cplusplus - -enum accesskit_vertical_offset -#ifdef __cplusplus - : uint8_t -#endif // __cplusplus -{ - ACCESSKIT_VERTICAL_OFFSET_SUBSCRIPT, - ACCESSKIT_VERTICAL_OFFSET_SUPERSCRIPT, -}; -#ifndef __cplusplus -typedef uint8_t accesskit_vertical_offset; -#endif // __cplusplus - -#if defined(__APPLE__) -typedef struct accesskit_macos_adapter accesskit_macos_adapter; -#endif - -#if defined(__APPLE__) -typedef struct accesskit_macos_queued_events accesskit_macos_queued_events; -#endif - -#if defined(__APPLE__) -typedef struct accesskit_macos_subclassing_adapter - accesskit_macos_subclassing_adapter; -#endif - -typedef struct accesskit_node accesskit_node; - -typedef struct accesskit_node_builder accesskit_node_builder; - -typedef struct accesskit_tree accesskit_tree; - -typedef struct accesskit_tree_update accesskit_tree_update; - -#if (defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ - defined(__NetBSD__) || defined(__OpenBSD__)) -typedef struct accesskit_unix_adapter accesskit_unix_adapter; -#endif - -#if defined(_WIN32) -typedef struct accesskit_windows_adapter accesskit_windows_adapter; -#endif - -#if defined(_WIN32) -typedef struct accesskit_windows_queued_events accesskit_windows_queued_events; -#endif - -#if defined(_WIN32) -typedef struct accesskit_windows_subclassing_adapter - accesskit_windows_subclassing_adapter; -#endif - -typedef uint64_t accesskit_node_id; - -typedef struct accesskit_node_ids { - size_t length; - const accesskit_node_id *values; -} accesskit_node_ids; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_node_id { - bool has_value; - accesskit_node_id value; -} accesskit_opt_node_id; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_double { - bool has_value; - double value; -} accesskit_opt_double; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_index { - bool has_value; - size_t value; -} accesskit_opt_index; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_color { - bool has_value; - uint32_t value; -} accesskit_opt_color; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_text_decoration { - bool has_value; - accesskit_text_decoration value; -} accesskit_opt_text_decoration; - -typedef struct accesskit_lengths { - size_t length; - const uint8_t *values; -} accesskit_lengths; - -typedef struct accesskit_opt_coords { - bool has_value; - size_t length; - const float *values; -} accesskit_opt_coords; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_bool { - bool has_value; - bool value; -} accesskit_opt_bool; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_invalid { - bool has_value; - accesskit_invalid value; -} accesskit_opt_invalid; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_toggled { - bool has_value; - accesskit_toggled value; -} accesskit_opt_toggled; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_live { - bool has_value; - accesskit_live value; -} accesskit_opt_live; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_default_action_verb { - bool has_value; - accesskit_default_action_verb value; -} accesskit_opt_default_action_verb; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_text_direction { - bool has_value; - accesskit_text_direction value; -} accesskit_opt_text_direction; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_orientation { - bool has_value; - accesskit_orientation value; -} accesskit_opt_orientation; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_sort_direction { - bool has_value; - accesskit_sort_direction value; -} accesskit_opt_sort_direction; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_aria_current { - bool has_value; - accesskit_aria_current value; -} accesskit_opt_aria_current; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_auto_complete { - bool has_value; - accesskit_auto_complete value; -} accesskit_opt_auto_complete; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_has_popup { - bool has_value; - accesskit_has_popup value; -} accesskit_opt_has_popup; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_list_style { - bool has_value; - accesskit_list_style value; -} accesskit_opt_list_style; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_text_align { - bool has_value; - accesskit_text_align value; -} accesskit_opt_text_align; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_vertical_offset { - bool has_value; - accesskit_vertical_offset value; -} accesskit_opt_vertical_offset; - -/** - * A 2D affine transform. Derived from - * [kurbo](https://github.com/linebender/kurbo). - */ -typedef struct accesskit_affine { - double _0[6]; -} accesskit_affine; - -/** - * A rectangle. Derived from [kurbo](https://github.com/linebender/kurbo). - */ -typedef struct accesskit_rect { - /** - * The minimum x coordinate (left edge). - */ - double x0; - /** - * The minimum y coordinate (top edge in y-down spaces). - */ - double y0; - /** - * The maximum x coordinate (right edge). - */ - double x1; - /** - * The maximum y coordinate (bottom edge in y-down spaces). - */ - double y1; -} accesskit_rect; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_rect { - bool has_value; - struct accesskit_rect value; -} accesskit_opt_rect; - -typedef struct accesskit_text_position { - accesskit_node_id node; - size_t character_index; -} accesskit_text_position; - -typedef struct accesskit_text_selection { - struct accesskit_text_position anchor; - struct accesskit_text_position focus; -} accesskit_text_selection; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_text_selection { - bool has_value; - struct accesskit_text_selection value; -} accesskit_opt_text_selection; - -/** - * Use `accesskit_custom_action_new` to create this struct. Do not reallocate - * `description`. - * - * When you get this struct, you are responsible for freeing `description`. - */ -typedef struct accesskit_custom_action { - int32_t id; - char *description; -} accesskit_custom_action; - -typedef struct accesskit_custom_actions { - size_t length; - struct accesskit_custom_action *values; -} accesskit_custom_actions; - -/** - * A 2D point. Derived from [kurbo](https://github.com/linebender/kurbo). - */ -typedef struct accesskit_point { - /** - * The x coordinate. - */ - double x; - /** - * The y coordinate. - */ - double y; -} accesskit_point; - -typedef enum accesskit_action_data_Tag { - ACCESSKIT_ACTION_DATA_CUSTOM_ACTION, - ACCESSKIT_ACTION_DATA_VALUE, - ACCESSKIT_ACTION_DATA_NUMERIC_VALUE, - ACCESSKIT_ACTION_DATA_SCROLL_TARGET_RECT, - ACCESSKIT_ACTION_DATA_SCROLL_TO_POINT, - ACCESSKIT_ACTION_DATA_SET_SCROLL_OFFSET, - ACCESSKIT_ACTION_DATA_SET_TEXT_SELECTION, -} accesskit_action_data_Tag; - -typedef struct accesskit_action_data { - accesskit_action_data_Tag tag; - union { - struct { - int32_t custom_action; - }; - struct { - char *value; - }; - struct { - double numeric_value; - }; - struct { - struct accesskit_rect scroll_target_rect; - }; - struct { - struct accesskit_point scroll_to_point; - }; - struct { - struct accesskit_point set_scroll_offset; - }; - struct { - struct accesskit_text_selection set_text_selection; - }; - }; -} accesskit_action_data; - -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_action_data { - bool has_value; - struct accesskit_action_data value; -} accesskit_opt_action_data; - -typedef struct accesskit_action_request { - accesskit_action action; - accesskit_node_id target; - struct accesskit_opt_action_data data; -} accesskit_action_request; - -/** - * A 2D vector. Derived from [kurbo](https://github.com/linebender/kurbo). - * - * This is intended primarily for a vector in the mathematical sense, - * but it can be interpreted as a translation, and converted to and - * from a point (vector relative to the origin) and size. - */ -typedef struct accesskit_vec2 { - /** - * The x-coordinate. - */ - double x; - /** - * The y-coordinate. - */ - double y; -} accesskit_vec2; - -/** - * A 2D size. Derived from [kurbo](https://github.com/linebender/kurbo). - */ -typedef struct accesskit_size { - /** - * The width. - */ - double width; - /** - * The height. - */ - double height; -} accesskit_size; - -/** - * Ownership of `request` is transfered to the callback. `request` must - * be freed using `accesskit_action_request_free`. - */ -typedef void (*accesskit_action_handler_callback)( - struct accesskit_action_request *request, void *userdata); - -typedef void *accesskit_tree_update_factory_userdata; - -/** - * This function can't return a null pointer. Ownership of the returned value - * will be transferred to the caller. - */ -typedef struct accesskit_tree_update *(*accesskit_tree_update_factory)( - accesskit_tree_update_factory_userdata); - -typedef struct accesskit_tree_update *(*accesskit_activation_handler_callback)( - void *userdata); - -typedef void (*accesskit_deactivation_handler_callback)(void *userdata); - -#if defined(_WIN32) -/** - * Represents an optional value. - * - * If `has_value` is false, do not read the `value` field. - */ -typedef struct accesskit_opt_lresult { - bool has_value; - LRESULT value; -} accesskit_opt_lresult; -#endif - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -void accesskit_node_free(struct accesskit_node *node); - -accesskit_role accesskit_node_role(const struct accesskit_node *node); - -accesskit_role accesskit_node_builder_role( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_role(struct accesskit_node_builder *builder, - accesskit_role value); - -bool accesskit_node_supports_action(const struct accesskit_node *node, - accesskit_action action); - -bool accesskit_node_builder_supports_action( - const struct accesskit_node_builder *builder, accesskit_action action); - -void accesskit_node_builder_add_action(struct accesskit_node_builder *builder, - accesskit_action action); - -void accesskit_node_builder_remove_action( - struct accesskit_node_builder *builder, accesskit_action action); - -void accesskit_node_builder_clear_actions( - struct accesskit_node_builder *builder); - -bool accesskit_node_is_hovered(const struct accesskit_node *node); - -bool accesskit_node_is_hidden(const struct accesskit_node *node); - -bool accesskit_node_is_linked(const struct accesskit_node *node); - -bool accesskit_node_is_multiselectable(const struct accesskit_node *node); - -bool accesskit_node_is_required(const struct accesskit_node *node); - -bool accesskit_node_is_visited(const struct accesskit_node *node); - -bool accesskit_node_is_busy(const struct accesskit_node *node); - -bool accesskit_node_is_live_atomic(const struct accesskit_node *node); - -bool accesskit_node_is_modal(const struct accesskit_node *node); - -bool accesskit_node_is_touch_transparent(const struct accesskit_node *node); - -bool accesskit_node_is_read_only(const struct accesskit_node *node); - -bool accesskit_node_is_disabled(const struct accesskit_node *node); - -bool accesskit_node_is_bold(const struct accesskit_node *node); - -bool accesskit_node_is_italic(const struct accesskit_node *node); - -bool accesskit_node_clips_children(const struct accesskit_node *node); - -bool accesskit_node_is_line_breaking_object(const struct accesskit_node *node); - -bool accesskit_node_is_page_breaking_object(const struct accesskit_node *node); - -bool accesskit_node_is_spelling_error(const struct accesskit_node *node); - -bool accesskit_node_is_grammar_error(const struct accesskit_node *node); - -bool accesskit_node_is_search_match(const struct accesskit_node *node); - -bool accesskit_node_is_suggestion(const struct accesskit_node *node); - -bool accesskit_node_builder_is_hovered( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_hovered(struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_hovered( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_hidden( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_hidden(struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_hidden( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_linked( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_linked(struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_linked( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_multiselectable( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_multiselectable( - struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_multiselectable( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_required( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_required( - struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_required( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_visited( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_visited(struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_visited( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_busy( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_busy(struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_busy(struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_live_atomic( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_live_atomic( - struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_live_atomic( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_modal( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_modal(struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_modal(struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_touch_transparent( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_touch_transparent( - struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_touch_transparent( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_read_only( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_read_only( - struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_read_only( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_disabled( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_disabled( - struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_disabled( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_bold( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_bold(struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_bold(struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_italic( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_italic(struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_italic( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_clips_children( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_clips_children( - struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_clips_children( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_line_breaking_object( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_is_line_breaking_object( - struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_is_line_breaking_object( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_page_breaking_object( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_is_page_breaking_object( - struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_is_page_breaking_object( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_spelling_error( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_is_spelling_error( - struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_is_spelling_error( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_grammar_error( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_is_grammar_error( - struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_is_grammar_error( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_search_match( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_is_search_match( - struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_is_search_match( - struct accesskit_node_builder *builder); - -bool accesskit_node_builder_is_suggestion( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_is_suggestion( - struct accesskit_node_builder *builder); - -void accesskit_node_builder_clear_is_suggestion( - struct accesskit_node_builder *builder); - -struct accesskit_node_ids accesskit_node_children( - const struct accesskit_node *node); - -struct accesskit_node_ids accesskit_node_builder_children( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing `values`. - */ -void accesskit_node_builder_set_children(struct accesskit_node_builder *builder, - size_t length, - const accesskit_node_id *values); - -void accesskit_node_builder_push_child(struct accesskit_node_builder *builder, - accesskit_node_id item); - -void accesskit_node_builder_clear_children( - struct accesskit_node_builder *builder); - -struct accesskit_node_ids accesskit_node_controls( - const struct accesskit_node *node); - -struct accesskit_node_ids accesskit_node_builder_controls( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing `values`. - */ -void accesskit_node_builder_set_controls(struct accesskit_node_builder *builder, - size_t length, - const accesskit_node_id *values); - -void accesskit_node_builder_push_controlled( - struct accesskit_node_builder *builder, accesskit_node_id item); - -void accesskit_node_builder_clear_controls( - struct accesskit_node_builder *builder); - -struct accesskit_node_ids accesskit_node_details( - const struct accesskit_node *node); - -struct accesskit_node_ids accesskit_node_builder_details( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing `values`. - */ -void accesskit_node_builder_set_details(struct accesskit_node_builder *builder, - size_t length, - const accesskit_node_id *values); - -void accesskit_node_builder_push_detail(struct accesskit_node_builder *builder, - accesskit_node_id item); - -void accesskit_node_builder_clear_details( - struct accesskit_node_builder *builder); - -struct accesskit_node_ids accesskit_node_described_by( - const struct accesskit_node *node); - -struct accesskit_node_ids accesskit_node_builder_described_by( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing `values`. - */ -void accesskit_node_builder_set_described_by( - struct accesskit_node_builder *builder, size_t length, - const accesskit_node_id *values); - -void accesskit_node_builder_push_described_by( - struct accesskit_node_builder *builder, accesskit_node_id item); - -void accesskit_node_builder_clear_described_by( - struct accesskit_node_builder *builder); - -struct accesskit_node_ids accesskit_node_flow_to( - const struct accesskit_node *node); - -struct accesskit_node_ids accesskit_node_builder_flow_to( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing `values`. - */ -void accesskit_node_builder_set_flow_to(struct accesskit_node_builder *builder, - size_t length, - const accesskit_node_id *values); - -void accesskit_node_builder_push_flow_to(struct accesskit_node_builder *builder, - accesskit_node_id item); - -void accesskit_node_builder_clear_flow_to( - struct accesskit_node_builder *builder); - -struct accesskit_node_ids accesskit_node_labelled_by( - const struct accesskit_node *node); - -struct accesskit_node_ids accesskit_node_builder_labelled_by( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing `values`. - */ -void accesskit_node_builder_set_labelled_by( - struct accesskit_node_builder *builder, size_t length, - const accesskit_node_id *values); - -void accesskit_node_builder_push_labelled_by( - struct accesskit_node_builder *builder, accesskit_node_id item); - -void accesskit_node_builder_clear_labelled_by( - struct accesskit_node_builder *builder); - -struct accesskit_node_ids accesskit_node_owns( - const struct accesskit_node *node); - -struct accesskit_node_ids accesskit_node_builder_owns( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing `values`. - */ -void accesskit_node_builder_set_owns(struct accesskit_node_builder *builder, - size_t length, - const accesskit_node_id *values); - -void accesskit_node_builder_push_owned(struct accesskit_node_builder *builder, - accesskit_node_id item); - -void accesskit_node_builder_clear_owns(struct accesskit_node_builder *builder); - -struct accesskit_node_ids accesskit_node_radio_group( - const struct accesskit_node *node); - -struct accesskit_node_ids accesskit_node_builder_radio_group( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing `values`. - */ -void accesskit_node_builder_set_radio_group( - struct accesskit_node_builder *builder, size_t length, - const accesskit_node_id *values); - -void accesskit_node_builder_push_to_radio_group( - struct accesskit_node_builder *builder, accesskit_node_id item); - -void accesskit_node_builder_clear_radio_group( - struct accesskit_node_builder *builder); - -struct accesskit_opt_node_id accesskit_node_active_descendant( - const struct accesskit_node *node); - -struct accesskit_opt_node_id accesskit_node_builder_active_descendant( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_active_descendant( - struct accesskit_node_builder *builder, accesskit_node_id value); - -void accesskit_node_builder_clear_active_descendant( - struct accesskit_node_builder *builder); - -struct accesskit_opt_node_id accesskit_node_error_message( - const struct accesskit_node *node); - -struct accesskit_opt_node_id accesskit_node_builder_error_message( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_error_message( - struct accesskit_node_builder *builder, accesskit_node_id value); - -void accesskit_node_builder_clear_error_message( - struct accesskit_node_builder *builder); - -struct accesskit_opt_node_id accesskit_node_in_page_link_target( - const struct accesskit_node *node); - -struct accesskit_opt_node_id accesskit_node_builder_in_page_link_target( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_in_page_link_target( - struct accesskit_node_builder *builder, accesskit_node_id value); - -void accesskit_node_builder_clear_in_page_link_target( - struct accesskit_node_builder *builder); - -struct accesskit_opt_node_id accesskit_node_member_of( - const struct accesskit_node *node); - -struct accesskit_opt_node_id accesskit_node_builder_member_of( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_member_of( - struct accesskit_node_builder *builder, accesskit_node_id value); - -void accesskit_node_builder_clear_member_of( - struct accesskit_node_builder *builder); - -struct accesskit_opt_node_id accesskit_node_next_on_line( - const struct accesskit_node *node); - -struct accesskit_opt_node_id accesskit_node_builder_next_on_line( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_next_on_line( - struct accesskit_node_builder *builder, accesskit_node_id value); - -void accesskit_node_builder_clear_next_on_line( - struct accesskit_node_builder *builder); - -struct accesskit_opt_node_id accesskit_node_previous_on_line( - const struct accesskit_node *node); - -struct accesskit_opt_node_id accesskit_node_builder_previous_on_line( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_previous_on_line( - struct accesskit_node_builder *builder, accesskit_node_id value); - -void accesskit_node_builder_clear_previous_on_line( - struct accesskit_node_builder *builder); - -struct accesskit_opt_node_id accesskit_node_popup_for( - const struct accesskit_node *node); - -struct accesskit_opt_node_id accesskit_node_builder_popup_for( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_popup_for( - struct accesskit_node_builder *builder, accesskit_node_id value); - -void accesskit_node_builder_clear_popup_for( - struct accesskit_node_builder *builder); - -/** - * Only call this function with a string that originated from AccessKit. - */ -void accesskit_string_free(char *string); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_name(const struct accesskit_node *node); - -char *accesskit_node_description(const struct accesskit_node *node); - -char *accesskit_node_value(const struct accesskit_node *node); - -char *accesskit_node_access_key(const struct accesskit_node *node); - -char *accesskit_node_author_id(const struct accesskit_node *node); - -char *accesskit_node_class_name(const struct accesskit_node *node); - -char *accesskit_node_font_family(const struct accesskit_node *node); - -char *accesskit_node_html_tag(const struct accesskit_node *node); - -char *accesskit_node_inner_html(const struct accesskit_node *node); - -char *accesskit_node_keyboard_shortcut(const struct accesskit_node *node); - -char *accesskit_node_language(const struct accesskit_node *node); - -char *accesskit_node_placeholder(const struct accesskit_node *node); - -char *accesskit_node_role_description(const struct accesskit_node *node); - -char *accesskit_node_state_description(const struct accesskit_node *node); - -char *accesskit_node_tooltip(const struct accesskit_node *node); - -char *accesskit_node_url(const struct accesskit_node *node); - -char *accesskit_node_row_index_text(const struct accesskit_node *node); - -char *accesskit_node_column_index_text(const struct accesskit_node *node); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_name(const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_name(struct accesskit_node_builder *builder, - const char *value); - -void accesskit_node_builder_clear_name(struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_description( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_description( - struct accesskit_node_builder *builder, const char *value); - -void accesskit_node_builder_clear_description( - struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_value( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_value(struct accesskit_node_builder *builder, - const char *value); - -void accesskit_node_builder_clear_value(struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_access_key( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_access_key( - struct accesskit_node_builder *builder, const char *value); - -void accesskit_node_builder_clear_access_key( - struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_author_id( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_author_id( - struct accesskit_node_builder *builder, const char *value); - -void accesskit_node_builder_clear_author_id( - struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_class_name( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_class_name( - struct accesskit_node_builder *builder, const char *value); - -void accesskit_node_builder_clear_class_name( - struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_font_family( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_font_family( - struct accesskit_node_builder *builder, const char *value); - -void accesskit_node_builder_clear_font_family( - struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_html_tag( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_html_tag(struct accesskit_node_builder *builder, - const char *value); - -void accesskit_node_builder_clear_html_tag( - struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_inner_html( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_inner_html( - struct accesskit_node_builder *builder, const char *value); - -void accesskit_node_builder_clear_inner_html( - struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_keyboard_shortcut( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_keyboard_shortcut( - struct accesskit_node_builder *builder, const char *value); - -void accesskit_node_builder_clear_keyboard_shortcut( - struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_language( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_language(struct accesskit_node_builder *builder, - const char *value); - -void accesskit_node_builder_clear_language( - struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_placeholder( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_placeholder( - struct accesskit_node_builder *builder, const char *value); - -void accesskit_node_builder_clear_placeholder( - struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_role_description( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_role_description( - struct accesskit_node_builder *builder, const char *value); - -void accesskit_node_builder_clear_role_description( - struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_state_description( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_state_description( - struct accesskit_node_builder *builder, const char *value); - -void accesskit_node_builder_clear_state_description( - struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_tooltip( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_tooltip(struct accesskit_node_builder *builder, - const char *value); - -void accesskit_node_builder_clear_tooltip( - struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_url(const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_url(struct accesskit_node_builder *builder, - const char *value); - -void accesskit_node_builder_clear_url(struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_row_index_text( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_row_index_text( - struct accesskit_node_builder *builder, const char *value); - -void accesskit_node_builder_clear_row_index_text( - struct accesskit_node_builder *builder); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_node_builder_column_index_text( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing the memory pointed by `value`. - */ -void accesskit_node_builder_set_column_index_text( - struct accesskit_node_builder *builder, const char *value); - -void accesskit_node_builder_clear_column_index_text( - struct accesskit_node_builder *builder); - -struct accesskit_opt_double accesskit_node_scroll_x( - const struct accesskit_node *node); - -struct accesskit_opt_double accesskit_node_builder_scroll_x( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_scroll_x(struct accesskit_node_builder *builder, - double value); - -void accesskit_node_builder_clear_scroll_x( - struct accesskit_node_builder *builder); - -struct accesskit_opt_double accesskit_node_scroll_x_min( - const struct accesskit_node *node); - -struct accesskit_opt_double accesskit_node_builder_scroll_x_min( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_scroll_x_min( - struct accesskit_node_builder *builder, double value); - -void accesskit_node_builder_clear_scroll_x_min( - struct accesskit_node_builder *builder); - -struct accesskit_opt_double accesskit_node_scroll_x_max( - const struct accesskit_node *node); - -struct accesskit_opt_double accesskit_node_builder_scroll_x_max( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_scroll_x_max( - struct accesskit_node_builder *builder, double value); - -void accesskit_node_builder_clear_scroll_x_max( - struct accesskit_node_builder *builder); - -struct accesskit_opt_double accesskit_node_scroll_y( - const struct accesskit_node *node); - -struct accesskit_opt_double accesskit_node_builder_scroll_y( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_scroll_y(struct accesskit_node_builder *builder, - double value); - -void accesskit_node_builder_clear_scroll_y( - struct accesskit_node_builder *builder); - -struct accesskit_opt_double accesskit_node_scroll_y_min( - const struct accesskit_node *node); - -struct accesskit_opt_double accesskit_node_builder_scroll_y_min( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_scroll_y_min( - struct accesskit_node_builder *builder, double value); - -void accesskit_node_builder_clear_scroll_y_min( - struct accesskit_node_builder *builder); - -struct accesskit_opt_double accesskit_node_scroll_y_max( - const struct accesskit_node *node); - -struct accesskit_opt_double accesskit_node_builder_scroll_y_max( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_scroll_y_max( - struct accesskit_node_builder *builder, double value); - -void accesskit_node_builder_clear_scroll_y_max( - struct accesskit_node_builder *builder); - -struct accesskit_opt_double accesskit_node_numeric_value( - const struct accesskit_node *node); - -struct accesskit_opt_double accesskit_node_builder_numeric_value( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_numeric_value( - struct accesskit_node_builder *builder, double value); - -void accesskit_node_builder_clear_numeric_value( - struct accesskit_node_builder *builder); - -struct accesskit_opt_double accesskit_node_min_numeric_value( - const struct accesskit_node *node); - -struct accesskit_opt_double accesskit_node_builder_min_numeric_value( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_min_numeric_value( - struct accesskit_node_builder *builder, double value); - -void accesskit_node_builder_clear_min_numeric_value( - struct accesskit_node_builder *builder); - -struct accesskit_opt_double accesskit_node_max_numeric_value( - const struct accesskit_node *node); - -struct accesskit_opt_double accesskit_node_builder_max_numeric_value( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_max_numeric_value( - struct accesskit_node_builder *builder, double value); - -void accesskit_node_builder_clear_max_numeric_value( - struct accesskit_node_builder *builder); - -struct accesskit_opt_double accesskit_node_numeric_value_step( - const struct accesskit_node *node); - -struct accesskit_opt_double accesskit_node_builder_numeric_value_step( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_numeric_value_step( - struct accesskit_node_builder *builder, double value); - -void accesskit_node_builder_clear_numeric_value_step( - struct accesskit_node_builder *builder); - -struct accesskit_opt_double accesskit_node_numeric_value_jump( - const struct accesskit_node *node); - -struct accesskit_opt_double accesskit_node_builder_numeric_value_jump( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_numeric_value_jump( - struct accesskit_node_builder *builder, double value); - -void accesskit_node_builder_clear_numeric_value_jump( - struct accesskit_node_builder *builder); - -struct accesskit_opt_double accesskit_node_font_size( - const struct accesskit_node *node); - -struct accesskit_opt_double accesskit_node_builder_font_size( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_font_size( - struct accesskit_node_builder *builder, double value); - -void accesskit_node_builder_clear_font_size( - struct accesskit_node_builder *builder); - -struct accesskit_opt_double accesskit_node_font_weight( - const struct accesskit_node *node); - -struct accesskit_opt_double accesskit_node_builder_font_weight( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_font_weight( - struct accesskit_node_builder *builder, double value); - -void accesskit_node_builder_clear_font_weight( - struct accesskit_node_builder *builder); - -struct accesskit_opt_index accesskit_node_row_count( - const struct accesskit_node *node); - -struct accesskit_opt_index accesskit_node_builder_row_count( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_row_count( - struct accesskit_node_builder *builder, size_t value); - -void accesskit_node_builder_clear_row_count( - struct accesskit_node_builder *builder); - -struct accesskit_opt_index accesskit_node_column_count( - const struct accesskit_node *node); - -struct accesskit_opt_index accesskit_node_builder_column_count( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_column_count( - struct accesskit_node_builder *builder, size_t value); - -void accesskit_node_builder_clear_column_count( - struct accesskit_node_builder *builder); - -struct accesskit_opt_index accesskit_node_row_index( - const struct accesskit_node *node); - -struct accesskit_opt_index accesskit_node_builder_row_index( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_row_index( - struct accesskit_node_builder *builder, size_t value); - -void accesskit_node_builder_clear_row_index( - struct accesskit_node_builder *builder); - -struct accesskit_opt_index accesskit_node_column_index( - const struct accesskit_node *node); - -struct accesskit_opt_index accesskit_node_builder_column_index( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_column_index( - struct accesskit_node_builder *builder, size_t value); - -void accesskit_node_builder_clear_column_index( - struct accesskit_node_builder *builder); - -struct accesskit_opt_index accesskit_node_row_span( - const struct accesskit_node *node); - -struct accesskit_opt_index accesskit_node_builder_row_span( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_row_span(struct accesskit_node_builder *builder, - size_t value); - -void accesskit_node_builder_clear_row_span( - struct accesskit_node_builder *builder); - -struct accesskit_opt_index accesskit_node_column_span( - const struct accesskit_node *node); - -struct accesskit_opt_index accesskit_node_builder_column_span( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_column_span( - struct accesskit_node_builder *builder, size_t value); - -void accesskit_node_builder_clear_column_span( - struct accesskit_node_builder *builder); - -struct accesskit_opt_index accesskit_node_level( - const struct accesskit_node *node); - -struct accesskit_opt_index accesskit_node_builder_level( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_level(struct accesskit_node_builder *builder, - size_t value); - -void accesskit_node_builder_clear_level(struct accesskit_node_builder *builder); - -struct accesskit_opt_index accesskit_node_size_of_set( - const struct accesskit_node *node); - -struct accesskit_opt_index accesskit_node_builder_size_of_set( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_size_of_set( - struct accesskit_node_builder *builder, size_t value); - -void accesskit_node_builder_clear_size_of_set( - struct accesskit_node_builder *builder); - -struct accesskit_opt_index accesskit_node_position_in_set( - const struct accesskit_node *node); - -struct accesskit_opt_index accesskit_node_builder_position_in_set( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_position_in_set( - struct accesskit_node_builder *builder, size_t value); - -void accesskit_node_builder_clear_position_in_set( - struct accesskit_node_builder *builder); - -struct accesskit_opt_color accesskit_node_color_value( - const struct accesskit_node *node); - -struct accesskit_opt_color accesskit_node_builder_color_value( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_color_value( - struct accesskit_node_builder *builder, uint32_t value); - -void accesskit_node_builder_clear_color_value( - struct accesskit_node_builder *builder); - -struct accesskit_opt_color accesskit_node_background_color( - const struct accesskit_node *node); - -struct accesskit_opt_color accesskit_node_builder_background_color( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_background_color( - struct accesskit_node_builder *builder, uint32_t value); - -void accesskit_node_builder_clear_background_color( - struct accesskit_node_builder *builder); - -struct accesskit_opt_color accesskit_node_foreground_color( - const struct accesskit_node *node); - -struct accesskit_opt_color accesskit_node_builder_foreground_color( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_foreground_color( - struct accesskit_node_builder *builder, uint32_t value); - -void accesskit_node_builder_clear_foreground_color( - struct accesskit_node_builder *builder); - -struct accesskit_opt_text_decoration accesskit_node_overline( - const struct accesskit_node *node); - -struct accesskit_opt_text_decoration accesskit_node_builder_overline( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_overline(struct accesskit_node_builder *builder, - accesskit_text_decoration value); - -void accesskit_node_builder_clear_overline( - struct accesskit_node_builder *builder); - -struct accesskit_opt_text_decoration accesskit_node_strikethrough( - const struct accesskit_node *node); - -struct accesskit_opt_text_decoration accesskit_node_builder_strikethrough( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_strikethrough( - struct accesskit_node_builder *builder, accesskit_text_decoration value); - -void accesskit_node_builder_clear_strikethrough( - struct accesskit_node_builder *builder); - -struct accesskit_opt_text_decoration accesskit_node_underline( - const struct accesskit_node *node); - -struct accesskit_opt_text_decoration accesskit_node_builder_underline( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_underline( - struct accesskit_node_builder *builder, accesskit_text_decoration value); - -void accesskit_node_builder_clear_underline( - struct accesskit_node_builder *builder); - -struct accesskit_lengths accesskit_node_character_lengths( - const struct accesskit_node *node); - -struct accesskit_lengths accesskit_node_builder_character_lengths( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing `values`. - */ -void accesskit_node_builder_set_character_lengths( - struct accesskit_node_builder *builder, size_t length, - const uint8_t *values); - -void accesskit_node_builder_clear_character_lengths( - struct accesskit_node_builder *builder); - -struct accesskit_lengths accesskit_node_word_lengths( - const struct accesskit_node *node); - -struct accesskit_lengths accesskit_node_builder_word_lengths( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing `values`. - */ -void accesskit_node_builder_set_word_lengths( - struct accesskit_node_builder *builder, size_t length, - const uint8_t *values); - -void accesskit_node_builder_clear_word_lengths( - struct accesskit_node_builder *builder); - -struct accesskit_opt_coords accesskit_node_character_positions( - const struct accesskit_node *node); - -struct accesskit_opt_coords accesskit_node_builder_character_positions( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing `values`. - */ -void accesskit_node_builder_set_character_positions( - struct accesskit_node_builder *builder, size_t length, const float *values); - -void accesskit_node_builder_clear_character_positions( - struct accesskit_node_builder *builder); - -struct accesskit_opt_coords accesskit_node_character_widths( - const struct accesskit_node *node); - -struct accesskit_opt_coords accesskit_node_builder_character_widths( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing `values`. - */ -void accesskit_node_builder_set_character_widths( - struct accesskit_node_builder *builder, size_t length, const float *values); - -void accesskit_node_builder_clear_character_widths( - struct accesskit_node_builder *builder); - -struct accesskit_opt_bool accesskit_node_is_expanded( - const struct accesskit_node *node); - -struct accesskit_opt_bool accesskit_node_builder_is_expanded( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_expanded(struct accesskit_node_builder *builder, - bool value); - -void accesskit_node_builder_clear_expanded( - struct accesskit_node_builder *builder); - -struct accesskit_opt_bool accesskit_node_is_selected( - const struct accesskit_node *node); - -struct accesskit_opt_bool accesskit_node_builder_is_selected( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_selected(struct accesskit_node_builder *builder, - bool value); - -void accesskit_node_builder_clear_selected( - struct accesskit_node_builder *builder); - -struct accesskit_opt_invalid accesskit_node_invalid( - const struct accesskit_node *node); - -struct accesskit_opt_invalid accesskit_node_builder_invalid( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_invalid(struct accesskit_node_builder *builder, - accesskit_invalid value); - -void accesskit_node_builder_clear_invalid( - struct accesskit_node_builder *builder); - -struct accesskit_opt_toggled accesskit_node_toggled( - const struct accesskit_node *node); - -struct accesskit_opt_toggled accesskit_node_builder_toggled( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_toggled(struct accesskit_node_builder *builder, - accesskit_toggled value); - -void accesskit_node_builder_clear_toggled( - struct accesskit_node_builder *builder); - -struct accesskit_opt_live accesskit_node_live( - const struct accesskit_node *node); - -struct accesskit_opt_live accesskit_node_builder_live( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_live(struct accesskit_node_builder *builder, - accesskit_live value); - -void accesskit_node_builder_clear_live(struct accesskit_node_builder *builder); - -struct accesskit_opt_default_action_verb accesskit_node_default_action_verb( - const struct accesskit_node *node); - -struct accesskit_opt_default_action_verb -accesskit_node_builder_default_action_verb( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_default_action_verb( - struct accesskit_node_builder *builder, - accesskit_default_action_verb value); - -void accesskit_node_builder_clear_default_action_verb( - struct accesskit_node_builder *builder); - -struct accesskit_opt_text_direction accesskit_node_text_direction( - const struct accesskit_node *node); - -struct accesskit_opt_text_direction accesskit_node_builder_text_direction( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_text_direction( - struct accesskit_node_builder *builder, accesskit_text_direction value); - -void accesskit_node_builder_clear_text_direction( - struct accesskit_node_builder *builder); - -struct accesskit_opt_orientation accesskit_node_orientation( - const struct accesskit_node *node); - -struct accesskit_opt_orientation accesskit_node_builder_orientation( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_orientation( - struct accesskit_node_builder *builder, accesskit_orientation value); - -void accesskit_node_builder_clear_orientation( - struct accesskit_node_builder *builder); - -struct accesskit_opt_sort_direction accesskit_node_sort_direction( - const struct accesskit_node *node); - -struct accesskit_opt_sort_direction accesskit_node_builder_sort_direction( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_sort_direction( - struct accesskit_node_builder *builder, accesskit_sort_direction value); - -void accesskit_node_builder_clear_sort_direction( - struct accesskit_node_builder *builder); - -struct accesskit_opt_aria_current accesskit_node_aria_current( - const struct accesskit_node *node); - -struct accesskit_opt_aria_current accesskit_node_builder_aria_current( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_aria_current( - struct accesskit_node_builder *builder, accesskit_aria_current value); - -void accesskit_node_builder_clear_aria_current( - struct accesskit_node_builder *builder); - -struct accesskit_opt_auto_complete accesskit_node_auto_complete( - const struct accesskit_node *node); - -struct accesskit_opt_auto_complete accesskit_node_builder_auto_complete( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_auto_complete( - struct accesskit_node_builder *builder, accesskit_auto_complete value); - -void accesskit_node_builder_clear_auto_complete( - struct accesskit_node_builder *builder); - -struct accesskit_opt_has_popup accesskit_node_has_popup( - const struct accesskit_node *node); - -struct accesskit_opt_has_popup accesskit_node_builder_has_popup( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_has_popup( - struct accesskit_node_builder *builder, accesskit_has_popup value); - -void accesskit_node_builder_clear_has_popup( - struct accesskit_node_builder *builder); - -struct accesskit_opt_list_style accesskit_node_list_style( - const struct accesskit_node *node); - -struct accesskit_opt_list_style accesskit_node_builder_list_style( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_list_style( - struct accesskit_node_builder *builder, accesskit_list_style value); - -void accesskit_node_builder_clear_list_style( - struct accesskit_node_builder *builder); - -struct accesskit_opt_text_align accesskit_node_text_align( - const struct accesskit_node *node); - -struct accesskit_opt_text_align accesskit_node_builder_text_align( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_text_align( - struct accesskit_node_builder *builder, accesskit_text_align value); - -void accesskit_node_builder_clear_text_align( - struct accesskit_node_builder *builder); - -struct accesskit_opt_vertical_offset accesskit_node_vertical_offset( - const struct accesskit_node *node); - -struct accesskit_opt_vertical_offset accesskit_node_builder_vertical_offset( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_vertical_offset( - struct accesskit_node_builder *builder, accesskit_vertical_offset value); - -void accesskit_node_builder_clear_vertical_offset( - struct accesskit_node_builder *builder); - -const struct accesskit_affine *accesskit_node_transform( - const struct accesskit_node *node); - -const struct accesskit_affine *accesskit_node_builder_transform( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_transform( - struct accesskit_node_builder *builder, struct accesskit_affine value); - -void accesskit_node_builder_clear_transform( - struct accesskit_node_builder *builder); - -struct accesskit_opt_rect accesskit_node_bounds( - const struct accesskit_node *node); - -struct accesskit_opt_rect accesskit_node_builder_bounds( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_bounds(struct accesskit_node_builder *builder, - struct accesskit_rect value); - -void accesskit_node_builder_clear_bounds( - struct accesskit_node_builder *builder); - -struct accesskit_opt_text_selection accesskit_node_text_selection( - const struct accesskit_node *node); - -struct accesskit_opt_text_selection accesskit_node_builder_text_selection( - const struct accesskit_node_builder *builder); - -void accesskit_node_builder_set_text_selection( - struct accesskit_node_builder *builder, - struct accesskit_text_selection value); - -void accesskit_node_builder_clear_text_selection( - struct accesskit_node_builder *builder); - -struct accesskit_custom_action accesskit_custom_action_new( - int32_t id, const char *description); - -void accesskit_custom_actions_free(struct accesskit_custom_actions *value); - -/** - * Caller is responsible for freeing the returned value. - */ -struct accesskit_custom_actions *accesskit_node_custom_actions( - const struct accesskit_node *node); - -/** - * Caller is responsible for freeing the returned value. - */ -const struct accesskit_custom_actions *accesskit_node_builder_custom_actions( - const struct accesskit_node_builder *builder); - -/** - * Caller is responsible for freeing `values`. - */ -void accesskit_node_builder_set_custom_actions( - struct accesskit_node_builder *builder, size_t length, - const struct accesskit_custom_action *values); - -void accesskit_node_builder_push_custom_action( - struct accesskit_node_builder *builder, - struct accesskit_custom_action item); - -void accesskit_node_builder_clear_custom_actions( - struct accesskit_node_builder *builder); - -struct accesskit_node_builder *accesskit_node_builder_new(accesskit_role role); - -/** - * Converts an `accesskit_node_builder` to an `accesskit_node`, freeing the - * memory in the process. - */ -struct accesskit_node *accesskit_node_builder_build( - struct accesskit_node_builder *builder); - -/** - * Only call this function if you have to abort the building of a node. - * - * If you called `accesskit_node_builder_build`, don't call this function. - */ -void accesskit_node_builder_free(struct accesskit_node_builder *builder); - -struct accesskit_tree *accesskit_tree_new(accesskit_node_id root); - -void accesskit_tree_free(struct accesskit_tree *tree); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_tree_get_app_name(const struct accesskit_tree *tree); - -void accesskit_tree_set_app_name(struct accesskit_tree *tree, - const char *app_name); - -void accesskit_tree_clear_app_name(struct accesskit_tree *tree); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_tree_get_toolkit_name(const struct accesskit_tree *tree); - -void accesskit_tree_set_toolkit_name(struct accesskit_tree *tree, - const char *toolkit_name); - -void accesskit_tree_clear_toolkit_name(struct accesskit_tree *tree); - -/** - * Caller must call `accesskit_string_free` with the return value. - */ -char *accesskit_tree_get_toolkit_version(const struct accesskit_tree *tree); - -void accesskit_tree_set_toolkit_version(struct accesskit_tree *tree, - const char *toolkit_version); - -void accesskit_tree_clear_toolkit_version(struct accesskit_tree *tree); - -struct accesskit_tree_update *accesskit_tree_update_with_focus( - accesskit_node_id focus); - -struct accesskit_tree_update *accesskit_tree_update_with_capacity_and_focus( - size_t capacity, accesskit_node_id focus); - -void accesskit_tree_update_free(struct accesskit_tree_update *update); - -/** - * Appends the provided node to the tree update's list of nodes. - * Takes ownership of `node`. - */ -void accesskit_tree_update_push_node(struct accesskit_tree_update *update, - accesskit_node_id id, - struct accesskit_node *node); - -void accesskit_tree_update_set_tree(struct accesskit_tree_update *update, - struct accesskit_tree *tree); - -void accesskit_tree_update_clear_tree(struct accesskit_tree_update *update); - -void accesskit_tree_update_set_focus(struct accesskit_tree_update *update, - accesskit_node_id focus); - -void accesskit_action_request_free(struct accesskit_action_request *request); - -struct accesskit_affine accesskit_affine_identity(void); - -struct accesskit_affine accesskit_affine_flip_y(void); - -struct accesskit_affine accesskit_affine_flip_x(void); - -struct accesskit_affine accesskit_affine_scale(double s); - -struct accesskit_affine accesskit_affine_scale_non_uniform(double s_x, - double s_y); - -struct accesskit_affine accesskit_affine_rotate(double th); - -struct accesskit_affine accesskit_affine_translate(struct accesskit_vec2 p); - -struct accesskit_affine accesskit_affine_map_unit_square( - struct accesskit_rect rect); - -double accesskit_affine_determinant(struct accesskit_affine affine); - -struct accesskit_affine accesskit_affine_inverse( - struct accesskit_affine affine); - -struct accesskit_rect accesskit_affine_transform_rect_bbox( - struct accesskit_affine affine, struct accesskit_rect rect); - -bool accesskit_affine_is_finite(const struct accesskit_affine *affine); - -bool accesskit_affine_is_nan(const struct accesskit_affine *affine); - -struct accesskit_vec2 accesskit_point_to_vec2(struct accesskit_point point); - -struct accesskit_rect accesskit_rect_from_points(struct accesskit_point p0, - struct accesskit_point p1); - -struct accesskit_rect accesskit_rect_from_origin_size( - struct accesskit_point origin, struct accesskit_size size); - -struct accesskit_rect accesskit_rect_with_origin(struct accesskit_rect rect, - struct accesskit_point origin); - -struct accesskit_rect accesskit_rect_with_size(struct accesskit_rect rect, - struct accesskit_size size); - -double accesskit_rect_width(const struct accesskit_rect *rect); - -double accesskit_rect_height(const struct accesskit_rect *rect); - -double accesskit_rect_min_x(const struct accesskit_rect *rect); - -double accesskit_rect_max_x(const struct accesskit_rect *rect); - -double accesskit_rect_min_y(const struct accesskit_rect *rect); - -double accesskit_rect_max_y(const struct accesskit_rect *rect); - -struct accesskit_point accesskit_rect_origin(const struct accesskit_rect *rect); - -struct accesskit_size accesskit_rect_size(const struct accesskit_rect *rect); - -struct accesskit_rect accesskit_rect_abs(const struct accesskit_rect *rect); - -double accesskit_rect_area(const struct accesskit_rect *rect); - -bool accesskit_rect_is_empty(const struct accesskit_rect *rect); - -bool accesskit_rect_contains(const struct accesskit_rect *rect, - struct accesskit_point point); - -struct accesskit_rect accesskit_rect_union(const struct accesskit_rect *rect, - struct accesskit_rect other); - -struct accesskit_rect accesskit_rect_union_pt(const struct accesskit_rect *rect, - struct accesskit_point pt); - -struct accesskit_rect accesskit_rect_intersect( - const struct accesskit_rect *rect, struct accesskit_rect other); - -struct accesskit_vec2 accesskit_size_to_vec2(struct accesskit_size size); - -struct accesskit_point accesskit_vec2_to_point(struct accesskit_vec2 vec2); - -struct accesskit_size accesskit_vec2_to_size(struct accesskit_vec2 vec2); - -#if defined(__APPLE__) -/** - * Memory is also freed when calling this function. - */ -void accesskit_macos_queued_events_raise( - struct accesskit_macos_queued_events *events); -#endif - -#if defined(__APPLE__) -/** - * # Safety - * - * `view` must be a valid, unreleased pointer to an `NSView`. - */ -struct accesskit_macos_adapter *accesskit_macos_adapter_new( - void *view, bool is_view_focused, - accesskit_action_handler_callback action_handler, - void *action_handler_userdata); -#endif - -#if defined(__APPLE__) -void accesskit_macos_adapter_free(struct accesskit_macos_adapter *adapter); -#endif - -#if defined(__APPLE__) -/** - * You must call `accesskit_macos_queued_events_raise` on the returned pointer. - * It can be null if the adapter is not active. - */ -struct accesskit_macos_queued_events *accesskit_macos_adapter_update_if_active( - struct accesskit_macos_adapter *adapter, - accesskit_tree_update_factory update_factory, - void *update_factory_userdata); -#endif - -#if defined(__APPLE__) -/** - * Update the tree state based on whether the window is focused. - * - * You must call `accesskit_macos_queued_events_raise` on the returned pointer. - * It can be null if the adapter is not active. - */ -struct accesskit_macos_queued_events * -accesskit_macos_adapter_update_view_focus_state( - struct accesskit_macos_adapter *adapter, bool is_focused); -#endif - -#if defined(__APPLE__) -/** - * Returns a pointer to an `NSArray`. Ownership of the pointer is not - * transferred. - */ -void *accesskit_macos_adapter_view_children( - struct accesskit_macos_adapter *adapter, - accesskit_activation_handler_callback activation_handler, - void *activation_handler_userdata); -#endif - -#if defined(__APPLE__) -/** - * Returns a pointer to an `NSObject`. Ownership of the pointer is not - * transferred. - */ -void *accesskit_macos_adapter_focus( - struct accesskit_macos_adapter *adapter, - accesskit_activation_handler_callback activation_handler, - void *activation_handler_userdata); -#endif - -#if defined(__APPLE__) -/** - * Returns a pointer to an `NSObject`. Ownership of the pointer is not - * transferred. - */ -void *accesskit_macos_adapter_hit_test( - struct accesskit_macos_adapter *adapter, double x, double y, - accesskit_activation_handler_callback activation_handler, - void *activation_handler_userdata); -#endif - -#if defined(__APPLE__) -/** - * # Safety - * - * `view` must be a valid, unreleased pointer to an `NSView`. - */ -struct accesskit_macos_subclassing_adapter * -accesskit_macos_subclassing_adapter_new( - void *view, accesskit_activation_handler_callback activation_handler, - void *activation_handler_userdata, - accesskit_action_handler_callback action_handler, - void *action_handler_userdata); -#endif - -#if defined(__APPLE__) -/** - * # Safety - * - * `window` must be a valid, unreleased pointer to an `NSWindow`. - * - * # Panics - * - * This function panics if the specified window doesn't currently have - * a content view. - */ -struct accesskit_macos_subclassing_adapter * -accesskit_macos_subclassing_adapter_for_window( - void *window, accesskit_activation_handler_callback activation_handler, - void *activation_handler_userdata, - accesskit_action_handler_callback action_handler, - void *action_handler_userdata); -#endif - -#if defined(__APPLE__) -void accesskit_macos_subclassing_adapter_free( - struct accesskit_macos_subclassing_adapter *adapter); -#endif - -#if defined(__APPLE__) -/** - * You must call `accesskit_macos_queued_events_raise` on the returned pointer. - * It can be null if the adapter is not active. - */ -struct accesskit_macos_queued_events * -accesskit_macos_subclassing_adapter_update_if_active( - struct accesskit_macos_subclassing_adapter *adapter, - accesskit_tree_update_factory update_factory, - void *update_factory_userdata); -#endif - -#if defined(__APPLE__) -/** - * Update the tree state based on whether the window is focused. - * - * You must call `accesskit_macos_queued_events_raise` on the returned pointer. - * It can be null if the adapter is not active. - */ -struct accesskit_macos_queued_events * -accesskit_macos_subclassing_adapter_update_view_focus_state( - struct accesskit_macos_subclassing_adapter *adapter, bool is_focused); -#endif - -#if defined(__APPLE__) -/** - * Modifies the specified class, which must be a subclass of `NSWindow`, - * to include an `accessibilityFocusedUIElement` method that calls - * the corresponding method on the window's content view. This is needed - * for windowing libraries such as SDL that place the keyboard focus - * directly on the window rather than the content view. - * - * # Safety - * - * This function is declared unsafe because the caller must ensure that the - * code for this library is never unloaded from the application process, - * since it's not possible to reverse this operation. It's safest - * if this library is statically linked into the application's main executable. - * Also, this function assumes that the specified class is a subclass - * of `NSWindow`. - */ -void accesskit_macos_add_focus_forwarder_to_window_class( - const char *class_name); -#endif - -#if (defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ - defined(__NetBSD__) || defined(__OpenBSD__)) -/** - * All of the handlers will always be called from another thread. - */ -struct accesskit_unix_adapter *accesskit_unix_adapter_new( - accesskit_activation_handler_callback activation_handler, - void *activation_handler_userdata, - accesskit_action_handler_callback action_handler, - void *action_handler_userdata, - accesskit_deactivation_handler_callback deactivation_handler, - void *deactivation_handler_userdata); -#endif - -#if (defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ - defined(__NetBSD__) || defined(__OpenBSD__)) -void accesskit_unix_adapter_free(struct accesskit_unix_adapter *adapter); -#endif - -#if (defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ - defined(__NetBSD__) || defined(__OpenBSD__)) -void accesskit_unix_adapter_set_root_window_bounds( - struct accesskit_unix_adapter *adapter, struct accesskit_rect outer, - struct accesskit_rect inner); -#endif - -#if (defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ - defined(__NetBSD__) || defined(__OpenBSD__)) -void accesskit_unix_adapter_update_if_active( - struct accesskit_unix_adapter *adapter, - accesskit_tree_update_factory update_factory, - void *update_factory_userdata); -#endif - -#if (defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ - defined(__NetBSD__) || defined(__OpenBSD__)) -/** - * Update the tree state based on whether the window is focused. - */ -void accesskit_unix_adapter_update_window_focus_state( - struct accesskit_unix_adapter *adapter, bool is_focused); -#endif - -#if defined(_WIN32) -/** - * Memory is also freed when calling this function. - */ -void accesskit_windows_queued_events_raise( - struct accesskit_windows_queued_events *events); -#endif - -#if defined(_WIN32) -struct accesskit_windows_adapter *accesskit_windows_adapter_new( - HWND hwnd, bool is_window_focused, - accesskit_action_handler_callback action_handler, - void *action_handler_userdata); -#endif - -#if defined(_WIN32) -void accesskit_windows_adapter_free(struct accesskit_windows_adapter *adapter); -#endif - -#if defined(_WIN32) -/** - * You must call `accesskit_windows_queued_events_raise` on the returned - * pointer. It can be null if the adapter is not active. - */ -struct accesskit_windows_queued_events * -accesskit_windows_adapter_update_if_active( - struct accesskit_windows_adapter *adapter, - accesskit_tree_update_factory update_factory, - void *update_factory_userdata); -#endif - -#if defined(_WIN32) -/** - * Update the tree state based on whether the window is focused. - * - * You must call `accesskit_windows_queued_events_raise` on the returned - * pointer. - */ -struct accesskit_windows_queued_events * -accesskit_windows_adapter_update_window_focus_state( - struct accesskit_windows_adapter *adapter, bool is_focused); -#endif - -#if defined(_WIN32) -struct accesskit_opt_lresult accesskit_windows_adapter_handle_wm_getobject( - struct accesskit_windows_adapter *adapter, WPARAM wparam, LPARAM lparam, - accesskit_activation_handler_callback activation_handler, - void *activation_handler_userdata); -#endif - -#if defined(_WIN32) -struct accesskit_windows_subclassing_adapter * -accesskit_windows_subclassing_adapter_new( - HWND hwnd, accesskit_activation_handler_callback activation_handler, - void *activation_handler_userdata, - accesskit_action_handler_callback action_handler, - void *action_handler_userdata); -#endif - -#if defined(_WIN32) -void accesskit_windows_subclassing_adapter_free( - struct accesskit_windows_subclassing_adapter *adapter); -#endif - -#if defined(_WIN32) -/** - * You must call `accesskit_windows_queued_events_raise` on the returned - * pointer. It can be null if the adapter is not active. - */ -struct accesskit_windows_queued_events * -accesskit_windows_subclassing_adapter_update_if_active( - struct accesskit_windows_subclassing_adapter *adapter, - accesskit_tree_update_factory update_factory, - void *update_factory_userdata); -#endif - -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus - -#endif /* ACCESSKIT_H */ diff --git a/bindings/c/src/common.rs b/bindings/c/src/common.rs deleted file mode 100644 index be690049..00000000 --- a/bindings/c/src/common.rs +++ /dev/null @@ -1,1156 +0,0 @@ -// Copyright 2023 The AccessKit Authors. All rights reserved. -// Licensed under the Apache License, Version 2.0 (found in -// the LICENSE-APACHE file) or the MIT license (found in -// the LICENSE-MIT file), at your option. - -use crate::{box_from_ptr, mut_from_ptr, opt_struct, ref_from_ptr, BoxCastPtr, CastPtr}; -use accesskit::*; -use paste::paste; -use std::{ - ffi::{CStr, CString}, - mem, - os::raw::{c_char, c_void}, - ptr, slice, -}; - -pub struct node { - _private: [u8; 0], -} - -impl CastPtr for node { - type RustType = Node; -} - -impl BoxCastPtr for node {} - -impl node { - #[no_mangle] - pub extern "C" fn accesskit_node_free(node: *mut node) { - drop(box_from_ptr(node)); - } -} - -pub struct node_builder { - _private: [u8; 0], -} - -impl CastPtr for node_builder { - type RustType = NodeBuilder; -} - -impl BoxCastPtr for node_builder {} - -macro_rules! clearer { - ($clearer:ident) => { - paste! { - impl node_builder { - #[no_mangle] - pub extern "C" fn [](builder: *mut node_builder) { - let builder = mut_from_ptr(builder); - builder.$clearer() - } - } - } - }; -} - -macro_rules! flag_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - paste! { - impl node { - $(#[no_mangle] - pub extern "C" fn [](node: *const node) -> bool { - let node = ref_from_ptr(node); - node.$getter() - })* - } - $(impl node_builder { - #[no_mangle] - pub extern "C" fn [](builder: *const node_builder) -> bool { - let builder = ref_from_ptr(builder); - builder.$getter() - } - #[no_mangle] - pub extern "C" fn [](builder: *mut node_builder) { - let builder = mut_from_ptr(builder); - builder.$setter() - } - } - clearer! { $clearer })* - } - } -} - -macro_rules! array_setter { - ($setter:ident, $ffi_type:ty, $rust_type:ty) => { - paste! { - impl node_builder { - /// Caller is responsible for freeing `values`. - #[no_mangle] - pub extern "C" fn [](builder: *mut node_builder, length: usize, values: *const $ffi_type) { - let builder = mut_from_ptr(builder); - let values = unsafe { - slice::from_raw_parts(values, length) - .iter() - .cloned() - .map(From::from) - .collect::>() - }; - builder.$setter(values); - } - } - } - } -} - -macro_rules! property_getters { - ($getter:ident, *const $getter_result:tt) => { - paste! { - impl node { - #[no_mangle] - pub extern "C" fn [](node: *const node) -> *const $getter_result { - let node = ref_from_ptr(node); - match node.$getter() { - Some(value) => value as *const _, - None => ptr::null(), - } - } - } - impl node_builder { - #[no_mangle] - pub extern "C" fn [](builder: *const node_builder) -> *const $getter_result { - let builder = ref_from_ptr(builder); - match builder.$getter() { - Some(value) => value as *const _, - None => ptr::null(), - } - } - } - } - }; - ($getter:ident, *mut $getter_result:tt) => { - paste! { - impl node { - /// Caller is responsible for freeing the returned value. - #[no_mangle] - pub extern "C" fn [](node: *const node) -> *mut $getter_result { - let node = ref_from_ptr(node); - BoxCastPtr::to_mut_ptr(node.$getter().into()) - } - } - impl node_builder { - /// Caller is responsible for freeing the returned value. - #[no_mangle] - pub extern "C" fn [](builder: *const node_builder) -> *const $getter_result { - let builder = ref_from_ptr(builder); - BoxCastPtr::to_mut_ptr(builder.$getter().into()) - } - } - } - }; - ($getter:ident, $getter_result:tt) => { - paste! { - impl node { - #[no_mangle] - pub extern "C" fn [](node: *const node) -> $getter_result { - let node = ref_from_ptr(node); - node.$getter().into() - } - } - impl node_builder { - #[no_mangle] - pub extern "C" fn [](builder: *const node_builder) -> $getter_result { - let builder = ref_from_ptr(builder); - builder.$getter().into() - } - } - } - } -} - -macro_rules! simple_property_methods { - ($getter:ident, $getter_result:tt, $setter:ident, $setter_param:tt, $clearer:ident) => { - paste! { - property_getters! { $getter, $getter_result } - impl node_builder { - #[no_mangle] - pub extern "C" fn [](builder: *mut node_builder, value: $setter_param) { - let builder = mut_from_ptr(builder); - builder.$setter(value.into()); - } - } - clearer! { $clearer } - } - }; - ($getter:ident, *const $getter_result:tt, $setter:ident, $setter_param:tt, $clearer:ident) => { - paste! { - property_getters! { $getter, *const $getter_result } - impl node_builder { - #[no_mangle] - pub extern "C" fn [](builder: *mut node_builder, value: $setter_param) { - let builder = mut_from_ptr(builder); - builder.$setter(Box::new(value)); - } - } - clearer! { $clearer } - } - }; - ($getter:ident, $getter_result:tt, $setter:ident, *const $setter_param:tt, $clearer:ident) => { - property_getters! { $getter, $getter_result } - array_setter! { $setter, $setter_param, $setter_param } - clearer! { $clearer } - } -} - -macro_rules! slice_struct { - ($struct_name:ident, $rust_type:ty, $ffi_type:ty) => { - #[repr(C)] - pub struct $struct_name { - pub length: usize, - pub values: *const $ffi_type, - } - impl From<&[$rust_type]> for $struct_name { - fn from(values: &[$rust_type]) -> Self { - Self { - length: values.len(), - values: values.as_ptr() as *const _, - } - } - } - impl From<$struct_name> for Vec<$rust_type> { - fn from(values: $struct_name) -> Self { - unsafe { - slice::from_raw_parts(values.values as *mut $rust_type, values.length).to_vec() - } - } - } - }; -} - -macro_rules! array_struct { - ($struct_name:ident, $rust_type:ty, $ffi_type:ty) => { - #[repr(C)] - pub struct $struct_name { - pub length: usize, - pub values: *mut $ffi_type, - } - impl CastPtr for $struct_name { - type RustType = $struct_name; - } - impl BoxCastPtr for $struct_name {} - paste! { - impl $struct_name { - #[no_mangle] - pub extern "C" fn [](value: *mut $struct_name) { - let array = box_from_ptr(value); - unsafe { Vec::from_raw_parts(array.values, array.length, array.length) }; - drop(array); - } - } - } - impl From<&[$rust_type]> for $struct_name { - fn from(values: &[$rust_type]) -> Self { - let length = values.len(); - let mut ffi_values = values.iter().map(From::from).collect::>(); - let array = Self { - length, - values: ffi_values.as_mut_ptr(), - }; - mem::forget(ffi_values); - array - } - } - }; -} - -macro_rules! vec_property_methods { - ($(($item_type:ty, $getter:ident, *mut $getter_result:ty, $setter:ident, $setter_param:ty, $pusher:ident, $clearer:ident)),+) => { - paste! { - $(property_getters! { $getter, *mut $getter_result } - array_setter! { $setter, $setter_param, $item_type } - impl node_builder { - #[no_mangle] - pub extern "C" fn [](builder: *mut node_builder, item: $setter_param) { - let builder = mut_from_ptr(builder); - builder.$pusher(item.into()); - } - } - clearer! { $clearer })* - } - }; - ($(($item_type:ty, $getter:ident, $getter_result:ty, $setter:ident, $setter_param:ty, $pusher:ident, $clearer:ident)),+) => { - paste! { - $(property_getters! { $getter, $getter_result } - array_setter! { $setter, $setter_param, $item_type } - impl node_builder { - #[no_mangle] - pub extern "C" fn [](builder: *mut node_builder, item: $setter_param) { - let builder = mut_from_ptr(builder); - builder.$pusher(item.into()); - } - } - clearer! { $clearer })* - } - } -} - -pub type node_id = u64; - -slice_struct! { node_ids, NodeId, node_id } - -macro_rules! node_id_vec_property_methods { - ($(($getter:ident, $setter:ident, $pusher:ident, $clearer:ident)),+) => { - $(vec_property_methods! { - (NodeId, $getter, node_ids, $setter, node_id, $pusher, $clearer) - })* - } -} - -macro_rules! node_id_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - opt_struct! { opt_node_id, node_id } - $(simple_property_methods! { - $getter, opt_node_id, $setter, node_id, $clearer - })* - } -} - -macro_rules! string_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - paste! { - impl node { - /// Caller must call `accesskit_string_free` with the return value. - $(#[no_mangle] - pub extern "C" fn [](node: *const node) -> *mut c_char { - let node = ref_from_ptr(node); - match node.$getter() { - Some(value) => CString::new(value).unwrap().into_raw(), - None => ptr::null_mut() - } - })* - } - $(impl node_builder { - /// Caller must call `accesskit_string_free` with the return value. - #[no_mangle] - pub extern "C" fn [](builder: *const node_builder) -> *mut c_char { - let builder = ref_from_ptr(builder); - match builder.$getter() { - Some(value) => CString::new(value).unwrap().into_raw(), - None => ptr::null_mut() - } - } - /// Caller is responsible for freeing the memory pointed by `value`. - #[no_mangle] - pub extern "C" fn [](builder: *mut node_builder, value: *const c_char) { - let builder = mut_from_ptr(builder); - let value = unsafe { CStr::from_ptr(value) }; - builder.$setter(value.to_string_lossy()); - } - } - clearer! { $clearer })* - } - } -} - -macro_rules! f64_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - opt_struct! { opt_double, f64 } - $(simple_property_methods! { - $getter, opt_double, $setter, f64, $clearer - })* - } -} - -macro_rules! usize_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - opt_struct! { opt_index, usize } - $(simple_property_methods! { - $getter, opt_index, $setter, usize, $clearer - })* - } -} - -macro_rules! color_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - opt_struct! { opt_color, u32 } - $(simple_property_methods! { - $getter, opt_color, $setter, u32, $clearer - })* - } -} - -macro_rules! text_decoration_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - opt_struct! { opt_text_decoration, TextDecoration } - $(simple_property_methods! { - $getter, opt_text_decoration, $setter, TextDecoration, $clearer - })* - } -} - -macro_rules! opt_slice_struct { - ($struct_name:ident, $rust_type:ty, $ffi_type:ty) => { - #[repr(C)] - pub struct $struct_name { - pub has_value: bool, - pub length: usize, - pub values: *const $ffi_type, - } - impl From> for $struct_name { - fn from(value: Option<&[$rust_type]>) -> $struct_name { - match value { - Some(value) => $struct_name { - has_value: true, - length: value.len(), - values: value.as_ptr() as *const $ffi_type, - }, - None => $struct_name::default(), - } - } - } - impl Default for $struct_name { - fn default() -> $struct_name { - $struct_name { - has_value: false, - length: 0, - values: ptr::null(), - } - } - } - }; -} - -macro_rules! length_slice_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - slice_struct! { lengths, u8, u8 } - $(simple_property_methods! { - $getter, lengths, $setter, *const u8, $clearer - })* - } -} - -macro_rules! coord_slice_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - opt_slice_struct! { opt_coords, f32, f32 } - $(simple_property_methods! { - $getter, opt_coords, $setter, *const f32, $clearer - })* - } -} - -macro_rules! bool_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - opt_struct! { opt_bool, bool } - $(simple_property_methods! { - $getter, opt_bool, $setter, bool, $clearer - })* - } -} - -macro_rules! unique_enum_property_methods { - ($(($prop_type:ty, $getter:ident, $setter:ident, $clearer:ident)),+) => { - $(paste! { - opt_struct! { [], $prop_type } - simple_property_methods! { - $getter, [], $setter, $prop_type, $clearer - } - })* - } -} - -property_getters! { role, Role } -impl node_builder { - #[no_mangle] - pub extern "C" fn accesskit_node_builder_set_role(builder: *mut node_builder, value: Role) { - let builder = mut_from_ptr(builder); - builder.set_role(value); - } -} - -impl node { - #[no_mangle] - pub extern "C" fn accesskit_node_supports_action(node: *const node, action: Action) -> bool { - let node = ref_from_ptr(node); - node.supports_action(action) - } -} - -impl node_builder { - #[no_mangle] - pub extern "C" fn accesskit_node_builder_supports_action( - builder: *const node_builder, - action: Action, - ) -> bool { - let builder = ref_from_ptr(builder); - builder.supports_action(action) - } - - #[no_mangle] - pub extern "C" fn accesskit_node_builder_add_action( - builder: *mut node_builder, - action: Action, - ) { - let builder = mut_from_ptr(builder); - builder.add_action(action); - } - - #[no_mangle] - pub extern "C" fn accesskit_node_builder_remove_action( - builder: *mut node_builder, - action: Action, - ) { - let builder = mut_from_ptr(builder); - builder.remove_action(action); - } - - #[no_mangle] - pub extern "C" fn accesskit_node_builder_clear_actions(builder: *mut node_builder) { - let builder = mut_from_ptr(builder); - builder.clear_actions(); - } -} - -flag_methods! { - (is_hovered, set_hovered, clear_hovered), - (is_hidden, set_hidden, clear_hidden), - (is_linked, set_linked, clear_linked), - (is_multiselectable, set_multiselectable, clear_multiselectable), - (is_required, set_required, clear_required), - (is_visited, set_visited, clear_visited), - (is_busy, set_busy, clear_busy), - (is_live_atomic, set_live_atomic, clear_live_atomic), - (is_modal, set_modal, clear_modal), - (is_touch_transparent, set_touch_transparent, clear_touch_transparent), - (is_read_only, set_read_only, clear_read_only), - (is_disabled, set_disabled, clear_disabled), - (is_bold, set_bold, clear_bold), - (is_italic, set_italic, clear_italic), - (clips_children, set_clips_children, clear_clips_children), - (is_line_breaking_object, set_is_line_breaking_object, clear_is_line_breaking_object), - (is_page_breaking_object, set_is_page_breaking_object, clear_is_page_breaking_object), - (is_spelling_error, set_is_spelling_error, clear_is_spelling_error), - (is_grammar_error, set_is_grammar_error, clear_is_grammar_error), - (is_search_match, set_is_search_match, clear_is_search_match), - (is_suggestion, set_is_suggestion, clear_is_suggestion) -} - -node_id_vec_property_methods! { - (children, set_children, push_child, clear_children), - (controls, set_controls, push_controlled, clear_controls), - (details, set_details, push_detail, clear_details), - (described_by, set_described_by, push_described_by, clear_described_by), - (flow_to, set_flow_to, push_flow_to, clear_flow_to), - (labelled_by, set_labelled_by, push_labelled_by, clear_labelled_by), - (owns, set_owns, push_owned, clear_owns), - (radio_group, set_radio_group, push_to_radio_group, clear_radio_group) -} - -node_id_property_methods! { - (active_descendant, set_active_descendant, clear_active_descendant), - (error_message, set_error_message, clear_error_message), - (in_page_link_target, set_in_page_link_target, clear_in_page_link_target), - (member_of, set_member_of, clear_member_of), - (next_on_line, set_next_on_line, clear_next_on_line), - (previous_on_line, set_previous_on_line, clear_previous_on_line), - (popup_for, set_popup_for, clear_popup_for) -} - -/// Only call this function with a string that originated from AccessKit. -#[no_mangle] -pub extern "C" fn accesskit_string_free(string: *mut c_char) { - assert!(!string.is_null()); - drop(unsafe { CString::from_raw(string) }); -} - -string_property_methods! { - (name, set_name, clear_name), - (description, set_description, clear_description), - (value, set_value, clear_value), - (access_key, set_access_key, clear_access_key), - (author_id, set_author_id, clear_author_id), - (class_name, set_class_name, clear_class_name), - (font_family, set_font_family, clear_font_family), - (html_tag, set_html_tag, clear_html_tag), - (inner_html, set_inner_html, clear_inner_html), - (keyboard_shortcut, set_keyboard_shortcut, clear_keyboard_shortcut), - (language, set_language, clear_language), - (placeholder, set_placeholder, clear_placeholder), - (role_description, set_role_description, clear_role_description), - (state_description, set_state_description, clear_state_description), - (tooltip, set_tooltip, clear_tooltip), - (url, set_url, clear_url), - (row_index_text, set_row_index_text, clear_row_index_text), - (column_index_text, set_column_index_text, clear_column_index_text) -} - -f64_property_methods! { - (scroll_x, set_scroll_x, clear_scroll_x), - (scroll_x_min, set_scroll_x_min, clear_scroll_x_min), - (scroll_x_max, set_scroll_x_max, clear_scroll_x_max), - (scroll_y, set_scroll_y, clear_scroll_y), - (scroll_y_min, set_scroll_y_min, clear_scroll_y_min), - (scroll_y_max, set_scroll_y_max, clear_scroll_y_max), - (numeric_value, set_numeric_value, clear_numeric_value), - (min_numeric_value, set_min_numeric_value, clear_min_numeric_value), - (max_numeric_value, set_max_numeric_value, clear_max_numeric_value), - (numeric_value_step, set_numeric_value_step, clear_numeric_value_step), - (numeric_value_jump, set_numeric_value_jump, clear_numeric_value_jump), - (font_size, set_font_size, clear_font_size), - (font_weight, set_font_weight, clear_font_weight) -} - -usize_property_methods! { - (row_count, set_row_count, clear_row_count), - (column_count, set_column_count, clear_column_count), - (row_index, set_row_index, clear_row_index), - (column_index, set_column_index, clear_column_index), - (row_span, set_row_span, clear_row_span), - (column_span, set_column_span, clear_column_span), - (level, set_level, clear_level), - (size_of_set, set_size_of_set, clear_size_of_set), - (position_in_set, set_position_in_set, clear_position_in_set) -} - -color_property_methods! { - (color_value, set_color_value, clear_color_value), - (background_color, set_background_color, clear_background_color), - (foreground_color, set_foreground_color, clear_foreground_color) -} - -text_decoration_property_methods! { - (overline, set_overline, clear_overline), - (strikethrough, set_strikethrough, clear_strikethrough), - (underline, set_underline, clear_underline) -} - -length_slice_property_methods! { - (character_lengths, set_character_lengths, clear_character_lengths), - (word_lengths, set_word_lengths, clear_word_lengths) -} - -coord_slice_property_methods! { - (character_positions, set_character_positions, clear_character_positions), - (character_widths, set_character_widths, clear_character_widths) -} - -bool_property_methods! { - (is_expanded, set_expanded, clear_expanded), - (is_selected, set_selected, clear_selected) -} - -unique_enum_property_methods! { - (Invalid, invalid, set_invalid, clear_invalid), - (Toggled, toggled, set_toggled, clear_toggled), - (Live, live, set_live, clear_live), - (DefaultActionVerb, default_action_verb, set_default_action_verb, clear_default_action_verb), - (TextDirection, text_direction, set_text_direction, clear_text_direction), - (Orientation, orientation, set_orientation, clear_orientation), - (SortDirection, sort_direction, set_sort_direction, clear_sort_direction), - (AriaCurrent, aria_current, set_aria_current, clear_aria_current), - (AutoComplete, auto_complete, set_auto_complete, clear_auto_complete), - (HasPopup, has_popup, set_has_popup, clear_has_popup), - (ListStyle, list_style, set_list_style, clear_list_style), - (TextAlign, text_align, set_text_align, clear_text_align), - (VerticalOffset, vertical_offset, set_vertical_offset, clear_vertical_offset) -} - -simple_property_methods! { - transform, *const Affine, set_transform, Affine, clear_transform -} -opt_struct! { opt_rect, Rect } -simple_property_methods! { - bounds, opt_rect, set_bounds, Rect, clear_bounds -} - -#[repr(C)] -pub struct text_position { - pub node: node_id, - pub character_index: usize, -} - -impl From for TextPosition { - fn from(position: text_position) -> Self { - Self { - node: position.node.into(), - character_index: position.character_index, - } - } -} - -impl From for text_position { - fn from(position: TextPosition) -> Self { - Self { - node: position.node.into(), - character_index: position.character_index, - } - } -} - -#[repr(C)] -pub struct text_selection { - pub anchor: text_position, - pub focus: text_position, -} - -impl From for TextSelection { - fn from(selection: text_selection) -> Self { - Self { - anchor: selection.anchor.into(), - focus: selection.focus.into(), - } - } -} - -impl From for text_selection { - fn from(selection: TextSelection) -> Self { - Self { - anchor: selection.anchor.into(), - focus: selection.focus.into(), - } - } -} - -impl From<&TextSelection> for text_selection { - fn from(selection: &TextSelection) -> Self { - Self { - anchor: selection.anchor.into(), - focus: selection.focus.into(), - } - } -} - -opt_struct! { opt_text_selection, text_selection } -property_getters! { text_selection, opt_text_selection } -impl node_builder { - #[no_mangle] - pub extern "C" fn accesskit_node_builder_set_text_selection( - builder: *mut node_builder, - value: text_selection, - ) { - let builder = mut_from_ptr(builder); - builder.set_text_selection(Box::new(value.into())); - } -} -clearer! { clear_text_selection } - -/// Use `accesskit_custom_action_new` to create this struct. Do not reallocate `description`. -/// -/// When you get this struct, you are responsible for freeing `description`. -#[derive(Clone)] -#[repr(C)] -pub struct custom_action { - pub id: i32, - pub description: *mut c_char, -} - -impl custom_action { - #[no_mangle] - pub extern "C" fn accesskit_custom_action_new( - id: i32, - description: *const c_char, - ) -> custom_action { - let description = CString::new(String::from( - unsafe { CStr::from_ptr(description) }.to_string_lossy(), - )) - .unwrap(); - Self { - id, - description: description.into_raw(), - } - } -} - -impl Drop for custom_action { - fn drop(&mut self) { - accesskit_string_free(self.description); - } -} - -impl From for CustomAction { - fn from(action: custom_action) -> Self { - Self { - id: action.id, - description: unsafe { CStr::from_ptr(action.description).to_string_lossy().into() }, - } - } -} - -impl From<&custom_action> for CustomAction { - fn from(action: &custom_action) -> Self { - Self { - id: action.id, - description: unsafe { CStr::from_ptr(action.description).to_string_lossy().into() }, - } - } -} - -impl From<&CustomAction> for custom_action { - fn from(action: &CustomAction) -> Self { - Self { - id: action.id, - description: CString::new(&*action.description).unwrap().into_raw(), - } - } -} - -array_struct! { custom_actions, CustomAction, custom_action } - -vec_property_methods! { - (CustomAction, custom_actions, *mut custom_actions, set_custom_actions, custom_action, push_custom_action, clear_custom_actions) -} - -impl node_builder { - #[no_mangle] - pub extern "C" fn accesskit_node_builder_new(role: Role) -> *mut node_builder { - let builder = NodeBuilder::new(role); - BoxCastPtr::to_mut_ptr(builder) - } - - /// Converts an `accesskit_node_builder` to an `accesskit_node`, freeing the memory in the process. - #[no_mangle] - pub extern "C" fn accesskit_node_builder_build(builder: *mut node_builder) -> *mut node { - let builder = box_from_ptr(builder); - let node = builder.build(); - BoxCastPtr::to_mut_ptr(node) - } - - /// Only call this function if you have to abort the building of a node. - /// - /// If you called `accesskit_node_builder_build`, don't call this function. - #[no_mangle] - pub extern "C" fn accesskit_node_builder_free(builder: *mut node_builder) { - drop(box_from_ptr(builder)); - } -} - -pub struct tree { - _private: [u8; 0], -} - -impl CastPtr for tree { - type RustType = Tree; -} - -impl BoxCastPtr for tree {} - -impl tree { - #[no_mangle] - pub extern "C" fn accesskit_tree_new(root: node_id) -> *mut tree { - let tree = Tree::new(root.into()); - BoxCastPtr::to_mut_ptr(tree) - } - - #[no_mangle] - pub extern "C" fn accesskit_tree_free(tree: *mut tree) { - drop(box_from_ptr(tree)); - } - - /// Caller must call `accesskit_string_free` with the return value. - #[no_mangle] - pub extern "C" fn accesskit_tree_get_app_name(tree: *const tree) -> *mut c_char { - let tree = ref_from_ptr(tree); - match tree.app_name.as_ref() { - Some(value) => CString::new(value.clone()).unwrap().into_raw(), - None => ptr::null_mut(), - } - } - - #[no_mangle] - pub extern "C" fn accesskit_tree_set_app_name(tree: *mut tree, app_name: *const c_char) { - let tree = mut_from_ptr(tree); - tree.app_name = Some(String::from( - unsafe { CStr::from_ptr(app_name) }.to_string_lossy(), - )); - } - - #[no_mangle] - pub extern "C" fn accesskit_tree_clear_app_name(tree: *mut tree) { - let tree = mut_from_ptr(tree); - tree.app_name = None; - } - - /// Caller must call `accesskit_string_free` with the return value. - #[no_mangle] - pub extern "C" fn accesskit_tree_get_toolkit_name(tree: *const tree) -> *mut c_char { - let tree = ref_from_ptr(tree); - match tree.toolkit_name.as_ref() { - Some(value) => CString::new(value.clone()).unwrap().into_raw(), - None => ptr::null_mut(), - } - } - - #[no_mangle] - pub extern "C" fn accesskit_tree_set_toolkit_name( - tree: *mut tree, - toolkit_name: *const c_char, - ) { - let tree = mut_from_ptr(tree); - tree.toolkit_name = Some(String::from( - unsafe { CStr::from_ptr(toolkit_name) }.to_string_lossy(), - )); - } - - #[no_mangle] - pub extern "C" fn accesskit_tree_clear_toolkit_name(tree: *mut tree) { - let tree = mut_from_ptr(tree); - tree.toolkit_name = None; - } - - /// Caller must call `accesskit_string_free` with the return value. - #[no_mangle] - pub extern "C" fn accesskit_tree_get_toolkit_version(tree: *const tree) -> *mut c_char { - let tree = ref_from_ptr(tree); - match tree.toolkit_version.as_ref() { - Some(value) => CString::new(value.clone()).unwrap().into_raw(), - None => ptr::null_mut(), - } - } - - #[no_mangle] - pub extern "C" fn accesskit_tree_set_toolkit_version( - tree: *mut tree, - toolkit_version: *const c_char, - ) { - let tree = mut_from_ptr(tree); - tree.toolkit_version = Some(String::from( - unsafe { CStr::from_ptr(toolkit_version) }.to_string_lossy(), - )); - } - - #[no_mangle] - pub extern "C" fn accesskit_tree_clear_toolkit_version(tree: *mut tree) { - let tree = mut_from_ptr(tree); - tree.toolkit_version = None; - } -} - -pub struct tree_update { - _private: [u8; 0], -} - -impl CastPtr for tree_update { - type RustType = TreeUpdate; -} - -impl BoxCastPtr for tree_update {} - -impl tree_update { - #[no_mangle] - pub extern "C" fn accesskit_tree_update_with_focus(focus: node_id) -> *mut tree_update { - let update = TreeUpdate { - nodes: vec![], - tree: None, - focus: focus.into(), - }; - BoxCastPtr::to_mut_ptr(update) - } - - #[no_mangle] - pub extern "C" fn accesskit_tree_update_with_capacity_and_focus( - capacity: usize, - focus: node_id, - ) -> *mut tree_update { - let update = TreeUpdate { - nodes: Vec::with_capacity(capacity), - tree: None, - focus: focus.into(), - }; - BoxCastPtr::to_mut_ptr(update) - } - - #[no_mangle] - pub extern "C" fn accesskit_tree_update_free(update: *mut tree_update) { - drop(box_from_ptr(update)); - } - - /// Appends the provided node to the tree update's list of nodes. - /// Takes ownership of `node`. - #[no_mangle] - pub extern "C" fn accesskit_tree_update_push_node( - update: *mut tree_update, - id: node_id, - node: *mut node, - ) { - let update = mut_from_ptr(update); - let node = box_from_ptr(node); - update.nodes.push((id.into(), *node)); - } - - #[no_mangle] - pub extern "C" fn accesskit_tree_update_set_tree(update: *mut tree_update, tree: *mut tree) { - let update = mut_from_ptr(update); - update.tree = Some(*box_from_ptr(tree)); - } - - #[no_mangle] - pub extern "C" fn accesskit_tree_update_clear_tree(update: *mut tree_update) { - let update = mut_from_ptr(update); - update.tree = None; - } - - #[no_mangle] - pub extern "C" fn accesskit_tree_update_set_focus(update: *mut tree_update, focus: node_id) { - let update = mut_from_ptr(update); - update.focus = focus.into(); - } -} - -#[repr(C)] -pub enum action_data { - CustomAction(i32), - Value(*mut c_char), - NumericValue(f64), - ScrollTargetRect(Rect), - ScrollToPoint(Point), - SetScrollOffset(Point), - SetTextSelection(text_selection), -} - -impl Drop for action_data { - fn drop(&mut self) { - if let Self::Value(value) = *self { - accesskit_string_free(value); - } - } -} - -opt_struct! { opt_action_data, action_data } - -impl From for action_data { - fn from(data: ActionData) -> Self { - match data { - ActionData::CustomAction(action) => Self::CustomAction(action), - ActionData::Value(value) => Self::Value(CString::new(&*value).unwrap().into_raw()), - ActionData::NumericValue(value) => Self::NumericValue(value), - ActionData::ScrollTargetRect(rect) => Self::ScrollTargetRect(rect), - ActionData::ScrollToPoint(point) => Self::ScrollToPoint(point), - ActionData::SetScrollOffset(offset) => Self::SetScrollOffset(offset), - ActionData::SetTextSelection(selection) => Self::SetTextSelection(selection.into()), - } - } -} - -#[repr(C)] -pub struct action_request { - pub action: Action, - pub target: node_id, - pub data: opt_action_data, -} - -impl From for action_request { - fn from(request: ActionRequest) -> action_request { - Self { - action: request.action, - target: request.target.into(), - data: request.data.into(), - } - } -} - -#[no_mangle] -pub extern "C" fn accesskit_action_request_free(request: *mut action_request) { - drop(unsafe { Box::from_raw(request) }); -} - -type ActivationHandlerCallbackUnwrapped = extern "C" fn(userdata: *mut c_void) -> *mut tree_update; -pub type ActivationHandlerCallback = - Option *mut tree_update>; - -struct FfiActivationHandlerUserdata(*mut c_void); - -unsafe impl Send for FfiActivationHandlerUserdata {} - -pub(crate) struct FfiActivationHandler { - callback: ActivationHandlerCallbackUnwrapped, - userdata: FfiActivationHandlerUserdata, -} - -impl FfiActivationHandler { - pub(crate) fn new(callback: ActivationHandlerCallback, userdata: *mut c_void) -> Self { - Self { - callback: callback.unwrap(), - userdata: FfiActivationHandlerUserdata(userdata), - } - } -} - -impl ActivationHandler for FfiActivationHandler { - fn request_initial_tree(&mut self) -> Option { - let result = (self.callback)(self.userdata.0); - if result.is_null() { - None - } else { - Some(*box_from_ptr(result)) - } - } -} - -type ActionHandlerCallbackUnwrapped = - extern "C" fn(request: *mut action_request, userdata: *mut c_void); - -/// Ownership of `request` is transfered to the callback. `request` must -/// be freed using `accesskit_action_request_free`. -pub type ActionHandlerCallback = - Option; - -struct FfiActionHandlerUserdata(*mut c_void); - -unsafe impl Send for FfiActionHandlerUserdata {} - -pub(crate) struct FfiActionHandler { - callback: ActionHandlerCallbackUnwrapped, - userdata: FfiActionHandlerUserdata, -} - -impl FfiActionHandler { - pub(crate) fn new(callback: ActionHandlerCallback, userdata: *mut c_void) -> Self { - Self { - callback: callback.unwrap(), - userdata: FfiActionHandlerUserdata(userdata), - } - } -} - -impl ActionHandler for FfiActionHandler { - fn do_action(&mut self, request: ActionRequest) { - let request = Box::new(action_request::from(request)); - (self.callback)(Box::into_raw(request), self.userdata.0); - } -} - -type DeactivationHandlerCallbackUnwrapped = extern "C" fn(userdata: *mut c_void); -pub type DeactivationHandlerCallback = Option; - -struct FfiDeactivationHandlerUserdata(*mut c_void); - -unsafe impl Send for FfiDeactivationHandlerUserdata {} - -pub(crate) struct FfiDeactivationHandler { - callback: DeactivationHandlerCallbackUnwrapped, - userdata: FfiDeactivationHandlerUserdata, -} - -impl FfiDeactivationHandler { - #[allow(dead_code)] - pub(crate) fn new(callback: DeactivationHandlerCallback, userdata: *mut c_void) -> Self { - Self { - callback: callback.unwrap(), - userdata: FfiDeactivationHandlerUserdata(userdata), - } - } -} - -impl DeactivationHandler for FfiDeactivationHandler { - fn deactivate_accessibility(&mut self) { - (self.callback)(self.userdata.0); - } -} - -#[repr(transparent)] -pub struct tree_update_factory_userdata(pub *mut c_void); - -unsafe impl Send for tree_update_factory_userdata {} - -/// This function can't return a null pointer. Ownership of the returned value will be transferred to the caller. -pub type tree_update_factory = - Option *mut tree_update>; diff --git a/bindings/c/src/geometry.rs b/bindings/c/src/geometry.rs deleted file mode 100644 index 16a23888..00000000 --- a/bindings/c/src/geometry.rs +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright 2023 The AccessKit Authors. All rights reserved. -// Licensed under the Apache License, Version 2.0 (found in -// the LICENSE-APACHE file) or the MIT license (found in -// the LICENSE-MIT file), at your option. - -use accesskit::{Affine, Point, Rect, Size, Vec2}; -use paste::paste; - -#[no_mangle] -pub const extern "C" fn accesskit_affine_identity() -> Affine { - Affine::scale(1.0) -} - -#[no_mangle] -pub const extern "C" fn accesskit_affine_flip_y() -> Affine { - Affine::new([1.0, 0., 0., -1.0, 0., 0.]) -} - -#[no_mangle] -pub const extern "C" fn accesskit_affine_flip_x() -> Affine { - Affine::new([-1.0, 0., 0., 1.0, 0., 0.]) -} - -#[no_mangle] -pub const extern "C" fn accesskit_affine_scale(s: f64) -> Affine { - Affine::scale(s) -} - -#[no_mangle] -pub const extern "C" fn accesskit_affine_scale_non_uniform(s_x: f64, s_y: f64) -> Affine { - Affine::scale_non_uniform(s_x, s_y) -} - -#[no_mangle] -pub extern "C" fn accesskit_affine_rotate(th: f64) -> Affine { - Affine::rotate(th) -} - -#[no_mangle] -pub extern "C" fn accesskit_affine_translate(p: Vec2) -> Affine { - Affine::translate(p) -} - -#[no_mangle] -pub extern "C" fn accesskit_affine_map_unit_square(rect: Rect) -> Affine { - Affine::map_unit_square(rect) -} - -#[no_mangle] -pub extern "C" fn accesskit_affine_determinant(affine: Affine) -> f64 { - Affine::determinant(affine) -} - -#[no_mangle] -pub extern "C" fn accesskit_affine_inverse(affine: Affine) -> Affine { - Affine::inverse(affine) -} - -#[no_mangle] -pub extern "C" fn accesskit_affine_transform_rect_bbox(affine: Affine, rect: Rect) -> Rect { - Affine::transform_rect_bbox(affine, rect) -} - -#[no_mangle] -pub extern "C" fn accesskit_affine_is_finite(affine: *const Affine) -> bool { - if affine.is_null() { - false - } else { - unsafe { Box::from_raw(affine as *mut Affine).is_finite() } - } -} - -#[no_mangle] -pub extern "C" fn accesskit_affine_is_nan(affine: *const Affine) -> bool { - if affine.is_null() { - false - } else { - unsafe { Box::from_raw(affine as *mut Affine).is_nan() } - } -} - -#[no_mangle] -pub const extern "C" fn accesskit_point_to_vec2(point: Point) -> Vec2 { - Point::to_vec2(point) -} - -#[no_mangle] -pub extern "C" fn accesskit_rect_from_points(p0: Point, p1: Point) -> Rect { - Rect::from_points(p0, p1) -} - -#[no_mangle] -pub extern "C" fn accesskit_rect_from_origin_size(origin: Point, size: Size) -> Rect { - Rect::from_origin_size(origin, size) -} - -#[no_mangle] -pub extern "C" fn accesskit_rect_with_origin(rect: Rect, origin: Point) -> Rect { - Rect::with_origin(rect, origin) -} - -#[no_mangle] -pub extern "C" fn accesskit_rect_with_size(rect: Rect, size: Size) -> Rect { - Rect::with_size(rect, size) -} - -macro_rules! rect_getter_methods { - ($(($getter:ident, $getter_result:ty, $default_value:expr)),+) => { - paste! { - $(#[no_mangle] - pub extern "C" fn [](rect: *const Rect) -> $getter_result { - if rect.is_null() { - $default_value - } else { - unsafe { Box::from_raw(rect as *mut Rect).$getter() } - } - })* - } - } -} - -rect_getter_methods! { - (width, f64, 0.), - (height, f64, 0.), - (min_x, f64, 0.), - (max_x, f64, 0.), - (min_y, f64, 0.), - (max_y, f64, 0.), - (origin, Point, Point::ZERO), - (size, Size, Size::ZERO), - (abs, Rect, Rect::ZERO), - (area, f64, 0.), - (is_empty, bool, true) -} - -#[no_mangle] -pub extern "C" fn accesskit_rect_contains(rect: *const Rect, point: Point) -> bool { - if rect.is_null() { - false - } else { - unsafe { Box::from_raw(rect as *mut Rect).contains(point) } - } -} - -#[no_mangle] -pub extern "C" fn accesskit_rect_union(rect: *const Rect, other: Rect) -> Rect { - if rect.is_null() { - Rect::ZERO - } else { - unsafe { Box::from_raw(rect as *mut Rect).union(other) } - } -} - -#[no_mangle] -pub extern "C" fn accesskit_rect_union_pt(rect: *const Rect, pt: Point) -> Rect { - if rect.is_null() { - Rect::ZERO - } else { - unsafe { Box::from_raw(rect as *mut Rect).union_pt(pt) } - } -} - -#[no_mangle] -pub extern "C" fn accesskit_rect_intersect(rect: *const Rect, other: Rect) -> Rect { - if rect.is_null() { - Rect::ZERO - } else { - unsafe { Box::from_raw(rect as *mut Rect).intersect(other) } - } -} - -#[no_mangle] -pub const extern "C" fn accesskit_size_to_vec2(size: Size) -> Vec2 { - Size::to_vec2(size) -} - -#[no_mangle] -pub const extern "C" fn accesskit_vec2_to_point(vec2: Vec2) -> Point { - Vec2::to_point(vec2) -} - -#[no_mangle] -pub const extern "C" fn accesskit_vec2_to_size(vec2: Vec2) -> Size { - Vec2::to_size(vec2) -} diff --git a/bindings/c/src/lib.rs b/bindings/c/src/lib.rs deleted file mode 100644 index 11353de8..00000000 --- a/bindings/c/src/lib.rs +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright 2023 The AccessKit Authors. All rights reserved. -// Licensed under the Apache License, Version 2.0 (found in -// the LICENSE-APACHE file) or the MIT license (found in -// the LICENSE-MIT file), at your option. - -// Derived from rustls-ffi. -// Copyright (c) 2021, Jacob Hoffman-Andrews -// Licensed under the Apache License, Version 2.0 (found in -// the LICENSE-APACHE file), the ISC license (found in -// the LICENSE-ISC file), or the MIT license (found in -// the LICENSE-MIT file), at your option. - -#![allow(non_camel_case_types)] -#![allow(clippy::not_unsafe_ptr_arg_deref)] - -mod common; -mod geometry; - -#[cfg(any(target_os = "macos", feature = "cbindgen"))] -mod macos; -#[cfg(any( - target_os = "linux", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd", - feature = "cbindgen" -))] -mod unix; -#[cfg(any(target_os = "windows", feature = "cbindgen"))] -mod windows; - -pub use common::*; -pub use geometry::*; -#[cfg(any(target_os = "macos", feature = "cbindgen"))] -pub use macos::*; -#[cfg(any( - target_os = "linux", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd", - feature = "cbindgen" -))] -pub use unix::*; -#[cfg(any(target_os = "windows", feature = "cbindgen"))] -pub use windows::*; - -/// `CastPtr` represents the relationship between a snake case type (like `node_builder`) -/// and the corresponding Rust type (like `NodeBuilder`). For each matched pair of types, there -/// should be an `impl CastPtr for foo_bar { RustType = FooBar }`. -/// -/// This allows us to avoid using `as` in most places, and ensure that when we cast, we're -/// preserving const-ness, and casting between the correct types. -/// Implementing this is required in order to use `ref_from_ptr!` or -/// `mut_from_ptr!`. -pub(crate) trait CastPtr { - type RustType; - - fn cast_mut_ptr(ptr: *mut Self) -> *mut Self::RustType { - ptr as *mut _ - } -} - -/// `CastConstPtr` represents a subset of `CastPtr`, for when we can only treat -/// something as a const (for instance when dealing with `Arc`). -pub(crate) trait CastConstPtr { - type RustType; - - fn cast_const_ptr(ptr: *const Self) -> *const Self::RustType { - ptr as *const _ - } -} - -/// Anything that qualifies for `CastPtr` also automatically qualifies for -/// `CastConstPtr`. Splitting out `CastPtr` vs `CastConstPtr` allows us to ensure -/// that `Arc`s are never cast to a mutable pointer. -impl CastConstPtr for T -where - T: CastPtr, -{ - type RustType = R; -} - -// An implementation of BoxCastPtr means that when we give C code a pointer to the relevant type, -// it is actually a Box. -pub(crate) trait BoxCastPtr: CastPtr + Sized { - fn to_box(ptr: *mut Self) -> Box { - assert!(!ptr.is_null()); - let rs_typed = Self::cast_mut_ptr(ptr); - unsafe { Box::from_raw(rs_typed) } - } - - fn to_mut_ptr(src: Self::RustType) -> *mut Self { - Box::into_raw(Box::new(src)) as *mut _ - } - - // The following exception is needed because this function is only - // used in the bindings for some platform adapters. - #[allow(dead_code)] - fn to_nullable_mut_ptr(src: Option) -> *mut Self { - src.map_or_else(std::ptr::null_mut, Self::to_mut_ptr) - } -} - -/// Turn a raw const pointer into a reference. This is a generic function -/// rather than part of the `CastPtr` trait because (a) const pointers can't act -/// as "self" for trait methods, and (b) we want to rely on type inference -/// against `T` (the cast-to type) rather than across `F` (the from type). -pub(crate) fn ref_from_ptr<'a, F, T>(from: *const F) -> &'a T -where - F: CastConstPtr, -{ - unsafe { F::cast_const_ptr(from).as_ref() }.unwrap() -} - -/// Turn a raw mut pointer into a mutable reference. -pub(crate) fn mut_from_ptr<'a, F, T>(from: *mut F) -> &'a mut T -where - F: CastPtr, -{ - unsafe { F::cast_mut_ptr(from).as_mut() }.unwrap() -} - -pub(crate) fn box_from_ptr(from: *mut F) -> Box -where - F: BoxCastPtr, -{ - F::to_box(from) -} - -#[doc(hidden)] -#[macro_export] -macro_rules! opt_struct { - ($struct_name:ident, $prop_type:ty) => { - /// Represents an optional value. - /// - /// If `has_value` is false, do not read the `value` field. - #[repr(C)] - pub struct $struct_name { - pub has_value: bool, - pub value: std::mem::MaybeUninit<$prop_type>, - } - impl From> for $struct_name - where - T: Into<$prop_type>, - { - fn from(value: Option) -> $struct_name { - match value { - None => $struct_name::default(), - Some(value) => $struct_name { - has_value: true, - value: std::mem::MaybeUninit::new(value.into()), - }, - } - } - } - impl From<$struct_name> for Option - where - T: From<$prop_type>, - { - fn from(value: $struct_name) -> Self { - match value.has_value { - true => Some(unsafe { T::from(value.value.assume_init()) }), - false => None, - } - } - } - impl Default for $struct_name { - fn default() -> $struct_name { - $struct_name { - has_value: false, - value: std::mem::MaybeUninit::uninit(), - } - } - } - }; -} diff --git a/bindings/c/src/macos.rs b/bindings/c/src/macos.rs deleted file mode 100644 index 3434e7bc..00000000 --- a/bindings/c/src/macos.rs +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright 2023 The AccessKit Authors. All rights reserved. -// Licensed under the Apache License, Version 2.0 (found in -// the LICENSE-APACHE file) or the MIT license (found in -// the LICENSE-MIT file), at your option. - -use crate::{ - box_from_ptr, mut_from_ptr, tree_update_factory, tree_update_factory_userdata, - ActionHandlerCallback, ActivationHandlerCallback, BoxCastPtr, CastPtr, FfiActionHandler, - FfiActivationHandler, -}; -use accesskit_macos::{ - add_focus_forwarder_to_window_class, Adapter, NSPoint, QueuedEvents, SubclassingAdapter, -}; -use std::{ - ffi::CStr, - os::raw::{c_char, c_void}, -}; - -pub struct macos_queued_events { - _private: [u8; 0], -} - -impl CastPtr for macos_queued_events { - type RustType = QueuedEvents; -} - -impl BoxCastPtr for macos_queued_events {} - -impl macos_queued_events { - /// Memory is also freed when calling this function. - #[no_mangle] - pub extern "C" fn accesskit_macos_queued_events_raise(events: *mut macos_queued_events) { - let events = box_from_ptr(events); - events.raise(); - } -} - -pub struct macos_adapter { - _private: [u8; 0], -} - -impl CastPtr for macos_adapter { - type RustType = Adapter; -} - -impl BoxCastPtr for macos_adapter {} - -impl macos_adapter { - /// # Safety - /// - /// `view` must be a valid, unreleased pointer to an `NSView`. - #[no_mangle] - pub unsafe extern "C" fn accesskit_macos_adapter_new( - view: *mut c_void, - is_view_focused: bool, - action_handler: ActionHandlerCallback, - action_handler_userdata: *mut c_void, - ) -> *mut macos_adapter { - let action_handler = FfiActionHandler::new(action_handler, action_handler_userdata); - let adapter = Adapter::new(view, is_view_focused, action_handler); - BoxCastPtr::to_mut_ptr(adapter) - } - - #[no_mangle] - pub extern "C" fn accesskit_macos_adapter_free(adapter: *mut macos_adapter) { - drop(box_from_ptr(adapter)); - } - - /// You must call `accesskit_macos_queued_events_raise` on the returned pointer. It can be null if the adapter is not active. - #[no_mangle] - pub extern "C" fn accesskit_macos_adapter_update_if_active( - adapter: *mut macos_adapter, - update_factory: tree_update_factory, - update_factory_userdata: *mut c_void, - ) -> *mut macos_queued_events { - let update_factory = update_factory.unwrap(); - let update_factory_userdata = tree_update_factory_userdata(update_factory_userdata); - let adapter = mut_from_ptr(adapter); - let events = - adapter.update_if_active(|| *box_from_ptr(update_factory(update_factory_userdata))); - BoxCastPtr::to_nullable_mut_ptr(events) - } - - /// Update the tree state based on whether the window is focused. - /// - /// You must call `accesskit_macos_queued_events_raise` on the returned pointer. It can be null if the adapter is not active. - #[no_mangle] - pub extern "C" fn accesskit_macos_adapter_update_view_focus_state( - adapter: *mut macos_adapter, - is_focused: bool, - ) -> *mut macos_queued_events { - let adapter = mut_from_ptr(adapter); - let events = adapter.update_view_focus_state(is_focused); - BoxCastPtr::to_nullable_mut_ptr(events) - } - - /// Returns a pointer to an `NSArray`. Ownership of the pointer is not transferred. - #[no_mangle] - pub extern "C" fn accesskit_macos_adapter_view_children( - adapter: *mut macos_adapter, - activation_handler: ActivationHandlerCallback, - activation_handler_userdata: *mut c_void, - ) -> *mut c_void { - let adapter = mut_from_ptr(adapter); - let mut activation_handler = - FfiActivationHandler::new(activation_handler, activation_handler_userdata); - adapter.view_children(&mut activation_handler) as *mut _ - } - - /// Returns a pointer to an `NSObject`. Ownership of the pointer is not transferred. - #[no_mangle] - pub extern "C" fn accesskit_macos_adapter_focus( - adapter: *mut macos_adapter, - activation_handler: ActivationHandlerCallback, - activation_handler_userdata: *mut c_void, - ) -> *mut c_void { - let adapter = mut_from_ptr(adapter); - let mut activation_handler = - FfiActivationHandler::new(activation_handler, activation_handler_userdata); - adapter.focus(&mut activation_handler) as *mut _ - } - - /// Returns a pointer to an `NSObject`. Ownership of the pointer is not transferred. - #[no_mangle] - pub extern "C" fn accesskit_macos_adapter_hit_test( - adapter: *mut macos_adapter, - x: f64, - y: f64, - activation_handler: ActivationHandlerCallback, - activation_handler_userdata: *mut c_void, - ) -> *mut c_void { - let adapter = mut_from_ptr(adapter); - let mut activation_handler = - FfiActivationHandler::new(activation_handler, activation_handler_userdata); - adapter.hit_test(NSPoint::new(x, y), &mut activation_handler) as *mut _ - } -} - -pub struct macos_subclassing_adapter { - _private: [u8; 0], -} - -impl CastPtr for macos_subclassing_adapter { - type RustType = SubclassingAdapter; -} - -impl BoxCastPtr for macos_subclassing_adapter {} - -impl macos_subclassing_adapter { - /// # Safety - /// - /// `view` must be a valid, unreleased pointer to an `NSView`. - #[no_mangle] - pub unsafe extern "C" fn accesskit_macos_subclassing_adapter_new( - view: *mut c_void, - activation_handler: ActivationHandlerCallback, - activation_handler_userdata: *mut c_void, - action_handler: ActionHandlerCallback, - action_handler_userdata: *mut c_void, - ) -> *mut macos_subclassing_adapter { - let activation_handler = - FfiActivationHandler::new(activation_handler, activation_handler_userdata); - let action_handler = FfiActionHandler::new(action_handler, action_handler_userdata); - let adapter = SubclassingAdapter::new(view, activation_handler, action_handler); - BoxCastPtr::to_mut_ptr(adapter) - } - - /// # Safety - /// - /// `window` must be a valid, unreleased pointer to an `NSWindow`. - /// - /// # Panics - /// - /// This function panics if the specified window doesn't currently have - /// a content view. - #[no_mangle] - pub unsafe extern "C" fn accesskit_macos_subclassing_adapter_for_window( - window: *mut c_void, - activation_handler: ActivationHandlerCallback, - activation_handler_userdata: *mut c_void, - action_handler: ActionHandlerCallback, - action_handler_userdata: *mut c_void, - ) -> *mut macos_subclassing_adapter { - let activation_handler = - FfiActivationHandler::new(activation_handler, activation_handler_userdata); - let action_handler = FfiActionHandler::new(action_handler, action_handler_userdata); - let adapter = SubclassingAdapter::for_window(window, activation_handler, action_handler); - BoxCastPtr::to_mut_ptr(adapter) - } - - #[no_mangle] - pub extern "C" fn accesskit_macos_subclassing_adapter_free( - adapter: *mut macos_subclassing_adapter, - ) { - drop(box_from_ptr(adapter)); - } - - /// You must call `accesskit_macos_queued_events_raise` on the returned pointer. It can be null if the adapter is not active. - #[no_mangle] - pub extern "C" fn accesskit_macos_subclassing_adapter_update_if_active( - adapter: *mut macos_subclassing_adapter, - update_factory: tree_update_factory, - update_factory_userdata: *mut c_void, - ) -> *mut macos_queued_events { - let update_factory = update_factory.unwrap(); - let update_factory_userdata = tree_update_factory_userdata(update_factory_userdata); - let adapter = mut_from_ptr(adapter); - let events = - adapter.update_if_active(|| *box_from_ptr(update_factory(update_factory_userdata))); - BoxCastPtr::to_nullable_mut_ptr(events) - } - - /// Update the tree state based on whether the window is focused. - /// - /// You must call `accesskit_macos_queued_events_raise` on the returned pointer. It can be null if the adapter is not active. - #[no_mangle] - pub extern "C" fn accesskit_macos_subclassing_adapter_update_view_focus_state( - adapter: *mut macos_subclassing_adapter, - is_focused: bool, - ) -> *mut macos_queued_events { - let adapter = mut_from_ptr(adapter); - let events = adapter.update_view_focus_state(is_focused); - BoxCastPtr::to_nullable_mut_ptr(events) - } -} - -/// Modifies the specified class, which must be a subclass of `NSWindow`, -/// to include an `accessibilityFocusedUIElement` method that calls -/// the corresponding method on the window's content view. This is needed -/// for windowing libraries such as SDL that place the keyboard focus -/// directly on the window rather than the content view. -/// -/// # Safety -/// -/// This function is declared unsafe because the caller must ensure that the -/// code for this library is never unloaded from the application process, -/// since it's not possible to reverse this operation. It's safest -/// if this library is statically linked into the application's main executable. -/// Also, this function assumes that the specified class is a subclass -/// of `NSWindow`. -#[no_mangle] -pub unsafe extern "C" fn accesskit_macos_add_focus_forwarder_to_window_class( - class_name: *const c_char, -) { - let class_name = unsafe { CStr::from_ptr(class_name).to_string_lossy() }; - add_focus_forwarder_to_window_class(&class_name); -} diff --git a/bindings/c/src/unix.rs b/bindings/c/src/unix.rs deleted file mode 100644 index 80b37c25..00000000 --- a/bindings/c/src/unix.rs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2023 The AccessKit Authors. All rights reserved. -// Licensed under the Apache License, Version 2.0 (found in -// the LICENSE-APACHE file) or the MIT license (found in -// the LICENSE-MIT file), at your option. - -use crate::{ - box_from_ptr, mut_from_ptr, tree_update_factory, tree_update_factory_userdata, - ActionHandlerCallback, ActivationHandlerCallback, BoxCastPtr, CastPtr, - DeactivationHandlerCallback, FfiActionHandler, FfiActivationHandler, FfiDeactivationHandler, -}; -use accesskit::Rect; -use accesskit_unix::Adapter; -use std::os::raw::c_void; - -pub struct unix_adapter { - _private: [u8; 0], -} - -impl CastPtr for unix_adapter { - type RustType = Adapter; -} - -impl BoxCastPtr for unix_adapter {} - -impl unix_adapter { - /// All of the handlers will always be called from another thread. - #[no_mangle] - pub extern "C" fn accesskit_unix_adapter_new( - activation_handler: ActivationHandlerCallback, - activation_handler_userdata: *mut c_void, - action_handler: ActionHandlerCallback, - action_handler_userdata: *mut c_void, - deactivation_handler: DeactivationHandlerCallback, - deactivation_handler_userdata: *mut c_void, - ) -> *mut unix_adapter { - let activation_handler = - FfiActivationHandler::new(activation_handler, activation_handler_userdata); - let action_handler = FfiActionHandler::new(action_handler, action_handler_userdata); - let deactivation_handler = - FfiDeactivationHandler::new(deactivation_handler, deactivation_handler_userdata); - let adapter = Adapter::new(activation_handler, action_handler, deactivation_handler); - BoxCastPtr::to_mut_ptr(adapter) - } - - #[no_mangle] - pub extern "C" fn accesskit_unix_adapter_free(adapter: *mut unix_adapter) { - drop(box_from_ptr(adapter)); - } - - #[no_mangle] - pub extern "C" fn accesskit_unix_adapter_set_root_window_bounds( - adapter: *mut unix_adapter, - outer: Rect, - inner: Rect, - ) { - let adapter = mut_from_ptr(adapter); - adapter.set_root_window_bounds(outer, inner); - } - - #[no_mangle] - pub extern "C" fn accesskit_unix_adapter_update_if_active( - adapter: *mut unix_adapter, - update_factory: tree_update_factory, - update_factory_userdata: *mut c_void, - ) { - let update_factory = update_factory.unwrap(); - let update_factory_userdata = tree_update_factory_userdata(update_factory_userdata); - let adapter = mut_from_ptr(adapter); - adapter.update_if_active(|| *box_from_ptr(update_factory(update_factory_userdata))); - } - - /// Update the tree state based on whether the window is focused. - #[no_mangle] - pub extern "C" fn accesskit_unix_adapter_update_window_focus_state( - adapter: *mut unix_adapter, - is_focused: bool, - ) { - let adapter = mut_from_ptr(adapter); - adapter.update_window_focus_state(is_focused); - } -} diff --git a/bindings/c/src/windows.rs b/bindings/c/src/windows.rs deleted file mode 100644 index bbcb43f1..00000000 --- a/bindings/c/src/windows.rs +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright 2023 The AccessKit Authors. All rights reserved. -// Licensed under the Apache License, Version 2.0 (found in -// the LICENSE-APACHE file) or the MIT license (found in -// the LICENSE-MIT file), at your option. - -use crate::{ - box_from_ptr, mut_from_ptr, opt_struct, tree_update_factory, tree_update_factory_userdata, - ActionHandlerCallback, ActivationHandlerCallback, BoxCastPtr, CastPtr, FfiActionHandler, - FfiActivationHandler, -}; -use accesskit_windows::*; -use std::os::raw::c_void; - -pub struct windows_queued_events { - _private: [u8; 0], -} - -impl CastPtr for windows_queued_events { - type RustType = QueuedEvents; -} - -impl BoxCastPtr for windows_queued_events {} - -impl windows_queued_events { - /// Memory is also freed when calling this function. - #[no_mangle] - pub extern "C" fn accesskit_windows_queued_events_raise(events: *mut windows_queued_events) { - let events = box_from_ptr(events); - events.raise(); - } -} - -opt_struct! { opt_lresult, LRESULT } - -pub struct windows_adapter { - _private: [u8; 0], -} - -impl CastPtr for windows_adapter { - type RustType = Adapter; -} - -impl BoxCastPtr for windows_adapter {} - -impl windows_adapter { - #[no_mangle] - pub extern "C" fn accesskit_windows_adapter_new( - hwnd: HWND, - is_window_focused: bool, - action_handler: ActionHandlerCallback, - action_handler_userdata: *mut c_void, - ) -> *mut windows_adapter { - let action_handler = FfiActionHandler::new(action_handler, action_handler_userdata); - let adapter = Adapter::new(hwnd, is_window_focused, action_handler); - BoxCastPtr::to_mut_ptr(adapter) - } - - #[no_mangle] - pub extern "C" fn accesskit_windows_adapter_free(adapter: *mut windows_adapter) { - drop(box_from_ptr(adapter)); - } - - /// You must call `accesskit_windows_queued_events_raise` on the returned pointer. It can be null if the adapter is not active. - #[no_mangle] - pub extern "C" fn accesskit_windows_adapter_update_if_active( - adapter: *mut windows_adapter, - update_factory: tree_update_factory, - update_factory_userdata: *mut c_void, - ) -> *mut windows_queued_events { - let update_factory = update_factory.unwrap(); - let update_factory_userdata = tree_update_factory_userdata(update_factory_userdata); - let adapter = mut_from_ptr(adapter); - let events = - adapter.update_if_active(|| *box_from_ptr(update_factory(update_factory_userdata))); - BoxCastPtr::to_nullable_mut_ptr(events) - } - - /// Update the tree state based on whether the window is focused. - /// - /// You must call `accesskit_windows_queued_events_raise` on the returned pointer. - #[no_mangle] - pub extern "C" fn accesskit_windows_adapter_update_window_focus_state( - adapter: *mut windows_adapter, - is_focused: bool, - ) -> *mut windows_queued_events { - let adapter = mut_from_ptr(adapter); - let events = adapter.update_window_focus_state(is_focused); - BoxCastPtr::to_nullable_mut_ptr(events) - } - - #[no_mangle] - pub extern "C" fn accesskit_windows_adapter_handle_wm_getobject( - adapter: *mut windows_adapter, - wparam: WPARAM, - lparam: LPARAM, - activation_handler: ActivationHandlerCallback, - activation_handler_userdata: *mut c_void, - ) -> opt_lresult { - let adapter = mut_from_ptr(adapter); - let mut activation_handler = - FfiActivationHandler::new(activation_handler, activation_handler_userdata); - let lresult = adapter.handle_wm_getobject(wparam, lparam, &mut activation_handler); - opt_lresult::from(lresult) - } -} - -pub struct windows_subclassing_adapter { - _private: [u8; 0], -} - -impl CastPtr for windows_subclassing_adapter { - type RustType = SubclassingAdapter; -} - -impl BoxCastPtr for windows_subclassing_adapter {} - -impl windows_subclassing_adapter { - #[no_mangle] - pub extern "C" fn accesskit_windows_subclassing_adapter_new( - hwnd: HWND, - activation_handler: ActivationHandlerCallback, - activation_handler_userdata: *mut c_void, - action_handler: ActionHandlerCallback, - action_handler_userdata: *mut c_void, - ) -> *mut windows_subclassing_adapter { - let activation_handler = - FfiActivationHandler::new(activation_handler, activation_handler_userdata); - let action_handler = FfiActionHandler::new(action_handler, action_handler_userdata); - let adapter = SubclassingAdapter::new(hwnd, activation_handler, action_handler); - BoxCastPtr::to_mut_ptr(adapter) - } - - #[no_mangle] - pub extern "C" fn accesskit_windows_subclassing_adapter_free( - adapter: *mut windows_subclassing_adapter, - ) { - drop(box_from_ptr(adapter)); - } - - /// You must call `accesskit_windows_queued_events_raise` on the returned pointer. It can be null if the adapter is not active. - #[no_mangle] - pub extern "C" fn accesskit_windows_subclassing_adapter_update_if_active( - adapter: *mut windows_subclassing_adapter, - update_factory: tree_update_factory, - update_factory_userdata: *mut c_void, - ) -> *mut windows_queued_events { - let update_factory = update_factory.unwrap(); - let update_factory_userdata = tree_update_factory_userdata(update_factory_userdata); - let adapter = mut_from_ptr(adapter); - let events = - adapter.update_if_active(|| *box_from_ptr(update_factory(update_factory_userdata))); - BoxCastPtr::to_nullable_mut_ptr(events) - } -} diff --git a/bindings/python/.cargo/config.toml b/bindings/python/.cargo/config.toml deleted file mode 100644 index 7cb83a10..00000000 --- a/bindings/python/.cargo/config.toml +++ /dev/null @@ -1,11 +0,0 @@ -[target.aarch64-apple-darwin] -rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", -] - -[target.x86_64-apple-darwin] -rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", -] diff --git a/bindings/python/CHANGELOG.md b/bindings/python/CHANGELOG.md deleted file mode 100644 index 894a1510..00000000 --- a/bindings/python/CHANGELOG.md +++ /dev/null @@ -1,191 +0,0 @@ -# Changelog - -* The following workspace dependencies were updated - * dependencies - * accesskit_unix bumped from 0.7.0 to 0.7.1 - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.16.0 to 0.16.1 - * accesskit_unix bumped from 0.7.1 to 0.7.2 - -* The following workspace dependencies were updated - * dependencies - * accesskit_unix bumped from 0.7.2 to 0.7.3 - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.16.1 to 0.16.2 - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.12.2 to 0.12.3 - * accesskit_windows bumped from 0.16.2 to 0.16.3 - * accesskit_macos bumped from 0.11.0 to 0.11.1 - * accesskit_unix bumped from 0.7.3 to 0.7.4 - -* The following workspace dependencies were updated - * dependencies - * accesskit_unix bumped from 0.7.4 to 0.7.5 - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.16.3 to 0.16.4 - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.18.1 to 0.18.2 - * accesskit_macos bumped from 0.13.1 to 0.13.2 - * accesskit_unix bumped from 0.9.1 to 0.9.2 - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.18.2 to 0.19.0 - * accesskit_macos bumped from 0.13.2 to 0.14.0 - * accesskit_unix bumped from 0.9.2 to 0.10.0 - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.19.0 to 0.20.0 - * accesskit_macos bumped from 0.14.0 to 0.15.0 - * accesskit_unix bumped from 0.10.0 to 0.10.1 - -* The following workspace dependencies were updated - * dependencies - * accesskit_unix bumped from 0.11.0 to 0.11.1 - -## [0.5.0](https://github.com/AccessKit/accesskit/compare/accesskit_python-v0.4.1...accesskit_python-v0.5.0) (2024-06-29) - - -### ⚠ BREAKING CHANGES - -* Rename the `StaticText` role to `Label` ([#434](https://github.com/AccessKit/accesskit/issues/434)) - -### Code Refactoring - -* Rename the `StaticText` role to `Label` ([#434](https://github.com/AccessKit/accesskit/issues/434)) ([7086bc0](https://github.com/AccessKit/accesskit/commit/7086bc0fad446d3ed4a0fd5eff641a1e75f6c599)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.15.0 to 0.16.0 - * accesskit_windows bumped from 0.21.0 to 0.22.0 - * accesskit_macos bumped from 0.16.0 to 0.17.0 - * accesskit_unix bumped from 0.11.1 to 0.12.0 - -## [0.4.0](https://github.com/AccessKit/accesskit/compare/accesskit_python-v0.3.4...accesskit_python-v0.4.0) (2024-06-09) - - -### Features - -* Add `author_id` property ([#424](https://github.com/AccessKit/accesskit/issues/424)) ([0d1c56f](https://github.com/AccessKit/accesskit/commit/0d1c56f0bdde58715e1c69f6015df600cb7cb8c1)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.14.0 to 0.15.0 - * accesskit_windows bumped from 0.20.0 to 0.21.0 - * accesskit_macos bumped from 0.15.0 to 0.16.0 - * accesskit_unix bumped from 0.10.1 to 0.11.0 - -## [0.3.1](https://github.com/AccessKit/accesskit/compare/accesskit_python-v0.3.0...accesskit_python-v0.3.1) (2024-05-11) - - -### Bug Fixes - -* Fix dead code warning on Unix platforms ([#403](https://github.com/AccessKit/accesskit/issues/403)) ([09d9157](https://github.com/AccessKit/accesskit/commit/09d91577dd88743e379a1fdea34b25a94726d0fb)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit_windows bumped from 0.18.0 to 0.18.1 - * accesskit_macos bumped from 0.13.0 to 0.13.1 - * accesskit_unix bumped from 0.9.0 to 0.9.1 - -## [0.3.0](https://github.com/AccessKit/accesskit/compare/accesskit_python-v0.2.0...accesskit_python-v0.3.0) (2024-04-30) - - -### ⚠ BREAKING CHANGES - -* Clean up table roles and properties ([#393](https://github.com/AccessKit/accesskit/issues/393)) -* Rename `hierarchical_level` to `level` ([#390](https://github.com/AccessKit/accesskit/issues/390)) -* Drop `NodeClassSet` ([#389](https://github.com/AccessKit/accesskit/issues/389)) -* Rename `Checked` to `Toggled`; drop `ToggleButton` role ([#388](https://github.com/AccessKit/accesskit/issues/388)) - -### Features - -* Add the `owns` relation ([#392](https://github.com/AccessKit/accesskit/issues/392)) ([fd668dd](https://github.com/AccessKit/accesskit/commit/fd668ddc4b64cb05ab3600972b3d3823a037f2d5)) - - -### Bug Fixes - -* Increase minimum supported Rust version to `1.70` ([#396](https://github.com/AccessKit/accesskit/issues/396)) ([a8398b8](https://github.com/AccessKit/accesskit/commit/a8398b847aa003de91042ac45e33126fc2cae053)) - - -### Code Refactoring - -* Clean up table roles and properties ([#393](https://github.com/AccessKit/accesskit/issues/393)) ([e34dad9](https://github.com/AccessKit/accesskit/commit/e34dad94448a5321ece9def3f2e054aa5f62dd79)) -* Drop `NodeClassSet` ([#389](https://github.com/AccessKit/accesskit/issues/389)) ([1b153ed](https://github.com/AccessKit/accesskit/commit/1b153ed51f8421cdba2dc98beca2e8f5f8c781bc)) -* Rename `Checked` to `Toggled`; drop `ToggleButton` role ([#388](https://github.com/AccessKit/accesskit/issues/388)) ([6bc040b](https://github.com/AccessKit/accesskit/commit/6bc040b7cf75cdbd6a019cc380d8dbce804b3c81)) -* Rename `hierarchical_level` to `level` ([#390](https://github.com/AccessKit/accesskit/issues/390)) ([2d61e01](https://github.com/AccessKit/accesskit/commit/2d61e01fffff1265b348c141715f6f9b6fe4081b)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.13.0 to 0.14.0 - * accesskit_windows bumped from 0.17.0 to 0.18.0 - * accesskit_macos bumped from 0.12.0 to 0.13.0 - * accesskit_unix bumped from 0.8.0 to 0.9.0 - -## [0.2.0](https://github.com/AccessKit/accesskit/compare/accesskit_python-v0.1.8...accesskit_python-v0.2.0) (2024-04-14) - - -### ⚠ BREAKING CHANGES - -* New approach to lazy initialization ([#375](https://github.com/AccessKit/accesskit/issues/375)) - -### Code Refactoring - -* New approach to lazy initialization ([#375](https://github.com/AccessKit/accesskit/issues/375)) ([9baebdc](https://github.com/AccessKit/accesskit/commit/9baebdceed7300389b6768815d7ae48f1ce401e4)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.12.3 to 0.13.0 - * accesskit_windows bumped from 0.16.4 to 0.17.0 - * accesskit_macos bumped from 0.11.1 to 0.12.0 - * accesskit_unix bumped from 0.7.5 to 0.8.0 - -## [0.1.1](https://github.com/AccessKit/accesskit/compare/accesskit_python-v0.1.0...accesskit_python-v0.1.1) (2024-01-06) - - -### Bug Fixes - -* Decrease minimum Python version to 3.8 for Python bindings ([#334](https://github.com/AccessKit/accesskit/issues/334)) ([3725373](https://github.com/AccessKit/accesskit/commit/3725373658bf2475cf3e1341b2e5fcefada576bd)) - -## 0.1.0 (2024-01-03) - - -### Features - -* Add Python bindings ([#269](https://github.com/AccessKit/accesskit/issues/269)) ([52560da](https://github.com/AccessKit/accesskit/commit/52560da1c1480f1a37a27906b24b518a5fa03249)) - - -### Dependencies - -* The following workspace dependencies were updated - * dependencies - * accesskit bumped from 0.12.1 to 0.12.2 - * accesskit_windows bumped from 0.15.1 to 0.16.0 - * accesskit_macos bumped from 0.10.1 to 0.11.0 - * accesskit_unix bumped from 0.6.2 to 0.7.0 diff --git a/bindings/python/Cargo.toml b/bindings/python/Cargo.toml deleted file mode 100644 index 2c4cd9ed..00000000 --- a/bindings/python/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -name = "accesskit_python" -version = "0.5.0" -authors.workspace = true -license.workspace = true -description = "Python bindings to the AccessKit library" -readme = "README.md" -publish = false -edition.workspace = true - -[lib] -name = "accesskit" -crate-type = ["cdylib"] -doc = false - -[features] -extension-module = ["pyo3/extension-module"] - -[dependencies] -accesskit = { version = "0.16.0", path = "../../common", features = ["pyo3"] } -pyo3 = { version = "0.20", features = ["abi3-py38", "multiple-pymethods"] } - -[target.'cfg(target_os = "windows")'.dependencies] -accesskit_windows = { version = "0.22.0", path = "../../platforms/windows" } - -[target.'cfg(target_os = "macos")'.dependencies] -accesskit_macos = { version = "0.17.0", path = "../../platforms/macos" } - -[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies] -accesskit_unix = { version = "0.12.0", path = "../../platforms/unix" } diff --git a/bindings/python/README.md b/bindings/python/README.md deleted file mode 100644 index ae8967fd..00000000 --- a/bindings/python/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# AccessKit - -These are the bindings to use AccessKit from Python. - -Documentation for the Rust packages can be found [here](https://docs.rs/accesskit/latest/accesskit/). - -An example program showing how to integrate AccessKit in a pygame application is available [here](https://github.com/AccessKit/accesskit/tree/main/bindings/python/examples/pygame). - -## Building from a Source Distribution - -If there are no wheels available for your platform, you will have to build one yourself. You will need to have Rust installed on your system, so that the native libraries can be compiled. Please visit [rustup.rs](https://rustup.rs) for instructions on how to proceed. - -## Building from within the repository - -This project uses [maturin](https://github.com/PyO3/maturin) as its build tool. If you need to manually build wheels for development purposes, it is recommended to install it inside a virtual environment. All maturin commands must be issued from this repository's root directory. diff --git a/bindings/python/examples/pygame/.gitignore b/bindings/python/examples/pygame/.gitignore deleted file mode 100644 index 68bc17f9..00000000 --- a/bindings/python/examples/pygame/.gitignore +++ /dev/null @@ -1,160 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ diff --git a/bindings/python/examples/pygame/README.md b/bindings/python/examples/pygame/README.md deleted file mode 100644 index 72583639..00000000 --- a/bindings/python/examples/pygame/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# pygame example - -This directory contains a cross-platform application that demonstrates how to integrate AccessKit with the pygame library. - -## Prerequisites - -- Python 3.8 or higher -- A virtual environment: `python -m venv .venv` (activating it will vary based on your platform) -- `pip install -r requirements.txt` - -## How to run - -```bash -python hello_world.py -``` diff --git a/bindings/python/examples/pygame/hello_world.py b/bindings/python/examples/pygame/hello_world.py deleted file mode 100644 index 3c9695db..00000000 --- a/bindings/python/examples/pygame/hello_world.py +++ /dev/null @@ -1,194 +0,0 @@ -import accesskit -import os -import platform -import pygame - -PLATFORM_SYSTEM = platform.system() - -WINDOW_TITLE = "Hello world" -WINDOW_WIDTH = 400 -WINDOW_HEIGHT = 200 - -WINDOW_ID = 0 -BUTTON_1_ID = 1 -BUTTON_2_ID = 2 -ANNOUNCEMENT_ID = 3 -INITIAL_FOCUS = BUTTON_1_ID - -BUTTON_1_RECT = accesskit.Rect(20.0, 20.0, 100.0, 60.0) - -BUTTON_2_RECT = accesskit.Rect(20.0, 60.0, 100.0, 100.0) - -ACCESSKIT_EVENT = pygame.event.custom_type() -SET_FOCUS_MSG = 0 -DO_DEFAULT_ACTION_MSG = 1 - - -def build_button(id, name): - builder = accesskit.NodeBuilder(accesskit.Role.BUTTON) - builder.set_bounds(BUTTON_1_RECT if id == BUTTON_1_ID else BUTTON_2_RECT) - builder.set_name(name) - builder.add_action(accesskit.Action.FOCUS) - builder.set_default_action_verb(accesskit.DefaultActionVerb.CLICK) - return builder.build() - - -def build_announcement(text): - builder = accesskit.NodeBuilder(accesskit.Role.LABEL) - builder.set_name(text) - builder.set_live(accesskit.Live.POLITE) - return builder.build() - - -class PygameAdapter: - def __init__(self, activation_handler, action_handler, deactivation_handler): - if PLATFORM_SYSTEM == "Darwin": - accesskit.macos.add_focus_forwarder_to_window_class("SDLWindow") - window = pygame.display.get_wm_info()["window"] - self.adapter = accesskit.macos.SubclassingAdapter.for_window( - window, activation_handler, action_handler - ) - elif os.name == "posix": - self.adapter = accesskit.unix.Adapter( - activation_handler, action_handler, deactivation_handler - ) - elif PLATFORM_SYSTEM == "Windows": - hwnd = pygame.display.get_wm_info()["window"] - self.adapter = accesskit.windows.SubclassingAdapter( - hwnd, activation_handler, action_handler - ) - - def update_if_active(self, update_factory): - events = self.adapter.update_if_active(update_factory) - if events is not None: - events.raise_events() - - def update_window_focus_state(self, is_focused): - if PLATFORM_SYSTEM == "Darwin": - events = self.adapter.update_view_focus_state(is_focused) - if events is not None: - events.raise_events() - elif os.name == "posix": - self.adapter.update_window_focus_state(is_focused) - - -class WindowState: - def __init__(self): - self.focus = INITIAL_FOCUS - self.announcement = None - - def build_root(self): - builder = accesskit.NodeBuilder(accesskit.Role.WINDOW) - builder.set_children([BUTTON_1_ID, BUTTON_2_ID]) - if self.announcement is not None: - builder.push_child(ANNOUNCEMENT_ID) - builder.set_name(WINDOW_TITLE) - return builder.build() - - def build_initial_tree(self): - root = self.build_root() - button_1 = build_button(BUTTON_1_ID, "Button 1") - button_2 = build_button(BUTTON_2_ID, "Button 2") - result = accesskit.TreeUpdate(self.focus) - tree = accesskit.Tree(WINDOW_ID) - tree.app_name = "Hello world" - result.tree = tree - result.nodes.append((WINDOW_ID, root)) - result.nodes.append((BUTTON_1_ID, button_1)) - result.nodes.append((BUTTON_2_ID, button_2)) - if self.announcement is not None: - result.nodes.append( - ( - ANNOUNCEMENT_ID, - build_announcement(self.announcement), - ) - ) - return result - - def press_button(self, adapter, id): - self.announcement = ( - "You pressed button 1" if id == BUTTON_1_ID else "You pressed button 2" - ) - adapter.update_if_active(self.build_tree_update_for_button_press) - - def build_tree_update_for_button_press(self): - update = accesskit.TreeUpdate(self.focus) - update.nodes.append((ANNOUNCEMENT_ID, build_announcement(self.announcement))) - update.nodes.append((WINDOW_ID, self.build_root())) - return update - - def set_focus(self, adapter, focus): - self.focus = focus - adapter.update_if_active(self.build_tree_update_for_focus_update) - - def build_tree_update_for_focus_update(self): - return accesskit.TreeUpdate(self.focus) - - def deactivate_accessibility(self): - # There's nothing in the state that depends on whether the adapter - # is active, so there's nothing to do here. - pass - - -def do_action(request): - if request.action in [accesskit.Action.DEFAULT, accesskit.Action.FOCUS]: - args = { - "event": SET_FOCUS_MSG - if request.action == accesskit.Action.FOCUS - else DO_DEFAULT_ACTION_MSG, - "target": request.target, - } - event = pygame.event.Event(ACCESSKIT_EVENT, args) - pygame.event.post(event) - - -def main(): - print("This example has no visible GUI, and a keyboard interface:") - print("- [Tab] switches focus between two logical buttons.") - print( - "- [Space] 'presses' the button, adding static text in a live region announcing that it was pressed." - ) - if PLATFORM_SYSTEM == "Windows": - print( - "Enable Narrator with [Win]+[Ctrl]+[Enter] (or [Win]+[Enter] on older versions of Windows)." - ) - elif os.name == "posix" and PLATFORM_SYSTEM != "Darwin": - print("Enable Orca with [Super]+[Alt]+[S].") - - state = WindowState() - pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT), pygame.HIDDEN) - pygame.display.set_caption(WINDOW_TITLE) - adapter = PygameAdapter( - state.build_initial_tree, do_action, state.deactivate_accessibility - ) - pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT), pygame.SHOWN) - is_running = True - while is_running: - for event in pygame.event.get(): - if event.type == pygame.QUIT: - is_running = False - elif event.type == pygame.WINDOWFOCUSGAINED: - adapter.update_window_focus_state(True) - elif event.type == pygame.WINDOWFOCUSLOST: - adapter.update_window_focus_state(False) - elif event.type == pygame.KEYDOWN: - if event.key == pygame.K_TAB: - new_focus = ( - BUTTON_2_ID if state.focus == BUTTON_1_ID else BUTTON_1_ID - ) - state.set_focus(adapter, new_focus) - elif event.key == pygame.K_SPACE: - state.press_button(adapter, state.focus) - elif event.type == ACCESSKIT_EVENT and event.__dict__["target"] in [ - BUTTON_1_ID, - BUTTON_2_ID, - ]: - target = event.__dict__["target"] - if event.__dict__["event"] == SET_FOCUS_MSG: - state.set_focus(adapter, target) - elif event.__dict__["event"] == DO_DEFAULT_ACTION_MSG: - state.press_button(adapter, target) - - -if __name__ == "__main__": - main() diff --git a/bindings/python/examples/pygame/requirements.txt b/bindings/python/examples/pygame/requirements.txt deleted file mode 100644 index c2e97053..00000000 --- a/bindings/python/examples/pygame/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -accesskit -pygame==2.5.0 diff --git a/bindings/python/src/common.rs b/bindings/python/src/common.rs deleted file mode 100644 index dfe6af13..00000000 --- a/bindings/python/src/common.rs +++ /dev/null @@ -1,770 +0,0 @@ -// Copyright 2023 The AccessKit Authors. All rights reserved. -// Licensed under the Apache License, Version 2.0 (found in -// the LICENSE-APACHE file) or the MIT license (found in -// the LICENSE-MIT file), at your option. - -use crate::{Point, Rect}; -use pyo3::{prelude::*, types::PyList}; - -#[derive(Clone)] -#[pyclass(module = "accesskit")] -pub struct Node(accesskit::Node); - -impl Node { - #[inline] - fn inner(&self) -> &accesskit::Node { - &self.0 - } -} - -impl From for accesskit::Node { - fn from(node: Node) -> accesskit::Node { - node.0 - } -} - -#[pymethods] -impl Node { - #[getter] - pub fn role(&self) -> accesskit::Role { - self.inner().role() - } - - pub fn supports_action(&self, action: accesskit::Action) -> bool { - self.inner().supports_action(action) - } -} - -#[pyclass(module = "accesskit")] -pub struct NodeBuilder(Option); - -impl NodeBuilder { - #[inline] - fn inner(&self) -> &accesskit::NodeBuilder { - self.0.as_ref().unwrap() - } - - #[inline] - fn inner_mut(&mut self) -> &mut accesskit::NodeBuilder { - self.0.as_mut().unwrap() - } -} - -#[pymethods] -impl NodeBuilder { - #[new] - pub fn new(role: accesskit::Role) -> NodeBuilder { - Self(Some(accesskit::NodeBuilder::new(role))) - } - - pub fn build(&mut self) -> Node { - let builder = self.0.take().unwrap(); - Node(builder.build()) - } - - #[getter] - pub fn role(&self) -> accesskit::Role { - self.inner().role() - } - - pub fn set_role(&mut self, value: accesskit::Role) { - self.inner_mut().set_role(value); - } - - pub fn supports_action(&self, action: accesskit::Action) -> bool { - self.inner().supports_action(action) - } - - pub fn add_action(&mut self, action: accesskit::Action) { - self.inner_mut().add_action(action) - } - - pub fn remove_action(&mut self, action: accesskit::Action) { - self.inner_mut().remove_action(action) - } - - pub fn clear_actions(&mut self) { - self.inner_mut().clear_actions() - } -} - -pub type NodeId = u64; - -#[derive(Clone)] -#[pyclass(module = "accesskit")] -pub struct CustomAction(accesskit::CustomAction); - -#[pymethods] -impl CustomAction { - #[new] - pub fn new(id: i32, description: &str) -> Self { - Self(accesskit::CustomAction { - id, - description: description.into(), - }) - } - - #[getter] - pub fn id(&self) -> i32 { - self.0.id - } - - #[setter] - pub fn set_id(&mut self, id: i32) { - self.0.id = id; - } - - #[getter] - pub fn description(&self) -> &str { - &self.0.description - } - - #[setter] - pub fn set_description(&mut self, description: &str) { - self.0.description = description.into() - } -} - -impl From for accesskit::CustomAction { - fn from(action: CustomAction) -> Self { - action.0 - } -} - -impl From for CustomAction { - fn from(action: accesskit::CustomAction) -> Self { - Self(action) - } -} - -#[derive(Clone)] -#[pyclass(module = "accesskit")] -pub struct TextPosition(accesskit::TextPosition); - -#[pymethods] -impl TextPosition { - #[new] - pub fn new(node: NodeId, character_index: usize) -> Self { - Self(accesskit::TextPosition { - node: node.into(), - character_index, - }) - } - - #[getter] - pub fn node(&self) -> NodeId { - self.0.node.into() - } - - #[setter] - pub fn set_node(&mut self, node: NodeId) { - self.0.node = node.into(); - } - - #[getter] - pub fn character_index(&self) -> usize { - self.0.character_index - } - - #[setter] - pub fn set_character_index(&mut self, character_index: usize) { - self.0.character_index = character_index; - } -} - -impl From for TextPosition { - fn from(position: accesskit::TextPosition) -> Self { - Self(position) - } -} - -#[derive(Clone)] -#[pyclass(get_all, set_all, module = "accesskit")] -pub struct TextSelection { - pub anchor: Py, - pub focus: Py, -} - -#[pymethods] -impl TextSelection { - #[new] - pub fn new(anchor: Py, focus: Py) -> Self { - Self { anchor, focus } - } -} - -impl From<&accesskit::TextSelection> for TextSelection { - fn from(selection: &accesskit::TextSelection) -> Self { - Python::with_gil(|py| Self { - anchor: Py::new(py, TextPosition::from(selection.anchor)).unwrap(), - focus: Py::new(py, TextPosition::from(selection.focus)).unwrap(), - }) - } -} - -impl From for accesskit::TextSelection { - fn from(selection: TextSelection) -> Self { - Python::with_gil(|py| accesskit::TextSelection { - anchor: selection.anchor.as_ref(py).borrow().0, - focus: selection.focus.as_ref(py).borrow().0, - }) - } -} - -impl From for Box { - fn from(selection: TextSelection) -> Self { - Box::new(selection.into()) - } -} - -macro_rules! clearer { - ($clearer:ident) => { - #[pymethods] - impl NodeBuilder { - pub fn $clearer(&mut self) { - self.inner_mut().$clearer() - } - } - }; -} - -macro_rules! getters { - ($getter:ident, $macro_name:ident, $type:ty) => { - $macro_name! { Node, $getter, $type } - $macro_name! { NodeBuilder, $getter, $type } - }; -} - -macro_rules! simple_getter { - ($struct_name:ident, $getter:ident, $type:ty) => { - #[pymethods] - impl $struct_name { - #[getter] - pub fn $getter(&self) -> $type { - self.inner().$getter() - } - } - }; -} - -macro_rules! converting_getter { - ($struct_name:ident, $getter:ident, $type:ty) => { - #[pymethods] - impl $struct_name { - #[getter] - pub fn $getter(&self) -> $type { - self.inner().$getter().into() - } - } - }; -} - -macro_rules! option_getter { - ($struct_name:ident, $getter:ident, $type:ty) => { - #[pymethods] - impl $struct_name { - #[getter] - pub fn $getter(&self) -> $type { - self.inner().$getter().map(Into::into) - } - } - }; -} - -macro_rules! simple_setter { - ($setter:ident, $setter_param:ty) => { - #[pymethods] - impl NodeBuilder { - pub fn $setter(&mut self, value: $setter_param) { - self.inner_mut().$setter(value); - } - } - }; -} - -macro_rules! converting_setter { - ($setter:ident, $setter_param:ty) => { - #[pymethods] - impl NodeBuilder { - pub fn $setter(&mut self, value: $setter_param) { - self.inner_mut().$setter(value.into()); - } - } - }; -} - -macro_rules! flag_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - $(getters! { $getter, simple_getter, bool } - #[pymethods] - impl NodeBuilder { - pub fn $setter(&mut self) { - self.inner_mut().$setter(); - } - } - clearer! { $clearer })* - } -} - -macro_rules! property_methods { - ( - $(($getter:ident, $getter_macro:ident, $getter_result:ty, $setter:ident, $setter_macro:ident, $setter_param:ty, $clearer:ident)),+ - ) => { - $(getters! { $getter, $getter_macro, $getter_result } - $setter_macro! { $setter, $setter_param } - clearer! { $clearer })* - } -} - -macro_rules! vec_property_methods { - ($(($py_item_type:ty, $accesskit_item_type:ty, $getter:ident, $setter:ident, $pusher:ident, $clearer:ident)),+) => { - #[pymethods] - impl Node { - $(#[getter] - pub fn $getter(&self, py: Python) -> Py { - let values = self.inner().$getter().iter().cloned().map(<$py_item_type>::from).map(|i| i.into_py(py)); - PyList::new(py, values).into() - })* - } - $(#[pymethods] - impl NodeBuilder { - #[getter] - pub fn $getter(&self, py: Python) -> Py { - let values = self.inner().$getter().iter().cloned().map(<$py_item_type>::from).map(|i| i.into_py(py)); - PyList::new(py, values).into() - } - pub fn $setter(&mut self, values: &PyList) { - let values = values - .iter() - .map(PyAny::extract::<$py_item_type>) - .filter_map(PyResult::ok) - .map(<$accesskit_item_type>::from) - .collect::>(); - self.inner_mut().$setter(values); - } - pub fn $pusher(&mut self, item: $py_item_type) { - self.inner_mut().$pusher(item.into()); - } - } - clearer! { $clearer })* - } -} - -macro_rules! string_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - $(property_methods! { - ($getter, option_getter, Option<&str>, $setter, simple_setter, String, $clearer) - })* - } -} - -macro_rules! node_id_vec_property_methods { - ($(($getter:ident, $setter:ident, $pusher:ident, $clearer:ident)),+) => { - $(vec_property_methods! { - (NodeId, accesskit::NodeId, $getter, $setter, $pusher, $clearer) - })* - } -} - -macro_rules! node_id_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - $(property_methods! { - ($getter, option_getter, Option, $setter, converting_setter, NodeId, $clearer) - })* - } -} - -macro_rules! f64_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - $(property_methods! { - ($getter, option_getter, Option, $setter, simple_setter, f64, $clearer) - })* - } -} - -macro_rules! usize_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - $(property_methods! { - ($getter, option_getter, Option, $setter, simple_setter, usize, $clearer) - })* - } -} - -macro_rules! color_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - $(property_methods! { - ($getter, option_getter, Option, $setter, simple_setter, u32, $clearer) - })* - } -} - -macro_rules! text_decoration_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - $(property_methods! { - ($getter, option_getter, Option, $setter, converting_setter, accesskit::TextDecoration, $clearer) - })* - } -} - -macro_rules! length_slice_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - $(property_methods! { - ($getter, converting_getter, Vec, $setter, simple_setter, Vec, $clearer) - })* - } -} - -macro_rules! coord_slice_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - $(property_methods! { - ($getter, option_getter, Option>, $setter, simple_setter, Vec, $clearer) - })* - } -} - -macro_rules! bool_property_methods { - ($(($getter:ident, $setter:ident, $clearer:ident)),+) => { - $(property_methods! { - ($getter, option_getter, Option, $setter, simple_setter, bool, $clearer) - })* - } -} - -macro_rules! unique_enum_property_methods { - ($(($type:ty, $getter:ident, $setter:ident, $clearer:ident)),+) => { - $(property_methods! { - ($getter, option_getter, Option<$type>, $setter, simple_setter, $type, $clearer) - })* - } -} - -flag_methods! { - (is_hovered, set_hovered, clear_hovered), - (is_hidden, set_hidden, clear_hidden), - (is_linked, set_linked, clear_linked), - (is_multiselectable, set_multiselectable, clear_multiselectable), - (is_required, set_required, clear_required), - (is_visited, set_visited, clear_visited), - (is_busy, set_busy, clear_busy), - (is_live_atomic, set_live_atomic, clear_live_atomic), - (is_modal, set_modal, clear_modal), - (is_touch_transparent, set_touch_transparent, clear_touch_transparent), - (is_read_only, set_read_only, clear_read_only), - (is_disabled, set_disabled, clear_disabled), - (is_bold, set_bold, clear_bold), - (is_italic, set_italic, clear_italic), - (clips_children, set_clips_children, clear_clips_children), - (is_line_breaking_object, set_is_line_breaking_object, clear_is_line_breaking_object), - (is_page_breaking_object, set_is_page_breaking_object, clear_is_page_breaking_object), - (is_spelling_error, set_is_spelling_error, clear_is_spelling_error), - (is_grammar_error, set_is_grammar_error, clear_is_grammar_error), - (is_search_match, set_is_search_match, clear_is_search_match), - (is_suggestion, set_is_suggestion, clear_is_suggestion) -} - -node_id_vec_property_methods! { - (children, set_children, push_child, clear_children), - (controls, set_controls, push_controlled, clear_controls), - (details, set_details, push_detail, clear_details), - (described_by, set_described_by, push_described_by, clear_described_by), - (flow_to, set_flow_to, push_flow_to, clear_flow_to), - (labelled_by, set_labelled_by, push_labelled_by, clear_labelled_by), - (owns, set_owns, push_owned, clear_owns), - (radio_group, set_radio_group, push_to_radio_group, clear_radio_group) -} - -node_id_property_methods! { - (active_descendant, set_active_descendant, clear_active_descendant), - (error_message, set_error_message, clear_error_message), - (in_page_link_target, set_in_page_link_target, clear_in_page_link_target), - (member_of, set_member_of, clear_member_of), - (next_on_line, set_next_on_line, clear_next_on_line), - (previous_on_line, set_previous_on_line, clear_previous_on_line), - (popup_for, set_popup_for, clear_popup_for) -} - -string_property_methods! { - (name, set_name, clear_name), - (description, set_description, clear_description), - (value, set_value, clear_value), - (access_key, set_access_key, clear_access_key), - (author_id, set_author_id, clear_author_id), - (class_name, set_class_name, clear_class_name), - (font_family, set_font_family, clear_font_family), - (html_tag, set_html_tag, clear_html_tag), - (inner_html, set_inner_html, clear_inner_html), - (keyboard_shortcut, set_keyboard_shortcut, clear_keyboard_shortcut), - (language, set_language, clear_language), - (placeholder, set_placeholder, clear_placeholder), - (role_description, set_role_description, clear_role_description), - (state_description, set_state_description, clear_state_description), - (tooltip, set_tooltip, clear_tooltip), - (url, set_url, clear_url), - (row_index_text, set_row_index_text, clear_row_index_text), - (column_index_text, set_column_index_text, clear_column_index_text) -} - -f64_property_methods! { - (scroll_x, set_scroll_x, clear_scroll_x), - (scroll_x_min, set_scroll_x_min, clear_scroll_x_min), - (scroll_x_max, set_scroll_x_max, clear_scroll_x_max), - (scroll_y, set_scroll_y, clear_scroll_y), - (scroll_y_min, set_scroll_y_min, clear_scroll_y_min), - (scroll_y_max, set_scroll_y_max, clear_scroll_y_max), - (numeric_value, set_numeric_value, clear_numeric_value), - (min_numeric_value, set_min_numeric_value, clear_min_numeric_value), - (max_numeric_value, set_max_numeric_value, clear_max_numeric_value), - (numeric_value_step, set_numeric_value_step, clear_numeric_value_step), - (numeric_value_jump, set_numeric_value_jump, clear_numeric_value_jump), - (font_size, set_font_size, clear_font_size), - (font_weight, set_font_weight, clear_font_weight) -} - -usize_property_methods! { - (row_count, set_row_count, clear_row_count), - (column_count, set_column_count, clear_column_count), - (row_index, set_row_index, clear_row_index), - (column_index, set_column_index, clear_column_index), - (row_span, set_row_span, clear_row_span), - (column_span, set_column_span, clear_column_span), - (level, set_level, clear_level), - (size_of_set, set_size_of_set, clear_size_of_set), - (position_in_set, set_position_in_set, clear_position_in_set) -} - -color_property_methods! { - (color_value, set_color_value, clear_color_value), - (background_color, set_background_color, clear_background_color), - (foreground_color, set_foreground_color, clear_foreground_color) -} - -text_decoration_property_methods! { - (overline, set_overline, clear_overline), - (strikethrough, set_strikethrough, clear_strikethrough), - (underline, set_underline, clear_underline) -} - -length_slice_property_methods! { - (character_lengths, set_character_lengths, clear_character_lengths), - (word_lengths, set_word_lengths, clear_word_lengths) -} - -coord_slice_property_methods! { - (character_positions, set_character_positions, clear_character_positions), - (character_widths, set_character_widths, clear_character_widths) -} - -bool_property_methods! { - (is_expanded, set_expanded, clear_expanded), - (is_selected, set_selected, clear_selected) -} - -unique_enum_property_methods! { - (accesskit::Invalid, invalid, set_invalid, clear_invalid), - (accesskit::Toggled, toggled, set_toggled, clear_toggled), - (accesskit::Live, live, set_live, clear_live), - (accesskit::DefaultActionVerb, default_action_verb, set_default_action_verb, clear_default_action_verb), - (accesskit::TextDirection, text_direction, set_text_direction, clear_text_direction), - (accesskit::Orientation, orientation, set_orientation, clear_orientation), - (accesskit::SortDirection, sort_direction, set_sort_direction, clear_sort_direction), - (accesskit::AriaCurrent, aria_current, set_aria_current, clear_aria_current), - (accesskit::AutoComplete, auto_complete, set_auto_complete, clear_auto_complete), - (accesskit::HasPopup, has_popup, set_has_popup, clear_has_popup), - (accesskit::ListStyle, list_style, set_list_style, clear_list_style), - (accesskit::TextAlign, text_align, set_text_align, clear_text_align), - (accesskit::VerticalOffset, vertical_offset, set_vertical_offset, clear_vertical_offset) -} - -property_methods! { - (transform, option_getter, Option, set_transform, simple_setter, crate::Affine, clear_transform), - (bounds, option_getter, Option, set_bounds, converting_setter, crate::Rect, clear_bounds), - (text_selection, option_getter, Option, set_text_selection, simple_setter, TextSelection, clear_text_selection) -} - -vec_property_methods! { - (CustomAction, accesskit::CustomAction, custom_actions, set_custom_actions, push_custom_action, clear_custom_actions) -} - -#[derive(Clone)] -#[pyclass(module = "accesskit", get_all, set_all)] -pub struct Tree { - pub root: NodeId, - pub app_name: Option, - pub toolkit_name: Option, - pub toolkit_version: Option, -} - -#[pymethods] -impl Tree { - #[new] - pub fn new(root: NodeId) -> Self { - Self { - root, - app_name: None, - toolkit_name: None, - toolkit_version: None, - } - } -} - -impl From for accesskit::Tree { - fn from(tree: Tree) -> Self { - Self { - root: tree.root.into(), - app_name: tree.app_name, - toolkit_name: tree.toolkit_name, - toolkit_version: tree.toolkit_version, - } - } -} - -#[derive(Clone)] -#[pyclass(module = "accesskit", get_all, set_all)] -pub struct TreeUpdate { - pub nodes: Py, - pub tree: Option>, - pub focus: NodeId, -} - -#[pymethods] -impl TreeUpdate { - #[new] - pub fn new(py: Python<'_>, focus: NodeId) -> Self { - Self { - nodes: PyList::empty(py).into(), - tree: None, - focus, - } - } -} - -impl From for accesskit::TreeUpdate { - fn from(update: TreeUpdate) -> Self { - Python::with_gil(|py| Self { - nodes: update - .nodes - .as_ref(py) - .iter() - .map(PyAny::extract::<(NodeId, Node)>) - .filter_map(Result::ok) - .map(|(id, node)| (id.into(), node.into())) - .collect(), - tree: update.tree.map(|tree| { - let tree = tree.as_ref(py).borrow(); - accesskit::Tree { - root: tree.root.into(), - app_name: tree.app_name.clone(), - toolkit_name: tree.toolkit_name.clone(), - toolkit_version: tree.toolkit_version.clone(), - } - }), - focus: update.focus.into(), - }) - } -} - -#[derive(Clone)] -#[pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE")] -pub enum ActionDataKind { - CustomAction, - Value, - NumericValue, - ScrollTargetRect, - ScrollToPoint, - SetScrollOffset, - SetTextSelection, -} - -#[pyclass(get_all, module = "accesskit")] -pub struct ActionRequest { - pub action: accesskit::Action, - pub target: NodeId, - pub data: Option<(ActionDataKind, Py)>, -} - -impl From for ActionRequest { - fn from(request: accesskit::ActionRequest) -> Self { - Python::with_gil(|py| Self { - action: request.action, - target: request.target.into(), - data: request.data.map(|data| match data { - accesskit::ActionData::CustomAction(action) => { - (ActionDataKind::CustomAction, action.into_py(py)) - } - accesskit::ActionData::Value(value) => (ActionDataKind::Value, value.into_py(py)), - accesskit::ActionData::NumericValue(value) => { - (ActionDataKind::NumericValue, value.into_py(py)) - } - accesskit::ActionData::ScrollTargetRect(rect) => ( - ActionDataKind::ScrollTargetRect, - Rect::from(rect).into_py(py), - ), - accesskit::ActionData::ScrollToPoint(point) => ( - ActionDataKind::ScrollToPoint, - Point::from(point).into_py(py), - ), - accesskit::ActionData::SetScrollOffset(point) => ( - ActionDataKind::SetScrollOffset, - Point::from(point).into_py(py), - ), - accesskit::ActionData::SetTextSelection(selection) => ( - ActionDataKind::SetTextSelection, - TextSelection::from(&selection).into_py(py), - ), - }), - }) - } -} - -// The following exception is needed because this struct is only used -// in the bindings for some platform adapters. -#[allow(dead_code)] -pub(crate) struct LocalPythonActivationHandler<'a> { - pub(crate) py: Python<'a>, - pub(crate) handler: Py, -} - -impl accesskit::ActivationHandler for LocalPythonActivationHandler<'_> { - fn request_initial_tree(&mut self) -> Option { - let result = self.handler.call0(self.py).unwrap(); - result - .extract::>(self.py) - .unwrap() - .map(Into::into) - } -} - -pub struct PythonActivationHandler(pub(crate) Py); - -impl accesskit::ActivationHandler for PythonActivationHandler { - fn request_initial_tree(&mut self) -> Option { - Python::with_gil(|py| { - let result = self.0.call0(py).unwrap(); - result - .extract::>(py) - .unwrap() - .map(Into::into) - }) - } -} - -pub struct PythonActionHandler(pub(crate) Py); - -impl accesskit::ActionHandler for PythonActionHandler { - fn do_action(&mut self, request: accesskit::ActionRequest) { - let request = ActionRequest::from(request); - Python::with_gil(|py| { - self.0.call(py, (request,), None).unwrap(); - }); - } -} - -pub struct PythonDeactivationHandler(pub(crate) Py); - -impl accesskit::DeactivationHandler for PythonDeactivationHandler { - fn deactivate_accessibility(&mut self) { - Python::with_gil(|py| { - self.0.call(py, (), None).unwrap(); - }); - } -} diff --git a/bindings/python/src/geometry.rs b/bindings/python/src/geometry.rs deleted file mode 100644 index 4df784a0..00000000 --- a/bindings/python/src/geometry.rs +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright 2023 The AccessKit Authors. All rights reserved. -// Licensed under the Apache License, Version 2.0 (found in -// the LICENSE-APACHE file) or the MIT license (found in -// the LICENSE-MIT file), at your option. - -use pyo3::prelude::*; - -#[derive(Clone)] -#[pyclass(module = "accesskit")] -pub struct Affine(accesskit::Affine); - -#[pymethods] -impl Affine { - #[new] - pub fn new(c: [f64; 6]) -> Affine { - accesskit::Affine::new(c).into() - } - - #[getter] - pub fn coeffs(&self) -> [f64; 6] { - self.0.as_coeffs() - } -} - -impl From for Box { - fn from(value: Affine) -> Self { - Box::new(value.0) - } -} - -impl From for Affine { - fn from(value: accesskit::Affine) -> Self { - Self(value) - } -} - -impl From<&accesskit::Affine> for Affine { - fn from(value: &accesskit::Affine) -> Self { - Self(*value) - } -} - -#[derive(Clone)] -#[pyclass(module = "accesskit")] -pub struct Point(accesskit::Point); - -#[pymethods] -impl Point { - #[new] - pub fn new(x: f64, y: f64) -> Self { - accesskit::Point::new(x, y).into() - } - - #[getter] - pub fn get_x(&self) -> f64 { - self.0.x - } - - #[setter] - pub fn set_x(&mut self, value: f64) { - self.0.x = value - } - - #[getter] - pub fn get_y(&self) -> f64 { - self.0.y - } - - #[setter] - pub fn set_y(&mut self, value: f64) { - self.0.y = value - } -} - -impl From for accesskit::Point { - fn from(value: Point) -> Self { - value.0 - } -} - -impl From for Point { - fn from(value: accesskit::Point) -> Self { - Self(value) - } -} - -#[derive(Clone)] -#[pyclass(module = "accesskit")] -pub struct Rect(accesskit::Rect); - -#[pymethods] -impl Rect { - #[new] - pub fn new(x0: f64, y0: f64, x1: f64, y1: f64) -> Rect { - accesskit::Rect::new(x0, y0, x1, y1).into() - } - - #[staticmethod] - pub fn from_points(p0: Point, p1: Point) -> Self { - let p0 = accesskit::Point::from(p0); - let p1 = accesskit::Point::from(p1); - accesskit::Rect::from_points(p0, p1).into() - } - - #[staticmethod] - pub fn from_origin_size(origin: Point, size: Size) -> Self { - let origin = accesskit::Point::from(origin); - let size = accesskit::Size::from(size); - accesskit::Rect::from_origin_size(origin, size).into() - } - - #[getter] - pub fn get_x0(&self) -> f64 { - self.0.x0 - } - - #[setter] - pub fn set_x0(&mut self, value: f64) { - self.0.x0 = value - } - - #[getter] - pub fn get_y0(&self) -> f64 { - self.0.y0 - } - - #[setter] - pub fn set_y0(&mut self, value: f64) { - self.0.y0 = value - } - - #[getter] - pub fn get_x1(&self) -> f64 { - self.0.x1 - } - - #[setter] - pub fn set_x1(&mut self, value: f64) { - self.0.x1 = value - } - - #[getter] - pub fn get_y1(&self) -> f64 { - self.0.y1 - } - - #[setter] - pub fn set_y1(&mut self, value: f64) { - self.0.y1 = value - } -} - -impl From for accesskit::Rect { - fn from(value: Rect) -> Self { - value.0 - } -} - -impl From for Rect { - fn from(value: accesskit::Rect) -> Self { - Self(value) - } -} - -#[derive(Clone)] -#[pyclass(module = "accesskit")] -pub struct Size(accesskit::Size); - -#[pymethods] -impl Size { - #[new] - pub fn new(width: f64, height: f64) -> Self { - accesskit::Size::new(width, height).into() - } - - #[getter] - pub fn get_width(&self) -> f64 { - self.0.width - } - - #[setter] - pub fn set_width(&mut self, value: f64) { - self.0.width = value - } - - #[getter] - pub fn get_height(&self) -> f64 { - self.0.height - } - - #[setter] - pub fn set_height(&mut self, value: f64) { - self.0.height = value - } -} - -impl From for accesskit::Size { - fn from(value: Size) -> Self { - value.0 - } -} - -impl From for Size { - fn from(value: accesskit::Size) -> Self { - Self(value) - } -} - -#[derive(Clone)] -#[pyclass(module = "accesskit")] -pub struct Vec2(accesskit::Vec2); - -#[pymethods] -impl Vec2 { - #[new] - pub fn new(x: f64, y: f64) -> Vec2 { - accesskit::Vec2::new(x, y).into() - } - - #[getter] - pub fn get_x(&self) -> f64 { - self.0.x - } - - #[setter] - pub fn set_x(&mut self, value: f64) { - self.0.x = value - } - - #[getter] - pub fn get_y(&self) -> f64 { - self.0.y - } - - #[setter] - pub fn set_y(&mut self, value: f64) { - self.0.y = value - } -} - -impl From for accesskit::Vec2 { - fn from(value: Vec2) -> Self { - value.0 - } -} - -impl From for Vec2 { - fn from(value: accesskit::Vec2) -> Self { - Self(value) - } -} diff --git a/bindings/python/src/lib.rs b/bindings/python/src/lib.rs deleted file mode 100644 index 26b872ba..00000000 --- a/bindings/python/src/lib.rs +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2023 The AccessKit Authors. All rights reserved. -// Licensed under the Apache License, Version 2.0 (found in -// the LICENSE-APACHE file) or the MIT license (found in -// the LICENSE-MIT file), at your option. - -mod common; -mod geometry; - -#[cfg(target_os = "macos")] -mod macos; -#[cfg(any( - target_os = "linux", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd", -))] -mod unix; -#[cfg(target_os = "windows")] -mod windows; - -pub use common::*; -pub use geometry::*; - -use pyo3::prelude::*; - -#[pymodule] -fn accesskit(py: Python<'_>, m: &PyModule) -> PyResult<()> { - m.add_class::<::accesskit::Role>()?; - m.add_class::<::accesskit::Action>()?; - m.add_class::<::accesskit::Orientation>()?; - m.add_class::<::accesskit::TextDirection>()?; - m.add_class::<::accesskit::Invalid>()?; - m.add_class::<::accesskit::Toggled>()?; - m.add_class::<::accesskit::DefaultActionVerb>()?; - m.add_class::<::accesskit::SortDirection>()?; - m.add_class::<::accesskit::AriaCurrent>()?; - m.add_class::<::accesskit::Live>()?; - m.add_class::<::accesskit::HasPopup>()?; - m.add_class::<::accesskit::ListStyle>()?; - m.add_class::<::accesskit::TextAlign>()?; - m.add_class::<::accesskit::VerticalOffset>()?; - m.add_class::<::accesskit::TextDecoration>()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - - #[cfg(target_os = "macos")] - { - let macos_module = PyModule::new(py, "macos")?; - macos_module.add_class::()?; - macos_module.add_class::()?; - macos_module.add_class::()?; - macos_module.add_function(wrap_pyfunction!( - macos::add_focus_forwarder_to_window_class, - macos_module - )?)?; - m.add_submodule(macos_module)?; - } - #[cfg(any( - target_os = "linux", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd", - ))] - { - let unix_module = PyModule::new(py, "unix")?; - unix_module.add_class::()?; - m.add_submodule(unix_module)?; - } - #[cfg(target_os = "windows")] - { - let windows_module = PyModule::new(py, "windows")?; - windows_module.add_class::()?; - windows_module.add_class::()?; - windows_module.add_class::()?; - m.add_submodule(windows_module)?; - } - - Ok(()) -} diff --git a/bindings/python/src/macos.rs b/bindings/python/src/macos.rs deleted file mode 100644 index ca8933f9..00000000 --- a/bindings/python/src/macos.rs +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright 2023 The AccessKit Authors. All rights reserved. -// Licensed under the Apache License, Version 2.0 (found in -// the LICENSE-APACHE file) or the MIT license (found in -// the LICENSE-MIT file), at your option. - -use crate::{ - LocalPythonActivationHandler, PythonActionHandler, PythonActivationHandler, TreeUpdate, -}; -use accesskit_macos::NSPoint; -use pyo3::{prelude::*, types::PyCapsule}; -use std::ffi::c_void; - -/// This class must only be used from the main thread. -#[pyclass(module = "accesskit.macos", unsendable)] -pub struct QueuedEvents(Option); - -#[pymethods] -impl QueuedEvents { - pub fn raise_events(&mut self) { - let events = self.0.take().unwrap(); - events.raise(); - } -} - -impl From for QueuedEvents { - fn from(events: accesskit_macos::QueuedEvents) -> Self { - Self(Some(events)) - } -} - -/// This class must only be used from the main thread. -#[pyclass(module = "accesskit.macos", unsendable)] -pub struct Adapter(accesskit_macos::Adapter); - -#[pymethods] -impl Adapter { - /// Create a new macOS adapter. - /// - /// The action handler will always be called on the main thread. - /// - /// # Safety - /// - /// `view` must be a valid, unreleased pointer to an `NSView`. - #[new] - pub unsafe fn new(view: &PyAny, is_view_focused: bool, action_handler: Py) -> Self { - Self(accesskit_macos::Adapter::new( - to_void_ptr(view), - is_view_focused, - PythonActionHandler(action_handler), - )) - } - - /// You must call `accesskit.macos.QueuedEvents.raise_events` on the returned value. It can be `None` if the window is not active. - pub fn update_if_active( - &mut self, - py: Python<'_>, - update_factory: Py, - ) -> Option { - self.0 - .update_if_active(|| { - let update = update_factory.call0(py).unwrap(); - update.extract::(py).unwrap().into() - }) - .map(Into::into) - } - - /// You must call `accesskit.macos.QueuedEvents.raise_events` on the returned value. It can be `None` if the window is not active. - pub fn update_view_focus_state(&mut self, is_focused: bool) -> Option { - self.0.update_view_focus_state(is_focused).map(Into::into) - } - - pub fn view_children( - &mut self, - py: Python<'_>, - activation_handler: Py, - ) -> PyResult> { - let mut activation_handler = LocalPythonActivationHandler { - py, - handler: activation_handler, - }; - let ptr: isize = self.0.view_children(&mut activation_handler) as _; - Ok(PyCapsule::new(py, ptr, None)?.into()) - } - - pub fn focus( - &mut self, - py: Python<'_>, - activation_handler: Py, - ) -> PyResult> { - let mut activation_handler = LocalPythonActivationHandler { - py, - handler: activation_handler, - }; - let ptr: isize = self.0.focus(&mut activation_handler) as _; - Ok(PyCapsule::new(py, ptr, None)?.into()) - } - - pub fn hit_test( - &mut self, - py: Python<'_>, - x: f64, - y: f64, - activation_handler: Py, - ) -> PyResult> { - let mut activation_handler = LocalPythonActivationHandler { - py, - handler: activation_handler, - }; - let ptr: isize = self.0.hit_test(NSPoint::new(x, y), &mut activation_handler) as _; - Ok(PyCapsule::new(py, ptr, None)?.into()) - } -} - -/// This class must only be used from the main thread. -#[pyclass(module = "accesskit.macos", unsendable)] -pub struct SubclassingAdapter(accesskit_macos::SubclassingAdapter); - -#[pymethods] -impl SubclassingAdapter { - /// Create an adapter that dynamically subclasses the specified view. - /// This must be done before the view is shown or focused for - /// the first time. - /// - /// The action handler will always be called on the main thread. - /// - /// # Safety - /// - /// `view` must be a valid, unreleased pointer to an `NSView`. - #[new] - pub unsafe fn new( - view: &PyAny, - activation_handler: Py, - action_handler: Py, - ) -> Self { - Self(accesskit_macos::SubclassingAdapter::new( - to_void_ptr(view), - PythonActivationHandler(activation_handler), - PythonActionHandler(action_handler), - )) - } - - /// Create an adapter that dynamically subclasses the content view - /// of the specified window. - /// - /// The action handler will always be called on the main thread. - /// - /// # Safety - /// - /// `window` must be a valid, unreleased pointer to an `NSWindow`. - /// - /// # Panics - /// - /// This function panics if the specified window doesn't currently have - /// a content view. - #[staticmethod] - pub unsafe fn for_window( - window: &PyAny, - activation_handler: Py, - action_handler: Py, - ) -> Self { - Self(accesskit_macos::SubclassingAdapter::for_window( - to_void_ptr(window), - PythonActivationHandler(activation_handler), - PythonActionHandler(action_handler), - )) - } - - /// You must call `accesskit.macos.QueuedEvents.raise_events` on the returned value. It can be `None` if the window is not active. - pub fn update_if_active( - &mut self, - py: Python<'_>, - update_factory: Py, - ) -> Option { - self.0 - .update_if_active(|| { - let update = update_factory.call0(py).unwrap(); - update.extract::(py).unwrap().into() - }) - .map(Into::into) - } - - /// You must call `accesskit.macos.QueuedEvents.raise_events` on the returned value. It can be `None` if the window is not active. - pub fn update_view_focus_state(&mut self, is_focused: bool) -> Option { - self.0.update_view_focus_state(is_focused).map(Into::into) - } -} - -/// Modifies the specified class, which must be a subclass of `NSWindow`, -/// to include an `accessibilityFocusedUIElement` method that calls -/// the corresponding method on the window's content view. This is needed -/// for windowing libraries such as SDL that place the keyboard focus -/// directly on the window rather than the content view. -/// -/// # Safety -/// -/// This function is declared unsafe because the caller must ensure that the -/// code for this library is never unloaded from the application process, -/// since it's not possible to reverse this operation. It's safest -/// if this library is statically linked into the application's main executable. -/// Also, this function assumes that the specified class is a subclass -/// of `NSWindow`. -#[pyfunction] -pub unsafe fn add_focus_forwarder_to_window_class(class_name: &str) { - accesskit_macos::add_focus_forwarder_to_window_class(class_name) -} - -fn to_void_ptr(value: &PyAny) -> *mut c_void { - if let Ok(value) = value.extract::<&PyCapsule>() { - return value.pointer(); - } - let value = value.getattr("value").unwrap_or(value); - value.extract::().unwrap() as *mut _ -} diff --git a/bindings/python/src/unix.rs b/bindings/python/src/unix.rs deleted file mode 100644 index c0f92374..00000000 --- a/bindings/python/src/unix.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2023 The AccessKit Authors. All rights reserved. -// Licensed under the Apache License, Version 2.0 (found in -// the LICENSE-APACHE file) or the MIT license (found in -// the LICENSE-MIT file), at your option. - -use crate::{ - PythonActionHandler, PythonActivationHandler, PythonDeactivationHandler, Rect, TreeUpdate, -}; -use pyo3::prelude::*; - -#[pyclass(module = "accesskit.unix")] -pub struct Adapter(accesskit_unix::Adapter); - -#[pymethods] -impl Adapter { - /// Create a new Unix adapter. - /// - /// All of the handlers will always be called from another thread. - #[new] - pub fn new( - activation_handler: Py, - action_handler: Py, - deactivation_handler: Py, - ) -> Self { - Self(accesskit_unix::Adapter::new( - PythonActivationHandler(activation_handler), - PythonActionHandler(action_handler), - PythonDeactivationHandler(deactivation_handler), - )) - } - - pub fn set_root_window_bounds(&mut self, outer: Rect, inner: Rect) { - self.0.set_root_window_bounds(outer.into(), inner.into()); - } - - pub fn update_if_active(&mut self, py: Python<'_>, update_factory: Py) { - self.0.update_if_active(|| { - let update = update_factory.call0(py).unwrap(); - update.extract::(py).unwrap().into() - }); - } - - pub fn update_window_focus_state(&mut self, is_focused: bool) { - self.0.update_window_focus_state(is_focused); - } -} diff --git a/bindings/python/src/windows.rs b/bindings/python/src/windows.rs deleted file mode 100644 index 21d600c1..00000000 --- a/bindings/python/src/windows.rs +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2023 The AccessKit Authors. All rights reserved. -// Licensed under the Apache License, Version 2.0 (found in -// the LICENSE-APACHE file) or the MIT license (found in -// the LICENSE-MIT file), at your option. - -use crate::{ - LocalPythonActivationHandler, PythonActionHandler, PythonActivationHandler, TreeUpdate, -}; -use accesskit_windows::{HWND, LPARAM, WPARAM}; -use pyo3::prelude::*; - -#[pyclass(module = "accesskit.windows")] -pub struct QueuedEvents(Option); - -#[pymethods] -impl QueuedEvents { - pub fn raise_events(&mut self) { - let events = self.0.take().unwrap(); - events.raise(); - } -} - -impl From for QueuedEvents { - fn from(events: accesskit_windows::QueuedEvents) -> Self { - Self(Some(events)) - } -} - -#[pyclass(module = "accesskit.windows")] -pub struct Adapter(accesskit_windows::Adapter); - -#[pymethods] -impl Adapter { - /// Creates a new Windows platform adapter. - /// - /// The action handler may or may not be called on the thread that owns - /// the window. - #[new] - pub fn new(hwnd: &PyAny, is_window_focused: bool, action_handler: Py) -> Self { - Self(accesskit_windows::Adapter::new( - HWND(cast::(hwnd)), - is_window_focused, - PythonActionHandler(action_handler), - )) - } - - /// You must call `accesskit.windows.QueuedEvents.raise_events` on the returned value. It can be `None` if the window is not active. - pub fn update_if_active( - &mut self, - py: Python<'_>, - update_factory: Py, - ) -> Option { - self.0 - .update_if_active(|| { - let update = update_factory.call0(py).unwrap(); - update.extract::(py).unwrap().into() - }) - .map(Into::into) - } - - /// You must call `accesskit.windows.QueuedEvents.raise_events` on the returned value. - pub fn update_window_focus_state(&mut self, is_focused: bool) -> Option { - self.0.update_window_focus_state(is_focused).map(Into::into) - } - - pub fn handle_wm_getobject( - &mut self, - py: Python<'_>, - wparam: &PyAny, - lparam: &PyAny, - activation_handler: Py, - ) -> Option { - let mut activation_handler = LocalPythonActivationHandler { - py, - handler: activation_handler, - }; - self.0 - .handle_wm_getobject( - WPARAM(cast::(wparam)), - LPARAM(cast::(lparam)), - &mut activation_handler, - ) - .map(|lresult| lresult.into().0) - } -} - -#[pyclass(module = "accesskit.windows", unsendable)] -pub struct SubclassingAdapter(accesskit_windows::SubclassingAdapter); - -#[pymethods] -impl SubclassingAdapter { - /// Creates a new Windows platform adapter using window subclassing. - /// This must be done before the window is shown or focused - /// for the first time. - /// - /// The action handler may or may not be called on the thread that owns - /// the window. - #[new] - pub fn new(hwnd: &PyAny, activation_handler: Py, action_handler: Py) -> Self { - Self(accesskit_windows::SubclassingAdapter::new( - HWND(cast::(hwnd)), - PythonActivationHandler(activation_handler), - PythonActionHandler(action_handler), - )) - } - - /// You must call `accesskit.windows.QueuedEvents.raise_events` on the returned value. It can be `None` if the window is not active. - pub fn update_if_active( - &mut self, - py: Python<'_>, - update_factory: Py, - ) -> Option { - self.0 - .update_if_active(|| { - let update = update_factory.call0(py).unwrap(); - update.extract::(py).unwrap().into() - }) - .map(Into::into) - } -} - -fn cast<'a, D: FromPyObject<'a>>(value: &'a PyAny) -> D { - let value = value.getattr("value").unwrap_or(value); - value.extract().unwrap() -} diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 0be320f9..00000000 --- a/pyproject.toml +++ /dev/null @@ -1,39 +0,0 @@ -[build-system] -requires = ["maturin>=1.0,<2.0"] -build-backend = "maturin" - -[tool.maturin] -manifest-path = "bindings/python/Cargo.toml" -features = ["pyo3/extension-module"] -include = [ - "LICENSE*" -] - -[tool.maturin.target."x86_64-apple-darwin"] -macos-deployment-target = "10.12" - -[tool.maturin.target."aarch64-apple-darwin"] -macos-deployment-target = "11.0" - -[tool.ruff] -include = ['bindings/python/*.py'] - -[project] -name = "accesskit" -requires-python = ">= 3.8" -classifiers = [ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Topic :: Software Development :: User Interfaces" -] - -[project.urls] -Homepage = "https://github.com/AccessKit/accesskit" diff --git a/release-please-config.json b/release-please-config.json index 4f96ea7c..2b5f5167 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -10,8 +10,6 @@ "platforms/macos": {}, "platforms/unix": {}, "platforms/windows": {}, - "platforms/winit": {}, - "bindings/c": {}, - "bindings/python": {} + "platforms/winit": {} } }