feat(client): redesign native UI, themes, settings and avatars
Separate conversation drafts and voice view state, add native settings and restricted CSS themes, implement validated avatar cropping, and refresh dependencies with documented desktop compatibility backports.
This commit is contained in:
parent
44d284a568
commit
8e5ab56611
276 changed files with 53546 additions and 3399 deletions
528
patches/accesskit_atspi_common/CHANGELOG.md
vendored
Normal file
528
patches/accesskit_atspi_common/CHANGELOG.md
vendored
Normal file
|
|
@ -0,0 +1,528 @@
|
|||
# Changelog
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.12.2 to 0.12.3
|
||||
* accesskit_consumer bumped from 0.17.0 to 0.17.1
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit_consumer bumped from 0.19.0 to 0.19.1
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.16.0 to 0.16.1
|
||||
* accesskit_consumer bumped from 0.24.0 to 0.24.1
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.16.2 to 0.16.3
|
||||
* accesskit_consumer bumped from 0.24.2 to 0.24.3
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.17.0 to 0.17.1
|
||||
* accesskit_consumer bumped from 0.25.0 to 0.26.0
|
||||
|
||||
## [0.19.1](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.19.0...accesskit_atspi_common-v0.19.1) (2026-07-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Update Tree::toolkit_name call sites in the adapters ([27734d8](https://github.com/AccessKit/accesskit/commit/27734d8409d9e03f51caefe1c13ae4ff74e3c6b2))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit_consumer bumped from 0.37.0 to 0.38.0
|
||||
|
||||
## [0.19.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.18.1...accesskit_atspi_common-v0.19.0) (2026-06-12)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Trim trait bounds on iterator return types ([#721](https://github.com/AccessKit/accesskit/issues/721))
|
||||
|
||||
### Features
|
||||
|
||||
* Implement the cache object on Unix ([#719](https://github.com/AccessKit/accesskit/issues/719)) ([61bdabd](https://github.com/AccessKit/accesskit/commit/61bdabdb70016068c21e31bf42b36bc4209232cd))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Compute index in parent for tree roots on Unix ([#718](https://github.com/AccessKit/accesskit/issues/718)) ([7d8c55e](https://github.com/AccessKit/accesskit/commit/7d8c55e55cce4b88c289e96fccb67a38d0afa27f))
|
||||
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* Trim trait bounds on iterator return types ([#721](https://github.com/AccessKit/accesskit/issues/721)) ([4023b41](https://github.com/AccessKit/accesskit/commit/4023b414c3c1318ec2780b13a4e9f70713703862))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.24.0 to 0.24.1
|
||||
* accesskit_consumer bumped from 0.36.0 to 0.37.0
|
||||
|
||||
## [0.18.1](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.18.0...accesskit_atspi_common-v0.18.1) (2026-05-11)
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit_consumer bumped from 0.35.0 to 0.36.0
|
||||
|
||||
## [0.18.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.17.0...accesskit_atspi_common-v0.18.0) (2026-03-04)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Implement text attributes for AT-SPI ([#695](https://github.com/AccessKit/accesskit/issues/695)) ([33fc4f0](https://github.com/AccessKit/accesskit/commit/33fc4f06699da335f9b2de3ab381cc940314e9c1))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit_consumer bumped from 0.34.0 to 0.35.0
|
||||
|
||||
## [0.17.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.16.1...accesskit_atspi_common-v0.17.0) (2026-02-01)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Update minimum supported Rust version to 1.85 ([#683](https://github.com/AccessKit/accesskit/issues/683))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Update minimum supported Rust version to 1.85 ([#683](https://github.com/AccessKit/accesskit/issues/683)) ([f8c22cb](https://github.com/AccessKit/accesskit/commit/f8c22cbb53ce6b1859adeff3c0b7154ad9e1f25e))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.23.0 to 0.24.0
|
||||
* accesskit_consumer bumped from 0.33.1 to 0.34.0
|
||||
|
||||
## [0.16.1](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.16.0...accesskit_atspi_common-v0.16.1) (2026-01-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Emit initial focus event for active descendant node ([#681](https://github.com/AccessKit/accesskit/issues/681)) ([13a37d1](https://github.com/AccessKit/accesskit/commit/13a37d144e2fafceaf26e7645f6acc679ccb2f34))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit_consumer bumped from 0.33.0 to 0.33.1
|
||||
|
||||
## [0.16.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.15.0...accesskit_atspi_common-v0.16.0) (2026-01-15)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Multiple tree support ([#655](https://github.com/AccessKit/accesskit/issues/655))
|
||||
|
||||
### Features
|
||||
|
||||
* Implement the `url` property ([#669](https://github.com/AccessKit/accesskit/issues/669)) ([6202e63](https://github.com/AccessKit/accesskit/commit/6202e63c667e73216a306b3dd45ff25c364a4f45))
|
||||
* Multiple tree support ([#655](https://github.com/AccessKit/accesskit/issues/655)) ([c16eb80](https://github.com/AccessKit/accesskit/commit/c16eb80c49d14f39e8a7defb1694bf22b8ceed6f))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.22.0 to 0.23.0
|
||||
* accesskit_consumer bumped from 0.32.0 to 0.33.0
|
||||
|
||||
## [0.15.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.14.2...accesskit_atspi_common-v0.15.0) (2025-12-23)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Drop deprecated roles ([#642](https://github.com/AccessKit/accesskit/issues/642))
|
||||
* Infrastructure for supporting text formatting changes ([#626](https://github.com/AccessKit/accesskit/issues/626))
|
||||
|
||||
### Features
|
||||
|
||||
* Add GridCell role ([#643](https://github.com/AccessKit/accesskit/issues/643)) ([1e5abca](https://github.com/AccessKit/accesskit/commit/1e5abca737d1ee942c0804fec2c06d3cb08faa94))
|
||||
* Implement BrailleLabel and BrailleRoleDescription roles ([#638](https://github.com/AccessKit/accesskit/issues/638)) ([0fdcebb](https://github.com/AccessKit/accesskit/commit/0fdcebb55e308e039ec99fbc31e94e8087a69f2d))
|
||||
* Rename HeaderAsNonLandmark to SectionHeader, FooterAsNonLandmark to SectionFooter ([#635](https://github.com/AccessKit/accesskit/issues/635)) ([dd69526](https://github.com/AccessKit/accesskit/commit/dd695260877cb862ece4c2b7d8607308f5fed608))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Bump atspi crates ([dbf81c9](https://github.com/AccessKit/accesskit/commit/dbf81c968739187a9f4c3c105d0618c0f9db3135))
|
||||
* Expose dialogs in the platform adapters ([1576a94](https://github.com/AccessKit/accesskit/commit/1576a940ec3e9066fc5e181419dae6899bf2db46))
|
||||
* Replace thiserror with manual trait implementations ([#652](https://github.com/AccessKit/accesskit/issues/652)) ([b42c5e2](https://github.com/AccessKit/accesskit/commit/b42c5e25659aeb74d7f534ef2a8745d80227c1e3))
|
||||
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* Drop deprecated roles ([#642](https://github.com/AccessKit/accesskit/issues/642)) ([4d46c27](https://github.com/AccessKit/accesskit/commit/4d46c2740631c5fe4f057707b949d12b26931d0b))
|
||||
* Infrastructure for supporting text formatting changes ([#626](https://github.com/AccessKit/accesskit/issues/626)) ([ea23ec4](https://github.com/AccessKit/accesskit/commit/ea23ec424c7dbb8841e03d71b6a15b74264850a9))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.21.1 to 0.22.0
|
||||
* accesskit_consumer bumped from 0.31.0 to 0.32.0
|
||||
|
||||
## [0.14.2](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.14.1...accesskit_atspi_common-v0.14.2) (2025-10-20)
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit_consumer bumped from 0.30.1 to 0.31.0
|
||||
|
||||
## [0.14.1](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.14.0...accesskit_atspi_common-v0.14.1) (2025-10-02)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix clippy warnings introduced in 1.89 ([#606](https://github.com/AccessKit/accesskit/issues/606)) ([b2c07d6](https://github.com/AccessKit/accesskit/commit/b2c07d654a8ce6f01e61a79c91f2f9d5a96afdc9))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.21.0 to 0.21.1
|
||||
* accesskit_consumer bumped from 0.30.0 to 0.30.1
|
||||
|
||||
## [0.14.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.13.0...accesskit_atspi_common-v0.14.0) (2025-07-16)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Implement refactored `ScrollIntoView` action across desktop platforms ([#594](https://github.com/AccessKit/accesskit/issues/594))
|
||||
|
||||
### Features
|
||||
|
||||
* Implement refactored `ScrollIntoView` action across desktop platforms ([#594](https://github.com/AccessKit/accesskit/issues/594)) ([1d9b74c](https://github.com/AccessKit/accesskit/commit/1d9b74c057051509b3ffbf63afeacfb16f544ff8))
|
||||
* Let parents declare actions supported on their children ([#593](https://github.com/AccessKit/accesskit/issues/593)) ([70b534b](https://github.com/AccessKit/accesskit/commit/70b534bed168a84b84cc35199588aa8ab784fb43))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.20.0 to 0.21.0
|
||||
* accesskit_consumer bumped from 0.29.0 to 0.30.0
|
||||
|
||||
## [0.13.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.12.0...accesskit_atspi_common-v0.13.0) (2025-06-26)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Force a semver-breaking release ([#589](https://github.com/AccessKit/accesskit/issues/589))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Force a semver-breaking release ([#589](https://github.com/AccessKit/accesskit/issues/589)) ([2887cdd](https://github.com/AccessKit/accesskit/commit/2887cddde817ba3851688068d8d10de5cef7c624))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.19.0 to 0.20.0
|
||||
* accesskit_consumer bumped from 0.28.0 to 0.29.0
|
||||
|
||||
## [0.12.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.11.0...accesskit_atspi_common-v0.12.0) (2025-05-06)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Drop redundant `HasPopup::True` ([#550](https://github.com/AccessKit/accesskit/issues/550))
|
||||
|
||||
### Features
|
||||
|
||||
* Expose tabs in consumer and atspi-common ([b1fb5b3](https://github.com/AccessKit/accesskit/commit/b1fb5b3de12c001e34021263038b66a6e3a7dd1e))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix a compilation error in atspi-common `Event::new` ([#537](https://github.com/AccessKit/accesskit/issues/537)) ([23b4d8d](https://github.com/AccessKit/accesskit/commit/23b4d8d49fed378899855a40e63aff10e829f6e8))
|
||||
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* Drop redundant `HasPopup::True` ([#550](https://github.com/AccessKit/accesskit/issues/550)) ([56abf17](https://github.com/AccessKit/accesskit/commit/56abf17356e4c7f13f64aaeaca6a63c8f7ede553))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.18.0 to 0.19.0
|
||||
* accesskit_consumer bumped from 0.27.0 to 0.28.0
|
||||
|
||||
## [0.11.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.10.1...accesskit_atspi_common-v0.11.0) (2025-03-06)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Optimize simple string getters ([#493](https://github.com/AccessKit/accesskit/issues/493))
|
||||
* Drop `Tree::app_name` ([#492](https://github.com/AccessKit/accesskit/issues/492))
|
||||
|
||||
### Features
|
||||
|
||||
* Add list box support to the `consumer` and `atspi-common` crates ([d6dca15](https://github.com/AccessKit/accesskit/commit/d6dca15d5c298c797ab7a702f0186043eac33c5c))
|
||||
* Expose the `is_required` property ([#497](https://github.com/AccessKit/accesskit/issues/497)) ([46ed99b](https://github.com/AccessKit/accesskit/commit/46ed99bb958ddb32cbf1bee2fcfb7b328bcbe0ab))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Derive `Debug` for adapters ([#513](https://github.com/AccessKit/accesskit/issues/513)) ([753d904](https://github.com/AccessKit/accesskit/commit/753d90473cf57682568c7a17c82474c8e5d00b25))
|
||||
* Remove unnecessary explicit lifetimes ([#488](https://github.com/AccessKit/accesskit/issues/488)) ([d2bcd6d](https://github.com/AccessKit/accesskit/commit/d2bcd6d3048d23df4e132bee6171eb247b2dc2c8))
|
||||
* Update zbus to 5.0 ([#519](https://github.com/AccessKit/accesskit/issues/519)) ([4c10b80](https://github.com/AccessKit/accesskit/commit/4c10b801b6924c7010b83f4eb44c8c350c860cf6))
|
||||
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* Drop `Tree::app_name` ([#492](https://github.com/AccessKit/accesskit/issues/492)) ([089794c](https://github.com/AccessKit/accesskit/commit/089794c8f74957e91a19ae3df508e2a892f39ebc))
|
||||
* Optimize simple string getters ([#493](https://github.com/AccessKit/accesskit/issues/493)) ([484fd7c](https://github.com/AccessKit/accesskit/commit/484fd7cbfb778222369d3f57d31dd998f6fa80d8))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.17.1 to 0.18.0
|
||||
* accesskit_consumer bumped from 0.26.0 to 0.27.0
|
||||
|
||||
## [0.10.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.9.3...accesskit_atspi_common-v0.10.0) (2024-10-31)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Rename `name` to `label` and use `value` for label content ([#475](https://github.com/AccessKit/accesskit/issues/475))
|
||||
* Rename `Role::InlineTextBox` to `TextRun` ([#473](https://github.com/AccessKit/accesskit/issues/473))
|
||||
* Drop `DefaultActionVerb` ([#472](https://github.com/AccessKit/accesskit/issues/472))
|
||||
* Make the core crate no-std ([#468](https://github.com/AccessKit/accesskit/issues/468))
|
||||
|
||||
### Features
|
||||
|
||||
* Make the core crate no-std ([#468](https://github.com/AccessKit/accesskit/issues/468)) ([2fa0d3f](https://github.com/AccessKit/accesskit/commit/2fa0d3f5b2b7ac11ef1751c133706f29e548bd6d))
|
||||
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* Drop `DefaultActionVerb` ([#472](https://github.com/AccessKit/accesskit/issues/472)) ([ef3b003](https://github.com/AccessKit/accesskit/commit/ef3b0038224459094f650368412650bc3b69526b))
|
||||
* Rename `name` to `label` and use `value` for label content ([#475](https://github.com/AccessKit/accesskit/issues/475)) ([e0053a5](https://github.com/AccessKit/accesskit/commit/e0053a5399929e8e0d4f07aa18de604ed8766ace))
|
||||
* Rename `Role::InlineTextBox` to `TextRun` ([#473](https://github.com/AccessKit/accesskit/issues/473)) ([29fa341](https://github.com/AccessKit/accesskit/commit/29fa34125a811bd3a0f9da579a9f35c9da90bf29))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.16.3 to 0.17.0
|
||||
* accesskit_consumer bumped from 0.24.3 to 0.25.0
|
||||
|
||||
## [0.9.2](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.9.1...accesskit_atspi_common-v0.9.2) (2024-10-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Update minimum supported Rust version to 1.75 ([#457](https://github.com/AccessKit/accesskit/issues/457)) ([fc622fe](https://github.com/AccessKit/accesskit/commit/fc622fe7657c80a4eedad6f6cded11d2538b54d5))
|
||||
* Update to zbus v4 ([#456](https://github.com/AccessKit/accesskit/issues/456)) ([95db8f1](https://github.com/AccessKit/accesskit/commit/95db8f1c5f7f56598eab6910a990ccbf9d864dda))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.16.1 to 0.16.2
|
||||
* accesskit_consumer bumped from 0.24.1 to 0.24.2
|
||||
|
||||
## [0.9.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.8.0...accesskit_atspi_common-v0.9.0) (2024-06-29)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Rename the `StaticText` role to `Label` ([#434](https://github.com/AccessKit/accesskit/issues/434))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Correctly handle recursive filtering ([#438](https://github.com/AccessKit/accesskit/issues/438)) ([72f9b42](https://github.com/AccessKit/accesskit/commit/72f9b424a5c6e7914df8bf31eeb2fc61be35f47b))
|
||||
* Smarter calculation of AT-SPI extents for the window ([#435](https://github.com/AccessKit/accesskit/issues/435)) ([7f40fbc](https://github.com/AccessKit/accesskit/commit/7f40fbc811f863e99088cd7eb725994d0f79263f))
|
||||
|
||||
|
||||
### 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_consumer bumped from 0.23.0 to 0.24.0
|
||||
|
||||
## [0.8.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.7.0...accesskit_atspi_common-v0.8.0) (2024-06-15)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Feature-gate the `accesskit_atspi_common::simplified` module ([#430](https://github.com/AccessKit/accesskit/issues/430)) ([50341f1](https://github.com/AccessKit/accesskit/commit/50341f10cf32ef16c904d54725f717a585d21043))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Avoid unnecessary repeated checks for text changes ([#432](https://github.com/AccessKit/accesskit/issues/432)) ([0e89671](https://github.com/AccessKit/accesskit/commit/0e89671fc0cf831d2c86a2cacf0195e247560753))
|
||||
|
||||
## [0.7.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.6.0...accesskit_atspi_common-v0.7.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_consumer bumped from 0.22.0 to 0.23.0
|
||||
|
||||
## [0.6.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.5.0...accesskit_atspi_common-v0.6.0) (2024-05-27)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Expose the `orientation` property ([#421](https://github.com/AccessKit/accesskit/issues/421)) ([590aada](https://github.com/AccessKit/accesskit/commit/590aada070dc812f9b8f171fb9e43ac984fad2a1))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix a logic error in suffix calculation for text changes ([#423](https://github.com/AccessKit/accesskit/issues/423)) ([1121723](https://github.com/AccessKit/accesskit/commit/1121723983cb2fa64b5053626ec64afb851ff6c4))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit_consumer bumped from 0.21.0 to 0.22.0
|
||||
|
||||
## [0.5.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.4.2...accesskit_atspi_common-v0.5.0) (2024-05-26)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Add basic text support on Unix ([#362](https://github.com/AccessKit/accesskit/issues/362)) ([52540f8](https://github.com/AccessKit/accesskit/commit/52540f82cf9fc148358351ed486bab3e7e91f1d6))
|
||||
* Expose the `placeholder` property ([#417](https://github.com/AccessKit/accesskit/issues/417)) ([8f4a0a1](https://github.com/AccessKit/accesskit/commit/8f4a0a1c10f83fcc8580a37d8013fec2d110865b))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Don't fire events for filtered children on Unix ([#414](https://github.com/AccessKit/accesskit/issues/414)) ([2bcb1b6](https://github.com/AccessKit/accesskit/commit/2bcb1b63e88b801b194a4db50059fa063efbee64))
|
||||
* Improve how coordinates are computed on Unix ([#420](https://github.com/AccessKit/accesskit/issues/420)) ([fc5125e](https://github.com/AccessKit/accesskit/commit/fc5125e27f8f4f655e1de5049d0d53536284d9a0))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit_consumer bumped from 0.20.0 to 0.21.0
|
||||
|
||||
## [0.4.2](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.4.1...accesskit_atspi_common-v0.4.2) (2024-05-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fix platform adapters to support copy-on-write tree snapshots again ([#411](https://github.com/AccessKit/accesskit/issues/411)) ([d3a130a](https://github.com/AccessKit/accesskit/commit/d3a130a5ec8ae1d9edf0bf85a44f35f0e365242c))
|
||||
* Return to handling focus events directly, after generic node changes ([#409](https://github.com/AccessKit/accesskit/issues/409)) ([cd2e35e](https://github.com/AccessKit/accesskit/commit/cd2e35e43817405199ae6acd64ef90aee445be0b))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit_consumer bumped from 0.19.1 to 0.20.0
|
||||
|
||||
## [0.4.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.3.0...accesskit_atspi_common-v0.4.0) (2024-04-30)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Clean up table roles and properties ([#393](https://github.com/AccessKit/accesskit/issues/393))
|
||||
* Rename `Checked` to `Toggled`; drop `ToggleButton` role ([#388](https://github.com/AccessKit/accesskit/issues/388))
|
||||
|
||||
### Features
|
||||
|
||||
* Implement the `description` property ([#382](https://github.com/AccessKit/accesskit/issues/382)) ([d49f406](https://github.com/AccessKit/accesskit/commit/d49f40660b5dc23ed074cd72a91e511b130756ae))
|
||||
|
||||
|
||||
### 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))
|
||||
* Rename `Checked` to `Toggled`; drop `ToggleButton` role ([#388](https://github.com/AccessKit/accesskit/issues/388)) ([6bc040b](https://github.com/AccessKit/accesskit/commit/6bc040b7cf75cdbd6a019cc380d8dbce804b3c81))
|
||||
|
||||
|
||||
### Dependencies
|
||||
|
||||
* The following workspace dependencies were updated
|
||||
* dependencies
|
||||
* accesskit bumped from 0.13.0 to 0.14.0
|
||||
* accesskit_consumer bumped from 0.18.0 to 0.19.0
|
||||
|
||||
## [0.3.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.2.0...accesskit_atspi_common-v0.3.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_consumer bumped from 0.17.1 to 0.18.0
|
||||
|
||||
## [0.2.0](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.1.2...accesskit_atspi_common-v0.2.0) (2024-03-11)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Expose root node ID in `accesskit_atspi_common::Adapter` ([#370](https://github.com/AccessKit/accesskit/issues/370)) ([a43b497](https://github.com/AccessKit/accesskit/commit/a43b497afbbbcf90e9d15259635a329164d6a791))
|
||||
|
||||
## [0.1.1](https://github.com/AccessKit/accesskit/compare/accesskit_atspi_common-v0.1.0...accesskit_atspi_common-v0.1.1) (2024-02-24)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Add missing README ([#357](https://github.com/AccessKit/accesskit/issues/357)) ([e8cf48e](https://github.com/AccessKit/accesskit/commit/e8cf48e21be0146768b2d14289164d192823fd1f))
|
||||
|
||||
## 0.1.0 (2024-02-24)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Factor out core AT-SPI translation layer ([#352](https://github.com/AccessKit/accesskit/issues/352)) ([8c0ab58](https://github.com/AccessKit/accesskit/commit/8c0ab58d441c0d4484e0bc31a554bdfb3f088cd6))
|
||||
64
patches/accesskit_atspi_common/Cargo.toml
vendored
Normal file
64
patches/accesskit_atspi_common/Cargo.toml
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2024"
|
||||
rust-version = "1.85"
|
||||
name = "accesskit_atspi_common"
|
||||
version = "0.19.1"
|
||||
authors = ["The AccessKit contributors"]
|
||||
build = false
|
||||
autolib = false
|
||||
autobins = false
|
||||
autoexamples = false
|
||||
autotests = false
|
||||
autobenches = false
|
||||
description = "AccessKit UI accessibility infrastructure: core AT-SPI translation layer"
|
||||
readme = "README.md"
|
||||
keywords = [
|
||||
"gui",
|
||||
"ui",
|
||||
"accessibility",
|
||||
]
|
||||
categories = ["gui"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/AccessKit/accesskit"
|
||||
resolver = "2"
|
||||
|
||||
[features]
|
||||
simplified-api = []
|
||||
|
||||
[lib]
|
||||
name = "accesskit_atspi_common"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies.accesskit]
|
||||
version = "0.24.1"
|
||||
|
||||
[dependencies.accesskit_consumer]
|
||||
version = "0.38.0"
|
||||
|
||||
[dependencies.atspi-common]
|
||||
version = "0.13"
|
||||
default-features = false
|
||||
|
||||
[dependencies.phf]
|
||||
version = "0.13.1"
|
||||
features = ["macros"]
|
||||
|
||||
[dependencies.serde]
|
||||
version = "1.0"
|
||||
|
||||
|
||||
[dependencies.zbus]
|
||||
version = "6.1"
|
||||
default-features = false
|
||||
features = ["default-rt", "proxy", "service", "object-manager"]
|
||||
176
patches/accesskit_atspi_common/LICENSE-APACHE
vendored
Normal file
176
patches/accesskit_atspi_common/LICENSE-APACHE
vendored
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
23
patches/accesskit_atspi_common/LICENSE-MIT
vendored
Normal file
23
patches/accesskit_atspi_common/LICENSE-MIT
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
3
patches/accesskit_atspi_common/README.md
vendored
Normal file
3
patches/accesskit_atspi_common/README.md
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# AccessKit common AT-SPI translation layer
|
||||
|
||||
This crate contains common logic for translating between AccessKit and AT-SPI. It is shared by the AccessKit Unix adapter and the new, experimental GNOME accessibility stack (code-named Newton) which is based on pushing AccessKit tree updates to the assistive technology.
|
||||
9
patches/accesskit_atspi_common/VNOX-PATCH.md
vendored
Normal file
9
patches/accesskit_atspi_common/VNOX-PATCH.md
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Vnox maintenance patch: accesskit_atspi_common 0.19.1
|
||||
|
||||
Source: published crates.io accesskit_atspi_common 0.19.1, original licenses included.
|
||||
|
||||
This is a maintained-parent compatibility backport, not a fork of an unmaintained D-Bus codec. Vnox updates dependencies/imports to maintained zbus 6, which merged zvariant and zbus_names. The original package version identifies its API baseline; no version is spoofed to suppress RustSec.
|
||||
|
||||
The Slint Winit patch additionally uses Winit's supported crossfont CSD backend to avoid the unmaintained ttf-parser chain while retaining Wayland client-side title decorations.
|
||||
|
||||
Remove this patch once upstream publishes the equivalent migration. Changes must be tested with full client build, native rendering, accessibility/portal interfaces and RustSec audit.
|
||||
14
patches/accesskit_atspi_common/src/action.rs
vendored
Normal file
14
patches/accesskit_atspi_common/src/action.rs
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2022 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 serde::{Deserialize, Serialize};
|
||||
use zbus::wire::Type;
|
||||
|
||||
#[derive(Deserialize, Serialize, Type)]
|
||||
pub struct Action {
|
||||
pub localized_name: String,
|
||||
pub description: String,
|
||||
pub key_binding: String,
|
||||
}
|
||||
822
patches/accesskit_atspi_common/src/adapter.rs
vendored
Normal file
822
patches/accesskit_atspi_common/src/adapter.rs
vendored
Normal file
|
|
@ -0,0 +1,822 @@
|
|||
// Copyright 2022 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 Chromium's accessibility abstraction.
|
||||
// Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE.chromium file.
|
||||
|
||||
use crate::{
|
||||
AdapterCallback, CacheEvent, Event, ObjectEvent, WindowEvent,
|
||||
context::{ActionHandlerNoMut, ActionHandlerWrapper, AppContext, Context},
|
||||
filters::filter,
|
||||
node::{NodeIdOrRoot, NodeWrapper, PlatformNode, PlatformRoot},
|
||||
util::WindowBounds,
|
||||
};
|
||||
use accesskit::{ActionHandler, Role, TreeUpdate};
|
||||
use accesskit_consumer::{FilterResult, Node, NodeId, Tree, TreeChangeHandler, TreeState};
|
||||
use atspi_common::{InterfaceSet, Politeness, State};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
sync::{
|
||||
Arc, RwLock,
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
},
|
||||
};
|
||||
|
||||
struct AdapterChangeHandler<'a> {
|
||||
adapter: &'a Adapter,
|
||||
added_nodes: HashSet<NodeId>,
|
||||
removed_nodes: HashSet<NodeId>,
|
||||
checked_text_change: HashSet<NodeId>,
|
||||
selection_changed: HashSet<NodeId>,
|
||||
}
|
||||
|
||||
impl<'a> AdapterChangeHandler<'a> {
|
||||
fn new(adapter: &'a Adapter) -> Self {
|
||||
Self {
|
||||
adapter,
|
||||
added_nodes: HashSet::new(),
|
||||
removed_nodes: HashSet::new(),
|
||||
checked_text_change: HashSet::new(),
|
||||
selection_changed: HashSet::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn add_node(&mut self, node: &Node) {
|
||||
let id = node.id();
|
||||
if self.added_nodes.contains(&id) {
|
||||
return;
|
||||
}
|
||||
self.added_nodes.insert(id);
|
||||
|
||||
let role = node.role();
|
||||
let is_root = node.is_root();
|
||||
let wrapper = NodeWrapper(node);
|
||||
let interfaces = wrapper.interfaces();
|
||||
self.adapter.register_interfaces(node.id(), interfaces);
|
||||
self.adapter.emit_cache_added(node.id());
|
||||
if is_root && role == Role::Window {
|
||||
let adapter_index = self
|
||||
.adapter
|
||||
.context
|
||||
.read_app_context()
|
||||
.adapter_index(self.adapter.id)
|
||||
.unwrap();
|
||||
self.adapter.window_created(adapter_index, node.id());
|
||||
}
|
||||
|
||||
let live = wrapper.live();
|
||||
if live != Politeness::None {
|
||||
if let Some(name) = wrapper.name() {
|
||||
self.adapter
|
||||
.emit_object_event(node.id(), ObjectEvent::Announcement(name, live));
|
||||
}
|
||||
}
|
||||
if let Some(true) = node.is_selected() {
|
||||
self.enqueue_selection_changed_if_needed(node);
|
||||
}
|
||||
}
|
||||
|
||||
fn add_subtree(&mut self, node: &Node) {
|
||||
self.add_node(node);
|
||||
for child in node.filtered_children(&filter) {
|
||||
self.add_subtree(&child);
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_node(&mut self, node: &Node) {
|
||||
let id = node.id();
|
||||
if self.removed_nodes.contains(&id) {
|
||||
return;
|
||||
}
|
||||
self.removed_nodes.insert(id);
|
||||
|
||||
let role = node.role();
|
||||
let is_root = node.is_root();
|
||||
let wrapper = NodeWrapper(node);
|
||||
if is_root && role == Role::Window {
|
||||
self.adapter.window_destroyed(node.id());
|
||||
}
|
||||
self.adapter
|
||||
.emit_object_event(node.id(), ObjectEvent::StateChanged(State::Defunct, true));
|
||||
self.adapter.emit_cache_removed(node.id());
|
||||
self.adapter
|
||||
.unregister_interfaces(node.id(), wrapper.interfaces());
|
||||
if let Some(true) = node.is_selected() {
|
||||
self.enqueue_selection_changed_if_needed(node);
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_subtree(&mut self, node: &Node) {
|
||||
for child in node.filtered_children(&filter) {
|
||||
self.remove_subtree(&child);
|
||||
}
|
||||
self.remove_node(node);
|
||||
}
|
||||
|
||||
fn emit_text_change_if_needed_parent(&mut self, old_node: &Node, new_node: &Node) {
|
||||
if !new_node.supports_text_ranges() || !old_node.supports_text_ranges() {
|
||||
return;
|
||||
}
|
||||
let id = new_node.id();
|
||||
if self.checked_text_change.contains(&id) {
|
||||
return;
|
||||
}
|
||||
self.checked_text_change.insert(id);
|
||||
let old_text = old_node.document_range().text();
|
||||
let new_text = new_node.document_range().text();
|
||||
|
||||
let mut old_chars = old_text.chars();
|
||||
let mut new_chars = new_text.chars();
|
||||
let mut prefix_usv_count = 0;
|
||||
let mut prefix_byte_count = 0;
|
||||
loop {
|
||||
match (old_chars.next(), new_chars.next()) {
|
||||
(Some(old_char), Some(new_char)) if old_char == new_char => {
|
||||
prefix_usv_count += 1;
|
||||
prefix_byte_count += new_char.len_utf8();
|
||||
}
|
||||
(None, None) => return,
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
|
||||
let suffix_byte_count = old_text[prefix_byte_count..]
|
||||
.chars()
|
||||
.rev()
|
||||
.zip(new_text[prefix_byte_count..].chars().rev())
|
||||
.take_while(|(old_char, new_char)| old_char == new_char)
|
||||
.fold(0, |count, (c, _)| count + c.len_utf8());
|
||||
|
||||
let old_content = &old_text[prefix_byte_count..old_text.len() - suffix_byte_count];
|
||||
if let Ok(length) = old_content.chars().count().try_into() {
|
||||
if length > 0 {
|
||||
self.adapter.emit_object_event(
|
||||
id,
|
||||
ObjectEvent::TextRemoved {
|
||||
start_index: prefix_usv_count,
|
||||
length,
|
||||
content: old_content.to_string(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let new_content = &new_text[prefix_byte_count..new_text.len() - suffix_byte_count];
|
||||
if let Ok(length) = new_content.chars().count().try_into() {
|
||||
if length > 0 {
|
||||
self.adapter.emit_object_event(
|
||||
id,
|
||||
ObjectEvent::TextInserted {
|
||||
start_index: prefix_usv_count,
|
||||
length,
|
||||
content: new_content.to_string(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_text_change_if_needed(&mut self, old_node: &Node, new_node: &Node) {
|
||||
if let Role::TextRun | Role::GenericContainer = new_node.role() {
|
||||
if let (Some(old_parent), Some(new_parent)) = (
|
||||
old_node.filtered_parent(&filter),
|
||||
new_node.filtered_parent(&filter),
|
||||
) {
|
||||
self.emit_text_change_if_needed_parent(&old_parent, &new_parent);
|
||||
}
|
||||
} else {
|
||||
self.emit_text_change_if_needed_parent(old_node, new_node);
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_text_selection_change(&self, old_node: Option<&Node>, new_node: &Node) {
|
||||
if !new_node.supports_text_ranges() {
|
||||
return;
|
||||
}
|
||||
let Some(old_node) = old_node else {
|
||||
if let Some(selection) = new_node.text_selection() {
|
||||
if !selection.is_degenerate() {
|
||||
self.adapter
|
||||
.emit_object_event(new_node.id(), ObjectEvent::TextSelectionChanged);
|
||||
}
|
||||
}
|
||||
if let Some(selection_focus) = new_node.text_selection_focus() {
|
||||
if let Ok(offset) = selection_focus.to_global_usv_index().try_into() {
|
||||
self.adapter
|
||||
.emit_object_event(new_node.id(), ObjectEvent::CaretMoved(offset));
|
||||
}
|
||||
}
|
||||
return;
|
||||
};
|
||||
if !old_node.is_focused() || new_node.raw_text_selection() == old_node.raw_text_selection()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(selection) = new_node.text_selection() {
|
||||
if !selection.is_degenerate()
|
||||
|| old_node
|
||||
.text_selection()
|
||||
.map(|selection| !selection.is_degenerate())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
self.adapter
|
||||
.emit_object_event(new_node.id(), ObjectEvent::TextSelectionChanged);
|
||||
}
|
||||
}
|
||||
|
||||
let old_caret_position = old_node
|
||||
.raw_text_selection()
|
||||
.map(|selection| selection.focus);
|
||||
let new_caret_position = new_node
|
||||
.raw_text_selection()
|
||||
.map(|selection| selection.focus);
|
||||
if old_caret_position != new_caret_position {
|
||||
if let Some(selection_focus) = new_node.text_selection_focus() {
|
||||
if let Ok(offset) = selection_focus.to_global_usv_index().try_into() {
|
||||
self.adapter
|
||||
.emit_object_event(new_node.id(), ObjectEvent::CaretMoved(offset));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn enqueue_selection_changed_if_needed_parent(&mut self, node: Node) {
|
||||
if !node.is_container_with_selectable_children() {
|
||||
return;
|
||||
}
|
||||
let id = node.id();
|
||||
if self.selection_changed.contains(&id) {
|
||||
return;
|
||||
}
|
||||
self.selection_changed.insert(id);
|
||||
}
|
||||
|
||||
fn enqueue_selection_changed_if_needed(&mut self, node: &Node) {
|
||||
if !node.is_item_like() {
|
||||
return;
|
||||
}
|
||||
if let Some(node) = node.selection_container(&filter) {
|
||||
self.enqueue_selection_changed_if_needed_parent(node);
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_selection_changed(&mut self) {
|
||||
for id in self.selection_changed.iter() {
|
||||
if self.removed_nodes.contains(id) {
|
||||
continue;
|
||||
}
|
||||
self.adapter
|
||||
.emit_object_event(*id, ObjectEvent::SelectionChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeChangeHandler for AdapterChangeHandler<'_> {
|
||||
fn node_added(&mut self, node: &Node) {
|
||||
if filter(node) == FilterResult::Include {
|
||||
self.add_node(node);
|
||||
}
|
||||
}
|
||||
|
||||
fn node_updated(&mut self, old_node: &Node, new_node: &Node) {
|
||||
self.emit_text_change_if_needed(old_node, new_node);
|
||||
let filter_old = filter(old_node);
|
||||
let filter_new = filter(new_node);
|
||||
if filter_new != filter_old {
|
||||
if filter_new == FilterResult::Include {
|
||||
if filter_old == FilterResult::ExcludeSubtree {
|
||||
self.add_subtree(new_node);
|
||||
} else {
|
||||
self.add_node(new_node);
|
||||
}
|
||||
} else if filter_old == FilterResult::Include {
|
||||
if filter_new == FilterResult::ExcludeSubtree {
|
||||
self.remove_subtree(old_node);
|
||||
} else {
|
||||
self.remove_node(old_node);
|
||||
}
|
||||
}
|
||||
} else if filter_new == FilterResult::Include {
|
||||
let old_wrapper = NodeWrapper(old_node);
|
||||
let new_wrapper = NodeWrapper(new_node);
|
||||
let old_interfaces = old_wrapper.interfaces();
|
||||
let new_interfaces = new_wrapper.interfaces();
|
||||
let kept_interfaces = old_interfaces & new_interfaces;
|
||||
self.adapter
|
||||
.unregister_interfaces(new_wrapper.id(), old_interfaces ^ kept_interfaces);
|
||||
self.adapter
|
||||
.register_interfaces(new_node.id(), new_interfaces ^ kept_interfaces);
|
||||
let bounds = *self.adapter.context.read_root_window_bounds();
|
||||
new_wrapper.notify_changes(&bounds, self.adapter, &old_wrapper);
|
||||
self.emit_text_selection_change(Some(old_node), new_node);
|
||||
if new_node.is_selected() != old_node.is_selected() {
|
||||
self.enqueue_selection_changed_if_needed(new_node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn focus_moved(&mut self, old_node: Option<&Node>, new_node: Option<&Node>) {
|
||||
if let (None, Some(new_node)) = (old_node, new_node) {
|
||||
if let Some(root_window) = root_window(new_node.tree_state) {
|
||||
self.adapter.window_activated(&NodeWrapper(&root_window));
|
||||
}
|
||||
} else if let (Some(old_node), None) = (old_node, new_node) {
|
||||
if let Some(root_window) = root_window(old_node.tree_state) {
|
||||
self.adapter.window_deactivated(&NodeWrapper(&root_window));
|
||||
}
|
||||
}
|
||||
if let Some(node) = new_node {
|
||||
self.adapter
|
||||
.emit_object_event(node.id(), ObjectEvent::StateChanged(State::Focused, true));
|
||||
self.emit_text_selection_change(None, node);
|
||||
}
|
||||
if let Some(node) = old_node {
|
||||
self.adapter
|
||||
.emit_object_event(node.id(), ObjectEvent::StateChanged(State::Focused, false));
|
||||
}
|
||||
}
|
||||
|
||||
fn node_removed(&mut self, node: &Node) {
|
||||
if filter(node) == FilterResult::Include {
|
||||
self.remove_node(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static NEXT_ADAPTER_ID: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
/// If you use this function, you must ensure that only one adapter at a time
|
||||
/// has a given ID.
|
||||
pub fn next_adapter_id() -> usize {
|
||||
NEXT_ADAPTER_ID.fetch_add(1, Ordering::Relaxed)
|
||||
}
|
||||
|
||||
pub struct Adapter {
|
||||
id: usize,
|
||||
callback: Box<dyn AdapterCallback + Send + Sync>,
|
||||
context: Arc<Context>,
|
||||
}
|
||||
|
||||
impl Debug for Adapter {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("Adapter")
|
||||
.field("id", &self.id)
|
||||
.field("callback", &"AdapterCallback")
|
||||
.field("context", &self.context)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl Adapter {
|
||||
pub fn new(
|
||||
app_context: &Arc<RwLock<AppContext>>,
|
||||
callback: impl 'static + AdapterCallback + Send + Sync,
|
||||
initial_state: TreeUpdate,
|
||||
is_window_focused: bool,
|
||||
root_window_bounds: WindowBounds,
|
||||
action_handler: impl 'static + ActionHandler + Send,
|
||||
) -> Self {
|
||||
let id = next_adapter_id();
|
||||
Self::with_id(
|
||||
id,
|
||||
app_context,
|
||||
callback,
|
||||
initial_state,
|
||||
is_window_focused,
|
||||
root_window_bounds,
|
||||
action_handler,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn with_id(
|
||||
id: usize,
|
||||
app_context: &Arc<RwLock<AppContext>>,
|
||||
callback: impl 'static + AdapterCallback + Send + Sync,
|
||||
initial_state: TreeUpdate,
|
||||
is_window_focused: bool,
|
||||
root_window_bounds: WindowBounds,
|
||||
action_handler: impl 'static + ActionHandler + Send,
|
||||
) -> Self {
|
||||
Self::with_wrapped_action_handler(
|
||||
id,
|
||||
app_context,
|
||||
callback,
|
||||
initial_state,
|
||||
is_window_focused,
|
||||
root_window_bounds,
|
||||
Arc::new(ActionHandlerWrapper::new(action_handler)),
|
||||
)
|
||||
}
|
||||
|
||||
/// This is an implementation detail of `accesskit_unix`, required for
|
||||
/// robust state transitions with minimal overhead.
|
||||
pub fn with_wrapped_action_handler(
|
||||
id: usize,
|
||||
app_context: &Arc<RwLock<AppContext>>,
|
||||
callback: impl 'static + AdapterCallback + Send + Sync,
|
||||
initial_state: TreeUpdate,
|
||||
is_window_focused: bool,
|
||||
root_window_bounds: WindowBounds,
|
||||
action_handler: Arc<dyn ActionHandlerNoMut + Send + Sync>,
|
||||
) -> Self {
|
||||
let tree = Tree::new(initial_state, is_window_focused);
|
||||
let focus_id = tree.state().focus().map(|node| node.id());
|
||||
let context = Context::new(app_context, tree, action_handler, root_window_bounds);
|
||||
context.write_app_context().push_adapter(id, &context);
|
||||
let adapter = Self {
|
||||
id,
|
||||
callback: Box::new(callback),
|
||||
context,
|
||||
};
|
||||
adapter.register_tree();
|
||||
if let Some(id) = focus_id {
|
||||
adapter.emit_object_event(id, ObjectEvent::StateChanged(State::Focused, true));
|
||||
}
|
||||
adapter
|
||||
}
|
||||
|
||||
fn register_tree(&self) {
|
||||
fn add_children(node: Node<'_>, to_add: &mut Vec<(NodeId, InterfaceSet)>) {
|
||||
for child in node.filtered_children(&filter) {
|
||||
let child_id = child.id();
|
||||
let wrapper = NodeWrapper(&child);
|
||||
let interfaces = wrapper.interfaces();
|
||||
to_add.push((child_id, interfaces));
|
||||
add_children(child, to_add);
|
||||
}
|
||||
}
|
||||
|
||||
let mut objects_to_add = Vec::new();
|
||||
|
||||
let (adapter_index, root_id) = {
|
||||
let tree = self.context.read_tree();
|
||||
let tree_state = tree.state();
|
||||
let mut app_context = self.context.write_app_context();
|
||||
app_context.toolkit_name = Some(tree_state.toolkit_name().to_string());
|
||||
app_context.toolkit_version = tree_state.toolkit_version().map(|s| s.to_string());
|
||||
let adapter_index = app_context.adapter_index(self.id).unwrap();
|
||||
let root = tree_state.root();
|
||||
let root_id = root.id();
|
||||
let wrapper = NodeWrapper(&root);
|
||||
objects_to_add.push((root_id, wrapper.interfaces()));
|
||||
add_children(root, &mut objects_to_add);
|
||||
(adapter_index, root_id)
|
||||
};
|
||||
|
||||
for (id, interfaces) in objects_to_add {
|
||||
self.register_interfaces(id, interfaces);
|
||||
if id == root_id {
|
||||
self.window_created(adapter_index, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn platform_node(&self, id: NodeId) -> PlatformNode {
|
||||
PlatformNode::new(&self.context, self.id, id)
|
||||
}
|
||||
|
||||
pub fn root_id(&self) -> NodeId {
|
||||
self.context.read_tree().state().root_id()
|
||||
}
|
||||
|
||||
pub fn platform_root(&self) -> PlatformRoot {
|
||||
PlatformRoot::new(&self.context.app_context)
|
||||
}
|
||||
|
||||
fn register_interfaces(&self, id: NodeId, new_interfaces: InterfaceSet) {
|
||||
self.callback.register_interfaces(self, id, new_interfaces);
|
||||
}
|
||||
|
||||
fn unregister_interfaces(&self, id: NodeId, old_interfaces: InterfaceSet) {
|
||||
self.callback
|
||||
.unregister_interfaces(self, id, old_interfaces);
|
||||
}
|
||||
|
||||
pub(crate) fn emit_object_event(&self, target: NodeId, event: ObjectEvent) {
|
||||
let target = NodeIdOrRoot::Node(target);
|
||||
self.callback
|
||||
.emit_event(self, Event::Object { target, event });
|
||||
}
|
||||
|
||||
fn emit_root_object_event(&self, event: ObjectEvent) {
|
||||
let target = NodeIdOrRoot::Root;
|
||||
self.callback
|
||||
.emit_event(self, Event::Object { target, event });
|
||||
}
|
||||
|
||||
fn emit_cache_added(&self, target: NodeId) {
|
||||
self.callback
|
||||
.emit_event(self, Event::Cache(CacheEvent::Added(target)));
|
||||
}
|
||||
|
||||
fn emit_cache_removed(&self, target: NodeId) {
|
||||
self.callback
|
||||
.emit_event(self, Event::Cache(CacheEvent::Removed(target)));
|
||||
}
|
||||
|
||||
pub fn set_root_window_bounds(&mut self, new_bounds: WindowBounds) {
|
||||
let mut bounds = self.context.root_window_bounds.write().unwrap();
|
||||
*bounds = new_bounds;
|
||||
}
|
||||
|
||||
pub fn update(&mut self, update: TreeUpdate) {
|
||||
let mut handler = AdapterChangeHandler::new(self);
|
||||
let mut tree = self.context.tree.write().unwrap();
|
||||
tree.update_and_process_changes(update, &mut handler);
|
||||
drop(tree);
|
||||
handler.emit_selection_changed();
|
||||
}
|
||||
|
||||
pub fn update_window_focus_state(&mut self, is_focused: bool) {
|
||||
let mut handler = AdapterChangeHandler::new(self);
|
||||
let mut tree = self.context.tree.write().unwrap();
|
||||
tree.update_host_focus_state_and_process_changes(is_focused, &mut handler);
|
||||
}
|
||||
|
||||
fn window_created(&self, adapter_index: usize, window: NodeId) {
|
||||
self.emit_root_object_event(ObjectEvent::ChildAdded(adapter_index, window));
|
||||
}
|
||||
|
||||
fn window_activated(&self, window: &NodeWrapper<'_>) {
|
||||
self.callback.emit_event(
|
||||
self,
|
||||
Event::Window {
|
||||
target: window.id(),
|
||||
name: window.name().unwrap_or_default(),
|
||||
event: WindowEvent::Activated,
|
||||
},
|
||||
);
|
||||
self.emit_object_event(window.id(), ObjectEvent::StateChanged(State::Active, true));
|
||||
self.emit_root_object_event(ObjectEvent::ActiveDescendantChanged(window.id()));
|
||||
}
|
||||
|
||||
fn window_deactivated(&self, window: &NodeWrapper<'_>) {
|
||||
self.callback.emit_event(
|
||||
self,
|
||||
Event::Window {
|
||||
target: window.id(),
|
||||
name: window.name().unwrap_or_default(),
|
||||
event: WindowEvent::Deactivated,
|
||||
},
|
||||
);
|
||||
self.emit_object_event(window.id(), ObjectEvent::StateChanged(State::Active, false));
|
||||
}
|
||||
|
||||
fn window_destroyed(&self, window: NodeId) {
|
||||
self.emit_root_object_event(ObjectEvent::ChildRemoved(window));
|
||||
}
|
||||
|
||||
pub fn id(&self) -> usize {
|
||||
self.id
|
||||
}
|
||||
|
||||
pub fn is_window_focused(&self) -> bool {
|
||||
self.context.read_tree().state().is_host_focused()
|
||||
}
|
||||
|
||||
pub fn root_window_bounds(&self) -> WindowBounds {
|
||||
*self.context.read_root_window_bounds()
|
||||
}
|
||||
|
||||
/// This is an implementation detail of `accesskit_unix`, required for
|
||||
/// robust state transitions with minimal overhead.
|
||||
pub fn wrapped_action_handler(&self) -> Arc<dyn ActionHandlerNoMut + Send + Sync> {
|
||||
Arc::clone(&self.context.action_handler)
|
||||
}
|
||||
}
|
||||
|
||||
fn root_window(current_state: &TreeState) -> Option<Node<'_>> {
|
||||
const WINDOW_ROLES: &[Role] = &[Role::AlertDialog, Role::Dialog, Role::Window];
|
||||
let root = current_state.root();
|
||||
if WINDOW_ROLES.contains(&root.role()) {
|
||||
Some(root)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Adapter {
|
||||
fn drop(&mut self) {
|
||||
let root_id = self.context.read_tree().state().root_id();
|
||||
self.window_destroyed(root_id);
|
||||
// Note: We deliberately do the following here, not in a Drop
|
||||
// implementation on context, because AppContext owns a second
|
||||
// strong reference to Context, and we need that to be released.
|
||||
self.context.write_app_context().remove_adapter(self.id);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Adapter;
|
||||
use crate::{AdapterCallback, AppContext, CacheEvent, Event, InterfaceSet, WindowBounds};
|
||||
use accesskit::{
|
||||
ActionHandler, ActionRequest, Node, NodeId as LocalNodeId, Role, Tree, TreeId, TreeUpdate,
|
||||
};
|
||||
use accesskit_consumer::NodeId;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
enum CacheOp {
|
||||
Added(NodeId),
|
||||
Removed(NodeId),
|
||||
}
|
||||
|
||||
struct CapturingCallback {
|
||||
ops: Arc<Mutex<Vec<CacheOp>>>,
|
||||
}
|
||||
|
||||
impl AdapterCallback for CapturingCallback {
|
||||
fn register_interfaces(&self, _: &Adapter, _: NodeId, _: InterfaceSet) {}
|
||||
fn unregister_interfaces(&self, _: &Adapter, _: NodeId, _: InterfaceSet) {}
|
||||
fn emit_event(&self, _: &Adapter, event: Event) {
|
||||
let mut ops = self.ops.lock().unwrap();
|
||||
match event {
|
||||
Event::Cache(CacheEvent::Added(id)) => ops.push(CacheOp::Added(id)),
|
||||
Event::Cache(CacheEvent::Removed(id)) => ops.push(CacheOp::Removed(id)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct NoOpActionHandler;
|
||||
impl ActionHandler for NoOpActionHandler {
|
||||
fn do_action(&mut self, _request: ActionRequest) {}
|
||||
}
|
||||
|
||||
fn with_children(role: Role, children: &[LocalNodeId]) -> Node {
|
||||
let mut node = Node::new(role);
|
||||
node.set_children(children.to_vec());
|
||||
node
|
||||
}
|
||||
|
||||
fn build(initial: TreeUpdate) -> (Adapter, Arc<Mutex<Vec<CacheOp>>>) {
|
||||
let ops = Arc::new(Mutex::new(Vec::new()));
|
||||
let app_context = AppContext::new(None);
|
||||
let adapter = Adapter::new(
|
||||
&app_context,
|
||||
CapturingCallback { ops: ops.clone() },
|
||||
initial,
|
||||
false,
|
||||
WindowBounds::default(),
|
||||
NoOpActionHandler,
|
||||
);
|
||||
(adapter, ops)
|
||||
}
|
||||
|
||||
fn initial_tree() -> TreeUpdate {
|
||||
TreeUpdate {
|
||||
nodes: vec![
|
||||
(
|
||||
LocalNodeId(0),
|
||||
with_children(Role::Window, &[LocalNodeId(1)]),
|
||||
),
|
||||
(LocalNodeId(1), Node::new(Role::Button)),
|
||||
],
|
||||
tree: Some(Tree::new(LocalNodeId(0))),
|
||||
tree_id: TreeId::ROOT,
|
||||
focus: LocalNodeId(0),
|
||||
}
|
||||
}
|
||||
|
||||
fn update(nodes: Vec<(LocalNodeId, Node)>) -> TreeUpdate {
|
||||
TreeUpdate {
|
||||
nodes,
|
||||
tree: None,
|
||||
tree_id: TreeId::ROOT,
|
||||
focus: LocalNodeId(0),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_cache_events_on_construction() {
|
||||
let (_adapter, ops) = build(initial_tree());
|
||||
assert!(ops.lock().unwrap().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_node_emits_one_added() {
|
||||
let (mut adapter, ops) = build(initial_tree());
|
||||
ops.lock().unwrap().clear();
|
||||
adapter.update(update(vec![
|
||||
(
|
||||
LocalNodeId(0),
|
||||
with_children(Role::Window, &[LocalNodeId(1), LocalNodeId(2)]),
|
||||
),
|
||||
(LocalNodeId(2), Node::new(Role::Button)),
|
||||
]));
|
||||
let ops = ops.lock().unwrap();
|
||||
assert_eq!(ops.len(), 1);
|
||||
assert!(matches!(ops[0], CacheOp::Added(_)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_node_emits_removed_for_same_id() {
|
||||
let (mut adapter, ops) = build(initial_tree());
|
||||
adapter.update(update(vec![
|
||||
(
|
||||
LocalNodeId(0),
|
||||
with_children(Role::Window, &[LocalNodeId(1), LocalNodeId(2)]),
|
||||
),
|
||||
(LocalNodeId(2), Node::new(Role::Button)),
|
||||
]));
|
||||
let added_id = match ops.lock().unwrap().as_slice() {
|
||||
[CacheOp::Added(id)] => *id,
|
||||
other => panic!("expected exactly one Added, got {other:?}"),
|
||||
};
|
||||
ops.lock().unwrap().clear();
|
||||
adapter.update(update(vec![(
|
||||
LocalNodeId(0),
|
||||
with_children(Role::Window, &[LocalNodeId(1)]),
|
||||
)]));
|
||||
assert_eq!(*ops.lock().unwrap(), vec![CacheOp::Removed(added_id)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn subtree_add_emits_added_per_node() {
|
||||
let (mut adapter, ops) = build(initial_tree());
|
||||
ops.lock().unwrap().clear();
|
||||
adapter.update(update(vec![
|
||||
(
|
||||
LocalNodeId(0),
|
||||
with_children(Role::Window, &[LocalNodeId(1), LocalNodeId(2)]),
|
||||
),
|
||||
(
|
||||
LocalNodeId(2),
|
||||
with_children(Role::Group, &[LocalNodeId(3), LocalNodeId(4)]),
|
||||
),
|
||||
(LocalNodeId(3), Node::new(Role::Button)),
|
||||
(LocalNodeId(4), Node::new(Role::Button)),
|
||||
]));
|
||||
let ops = ops.lock().unwrap();
|
||||
assert_eq!(ops.len(), 3);
|
||||
assert!(ops.iter().all(|op| matches!(op, CacheOp::Added(_))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn subtree_remove_emits_removed_per_node() {
|
||||
let (mut adapter, ops) = build(initial_tree());
|
||||
adapter.update(update(vec![
|
||||
(
|
||||
LocalNodeId(0),
|
||||
with_children(Role::Window, &[LocalNodeId(1), LocalNodeId(2)]),
|
||||
),
|
||||
(
|
||||
LocalNodeId(2),
|
||||
with_children(Role::Group, &[LocalNodeId(3), LocalNodeId(4)]),
|
||||
),
|
||||
(LocalNodeId(3), Node::new(Role::Button)),
|
||||
(LocalNodeId(4), Node::new(Role::Button)),
|
||||
]));
|
||||
ops.lock().unwrap().clear();
|
||||
adapter.update(update(vec![(
|
||||
LocalNodeId(0),
|
||||
with_children(Role::Window, &[LocalNodeId(1)]),
|
||||
)]));
|
||||
let ops = ops.lock().unwrap();
|
||||
assert_eq!(ops.len(), 3);
|
||||
assert!(ops.iter().all(|op| matches!(op, CacheOp::Removed(_))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn filter_transition_into_tree_emits_added() {
|
||||
let mut hidden = Node::new(Role::Button);
|
||||
hidden.set_hidden();
|
||||
let (mut adapter, ops) = build(TreeUpdate {
|
||||
nodes: vec![
|
||||
(
|
||||
LocalNodeId(0),
|
||||
with_children(Role::Window, &[LocalNodeId(1), LocalNodeId(2)]),
|
||||
),
|
||||
(LocalNodeId(1), Node::new(Role::Button)),
|
||||
(LocalNodeId(2), hidden),
|
||||
],
|
||||
tree: Some(Tree::new(LocalNodeId(0))),
|
||||
tree_id: TreeId::ROOT,
|
||||
focus: LocalNodeId(0),
|
||||
});
|
||||
ops.lock().unwrap().clear();
|
||||
adapter.update(update(vec![(LocalNodeId(2), Node::new(Role::Button))]));
|
||||
let ops = ops.lock().unwrap();
|
||||
assert_eq!(ops.len(), 1);
|
||||
assert!(matches!(ops[0], CacheOp::Added(_)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn filter_transition_out_of_tree_emits_removed() {
|
||||
let (mut adapter, ops) = build(initial_tree());
|
||||
ops.lock().unwrap().clear();
|
||||
let mut hidden = Node::new(Role::Button);
|
||||
hidden.set_hidden();
|
||||
adapter.update(update(vec![(LocalNodeId(1), hidden)]));
|
||||
let ops = ops.lock().unwrap();
|
||||
assert_eq!(ops.len(), 1);
|
||||
assert!(matches!(ops[0], CacheOp::Removed(_)));
|
||||
}
|
||||
}
|
||||
15
patches/accesskit_atspi_common/src/callback.rs
vendored
Normal file
15
patches/accesskit_atspi_common/src/callback.rs
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// 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_consumer::NodeId;
|
||||
use atspi_common::InterfaceSet;
|
||||
|
||||
use crate::{Adapter, Event};
|
||||
|
||||
pub trait AdapterCallback {
|
||||
fn register_interfaces(&self, adapter: &Adapter, id: NodeId, interfaces: InterfaceSet);
|
||||
fn unregister_interfaces(&self, adapter: &Adapter, id: NodeId, interfaces: InterfaceSet);
|
||||
fn emit_event(&self, adapter: &Adapter, event: Event);
|
||||
}
|
||||
122
patches/accesskit_atspi_common/src/context.rs
vendored
Normal file
122
patches/accesskit_atspi_common/src/context.rs
vendored
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
// 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::{ActionHandler, ActionRequest};
|
||||
use accesskit_consumer::Tree;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::sync::{Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
|
||||
use crate::WindowBounds;
|
||||
|
||||
/// This is an implementation detail of `accesskit_unix`, required for robust
|
||||
/// state transitions with minimal overhead.
|
||||
pub trait ActionHandlerNoMut {
|
||||
fn do_action(&self, request: ActionRequest);
|
||||
}
|
||||
|
||||
/// This is an implementation detail of `accesskit_unix`, required for robust
|
||||
/// state transitions with minimal overhead.
|
||||
pub struct ActionHandlerWrapper<H: ActionHandler + Send>(Mutex<H>);
|
||||
|
||||
impl<H: 'static + ActionHandler + Send> ActionHandlerWrapper<H> {
|
||||
pub fn new(inner: H) -> Self {
|
||||
Self(Mutex::new(inner))
|
||||
}
|
||||
}
|
||||
|
||||
impl<H: ActionHandler + Send> ActionHandlerNoMut for ActionHandlerWrapper<H> {
|
||||
fn do_action(&self, request: ActionRequest) {
|
||||
self.0.lock().unwrap().do_action(request)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct Context {
|
||||
pub(crate) app_context: Arc<RwLock<AppContext>>,
|
||||
pub(crate) tree: RwLock<Tree>,
|
||||
pub(crate) action_handler: Arc<dyn ActionHandlerNoMut + Send + Sync>,
|
||||
pub(crate) root_window_bounds: RwLock<WindowBounds>,
|
||||
}
|
||||
|
||||
impl Debug for Context {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("Context")
|
||||
.field("app_context", &self.app_context)
|
||||
.field("tree", &self.tree)
|
||||
.field("action_handler", &"ActionHandler")
|
||||
.field("root_window_bounds", &self.root_window_bounds)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl Context {
|
||||
pub(crate) fn new(
|
||||
app_context: &Arc<RwLock<AppContext>>,
|
||||
tree: Tree,
|
||||
action_handler: Arc<dyn ActionHandlerNoMut + Send + Sync>,
|
||||
root_window_bounds: WindowBounds,
|
||||
) -> Arc<Self> {
|
||||
Arc::new(Self {
|
||||
app_context: Arc::clone(app_context),
|
||||
tree: RwLock::new(tree),
|
||||
action_handler,
|
||||
root_window_bounds: RwLock::new(root_window_bounds),
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn read_tree(&self) -> RwLockReadGuard<'_, Tree> {
|
||||
self.tree.read().unwrap()
|
||||
}
|
||||
|
||||
pub(crate) fn read_root_window_bounds(&self) -> RwLockReadGuard<'_, WindowBounds> {
|
||||
self.root_window_bounds.read().unwrap()
|
||||
}
|
||||
|
||||
pub fn do_action(&self, request: ActionRequest) {
|
||||
self.action_handler.do_action(request);
|
||||
}
|
||||
|
||||
pub(crate) fn read_app_context(&self) -> RwLockReadGuard<'_, AppContext> {
|
||||
self.app_context.read().unwrap()
|
||||
}
|
||||
|
||||
pub(crate) fn write_app_context(&self) -> RwLockWriteGuard<'_, AppContext> {
|
||||
self.app_context.write().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AppContext {
|
||||
pub(crate) name: Option<String>,
|
||||
pub(crate) toolkit_name: Option<String>,
|
||||
pub(crate) toolkit_version: Option<String>,
|
||||
pub(crate) id: Option<i32>,
|
||||
pub(crate) adapters: Vec<(usize, Arc<Context>)>,
|
||||
}
|
||||
|
||||
impl AppContext {
|
||||
pub fn new(name: Option<String>) -> Arc<RwLock<Self>> {
|
||||
Arc::new(RwLock::new(Self {
|
||||
name,
|
||||
toolkit_name: None,
|
||||
toolkit_version: None,
|
||||
id: None,
|
||||
adapters: Vec::new(),
|
||||
}))
|
||||
}
|
||||
|
||||
pub(crate) fn adapter_index(&self, id: usize) -> Result<usize, usize> {
|
||||
self.adapters.binary_search_by(|adapter| adapter.0.cmp(&id))
|
||||
}
|
||||
|
||||
pub(crate) fn push_adapter(&mut self, id: usize, context: &Arc<Context>) {
|
||||
self.adapters.push((id, Arc::clone(context)));
|
||||
}
|
||||
|
||||
pub(crate) fn remove_adapter(&mut self, id: usize) {
|
||||
if let Ok(index) = self.adapter_index(id) {
|
||||
self.adapters.remove(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
patches/accesskit_atspi_common/src/error.rs
vendored
Normal file
33
patches/accesskit_atspi_common/src/error.rs
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2022 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 std::fmt;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
Defunct,
|
||||
UnsupportedInterface,
|
||||
TooManyChildren,
|
||||
IndexOutOfRange,
|
||||
TooManyCharacters,
|
||||
UnsupportedTextGranularity,
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str(match self {
|
||||
Self::Defunct => "defunct",
|
||||
Self::UnsupportedInterface => "unsupported interface",
|
||||
Self::TooManyChildren => "too many children",
|
||||
Self::IndexOutOfRange => "index out of range",
|
||||
Self::TooManyCharacters => "too many characters",
|
||||
Self::UnsupportedTextGranularity => "unsupported text granularity",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
69
patches/accesskit_atspi_common/src/events.rs
vendored
Normal file
69
patches/accesskit_atspi_common/src/events.rs
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
// Copyright 2022 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_consumer::NodeId;
|
||||
use atspi_common::{Politeness, Role, State};
|
||||
|
||||
use crate::{NodeIdOrRoot, Rect};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Event {
|
||||
Object {
|
||||
target: NodeIdOrRoot,
|
||||
event: ObjectEvent,
|
||||
},
|
||||
Window {
|
||||
target: NodeId,
|
||||
name: String,
|
||||
event: WindowEvent,
|
||||
},
|
||||
Cache(CacheEvent),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum CacheEvent {
|
||||
Added(NodeId),
|
||||
Removed(NodeId),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Property {
|
||||
Name(String),
|
||||
Description(String),
|
||||
Parent(NodeIdOrRoot),
|
||||
Role(Role),
|
||||
Value(f64),
|
||||
}
|
||||
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
#[derive(Debug)]
|
||||
pub enum ObjectEvent {
|
||||
ActiveDescendantChanged(NodeId),
|
||||
Announcement(String, Politeness),
|
||||
BoundsChanged(Rect),
|
||||
CaretMoved(i32),
|
||||
ChildAdded(usize, NodeId),
|
||||
ChildRemoved(NodeId),
|
||||
PropertyChanged(Property),
|
||||
SelectionChanged,
|
||||
StateChanged(State, bool),
|
||||
TextInserted {
|
||||
start_index: i32,
|
||||
length: i32,
|
||||
content: String,
|
||||
},
|
||||
TextRemoved {
|
||||
start_index: i32,
|
||||
length: i32,
|
||||
content: String,
|
||||
},
|
||||
TextSelectionChanged,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum WindowEvent {
|
||||
Activated,
|
||||
Deactivated,
|
||||
}
|
||||
6
patches/accesskit_atspi_common/src/filters.rs
vendored
Normal file
6
patches/accesskit_atspi_common/src/filters.rs
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// 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.
|
||||
|
||||
pub(crate) use accesskit_consumer::common_filter as filter;
|
||||
33
patches/accesskit_atspi_common/src/lib.rs
vendored
Normal file
33
patches/accesskit_atspi_common/src/lib.rs
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2022 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 action;
|
||||
mod adapter;
|
||||
mod callback;
|
||||
mod context;
|
||||
mod error;
|
||||
mod events;
|
||||
mod filters;
|
||||
mod node;
|
||||
mod rect;
|
||||
#[cfg(feature = "simplified-api")]
|
||||
pub mod simplified;
|
||||
mod text_attributes;
|
||||
mod util;
|
||||
|
||||
pub use accesskit_consumer::NodeId;
|
||||
pub use atspi_common::{
|
||||
CoordType, Granularity, InterfaceSet, Layer, RelationType, Role, ScrollType, State, StateSet,
|
||||
};
|
||||
|
||||
pub use action::*;
|
||||
pub use adapter::{Adapter, next_adapter_id};
|
||||
pub use callback::AdapterCallback;
|
||||
pub use context::{ActionHandlerNoMut, ActionHandlerWrapper, AppContext};
|
||||
pub use error::*;
|
||||
pub use events::*;
|
||||
pub use node::{CacheNode, NodeIdOrRoot, PlatformNode, PlatformRoot};
|
||||
pub use rect::*;
|
||||
pub use util::WindowBounds;
|
||||
1944
patches/accesskit_atspi_common/src/node.rs
vendored
Normal file
1944
patches/accesskit_atspi_common/src/node.rs
vendored
Normal file
File diff suppressed because it is too large
Load diff
37
patches/accesskit_atspi_common/src/rect.rs
vendored
Normal file
37
patches/accesskit_atspi_common/src/rect.rs
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2022 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 serde::{Deserialize, Serialize};
|
||||
use zbus::wire::{OwnedVariant as OwnedValue, Type, Variant as Value};
|
||||
|
||||
#[derive(
|
||||
Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, OwnedValue, Type, Value,
|
||||
)]
|
||||
pub struct Rect {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
}
|
||||
|
||||
impl Rect {
|
||||
pub const INVALID: Rect = Rect {
|
||||
x: -1,
|
||||
y: -1,
|
||||
width: -1,
|
||||
height: -1,
|
||||
};
|
||||
}
|
||||
|
||||
impl From<accesskit::Rect> for Rect {
|
||||
fn from(value: accesskit::Rect) -> Rect {
|
||||
Rect {
|
||||
x: value.x0 as i32,
|
||||
y: value.y0 as i32,
|
||||
width: value.width() as i32,
|
||||
height: value.height() as i32,
|
||||
}
|
||||
}
|
||||
}
|
||||
901
patches/accesskit_atspi_common/src/simplified.rs
vendored
Normal file
901
patches/accesskit_atspi_common/src/simplified.rs
vendored
Normal file
|
|
@ -0,0 +1,901 @@
|
|||
// Copyright 2024 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.
|
||||
|
||||
//! API that corresponds more closely to the libatspi client API,
|
||||
//! intended to be used by bindings to languages with less rich
|
||||
//! type systems.
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
Adapter, CacheEvent, Event as EventEnum, NodeIdOrRoot, ObjectEvent, PlatformNode, PlatformRoot,
|
||||
Property, WindowEvent,
|
||||
};
|
||||
|
||||
pub use crate::{
|
||||
CoordType, Error, Granularity, Layer, Rect, RelationType, Result, Role, ScrollType, StateSet,
|
||||
};
|
||||
|
||||
#[derive(Clone, Hash, PartialEq)]
|
||||
pub enum Accessible {
|
||||
Node(PlatformNode),
|
||||
Root(PlatformRoot),
|
||||
}
|
||||
|
||||
impl Accessible {
|
||||
pub fn role(&self) -> Result<Role> {
|
||||
match self {
|
||||
Self::Node(node) => node.role(),
|
||||
Self::Root(root) => Ok(root.role()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn localized_role_name(&self) -> Result<String> {
|
||||
match self {
|
||||
Self::Node(node) => node.localized_role_name(),
|
||||
Self::Root(_) => Ok("".into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> Result<String> {
|
||||
match self {
|
||||
Self::Node(node) => node.name(),
|
||||
Self::Root(root) => root.name(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn description(&self) -> Result<String> {
|
||||
match self {
|
||||
Self::Node(node) => node.description(),
|
||||
Self::Root(root) => root.description(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn state(&self) -> StateSet {
|
||||
match self {
|
||||
Self::Node(node) => node.state(),
|
||||
Self::Root(root) => root.state(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn attributes(&self) -> Result<HashMap<&'static str, String>> {
|
||||
match self {
|
||||
Self::Node(node) => node.attributes(),
|
||||
Self::Root(_) => Ok(HashMap::new()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parent(&self) -> Result<Option<Self>> {
|
||||
match self {
|
||||
Self::Node(node) => match node.parent()? {
|
||||
NodeIdOrRoot::Node(id) => Ok(Some(Self::Node(node.relative(id)))),
|
||||
NodeIdOrRoot::Root => node.root().map(|root| Some(Self::Root(root))),
|
||||
},
|
||||
Self::Root(_) => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn index_in_parent(&self) -> Result<i32> {
|
||||
match self {
|
||||
Self::Node(node) => node.index_in_parent(),
|
||||
Self::Root(root) => Ok(root.index_in_parent()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn child_count(&self) -> Result<i32> {
|
||||
match self {
|
||||
Self::Node(node) => node.child_count(),
|
||||
Self::Root(root) => root.child_count(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn accessible_id(&self) -> Result<String> {
|
||||
match self {
|
||||
Self::Node(node) => node.accessible_id(),
|
||||
Self::Root(_) => Ok(String::new()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn child_at_index(&self, index: usize) -> Result<Option<Self>> {
|
||||
match self {
|
||||
Self::Node(node) => node
|
||||
.child_at_index(index)
|
||||
.map(|id| id.map(|id| Self::Node(node.relative(id)))),
|
||||
Self::Root(root) => root
|
||||
.child_at_index(index)
|
||||
.map(|child| child.map(Self::Node)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_children<T, I>(&self, f: impl Fn(Self) -> I) -> Result<T>
|
||||
where
|
||||
T: FromIterator<I>,
|
||||
{
|
||||
match self {
|
||||
Self::Node(node) => node.map_children(|id| f(Self::Node(node.relative(id)))),
|
||||
Self::Root(root) => root.map_children(|node| f(Self::Node(node))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn relation_set(&self) -> Result<HashMap<RelationType, Vec<Self>>> {
|
||||
match self {
|
||||
Self::Node(node) => node.relation_set(|id| Self::Node(node.relative(id))),
|
||||
Self::Root(_) => Ok(HashMap::new()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn application(&self) -> Result<Self> {
|
||||
match self {
|
||||
Self::Node(node) => node.root().map(Self::Root),
|
||||
Self::Root(root) => Ok(Self::Root(root.clone())),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toolkit_name(&self) -> Result<String> {
|
||||
match self {
|
||||
Self::Node(node) => node.toolkit_name(),
|
||||
Self::Root(root) => root.toolkit_name(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toolkit_version(&self) -> Result<String> {
|
||||
match self {
|
||||
Self::Node(node) => node.toolkit_version(),
|
||||
Self::Root(root) => root.toolkit_version(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn supports_action(&self) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.supports_action(),
|
||||
Self::Root(_) => Ok(false),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn n_actions(&self) -> Result<i32> {
|
||||
match self {
|
||||
Self::Node(node) => node.n_actions(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn action_name(&self, index: i32) -> Result<String> {
|
||||
match self {
|
||||
Self::Node(node) => node.action_name(index),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn do_action(&self, index: i32) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.do_action(index),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn supports_component(&self) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.supports_component(),
|
||||
Self::Root(_) => Ok(false),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn contains(&self, x: i32, y: i32, coord_type: CoordType) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.contains(x, y, coord_type),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn accessible_at_point(
|
||||
&self,
|
||||
x: i32,
|
||||
y: i32,
|
||||
coord_type: CoordType,
|
||||
) -> Result<Option<Self>> {
|
||||
match self {
|
||||
Self::Node(node) => node
|
||||
.accessible_at_point(x, y, coord_type)
|
||||
.map(|id| id.map(|id| Self::Node(node.relative(id)))),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn extents(&self, coord_type: CoordType) -> Result<Rect> {
|
||||
match self {
|
||||
Self::Node(node) => node.extents(coord_type),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn layer(&self) -> Result<Layer> {
|
||||
match self {
|
||||
Self::Node(node) => node.layer(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn grab_focus(&self) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.grab_focus(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scroll_to(&self, scroll_type: ScrollType) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.scroll_to(scroll_type),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scroll_to_point(&self, coord_type: CoordType, x: i32, y: i32) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.scroll_to_point(coord_type, x, y),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn supports_hyperlink(&self) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.supports_hyperlink(),
|
||||
Self::Root(_) => Ok(false),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn n_anchors(&self) -> Result<i32> {
|
||||
match self {
|
||||
Self::Node(node) => node.n_anchors(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hyperlink_start_index(&self) -> Result<i32> {
|
||||
match self {
|
||||
Self::Node(node) => node.hyperlink_start_index(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hyperlink_end_index(&self) -> Result<i32> {
|
||||
match self {
|
||||
Self::Node(node) => node.hyperlink_end_index(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hyperlink_object(&self, index: i32) -> Result<Option<Self>> {
|
||||
match self {
|
||||
Self::Node(node) => node
|
||||
.hyperlink_object(index)
|
||||
.map(|id| id.map(|id| Self::Node(node.relative(id)))),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn uri(&self, index: i32) -> Result<String> {
|
||||
match self {
|
||||
Self::Node(node) => node.uri(index),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hyperlink_is_valid(&self) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.hyperlink_is_valid(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn supports_selection(&self) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.supports_selection(),
|
||||
Self::Root(_) => Ok(false),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn n_selected_children(&self) -> Result<i32> {
|
||||
match self {
|
||||
Self::Node(node) => node.n_selected_children(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn selected_child(&self, selected_child_index: usize) -> Result<Option<Self>> {
|
||||
match self {
|
||||
Self::Node(node) => node
|
||||
.selected_child(selected_child_index)
|
||||
.map(|id| id.map(|id| Self::Node(node.relative(id)))),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn select_child(&self, child_index: usize) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.select_child(child_index),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deselect_selected_child(&self, selected_child_index: usize) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.deselect_selected_child(selected_child_index),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_child_selected(&self, child_index: usize) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.is_child_selected(child_index),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn select_all(&self) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.select_all(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear_selection(&self) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.clear_selection(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deselect_child(&self, child_index: usize) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.deselect_child(child_index),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn supports_text(&self) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.supports_text(),
|
||||
Self::Root(_) => Ok(false),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn character_count(&self) -> Result<i32> {
|
||||
match self {
|
||||
Self::Node(node) => node.character_count(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn caret_offset(&self) -> Result<i32> {
|
||||
match self {
|
||||
Self::Node(node) => node.caret_offset(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn string_at_offset(
|
||||
&self,
|
||||
offset: i32,
|
||||
granularity: Granularity,
|
||||
) -> Result<(String, i32, i32)> {
|
||||
match self {
|
||||
Self::Node(node) => node.string_at_offset(offset, granularity),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn text(&self, start_offset: i32, end_offset: i32) -> Result<String> {
|
||||
match self {
|
||||
Self::Node(node) => node.text(start_offset, end_offset),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_caret_offset(&self, offset: i32) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.set_caret_offset(offset),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn text_attribute_value(&self, offset: i32, attribute_name: &str) -> Result<String> {
|
||||
match self {
|
||||
Self::Node(node) => node.text_attribute_value(offset, attribute_name),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn text_attributes(
|
||||
&self,
|
||||
offset: i32,
|
||||
) -> Result<(HashMap<&'static str, String>, i32, i32)> {
|
||||
match self {
|
||||
Self::Node(node) => node.text_attributes(offset),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_text_attributes(&self) -> Result<HashMap<&'static str, String>> {
|
||||
match self {
|
||||
Self::Node(node) => node.default_text_attributes(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn character_extents(&self, offset: i32, coord_type: CoordType) -> Result<Rect> {
|
||||
match self {
|
||||
Self::Node(node) => node.character_extents(offset, coord_type),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn offset_at_point(&self, x: i32, y: i32, coord_type: CoordType) -> Result<i32> {
|
||||
match self {
|
||||
Self::Node(node) => node.offset_at_point(x, y, coord_type),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn n_selections(&self) -> Result<i32> {
|
||||
match self {
|
||||
Self::Node(node) => node.n_selections(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn selection(&self, selection_num: i32) -> Result<(i32, i32)> {
|
||||
match self {
|
||||
Self::Node(node) => node.selection(selection_num),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_selection(&self, start_offset: i32, end_offset: i32) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.add_selection(start_offset, end_offset),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_selection(&self, selection_num: i32) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.remove_selection(selection_num),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_selection(
|
||||
&self,
|
||||
selection_num: i32,
|
||||
start_offset: i32,
|
||||
end_offset: i32,
|
||||
) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.set_selection(selection_num, start_offset, end_offset),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn range_extents(
|
||||
&self,
|
||||
start_offset: i32,
|
||||
end_offset: i32,
|
||||
coord_type: CoordType,
|
||||
) -> Result<Rect> {
|
||||
match self {
|
||||
Self::Node(node) => node.range_extents(start_offset, end_offset, coord_type),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn text_attribute_run(
|
||||
&self,
|
||||
offset: i32,
|
||||
include_defaults: bool,
|
||||
) -> Result<(HashMap<&'static str, String>, i32, i32)> {
|
||||
match self {
|
||||
Self::Node(node) => node.text_attribute_run(offset, include_defaults),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scroll_substring_to(
|
||||
&self,
|
||||
start_offset: i32,
|
||||
end_offset: i32,
|
||||
scroll_type: ScrollType,
|
||||
) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.scroll_substring_to(start_offset, end_offset, scroll_type),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scroll_substring_to_point(
|
||||
&self,
|
||||
start_offset: i32,
|
||||
end_offset: i32,
|
||||
coord_type: CoordType,
|
||||
x: i32,
|
||||
y: i32,
|
||||
) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => {
|
||||
node.scroll_substring_to_point(start_offset, end_offset, coord_type, x, y)
|
||||
}
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn supports_value(&self) -> Result<bool> {
|
||||
match self {
|
||||
Self::Node(node) => node.supports_value(),
|
||||
Self::Root(_) => Ok(false),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn minimum_value(&self) -> Result<f64> {
|
||||
match self {
|
||||
Self::Node(node) => node.minimum_value(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn maximum_value(&self) -> Result<f64> {
|
||||
match self {
|
||||
Self::Node(node) => node.maximum_value(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn minimum_increment(&self) -> Result<f64> {
|
||||
match self {
|
||||
Self::Node(node) => node.minimum_increment(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn current_value(&self) -> Result<f64> {
|
||||
match self {
|
||||
Self::Node(node) => node.current_value(),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_current_value(&self, value: f64) -> Result<()> {
|
||||
match self {
|
||||
Self::Node(node) => node.set_current_value(value),
|
||||
Self::Root(_) => Err(Error::UnsupportedInterface),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Cache {
|
||||
root: PlatformRoot,
|
||||
}
|
||||
|
||||
impl Cache {
|
||||
pub fn new(root: PlatformRoot) -> Self {
|
||||
Self { root }
|
||||
}
|
||||
|
||||
pub fn items(&self) -> Result<Vec<Accessible>> {
|
||||
let descendants: Vec<Accessible> = self
|
||||
.root
|
||||
.map_descendants(|node, _, _| Accessible::Node(node))?;
|
||||
let mut items = Vec::with_capacity(descendants.len() + 1);
|
||||
items.push(Accessible::Root(self.root.clone()));
|
||||
items.extend(descendants);
|
||||
Ok(items)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub enum EventData {
|
||||
U32(u32),
|
||||
F64(f64),
|
||||
String(String),
|
||||
Rect(Rect),
|
||||
Accessible(Accessible),
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub struct Event {
|
||||
pub kind: String,
|
||||
pub source: Accessible,
|
||||
pub detail1: i32,
|
||||
pub detail2: i32,
|
||||
pub data: Option<EventData>,
|
||||
}
|
||||
|
||||
impl Event {
|
||||
pub fn new(adapter: &Adapter, event: EventEnum) -> Self {
|
||||
match event {
|
||||
EventEnum::Object { target, event } => {
|
||||
let source = match target {
|
||||
NodeIdOrRoot::Node(target) => Accessible::Node(adapter.platform_node(target)),
|
||||
NodeIdOrRoot::Root => Accessible::Root(adapter.platform_root()),
|
||||
};
|
||||
match event {
|
||||
ObjectEvent::ActiveDescendantChanged(child) => {
|
||||
let child = Accessible::Node(adapter.platform_node(child));
|
||||
Self {
|
||||
kind: "object:active-descendant-changed".into(),
|
||||
source,
|
||||
detail1: 0,
|
||||
detail2: 0,
|
||||
data: Some(EventData::Accessible(child)),
|
||||
}
|
||||
}
|
||||
ObjectEvent::Announcement(message, politeness) => Self {
|
||||
kind: "object:announcement".into(),
|
||||
source,
|
||||
detail1: politeness as i32,
|
||||
detail2: 0,
|
||||
data: Some(EventData::String(message)),
|
||||
},
|
||||
ObjectEvent::BoundsChanged(bounds) => Self {
|
||||
kind: "object:bounds-changed".into(),
|
||||
source,
|
||||
detail1: 0,
|
||||
detail2: 0,
|
||||
data: Some(EventData::Rect(bounds)),
|
||||
},
|
||||
ObjectEvent::CaretMoved(offset) => Self {
|
||||
kind: "object:text-caret-moved".into(),
|
||||
source,
|
||||
detail1: offset,
|
||||
detail2: 0,
|
||||
data: None,
|
||||
},
|
||||
ObjectEvent::ChildAdded(index, child) => {
|
||||
let child = Accessible::Node(adapter.platform_node(child));
|
||||
Self {
|
||||
kind: "object:children-changed:add".into(),
|
||||
source,
|
||||
detail1: index as i32,
|
||||
detail2: 0,
|
||||
data: Some(EventData::Accessible(child)),
|
||||
}
|
||||
}
|
||||
ObjectEvent::ChildRemoved(child) => {
|
||||
let child = Accessible::Node(adapter.platform_node(child));
|
||||
Self {
|
||||
kind: "object:children-changed:remove".into(),
|
||||
source,
|
||||
detail1: -1,
|
||||
detail2: 0,
|
||||
data: Some(EventData::Accessible(child)),
|
||||
}
|
||||
}
|
||||
ObjectEvent::PropertyChanged(property) => Self {
|
||||
kind: match property {
|
||||
Property::Name(_) => "object:property-change:accessible-name",
|
||||
Property::Description(_) => {
|
||||
"object:property-change:accessible-description"
|
||||
}
|
||||
Property::Parent(_) => "object:property-change:accessible-parent",
|
||||
Property::Role(_) => "object:property-change:accessible-role",
|
||||
Property::Value(_) => "object:property-change:accessible-value",
|
||||
}
|
||||
.into(),
|
||||
source,
|
||||
detail1: 0,
|
||||
detail2: 0,
|
||||
data: Some(match property {
|
||||
Property::Name(value) => EventData::String(value),
|
||||
Property::Description(value) => EventData::String(value),
|
||||
Property::Parent(parent) => {
|
||||
let parent = match parent {
|
||||
NodeIdOrRoot::Node(parent) => {
|
||||
Accessible::Node(adapter.platform_node(parent))
|
||||
}
|
||||
NodeIdOrRoot::Root => Accessible::Root(adapter.platform_root()),
|
||||
};
|
||||
EventData::Accessible(parent)
|
||||
}
|
||||
Property::Role(value) => EventData::U32(value as u32),
|
||||
Property::Value(value) => EventData::F64(value),
|
||||
}),
|
||||
},
|
||||
ObjectEvent::SelectionChanged => Self {
|
||||
kind: "object:selection-changed".into(),
|
||||
source,
|
||||
detail1: 0,
|
||||
detail2: 0,
|
||||
data: None,
|
||||
},
|
||||
ObjectEvent::StateChanged(state, value) => Self {
|
||||
kind: format!("object:state-changed:{}", state.to_static_str()),
|
||||
source,
|
||||
detail1: value as i32,
|
||||
detail2: 0,
|
||||
data: None,
|
||||
},
|
||||
ObjectEvent::TextInserted {
|
||||
start_index,
|
||||
length,
|
||||
content,
|
||||
} => Self {
|
||||
kind: "object:text-changed:insert".into(),
|
||||
source,
|
||||
detail1: start_index,
|
||||
detail2: length,
|
||||
data: Some(EventData::String(content)),
|
||||
},
|
||||
ObjectEvent::TextRemoved {
|
||||
start_index,
|
||||
length,
|
||||
content,
|
||||
} => Self {
|
||||
kind: "object:text-changed:delete".into(),
|
||||
source,
|
||||
detail1: start_index,
|
||||
detail2: length,
|
||||
data: Some(EventData::String(content)),
|
||||
},
|
||||
ObjectEvent::TextSelectionChanged => Self {
|
||||
kind: "object:text-selection-changed".into(),
|
||||
source,
|
||||
detail1: 0,
|
||||
detail2: 0,
|
||||
data: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
EventEnum::Window {
|
||||
target,
|
||||
name,
|
||||
event,
|
||||
} => {
|
||||
let kind = match event {
|
||||
WindowEvent::Activated => "window:activate",
|
||||
WindowEvent::Deactivated => "window:deactivate",
|
||||
};
|
||||
let source = Accessible::Node(adapter.platform_node(target));
|
||||
Self {
|
||||
kind: kind.into(),
|
||||
source,
|
||||
detail1: 0,
|
||||
detail2: 0,
|
||||
data: Some(EventData::String(name)),
|
||||
}
|
||||
}
|
||||
EventEnum::Cache(cache_event) => {
|
||||
let (kind, target) = match cache_event {
|
||||
CacheEvent::Added(target) => ("cache:add", target),
|
||||
CacheEvent::Removed(target) => ("cache:remove", target),
|
||||
};
|
||||
Self {
|
||||
kind: kind.into(),
|
||||
source: Accessible::Node(adapter.platform_node(target)),
|
||||
detail1: 0,
|
||||
detail2: 0,
|
||||
data: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{Accessible, Cache, Event as SimplifiedEvent};
|
||||
use crate::{Adapter, AdapterCallback, AppContext, Event, WindowBounds};
|
||||
use accesskit::{
|
||||
ActionHandler, ActionRequest, Node, NodeId as LocalNodeId, Role, Tree, TreeId, TreeUpdate,
|
||||
};
|
||||
use accesskit_consumer::NodeId;
|
||||
use atspi_common::InterfaceSet;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
struct NoOpActionHandler;
|
||||
impl ActionHandler for NoOpActionHandler {
|
||||
fn do_action(&mut self, _request: ActionRequest) {}
|
||||
}
|
||||
|
||||
struct CacheKindCallback {
|
||||
kinds: Arc<Mutex<Vec<String>>>,
|
||||
}
|
||||
|
||||
impl AdapterCallback for CacheKindCallback {
|
||||
fn register_interfaces(&self, _: &Adapter, _: NodeId, _: InterfaceSet) {}
|
||||
fn unregister_interfaces(&self, _: &Adapter, _: NodeId, _: InterfaceSet) {}
|
||||
fn emit_event(&self, adapter: &Adapter, event: Event) {
|
||||
if matches!(event, Event::Cache(_)) {
|
||||
let simplified = SimplifiedEvent::new(adapter, event);
|
||||
self.kinds.lock().unwrap().push(simplified.kind);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct NoOpCallback;
|
||||
impl AdapterCallback for NoOpCallback {
|
||||
fn register_interfaces(&self, _: &Adapter, _: NodeId, _: InterfaceSet) {}
|
||||
fn unregister_interfaces(&self, _: &Adapter, _: NodeId, _: InterfaceSet) {}
|
||||
fn emit_event(&self, _: &Adapter, _: Event) {}
|
||||
}
|
||||
|
||||
fn with_children(role: Role, children: &[LocalNodeId]) -> Node {
|
||||
let mut node = Node::new(role);
|
||||
node.set_children(children.to_vec());
|
||||
node
|
||||
}
|
||||
|
||||
fn initial_tree() -> TreeUpdate {
|
||||
TreeUpdate {
|
||||
nodes: vec![
|
||||
(
|
||||
LocalNodeId(0),
|
||||
with_children(Role::Window, &[LocalNodeId(1)]),
|
||||
),
|
||||
(LocalNodeId(1), Node::new(Role::Button)),
|
||||
],
|
||||
tree: Some(Tree::new(LocalNodeId(0))),
|
||||
tree_id: TreeId::ROOT,
|
||||
focus: LocalNodeId(0),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cache_events_map_to_kind_strings() {
|
||||
let kinds = Arc::new(Mutex::new(Vec::new()));
|
||||
let app_context = AppContext::new(None);
|
||||
let mut adapter = Adapter::new(
|
||||
&app_context,
|
||||
CacheKindCallback {
|
||||
kinds: kinds.clone(),
|
||||
},
|
||||
initial_tree(),
|
||||
false,
|
||||
WindowBounds::default(),
|
||||
NoOpActionHandler,
|
||||
);
|
||||
adapter.update(TreeUpdate {
|
||||
nodes: vec![
|
||||
(
|
||||
LocalNodeId(0),
|
||||
with_children(Role::Window, &[LocalNodeId(1), LocalNodeId(2)]),
|
||||
),
|
||||
(LocalNodeId(2), Node::new(Role::Button)),
|
||||
],
|
||||
tree: None,
|
||||
tree_id: TreeId::ROOT,
|
||||
focus: LocalNodeId(0),
|
||||
});
|
||||
adapter.update(TreeUpdate {
|
||||
nodes: vec![(
|
||||
LocalNodeId(0),
|
||||
with_children(Role::Window, &[LocalNodeId(1)]),
|
||||
)],
|
||||
tree: None,
|
||||
tree_id: TreeId::ROOT,
|
||||
focus: LocalNodeId(0),
|
||||
});
|
||||
assert_eq!(*kinds.lock().unwrap(), vec!["cache:add", "cache:remove"]);
|
||||
}
|
||||
|
||||
fn build_cache() -> (Adapter, Cache) {
|
||||
let app_context = AppContext::new(None);
|
||||
let adapter = Adapter::new(
|
||||
&app_context,
|
||||
NoOpCallback,
|
||||
initial_tree(),
|
||||
false,
|
||||
WindowBounds::default(),
|
||||
NoOpActionHandler,
|
||||
);
|
||||
let cache = Cache::new(adapter.platform_root());
|
||||
(adapter, cache)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn items_prepends_application_root() {
|
||||
let (_adapter, cache) = build_cache();
|
||||
let items = cache.items().unwrap();
|
||||
assert_eq!(items.len(), 3);
|
||||
assert!(matches!(items[0], Accessible::Root(_)));
|
||||
}
|
||||
}
|
||||
79
patches/accesskit_atspi_common/src/text_attributes.rs
vendored
Normal file
79
patches/accesskit_atspi_common/src/text_attributes.rs
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
// Copyright 2026 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::{Color, TextAlign, TextDecorationStyle};
|
||||
use accesskit_consumer::Node;
|
||||
use phf::phf_map;
|
||||
|
||||
fn color_to_string(color: Color) -> String {
|
||||
format!("{},{},{}", color.red, color.green, color.blue)
|
||||
}
|
||||
|
||||
fn family_name(node: &Node) -> Option<String> {
|
||||
node.font_family().map(String::from)
|
||||
}
|
||||
|
||||
fn size(node: &Node) -> Option<String> {
|
||||
node.font_size().map(|value| value.to_string())
|
||||
}
|
||||
|
||||
fn weight(node: &Node) -> Option<String> {
|
||||
node.font_weight().map(|value| value.to_string())
|
||||
}
|
||||
|
||||
fn style(node: &Node) -> Option<String> {
|
||||
node.is_italic().then(|| "italic".into())
|
||||
}
|
||||
|
||||
fn strikethrough(node: &Node) -> Option<String> {
|
||||
node.strikethrough().map(|_| "true".into())
|
||||
}
|
||||
|
||||
fn underline(node: &Node) -> Option<String> {
|
||||
node.underline().map(|deco| {
|
||||
match deco.style {
|
||||
TextDecorationStyle::Double => "double",
|
||||
_ => "single",
|
||||
}
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
fn bg_color(node: &Node) -> Option<String> {
|
||||
node.background_color().map(color_to_string)
|
||||
}
|
||||
|
||||
fn fg_color(node: &Node) -> Option<String> {
|
||||
node.foreground_color().map(color_to_string)
|
||||
}
|
||||
|
||||
fn language(node: &Node) -> Option<String> {
|
||||
node.language().map(String::from)
|
||||
}
|
||||
|
||||
fn justification(node: &Node) -> Option<String> {
|
||||
node.text_align().map(|align| {
|
||||
match align {
|
||||
TextAlign::Left => "left",
|
||||
TextAlign::Center => "center",
|
||||
TextAlign::Right => "right",
|
||||
TextAlign::Justify => "fill",
|
||||
}
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) const ATTRIBUTE_GETTERS: phf::Map<&'static str, fn(&Node) -> Option<String>> = phf_map! {
|
||||
"family-name" => family_name,
|
||||
"size" => size,
|
||||
"weight" => weight,
|
||||
"style" => style,
|
||||
"strikethrough" => strikethrough,
|
||||
"underline" => underline,
|
||||
"bg-color" => bg_color,
|
||||
"fg-color" => fg_color,
|
||||
"language" => language,
|
||||
"justification" => justification,
|
||||
};
|
||||
134
patches/accesskit_atspi_common/src/util.rs
vendored
Normal file
134
patches/accesskit_atspi_common/src/util.rs
vendored
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
// Copyright 2022 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::{Point, Rect, ScrollHint};
|
||||
use accesskit_consumer::{Node, TextPosition, TextRange};
|
||||
use atspi_common::{CoordType, Granularity, ScrollType};
|
||||
|
||||
use crate::Error;
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug)]
|
||||
pub struct WindowBounds {
|
||||
pub outer: Rect,
|
||||
pub inner: Rect,
|
||||
}
|
||||
|
||||
impl WindowBounds {
|
||||
pub fn new(outer: Rect, inner: Rect) -> Self {
|
||||
Self { outer, inner }
|
||||
}
|
||||
|
||||
pub(crate) fn accesskit_point_to_atspi_point(
|
||||
&self,
|
||||
point: Point,
|
||||
parent: Option<Node>,
|
||||
coord_type: CoordType,
|
||||
) -> Point {
|
||||
let origin = self.origin(parent, coord_type);
|
||||
Point::new(origin.x + point.x, origin.y + point.y)
|
||||
}
|
||||
|
||||
pub(crate) fn atspi_point_to_accesskit_point(
|
||||
&self,
|
||||
point: Point,
|
||||
parent: Option<Node>,
|
||||
coord_type: CoordType,
|
||||
) -> Point {
|
||||
let origin = self.origin(parent, coord_type);
|
||||
Point::new(point.x - origin.x, point.y - origin.y)
|
||||
}
|
||||
|
||||
fn origin(&self, parent: Option<Node>, coord_type: CoordType) -> Point {
|
||||
match coord_type {
|
||||
CoordType::Screen => self.inner.origin(),
|
||||
CoordType::Window => Point::ZERO,
|
||||
CoordType::Parent => {
|
||||
if let Some(parent) = parent {
|
||||
let parent_origin = parent.bounding_box().unwrap_or_default().origin();
|
||||
Point::new(-parent_origin.x, -parent_origin.y)
|
||||
} else {
|
||||
self.inner.origin()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn text_position_from_offset<'a>(
|
||||
node: &'a Node,
|
||||
offset: i32,
|
||||
) -> Option<TextPosition<'a>> {
|
||||
let index = offset.try_into().ok()?;
|
||||
node.text_position_from_global_usv_index(index)
|
||||
}
|
||||
|
||||
pub(crate) fn text_range_from_offset<'a>(
|
||||
node: &'a Node,
|
||||
offset: i32,
|
||||
granularity: Granularity,
|
||||
) -> Result<TextRange<'a>, Error> {
|
||||
let start_offset = text_position_from_offset(node, offset).ok_or(Error::IndexOutOfRange)?;
|
||||
let start = match granularity {
|
||||
Granularity::Char => start_offset,
|
||||
Granularity::Line if start_offset.is_line_start() => start_offset,
|
||||
Granularity::Line => start_offset.backward_to_line_start(),
|
||||
Granularity::Paragraph if start_offset.is_paragraph_start() => start_offset,
|
||||
Granularity::Paragraph => start_offset.backward_to_paragraph_start(),
|
||||
Granularity::Sentence => return Err(Error::UnsupportedTextGranularity),
|
||||
Granularity::Word if start_offset.is_word_start() => start_offset,
|
||||
Granularity::Word => start_offset.backward_to_word_start(),
|
||||
};
|
||||
let end = match granularity {
|
||||
Granularity::Char if start_offset.is_document_end() => start_offset,
|
||||
Granularity::Char => start.forward_to_character_end(),
|
||||
Granularity::Line => start.forward_to_line_end(),
|
||||
Granularity::Paragraph => start.forward_to_paragraph_end(),
|
||||
Granularity::Sentence => return Err(Error::UnsupportedTextGranularity),
|
||||
Granularity::Word => start.forward_to_word_end(),
|
||||
};
|
||||
let mut range = start.to_degenerate_range();
|
||||
range.set_end(end);
|
||||
Ok(range)
|
||||
}
|
||||
|
||||
pub(crate) fn text_range_from_offsets<'a>(
|
||||
node: &'a Node,
|
||||
start_offset: i32,
|
||||
end_offset: i32,
|
||||
) -> Option<TextRange<'a>> {
|
||||
let start = text_position_from_offset(node, start_offset)?;
|
||||
let end = if end_offset == -1 {
|
||||
node.document_range().end()
|
||||
} else {
|
||||
text_position_from_offset(node, end_offset)?
|
||||
};
|
||||
|
||||
let mut range = start.to_degenerate_range();
|
||||
range.set_end(end);
|
||||
Some(range)
|
||||
}
|
||||
|
||||
pub(crate) fn text_range_bounds_from_offsets(
|
||||
node: &Node,
|
||||
start_offset: i32,
|
||||
end_offset: i32,
|
||||
) -> Option<Rect> {
|
||||
text_range_from_offsets(node, start_offset, end_offset)?
|
||||
.bounding_boxes()
|
||||
.into_iter()
|
||||
.reduce(|rect1, rect2| rect1.union(rect2))
|
||||
}
|
||||
|
||||
pub(crate) fn atspi_scroll_type_to_scroll_hint(scroll_type: ScrollType) -> Option<ScrollHint> {
|
||||
match scroll_type {
|
||||
ScrollType::TopLeft => Some(ScrollHint::TopLeft),
|
||||
ScrollType::BottomRight => Some(ScrollHint::BottomRight),
|
||||
ScrollType::TopEdge => Some(ScrollHint::TopEdge),
|
||||
ScrollType::BottomEdge => Some(ScrollHint::BottomEdge),
|
||||
ScrollType::LeftEdge => Some(ScrollHint::LeftEdge),
|
||||
ScrollType::RightEdge => Some(ScrollHint::RightEdge),
|
||||
ScrollType::Anywhere => None,
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue