diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..719bd12 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,8 @@ +# Preserve published upstream formatting and literal unified-diff context. +# Application code and first-party patch tooling retain normal whitespace checks. +patches/accesskit*/** -whitespace linguist-vendored +patches/atspi*/** -whitespace linguist-vendored +patches/i-slint-backend-winit/** -whitespace linguist-vendored +patches/sctk-adwaita/** -whitespace linguist-vendored +patches/zbus-lockstep*/** -whitespace linguist-vendored +patches/changes/*.patch -whitespace diff --git a/.gitignore b/.gitignore index e08c794..7f64eb8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ target/ .DS_Store + +# Local credentials must stay outside Git. +.env +.env.* +!.env.example diff --git a/Cargo.lock b/Cargo.lock index ca8fec5..d41a316 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,22 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "ab_glyph" -version = "0.2.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01c0457472c38ea5bd1c3b5ada5e368271cb550be7a4ca4a0b4634e9913f6cc2" -dependencies = [ - "ab_glyph_rasterizer", - "owned_ttf_parser", -] - -[[package]] -name = "ab_glyph_rasterizer" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" - [[package]] name = "accesskit" version = "0.24.1" @@ -29,23 +13,21 @@ dependencies = [ [[package]] name = "accesskit_atspi_common" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e98018dbef3583d751dbb96e07b8728fb99581360e1c3df408af16f4a80b821" +version = "0.19.1" dependencies = [ "accesskit", "accesskit_consumer", "atspi-common", "phf", "serde", - "zvariant", + "zbus", ] [[package]] name = "accesskit_consumer" -version = "0.37.0" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950720ce064757a1b629caad3a408e8d2c63bb01f29b8a3ff8daa331053ffeb" +checksum = "5d10a236f96f87d70732e44520046785431ef01d5bcd6b041317bfadd2f88245" dependencies = [ "accesskit", "hashbrown 0.16.1", @@ -53,37 +35,35 @@ dependencies = [ [[package]] name = "accesskit_ios" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02ecb52198c7cf5f8d3e9ffc03d2ca0a5c7201926befd96721437829da4c5c6a" +checksum = "750c4e9f6ce888dfe8a10c0f1b5ceb646a7854fd46579d74919219d1bb314083" dependencies = [ "accesskit", "accesskit_consumer", "hashbrown 0.16.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-foundation 0.2.2", "objc2-ui-kit 0.2.2", ] [[package]] name = "accesskit_macos" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cb8b66cef272d48161b02a6317cc2bdd5f98bb0a5e79c68f704a5862aa396b" +checksum = "ce02dc63b43f0c9296af9ac946312a2dc8814427d7a64d2d600971dac55b6076" dependencies = [ "accesskit", "accesskit_consumer", "hashbrown 0.16.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-app-kit 0.2.2", "objc2-foundation 0.2.2", ] [[package]] name = "accesskit_unix" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5376ba4cc23312587634abb5250b1ce8618f01a55915608209aafd01efb4bf8c" +version = "0.22.1" dependencies = [ "accesskit", "accesskit_atspi_common", @@ -99,9 +79,9 @@ dependencies = [ [[package]] name = "accesskit_windows" -version = "0.33.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36e93ac7bf50b964f1cbb75f741629a4e950571baa1ef1274457ab5a80d9bcc2" +checksum = "106c2b961215864d1c2e703ee63269c25c4e80a577ffb2c1017b9c17dcdf83a1" dependencies = [ "accesskit", "accesskit_consumer", @@ -113,9 +93,9 @@ dependencies = [ [[package]] name = "accesskit_winit" -version = "0.33.1" +version = "0.33.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fe5862066316f6caaf02cd3aecd54bced25503ac5dbbfd0d03a42bc1246217" +checksum = "d5b41e63a69f36d9f1f41e70464c7e5f72eee485ef26aab19f0b4f86e6c0a84c" dependencies = [ "accesskit", "accesskit_ios", @@ -134,12 +114,12 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "aead" -version = "0.5.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +checksum = "1973cfbc1a2daf9cf550e74e1f088c28e7f7d8c1e1418fb6c9dc5184b7e84c99" dependencies = [ - "crypto-common 0.1.7", - "generic-array", + "crypto-common", + "inout", ] [[package]] @@ -157,31 +137,13 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" dependencies = [ "memchr", ] -[[package]] -name = "aligned" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee4508988c62edf04abd8d92897fca0c2995d907ce1dfeaf369dac3716a40685" -dependencies = [ - "as-slice", -] - -[[package]] -name = "aligned-vec" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc890384c8602f339876ded803c97ad529f3842aba97f6392b3dba0dd171769b" -dependencies = [ - "equator", -] - [[package]] name = "allocator-api2" version = "0.2.21" @@ -195,7 +157,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "812947049edcd670a82cd5c73c3661d2e58468577ba8489de58e1a73c04cbd5d" dependencies = [ "alsa-sys", - "bitflags 2.13.0", + "bitflags 2.13.2", "cfg-if", "libc", ] @@ -217,16 +179,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f2a1bb052857d5dd49572219344a7332b31b76405648eabac5bc68978251bcd" dependencies = [ "android-properties", - "bitflags 2.13.0", + "bitflags 2.13.2", "cc", - "jni 0.22.4", + "jni", "libc", "log", "ndk", "ndk-context", "ndk-sys", "num_enum", - "thiserror 2.0.18", + "thiserror 2.0.21", ] [[package]] @@ -237,18 +199,18 @@ checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" [[package]] name = "android_system_properties" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" dependencies = [ "libc", ] [[package]] name = "annotate-snippets" -version = "0.12.16" +version = "0.12.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f211a51805bc641f3ad5b7664c77d2547af685cc33b4cd8d31964027a46f13f1" +checksum = "b2a5b0a5ab8561c603f16c3b78c24a386b1f70e7fc1b1b1e8c15738828e4a176" dependencies = [ "anstyle", "memchr", @@ -263,9 +225,9 @@ checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" [[package]] name = "anyhow" -version = "1.0.103" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" [[package]] name = "anymap3" @@ -274,31 +236,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5dfbc6d8d2675589ccbe4d0fd61df2419075625f8c1a62325e718e2b0049f9" [[package]] -name = "arbitrary" -version = "1.4.2" +name = "arboard" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" - -[[package]] -name = "arg_enum_proc_macro" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" +checksum = "aeb9553e62312c8756a5979254fc6d7da8bbeb5986a1e17037fab932f7037917" dependencies = [ - "proc-macro2", - "quote", - "syn", + "clipboard-win", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "parking_lot", + "percent-encoding", + "windows-sys 0.61.2", + "wl-clipboard-rs", + "x11rb", ] [[package]] name = "argon2" -version = "0.5.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3610892ee6e0cbce8ae2700349fcf8f98adb0dbfbee85aec3c9179d29cc072" +checksum = "134c52ddac6d63c576bef8168db10c83c49c26444ecbc68060fef078925a901c" dependencies = [ "base64ct", "blake2", - "cpufeatures 0.2.17", + "cpufeatures", "password-hash", ] @@ -327,24 +290,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" [[package]] -name = "as-slice" -version = "0.2.1" +name = "ash" +version = "0.38.0+1.3.281" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516" +checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" dependencies = [ - "stable_deref_trait", -] - -[[package]] -name = "async-broadcast" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" -dependencies = [ - "event-listener", - "event-listener-strategy", - "futures-core", - "pin-project-lite", + "libloading", ] [[package]] @@ -373,82 +324,6 @@ dependencies = [ "slab", ] -[[package]] -name = "async-io" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc" -dependencies = [ - "autocfg", - "cfg-if", - "concurrent-queue", - "futures-io", - "futures-lite", - "parking", - "polling", - "rustix 1.1.4", - "slab", - "windows-sys 0.61.2", -] - -[[package]] -name = "async-lock" -version = "3.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f7f2596bd5b78a9fec8088ccd89180d7f9f55b94b0576823bbbdc72ee8311" -dependencies = [ - "event-listener", - "event-listener-strategy", - "pin-project-lite", -] - -[[package]] -name = "async-process" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75" -dependencies = [ - "async-channel", - "async-io", - "async-lock", - "async-signal", - "async-task", - "blocking", - "cfg-if", - "event-listener", - "futures-lite", - "rustix 1.1.4", -] - -[[package]] -name = "async-recursion" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "async-signal" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52b5aaafa020cf5053a01f2a60e8ff5dccf550f0f77ec54a4e47285ac2bab485" -dependencies = [ - "async-io", - "async-lock", - "atomic-waker", - "cfg-if", - "futures-core", - "futures-io", - "rustix 1.1.4", - "signal-hook-registry", - "slab", - "windows-sys 0.61.2", -] - [[package]] name = "async-task" version = "4.7.1" @@ -457,13 +332,13 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" -version = "0.1.89" +version = "0.1.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] @@ -475,18 +350,15 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "atspi" version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77886257be21c9cd89a4ae7e64860c6f0eefca799bb79127913052bd0eefb3d" dependencies = [ "atspi-common", "atspi-proxies", + "zbus", ] [[package]] name = "atspi-common" version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20c5617155740c98003016429ad13fe43ce7a77b007479350a9f8bf95a29f63d" dependencies = [ "enumflags2", "serde", @@ -494,98 +366,28 @@ dependencies = [ "zbus", "zbus-lockstep", "zbus-lockstep-macros", - "zbus_names", - "zvariant", ] [[package]] name = "atspi-proxies" version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2230e48787ed3eb4088996eab66a32ca20c0b67bbd4fd6cdfe79f04f1f04c9fc" dependencies = [ "atspi-common", "serde", "zbus", ] -[[package]] -name = "audiopus_sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62314a1546a2064e033665d658e88c620a62904be945f8147e6b16c3db9f8651" -dependencies = [ - "cmake", - "log", - "pkg-config", -] - -[[package]] -name = "auto_enums" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e4487600931c9a89f8db7ffbdf3fbdd45bb7bd85e26861f659a463cd0dff966" -dependencies = [ - "derive_utils", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "autocfg" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" -[[package]] -name = "av-scenechange" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f321d77c20e19b92c39e7471cf986812cbb46659d2af674adc4331ef3f18394" -dependencies = [ - "aligned", - "anyhow", - "arg_enum_proc_macro", - "arrayvec", - "log", - "num-rational", - "num-traits", - "pastey 0.1.1", - "rayon", - "thiserror 2.0.18", - "v_frame", - "y4m", -] - -[[package]] -name = "av1-grain" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cfddb07216410377231960af4fcab838eaa12e013417781b78bd95ee22077f8" -dependencies = [ - "anyhow", - "arrayvec", - "log", - "nom 8.0.0", - "num-rational", - "v_frame", -] - -[[package]] -name = "avif-serialize" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7178fe5f7d460b13895ebb9dcb28a3a6216d2df2574a0806cb51b555d297f38" -dependencies = [ - "arrayvec", -] - [[package]] name = "base64" -version = "0.22.1" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" [[package]] name = "base64ct" @@ -593,23 +395,13 @@ version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" -[[package]] -name = "bincode" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740" -dependencies = [ - "serde", - "unty", -] - [[package]] name = "bindgen" version = "0.72.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "cexpr", "clang-sys", "itertools 0.13.0", @@ -620,14 +412,23 @@ dependencies = [ "regex", "rustc-hash 2.1.3", "shlex 1.3.0", - "syn", + "syn 2.0.119", ] [[package]] -name = "bit_field" -version = "0.10.3" +name = "bit-set" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6" +checksum = "09ec2f926cc3060f09db9ebc5b52823d85268d24bb917e472c0c4bea35780a7d" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" [[package]] name = "bitflags" @@ -637,38 +438,20 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.13.0" +version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" dependencies = [ "serde_core", ] -[[package]] -name = "bitstream-io" -version = "4.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eff00be299a18769011411c9def0d827e8f2d7bf0c3dbf53633147a8867fd1f" -dependencies = [ - "no_std_io2", -] - [[package]] name = "blake2" -version = "0.10.6" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +checksum = "5b5d4d889834ee8ecfc0f8426ad30faf7cdcb10f741a8e6d7224d95325479f6f" dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", + "digest", ] [[package]] @@ -686,7 +469,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" dependencies = [ - "objc2 0.5.2", + "objc2 0.5.3", ] [[package]] @@ -695,38 +478,19 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" dependencies = [ - "objc2 0.6.4", -] - -[[package]] -name = "blocking" -version = "1.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83f8d02be6967315521be875afa792a316e28d57b5a2d401897e2a7921b7f21" -dependencies = [ - "async-channel", - "async-task", - "futures-io", - "futures-lite", - "piper", + "objc2 0.6.5", ] [[package]] name = "borsh" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f3f6da4992df95bbcd9af42a6c7dcb994498fc9048230405f3b36ff7cd3f145" +checksum = "553c5d846a6ba5150c65e3b1b8ec073bcf1abc20f9b7220de384a4443ea4e20a" dependencies = [ "bytes", "cfg_aliases", ] -[[package]] -name = "built" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c0e531d93d39c34eef561e929e8a7f86d77a5af08aac4f6d6e39976c51858e9" - [[package]] name = "bumpalo" version = "3.20.3" @@ -741,22 +505,22 @@ checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06" [[package]] name = "bytemuck" -version = "1.25.0" +version = "1.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8efb64bd706a16a1bdde310ae86b351e4d21550d98d056f22f8a7f7a2183fec" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.10.2" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" +checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] @@ -777,7 +541,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "log", "polling", "rustix 0.38.44", @@ -787,14 +551,13 @@ dependencies = [ [[package]] name = "calloop" -version = "0.14.4" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dbf9978365bac10f54d1d4b04f7ce4427e51f71d61f2fe15e3fed5166474df7" +checksum = "43b32313e937c8721c9d17ee9bf60699a6402b4b7c2cb6ac1bee0ffcaa4b4e5e" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "polling", - "rustix 1.1.4", - "slab", + "rustix 1.1.5", "tracing", ] @@ -810,23 +573,11 @@ dependencies = [ "wayland-client", ] -[[package]] -name = "calloop-wayland-source" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138efcf0940a02ebf0cc8d1eff41a1682a46b431630f4c52450d6265876021fa" -dependencies = [ - "calloop 0.14.4", - "rustix 1.1.4", - "wayland-backend", - "wayland-client", -] - [[package]] name = "cc" -version = "1.2.66" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5d6cac793997bd970000024b2934968efe83b382de4fdcf4fcb46b6ee4ad996" +checksum = "86e055fa6e3e40ad6187ba25b6855eeb635d5271f8e0f0e1e9a5826b8d75bea0" dependencies = [ "find-msvc-tools", "jobserver", @@ -834,12 +585,6 @@ dependencies = [ "shlex 2.0.1", ] -[[package]] -name = "cesu8" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" - [[package]] name = "cexpr" version = "0.6.0" @@ -851,15 +596,15 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" [[package]] name = "cfg_aliases" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" [[package]] name = "cgl" @@ -872,37 +617,26 @@ dependencies = [ [[package]] name = "chacha20" -version = "0.9.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" dependencies = [ "cfg-if", "cipher", - "cpufeatures 0.2.17", -] - -[[package]] -name = "chacha20" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.0", - "rand_core 0.10.1", + "cpufeatures", + "rand_core", ] [[package]] name = "chacha20poly1305" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +checksum = "9b89e1c441e926b9c82a8d023f6e1b7ae0adcfaa7d621814e4d60789bac751cb" dependencies = [ "aead", - "chacha20 0.9.1", + "chacha20", "cipher", "poly1305", - "zeroize", ] [[package]] @@ -920,20 +654,20 @@ dependencies = [ [[package]] name = "cipher" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c" dependencies = [ - "crypto-common 0.1.7", + "block-buffer", + "crypto-common", "inout", - "zeroize", ] [[package]] name = "clang-sys" -version = "1.8.1" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a" dependencies = [ "glob", "libc", @@ -942,9 +676,9 @@ dependencies = [ [[package]] name = "clipboard-win" -version = "5.4.1" +version = "5.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde03770d3df201d4fb868f2c9c59e66a3e4e2bd06692a0fe701e7103c7e84d4" +checksum = "052af7878466feccda12ba7a6a67d019d712f296809559b47c12c8cc196d3a9a" dependencies = [ "error-code", ] @@ -973,6 +707,15 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" +[[package]] +name = "codespan-reporting" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +dependencies = [ + "unicode-width", +] + [[package]] name = "color_quant" version = "1.1.0" @@ -981,9 +724,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "combine" -version = "4.6.7" +version = "4.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92" dependencies = [ "bytes", "memchr", @@ -1000,9 +743,9 @@ dependencies = [ [[package]] name = "const-field-offset" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9713489fbc45a2d113f58d17448c73115d533ed27fd2f2d0e5e5c69663eaf19b" +checksum = "d535c69e75b4e3c69e17205b5b37a91936c54086cecd339b70071500786acb9c" dependencies = [ "const-field-offset-macro", "field-offset", @@ -1010,21 +753,15 @@ dependencies = [ [[package]] name = "const-field-offset-macro" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b5dc851b7ea80cc4f69aa28632385ffd3e0f88014d53db3f2e5a781896ca783" +checksum = "93d5848843a221ac268cfdd6bfd14e68d5d3dfa79d52c880aafab93f9517fb74" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "const-oid" version = "0.10.2" @@ -1040,20 +777,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "copypasta" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e6811e17f81fe246ef2bc553f76b6ee6ab41a694845df1d37e52a92b7bbd38a" -dependencies = [ - "clipboard-win", - "objc2 0.5.2", - "objc2-app-kit 0.2.2", - "objc2-foundation 0.2.2", - "smithay-clipboard", - "x11-clipboard", -] - [[package]] name = "core-foundation" version = "0.9.4" @@ -1088,7 +811,20 @@ checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" dependencies = [ "bitflags 1.3.2", "core-foundation 0.9.4", - "core-graphics-types", + "core-graphics-types 0.1.3", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa95a34622365fa5bbf40b20b75dba8dfa8c94c734aea8ac9a5ca38af14316f1" +dependencies = [ + "bitflags 2.13.2", + "core-foundation 0.10.1", + "core-graphics-types 0.2.0", "foreign-types", "libc", ] @@ -1105,12 +841,26 @@ dependencies = [ ] [[package]] -name = "core_maths" -version = "0.1.1" +name = "core-graphics-types" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77745e017f5edba1a9c1d854f6f3a52dac8a12dd5af5d2f54aecf61e43d80d30" +checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" dependencies = [ - "libm", + "bitflags 2.13.2", + "core-foundation 0.10.1", + "libc", +] + +[[package]] +name = "core-text" +version = "21.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a593227b66cbd4007b2a050dfdd9e1d1318311409c8d600dc82ba1b15ca9c130" +dependencies = [ + "core-foundation 0.10.1", + "core-graphics 0.24.0", + "foreign-types", + "libc", ] [[package]] @@ -1119,7 +869,7 @@ version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d5d7dca3ebcf65a035582c9ad4385371a9d9ee6537474d2a278f4e1e475bb58" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "libc", "objc2-audio-toolbox", "objc2-core-audio", @@ -1135,53 +885,23 @@ checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636" [[package]] name = "cpal" -version = "0.17.3" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8942da362c0f0d895d7cac616263f2f9424edc5687364dfd1d25ef7eba506d7" -dependencies = [ - "alsa", - "coreaudio-rs", - "dasp_sample", - "jni 0.21.1", - "js-sys", - "libc", - "mach2 0.5.0", - "ndk", - "ndk-context", - "num-derive", - "num-traits", - "objc2 0.6.4", - "objc2-audio-toolbox", - "objc2-avf-audio", - "objc2-core-audio", - "objc2-core-audio-types", - "objc2-core-foundation", - "objc2-foundation 0.3.2", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "windows", -] - -[[package]] -name = "cpal" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f77b11176c37874be37e8d691c946e31b2b8c357abce9526f6a99eb469e1028" +checksum = "6f02e8d0327b42d3e2e4ab2119af397344eb9fc54a34bf0ddeaa1277af8681f1" dependencies = [ "alsa", "block2 0.6.2", "coreaudio-rs", "dasp_sample", - "jni 0.22.4", + "jni", "js-sys", "libc", - "mach2 0.6.0", + "mach2", "ndk", "ndk-context", "num-derive", "num-traits", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-audio-toolbox", "objc2-avf-audio", "objc2-core-audio", @@ -1195,27 +915,18 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.17" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" -dependencies = [ - "libc", -] - -[[package]] -name = "cpufeatures" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" dependencies = [ "libc", ] [[package]] name = "crc32fast" -version = "1.5.0" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +checksum = "0ba106e844045ddc02c20768ac4b0b7cb45f2cc2ecbd833ac9f5dacb183c2055" dependencies = [ "cfg-if", ] @@ -1228,18 +939,18 @@ checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" [[package]] name = "crossbeam-channel" -version = "0.5.16" +version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d85363c37faeca707aef026efa9f3b34d077bce547e48f770770625c6013679e" +checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-deque" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5181e0de7b61eb03a81e347d6dd8797bae9da5146707b51077e2d71a54ec0ceb" +checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -1247,18 +958,41 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.20" +version = "0.9.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d6914041f254d6e9176c01941b21115dcfb7089e55135a35411081bd106ef3f" +checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.22" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61803da095bee82a81bb1a452ecc25d3b2f1416d1897eb86430c6159ef717c17" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + +[[package]] +name = "crossfont" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedb5e91df8e36e458f03a935b5f71495f73211ce7c5e341c668ded8571261" +dependencies = [ + "core-foundation 0.10.1", + "core-foundation-sys", + "core-graphics 0.24.0", + "core-text", + "dwrote", + "foreign-types", + "freetype-rs", + "libc", + "log", + "objc2 0.5.3", + "objc2-foundation 0.2.2", + "once_cell", + "pkg-config", + "winapi", + "yeslogic-fontconfig-sys", +] [[package]] name = "crunchy" @@ -1266,24 +1000,15 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" -[[package]] -name = "crypto-common" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" -dependencies = [ - "generic-array", - "rand_core 0.6.4", - "typenum", -] - [[package]] name = "crypto-common" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" dependencies = [ + "getrandom 0.4.3", "hybrid-array", + "rand_core", ] [[package]] @@ -1297,9 +1022,9 @@ dependencies = [ [[package]] name = "ctutils" -version = "0.4.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e" +checksum = "38d28fb6aa7dd680b3ffd1a3e64e115c177bdba63c0ae7f9cd48129ff05c4fa0" dependencies = [ "cmov", ] @@ -1312,15 +1037,16 @@ checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" [[package]] name = "curve25519-dalek" -version = "4.1.3" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +checksum = "b5eed333089e2e1c1ac8c6c0398e5e2497b4c9926ca6d0365ed1e099afa5bc23" dependencies = [ "cfg-if", - "cpufeatures 0.2.17", + "cpufeatures", "curve25519-dalek-derive", - "digest 0.10.7", + "digest", "fiat-crypto", + "rand_core", "rustc_version", "subtle", "zeroize", @@ -1334,7 +1060,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -1349,16 +1075,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376" -[[package]] -name = "der" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" -dependencies = [ - "const-oid 0.9.6", - "zeroize", -] - [[package]] name = "derive_more" version = "2.1.1" @@ -1378,49 +1094,27 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn", + "syn 2.0.119", "unicode-xid", ] -[[package]] -name = "derive_utils" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "362f47930db19fe7735f527e6595e4900316b893ebf6d48ad3d31be928d57dd6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer 0.10.4", - "crypto-common 0.1.7", - "subtle", -] - [[package]] name = "digest" version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" dependencies = [ - "block-buffer 0.12.1", - "const-oid 0.10.2", - "crypto-common 0.2.2", + "block-buffer", + "const-oid", + "crypto-common", "ctutils", ] [[package]] name = "dirs" -version = "6.0.0" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" +checksum = "8d57d423b3c82e89b9a24ca3091fee61f456a26edbd28d26c65906f4bc1dcd8f" dependencies = [ "dirs-sys", ] @@ -1449,19 +1143,21 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" dependencies = [ - "bitflags 2.13.0", - "objc2 0.6.4", + "bitflags 2.13.2", + "block2 0.6.2", + "libc", + "objc2 0.6.5", ] [[package]] name = "displaydoc" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] @@ -1473,6 +1169,15 @@ dependencies = [ "libloading", ] +[[package]] +name = "document-features" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" +dependencies = [ + "litrs", +] + [[package]] name = "downcast-rs" version = "1.2.1" @@ -1491,7 +1196,7 @@ version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80bc8c5c6c2941f70a55c15f8d9f00f9710ebda3ffda98075f996a0e6c92756f" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "bytemuck", "drm-ffi", "drm-fourcc", @@ -1506,7 +1211,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51a91c9b32ac4e8105dec255e849e0d66e27d7c34d184364fb93e469db08f690" dependencies = [ "drm-sys", - "rustix 1.1.4", + "rustix 1.1.5", ] [[package]] @@ -1531,6 +1236,20 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edf234dd1594d6dd434a8fb8cada51ddbbc593e40e4a01556a0b31c62da2775b" +[[package]] +name = "dwrote" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b35532432acc8b19ceed096e35dfa088d3ea037fe4f3c085f1f97f33b4d02" +dependencies = [ + "lazy_static", + "libc", + "serde", + "serde_derive", + "winapi", + "wio", +] + [[package]] name = "easyfft" version = "0.4.2" @@ -1546,43 +1265,33 @@ dependencies = [ [[package]] name = "ed25519" -version = "2.2.3" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +checksum = "29fcf32e6c73d1079f83ab4d782de2d81620346a5f38c6237a86a22f8368980a" dependencies = [ - "pkcs8", "signature", ] [[package]] name = "ed25519-dalek" -version = "2.2.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" +checksum = "6ebaa1a2bf1290ab3bfe5a7b771d050ebffab2711c19a81691c683a5144a25de" dependencies = [ "curve25519-dalek", "ed25519", - "rand_core 0.6.4", - "serde", - "sha2 0.10.9", + "rand_core", + "sha2", + "signature", "subtle", "zeroize", ] [[package]] name = "either" -version = "1.16.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" - -[[package]] -name = "encoding_rs" -version = "0.8.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" -dependencies = [ - "cfg-if", -] +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "endi" @@ -1597,7 +1306,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef" dependencies = [ "enumflags2_derive", - "serde", ] [[package]] @@ -1608,34 +1316,14 @@ checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" dependencies = [ "proc-macro2", "quote", - "syn", -] - -[[package]] -name = "equator" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4711b213838dfee0117e3be6ac926007d7f433d7bbe33595975d4190cb07e6fc" -dependencies = [ - "equator-macro", -] - -[[package]] -name = "equator-macro" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "equivalent" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" [[package]] name = "errno" @@ -1649,9 +1337,9 @@ dependencies = [ [[package]] name = "error-code" -version = "3.3.2" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea2df4cf52843e0452895c455a1a2cfbb842a1e7329671acf418fdc53ed4c59" +checksum = "0b5343afd4a8365a643ac588dab4cf234a190c7f6c88c9f6dd6ffe00837661b7" [[package]] name = "euclid" @@ -1664,11 +1352,10 @@ dependencies = [ [[package]] name = "event-listener" -version = "5.4.1" +version = "5.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab" +checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2" dependencies = [ - "concurrent-queue", "parking", "pin-project-lite", ] @@ -1683,40 +1370,11 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "exr" -version = "1.74.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711fe42c9964295e01ee3fba3f9fe0e1d24b98886950d68efe81b1c76e21adf3" -dependencies = [ - "bit_field", - "half", - "lebe", - "miniz_oxide", - "num-complex", - "pulp", - "rayon-core", - "smallvec", - "zune-inflate", -] - -[[package]] -name = "extended" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af9673d8203fcb076b19dfd17e38b3d4ae9f44959416ea532ce72415a6020365" - [[package]] name = "fastrand" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" - -[[package]] -name = "fax" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf1079563223d5d59d83c85886a56e586cfd5c1a26292e971a0fa266531ac5a" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" [[package]] name = "fdeflate" @@ -1729,16 +1387,16 @@ dependencies = [ [[package]] name = "femtovg" -version = "0.25.1" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43d05da42e81724c16d34a150fb7fda53d3f786e5a94673ee526ff8602f0f6a" +checksum = "31eebf3ab1b76359ccd5f850c07a7c6b2722c64d9127c40e02358e83f3ff9b1a" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "bytemuck", "fnv", "glow", "imgref", - "itertools 0.14.0", + "itertools 0.15.0", "log", "rgb", "slotmap", @@ -1749,9 +1407,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.9" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24" [[package]] name = "field-offset" @@ -1775,15 +1433,15 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.9" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" [[package]] name = "fixed_decimal" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79c3c892f121fff406e5dd6b28c1b30096b95111c30701a899d4f2b18da6d1bd" +checksum = "2214fb00f669ee96bee5bb29dfb1ddabe058b2bc426817efc79afa03c9bc55ae" dependencies = [ "displaydoc", "smallvec", @@ -1791,13 +1449,20 @@ dependencies = [ ] [[package]] -name = "flate2" -version = "1.1.9" +name = "fixedbitset" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + +[[package]] +name = "flate2" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.9.1", + "zlib-rs", ] [[package]] @@ -1812,6 +1477,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + [[package]] name = "foldhash" version = "0.2.0" @@ -1820,35 +1491,34 @@ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" [[package]] name = "font-types" -version = "0.11.3" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b38ad915f6dadd993ced50848a8291a543bd41ca62bc10740d5e64e2ab4cfd7" +checksum = "835ae9d781464a79026cde387f9cbc650c9a4909d7cf7e658b127e3c35d2f35d" dependencies = [ "bytemuck", ] [[package]] name = "fontdb" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "457e789b3d1202543297a350643cf459f836cade38934e7a4cf6a39e7cde2905" +checksum = "2660c5e9157bf76d2db1294e4a9feba604ef610819a3b591088d0d8392a3290f" dependencies = [ "log", "slotmap", "tinyvec", - "ttf-parser", ] [[package]] name = "fontique" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "274fa4f0f0a926ae182c7c076c078cce8a38471d15e61a102a02cac984be9813" +checksum = "6688bc1294fe7117d788937b6c53480169b29c566954af490830d4c09da9516a" dependencies = [ "hashbrown 0.17.1", "linebender_resource_handle", "memmap2", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-core-foundation", "objc2-core-text", "objc2-foundation 0.3.2", @@ -1873,13 +1543,13 @@ dependencies = [ [[package]] name = "foreign-types-macros" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" +checksum = "ea5190182e6915eb873ddbc16e23b711b6eb1f9c00a0d0a3a91b5f6228475225" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] @@ -1898,10 +1568,32 @@ dependencies = [ ] [[package]] -name = "futures" -version = "0.3.32" +name = "freetype-rs" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" +checksum = "5442dee36ca09604133580dc0553780e867936bb3cbef3275859e889026d2b17" +dependencies = [ + "bitflags 2.13.2", + "freetype-sys", + "libc", +] + +[[package]] +name = "freetype-sys" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7edc5b9669349acfda99533e9e0bcf26a51862ab43b08ee7745c55d28eb134" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + +[[package]] +name = "futures" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" dependencies = [ "futures-channel", "futures-core", @@ -1914,9 +1606,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" dependencies = [ "futures-core", "futures-sink", @@ -1924,15 +1616,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" [[package]] name = "futures-executor" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" dependencies = [ "futures-core", "futures-task", @@ -1941,9 +1633,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" [[package]] name = "futures-lite" @@ -1960,32 +1652,32 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] name = "futures-sink" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" [[package]] name = "futures-task" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" [[package]] name = "futures-util" -version = "0.3.32" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" dependencies = [ "futures-channel", "futures-core", @@ -2004,7 +1696,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce852e998d3ca5e4a97014fb31c940dc5ef344ec7d364984525fd11e8a547e6a" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "drm", "drm-fourcc", "gbm-sys", @@ -2020,16 +1712,6 @@ dependencies = [ "libc", ] -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - [[package]] name = "generic_singleton" version = "0.5.3" @@ -2046,30 +1728,10 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" dependencies = [ - "rustix 1.1.4", + "rustix 1.1.5", "windows-link", ] -[[package]] -name = "getopts" -version = "0.2.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfe4fbac503b8d1f88e6676011885f34b7174f46e59956bba534ba83abded4df" -dependencies = [ - "unicode-width", -] - -[[package]] -name = "getrandom" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - [[package]] name = "getrandom" version = "0.3.4" @@ -2091,7 +1753,7 @@ dependencies = [ "cfg-if", "libc", "r-efi 6.0.0", - "rand_core 0.10.1", + "rand_core", ] [[package]] @@ -2117,15 +1779,15 @@ dependencies = [ [[package]] name = "glob" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" [[package]] name = "glow" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29038e1c483364cc6bb3cf78feee1816002e127c331a1eec55a4d202b9e1adb5" +checksum = "263218b0ba2b0715c3370fb04674f5f8aa331594b521c94ff0a8e4a8472d1386" dependencies = [ "js-sys", "slotmap", @@ -2139,7 +1801,7 @@ version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12124de845cacfebedff80e877bb37b5b75c34c5a4c89e47e1cdd67fb6041325" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "cfg_aliases", "cgl", "dispatch2", @@ -2147,7 +1809,7 @@ dependencies = [ "glutin_glx_sys", "glutin_wgl_sys", "libloading", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-app-kit 0.3.2", "objc2-core-foundation", "objc2-foundation 0.3.2", @@ -2199,6 +1861,20 @@ dependencies = [ "gl_generator", ] +[[package]] +name = "gpu-allocator" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51255ea7cfaadb6c5f1528d43e92a82acb2b96c43365989a28b2d44ee38f8795" +dependencies = [ + "ash", + "hashbrown 0.16.1", + "log", + "presser", + "thiserror 2.0.21", + "windows", +] + [[package]] name = "grid" version = "1.0.1" @@ -2213,16 +1889,17 @@ checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" dependencies = [ "cfg-if", "crunchy", + "num-traits", "zerocopy", ] [[package]] name = "harfrust" -version = "0.8.4" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d12c7c642d4ce8c2e784b4751a6634bd89583912265add4a679a8882d123fbcd" +checksum = "c03d949a14aa089bbb282f7dd76a498a7f684428e4257202efc119ec010376f9" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "bytemuck", "read-fonts", "smallvec", @@ -2234,6 +1911,15 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash 0.1.5", +] + [[package]] name = "hashbrown" version = "0.16.1" @@ -2242,7 +1928,7 @@ checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ "allocator-api2", "equivalent", - "foldhash", + "foldhash 0.2.0", ] [[package]] @@ -2251,7 +1937,7 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ - "foldhash", + "foldhash 0.2.0", ] [[package]] @@ -2262,15 +1948,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" -version = "0.3.9" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - -[[package]] -name = "hermit-abi" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" +checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" [[package]] name = "hex" @@ -2293,7 +1973,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" dependencies = [ - "digest 0.11.3", + "digest", ] [[package]] @@ -2304,21 +1984,21 @@ checksum = "48ce8546b993eaf241d69ded33b1be6d205dd9857ec879d9d18bd05d3676e144" [[package]] name = "hybrid-array" -version = "0.4.13" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "818356c5132c1fede50f837ca96afbe78ff42413047f4abb886217845e1b6c8c" +checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" dependencies = [ "typenum", ] [[package]] name = "i-slint-backend-linuxkms" -version = "1.17.1" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68e76f2b13846ca54bba6b8eb3b5454b26879ad987396d0a2d8abedc31a6c469" +checksum = "0f519a8611a4982921e46e391015e5e40ceac5cc63813333ef91ada77df180d8" dependencies = [ "bytemuck", - "calloop 0.14.4", + "calloop 0.14.5", "cfg_aliases", "drm", "gbm", @@ -2327,18 +2007,16 @@ dependencies = [ "i-slint-core", "i-slint-renderer-femtovg", "i-slint-renderer-software", - "input", "memmap2", "nix", "raw-window-handle", - "xkbcommon", ] [[package]] name = "i-slint-backend-selector" -version = "1.17.1" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2247a4590a02a466b2f4916cc789dfe66247f6af826f00eb84a2685259a45c1c" +checksum = "fb974705d61ba56034f6129ff61f3e6282a2c0c07752f25e6cb417d81c0f0958" dependencies = [ "cfg-if", "cfg_aliases", @@ -2353,9 +2031,9 @@ dependencies = [ [[package]] name = "i-slint-backend-testing" -version = "1.17.1" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521e901e3d47ab829c0ef500c63155776208707cd93259e6a7803ed627fa2786" +checksum = "01943d6c5ea5bc913d497bdaa423c309e7627afff47a6794bfd13be5c564209f" dependencies = [ "cfg_aliases", "i-slint-common", @@ -2366,18 +2044,15 @@ dependencies = [ [[package]] name = "i-slint-backend-winit" -version = "1.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27c7e8f53418d3017362465367b6612b6e439a68097d627d1b91c94b885f0a6" +version = "1.18.1" dependencies = [ "accesskit", "accesskit_winit", + "arboard", "block2 0.6.2", "bytemuck", "cfg-if", "cfg_aliases", - "copypasta", - "derive_more", "futures", "glutin", "glutin-winit", @@ -2390,7 +2065,7 @@ dependencies = [ "imgref", "lyon_path", "muda", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-app-kit 0.3.2", "objc2-foundation 0.3.2", "objc2-quartz-core 0.3.2", @@ -2413,9 +2088,9 @@ dependencies = [ [[package]] name = "i-slint-common" -version = "1.17.1" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e63f8ea55ba21e44567ae67d2b01a4f5d09bb1fab693b1e6c79d96bef9e456" +checksum = "68a578f3e4b681b2b9cbd326d3be19716e2fac51d00a8a5b00c0ef4ae923b5e6" dependencies = [ "derive_more", "fontique", @@ -2430,9 +2105,9 @@ dependencies = [ [[package]] name = "i-slint-compiler" -version = "1.17.1" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ea275b15a425c7f2f77481151e1f5f8f1ea83feae580273090ef6b9e192218" +checksum = "f55d48ebef05e2bf09ba5a1fc67bcb11033b9e12a2a50ed3105c7d25e2b539d0" dependencies = [ "annotate-snippets", "by_address", @@ -2440,9 +2115,10 @@ dependencies = [ "derive_more", "i-slint-common", "icu_normalizer", + "icu_properties", "image", - "itertools 0.14.0", - "linked_hash_set", + "indexmap", + "itertools 0.15.0", "lyon_extra", "lyon_path", "num_enum", @@ -2453,7 +2129,7 @@ dependencies = [ "rowan", "rspolib", "skrifa", - "smol_str 0.3.6", + "smol_str 0.3.7", "strum", "swash", "typed-index-collections", @@ -2463,13 +2139,12 @@ dependencies = [ [[package]] name = "i-slint-core" -version = "1.17.1" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e407dc2bd5385dcbdd9c1cf927213d2e4bacda667545abf8839c60f8290f754" +checksum = "ed2ea15059d70bc31b1a8b1eb4c34f2c5df04cb7e53f36179b43c0261231d646" dependencies = [ - "async-channel", - "auto_enums", - "bitflags 2.13.0", + "accesskit", + "bitflags 2.13.2", "cfg-if", "chrono", "clru", @@ -2480,13 +2155,13 @@ dependencies = [ "i-slint-core-macros", "icu_normalizer", "image", - "ksni", + "js-sys", "lyon_algorithms", "lyon_extra", "lyon_geom", "lyon_path", "num-traits", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-app-kit 0.3.2", "objc2-foundation 0.3.2", "once_cell", @@ -2511,29 +2186,29 @@ dependencies = [ "wasm-bindgen", "web-sys", "web-time", + "wgpu", "windows", ] [[package]] name = "i-slint-core-macros" -version = "1.17.1" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a842640da4c4d0909d25cc5a51e1f9cde02bd48f7fdfa94df10d595d4e3c80a" +checksum = "73f5a8a076de52f53be80caa826599ed2107b54c9d4a421e66dc06cf893a984c" dependencies = [ "quote", "serde_json", - "syn", + "syn 3.0.9", ] [[package]] name = "i-slint-renderer-femtovg" -version = "1.17.1" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78d0d99a18d66738b684758fe8460743a0aa0f64a96e05940942231a340085b1" +checksum = "eb0de504d57cdadf80c2abf7bcb8b7135a3716aee1f41b6ebb90ea93e3649d7c" dependencies = [ "cfg-if", "const-field-offset", - "derive_more", "femtovg", "glow", "i-slint-common", @@ -2549,23 +2224,22 @@ dependencies = [ [[package]] name = "i-slint-renderer-skia" -version = "1.17.1" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b6eed7f3f0a9a3d3ca6e8b9d4ca233371d989351fdb2a7ab88ec368b99e7b57" +checksum = "dc9c1cf02385f1d26fc1f423544e52390a8e5c2d89420a8042aa94b4fe109d1f" dependencies = [ "bytemuck", "cfg-if", "cfg_aliases", "clru", "const-field-offset", - "derive_more", "glow", "glutin", "i-slint-common", "i-slint-core", "i-slint-core-macros", "lyon_path", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-app-kit 0.3.2", "objc2-core-foundation", "objc2-foundation 0.3.2", @@ -2573,22 +2247,25 @@ dependencies = [ "objc2-quartz-core 0.3.2", "pin-weak", "raw-window-handle", - "raw-window-metal", "read-fonts", "scoped-tls-hkt", "skia-safe", "softbuffer", + "spin_on", "unicode-segmentation", "vtable", + "wgpu", + "wgpu-hal", "windows", + "windows-core", "write-fonts", ] [[package]] name = "i-slint-renderer-software" -version = "1.17.1" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73496f164f8e471877c35e0fadb996dcc674922712abd9c2be2cbe80c58859bd" +checksum = "2f8c641e138a2cc96537cac4481f5c7c8bb8dcc66d09acaed269329c8738628a" dependencies = [ "bytemuck", "clru", @@ -2596,7 +2273,6 @@ dependencies = [ "euclid", "i-slint-common", "i-slint-core", - "integer-sqrt", "lyon_path", "num-traits", "skrifa", @@ -2630,9 +2306,9 @@ dependencies = [ [[package]] name = "icu_collections" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" dependencies = [ "displaydoc", "potential_utf", @@ -2644,15 +2320,15 @@ dependencies = [ [[package]] name = "icu_decimal" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "288247df2e32aa776ac54fdd64de552149ac43cb840f2761811f0e8d09719dd4" +checksum = "1150ad5e272740670464934ee76facda43ef2e11f85c27b7ba76ccb33edf2d05" dependencies = [ "displaydoc", "fixed_decimal", "icu_decimal_data", - "icu_locale", "icu_locale_core", + "icu_locale_fallback", "icu_plurals", "icu_provider", "writeable", @@ -2661,30 +2337,15 @@ dependencies = [ [[package]] name = "icu_decimal_data" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f14a5ca9e8af29eef62064f269078424283d90dbaffeac5225addf62aaabc22" - -[[package]] -name = "icu_locale" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5a396343c7208121dc86e35623d3dfe19814a7613cfd14964994cdc9c9a2e26" -dependencies = [ - "icu_collections", - "icu_locale_core", - "icu_locale_data", - "icu_provider", - "potential_utf", - "tinystr", - "zerovec", -] +checksum = "5595ab78370d48abd24a062f3db115d5108dd0b65634352036cae532aebb0df8" [[package]] name = "icu_locale_core" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" dependencies = [ "displaydoc", "litemap", @@ -2695,16 +2356,30 @@ dependencies = [ ] [[package]] -name = "icu_locale_data" -version = "2.2.0" +name = "icu_locale_fallback" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5fdcc9ac77c6d74ff5cf6e65ef3181d6af32003b16fce3a77fb451d2f695993" +checksum = "406e9ae5b95d8aa37db6293405931b766a6172d1848daee22d70eb44aa78a43c" +dependencies = [ + "icu_locale_core", + "icu_locale_fallback_data", + "icu_provider", + "potential_utf", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locale_fallback_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3632ebbd0c5c3637ba1a40bdf8288f2cb9d2268e73441a69d5fc73d7cfbaa87c" [[package]] name = "icu_normalizer" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" dependencies = [ "icu_collections", "icu_normalizer_data", @@ -2716,18 +2391,18 @@ dependencies = [ [[package]] name = "icu_normalizer_data" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" [[package]] name = "icu_plurals" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a50023f1d49ad5c4333380328a0d4a19e4b9d6d842ec06639affd5ba47c8103" +checksum = "2ef046647b445acf95ce0f8083fa292467d3df649959fa9a20f3f8abfd957c5d" dependencies = [ "fixed_decimal", - "icu_locale", + "icu_locale_fallback", "icu_plurals_data", "icu_provider", "zerovec", @@ -2735,16 +2410,17 @@ dependencies = [ [[package]] name = "icu_plurals_data" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8485497155dc865f901decb93ecc20d3e467df67bfeceb91e3ba34e2b11e8e1d" +checksum = "d43ff7df2c1a1d41588a6ddcba354d513d4a3e10eec22c06fe56d13c12a848ea" [[package]] name = "icu_properties" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" dependencies = [ + "displaydoc", "icu_collections", "icu_locale_core", "icu_properties_data", @@ -2755,15 +2431,15 @@ dependencies = [ [[package]] name = "icu_properties_data" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" [[package]] name = "icu_provider" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" dependencies = [ "displaydoc", "icu_locale_core", @@ -2778,24 +2454,26 @@ dependencies = [ [[package]] name = "icu_segmenter" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c0794db0b1a86193ac9c48768d0e6c52c54448e0870ad87907d456ee0dac964" +checksum = "61b195dc605f81aa181bec9b3bd14e26cc71b903e4644f6af578ca9772c7a710" dependencies = [ "icu_collections", - "icu_locale", + "icu_locale_fallback", "icu_provider", "icu_segmenter_data", "potential_utf", + "smallvec", "utf8_iter", + "zerotrie", "zerovec", ] [[package]] name = "icu_segmenter_data" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a2c462a4d927d512f5f882a033ddd62f33a05bb9f230d98f736ac3dc85938f" +checksum = "913a7d294ad056474749152107309fdee3ec17d2482d1ab70fdc61a81c64b9a3" [[package]] name = "idna" @@ -2826,18 +2504,10 @@ checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104" dependencies = [ "bytemuck", "byteorder-lite", - "color_quant", - "exr", - "gif", "image-webp", "moxcms", "num-traits", "png", - "qoi", - "ravif", - "rayon", - "rgb", - "tiff", "zune-core", "zune-jpeg", ] @@ -2854,21 +2524,21 @@ dependencies = [ [[package]] name = "imagesize" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09e54e57b4c48b40f7aec75635392b12b3421fa26fe8b4332e63138ed278459c" +checksum = "65b27460c2c92b037f3f94c538ed9a3342f3fdf923606781629ccb35f82d042a" [[package]] name = "imgref" -version = "1.12.2" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89194689a993ab15268672e99e7b0e19da2da3268ac682e8f02d29d4d1434cd7" +checksum = "6e44b0a4eaa4c82f441d50a963f2d5f05a787240aeee097597033e72accfd22f" [[package]] name = "indexmap" -version = "2.14.0" +version = "2.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" dependencies = [ "equivalent", "hashbrown 0.17.1", @@ -2876,61 +2546,11 @@ dependencies = [ [[package]] name = "inout" -version = "0.1.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +checksum = "3b5cf4372d022092674a83b8febf5865f7a573cc0c5baec5e49c879b6a20978f" dependencies = [ - "generic-array", -] - -[[package]] -name = "input" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9793345a65d71317763a33066b5d8351f8760dde8d4930fe9e39b5f14a7959d" -dependencies = [ - "bitflags 2.13.0", - "input-sys", - "libc", - "log", - "udev", -] - -[[package]] -name = "input-sys" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36eee07d8e02bd95bf52b2e642cf13d33701b94c6e4b04fbf1d1fb07e9cb19e7" - -[[package]] -name = "integer-sqrt" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" -dependencies = [ - "num-traits", -] - -[[package]] -name = "interpolate_name" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi 0.3.9", - "libc", - "windows-sys 0.48.0", + "hybrid-array", ] [[package]] @@ -2944,9 +2564,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc" dependencies = [ "either", ] @@ -2957,22 +2577,6 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" -[[package]] -name = "jni" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" -dependencies = [ - "cesu8", - "cfg-if", - "combine", - "jni-sys 0.3.1", - "log", - "thiserror 1.0.69", - "walkdir", - "windows-sys 0.45.0", -] - [[package]] name = "jni" version = "0.22.4" @@ -2985,7 +2589,7 @@ dependencies = [ "jni-sys 0.4.1", "log", "simd_cesu8", - "thiserror 2.0.18", + "thiserror 2.0.21", "walkdir", "windows-link", ] @@ -3000,7 +2604,7 @@ dependencies = [ "quote", "rustc_version", "simd_cesu8", - "syn", + "syn 2.0.119", ] [[package]] @@ -3028,7 +2632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" dependencies = [ "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -3043,9 +2647,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.103" +version = "0.3.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102" +checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5" dependencies = [ "cfg-if", "futures-util", @@ -3058,7 +2662,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "serde", "unicode-segmentation", ] @@ -3069,23 +2673,6 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" -[[package]] -name = "ksni" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9eeb3f510b6148ae68f963af2c1fbb0de4d9e4e05f82813cfb319837c3ad2b" -dependencies = [ - "async-executor", - "async-io", - "async-lock", - "futures-channel", - "futures-lite", - "futures-util", - "pastey 0.2.3", - "serde", - "zbus", -] - [[package]] name = "kurbo" version = "0.13.1" @@ -3100,31 +2687,15 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - -[[package]] -name = "lebe" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" [[package]] name = "libc" -version = "0.2.186" +version = "0.2.191" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" - -[[package]] -name = "libfuzzer-sys" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9fd2f41a1cba099f79a0b6b6c35656cf7c03351a7bae8ff0f28f25270f929d2" -dependencies = [ - "arbitrary", - "cc", -] +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" [[package]] name = "libloading" @@ -3144,24 +2715,14 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libredox" -version = "0.1.18" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c943259e342f1e06ff2da7a83eabdfe7f92ce10262688dbf1895ff0b3e6e4652" +checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "libc", "plain", - "redox_syscall 0.9.0", -] - -[[package]] -name = "libudev-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" -dependencies = [ - "libc", - "pkg-config", + "redox_syscall 0.9.5", ] [[package]] @@ -3170,21 +2731,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - -[[package]] -name = "linked_hash_set" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "984fb35d06508d1e69fc91050cceba9c0b748f983e6739fa2c7a9237154c52c8" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "linux-raw-sys" version = "0.4.15" @@ -3205,9 +2751,15 @@ checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "litemap" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "litrs" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4744e383959f0db86ede514b809b1c53251889093803c05267acc7d4e7030d70" [[package]] name = "lock_api" @@ -3220,24 +2772,15 @@ dependencies = [ [[package]] name = "log" -version = "0.4.33" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" - -[[package]] -name = "loop9" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062" -dependencies = [ - "imgref", -] +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" [[package]] name = "lyon_algorithms" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8575c0d003ae459399623c4def180c63b77f343b1a7fee64f249b349e7699a31" +checksum = "f3a6b9d4e8b48acd531fbf1241ad9b270df6e60b6b92bdea1469f4f40899d805" dependencies = [ "lyon_path", "num-traits", @@ -3250,14 +2793,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7755f08423275157ad1680aaecc9ccb7e0cc633da3240fea2d1522935cc15c72" dependencies = [ "lyon_path", - "thiserror 2.0.18", + "thiserror 2.0.21", ] [[package]] name = "lyon_geom" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4336502e29e32af93cf2dad2214ed6003c17ceb5bd499df77b1de663b9042b92" +checksum = "d82dd26aa4dc0b5b70b9115de59824842bcb43cf4a28e1b1e6d0ad148c93f93e" dependencies = [ "arrayvec", "euclid", @@ -3274,15 +2817,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "mach2" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a1b95cd5421ec55b445b5ae102f5ea0e768de1f82bd3001e11f426c269c3aea" -dependencies = [ - "libc", -] - [[package]] name = "mach2" version = "0.6.0" @@ -3298,16 +2832,6 @@ dependencies = [ "regex-automata", ] -[[package]] -name = "maybe-rayon" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" -dependencies = [ - "cfg-if", - "rayon", -] - [[package]] name = "memchr" version = "2.8.3" @@ -3316,9 +2840,9 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "memmap2" -version = "0.9.11" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1219ed1b7f229ee7104d281dd01d6802fe28bb6e95d292942c4daacdeb798c0" +checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157" dependencies = [ "libc", ] @@ -3349,10 +2873,20 @@ dependencies = [ ] [[package]] -name = "mio" -version = "1.2.1" +name = "miniz_oxide" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02bd0af71c67b473010cbbc60715ee815645a4dc942899111f494b4b737d6fda" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "mio" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee" dependencies = [ "libc", "wasi", @@ -3378,16 +2912,54 @@ dependencies = [ "crossbeam-channel", "dpi", "keyboard-types", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-app-kit 0.3.2", "objc2-core-foundation", "objc2-foundation 0.3.2", "once_cell", "png", - "thiserror 2.0.18", + "thiserror 2.0.21", "windows-sys 0.61.2", ] +[[package]] +name = "naga" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a616d2fb8c89516ac2723a581f69d6c18576046bed761bd6b305e5618e6ae130" +dependencies = [ + "arrayvec", + "bit-set", + "bitflags 2.13.2", + "cfg-if", + "cfg_aliases", + "codespan-reporting", + "half", + "hashbrown 0.17.1", + "indexmap", + "libm", + "log", + "naga-types", + "num-traits", + "once_cell", + "rustc-hash 1.1.0", + "spirv", + "thiserror 2.0.21", + "unicode-ident", +] + +[[package]] +name = "naga-types" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "590afbf58a6f4f62873cd5cff4468061844bafa1cdf399cc954537c22d768d49" +dependencies = [ + "hashbrown 0.17.1", + "indexmap", + "rustc-hash 1.1.0", + "thiserror 2.0.21", +] + [[package]] name = "natord" version = "1.0.9" @@ -3400,7 +2972,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "jni-sys 0.3.1", "log", "ndk-sys", @@ -3424,19 +2996,13 @@ dependencies = [ "jni-sys 0.3.1", ] -[[package]] -name = "new_debug_unreachable" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" - [[package]] name = "nix" version = "0.31.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "cfg-if", "cfg_aliases", "libc", @@ -3452,15 +3018,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "no_std_io2" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418abd1b6d34fbf6cae440dc874771b0525a604428704c76e48b29a5e67b8003" -dependencies = [ - "memchr", -] - [[package]] name = "nom" version = "7.1.3" @@ -3480,12 +3037,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "noop_proc_macro" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" - [[package]] name = "nu-ansi-term" version = "0.50.3" @@ -3495,23 +3046,12 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "num-bigint" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "num-complex" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ - "bytemuck", "num-traits", "serde", ] @@ -3524,29 +3064,18 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "num-integer" -version = "0.1.46" +version = "0.1.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" dependencies = [ "num-traits", ] -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -3576,7 +3105,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -3587,9 +3116,9 @@ checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" [[package]] name = "objc2" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" +checksum = "19d5490aaf8f1d7cf7688dfa9b0ce07900e168852c45cd2c03f534dfd27cfd0b" dependencies = [ "objc-sys", "objc2-encode", @@ -3597,9 +3126,9 @@ dependencies = [ [[package]] name = "objc2" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a12a8ed07aefc768292f076dc3ac8c48f3781c8f2d5851dd3d98950e8c5a89f" +checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8" dependencies = [ "objc2-encode", ] @@ -3610,12 +3139,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "block2 0.5.1", "libc", - "objc2 0.5.2", - "objc2-core-data 0.2.2", - "objc2-core-image 0.2.2", + "objc2 0.5.3", + "objc2-core-data", + "objc2-core-image", "objc2-foundation 0.2.2", "objc2-quartz-core 0.2.2", ] @@ -3626,17 +3155,11 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "block2 0.6.2", - "libc", - "objc2 0.6.4", - "objc2-cloud-kit 0.3.2", - "objc2-core-data 0.3.2", + "objc2 0.6.5", "objc2-core-foundation", "objc2-core-graphics", - "objc2-core-image 0.3.2", - "objc2-core-text", - "objc2-core-video", "objc2-foundation 0.3.2", "objc2-quartz-core 0.3.2", ] @@ -3647,9 +3170,9 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6948501a91121d6399b79abaa33a8aa4ea7857fe019f341b8c23ad6e81b79b08" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "libc", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-core-audio", "objc2-core-audio-types", "objc2-core-foundation", @@ -3662,8 +3185,8 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13a380031deed8e99db00065c45937da434ca987c034e13b87e4441f9e4090be" dependencies = [ - "bitflags 2.13.0", - "objc2 0.6.4", + "bitflags 2.13.2", + "objc2 0.6.5", "objc2-foundation 0.3.2", ] @@ -3673,24 +3196,13 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-core-location", "objc2-foundation 0.2.2", ] -[[package]] -name = "objc2-cloud-kit" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c" -dependencies = [ - "bitflags 2.13.0", - "objc2 0.6.4", - "objc2-foundation 0.3.2", -] - [[package]] name = "objc2-contacts" version = "0.2.2" @@ -3698,7 +3210,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" dependencies = [ "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-foundation 0.2.2", ] @@ -3709,7 +3221,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1eebcea8b0dbff5f7c8504f3107c68fc061a3eb44932051c8cf8a68d969c3b2" dependencies = [ "dispatch2", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-core-audio-types", "objc2-core-foundation", "objc2-foundation 0.3.2", @@ -3721,8 +3233,8 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a89f2ec274a0cf4a32642b2991e8b351a404d290da87bb6a9a9d8632490bd1c" dependencies = [ - "bitflags 2.13.0", - "objc2 0.6.4", + "bitflags 2.13.2", + "objc2 0.6.5", ] [[package]] @@ -3731,34 +3243,23 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-foundation 0.2.2", ] -[[package]] -name = "objc2-core-data" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa" -dependencies = [ - "bitflags 2.13.0", - "objc2 0.6.4", - "objc2-foundation 0.3.2", -] - [[package]] name = "objc2-core-foundation" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "block2 0.6.2", "dispatch2", "libc", - "objc2 0.6.4", + "objc2 0.6.5", ] [[package]] @@ -3767,9 +3268,9 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "dispatch2", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-core-foundation", "objc2-io-surface", ] @@ -3781,21 +3282,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" dependencies = [ "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-foundation 0.2.2", "objc2-metal 0.2.2", ] -[[package]] -name = "objc2-core-image" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d563b38d2b97209f8e861173de434bd0214cf020e3423a52624cd1d989f006" -dependencies = [ - "objc2 0.6.4", - "objc2-foundation 0.3.2", -] - [[package]] name = "objc2-core-location" version = "0.2.2" @@ -3803,7 +3294,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781" dependencies = [ "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-contacts", "objc2-foundation 0.2.2", ] @@ -3814,23 +3305,8 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d" dependencies = [ - "bitflags 2.13.0", - "objc2 0.6.4", + "bitflags 2.13.2", "objc2-core-foundation", - "objc2-core-graphics", -] - -[[package]] -name = "objc2-core-video" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6" -dependencies = [ - "bitflags 2.13.0", - "objc2 0.6.4", - "objc2-core-foundation", - "objc2-core-graphics", - "objc2-io-surface", ] [[package]] @@ -3845,11 +3321,11 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "block2 0.5.1", "dispatch", "libc", - "objc2 0.5.2", + "objc2 0.5.3", ] [[package]] @@ -3858,10 +3334,10 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "block2 0.6.2", "libc", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-core-foundation", ] @@ -3871,8 +3347,8 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" dependencies = [ - "bitflags 2.13.0", - "objc2 0.6.4", + "bitflags 2.13.2", + "objc2 0.6.5", "objc2-core-foundation", ] @@ -3883,7 +3359,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" dependencies = [ "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-app-kit 0.2.2", "objc2-foundation 0.2.2", ] @@ -3894,9 +3370,9 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-foundation 0.2.2", ] @@ -3906,8 +3382,9 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0125f776a10d00af4152d74616409f0d4a2053a6f57fa5b7d6aa2854ac04794" dependencies = [ - "bitflags 2.13.0", - "objc2 0.6.4", + "bitflags 2.13.2", + "block2 0.6.2", + "objc2 0.6.5", "objc2-foundation 0.3.2", ] @@ -3917,9 +3394,9 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-foundation 0.2.2", "objc2-metal 0.2.2", ] @@ -3930,9 +3407,10 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" dependencies = [ - "bitflags 2.13.0", - "objc2 0.6.4", + "bitflags 2.13.2", + "objc2 0.6.5", "objc2-core-foundation", + "objc2-core-graphics", "objc2-foundation 0.3.2", "objc2-metal 0.3.2", ] @@ -3943,7 +3421,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" dependencies = [ - "objc2 0.5.2", + "objc2 0.5.3", "objc2-foundation 0.2.2", ] @@ -3953,12 +3431,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "block2 0.5.1", - "objc2 0.5.2", - "objc2-cloud-kit 0.2.2", - "objc2-core-data 0.2.2", - "objc2-core-image 0.2.2", + "objc2 0.5.3", + "objc2-cloud-kit", + "objc2-core-data", + "objc2-core-image", "objc2-core-location", "objc2-foundation 0.2.2", "objc2-link-presentation", @@ -3974,9 +3452,9 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "block2 0.6.2", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-core-foundation", "objc2-foundation 0.3.2", "objc2-quartz-core 0.3.2", @@ -3989,7 +3467,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" dependencies = [ "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-foundation 0.2.2", ] @@ -3999,9 +3477,9 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "block2 0.5.1", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-core-location", "objc2-foundation 0.2.2", ] @@ -4016,12 +3494,6 @@ dependencies = [ "portable-atomic", ] -[[package]] -name = "opaque-debug" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" - [[package]] name = "option-ext" version = "0.2.0" @@ -4030,11 +3502,20 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "opus" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d3809943dff6fbad5f0484449ea26bdb9cb7d8efdf26ed50d3c7f227f69eb5c" +checksum = "33718946cc77d4032911d4efe03a66dbcbfbd2bb16c3da06aaeadcc637c32216" dependencies = [ - "audiopus_sys", + "opusic-sys", +] + +[[package]] +name = "opusic-sys" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9d1ecdf206421bc74343ab3bb2f30ad2abbfee41fa341f7181fecbaf957769a" +dependencies = [ + "cmake", ] [[package]] @@ -4047,6 +3528,15 @@ dependencies = [ "libredox", ] +[[package]] +name = "ordered-float" +version = "5.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c7c9e0d9b23589f26070720bac724174bfec1083e82f7854cdd0267518343c0" +dependencies = [ + "num-traits", +] + [[package]] name = "ordered-stream" version = "0.2.0" @@ -4058,12 +3548,13 @@ dependencies = [ ] [[package]] -name = "owned_ttf_parser" -version = "0.25.1" +name = "os_pipe" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36820e9051aca1014ddc75770aab4d68bc1e9e632f0f5627c4086bc216fb583b" +checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" dependencies = [ - "ttf-parser", + "libc", + "windows-sys 0.61.2", ] [[package]] @@ -4097,16 +3588,17 @@ dependencies = [ [[package]] name = "parlance" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6937eda350acc1a5d05872c3cbf99fe78619c269096e2be3d4a350058639d5" +checksum = "73072a9470554c8e794778acece2312661218aaabb635600957d952cf01c716e" [[package]] name = "parley" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b1cfcf399c774719fb1fa51bc6b91e86bdf003b03202a0902f1827ba6750746" +checksum = "22d2ff88bd3f7d68d1d9b09c7e6209f9a8e8c05088295140a2bcf2e9b17038c5" dependencies = [ + "accesskit", "fontique", "harfrust", "hashbrown 0.17.1", @@ -4121,48 +3613,51 @@ dependencies = [ [[package]] name = "parley_data" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1d3755e2cc12c0625b0cd2f2773c6a37dd11d1531940c945ade4aeb78f2b145" +checksum = "1567535334d6ba2d3cde19221ba9a7bd0fabb3cbd99046ddfb10ae061cfcc889" dependencies = [ "icu_properties", ] [[package]] name = "password-hash" -version = "0.5.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" +checksum = "aab41826031698d6ffcd9cff78ef56ef998e39dc7e5067cdfebe373842d4723b" dependencies = [ - "base64ct", - "rand_core 0.6.4", - "subtle", + "getrandom 0.4.3", + "phc", ] -[[package]] -name = "paste" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" - -[[package]] -name = "pastey" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec" - -[[package]] -name = "pastey" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4" - [[package]] name = "percent-encoding" version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "petgraph" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" +dependencies = [ + "fixedbitset", + "hashbrown 0.15.5", + "indexmap", +] + +[[package]] +name = "phc" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44dc769b75f93afdddd8c7fa12d685292ddeff1e66f7f0f3a234cf1818afe892" +dependencies = [ + "base64ct", + "ctutils", + "getrandom 0.4.3", +] + [[package]] name = "phf" version = "0.13.1" @@ -4194,7 +3689,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -4229,7 +3724,7 @@ checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -4240,9 +3735,9 @@ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "pin-utils" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +checksum = "13bee6c73da26345c729282832b60b0363cf3dd9f4bfd81d8551b7a1c889a113" [[package]] name = "pin-weak" @@ -4250,32 +3745,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b330c9d1b92dfe68442ca20b009c717d5f0b1e3cf4965e62f704c3c6e95a1305" -[[package]] -name = "piper" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1" -dependencies = [ - "atomic-waker", - "fastrand", - "futures-io", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "pkg-config" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" [[package]] name = "plain" @@ -4289,11 +3763,11 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "crc32fast", "fdeflate", "flate2", - "miniz_oxide", + "miniz_oxide 0.8.9", ] [[package]] @@ -4304,20 +3778,25 @@ checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" dependencies = [ "cfg-if", "concurrent-queue", - "hermit-abi 0.5.2", + "hermit-abi", "pin-project-lite", - "rustix 1.1.4", + "rustix 1.1.5", "windows-sys 0.61.2", ] [[package]] -name = "poly1305" -version = "0.8.0" +name = "pollster" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3" + +[[package]] +name = "poly1305" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2d0073b297041425c7c3df6eb4792d598a15323fe63346852b092eca02904c" dependencies = [ - "cpufeatures 0.2.17", - "opaque-debug", + "cpufeatures", "universal-hash", ] @@ -4332,18 +3811,27 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.13.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" dependencies = [ "critical-section", ] [[package]] -name = "potential_utf" -version = "0.1.5" +name = "portable-atomic-util" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" dependencies = [ "serde_core", "writeable", @@ -4351,13 +3839,10 @@ dependencies = [ ] [[package]] -name = "ppv-lite86" -version = "0.2.21" +name = "presser" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" -dependencies = [ - "zerocopy", -] +checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" [[package]] name = "prettyplease" @@ -4366,7 +3851,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn", + "syn 2.0.119", ] [[package]] @@ -4389,9 +3874,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.106" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" dependencies = [ "unicode-ident", ] @@ -4401,77 +3886,24 @@ name = "profiling" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5" -dependencies = [ - "profiling-procmacros", -] - -[[package]] -name = "profiling-procmacros" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4488a4a36b9a4ba6b9334a32a39971f77c1436ec82c38707bce707699cc3bbcb" -dependencies = [ - "quote", - "syn", -] [[package]] name = "pulldown-cmark" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f068eba8e7071c5f9511831b44f32c740d5adf574e990f946ddb53db2f314e" +checksum = "278e9268c93b9e498a2da46c34d90ba93a3255eb99009646398f34bc73ab36eb" dependencies = [ - "bitflags 2.13.0", - "getopts", + "bitflags 2.13.2", "memchr", - "pulldown-cmark-escape", "unicase", ] -[[package]] -name = "pulldown-cmark-escape" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d8adb5ddab6f8e3f491ac63566a7d5002cc7ed73901f72057943fa71ae1ae" - -[[package]] -name = "pulp" -version = "0.22.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046aa45b989642ec2e4717c8e72d677b13edd831a4d3b6cf37d9a3e54912496a" -dependencies = [ - "bytemuck", - "cfg-if", - "libm", - "num-complex", - "paste", - "pulp-wasm-simd-flag", - "raw-cpuid", - "reborrow", - "version_check", -] - -[[package]] -name = "pulp-wasm-simd-flag" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d8f70e07b9c3962945a74e59ca1c511bba65b6419468acc217c457d93f3c740" - [[package]] name = "pxfm" version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" -[[package]] -name = "qoi" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" -dependencies = [ - "bytemuck", -] - [[package]] name = "quick-error" version = "2.0.1" @@ -4480,18 +3912,18 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" [[package]] name = "quick-xml" -version = "0.39.4" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdcc8dd4e2f670d309a5f0e83fe36dfdc05af317008fea29144da1a2ac858e5e" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" dependencies = [ "memchr", ] [[package]] name = "quote" -version = "1.0.46" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" dependencies = [ "proc-macro2", ] @@ -4510,72 +3942,13 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] name = "rand" -version = "0.8.6" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" +checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" -dependencies = [ - "rand_chacha 0.9.0", - "rand_core 0.9.5", -] - -[[package]] -name = "rand" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" -dependencies = [ - "chacha20 0.10.1", + "chacha20", "getrandom 0.4.3", - "rand_core 0.10.1", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" -dependencies = [ - "ppv-lite86", - "rand_core 0.9.5", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.17", -] - -[[package]] -name = "rand_core" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" -dependencies = [ - "getrandom 0.3.4", + "rand_core", ] [[package]] @@ -4585,73 +3958,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" [[package]] -name = "rand_distr" -version = "0.6.0" +name = "range-alloc" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d431c2703ccf129de4d45253c03f49ebb22b97d6ad79ee3ecfc7e3f4862c1d8" -dependencies = [ - "num-traits", - "rand 0.10.2", -] - -[[package]] -name = "rav1e" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b6dd56e85d9483277cde964fd1bdb0428de4fec5ebba7540995639a21cb32b" -dependencies = [ - "aligned-vec", - "arbitrary", - "arg_enum_proc_macro", - "arrayvec", - "av-scenechange", - "av1-grain", - "bitstream-io", - "built", - "cfg-if", - "interpolate_name", - "itertools 0.14.0", - "libc", - "libfuzzer-sys", - "log", - "maybe-rayon", - "new_debug_unreachable", - "noop_proc_macro", - "num-derive", - "num-traits", - "paste", - "profiling", - "rand 0.9.5", - "rand_chacha 0.9.0", - "simd_helpers", - "thiserror 2.0.18", - "v_frame", - "wasm-bindgen", -] - -[[package]] -name = "ravif" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e52310197d971b0f5be7fe6b57530dcd27beb35c1b013f29d66c1ad73fbbcc45" -dependencies = [ - "avif-serialize", - "imgref", - "loop9", - "quick-error", - "rav1e", - "rayon", - "rgb", -] - -[[package]] -name = "raw-cpuid" -version = "11.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186" -dependencies = [ - "bitflags 2.13.0", -] +checksum = "ca45419789ae5a7899559e9512e58ca889e41f04f1f2445e9f4b290ceccd1d08" [[package]] name = "raw-window-handle" @@ -4665,7 +3975,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40d213455a5f1dc59214213c7330e074ddf8114c9a42411eb890c767357ce135" dependencies = [ - "objc2 0.6.4", + "objc2 0.6.5", "objc2-core-foundation", "objc2-foundation 0.3.2", "objc2-quartz-core 0.3.2", @@ -4693,12 +4003,13 @@ dependencies = [ [[package]] name = "read-fonts" -version = "0.39.2" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4ed38b89c2c77ff968c524145ad65fb010f38af5c7a224b53b81d47ac2daa81" +checksum = "046a7d674daf459825b32f5062056d6882db0d2f5a479fbd76ccfc870ac18709" dependencies = [ "bytemuck", "font-types", + "once_cell", ] [[package]] @@ -4710,12 +4021,6 @@ dependencies = [ "rustfft", ] -[[package]] -name = "reborrow" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03251193000f4bd3b042892be858ee50e8b3719f2b08e5833ac4353724632430" - [[package]] name = "redox_syscall" version = "0.4.1" @@ -4731,34 +4036,33 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", ] [[package]] name = "redox_syscall" -version = "0.9.0" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5102a6aaa05aa011a238e178e6bca86d2cb56fc9f586d37cb80f5bca6e07759" +checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", ] [[package]] name = "redox_users" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" +checksum = "60dc65c0ff1a7ae1294b0c67b9f14baf70b644404010370171787bfac1038fc0" dependencies = [ - "getrandom 0.2.17", "libredox", - "thiserror 2.0.18", + "thiserror 2.0.21", ] [[package]] name = "regex" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0e75113e14dc5acb068cd0786884f214f1312650a3d36d269f5c4f3cdee8a2" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" dependencies = [ "aho-corasick", "memchr", @@ -4768,9 +4072,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.14" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" dependencies = [ "aho-corasick", "memchr", @@ -4784,11 +4088,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" [[package]] -name = "resvg" -version = "0.47.0" +name = "renderdoc-sys" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be183ad6a216aa96f33e4c8033b0988b8b3ea6fd2359d19af5bac4643fd8e81" +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" + +[[package]] +name = "resvg" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e3803f97b999e80cbf7c6ecdd07a8102204d92e1633cf48783720c521196bd" dependencies = [ + "bytemuck", "gif", "image-webp", "log", @@ -4800,6 +4111,33 @@ dependencies = [ "zune-jpeg", ] +[[package]] +name = "rfd" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20dafead71c16a34e1ff357ddefc8afc11e7d51d6d2b9fbd07eaa48e3e540220" +dependencies = [ + "block2 0.6.2", + "dispatch2", + "js-sys", + "libc", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "percent-encoding", + "pollster", + "raw-window-handle", + "wasm-bindgen", + "wasm-bindgen-futures", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "web-sys", + "windows-sys 0.61.2", +] + [[package]] name = "rgb" version = "0.8.53" @@ -4809,39 +4147,24 @@ dependencies = [ "bytemuck", ] -[[package]] -name = "rodio" -version = "0.22.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0a536bb79db59098ef71a4dd4246c02eb87b316deceb1b68e0cde7167ec01eb" -dependencies = [ - "cpal 0.17.3", - "dasp_sample", - "num-rational", - "rand 0.10.2", - "rand_distr", - "rtrb", - "symphonia", - "thiserror 2.0.18", -] - [[package]] name = "rowan" -version = "0.16.1" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "417a3a9f582e349834051b8a10c8d71ca88da4211e4093528e36b9845f6b5f21" +checksum = "14b574c58582fa59fa43a2feb6608b8744184659f08a2e0117e4b8224d95ed61" dependencies = [ "countme", "hashbrown 0.14.5", + "memoffset", "rustc-hash 1.1.0", "text-size", ] [[package]] name = "roxmltree" -version = "0.21.1" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1964b10c76125c36f8afe190065a4bf9a87bf324842c05701330bba9f1cacbb" +checksum = "9da7f59328b09405b181fee1018925fad50f157afb43c0c0f5c522c256dd5907" dependencies = [ "memchr", ] @@ -4859,12 +4182,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "rtrb" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ade083ccbb4bf536df69d1f6432cc23deb7acccff86b183f3923a6fd56a1153" - [[package]] name = "rustc-hash" version = "1.1.0" @@ -4906,7 +4223,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "errno", "libc", "linux-raw-sys 0.4.15", @@ -4915,11 +4232,11 @@ dependencies = [ [[package]] name = "rustix" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "errno", "libc", "linux-raw-sys 0.12.1", @@ -4932,24 +4249,6 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" -[[package]] -name = "rustybuzz" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3c7c96f8a08ee34eff8857b11b49b07d71d1c3f4e88f8a88d4c9e9f90b1702" -dependencies = [ - "bitflags 2.13.0", - "bytemuck", - "core_maths", - "log", - "smallvec", - "ttf-parser", - "unicode-bidi-mirroring", - "unicode-ccc", - "unicode-properties", - "unicode-script", -] - [[package]] name = "same-file" version = "1.0.6" @@ -4980,13 +4279,10 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sctk-adwaita" version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6277f0217056f77f1d8f49f2950ac6c278c0d607c45f5ee99328d792ede24ec" dependencies = [ - "ab_glyph", + "crossfont", "log", - "memmap2", - "smithay-client-toolkit 0.19.2", + "smithay-client-toolkit", "tiny-skia 0.11.4", ] @@ -4998,9 +4294,9 @@ checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" [[package]] name = "serde" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" dependencies = [ "serde_core", "serde_derive", @@ -5018,29 +4314,29 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] name = "serde_json" -version = "1.0.150" +version = "1.0.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" dependencies = [ "itoa", "memchr", @@ -5051,44 +4347,33 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.20" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" +checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] name = "serde_spanned" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26" +checksum = "4e7523beb55eece201a2356bee0bbca0d1ab466c14c07703b2e0ee6d42cb0c2c" dependencies = [ "serde_core", ] [[package]] name = "sha2" -version = "0.10.9" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" dependencies = [ "cfg-if", - "cpufeatures 0.2.17", - "digest 0.10.7", -] - -[[package]] -name = "sha2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.0", - "digest 0.11.3", + "cpufeatures", + "digest", ] [[package]] @@ -5124,38 +4409,29 @@ dependencies = [ [[package]] name = "signature" -version = "2.2.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5" dependencies = [ - "rand_core 0.6.4", + "rand_core", ] [[package]] name = "simd-adler32" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" [[package]] name = "simd_cesu8" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94f90157bb87cddf702797c5dadfa0be7d266cdf49e22da2fcaa32eff75b2c33" +checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520" dependencies = [ "rustc_version", "simdutf8", ] -[[package]] -name = "simd_helpers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6" -dependencies = [ - "quote", -] - [[package]] name = "simdutf8" version = "0.1.5" @@ -5173,15 +4449,15 @@ dependencies = [ [[package]] name = "siphasher" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ee5873ec9cce0195efcb7a4e9507a04cd49aec9c83d0389df45b1ef7ba2e649" +checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" [[package]] name = "skia-bindings" -version = "0.99.0" +version = "0.153.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2d1c3ebd697c0cbded0145e9204a38fa6b268446051b7196d0a096414ea7f3" +checksum = "eb325787c91b3f6c34a7c6f2b8a2297b20292d733ca53a08c233e5028aec49af" dependencies = [ "bindgen", "cc", @@ -5196,20 +4472,20 @@ dependencies = [ [[package]] name = "skia-safe" -version = "0.99.0" +version = "0.153.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f512ac418a64194842dd05566320805dad1c957c521039db2486fd6368865bc" +checksum = "c61cb643dac43067f3eb76c866635a74377ac0abca0ff2590674e1e295514c3d" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "skia-bindings", "windows", ] [[package]] name = "skrifa" -version = "0.42.1" +version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c34617370ae968efb7161bb2beb517d9084659aae19e24b89e3db25b46e4564" +checksum = "819ab7d62b1d3e72d9d9dea5650bac30424f9111364bb94928dbf5ecad1baa68" dependencies = [ "bytemuck", "read-fonts", @@ -5223,9 +4499,9 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "slint" -version = "1.17.1" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce12038f57f8f3a423564b0c9301a2ab3fda4246e4cbadd6b97acf9124bdc315" +checksum = "15e477d5ff6fec20909100ff8f7062432ebfbda7a62a0f37d0252aa126f38c83" dependencies = [ "const-field-offset", "i-slint-backend-selector", @@ -5244,9 +4520,9 @@ dependencies = [ [[package]] name = "slint-build" -version = "1.17.1" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76684c11441f775b10bbc7b0e6b3016a39f17efdd659ffca112f17cfd6bdaed1" +checksum = "3ea28d4e1ad47d829b91e227f17037fac07a8001668a93fee47ac04f88718ebc" dependencies = [ "derive_more", "fontique", @@ -5257,9 +4533,9 @@ dependencies = [ [[package]] name = "slint-macros" -version = "1.17.1" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f2a763e72e1e53c496f571d36327e777da1eb0d9e58fceb83890c2a83ee7223" +checksum = "35e74b13d20884dc480ce37d0fabbf02cb4bc0df2a595434feac96ca7c2a0f15" dependencies = [ "i-slint-compiler", "proc-macro2", @@ -5278,9 +4554,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.15.2" +version = "1.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" +checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8" [[package]] name = "smithay-client-toolkit" @@ -5288,9 +4564,9 @@ version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "calloop 0.13.0", - "calloop-wayland-source 0.3.0", + "calloop-wayland-source", "cursor-icon", "libc", "log", @@ -5307,44 +4583,6 @@ dependencies = [ "xkeysym", ] -[[package]] -name = "smithay-client-toolkit" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0512da38f5e2b31201a93524adb8d3136276fa4fe4aafab4e1f727a82b534cc0" -dependencies = [ - "bitflags 2.13.0", - "calloop 0.14.4", - "calloop-wayland-source 0.4.1", - "cursor-icon", - "libc", - "log", - "memmap2", - "rustix 1.1.4", - "thiserror 2.0.18", - "wayland-backend", - "wayland-client", - "wayland-csd-frame", - "wayland-cursor", - "wayland-protocols", - "wayland-protocols-experimental", - "wayland-protocols-misc", - "wayland-protocols-wlr", - "wayland-scanner", - "xkeysym", -] - -[[package]] -name = "smithay-clipboard" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71704c03f739f7745053bde45fa203a46c58d25bc5c4efba1d9a60e9dba81226" -dependencies = [ - "libc", - "smithay-client-toolkit 0.20.0", - "wayland-backend", -] - [[package]] name = "smol_str" version = "0.2.2" @@ -5356,9 +4594,9 @@ dependencies = [ [[package]] name = "smol_str" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4aaa7368fcf4852a4c2dd92df0cace6a71f2091ca0a23391ce7f3a31833f1523" +checksum = "eeb7109d23f319619d4cc0de5464613c8b7b1a09db2774a58101459cf6be2f10" dependencies = [ "borsh", "serde_core", @@ -5382,14 +4620,14 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "socket2" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" dependencies = [ "libc", "windows-sys 0.61.2", @@ -5407,14 +4645,14 @@ dependencies = [ "js-sys", "memmap2", "ndk", - "objc2 0.6.4", + "objc2 0.6.5", "objc2-core-foundation", "objc2-core-graphics", "objc2-foundation 0.3.2", "objc2-quartz-core 0.3.2", "raw-window-handle", "redox_syscall 0.5.18", - "rustix 1.1.4", + "rustix 1.1.5", "tiny-xlib", "tracing", "wasm-bindgen", @@ -5436,13 +4674,12 @@ dependencies = [ ] [[package]] -name = "spki" -version = "0.7.3" +name = "spirv" +version = "0.4.0+sdk-1.4.341.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +checksum = "d9571ea910ebd84c86af4b3ed27f9dbdc6ad06f17c5f96146b2b671e2976744f" dependencies = [ - "base64ct", - "der", + "bitflags 2.13.2", ] [[package]] @@ -5490,7 +4727,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -5511,9 +4748,9 @@ dependencies = [ [[package]] name = "swash" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0811b01ca2c4e8718760713911feaf4675c24f94e50530a015ec646cfb622f7c" +checksum = "6c2499c2d826531388872b2268718aed907a39bd785ab0dcfe57fab26283f92e" dependencies = [ "skrifa", "yazi", @@ -5521,157 +4758,21 @@ dependencies = [ ] [[package]] -name = "symphonia" -version = "0.5.5" +name = "syn" +version = "2.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5773a4c030a19d9bfaa090f49746ff35c75dfddfa700df7a5939d5e076a57039" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" dependencies = [ - "lazy_static", - "symphonia-bundle-flac", - "symphonia-bundle-mp3", - "symphonia-codec-aac", - "symphonia-codec-pcm", - "symphonia-codec-vorbis", - "symphonia-core", - "symphonia-format-isomp4", - "symphonia-format-ogg", - "symphonia-format-riff", - "symphonia-metadata", -] - -[[package]] -name = "symphonia-bundle-flac" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c91565e180aea25d9b80a910c546802526ffd0072d0b8974e3ebe59b686c9976" -dependencies = [ - "log", - "symphonia-core", - "symphonia-metadata", - "symphonia-utils-xiph", -] - -[[package]] -name = "symphonia-bundle-mp3" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4872dd6bb56bf5eac799e3e957aa1981086c3e613b27e0ac23b176054f7c57ed" -dependencies = [ - "lazy_static", - "log", - "symphonia-core", - "symphonia-metadata", -] - -[[package]] -name = "symphonia-codec-aac" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c263845aa86881416849c1729a54c7f55164f8b96111dba59de46849e73a790" -dependencies = [ - "lazy_static", - "log", - "symphonia-core", -] - -[[package]] -name = "symphonia-codec-pcm" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e89d716c01541ad3ebe7c91ce4c8d38a7cf266a3f7b2f090b108fb0cb031d95" -dependencies = [ - "log", - "symphonia-core", -] - -[[package]] -name = "symphonia-codec-vorbis" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f025837c309cd69ffef572750b4a2257b59552c5399a5e49707cc5b1b85d1c73" -dependencies = [ - "log", - "symphonia-core", - "symphonia-utils-xiph", -] - -[[package]] -name = "symphonia-core" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea00cc4f79b7f6bb7ff87eddc065a1066f3a43fe1875979056672c9ef948c2af" -dependencies = [ - "arrayvec", - "bitflags 1.3.2", - "bytemuck", - "lazy_static", - "log", -] - -[[package]] -name = "symphonia-format-isomp4" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243739585d11f81daf8dac8d9f3d18cc7898f6c09a259675fc364b382c30e0a5" -dependencies = [ - "encoding_rs", - "log", - "symphonia-core", - "symphonia-metadata", - "symphonia-utils-xiph", -] - -[[package]] -name = "symphonia-format-ogg" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b4955c67c1ed3aa8ae8428d04ca8397fbef6a19b2b051e73b5da8b1435639cb" -dependencies = [ - "log", - "symphonia-core", - "symphonia-metadata", - "symphonia-utils-xiph", -] - -[[package]] -name = "symphonia-format-riff" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2d7c3df0e7d94efb68401d81906eae73c02b40d5ec1a141962c592d0f11a96f" -dependencies = [ - "extended", - "log", - "symphonia-core", - "symphonia-metadata", -] - -[[package]] -name = "symphonia-metadata" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36306ff42b9ffe6e5afc99d49e121e0bd62fe79b9db7b9681d48e29fa19e6b16" -dependencies = [ - "encoding_rs", - "lazy_static", - "log", - "symphonia-core", -] - -[[package]] -name = "symphonia-utils-xiph" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27c85ab799a338446b68eec77abf42e1a6f1bb490656e121c6e27bfbab9f16" -dependencies = [ - "symphonia-core", - "symphonia-metadata", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] name = "syn" -version = "2.0.118" +version = "3.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" dependencies = [ "proc-macro2", "quote", @@ -5680,13 +4781,13 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.13.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] @@ -5733,7 +4834,7 @@ dependencies = [ "fastrand", "getrandom 0.4.3", "once_cell", - "rustix 1.1.4", + "rustix 1.1.5", "windows-sys 0.61.2", ] @@ -5754,11 +4855,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.18" +version = "2.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" dependencies = [ - "thiserror-impl 2.0.18", + "thiserror-impl 2.0.21", ] [[package]] @@ -5769,43 +4870,29 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "thiserror-impl" -version = "2.0.18" +version = "2.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] name = "thread_local" -version = "1.1.9" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070" dependencies = [ "cfg-if", ] -[[package]] -name = "tiff" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63feaf3343d35b6ca4d50483f94843803b0f51634937cc2ec519fc32232bc52" -dependencies = [ - "fax", - "flate2", - "half", - "quick-error", - "weezl", - "zune-jpeg", -] - [[package]] name = "tiny-skia" version = "0.11.4" @@ -5872,9 +4959,9 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" dependencies = [ "displaydoc", "serde_core", @@ -5883,24 +4970,15 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.12.0" +version = "1.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb4ebadaa0af04fab11ae01eb5f9fdb5f9c5b875506e210e71c07873528baa7f" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" [[package]] name = "tokio" -version = "1.52.3" +version = "1.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" dependencies = [ "bytes", "libc", @@ -5915,20 +4993,20 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.7.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] name = "toml" -version = "1.1.2+spec-1.1.0" +version = "1.1.8+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81f3d15e84cbcd896376e6730314d59fb5a87f31e4b038454184435cd57defee" +checksum = "20489e00e4d8741d6be680764cc12e270655e375a20d1011e844a9c3379e678d" dependencies = [ "indexmap", "serde_core", @@ -5941,18 +5019,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "1.1.1+spec-1.1.0" +version = "1.1.2+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" +checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053" dependencies = [ "serde_core", ] [[package]] name = "toml_edit" -version = "0.25.12+spec-1.1.0" +version = "0.25.17+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2153edc6955a6c354fad8f5efd38b6a8769bdccf9fe50f8e1329f81b0baa5d7" +checksum = "e3641d5bbb5349a79e1020a242d251efbc546ad8048d133958323ce9c40a9c9c" dependencies = [ "indexmap", "toml_datetime", @@ -5963,18 +5041,18 @@ dependencies = [ [[package]] name = "toml_parser" -version = "1.1.2+spec-1.1.0" +version = "1.1.5+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" dependencies = [ "winnow", ] [[package]] name = "toml_writer" -version = "1.1.1+spec-1.1.0" +version = "1.1.3+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "756daf9b1013ebe47a8776667b466417e2d4c5679d441c26230efd9ef78692db" +checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770" [[package]] name = "tracing" @@ -5996,7 +5074,7 @@ checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -6049,21 +5127,22 @@ dependencies = [ ] [[package]] -name = "ttf-parser" -version = "0.25.1" +name = "tree_magic_mini" +version = "3.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" +checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6" dependencies = [ - "core_maths", + "memchr", + "nom 8.0.0", + "petgraph", ] [[package]] name = "typed-index-collections" -version = "3.5.0" +version = "3.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "898160f1dfd383b4e92e17f0512a7d62f3c51c44937b23b6ffc3a1614a8eaccd" +checksum = "8d844b11f547a6fb9dee7ed073d9860174917a072aabe05df6ee60dbe79e7afa" dependencies = [ - "bincode", "serde", ] @@ -6073,18 +5152,6 @@ version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" -[[package]] -name = "udev" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4e37e9ea4401fc841ff54b9ddfc9be1079b1e89434c1a6a865dd68980f7e9f" -dependencies = [ - "io-lifetimes", - "libc", - "libudev-sys", - "pkg-config", -] - [[package]] name = "uds_windows" version = "1.2.1" @@ -6098,9 +5165,9 @@ dependencies = [ [[package]] name = "unicase" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142" +checksum = "357cc3acc6a036009fd6c973ed009037c732d60d0b4f6c673e9041497482a28f" [[package]] name = "unicode-bidi" @@ -6108,23 +5175,11 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" -[[package]] -name = "unicode-bidi-mirroring" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfa6e8c60bb66d49db113e0125ee8711b7647b5579dc7f5f19c42357ed039fe" - -[[package]] -name = "unicode-ccc" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce61d488bcdc9bc8b5d1772c404828b17fc481c0a582b5581e95fb233aef503e" - [[package]] name = "unicode-ident" -version = "1.0.24" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" [[package]] name = "unicode-linebreak" @@ -6132,12 +5187,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" -[[package]] -name = "unicode-properties" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" - [[package]] name = "unicode-script" version = "0.5.8" @@ -6170,20 +5219,14 @@ checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "universal-hash" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +checksum = "f4987bdc12753382e0bec4a65c50738ffaabc998b9cdd1f952fb5f39b0048a96" dependencies = [ - "crypto-common 0.1.7", - "subtle", + "crypto-common", + "ctutils", ] -[[package]] -name = "unty" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" - [[package]] name = "url" version = "2.5.8" @@ -6198,26 +5241,26 @@ dependencies = [ [[package]] name = "usvg" -version = "0.47.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d46cf96c5f498d36b7a9693bc6a7075c0bb9303189d61b2249b0dc3d309c07de" +checksum = "977d0a4abdef933f424a99fe09f95576e089b90aebc6f016a3bc813762493e91" dependencies = [ "base64", "data-url", "flate2", "fontdb", + "harfrust", "imagesize", "kurbo", "log", "pico-args", "roxmltree", - "rustybuzz", "simplecss", "siphasher", + "skrifa", "strict-num", "svgtypes", "tiny-skia-path 0.12.0", - "ttf-parser", "unicode-bidi", "unicode-script", "unicode-vo", @@ -6232,9 +5275,9 @@ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] name = "uuid" -version = "1.23.4" +version = "1.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf80a72845275afea99e7f2b434723d3bc7e38470fcd1c7ed39a599c73319a53" +checksum = "4a0e2d11620c50695fe12bbbfde96b3477fe606e7284c22d505c12ce51214514" dependencies = [ "getrandom 0.4.3", "js-sys", @@ -6242,17 +5285,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "v_frame" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "666b7727c8875d6ab5db9533418d7c764233ac9c0cff1d469aec8fa127597be2" -dependencies = [ - "aligned-vec", - "num-traits", - "wasm-bindgen", -] - [[package]] name = "valuable" version = "0.1.1" @@ -6272,33 +5304,35 @@ dependencies = [ "anyhow", "argon2", "chacha20poly1305", - "cpal 0.18.1", + "cpal", "dirs", "ed25519-dalek", "hex", "hkdf", + "image", "nnnoiseless", "opus", - "rand 0.8.6", - "rodio", + "rand", + "rfd", "serde", "serde_bytes", "serde_json", - "sha2 0.11.0", + "sha2", "slint", "slint-build", "tokio", "tracing", "tracing-subscriber", + "typed-index-collections", "uuid", "x25519-dalek", ] [[package]] name = "vtable" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea953f65593feb5287b022b83c35046d1ff49c7417b6f5851a079d8a231fe31" +checksum = "515a4b5b1399cc46fb0dc4081436cb40a3852a2d3e94fd1fa50bb68a334896eb" dependencies = [ "const-field-offset", "portable-atomic", @@ -6308,13 +5342,13 @@ dependencies = [ [[package]] name = "vtable-macro" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "482a37f9777480673d3a99c80ac2edc69f92382230440946855fa27ebc47cba6" +checksum = "8191d73ececf73fc94e65809bf0e667525a0bcff9aeeb8d042a4173a508332a1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] [[package]] @@ -6344,9 +5378,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.126" +version = "0.2.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4" +checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409" dependencies = [ "cfg-if", "once_cell", @@ -6357,19 +5391,20 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.76" +version = "0.4.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62df1340f32221cb9c54d6a27b030e3dba64361d4a95bed55f9aacb44da291d" +checksum = "3cbab34de2d982e9b48e18d216d04c4a6f641066ff19ffb699980f591ee3610e" dependencies = [ "js-sys", + "tokio", "wasm-bindgen", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.126" +version = "0.2.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1" +checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -6377,35 +5412,35 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.126" +version = "0.2.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e" +checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7" dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn", + "syn 3.0.9", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.126" +version = "0.2.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24" +checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6" dependencies = [ "unicode-ident", ] [[package]] name = "wayland-backend" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2857dd20b54e916ec7253b3d6b4d5c4d7d4ca2c33c2e11c6c76a99bd8744755d" +checksum = "38a91b4eaddff87b1cd1074985e3713da4af2c49742d1b356b2c01670a67a078" dependencies = [ "cc", "downcast-rs", - "rustix 1.1.4", + "rustix 1.1.5", "scoped-tls", "smallvec", "wayland-sys", @@ -6413,12 +5448,12 @@ dependencies = [ [[package]] name = "wayland-client" -version = "0.31.14" +version = "0.31.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c7c96bb74690c3189b5c9cb4ca1627062bb23693a4fad9d8c3de958260144" +checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073" dependencies = [ - "bitflags 2.13.0", - "rustix 1.1.4", + "bitflags 2.13.2", + "rustix 1.1.5", "wayland-backend", "wayland-scanner", ] @@ -6429,7 +5464,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "cursor-icon", "wayland-backend", ] @@ -6440,7 +5475,7 @@ version = "0.31.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d" dependencies = [ - "rustix 1.1.4", + "rustix 1.1.5", "wayland-client", "xcursor", ] @@ -6451,45 +5486,19 @@ version = "0.32.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23d0c813de3daa2ed6520af85a3bd49b0e722a3078506899aa9686fea58dc4b6" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "wayland-backend", "wayland-client", "wayland-scanner", ] -[[package]] -name = "wayland-protocols-experimental" -version = "20250721.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a1f863128dcaaec790d7b4b396cc9b9a7a079e878e18c47e6c2d2c5a8dcbb1" -dependencies = [ - "bitflags 2.13.0", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-scanner", -] - -[[package]] -name = "wayland-protocols-misc" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e9567599ef23e09b8dad6e429e5738d4509dfc46b3b21f32841a304d16b29c8" -dependencies = [ - "bitflags 2.13.0", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-scanner", -] - [[package]] name = "wayland-protocols-plasma" version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b6d8cf1eb2c1c31ed1f5643c88a6e53538129d4af80030c8cabd1f9fa884d91" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "wayland-backend", "wayland-client", "wayland-protocols", @@ -6502,7 +5511,7 @@ version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "wayland-backend", "wayland-client", "wayland-protocols", @@ -6511,9 +5520,9 @@ dependencies = [ [[package]] name = "wayland-scanner" -version = "0.31.10" +version = "0.31.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c324a910fd86ebdc364a3e61ec1f11737d3b1d6c273c0239ee8ff4bc0d24b4a" +checksum = "338e30461b3a2b67d70eb30a6d89f8e0c93a833e07d2ae89085cd070c4a00ac0" dependencies = [ "proc-macro2", "quick-xml", @@ -6534,9 +5543,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.103" +version = "0.3.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8622dcb61c0bcc9fffa6938bed81210af2da9a7e4a1a834b2e37a59b6dfb6141" +checksum = "88261b9deccee56594c11a3460c462c41f58d148598fe70ad77070126a68aba4" dependencies = [ "js-sys", "wasm-bindgen", @@ -6554,15 +5563,15 @@ dependencies = [ [[package]] name = "webbrowser" -version = "1.2.1" +version = "1.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc95580916af1e68ff6a7be07446fc5db73ebf71cf092de939bbf5f7e189f72" +checksum = "d2c8ddfbbf66e501434657400268cefe51b95140a0266236415cda7627732df7" dependencies = [ - "core-foundation 0.10.1", - "jni 0.22.4", + "jni", "log", "ndk-context", - "objc2 0.6.4", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", "objc2-foundation 0.3.2", "url", "web-sys", @@ -6574,6 +5583,168 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" +[[package]] +name = "wgpu" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527ccdf43dd5b2e8676eed9984ce00e2bbb0a1b85b70c1969dcb6cd2eb55ab9e" +dependencies = [ + "arrayvec", + "bitflags 2.13.2", + "bytemuck", + "cfg-if", + "cfg_aliases", + "document-features", + "hashbrown 0.17.1", + "log", + "portable-atomic", + "profiling", + "raw-window-handle", + "smallvec", + "static_assertions", + "wgpu-core", + "wgpu-hal", + "wgpu-types", +] + +[[package]] +name = "wgpu-core" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c018fce9b6270aa203c2fdd56f3cce996713534bd757e4ea58c8560b121f14" +dependencies = [ + "arrayvec", + "bit-set", + "bit-vec", + "bitflags 2.13.2", + "bytemuck", + "cfg_aliases", + "document-features", + "hashbrown 0.17.1", + "indexmap", + "log", + "naga", + "naga-types", + "once_cell", + "parking_lot", + "portable-atomic", + "profiling", + "raw-window-handle", + "rustc-hash 1.1.0", + "smallvec", + "thiserror 2.0.21", + "wgpu-core-deps-apple", + "wgpu-core-deps-windows-linux-android", + "wgpu-hal", + "wgpu-naga-bridge", + "wgpu-types", +] + +[[package]] +name = "wgpu-core-deps-apple" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "061f3d319a40d39d00b1ecc2c33b89fe21d4e6fe01859df3500a3a8ecccd6b68" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-windows-linux-android" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7586165fd5f6d881cb9ce4bb71f40d6caab2c0f1837e3fc1d9788a197fb6004f" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-hal" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b7fb58561a792bc237628ba0792e332de418fefe145f13b5ed8201e6d52f58" +dependencies = [ + "android_system_properties", + "arrayvec", + "ash", + "bit-set", + "bitflags 2.13.2", + "block2 0.6.2", + "bytemuck", + "cfg-if", + "cfg_aliases", + "gpu-allocator", + "hashbrown 0.17.1", + "libc", + "libloading", + "log", + "naga", + "naga-types", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "objc2-metal 0.3.2", + "objc2-quartz-core 0.3.2", + "once_cell", + "ordered-float", + "parking_lot", + "portable-atomic", + "portable-atomic-util", + "profiling", + "range-alloc", + "raw-window-handle", + "raw-window-metal", + "renderdoc-sys", + "smallvec", + "static_assertions", + "thiserror 2.0.21", + "wgpu-naga-bridge", + "wgpu-types", + "windows", + "windows-core", +] + +[[package]] +name = "wgpu-naga-bridge" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f62e73117bb7a62bfd9c5a5841438a823f6566c6442a808ee269d2d055c081" +dependencies = [ + "naga", + "wgpu-types", +] + +[[package]] +name = "wgpu-types" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99dad6f1fbdbbdb4c278a6508b059d44688f5cebddf78d005a46a31340269286" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "log", + "naga-types", + "raw-window-handle", + "static_assertions", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + [[package]] name = "winapi-util" version = "0.1.11" @@ -6583,6 +5754,12 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + [[package]] name = "windows" version = "0.62.2" @@ -6636,7 +5813,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -6647,7 +5824,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -6684,31 +5861,13 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -6717,7 +5876,7 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -6729,50 +5888,20 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] @@ -6784,54 +5913,18 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -6844,72 +5937,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -6925,21 +5970,21 @@ dependencies = [ "ahash", "android-activity", "atomic-waker", - "bitflags 2.13.0", + "bitflags 2.13.2", "block2 0.5.1", "bytemuck", "calloop 0.13.0", "cfg_aliases", "concurrent-queue", "core-foundation 0.9.4", - "core-graphics", + "core-graphics 0.23.2", "cursor-icon", "dpi", "js-sys", "libc", "memmap2", "ndk", - "objc2 0.5.2", + "objc2 0.5.3", "objc2-app-kit 0.2.2", "objc2-foundation 0.2.2", "objc2-ui-kit 0.2.2", @@ -6950,7 +5995,7 @@ dependencies = [ "redox_syscall 0.4.1", "rustix 0.38.44", "sctk-adwaita", - "smithay-client-toolkit 0.19.2", + "smithay-client-toolkit", "smol_str 0.2.2", "tracing", "unicode-segmentation", @@ -6970,13 +6015,22 @@ dependencies = [ [[package]] name = "winnow" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0592e1c9d151f854e6fd382574c3a0855250e1d9b2f99d9281c6e6391af352f1" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" dependencies = [ "memchr", ] +[[package]] +name = "wio" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5" +dependencies = [ + "winapi", +] + [[package]] name = "wit-bindgen" version = "0.57.1" @@ -6984,10 +6038,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" [[package]] -name = "write-fonts" -version = "0.48.1" +name = "wl-clipboard-rs" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb731d4c4d93eacc69a1ad2f270f905788a98e4a3438267bcafbe08d3431c8d8" +checksum = "4d7888ccd4896447b2d14d3a9350a85df2aeb6f181e2e7a31349d104ac46cac1" +dependencies = [ + "libc", + "log", + "os_pipe", + "rustix 1.1.5", + "thiserror 2.0.21", + "tree_magic_mini", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-wlr", +] + +[[package]] +name = "write-fonts" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cae90d1d9f6d1d36ef116b0b1e651a6d7c12ba925439d4d06ff9adc94662a3d8" dependencies = [ "font-types", "indexmap", @@ -6998,19 +6070,9 @@ dependencies = [ [[package]] name = "writeable" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" - -[[package]] -name = "x11-clipboard" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "662d74b3d77e396b8e5beb00b9cad6a9eccf40b2ef68cc858784b14c41d535a3" -dependencies = [ - "libc", - "x11rb", -] +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" [[package]] name = "x11-dl" @@ -7034,7 +6096,7 @@ dependencies = [ "libc", "libloading", "once_cell", - "rustix 1.1.4", + "rustix 1.1.5", "x11rb-protocol", ] @@ -7046,13 +6108,12 @@ checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd" [[package]] name = "x25519-dalek" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" +checksum = "e7e8131a03190127fb2263afc72b322ecadae46b6ff8c6f399ff5d02f5559af6" dependencies = [ "curve25519-dalek", - "rand_core 0.6.4", - "serde", + "rand_core", "zeroize", ] @@ -7063,25 +6124,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32e45ad4206f6d2479085147f02bc2ef834ac85886624a23575ae137c8aa8156" dependencies = [ "libc", - "rustix 1.1.4", + "rustix 1.1.5", ] [[package]] name = "xcursor" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec9e4a500ca8864c5b47b8b482a73d62e4237670e5b5f1d6b9e3cae50f28f2b" - -[[package]] -name = "xkbcommon" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a974f48060a14e95705c01f24ad9c3345022f4d97441b8a36beb7ed5c4a02d" -dependencies = [ - "libc", - "memmap2", - "xkeysym", -] +checksum = "163b33ed8786455e2fa5d72f554057ce3f3182425434f756cd39c99839d88e23" [[package]] name = "xkbcommon-dl" @@ -7089,7 +6139,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" dependencies = [ - "bitflags 2.13.0", + "bitflags 2.13.2", "dlib", "log", "once_cell", @@ -7104,9 +6154,9 @@ checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" [[package]] name = "xml-rs" -version = "0.8.28" +version = "0.8.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f" +checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7" [[package]] name = "xmlwriter" @@ -7114,12 +6164,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" -[[package]] -name = "y4m" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5a4b21e1a62b67a2970e6831bc091d7b87e119e7f9791aef9702e3bef04448" - [[package]] name = "yazi" version = "0.2.1" @@ -7128,9 +6172,9 @@ checksum = "e01738255b5a16e78bbb83e7fbba0a1e7dd506905cfc53f4622d89015a03fbb5" [[package]] name = "yeslogic-fontconfig-sys" -version = "6.0.1" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d8b8abf912b9a29ff112e1671c97c33636903d13a69712037190e6805af4f76" +checksum = "503a066b4c037c440169d995b869046827dbc71263f6e8f3be6d77d4f3229dbd" dependencies = [ "dlib", "once_cell", @@ -7139,9 +6183,9 @@ dependencies = [ [[package]] name = "yoke" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" dependencies = [ "stable_deref_trait", "yoke-derive", @@ -7150,111 +6194,105 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", "synstructure", ] [[package]] name = "zbus" -version = "5.17.0" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28b97f866896a4be7aefd2b5a8e01bb6773d19a775d54ab28b4d094b9a4480e" +checksum = "fcff5faa63a63d5b81051740f7382017f10b3440b3f401d97f0cf0b3b39c62d9" dependencies = [ - "async-broadcast", - "async-executor", - "async-io", - "async-lock", - "async-process", - "async-recursion", - "async-task", "async-trait", - "blocking", - "enumflags2", - "event-listener", + "bitflags 2.13.2", + "endi", "futures-core", - "futures-lite", "hex", "libc", "ordered-stream", - "rustix 1.1.4", + "rustix 1.1.5", "serde", "serde_repr", - "tracing", + "socket2", "uds_windows", "uuid", "windows-sys 0.61.2", "winnow", "zbus_macros", - "zbus_names", - "zvariant", + "zbus_utils", + "zcheapstr", + "zruntime", ] [[package]] name = "zbus-lockstep" version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6998de05217a084b7578728a9443d04ea4cd80f2a0839b8d78770b76ccd45863" dependencies = [ + "zbus", "zbus_xml", - "zvariant", ] [[package]] name = "zbus-lockstep-macros" version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10da05367f3a7b7553c8cdf8fa91aee6b64afebe32b51c95177957efc47ca3a0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", + "zbus", "zbus-lockstep", "zbus_xml", - "zvariant", ] [[package]] name = "zbus_macros" -version = "5.17.0" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e05ad887425eecf5e8384dc2406a4a9313eb73468712fc1cdea362eb4fe0469" +checksum = "5bba6e2bfe19571dc81b3e0be9f8daec6e5422db3e2eea2e766a859553e7bd37" dependencies = [ - "proc-macro-crate", "proc-macro2", "quote", - "syn", - "zbus_names", - "zvariant", - "zvariant_utils", + "syn 3.0.9", + "zbus_utils", ] [[package]] -name = "zbus_names" -version = "4.3.3" +name = "zbus_utils" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1039ca249fee9559680f3a9f05b55e0761fee51af4f6c1e7d8c1f31e549721d2" +checksum = "c27a055b114bd9fc3686e90f62bd1fe612d523fc5f620bac3b1d2f42d3f6cab8" dependencies = [ + "proc-macro2", + "quote", "serde", + "syn 3.0.9", "winnow", - "zvariant", ] [[package]] name = "zbus_xml" -version = "5.2.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ab0513c0a66a60a8718d5ad712a5094845a20d95b5c1c81e2bd8e904a52b4f" +checksum = "d21954afb379fe9389d5aaa8a91f9e1a19b58f72061a78199162ea39e63c801a" +dependencies = [ + "winnow", + "zbus", +] + +[[package]] +name = "zcheapstr" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1afec51604565183aeb5c54c20aeab286120d4e4460f7f76e3e8bb8c0d99473" dependencies = [ "serde", - "winnow", - "zbus_names", - "zvariant", ] [[package]] @@ -7265,22 +6303,22 @@ checksum = "6df3dc4292935e51816d896edcd52aa30bc297907c26167fec31e2b0c6a32524" [[package]] name = "zerocopy" -version = "0.8.54" +version = "0.8.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7cbbc0a705a0fd05cc3676525980d2bf5a9bc4adac6d6475209a7887cf59d19" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.54" +version = "0.8.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e817b7b52d0c7358d3246da9d69935ebb18116b2b102b4230dac079b4862f5" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -7294,41 +6332,27 @@ dependencies = [ [[package]] name = "zerofrom-derive" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", "synstructure", ] [[package]] name = "zeroize" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] +checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" [[package]] name = "zerotrie" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" dependencies = [ "displaydoc", "yoke", @@ -7338,9 +6362,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.6" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" dependencies = [ "serde", "yoke", @@ -7350,35 +6374,45 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.11.3" +version = "0.11.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.9", ] +[[package]] +name = "zlib-rs" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" + [[package]] name = "zmij" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + +[[package]] +name = "zruntime" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc035df602243402949ddf3dcc5bcfad7edeb732dd49ec6e605431c4eca54ce" +dependencies = [ + "futures-core", + "futures-io", + "rustix 1.1.5", + "socket2", + "windows-sys 0.61.2", +] [[package]] name = "zune-core" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb8a0807f7c01457d0379ba880ba6322660448ddebc890ce29bb64da71fb40f9" - -[[package]] -name = "zune-inflate" -version = "0.2.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" -dependencies = [ - "simd-adler32", -] +checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" [[package]] name = "zune-jpeg" @@ -7388,43 +6422,3 @@ checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" dependencies = [ "zune-core", ] - -[[package]] -name = "zvariant" -version = "5.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cf057bb00bf5c9ad77abb6147b0ca4818236a1858416e9d988e40d6322fefa7" -dependencies = [ - "endi", - "enumflags2", - "serde", - "winnow", - "zvariant_derive", - "zvariant_utils", -] - -[[package]] -name = "zvariant_derive" -version = "5.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8118ca6bda77bfc0ab51d660db0c955f2505eef854c9a449435bccb616933b31" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", - "zvariant_utils", -] - -[[package]] -name = "zvariant_utils" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90cb9383f9b45290407a1258b202d3f8f01db719eb60b4e4055c6375af4fc7c7" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "syn", - "winnow", -] diff --git a/Cargo.toml b/Cargo.toml index 04b13f9..c4408ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,15 +1,16 @@ [workspace] resolver = "2" +exclude = ["patches/*"] [package] name = "vnox-client" -description = "VNOX desktop client — egui + wgpu" +description = "VNOX native desktop client — Slint, chat and voice" version = "0.1.0" edition = "2024" license = "GPL-3.0" authors = ["VNOX Contributors"] repository = "https://github.com/loki5512344/Vnox" -rust-version = "1.85" +rust-version = "1.94" default-run = "vnox-client" [lib] @@ -25,32 +26,48 @@ name = "vnox-e2e-voice" path = "src/bin/e2e_voice.rs" [build-dependencies] -slint-build = "1" +slint-build = "=1.18.1" +# Compatible compiler utility before its unused bincode integration was added. +typed-index-collections = "=3.2.3" [dependencies] -tokio = { version = "1.52", features = ["full"] } +tokio = { version = "1.54", features = ["full"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde_bytes = "0.11" -ed25519-dalek = { version = "2", features = ["rand_core"] } -x25519-dalek = { version = "2", features = ["static_secrets"] } -chacha20poly1305 = "0.10" +ed25519-dalek = { version = "3", features = ["rand_core"] } +x25519-dalek = { version = "3", features = ["static_secrets"] } +chacha20poly1305 = "0.11" hkdf = "0.13" sha2 = "0.11" -rand = "0.8" +rand = "0.10" tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } anyhow = "1" hex = "0.4" uuid = { version = "1", features = ["v4"] } -argon2 = "0.5" -opus = "0.3" +argon2 = "0.6" +opus = "0.4" cpal = "0.18" -rodio = "0.22" -dirs = "6" -slint = { version = "1", features = ["backend-winit", "compat-1-2"] } +dirs = "7" +slint = { version = "=1.18.1", default-features = false, features = ["std", "backend-winit", "renderer-femtovg", "renderer-software", "accessibility", "compat-1-18"] } nnnoiseless = { version = "0.5.2", default-features = false, optional = true } +image = { version = "0.25.10", default-features = false, features = ["png", "jpeg", "webp"] } +rfd = { version = "0.17.2", default-features = false, features = ["xdg-portal", "wayland"] } + [features] default = [] rnnoise = ["dep:nnnoiseless"] + +# Compatibility backports to maintained zbus 6; see patches/README.md. +[patch.crates-io] +i-slint-backend-winit = { path = "patches/i-slint-backend-winit" } +accesskit_unix = { path = "patches/accesskit_unix" } +accesskit_atspi_common = { path = "patches/accesskit_atspi_common" } +atspi = { path = "patches/atspi" } +atspi-common = { path = "patches/atspi-common" } +atspi-proxies = { path = "patches/atspi-proxies" } +zbus-lockstep = { path = "patches/zbus-lockstep" } +zbus-lockstep-macros = { path = "patches/zbus-lockstep-macros" } +sctk-adwaita = { path = "patches/sctk-adwaita" } diff --git a/README.md b/README.md index 4e9c615..5e8050e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ > Native desktop client for VNOX. Voice, text, no cloud. [![License: GPL-3.0](https://img.shields.io/badge/license-GPL--3.0-blue.svg)](LICENSE) -[![Rust](https://img.shields.io/badge/rust-1.85%2B-orange.svg)](https://www.rust-lang.org/) +[![Rust](https://img.shields.io/badge/rust-1.94%2B-orange.svg)](https://www.rust-lang.org/) [![Status: Phase 1](https://img.shields.io/badge/status-phase%201%20%E2%80%94%20implemented-yellow.svg)](docs/00-status.md) --- @@ -68,7 +68,9 @@ See [docs/00-status.md](docs/00-status.md) for a full breakdown. ## Quick start -**Requirements:** Rust 1.85+, a running [VNOX Server](https://github.com/loki5512344/Vnox) +**Requirements:** Rust 1.94+, a running [VNOX Server](https://github.com/loki5512344/Vnox) + +Linux builds also need audio/protocol prerequisites and FreeType/fontconfig development libraries (`libfreetype6-dev libfontconfig1-dev` on Ubuntu); native file selection uses the desktop portal. ```bash # Terminal 1 — gateway diff --git a/build.rs b/build.rs index a3d1e04..7aa824a 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,4 @@ fn main() { - slint_build::compile("src/ui/slint/main.slint").unwrap(); + let config = slint_build::CompilerConfiguration::new().with_style("fluent".into()); + slint_build::compile_with_config("src/ui/slint/main.slint", config).unwrap(); } diff --git a/docs/04-clients/desktop.md b/docs/04-clients/desktop.md index 23f3e89..0b14121 100644 --- a/docs/04-clients/desktop.md +++ b/docs/04-clients/desktop.md @@ -193,3 +193,31 @@ cargo build --release # Binary ./target/release/vnox-client ``` + +## Native client redesign (October 2026) + +The current Slint shell uses neutral graphite surfaces, a server/channel sidebar, +readable variable-height messages, a collapsible member panel, and persistent +voice/profile controls below navigation. DM selection uses conversation IDs. +Drafts are isolated per conversation and are cleared when leaving a server. +Editable text, settings tabs, and keyfile forms survive UI synchronization. + +Audio settings expose actual device lists, transmission mode, volume, and bitrate; +preferences are saved in the platform config directory at `vnox/audio.json`. +Push-to-talk has a hold control in the voice view. Encrypted identity vaults show +an unlock screen at startup. Message deletion asks for confirmation. + +The UI has no demo members/messages. Threads, uploads, camera, screen sharing, +and global Hub features remain future work. The existing client JSON transport +still needs migration to the server's Protobuf/TLS contract. The server currently +has a single channel membership per session, so independent server-side text and +voice subscriptions are not guaranteed by the new local view state. Legacy E2EE +DM sends are blocked with a retained draft until a verified nonce/message-ID +contract is implemented; the client does not advertise unverified E2EE status. + +For native headless rendering and binding regressions, run `cargo test --workspace`. +Set `VNOX_UI_SNAPSHOT_DIR=/tmp/vnox-ui` to emit test-only PPM screenshots for the +chat, settings, voice, and connection views. These screenshots use test fixtures +and do not connect to a server. + +See [Themes and profile photos](themes.md) for appearance presets, restricted CSS themes, and the local avatar cropper. diff --git a/docs/04-clients/themes.md b/docs/04-clients/themes.md new file mode 100644 index 0000000..4acf0c6 --- /dev/null +++ b/docs/04-clients/themes.md @@ -0,0 +1,72 @@ +# Themes and appearance + +Open **Settings → Appearance** to choose Light, Dark, Mega-dark or Custom. The +same palette applies to chat, voice rooms, settings, dialogs and profile unlock. +Text size ranges from 12 to 22 px; smaller metadata remains at least 11 px. + +## Custom CSS format + +Vnox is a native Slint application. Its theme files accept a restricted CSS +custom-property format, not a browser stylesheet. Exactly one `:root { … }` +block is allowed; comments are supported. Selectors, layout rules, `@import`, +`url()`, scripts, external resources and unknown/duplicate variables are rejected. +Files must have a `.css` extension and contain at most 16 KiB of UTF-8 text. + +```css +:root { + --vnox-bg: #242424; + --vnox-text: #eeeeee; + --vnox-accent: #c8b797; + --vnox-font-size: 17px; +} +``` + +Unspecified colors inherit the standard dark palette. For a complete starting +point, export a built-in theme or edit [forest.css](../../examples/themes/forest.css). +Colors support `#RGB`, `#RGBA`, `#RRGGBB` and `#RRGGBBAA` (alpha comes last). +Font size must be a finite number from `12px` to `22px`. + +| Variable | Controls | +| --- | --- | +| `--vnox-bg` | Main content background | +| `--vnox-surface` | Sidebar and settings surfaces | +| `--vnox-rail` | Server rail and slider tracks | +| `--vnox-hover` | Hover backgrounds | +| `--vnox-elevated` | Raised sections and profile surfaces | +| `--vnox-input` | Inputs and controls | +| `--vnox-selected` | Selected rows and text selection | +| `--vnox-border` | Borders and dividers | +| `--vnox-accent` | Focus, actions and accents | +| `--vnox-text` | Primary text | +| `--vnox-text-secondary` | Supporting text | +| `--vnox-text-muted` | Metadata and hints | +| `--vnox-text-disabled` | Disabled/de-emphasized text | +| `--vnox-danger` | Destructive actions and errors | +| `--vnox-success` | Voice and success states | +| `--vnox-font-size` | Base text size | + +## Preview, save and files + +Built-in choices apply and save immediately. Selecting Custom opens its editor. +**Preview** validates and applies the editor contents without saving; closing +settings restores the last saved palette. **Apply** saves the custom theme. +**Reset** restores the standard dark theme and default custom template. + +The custom text-size slider updates the CSS preview; apply it to save. Import +reads a local `.css` file and previews it. Export writes validated CSS to the +specified path, replacing that file if it already exists. No theme data is sent +over the network. Appearance preferences live in the platform config directory +at `vnox/appearance.json`; the default import/export path is +`vnox/custom-theme.css` in that directory. + +## Profile photos + +Settings → Identity offers a native photo picker, square crop with circular +preview, drag/pan, zoom and confirm/cancel. PNG, JPEG and static WebP are accepted; +SVG and animated images are rejected. Encoded input is limited to 10 MiB, image +sides to 4096 px, and decoding allocations to 64 MiB. EXIF orientation is applied +before cropping. Confirm writes a 256×256 PNG in `vnox/avatars/`, scoped to the +current identity. Cancel and validation/save failures preserve the old photo. + +Photos currently affect the local own-profile display only. There is no server +profile-photo API yet, so other users/devices do not receive these photos. diff --git a/docs/maintenance/dependency-audit.md b/docs/maintenance/dependency-audit.md new file mode 100644 index 0000000..ab2af6d --- /dev/null +++ b/docs/maintenance/dependency-audit.md @@ -0,0 +1,52 @@ +# Аудит зависимостей клиента + +Проверены crates.io/upstream metadata, Cargo registry и RustSec advisory database. Edition остаётся2024. Объявленный минимум поднят доRust1.94 для согласованности проекта; актуальный Slint требует1.92. Сборка и проверки выполняются Rust1.99.0; компилятор1.94 отдельно не проверялся. + +## Прямые зависимости + +| Crate | До (lock) | После (lock) | +|---|---|---| +| anyhow | 1.0.103 | 1.0.104 | +| argon2 | 0.5.3 | 0.6.0 | +| chacha20poly1305 | 0.10.1 | 0.11.0 | +| cpal | 0.17.3, 0.18.1 | 0.18.2 | +| dirs | 6.0.0 | 7.0.0 | +| ed25519-dalek | 2.2.0 | 3.0.0 | +| hex | 0.4.3 | 0.4.3 | +| hkdf | 0.13.0 | 0.13.0 | +| image | новая прямая зависимость | 0.25.10 | +| nnnoiseless | 0.5.2 | 0.5.2 | +| opus | 0.3.1 | 0.4.0 | +| rand | 0.8.6, 0.9.5, 0.10.2 | 0.9.5, 0.10.3 | +| rfd | новая прямая зависимость | 0.17.2 | +| serde | 1.0.228 | 1.0.229 | +| serde_bytes | 0.11.19 | 0.11.19 | +| serde_json | 1.0.150 | 1.0.154 | +| sha2 | 0.10.9, 0.11.0 | 0.11.1 | +| slint | 1.17.1 | 1.18.1 | +| slint-build | 1.17.1 | 1.18.1 | +| tokio | 1.52.3 | 1.54.1 | +| tracing | 0.1.44 | 0.1.44 | +| tracing-subscriber | 0.3.23 | 0.3.23 | +| uuid | 1.23.4 | 1.29.0 | +| x25519-dalek | 2.0.1 | 3.0.0 | + +Неиспользуемый rodio удалён: аудиопайплайн использует cpal напрямую. Убраны неиспользуемые default backend/system-tray features Slint, сохранены Winit, OpenGL/software renderer и accessibility. Для аватара добавлены image с PNG/JPEG/WebP и rfd с portal/Wayland/Tokio. + +## Безопасность + +RustSec до обновления:5 advisories. После обновления:0 известных уязвимостей. Это не доказательство отсутствия неизвестных ошибок. + +Все пять прежних имён (`bincode`, `ttf-parser`, `zbus_names`, `zvariant`, `zvariant_derive`) полностью удалены из lock-файла. Финальный RustSec audit: **0 известных уязвимостей, 0 предупреждений**. Advisory ignores не добавлялись. + +Для этого обновлён rfd до0.17.2, parent UI/accessibility callers адаптированы к поддерживаемому zbus6, Wayland CSD использует crossfont0.9. Accessibility, portal и Wayland сохранены. `typed-index-collections` закреплён на совместимом3.2.3, чтобы убрать неиспользуемый optional bincode из resolution; это осознанное исключение из выбора самой новой версии. + +Локальные compatibility backports — отдельная обязанность сопровождения, а не релизы upstream. Точные исходные версии, SHA256, лицензии, исходные ревизии и девять компактных diff записаны в `patches/`. Патчи следует удалить после соответствующих upstream релизов. Для Linux нужны FreeType/fontconfig development packages (`libfreetype6-dev libfontconfig1-dev` на Ubuntu). + +## Совместимость и проверки + +Криптографические API мигрированы без изменения формата nonce/KDF/vault. Добавлен фиксированный независимый fixture Argon2id+ChaCha20Poly1305 и проверка повреждённого nonce. Проверены49workspace тестов, сборка, Clippy-Dwarnings, форматирование и отдельный реальный privateD-Bus smoke. Дополнительно1141/1141 сохранённых upstream atspi-common тестов прошли без пропусков; инструкции воспроизведения в patches/test-upstream.py. Windows/macOS, реальный screen reader и Rust1.94 в этой задаче не проверялись. + +Основной клиент/сервер всё ещё требуют отдельной миграции JSON→Protobuf/TLS; обновление crates этого не исправляет. Существующая u32 область nonce/sequence требует rekey/disconnect до повторного использования. + +Источники: https://crates.io/ ; https://docs.rs/slint/latest/slint/ ; https://docs.rs/image/latest/image/ ; https://docs.rs/rfd/latest/rfd/ ; https://rustsec.org/ . diff --git a/examples/themes/forest.css b/examples/themes/forest.css new file mode 100644 index 0000000..4e63d23 --- /dev/null +++ b/examples/themes/forest.css @@ -0,0 +1,19 @@ +/* Vnox native theme: edit these variables, preview, then apply in Appearance. */ +:root { + --vnox-bg: #252724; + --vnox-surface: #1d201c; + --vnox-rail: #131612; + --vnox-hover: #363d33; + --vnox-elevated: #30362d; + --vnox-input: #32392f; + --vnox-selected: #3a4636; + --vnox-border: #ffffff20; + --vnox-accent: #b5c49a; + --vnox-text: #eceee5; + --vnox-text-secondary: #bec5b6; + --vnox-text-muted: #a4ae9a; + --vnox-text-disabled: #8a9581; + --vnox-danger: #e79c91; + --vnox-success: #a5c49d; + --vnox-font-size: 16px; +} diff --git a/patches/PATCH-VERIFICATION.md b/patches/PATCH-VERIFICATION.md new file mode 100644 index 0000000..80df104 --- /dev/null +++ b/patches/PATCH-VERIFICATION.md @@ -0,0 +1,20 @@ +# Maintenance backport verification + +Verified with local Rust1.99.0 on Linux. + +- `cargo check --workspace`: passed. +- `cargo test --workspace --locked`: 49passed (34library,15binary),0failed. +- `cargo build --workspace --locked`: passed. +- `cargo clippy --all-targets --locked -- -D warnings`: passed. +- `cargo fmt --check` and `git diff --check`: passed. +- `cargo audit --no-fetch --json`:0knownvulnerabilities,0warnings. +- Private real D-Bus integration in `desktop-smoke`:1passed; no manual zbus executor ticks. +- Native software-rendered shell/settings/light/dark/black/custom/profile/avatar screens generated by actual UI smoke; avatar rendering visually inspected. + +All five original unmaintained package names (bincode, ttf-parser, zbus_names, zvariant, zvariant_derive) are absent from Cargo.lock. No advisory ignores, packageversion spoofing, or dropped accessibility/portal/Wayland functionality. + +Independent read-only review checked buildervalidation, wire decoding equivalence, original Linux-only target scope, and CSD feature preservation. Tests confirm proxy calls/eventroundtrip and invalidpathrejection on an isolated D-Bus daemon. + +Limitations: no real screenreader/assistive-technology acceptance run, no manual live portal chooser test, no Windows/macOS build or Rust1.94 test in this task. Keep monitoring maintained parents and remove local backports once equivalent upstream releases are available. + +Focused follow-up: full preserved atspi-common upstream library suite1141passed/0failed/0ignored after migrating its test-only APIs/imports; reproducible with `python3 patches/test-upstream.py`. Official Slint archive includesnestedLICENSES; COPYING byte-matches officialGPL-3.0-only exactrevision, applicableGPLchoiceexplicit. Reviewdiffs regenerated. diff --git a/patches/README.md b/patches/README.md new file mode 100644 index 0000000..1b7f296 --- /dev/null +++ b/patches/README.md @@ -0,0 +1,29 @@ +# Maintained upstream compatibility backports + +These patches migrate maintained UI/accessibility callers to maintained zbus 6 after zvariant/zbus_names merged upstream. They preserve accessibility, portal, and Wayland support. They do not vendor unmaintained codecs or suppress RustSec. Each directory retains the source license and VNOX-PATCH.md provenance. + +Slint's Wayland CSD selects supported crossfont, adding native FreeType/fontconfig build dependencies on Linux. Use `libfreetype6-dev libfontconfig1-dev` on Debian/Ubuntu. + +All patch changes must be removed when compatible upstream releases incorporate the migration. The compatibility baseline remains the published version, not a forged new version. + +## Verification and removal policy + +`upstream-sources.json` records exact published archive digests and upstream revisions; `changes/*.patch` contains concise diffs against those sources. These wrappers are local maintenance backports; they do not imply upstream has released these exact changes. + +The Slint migration preserves its original Linux-only D-Bus target scope. zbus6 stores invalid builder arguments until build(), owns its runtime, and object_server.at returns None on successful insertion. The AccessKit port respects those semantics. + +`typed-index-collections` is held at compatible 3.2.3 as a build dependency because later compatible releases add unused optional bincode integration to the lockfile. That pin removes an unused capability rather than replacing a serializer or ignoring an advisory. + +Run root `cargo check --workspace`, `cargo test --workspace --locked`, `cargo clippy --all-targets --locked -- -D warnings`, `cargo audit --no-fetch`. Run a real isolated D-Bus integration check with: + +```sh +dbus-run-session -- cargo test --manifest-path patches/desktop-smoke/Cargo.toml --target-dir target +``` + +The smoke check covers maintained runtime progress without manual executor ticks, AT-SPI proxy calls and event serialization, duplicate interface registration, and deferred invalid-path rejection. It does not replace a real assistive-technology or cross-platform acceptance test. + +## Preserved upstream tests + +Run `python3 patches/test-upstream.py` to compile and run the full preserved atspi-common library suite from exact patched sources and XML fixtures in a temporary standalone workspace. Cargo otherwise cannot run dev-dependency tests for a dependency excluded from the application workspace. No tests are filtered or ignored. Verified: **1141 passed, 0 failed, 0 ignored**. Test-only imports and message builders were migrated to zbus6 rather than hiding their build failures. + +Slint's original archive license texts are preserved under its patch's `LICENSES/`; `COPYING` additionally records the exact-revision official GPL3 text selected for this GPL Vnox distribution. See its VNOX-PATCH.md for provenance and checksum. diff --git a/patches/accesskit_atspi_common/CHANGELOG.md b/patches/accesskit_atspi_common/CHANGELOG.md new file mode 100644 index 0000000..6f0c695 --- /dev/null +++ b/patches/accesskit_atspi_common/CHANGELOG.md @@ -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)) diff --git a/patches/accesskit_atspi_common/Cargo.toml b/patches/accesskit_atspi_common/Cargo.toml new file mode 100644 index 0000000..f9e196b --- /dev/null +++ b/patches/accesskit_atspi_common/Cargo.toml @@ -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"] diff --git a/patches/accesskit_atspi_common/LICENSE-APACHE b/patches/accesskit_atspi_common/LICENSE-APACHE new file mode 100644 index 0000000..1b5ec8b --- /dev/null +++ b/patches/accesskit_atspi_common/LICENSE-APACHE @@ -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 diff --git a/patches/accesskit_atspi_common/LICENSE-MIT b/patches/accesskit_atspi_common/LICENSE-MIT new file mode 100644 index 0000000..31aa793 --- /dev/null +++ b/patches/accesskit_atspi_common/LICENSE-MIT @@ -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. diff --git a/patches/accesskit_atspi_common/README.md b/patches/accesskit_atspi_common/README.md new file mode 100644 index 0000000..14846b3 --- /dev/null +++ b/patches/accesskit_atspi_common/README.md @@ -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. diff --git a/patches/accesskit_atspi_common/VNOX-PATCH.md b/patches/accesskit_atspi_common/VNOX-PATCH.md new file mode 100644 index 0000000..9902fac --- /dev/null +++ b/patches/accesskit_atspi_common/VNOX-PATCH.md @@ -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. diff --git a/patches/accesskit_atspi_common/src/action.rs b/patches/accesskit_atspi_common/src/action.rs new file mode 100644 index 0000000..ea257ef --- /dev/null +++ b/patches/accesskit_atspi_common/src/action.rs @@ -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, +} diff --git a/patches/accesskit_atspi_common/src/adapter.rs b/patches/accesskit_atspi_common/src/adapter.rs new file mode 100644 index 0000000..6b7db3c --- /dev/null +++ b/patches/accesskit_atspi_common/src/adapter.rs @@ -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, + removed_nodes: HashSet, + checked_text_change: HashSet, + selection_changed: HashSet, +} + +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, + context: Arc, +} + +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>, + 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>, + 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>, + callback: impl 'static + AdapterCallback + Send + Sync, + initial_state: TreeUpdate, + is_window_focused: bool, + root_window_bounds: WindowBounds, + action_handler: Arc, + ) -> 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 { + Arc::clone(&self.context.action_handler) + } +} + +fn root_window(current_state: &TreeState) -> Option> { + 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>>, + } + + 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>>) { + 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(_))); + } +} diff --git a/patches/accesskit_atspi_common/src/callback.rs b/patches/accesskit_atspi_common/src/callback.rs new file mode 100644 index 0000000..81dce9b --- /dev/null +++ b/patches/accesskit_atspi_common/src/callback.rs @@ -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); +} diff --git a/patches/accesskit_atspi_common/src/context.rs b/patches/accesskit_atspi_common/src/context.rs new file mode 100644 index 0000000..79e5fd7 --- /dev/null +++ b/patches/accesskit_atspi_common/src/context.rs @@ -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(Mutex); + +impl ActionHandlerWrapper { + pub fn new(inner: H) -> Self { + Self(Mutex::new(inner)) + } +} + +impl ActionHandlerNoMut for ActionHandlerWrapper { + fn do_action(&self, request: ActionRequest) { + self.0.lock().unwrap().do_action(request) + } +} + +pub(crate) struct Context { + pub(crate) app_context: Arc>, + pub(crate) tree: RwLock, + pub(crate) action_handler: Arc, + pub(crate) root_window_bounds: RwLock, +} + +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>, + tree: Tree, + action_handler: Arc, + root_window_bounds: WindowBounds, + ) -> Arc { + 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, + pub(crate) toolkit_name: Option, + pub(crate) toolkit_version: Option, + pub(crate) id: Option, + pub(crate) adapters: Vec<(usize, Arc)>, +} + +impl AppContext { + pub fn new(name: Option) -> Arc> { + 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 { + self.adapters.binary_search_by(|adapter| adapter.0.cmp(&id)) + } + + pub(crate) fn push_adapter(&mut self, id: usize, context: &Arc) { + 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); + } + } +} diff --git a/patches/accesskit_atspi_common/src/error.rs b/patches/accesskit_atspi_common/src/error.rs new file mode 100644 index 0000000..b612903 --- /dev/null +++ b/patches/accesskit_atspi_common/src/error.rs @@ -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 = std::result::Result; diff --git a/patches/accesskit_atspi_common/src/events.rs b/patches/accesskit_atspi_common/src/events.rs new file mode 100644 index 0000000..aadc1a5 --- /dev/null +++ b/patches/accesskit_atspi_common/src/events.rs @@ -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, +} diff --git a/patches/accesskit_atspi_common/src/filters.rs b/patches/accesskit_atspi_common/src/filters.rs new file mode 100644 index 0000000..2802d57 --- /dev/null +++ b/patches/accesskit_atspi_common/src/filters.rs @@ -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; diff --git a/patches/accesskit_atspi_common/src/lib.rs b/patches/accesskit_atspi_common/src/lib.rs new file mode 100644 index 0000000..f296305 --- /dev/null +++ b/patches/accesskit_atspi_common/src/lib.rs @@ -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; diff --git a/patches/accesskit_atspi_common/src/node.rs b/patches/accesskit_atspi_common/src/node.rs new file mode 100644 index 0000000..ce197b1 --- /dev/null +++ b/patches/accesskit_atspi_common/src/node.rs @@ -0,0 +1,1944 @@ +// 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 accesskit::{ + Action, ActionData, ActionRequest, Affine, Live, NodeId as LocalNodeId, Orientation, Point, + Rect, Role, Toggled, TreeId, +}; +use accesskit_consumer::{FilterResult, Node, NodeId, Tree, TreeState}; +use atspi_common::{ + CoordType, Granularity, Interface, InterfaceSet, Layer, Politeness, RelationType, + Role as AtspiRole, ScrollType, State, StateSet, +}; +use std::{ + collections::HashMap, + hash::{Hash, Hasher}, + sync::{Arc, RwLock, RwLockReadGuard, Weak}, +}; + +use crate::{ + Action as AtspiAction, Error, ObjectEvent, Property, Rect as AtspiRect, Result, + adapter::Adapter, + context::{AppContext, Context}, + filters::filter, + text_attributes::ATTRIBUTE_GETTERS, + util::*, +}; + +pub(crate) struct NodeWrapper<'a>(pub(crate) &'a Node<'a>); + +impl NodeWrapper<'_> { + pub(crate) fn name(&self) -> Option { + if self.0.label_comes_from_value() { + self.0.value() + } else { + self.0.label() + } + } + + pub(crate) fn description(&self) -> Option { + self.0.description() + } + + pub(crate) fn parent_id(&self) -> Option { + self.0.parent_id() + } + + pub(crate) fn id(&self) -> NodeId { + self.0.id() + } + + pub(crate) fn cache_node( + &self, + adapter_id: usize, + index_in_parent: i32, + child_count: i32, + window_focused: bool, + ) -> CacheNode { + let parent = self + .0 + .filtered_parent(&filter) + .map_or(NodeIdOrRoot::Root, |node| NodeIdOrRoot::Node(node.id())); + CacheNode { + adapter_id, + id: self.id(), + parent, + index_in_parent, + child_count, + interfaces: self.interfaces(), + name: self.name().unwrap_or_default(), + description: self.description().unwrap_or_default(), + role: self.role(), + states: self.state(window_focused), + } + } + + fn filtered_child_ids(&self) -> impl DoubleEndedIterator { + self.0.filtered_children(&filter).map(|child| child.id()) + } + + pub(crate) fn role(&self) -> AtspiRole { + if self.0.has_role_description() { + return AtspiRole::Extended; + } + + match self.0.role() { + Role::Alert => AtspiRole::Notification, + Role::AlertDialog => AtspiRole::Alert, + Role::Comment | Role::Suggestion => AtspiRole::Section, + // TODO: See how to represent ARIA role="application" + Role::Application => AtspiRole::Embedded, + Role::Article => AtspiRole::Article, + Role::Audio => AtspiRole::Audio, + Role::Banner | Role::Header => AtspiRole::Landmark, + Role::Blockquote => AtspiRole::BlockQuote, + Role::Caret => AtspiRole::Unknown, + Role::Button => { + if self.0.toggled().is_some() { + AtspiRole::ToggleButton + } else { + AtspiRole::Button + } + } + Role::DefaultButton => AtspiRole::Button, + Role::Canvas => AtspiRole::Canvas, + Role::Caption => AtspiRole::Caption, + Role::Cell | Role::GridCell => AtspiRole::TableCell, + Role::CheckBox => AtspiRole::CheckBox, + Role::Switch => AtspiRole::ToggleButton, + Role::ColorWell => AtspiRole::Button, + Role::ColumnHeader => AtspiRole::ColumnHeader, + Role::ComboBox | Role::EditableComboBox => AtspiRole::ComboBox, + Role::Complementary => AtspiRole::Landmark, + Role::ContentDeletion => AtspiRole::ContentDeletion, + Role::ContentInsertion => AtspiRole::ContentInsertion, + Role::ContentInfo | Role::Footer => AtspiRole::Landmark, + Role::Definition => AtspiRole::DescriptionValue, + Role::DescriptionList => AtspiRole::DescriptionList, + Role::Details => AtspiRole::Panel, + Role::Dialog => AtspiRole::Dialog, + Role::DisclosureTriangle => AtspiRole::ToggleButton, + Role::DocCover => AtspiRole::Image, + Role::DocBackLink | Role::DocBiblioRef | Role::DocGlossRef | Role::DocNoteRef => { + AtspiRole::Link + } + Role::DocBiblioEntry | Role::DocEndnote => AtspiRole::ListItem, + Role::DocNotice | Role::DocTip => AtspiRole::Comment, + Role::DocFootnote => AtspiRole::Footnote, + Role::DocPageBreak => AtspiRole::Separator, + Role::DocPageFooter => AtspiRole::Footer, + Role::DocPageHeader => AtspiRole::Header, + Role::DocAcknowledgements + | Role::DocAfterword + | Role::DocAppendix + | Role::DocBibliography + | Role::DocChapter + | Role::DocConclusion + | Role::DocCredits + | Role::DocEndnotes + | Role::DocEpilogue + | Role::DocErrata + | Role::DocForeword + | Role::DocGlossary + | Role::DocIndex + | Role::DocIntroduction + | Role::DocPageList + | Role::DocPart + | Role::DocPreface + | Role::DocPrologue + | Role::DocToc => AtspiRole::Landmark, + Role::DocAbstract + | Role::DocColophon + | Role::DocCredit + | Role::DocDedication + | Role::DocEpigraph + | Role::DocExample + | Role::DocPullquote + | Role::DocQna => AtspiRole::Section, + Role::DocSubtitle => AtspiRole::Heading, + Role::Document => AtspiRole::DocumentFrame, + Role::EmbeddedObject => AtspiRole::Embedded, + // TODO: Forms which lack an accessible name are no longer + // exposed as forms. Forms which have accessible + // names should be exposed as `AtspiRole::Landmark` according to Core AAM. + Role::Form => AtspiRole::Form, + Role::Figure | Role::Feed => AtspiRole::Panel, + Role::GenericContainer | Role::Ruby => AtspiRole::Section, + Role::GraphicsDocument => AtspiRole::DocumentFrame, + Role::GraphicsObject => AtspiRole::Panel, + Role::GraphicsSymbol => AtspiRole::Image, + Role::Grid => AtspiRole::Table, + Role::Group => AtspiRole::Panel, + Role::Heading => AtspiRole::Heading, + Role::Iframe | Role::IframePresentational => AtspiRole::InternalFrame, + // TODO: If there are unignored children, then it should be AtspiRole::ImageMap. + Role::Image => AtspiRole::Image, + Role::TextRun => AtspiRole::Static, + Role::Legend => AtspiRole::Label, + // Layout table objects are treated the same as `Role::GenericContainer`. + Role::LayoutTable => AtspiRole::Section, + Role::LayoutTableCell => AtspiRole::Section, + Role::LayoutTableRow => AtspiRole::Section, + // TODO: Having a separate accessible object for line breaks + // is inconsistent with other implementations. + Role::LineBreak => AtspiRole::Static, + Role::Link => AtspiRole::Link, + Role::List => AtspiRole::List, + Role::ListBox => AtspiRole::ListBox, + // TODO: Use `AtspiRole::MenuItem' inside a combo box. + Role::ListBoxOption => AtspiRole::ListItem, + Role::ListGrid => AtspiRole::Table, + Role::ListItem => AtspiRole::ListItem, + // Regular list markers only expose their alternative text, but do not + // expose their descendants, and the descendants should be ignored. This + // is because the alternative text depends on the counter style and can + // be different from the actual (visual) marker text, and hence, + // inconsistent with the descendants. We treat a list marker as non-text + // only if it still has non-ignored descendants, which happens only when => + // - The list marker itself is ignored but the descendants are not + // - Or the list marker contains images + Role::ListMarker => AtspiRole::Static, + Role::Log => AtspiRole::Log, + Role::Main => AtspiRole::Landmark, + Role::Mark => AtspiRole::Static, + Role::Math => AtspiRole::Math, + Role::Marquee => AtspiRole::Marquee, + Role::Menu | Role::MenuListPopup => AtspiRole::Menu, + Role::MenuBar => AtspiRole::MenuBar, + Role::MenuItem | Role::MenuListOption => AtspiRole::MenuItem, + Role::MenuItemCheckBox => AtspiRole::CheckMenuItem, + Role::MenuItemRadio => AtspiRole::RadioMenuItem, + Role::Meter => AtspiRole::LevelBar, + Role::Navigation => AtspiRole::Landmark, + Role::Note => AtspiRole::Comment, + Role::Pane | Role::ScrollView => AtspiRole::Panel, + Role::Paragraph => AtspiRole::Paragraph, + Role::PdfActionableHighlight => AtspiRole::Button, + Role::PdfRoot => AtspiRole::DocumentFrame, + Role::PluginObject => AtspiRole::Embedded, + Role::ProgressIndicator => AtspiRole::ProgressBar, + Role::RadioButton => AtspiRole::RadioButton, + Role::RadioGroup => AtspiRole::Panel, + Role::Region => AtspiRole::Landmark, + Role::RootWebArea => AtspiRole::DocumentWeb, + Role::Row => AtspiRole::TableRow, + Role::RowGroup => AtspiRole::Panel, + Role::RowHeader => AtspiRole::RowHeader, + // TODO: Generally exposed as description on (`Role::Ruby`) element, not + // as its own object in the tree. + // However, it's possible to make a `Role::RubyAnnotation` element show up in the + // tree, for example by adding tabindex="0" to the source or + // element or making the source element the target of an aria-owns. + // Therefore, we need to gracefully handle it if it actually + // shows up in the tree. + Role::RubyAnnotation => AtspiRole::Static, + Role::Section => AtspiRole::Section, + Role::SectionFooter => AtspiRole::Footer, + Role::SectionHeader => AtspiRole::Header, + Role::ScrollBar => AtspiRole::ScrollBar, + Role::Search => AtspiRole::Landmark, + Role::Slider => AtspiRole::Slider, + Role::SpinButton => AtspiRole::SpinButton, + Role::Splitter => AtspiRole::Separator, + Role::Label => AtspiRole::Label, + Role::Status => AtspiRole::StatusBar, + Role::SvgRoot => AtspiRole::DocumentFrame, + Role::Tab => AtspiRole::PageTab, + Role::Table => AtspiRole::Table, + Role::TabList => AtspiRole::PageTabList, + Role::TabPanel => AtspiRole::ScrollPane, + // TODO: This mapping should also be applied to the dfn + // element. + Role::Term => AtspiRole::DescriptionTerm, + Role::TitleBar => AtspiRole::TitleBar, + Role::TextInput + | Role::MultilineTextInput + | Role::SearchInput + | Role::EmailInput + | Role::NumberInput + | Role::PhoneNumberInput + | Role::UrlInput => AtspiRole::Entry, + Role::DateInput + | Role::DateTimeInput + | Role::WeekInput + | Role::MonthInput + | Role::TimeInput => AtspiRole::DateEditor, + Role::PasswordInput => AtspiRole::PasswordText, + Role::Abbr | Role::Code | Role::Emphasis | Role::Strong | Role::Time => { + AtspiRole::Static + } + Role::Timer => AtspiRole::Timer, + Role::Toolbar => AtspiRole::ToolBar, + Role::Tooltip => AtspiRole::ToolTip, + Role::Tree => AtspiRole::Tree, + Role::TreeItem => AtspiRole::TreeItem, + Role::TreeGrid => AtspiRole::TreeTable, + Role::Video => AtspiRole::Video, + // In AT-SPI, elements with `AtspiRole::Frame` are windows with titles and + // buttons, while those with `AtspiRole::Window` are windows without those + // elements. + Role::Window => AtspiRole::Frame, + Role::WebView => AtspiRole::Panel, + Role::FigureCaption => AtspiRole::Caption, + // TODO: Are there special cases to consider? + Role::Unknown => AtspiRole::Unknown, + Role::ImeCandidate | Role::Keyboard => AtspiRole::RedundantObject, + Role::Terminal => AtspiRole::Terminal, + } + } + + fn is_focused(&self) -> bool { + self.0.is_focused() + } + + pub(crate) fn state(&self, is_window_focused: bool) -> StateSet { + let state = self.0; + let atspi_role = self.role(); + let mut atspi_state = StateSet::empty(); + if is_window_focused + && ((state.parent_id().is_none() && state.role() == Role::Window) + || (state.is_dialog() + && state.tree_state.active_dialog().map(|d| d.id()) == Some(state.id()))) + { + atspi_state.insert(State::Active); + } + if state.is_text_input() && !state.is_read_only() { + atspi_state.insert(State::Editable); + } + // TODO: Focus and selection. + if state.is_focusable(&filter) { + atspi_state.insert(State::Focusable); + } + let filter_result = filter(self.0); + if filter_result == FilterResult::Include { + atspi_state.insert(State::Visible | State::Showing); + } + if state.is_required() { + atspi_state.insert(State::Required); + } + if state.is_multiselectable() { + atspi_state.insert(State::Multiselectable); + } + if let Some(orientation) = state.orientation() { + atspi_state.insert(if orientation == Orientation::Horizontal { + State::Horizontal + } else { + State::Vertical + }); + } + if atspi_role != AtspiRole::ToggleButton && state.toggled().is_some() { + atspi_state.insert(State::Checkable); + } + if state.is_modal() { + atspi_state.insert(State::Modal); + } + if let Some(selected) = state.is_selected() { + if !state.is_disabled() { + atspi_state.insert(State::Selectable); + } + if selected { + atspi_state.insert(State::Selected); + } + } + if state.is_text_input() { + atspi_state.insert(State::SelectableText); + atspi_state.insert(match state.is_multiline() { + true => State::MultiLine, + false => State::SingleLine, + }); + } + + // Special case for indeterminate progressbar. + if state.role() == Role::ProgressIndicator && state.numeric_value().is_none() { + atspi_state.insert(State::Indeterminate); + } + + // Toggled state + match state.toggled() { + Some(Toggled::Mixed) => atspi_state.insert(State::Indeterminate), + Some(Toggled::True) if atspi_role == AtspiRole::ToggleButton => { + atspi_state.insert(State::Pressed) + } + Some(Toggled::True) => atspi_state.insert(State::Checked), + _ => {} + } + + if state.is_read_only_supported() && state.is_read_only_or_disabled() { + atspi_state.insert(State::ReadOnly); + } else { + atspi_state.insert(State::Enabled | State::Sensitive); + } + + if self.is_focused() { + atspi_state.insert(State::Focused); + } + + atspi_state + } + + fn placeholder(&self) -> Option<&str> { + self.0.placeholder() + } + + fn position_in_set(&self) -> Option { + self.0.position_in_set().map(|p| (p + 1).to_string()) + } + + fn size_of_set(&self) -> Option { + self.0 + .size_of_set_from_container(&filter) + .map(|s| s.to_string()) + } + + fn braille_label(&self) -> Option<&str> { + self.0.braille_label() + } + + fn braille_role_description(&self) -> Option<&str> { + self.0.braille_role_description() + } + + fn attributes(&self) -> HashMap<&'static str, String> { + let mut attributes = HashMap::new(); + if let Some(placeholder) = self.placeholder() { + attributes.insert("placeholder-text", placeholder.to_string()); + } + if let Some(position_in_set) = self.position_in_set() { + attributes.insert("posinset", position_in_set); + } + if let Some(size_of_set) = self.size_of_set() { + attributes.insert("setsize", size_of_set); + } + if let Some(label) = self.braille_label() { + attributes.insert("braillelabel", label.to_string()); + } + if let Some(role_description) = self.braille_role_description() { + attributes.insert("brailleroledescription", role_description.to_string()); + } + + attributes + } + + fn is_root(&self) -> bool { + self.0.is_root() + } + + fn supports_action(&self) -> bool { + self.0.is_clickable(&filter) + } + + fn supports_component(&self) -> bool { + self.0.raw_bounds().is_some() || self.is_root() + } + + fn supports_hyperlink(&self) -> bool { + self.0.supports_url() + } + + fn supports_selection(&self) -> bool { + self.0.is_container_with_selectable_children() + } + + fn supports_text(&self) -> bool { + self.0.supports_text_ranges() + } + + fn supports_value(&self) -> bool { + self.current_value().is_some() + } + + pub(crate) fn interfaces(&self) -> InterfaceSet { + let mut interfaces = InterfaceSet::new(Interface::Accessible); + if self.supports_action() { + interfaces.insert(Interface::Action); + } + if self.supports_component() { + interfaces.insert(Interface::Component); + } + if self.supports_hyperlink() { + interfaces.insert(Interface::Hyperlink); + } + if self.supports_selection() { + interfaces.insert(Interface::Selection); + } + if self.supports_text() { + interfaces.insert(Interface::Text); + } + if self.supports_value() { + interfaces.insert(Interface::Value); + } + interfaces + } + + pub(crate) fn live(&self) -> Politeness { + let live = self.0.live(); + match live { + Live::Off => Politeness::None, + Live::Polite => Politeness::Polite, + Live::Assertive => Politeness::Assertive, + } + } + + fn n_actions(&self) -> i32 { + if self.0.is_clickable(&filter) { 1 } else { 0 } + } + + fn get_action_name(&self, index: i32) -> String { + if index != 0 { + return String::new(); + } + String::from(if self.0.is_clickable(&filter) { + "click" + } else { + "" + }) + } + + fn raw_bounds_and_transform(&self) -> (Option, Affine) { + let state = self.0; + (state.raw_bounds(), state.direct_transform()) + } + + fn extents(&self, window_bounds: &WindowBounds, coord_type: CoordType) -> Option { + let mut bounds = self.0.bounding_box(); + if self.is_root() { + let window_bounds = window_bounds.inner.with_origin(Point::ZERO); + if !window_bounds.is_empty() { + if let Some(bounds) = &mut bounds { + bounds.x0 = bounds.x0.min(window_bounds.x1); + bounds.y0 = bounds.y0.min(window_bounds.y1); + bounds.x1 = bounds.x1.min(window_bounds.x1); + bounds.y1 = bounds.y1.min(window_bounds.y1); + } else { + bounds = Some(window_bounds); + } + } + } + bounds.map(|bounds| { + let new_origin = window_bounds.accesskit_point_to_atspi_point( + bounds.origin(), + self.0.filtered_parent(&filter), + coord_type, + ); + bounds.with_origin(new_origin) + }) + } + + fn current_value(&self) -> Option { + self.0.numeric_value() + } + + pub(crate) fn notify_changes( + &self, + window_bounds: &WindowBounds, + adapter: &Adapter, + old: &NodeWrapper<'_>, + ) { + self.notify_state_changes(adapter, old); + self.notify_property_changes(adapter, old); + self.notify_bounds_changes(window_bounds, adapter, old); + self.notify_children_changes(adapter, old); + } + + fn notify_state_changes(&self, adapter: &Adapter, old: &NodeWrapper<'_>) { + let old_state = old.state(true); + let new_state = self.state(true); + let changed_states = old_state ^ new_state; + for state in changed_states.iter() { + if state == State::Focused { + // This is handled specially in `focus_moved`. + continue; + } + adapter.emit_object_event( + self.id(), + ObjectEvent::StateChanged(state, new_state.contains(state)), + ); + } + } + + fn notify_property_changes(&self, adapter: &Adapter, old: &NodeWrapper<'_>) { + let name = self.name(); + if name != old.name() { + let name = name.unwrap_or_default(); + adapter.emit_object_event( + self.id(), + ObjectEvent::PropertyChanged(Property::Name(name.clone())), + ); + + let live = self.live(); + if live != Politeness::None { + adapter.emit_object_event(self.id(), ObjectEvent::Announcement(name, live)); + } + } + let description = self.description(); + if description != old.description() { + adapter.emit_object_event( + self.id(), + ObjectEvent::PropertyChanged(Property::Description( + description.unwrap_or_default(), + )), + ); + } + let parent_id = self.parent_id(); + if parent_id != old.parent_id() { + let parent = self + .0 + .filtered_parent(&filter) + .map_or(NodeIdOrRoot::Root, |node| NodeIdOrRoot::Node(node.id())); + adapter.emit_object_event( + self.id(), + ObjectEvent::PropertyChanged(Property::Parent(parent)), + ); + } + let role = self.role(); + if role != old.role() { + adapter.emit_object_event( + self.id(), + ObjectEvent::PropertyChanged(Property::Role(role)), + ); + } + if let Some(value) = self.current_value() { + if Some(value) != old.current_value() { + adapter.emit_object_event( + self.id(), + ObjectEvent::PropertyChanged(Property::Value(value)), + ); + } + } + } + + fn notify_bounds_changes( + &self, + window_bounds: &WindowBounds, + adapter: &Adapter, + old: &NodeWrapper<'_>, + ) { + if self.raw_bounds_and_transform() != old.raw_bounds_and_transform() { + if let Some(extents) = self.extents(window_bounds, CoordType::Window) { + adapter.emit_object_event(self.id(), ObjectEvent::BoundsChanged(extents.into())); + } + } + } + + fn notify_children_changes(&self, adapter: &Adapter, old: &NodeWrapper<'_>) { + let old_filtered_children = old.filtered_child_ids().collect::>(); + let new_filtered_children = self.filtered_child_ids().collect::>(); + for (index, child) in new_filtered_children.iter().enumerate() { + if !old_filtered_children.contains(child) { + adapter.emit_object_event(self.id(), ObjectEvent::ChildAdded(index, *child)); + } + } + for child in old_filtered_children.into_iter() { + if !new_filtered_children.contains(&child) { + adapter.emit_object_event(self.id(), ObjectEvent::ChildRemoved(child)); + } + } + } +} + +#[derive(Clone)] +pub struct PlatformNode { + context: Weak, + adapter_id: usize, + id: NodeId, +} + +impl PlatformNode { + pub(crate) fn new(context: &Arc, adapter_id: usize, id: NodeId) -> Self { + Self { + context: Arc::downgrade(context), + adapter_id, + id, + } + } + + fn from_adapter_root(adapter_id_and_context: &(usize, Arc)) -> Self { + let (adapter_id, context) = adapter_id_and_context; + Self::new(context, *adapter_id, context.read_tree().state().root_id()) + } + + fn upgrade_context(&self) -> Result> { + if let Some(context) = self.context.upgrade() { + Ok(context) + } else { + Err(Error::Defunct) + } + } + + fn with_tree_state(&self, f: F) -> Result + where + F: FnOnce(&TreeState) -> Result, + { + let context = self.upgrade_context()?; + let tree = context.read_tree(); + f(tree.state()) + } + + fn with_tree_and_context(&self, f: F) -> Result + where + F: FnOnce(&Tree, &Context) -> Result, + { + let context = self.upgrade_context()?; + let tree = context.read_tree(); + f(&tree, &context) + } + + fn resolve_with_context(&self, f: F) -> Result + where + for<'a> F: FnOnce(Node<'a>, &'a Tree, &Context) -> Result, + { + self.with_tree_and_context(|tree, context| { + if let Some(node) = tree.state().node_by_id(self.id) { + f(node, tree, context) + } else { + Err(Error::Defunct) + } + }) + } + + fn resolve_for_selection_with_context(&self, f: F) -> Result + where + for<'a> F: FnOnce(Node<'a>, &'a Tree, &Context) -> Result, + { + self.resolve_with_context(|node, tree, context| { + let wrapper = NodeWrapper(&node); + if wrapper.supports_selection() { + f(node, tree, context) + } else { + Err(Error::UnsupportedInterface) + } + }) + } + + fn resolve_for_text_with_context(&self, f: F) -> Result + where + for<'a> F: FnOnce(Node<'a>, &'a Tree, &Context) -> Result, + { + self.resolve_with_context(|node, tree, context| { + let wrapper = NodeWrapper(&node); + if wrapper.supports_text() { + f(node, tree, context) + } else { + Err(Error::UnsupportedInterface) + } + }) + } + + fn resolve(&self, f: F) -> Result + where + for<'a> F: FnOnce(Node<'a>) -> Result, + { + self.resolve_with_context(|node, _, _| f(node)) + } + + fn resolve_for_selection(&self, f: F) -> Result + where + for<'a> F: FnOnce(Node<'a>) -> Result, + { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + if wrapper.supports_selection() { + f(node) + } else { + Err(Error::UnsupportedInterface) + } + }) + } + + fn resolve_for_text(&self, f: F) -> Result + where + for<'a> F: FnOnce(Node<'a>) -> Result, + { + self.resolve_for_text_with_context(|node, _, _| f(node)) + } + + fn do_action_internal(&self, target: NodeId, f: F) -> Result<()> + where + F: FnOnce(&TreeState, &Context, LocalNodeId, TreeId) -> ActionRequest, + { + let context = self.upgrade_context()?; + let tree = context.read_tree(); + if let Some((target_node, target_tree)) = tree.state().locate_node(target) { + let request = f(tree.state(), &context, target_node, target_tree); + drop(tree); + context.do_action(request); + Ok(()) + } else { + Err(Error::Defunct) + } + } + + pub fn name(&self) -> Result { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + Ok(wrapper.name().unwrap_or_default()) + }) + } + + pub fn description(&self) -> Result { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + Ok(wrapper.description().unwrap_or_default()) + }) + } + + pub fn relative(&self, id: NodeId) -> Self { + Self { + context: self.context.clone(), + adapter_id: self.adapter_id, + id, + } + } + + pub fn root(&self) -> Result { + let context = self.upgrade_context()?; + Ok(PlatformRoot::new(&context.app_context)) + } + + pub fn toolkit_name(&self) -> Result { + self.with_tree_state(|state| Ok(state.toolkit_name().to_string())) + } + + pub fn toolkit_version(&self) -> Result { + self.with_tree_state(|state| Ok(state.toolkit_version().unwrap_or_default().to_string())) + } + + pub fn parent(&self) -> Result { + self.resolve(|node| { + let parent = node + .filtered_parent(&filter) + .map_or(NodeIdOrRoot::Root, |node| NodeIdOrRoot::Node(node.id())); + Ok(parent) + }) + } + + pub fn child_count(&self) -> Result { + self.resolve(|node| { + i32::try_from(node.filtered_children(&filter).count()) + .map_err(|_| Error::TooManyChildren) + }) + } + + pub fn adapter_id(&self) -> usize { + self.adapter_id + } + + pub fn id(&self) -> NodeId { + self.id + } + + pub fn accessible_id(&self) -> Result { + self.resolve(|node| { + if let Some(author_id) = node.author_id() { + Ok(author_id.to_string()) + } else { + Ok(String::new()) + } + }) + } + + pub fn child_at_index(&self, index: usize) -> Result> { + self.resolve(|node| { + let child = node + .filtered_children(&filter) + .nth(index) + .map(|child| child.id()); + Ok(child) + }) + } + + pub fn map_children(&self, f: impl Fn(NodeId) -> I) -> Result + where + T: FromIterator, + { + self.resolve(|node| { + let children = node + .filtered_children(&filter) + .map(|child| child.id()) + .map(f) + .collect(); + Ok(children) + }) + } + + pub fn index_in_parent(&self) -> Result { + self.resolve_with_context(|node, _tree, context| { + if node.filtered_parent(&filter).is_some() { + i32::try_from(node.preceding_filtered_siblings(&filter).count()) + .map_err(|_| Error::IndexOutOfRange) + } else { + let index = context + .read_app_context() + .adapter_index(self.adapter_id) + .map_err(|_| Error::Defunct)?; + i32::try_from(index).map_err(|_| Error::IndexOutOfRange) + } + }) + } + + pub fn cache_node(&self) -> Result { + self.resolve_with_context(|node, tree, context| { + let index_in_parent = if node.filtered_parent(&filter).is_some() { + i32::try_from(node.preceding_filtered_siblings(&filter).count()) + .map_err(|_| Error::IndexOutOfRange)? + } else { + let index = context + .read_app_context() + .adapter_index(self.adapter_id) + .map_err(|_| Error::Defunct)?; + i32::try_from(index).map_err(|_| Error::IndexOutOfRange)? + }; + let child_count = i32::try_from(node.filtered_children(&filter).count()) + .map_err(|_| Error::TooManyChildren)?; + let wrapper = NodeWrapper(&node); + Ok(wrapper.cache_node( + self.adapter_id, + index_in_parent, + child_count, + tree.state().focus_id().is_some(), + )) + }) + } + + pub fn relation_set( + &self, + f: impl Fn(NodeId) -> T, + ) -> Result>> { + self.resolve(|node| { + let mut relations = HashMap::new(); + let controls: Vec<_> = node + .controls() + .filter(|controlled| filter(controlled) == FilterResult::Include) + .map(|controlled| controlled.id()) + .map(f) + .collect(); + if !controls.is_empty() { + relations.insert(RelationType::ControllerFor, controls); + } + Ok(relations) + }) + } + + pub fn role(&self) -> Result { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + Ok(wrapper.role()) + }) + } + + pub fn localized_role_name(&self) -> Result { + self.resolve(|node| Ok(node.role_description().unwrap_or_default().to_string())) + } + + pub fn state(&self) -> StateSet { + self.resolve_with_context(|node, tree, _| { + let wrapper = NodeWrapper(&node); + Ok(wrapper.state(tree.state().focus_id().is_some())) + }) + .unwrap_or(State::Defunct.into()) + } + + pub fn attributes(&self) -> Result> { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + Ok(wrapper.attributes()) + }) + } + + pub fn supports_action(&self) -> Result { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + Ok(wrapper.supports_action()) + }) + } + + pub fn supports_component(&self) -> Result { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + Ok(wrapper.supports_component()) + }) + } + + pub fn supports_hyperlink(&self) -> Result { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + Ok(wrapper.supports_hyperlink()) + }) + } + + pub fn supports_selection(&self) -> Result { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + Ok(wrapper.supports_selection()) + }) + } + + pub fn supports_text(&self) -> Result { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + Ok(wrapper.supports_text()) + }) + } + + pub fn supports_value(&self) -> Result { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + Ok(wrapper.supports_value()) + }) + } + + pub fn interfaces(&self) -> Result { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + Ok(wrapper.interfaces()) + }) + } + + pub fn n_actions(&self) -> Result { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + Ok(wrapper.n_actions()) + }) + } + + pub fn action_name(&self, index: i32) -> Result { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + Ok(wrapper.get_action_name(index)) + }) + } + + pub fn actions(&self) -> Result> { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + let n_actions = wrapper.n_actions() as usize; + let mut actions = Vec::with_capacity(n_actions); + for i in 0..n_actions { + actions.push(AtspiAction { + localized_name: wrapper.get_action_name(i as i32), + description: "".into(), + key_binding: "".into(), + }); + } + Ok(actions) + }) + } + + pub fn do_action(&self, index: i32) -> Result { + if index != 0 { + return Ok(false); + } + self.do_action_internal(self.id, |_, _, target_node, target_tree| ActionRequest { + action: Action::Click, + target_tree, + target_node, + data: None, + })?; + Ok(true) + } + + pub fn contains(&self, x: i32, y: i32, coord_type: CoordType) -> Result { + self.resolve_with_context(|node, _, context| { + let window_bounds = context.read_root_window_bounds(); + let wrapper = NodeWrapper(&node); + if let Some(extents) = wrapper.extents(&window_bounds, coord_type) { + Ok(extents.contains(Point::new(x.into(), y.into()))) + } else { + Ok(false) + } + }) + } + + pub fn accessible_at_point( + &self, + x: i32, + y: i32, + coord_type: CoordType, + ) -> Result> { + self.resolve_with_context(|node, _, context| { + let window_bounds = context.read_root_window_bounds(); + let point = window_bounds.atspi_point_to_accesskit_point( + Point::new(x.into(), y.into()), + Some(node), + coord_type, + ); + let point = node.transform().inverse() * point; + Ok(node.node_at_point(point, &filter).map(|node| node.id())) + }) + } + + pub fn extents(&self, coord_type: CoordType) -> Result { + self.resolve_with_context(|node, _, context| { + let window_bounds = context.read_root_window_bounds(); + let wrapper = NodeWrapper(&node); + Ok(wrapper + .extents(&window_bounds, coord_type) + .map_or(AtspiRect::INVALID, AtspiRect::from)) + }) + } + + pub fn layer(&self) -> Result { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + if wrapper.role() == AtspiRole::Window { + Ok(Layer::Window) + } else { + Ok(Layer::Widget) + } + }) + } + + pub fn grab_focus(&self) -> Result { + self.do_action_internal(self.id, |_, _, target_node, target_tree| ActionRequest { + action: Action::Focus, + target_tree, + target_node, + data: None, + })?; + Ok(true) + } + + pub fn scroll_to(&self, scroll_type: ScrollType) -> Result { + self.do_action_internal(self.id, |_, _, target_node, target_tree| ActionRequest { + action: Action::ScrollIntoView, + target_tree, + target_node, + data: atspi_scroll_type_to_scroll_hint(scroll_type).map(ActionData::ScrollHint), + })?; + Ok(true) + } + + pub fn scroll_to_point(&self, coord_type: CoordType, x: i32, y: i32) -> Result { + self.resolve_with_context(|node, tree, context| { + let window_bounds = context.read_root_window_bounds(); + let point = window_bounds.atspi_point_to_accesskit_point( + Point::new(x.into(), y.into()), + node.filtered_parent(&filter), + coord_type, + ); + let (target_node, target_tree) = + tree.state().locate_node(self.id).ok_or(Error::Defunct)?; + context.do_action(ActionRequest { + action: Action::ScrollToPoint, + target_tree, + target_node, + data: Some(ActionData::ScrollToPoint(point)), + }); + Ok(()) + })?; + Ok(true) + } + + pub fn n_anchors(&self) -> Result { + self.resolve(|node| if node.url().is_some() { Ok(1) } else { Ok(0) }) + } + + pub fn hyperlink_start_index(&self) -> Result { + self.resolve(|_| { + // TODO: Support rich text + Ok(-1) + }) + } + + pub fn hyperlink_end_index(&self) -> Result { + self.resolve(|_| { + // TODO: Support rich text + Ok(-1) + }) + } + + pub fn hyperlink_object(&self, index: i32) -> Result> { + self.resolve(|_| { + if index == 0 { + Ok(Some(self.id)) + } else { + Ok(None) + } + }) + } + + pub fn uri(&self, index: i32) -> Result { + self.resolve(|node| { + if index == 0 { + Ok(node.url().map(|s| s.to_string()).unwrap_or_default()) + } else { + Ok(String::new()) + } + }) + } + + pub fn hyperlink_is_valid(&self) -> Result { + self.resolve(|node| Ok(node.url().is_some())) + } + + pub fn n_selected_children(&self) -> Result { + self.resolve_for_selection(|node| { + node.items(filter) + .filter(|item| item.is_selected() == Some(true)) + .count() + .try_into() + .map_err(|_| Error::TooManyChildren) + }) + } + + pub fn selected_child(&self, selected_child_index: usize) -> Result> { + self.resolve_for_selection(|node| { + Ok(node + .items(filter) + .filter(|item| item.is_selected() == Some(true)) + .nth(selected_child_index) + .map(|node| node.id())) + }) + } + + pub fn select_child(&self, child_index: usize) -> Result { + self.resolve_for_selection_with_context(|node, tree, context| { + if let Some(child) = node.filtered_children(filter).nth(child_index) { + if let Some(true) = child.is_selected() { + Ok(true) + } else if child.is_selectable() && child.is_clickable(&filter) { + let (target_node, target_tree) = + tree.state().locate_node(child.id()).ok_or(Error::Defunct)?; + context.do_action(ActionRequest { + action: Action::Click, + target_tree, + target_node, + data: None, + }); + Ok(true) + } else { + Ok(false) + } + } else { + Err(Error::Defunct) + } + }) + } + + pub fn deselect_selected_child(&self, selected_child_index: usize) -> Result { + self.resolve_for_selection_with_context(|node, tree, context| { + if let Some(child) = node + .items(filter) + .filter(|c| c.is_selected() == Some(true)) + .nth(selected_child_index) + { + if child.is_clickable(&filter) { + let (target_node, target_tree) = + tree.state().locate_node(child.id()).ok_or(Error::Defunct)?; + context.do_action(ActionRequest { + action: Action::Click, + target_tree, + target_node, + data: None, + }); + Ok(true) + } else { + Ok(false) + } + } else { + Err(Error::Defunct) + } + }) + } + + pub fn is_child_selected(&self, child_index: usize) -> Result { + self.resolve_for_selection(|node| { + node.filtered_children(filter) + .nth(child_index) + .map(|child| child.is_item_like() && child.is_selected() == Some(true)) + .ok_or(Error::Defunct) + }) + } + + pub fn select_all(&self) -> Result { + // We don't support selecting all children at once. + Ok(false) + } + + pub fn clear_selection(&self) -> Result { + // We don't support deselecting all children at once. + Ok(false) + } + + pub fn deselect_child(&self, child_index: usize) -> Result { + self.resolve_for_selection_with_context(|node, tree, context| { + if let Some(child) = node.filtered_children(filter).nth(child_index) { + if let Some(false) = child.is_selected() { + Ok(true) + } else if child.is_selectable() && child.is_clickable(&filter) { + let (target_node, target_tree) = + tree.state().locate_node(child.id()).ok_or(Error::Defunct)?; + context.do_action(ActionRequest { + action: Action::Click, + target_tree, + target_node, + data: None, + }); + Ok(true) + } else { + Ok(false) + } + } else { + Err(Error::Defunct) + } + }) + } + + pub fn character_count(&self) -> Result { + self.resolve_for_text(|node| { + node.document_range() + .end() + .to_global_usv_index() + .try_into() + .map_err(|_| Error::TooManyCharacters) + }) + } + + pub fn caret_offset(&self) -> Result { + self.resolve_for_text(|node| { + node.text_selection_focus().map_or(Ok(-1), |focus| { + focus + .to_global_usv_index() + .try_into() + .map_err(|_| Error::TooManyCharacters) + }) + }) + } + + pub fn string_at_offset( + &self, + offset: i32, + granularity: Granularity, + ) -> Result<(String, i32, i32)> { + self.resolve_for_text(|node| { + let range = text_range_from_offset(&node, offset, granularity)?; + let text = range.text(); + let start = range + .start() + .to_global_usv_index() + .try_into() + .map_err(|_| Error::TooManyCharacters)?; + let end = range + .end() + .to_global_usv_index() + .try_into() + .map_err(|_| Error::TooManyCharacters)?; + + Ok((text, start, end)) + }) + } + + pub fn text(&self, start_offset: i32, end_offset: i32) -> Result { + self.resolve_for_text(|node| { + let range = text_range_from_offsets(&node, start_offset, end_offset) + .ok_or(Error::IndexOutOfRange)?; + Ok(range.text()) + }) + } + + pub fn set_caret_offset(&self, offset: i32) -> Result { + self.resolve_for_text_with_context(|node, tree, context| { + let offset = text_position_from_offset(&node, offset).ok_or(Error::IndexOutOfRange)?; + let (target_node, target_tree) = + tree.state().locate_node(node.id()).ok_or(Error::Defunct)?; + context.do_action(ActionRequest { + action: Action::SetTextSelection, + target_tree, + target_node, + data: Some(ActionData::SetTextSelection( + offset.to_degenerate_range().to_text_selection(), + )), + }); + Ok(true) + }) + } + + pub fn text_attribute_value(&self, offset: i32, attribute_name: &str) -> Result { + self.resolve_for_text(|node| { + let pos = text_position_from_offset(&node, offset).ok_or(Error::IndexOutOfRange)?; + Ok(ATTRIBUTE_GETTERS + .get(attribute_name) + .and_then(|getter| (*getter)(pos.inner_node())) + .unwrap_or_default()) + }) + } + + pub fn text_attributes( + &self, + offset: i32, + ) -> Result<(HashMap<&'static str, String>, i32, i32)> { + self.text_attribute_run(offset, false) + } + + pub fn default_text_attributes(&self) -> Result> { + self.resolve_for_text(|node| { + let mut result = HashMap::with_capacity(ATTRIBUTE_GETTERS.len()); + for (name, getter) in ATTRIBUTE_GETTERS.entries() { + if let Some(value) = (*getter)(&node) { + result.insert(*name, value); + } + } + Ok(result) + }) + } + + pub fn character_extents(&self, offset: i32, coord_type: CoordType) -> Result { + self.resolve_for_text_with_context(|node, _, context| { + let range = text_range_from_offset(&node, offset, Granularity::Char)?; + if let Some(bounds) = range.bounding_boxes().first() { + let window_bounds = context.read_root_window_bounds(); + let new_origin = window_bounds.accesskit_point_to_atspi_point( + bounds.origin(), + Some(node), + coord_type, + ); + Ok(bounds.with_origin(new_origin).into()) + } else { + Ok(AtspiRect::INVALID) + } + }) + } + + pub fn offset_at_point(&self, x: i32, y: i32, coord_type: CoordType) -> Result { + self.resolve_for_text_with_context(|node, _, context| { + let window_bounds = context.read_root_window_bounds(); + let point = window_bounds.atspi_point_to_accesskit_point( + Point::new(x.into(), y.into()), + Some(node), + coord_type, + ); + let point = node.transform().inverse() * point; + node.text_position_at_point(point) + .to_global_usv_index() + .try_into() + .map_err(|_| Error::TooManyCharacters) + }) + } + + pub fn n_selections(&self) -> Result { + self.resolve_for_text(|node| { + match node.text_selection().filter(|range| !range.is_degenerate()) { + Some(_) => Ok(1), + None => Ok(0), + } + }) + } + + pub fn selection(&self, selection_num: i32) -> Result<(i32, i32)> { + if selection_num != 0 { + return Ok((-1, -1)); + } + + self.resolve_for_text(|node| { + node.text_selection() + .filter(|range| !range.is_degenerate()) + .map_or(Ok((-1, -1)), |range| { + let start = range + .start() + .to_global_usv_index() + .try_into() + .map_err(|_| Error::TooManyCharacters)?; + let end = range + .end() + .to_global_usv_index() + .try_into() + .map_err(|_| Error::TooManyCharacters)?; + + Ok((start, end)) + }) + }) + } + + pub fn add_selection(&self, start_offset: i32, end_offset: i32) -> Result { + // We only support one selection. + self.set_selection(0, start_offset, end_offset) + } + + pub fn remove_selection(&self, selection_num: i32) -> Result { + if selection_num != 0 { + return Ok(false); + } + + self.resolve_for_text_with_context(|node, tree, context| { + // Simply collapse the selection to the position of the caret if a caret is + // visible, otherwise set the selection to 0. + let selection_end = node + .text_selection_focus() + .unwrap_or_else(|| node.document_range().start()); + let (target_node, target_tree) = + tree.state().locate_node(node.id()).ok_or(Error::Defunct)?; + context.do_action(ActionRequest { + action: Action::SetTextSelection, + target_tree, + target_node, + data: Some(ActionData::SetTextSelection( + selection_end.to_degenerate_range().to_text_selection(), + )), + }); + Ok(true) + }) + } + + pub fn set_selection( + &self, + selection_num: i32, + start_offset: i32, + end_offset: i32, + ) -> Result { + if selection_num != 0 { + return Ok(false); + } + + self.resolve_for_text_with_context(|node, tree, context| { + let range = text_range_from_offsets(&node, start_offset, end_offset) + .ok_or(Error::IndexOutOfRange)?; + let (target_node, target_tree) = + tree.state().locate_node(node.id()).ok_or(Error::Defunct)?; + context.do_action(ActionRequest { + action: Action::SetTextSelection, + target_tree, + target_node, + data: Some(ActionData::SetTextSelection(range.to_text_selection())), + }); + Ok(true) + }) + } + + pub fn range_extents( + &self, + start_offset: i32, + end_offset: i32, + coord_type: CoordType, + ) -> Result { + self.resolve_for_text_with_context(|node, _, context| { + if let Some(rect) = text_range_bounds_from_offsets(&node, start_offset, end_offset) { + let window_bounds = context.read_root_window_bounds(); + let new_origin = window_bounds.accesskit_point_to_atspi_point( + rect.origin(), + Some(node), + coord_type, + ); + Ok(rect.with_origin(new_origin).into()) + } else { + Ok(AtspiRect::INVALID) + } + }) + } + + pub fn text_attribute_run( + &self, + offset: i32, + include_defaults: bool, + ) -> Result<(HashMap<&'static str, String>, i32, i32)> { + self.resolve_for_text(|node| { + let pos = text_position_from_offset(&node, offset).ok_or(Error::IndexOutOfRange)?; + let mut result = HashMap::with_capacity(ATTRIBUTE_GETTERS.len()); + for (name, getter) in ATTRIBUTE_GETTERS.entries() { + if let Some(value) = (*getter)(pos.inner_node()) { + if !include_defaults { + if let Some(default) = (*getter)(&node) { + if value == default { + continue; + } + } + } + result.insert(*name, value); + } + } + let start = if pos.is_format_start() { + pos + } else { + pos.backward_to_format_start() + }; + let end = pos.forward_to_format_end(); + Ok(( + result, + start + .to_global_usv_index() + .try_into() + .map_err(|_| Error::TooManyCharacters)?, + end.to_global_usv_index() + .try_into() + .map_err(|_| Error::TooManyCharacters)?, + )) + }) + } + + pub fn scroll_substring_to( + &self, + start_offset: i32, + end_offset: i32, + scroll_type: ScrollType, + ) -> Result { + self.resolve_for_text_with_context(|node, tree, context| { + if let Some(range) = text_range_from_offsets(&node, start_offset, end_offset) { + let position = if matches!( + scroll_type, + ScrollType::BottomRight | ScrollType::BottomEdge | ScrollType::RightEdge + ) { + range.end() + } else { + range.start() + }; + let (target_node, target_tree) = tree + .state() + .locate_node(position.inner_node().id()) + .ok_or(Error::Defunct)?; + context.do_action(ActionRequest { + action: Action::ScrollIntoView, + target_tree, + target_node, + data: atspi_scroll_type_to_scroll_hint(scroll_type).map(ActionData::ScrollHint), + }); + Ok(true) + } else { + Ok(false) + } + }) + } + + pub fn scroll_substring_to_point( + &self, + start_offset: i32, + end_offset: i32, + coord_type: CoordType, + x: i32, + y: i32, + ) -> Result { + self.resolve_for_text_with_context(|node, tree, context| { + let window_bounds = context.read_root_window_bounds(); + let target_point = window_bounds.atspi_point_to_accesskit_point( + Point::new(x.into(), y.into()), + Some(node), + coord_type, + ); + + if let Some(rect) = text_range_bounds_from_offsets(&node, start_offset, end_offset) { + let point = Point::new(target_point.x - rect.x0, target_point.y - rect.y0); + let (target_node, target_tree) = + tree.state().locate_node(node.id()).ok_or(Error::Defunct)?; + context.do_action(ActionRequest { + action: Action::ScrollToPoint, + target_tree, + target_node, + data: Some(ActionData::ScrollToPoint(point)), + }); + return Ok(true); + } + Ok(false) + }) + } + + pub fn minimum_value(&self) -> Result { + self.resolve(|node| Ok(node.min_numeric_value().unwrap_or(f64::MIN))) + } + + pub fn maximum_value(&self) -> Result { + self.resolve(|node| Ok(node.max_numeric_value().unwrap_or(f64::MAX))) + } + + pub fn minimum_increment(&self) -> Result { + self.resolve(|node| Ok(node.numeric_value_step().unwrap_or(0.0))) + } + + pub fn current_value(&self) -> Result { + self.resolve(|node| { + let wrapper = NodeWrapper(&node); + Ok(wrapper.current_value().unwrap_or(0.0)) + }) + } + + pub fn set_current_value(&self, value: f64) -> Result<()> { + self.do_action_internal(self.id, |_, _, target_node, target_tree| ActionRequest { + action: Action::SetValue, + target_tree, + target_node, + data: Some(ActionData::NumericValue(value)), + }) + } +} + +impl PartialEq for PlatformNode { + fn eq(&self, other: &Self) -> bool { + self.adapter_id == other.adapter_id && self.id == other.id + } +} + +impl Eq for PlatformNode {} + +impl Hash for PlatformNode { + fn hash(&self, state: &mut H) { + self.adapter_id.hash(state); + self.id.hash(state); + } +} + +#[derive(Clone)] +pub struct PlatformRoot { + app_context: Weak>, +} + +impl PlatformRoot { + pub fn new(app_context: &Arc>) -> Self { + Self { + app_context: Arc::downgrade(app_context), + } + } + + fn resolve_app_context(&self, f: F) -> Result + where + for<'a> F: FnOnce(RwLockReadGuard<'a, AppContext>) -> Result, + { + let app_context = match self.app_context.upgrade() { + Some(context) => context, + None => return Err(Error::Defunct), + }; + let app_context = app_context.read().unwrap(); + f(app_context) + } + + pub fn name(&self) -> Result { + self.resolve_app_context(|context| Ok(context.name.clone().unwrap_or_default())) + } + + pub fn description(&self) -> Result { + Ok(String::new()) + } + + pub fn child_count(&self) -> Result { + self.resolve_app_context(|context| { + i32::try_from(context.adapters.len()).map_err(|_| Error::TooManyChildren) + }) + } + + pub fn interfaces(&self) -> InterfaceSet { + InterfaceSet::new(Interface::Accessible | Interface::Application) + } + + pub fn role(&self) -> AtspiRole { + AtspiRole::Application + } + + pub fn index_in_parent(&self) -> i32 { + -1 + } + + pub fn state(&self) -> StateSet { + StateSet::empty() + } + + pub fn child_at_index(&self, index: usize) -> Result> { + self.resolve_app_context(|context| { + let child = context + .adapters + .get(index) + .map(PlatformNode::from_adapter_root); + Ok(child) + }) + } + + pub fn child_id_at_index(&self, index: usize) -> Result> { + self.resolve_app_context(|context| { + let child = context + .adapters + .get(index) + .map(|(adapter_id, context)| (*adapter_id, context.read_tree().state().root_id())); + Ok(child) + }) + } + + pub fn map_children(&self, f: impl Fn(PlatformNode) -> I) -> Result + where + T: FromIterator, + { + self.resolve_app_context(|context| { + let children = context + .adapters + .iter() + .map(PlatformNode::from_adapter_root) + .map(f) + .collect(); + Ok(children) + }) + } + + pub fn map_child_ids(&self, f: impl Fn((usize, NodeId)) -> I) -> Result + where + T: FromIterator, + { + self.resolve_app_context(|context| { + let children = context + .adapters + .iter() + .map(|(adapter_id, context)| (*adapter_id, context.read_tree().state().root_id())) + .map(f) + .collect(); + Ok(children) + }) + } + + pub fn toolkit_name(&self) -> Result { + self.resolve_app_context(|context| Ok(context.toolkit_name.clone().unwrap_or_default())) + } + + pub fn toolkit_version(&self) -> Result { + self.resolve_app_context(|context| Ok(context.toolkit_version.clone().unwrap_or_default())) + } + + pub fn id(&self) -> Result { + self.resolve_app_context(|context| Ok(context.id.unwrap_or(-1))) + } + + pub fn set_id(&mut self, id: i32) -> Result<()> { + let app_context = match self.app_context.upgrade() { + Some(context) => context, + None => return Err(Error::Defunct), + }; + let mut app_context = app_context.write().unwrap(); + app_context.id = Some(id); + Ok(()) + } + + pub fn map_descendants(&self, f: impl Fn(PlatformNode, usize, usize) -> I) -> Result + where + T: FromIterator, + { + fn collect_descendants( + node: Node<'_>, + index_in_parent: usize, + adapter_id: usize, + context: &Arc, + f: &impl Fn(PlatformNode, usize, usize) -> I, + results: &mut Vec, + ) { + let children: Vec<_> = node.filtered_children(&filter).collect(); + let platform_node = PlatformNode::new(context, adapter_id, node.id()); + results.push(f(platform_node, index_in_parent, children.len())); + for (child_index, child) in children.into_iter().enumerate() { + collect_descendants(child, child_index, adapter_id, context, f, results); + } + } + + self.resolve_app_context(|context| { + let mut results = Vec::new(); + + for (adapter_slot, (adapter_id, adapter_context)) in context.adapters.iter().enumerate() + { + let tree = adapter_context.read_tree(); + let state = tree.state(); + let root = state.root(); + + collect_descendants( + root, + adapter_slot, + *adapter_id, + adapter_context, + &f, + &mut results, + ); + } + + Ok(results.into_iter().collect()) + }) + } + + pub fn map_descendant_cache_nodes(&self, f: impl Fn(CacheNode) -> I) -> Result + where + T: FromIterator, + { + fn collect_descendants( + node: Node<'_>, + index_in_parent: i32, + adapter_id: usize, + window_focused: bool, + f: &impl Fn(CacheNode) -> I, + results: &mut Vec>, + ) { + let children: Vec<_> = node.filtered_children(&filter).collect(); + let child_count = match i32::try_from(children.len()) { + Ok(count) => count, + Err(_) => { + results.push(Err(Error::TooManyChildren)); + return; + } + }; + let wrapper = NodeWrapper(&node); + let cache_node = + wrapper.cache_node(adapter_id, index_in_parent, child_count, window_focused); + results.push(Ok(f(cache_node))); + for (child_index, child) in children.into_iter().enumerate() { + let child_index = match i32::try_from(child_index) { + Ok(index) => index, + Err(_) => { + results.push(Err(Error::IndexOutOfRange)); + return; + } + }; + collect_descendants(child, child_index, adapter_id, window_focused, f, results); + } + } + + self.resolve_app_context(|context| { + let mut results = Vec::new(); + + for (adapter_slot, (adapter_id, adapter_context)) in context.adapters.iter().enumerate() + { + let tree = adapter_context.read_tree(); + let state = tree.state(); + let root = state.root(); + let index_in_parent = + i32::try_from(adapter_slot).map_err(|_| Error::IndexOutOfRange)?; + let window_focused = state.focus_id().is_some(); + + collect_descendants( + root, + index_in_parent, + *adapter_id, + window_focused, + &f, + &mut results, + ); + } + + results.into_iter().collect() + }) + } +} + +impl PartialEq for PlatformRoot { + fn eq(&self, other: &Self) -> bool { + self.app_context.ptr_eq(&other.app_context) + } +} + +impl Hash for PlatformRoot { + fn hash(&self, state: &mut H) { + self.app_context.as_ptr().hash(state); + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum NodeIdOrRoot { + Node(NodeId), + Root, +} + +pub struct CacheNode { + pub adapter_id: usize, + pub id: NodeId, + pub parent: NodeIdOrRoot, + pub index_in_parent: i32, + pub child_count: i32, + pub interfaces: InterfaceSet, + pub name: String, + pub description: String, + pub role: AtspiRole, + pub states: StateSet, +} diff --git a/patches/accesskit_atspi_common/src/rect.rs b/patches/accesskit_atspi_common/src/rect.rs new file mode 100644 index 0000000..6b33952 --- /dev/null +++ b/patches/accesskit_atspi_common/src/rect.rs @@ -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 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, + } + } +} diff --git a/patches/accesskit_atspi_common/src/simplified.rs b/patches/accesskit_atspi_common/src/simplified.rs new file mode 100644 index 0000000..9ff3580 --- /dev/null +++ b/patches/accesskit_atspi_common/src/simplified.rs @@ -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 { + match self { + Self::Node(node) => node.role(), + Self::Root(root) => Ok(root.role()), + } + } + + pub fn localized_role_name(&self) -> Result { + match self { + Self::Node(node) => node.localized_role_name(), + Self::Root(_) => Ok("".into()), + } + } + + pub fn name(&self) -> Result { + match self { + Self::Node(node) => node.name(), + Self::Root(root) => root.name(), + } + } + + pub fn description(&self) -> Result { + 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> { + match self { + Self::Node(node) => node.attributes(), + Self::Root(_) => Ok(HashMap::new()), + } + } + + pub fn parent(&self) -> Result> { + 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 { + match self { + Self::Node(node) => node.index_in_parent(), + Self::Root(root) => Ok(root.index_in_parent()), + } + } + + pub fn child_count(&self) -> Result { + match self { + Self::Node(node) => node.child_count(), + Self::Root(root) => root.child_count(), + } + } + + pub fn accessible_id(&self) -> Result { + match self { + Self::Node(node) => node.accessible_id(), + Self::Root(_) => Ok(String::new()), + } + } + + pub fn child_at_index(&self, index: usize) -> Result> { + 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(&self, f: impl Fn(Self) -> I) -> Result + where + T: FromIterator, + { + 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>> { + match self { + Self::Node(node) => node.relation_set(|id| Self::Node(node.relative(id))), + Self::Root(_) => Ok(HashMap::new()), + } + } + + pub fn application(&self) -> Result { + match self { + Self::Node(node) => node.root().map(Self::Root), + Self::Root(root) => Ok(Self::Root(root.clone())), + } + } + + pub fn toolkit_name(&self) -> Result { + match self { + Self::Node(node) => node.toolkit_name(), + Self::Root(root) => root.toolkit_name(), + } + } + + pub fn toolkit_version(&self) -> Result { + match self { + Self::Node(node) => node.toolkit_version(), + Self::Root(root) => root.toolkit_version(), + } + } + + pub fn supports_action(&self) -> Result { + match self { + Self::Node(node) => node.supports_action(), + Self::Root(_) => Ok(false), + } + } + + pub fn n_actions(&self) -> Result { + match self { + Self::Node(node) => node.n_actions(), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn action_name(&self, index: i32) -> Result { + match self { + Self::Node(node) => node.action_name(index), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn do_action(&self, index: i32) -> Result { + match self { + Self::Node(node) => node.do_action(index), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn supports_component(&self) -> Result { + match self { + Self::Node(node) => node.supports_component(), + Self::Root(_) => Ok(false), + } + } + + pub fn contains(&self, x: i32, y: i32, coord_type: CoordType) -> Result { + 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> { + 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 { + match self { + Self::Node(node) => node.extents(coord_type), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn layer(&self) -> Result { + match self { + Self::Node(node) => node.layer(), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn grab_focus(&self) -> Result { + match self { + Self::Node(node) => node.grab_focus(), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn scroll_to(&self, scroll_type: ScrollType) -> Result { + 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 { + match self { + Self::Node(node) => node.scroll_to_point(coord_type, x, y), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn supports_hyperlink(&self) -> Result { + match self { + Self::Node(node) => node.supports_hyperlink(), + Self::Root(_) => Ok(false), + } + } + + pub fn n_anchors(&self) -> Result { + match self { + Self::Node(node) => node.n_anchors(), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn hyperlink_start_index(&self) -> Result { + match self { + Self::Node(node) => node.hyperlink_start_index(), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn hyperlink_end_index(&self) -> Result { + match self { + Self::Node(node) => node.hyperlink_end_index(), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn hyperlink_object(&self, index: i32) -> Result> { + 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 { + match self { + Self::Node(node) => node.uri(index), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn hyperlink_is_valid(&self) -> Result { + match self { + Self::Node(node) => node.hyperlink_is_valid(), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn supports_selection(&self) -> Result { + match self { + Self::Node(node) => node.supports_selection(), + Self::Root(_) => Ok(false), + } + } + + pub fn n_selected_children(&self) -> Result { + match self { + Self::Node(node) => node.n_selected_children(), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn selected_child(&self, selected_child_index: usize) -> Result> { + 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 { + 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 { + 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 { + match self { + Self::Node(node) => node.is_child_selected(child_index), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn select_all(&self) -> Result { + match self { + Self::Node(node) => node.select_all(), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn clear_selection(&self) -> Result { + match self { + Self::Node(node) => node.clear_selection(), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn deselect_child(&self, child_index: usize) -> Result { + match self { + Self::Node(node) => node.deselect_child(child_index), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn supports_text(&self) -> Result { + match self { + Self::Node(node) => node.supports_text(), + Self::Root(_) => Ok(false), + } + } + + pub fn character_count(&self) -> Result { + match self { + Self::Node(node) => node.character_count(), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn caret_offset(&self) -> Result { + 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 { + 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 { + 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 { + 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> { + 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 { + 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 { + match self { + Self::Node(node) => node.offset_at_point(x, y, coord_type), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn n_selections(&self) -> Result { + 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 { + 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 { + 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 { + 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 { + 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 { + 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 { + 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 { + match self { + Self::Node(node) => node.supports_value(), + Self::Root(_) => Ok(false), + } + } + + pub fn minimum_value(&self) -> Result { + match self { + Self::Node(node) => node.minimum_value(), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn maximum_value(&self) -> Result { + match self { + Self::Node(node) => node.maximum_value(), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn minimum_increment(&self) -> Result { + match self { + Self::Node(node) => node.minimum_increment(), + Self::Root(_) => Err(Error::UnsupportedInterface), + } + } + + pub fn current_value(&self) -> Result { + 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> { + let descendants: Vec = 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, +} + +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>>, + } + + 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(_))); + } +} diff --git a/patches/accesskit_atspi_common/src/text_attributes.rs b/patches/accesskit_atspi_common/src/text_attributes.rs new file mode 100644 index 0000000..0893f2f --- /dev/null +++ b/patches/accesskit_atspi_common/src/text_attributes.rs @@ -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 { + node.font_family().map(String::from) +} + +fn size(node: &Node) -> Option { + node.font_size().map(|value| value.to_string()) +} + +fn weight(node: &Node) -> Option { + node.font_weight().map(|value| value.to_string()) +} + +fn style(node: &Node) -> Option { + node.is_italic().then(|| "italic".into()) +} + +fn strikethrough(node: &Node) -> Option { + node.strikethrough().map(|_| "true".into()) +} + +fn underline(node: &Node) -> Option { + node.underline().map(|deco| { + match deco.style { + TextDecorationStyle::Double => "double", + _ => "single", + } + .into() + }) +} + +fn bg_color(node: &Node) -> Option { + node.background_color().map(color_to_string) +} + +fn fg_color(node: &Node) -> Option { + node.foreground_color().map(color_to_string) +} + +fn language(node: &Node) -> Option { + node.language().map(String::from) +} + +fn justification(node: &Node) -> Option { + 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> = 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, +}; diff --git a/patches/accesskit_atspi_common/src/util.rs b/patches/accesskit_atspi_common/src/util.rs new file mode 100644 index 0000000..0671254 --- /dev/null +++ b/patches/accesskit_atspi_common/src/util.rs @@ -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, + 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, + 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, 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> { + 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, 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> { + 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 { + 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 { + 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, + } +} diff --git a/patches/accesskit_unix/CHANGELOG.md b/patches/accesskit_unix/CHANGELOG.md new file mode 100644 index 0000000..2d04b49 --- /dev/null +++ b/patches/accesskit_unix/CHANGELOG.md @@ -0,0 +1,633 @@ +# Changelog + +* The following workspace dependencies were updated + * dependencies + * accesskit_consumer bumped from 0.12.0 to 0.12.1 + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.10.0 to 0.10.1 + * accesskit_consumer bumped from 0.14.0 to 0.14.1 + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.10.1 to 0.11.0 + * accesskit_consumer bumped from 0.14.1 to 0.14.2 + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.11.0 to 0.11.1 + * accesskit_consumer bumped from 0.15.0 to 0.15.1 + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.11.1 to 0.11.2 + * accesskit_consumer bumped from 0.15.1 to 0.15.2 + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.12.0 to 0.12.1 + * accesskit_consumer bumped from 0.16.0 to 0.16.1 + +* The following workspace dependencies were updated + * dependencies + * accesskit_atspi_common bumped from 0.1.0 to 0.1.1 + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.12.2 to 0.12.3 + * accesskit_atspi_common bumped from 0.1.1 to 0.1.2 + +* The following workspace dependencies were updated + * dependencies + * accesskit_atspi_common bumped from 0.1.2 to 0.2.0 + +* The following workspace dependencies were updated + * dependencies + * accesskit_atspi_common bumped from 0.4.0 to 0.4.1 + +* The following workspace dependencies were updated + * dependencies + * accesskit_atspi_common bumped from 0.4.1 to 0.4.2 + +* The following workspace dependencies were updated + * dependencies + * accesskit_atspi_common bumped from 0.5.0 to 0.6.0 + +* The following workspace dependencies were updated + * dependencies + * accesskit_atspi_common bumped from 0.7.0 to 0.8.0 + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.16.2 to 0.16.3 + * accesskit_atspi_common bumped from 0.9.2 to 0.9.3 + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.17.0 to 0.17.1 + * accesskit_atspi_common bumped from 0.10.0 to 0.10.1 + +## [0.22.1](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.22.0...accesskit_unix-v0.22.1) (2026-07-14) + + +### Bug Fixes + +* Don't panic on recoverable D-Bus errors on Unix ([#741](https://github.com/AccessKit/accesskit/issues/741)) ([a7d6545](https://github.com/AccessKit/accesskit/commit/a7d65458bd8d81ded693c7b8eae451e1e16aaa01)) +* Set the desktop as the app's parent on Unix ([#740](https://github.com/AccessKit/accesskit/issues/740)) ([e1f63ac](https://github.com/AccessKit/accesskit/commit/e1f63acbb2c36e3cae741871300aeb121c9e6274)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit_atspi_common bumped from 0.19.0 to 0.19.1 + +## [0.22.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.21.1...accesskit_unix-v0.22.0) (2026-06-12) + + +### 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 + +* Watch the IsEnabled property to lazily activate on Unix ([#715](https://github.com/AccessKit/accesskit/issues/715)) ([e7299a7](https://github.com/AccessKit/accesskit/commit/e7299a753d78e8b00dd75e1d2182abb517648f98)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.24.0 to 0.24.1 + * accesskit_atspi_common bumped from 0.18.1 to 0.19.0 + +## [0.21.1](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.21.0...accesskit_unix-v0.21.1) (2026-05-11) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit_atspi_common bumped from 0.18.0 to 0.18.1 + +## [0.21.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.20.0...accesskit_unix-v0.21.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)) + + +### Bug Fixes + +* Correctly register interfaces on Unix after Hyperlink was added ([#694](https://github.com/AccessKit/accesskit/issues/694)) ([b5979a4](https://github.com/AccessKit/accesskit/commit/b5979a4c88f5d9084f70525cf24f3a37c0988f57)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit_atspi_common bumped from 0.17.0 to 0.18.0 + +## [0.20.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.19.1...accesskit_unix-v0.20.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_atspi_common bumped from 0.16.1 to 0.17.0 + +## [0.19.1](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.19.0...accesskit_unix-v0.19.1) (2026-01-18) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit_atspi_common bumped from 0.16.0 to 0.16.1 + +## [0.19.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.18.0...accesskit_unix-v0.19.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_atspi_common bumped from 0.15.0 to 0.16.0 + +## [0.18.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.17.2...accesskit_unix-v0.18.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)) + + +### Bug Fixes + +* Activate when an assistive technology is actually running on Unix ([#628](https://github.com/AccessKit/accesskit/issues/628)) ([ec67fdf](https://github.com/AccessKit/accesskit/commit/ec67fdf1ec549913437a601fcd1fa142ec52c47d)) +* Bump atspi crates ([dbf81c9](https://github.com/AccessKit/accesskit/commit/dbf81c968739187a9f4c3c105d0618c0f9db3135)) + + +### 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_atspi_common bumped from 0.14.2 to 0.15.0 + +## [0.17.2](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.17.1...accesskit_unix-v0.17.2) (2025-10-20) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit_atspi_common bumped from 0.14.1 to 0.14.2 + +## [0.17.1](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.17.0...accesskit_unix-v0.17.1) (2025-10-02) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.21.0 to 0.21.1 + * accesskit_atspi_common bumped from 0.14.0 to 0.14.1 + +## [0.17.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.16.0...accesskit_unix-v0.17.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_atspi_common bumped from 0.13.0 to 0.14.0 + +## [0.16.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.15.0...accesskit_unix-v0.16.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_atspi_common bumped from 0.12.0 to 0.13.0 + +## [0.15.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.14.0...accesskit_unix-v0.15.0) (2025-05-06) + + +### ⚠ BREAKING CHANGES + +* Drop redundant `HasPopup::True` ([#550](https://github.com/AccessKit/accesskit/issues/550)) + +### Bug Fixes + +* Expose tabs in the platform adapters ([341a11b](https://github.com/AccessKit/accesskit/commit/341a11bca2c8a29682c11ddcfe91fa58776ea11d)) +* Mention caveats with window bounds under Wayland ([#559](https://github.com/AccessKit/accesskit/issues/559)) ([b0cf01a](https://github.com/AccessKit/accesskit/commit/b0cf01a26ded03d722818a193fa6902f69bbc102)) + + +### 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_atspi_common bumped from 0.11.0 to 0.12.0 + +## [0.14.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.13.1...accesskit_unix-v0.14.0) (2025-03-06) + + +### ⚠ BREAKING CHANGES + +* Drop `Tree::app_name` ([#492](https://github.com/AccessKit/accesskit/issues/492)) + +### Bug Fixes + +* Add list box support to the platform adapters ([6c622cf](https://github.com/AccessKit/accesskit/commit/6c622cff4c0c989d9a5f16b775adff9cdacf534c)) +* Derive `Debug` for adapters ([#513](https://github.com/AccessKit/accesskit/issues/513)) ([753d904](https://github.com/AccessKit/accesskit/commit/753d90473cf57682568c7a17c82474c8e5d00b25)) +* Don't enable the `zbus/tokio` feature on Unix ([#521](https://github.com/AccessKit/accesskit/issues/521)) ([9dfad97](https://github.com/AccessKit/accesskit/commit/9dfad9796f71563a78bc6a7d5f01b111d80e63e6)) +* Fix some clippy warnings ([#509](https://github.com/AccessKit/accesskit/issues/509)) ([579b9c1](https://github.com/AccessKit/accesskit/commit/579b9c12dd8abc44ecab41fa3c326a1d8999871d)) +* 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)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.17.1 to 0.18.0 + * accesskit_atspi_common bumped from 0.10.1 to 0.11.0 + +## [0.13.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.12.3...accesskit_unix-v0.13.0) (2024-10-31) + + +### ⚠ BREAKING CHANGES + +* 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)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.16.3 to 0.17.0 + * accesskit_atspi_common bumped from 0.9.3 to 0.10.0 + +## [0.12.2](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.12.1...accesskit_unix-v0.12.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_atspi_common bumped from 0.9.1 to 0.9.2 + +## [0.12.1](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.12.0...accesskit_unix-v0.12.1) (2024-09-24) + + +### Bug Fixes + +* Return a null object for AT-SPI application's parent ([#454](https://github.com/AccessKit/accesskit/issues/454)) ([8a84abf](https://github.com/AccessKit/accesskit/commit/8a84abf81eaf22dd3672813ca36f1a422b5c0f1e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.16.0 to 0.16.1 + * accesskit_atspi_common bumped from 0.9.0 to 0.9.1 + +## [0.12.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.11.1...accesskit_unix-v0.12.0) (2024-06-29) + + +### ⚠ BREAKING CHANGES + +* Rename the `StaticText` role to `Label` ([#434](https://github.com/AccessKit/accesskit/issues/434)) + +### Code Refactoring + +* Rename the `StaticText` role to `Label` ([#434](https://github.com/AccessKit/accesskit/issues/434)) ([7086bc0](https://github.com/AccessKit/accesskit/commit/7086bc0fad446d3ed4a0fd5eff641a1e75f6c599)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.15.0 to 0.16.0 + * accesskit_atspi_common bumped from 0.8.0 to 0.9.0 + +## [0.11.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.10.1...accesskit_unix-v0.11.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_atspi_common bumped from 0.6.0 to 0.7.0 + +## [0.10.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.9.2...accesskit_unix-v0.10.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)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit_atspi_common bumped from 0.4.2 to 0.5.0 + +## [0.9.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.8.0...accesskit_unix-v0.9.0) (2024-04-30) + + +### ⚠ BREAKING CHANGES + +* Force a semver-breaking release ([#398](https://github.com/AccessKit/accesskit/issues/398)) + +### Bug Fixes + +* Force a semver-breaking release ([#398](https://github.com/AccessKit/accesskit/issues/398)) ([87b8b92](https://github.com/AccessKit/accesskit/commit/87b8b92b74a102c7cae48e013d2c2ae1cc2f9598)) +* Increase minimum supported Rust version to `1.70` ([#396](https://github.com/AccessKit/accesskit/issues/396)) ([a8398b8](https://github.com/AccessKit/accesskit/commit/a8398b847aa003de91042ac45e33126fc2cae053)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.13.0 to 0.14.0 + * accesskit_atspi_common bumped from 0.3.0 to 0.4.0 + +## [0.8.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.7.5...accesskit_unix-v0.8.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_atspi_common bumped from 0.2.0 to 0.3.0 + +## [0.7.2](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.7.1...accesskit_unix-v0.7.2) (2024-02-24) + + +### Bug Fixes + +* Don't emit focus event twice on Unix ([#354](https://github.com/AccessKit/accesskit/issues/354)) ([b39216c](https://github.com/AccessKit/accesskit/commit/b39216cb31df692fef377f9b3c3c718fd225cc3c)) +* Use the new accesskit_atspi_common crate in the Unix adapter ([#356](https://github.com/AccessKit/accesskit/issues/356)) ([b2a468c](https://github.com/AccessKit/accesskit/commit/b2a468ccb91ee4e6d3435e73eb00c65cbe75060a)) + +## [0.7.1](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.7.0...accesskit_unix-v0.7.1) (2024-01-11) + + +### Bug Fixes + +* Make full use of tokio ecosystem if the tokio feature is enabled on Unix ([#336](https://github.com/AccessKit/accesskit/issues/336)) ([c034802](https://github.com/AccessKit/accesskit/commit/c0348024665a615a30fd8fe2f02e8c93cf9c6332)) +* Run our own async executor on Unix ([#337](https://github.com/AccessKit/accesskit/issues/337)) ([8f937ba](https://github.com/AccessKit/accesskit/commit/8f937baaa510dd96da196501822b82f75f05b595)) + +## [0.7.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.6.2...accesskit_unix-v0.7.0) (2024-01-03) + + +### ⚠ BREAKING CHANGES + +* Lazily activate Unix adapters ([#324](https://github.com/AccessKit/accesskit/issues/324)) + +### Features + +* Support custom role descriptions ([#316](https://github.com/AccessKit/accesskit/issues/316)) ([c8d1a56](https://github.com/AccessKit/accesskit/commit/c8d1a5638fa6c33adfa059815c04f7e043c56026)) + + +### Bug Fixes + +* Lazily activate Unix adapters ([#324](https://github.com/AccessKit/accesskit/issues/324)) ([54ed036](https://github.com/AccessKit/accesskit/commit/54ed036c99d87428a8eb5bb03fd77e9e31562d4c)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.12.1 to 0.12.2 + * accesskit_consumer bumped from 0.16.1 to 0.17.0 + +## [0.6.2](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.6.1...accesskit_unix-v0.6.2) (2023-12-14) + + +### Bug Fixes + +* Bump async-channel dependency to `2.1.1` ([#321](https://github.com/AccessKit/accesskit/issues/321)) ([99120b8](https://github.com/AccessKit/accesskit/commit/99120b828d65306ab71d41f71979dc67e8b0bf6b)) + +## [0.6.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.5.2...accesskit_unix-v0.6.0) (2023-09-27) + + +### ⚠ BREAKING CHANGES + +* Allow providing app_name, toolkit_name and toolkit_version in Tree, remove parameters from unix adapter constructor ([#291](https://github.com/AccessKit/accesskit/issues/291)) +* Make `ActionHandler::do_action` take `&mut self` ([#296](https://github.com/AccessKit/accesskit/issues/296)) +* Clean up roles and properties ([#289](https://github.com/AccessKit/accesskit/issues/289)) +* Decouple in-tree focus from host window/view focus ([#278](https://github.com/AccessKit/accesskit/issues/278)) +* Switch to simple unsigned 64-bit integer for node IDs ([#276](https://github.com/AccessKit/accesskit/issues/276)) + +### Features + +* Add role for terminals ([#282](https://github.com/AccessKit/accesskit/issues/282)) ([ddbef37](https://github.com/AccessKit/accesskit/commit/ddbef37158b57f56217317b480e40d58f83a9c24)) +* Allow providing app_name, toolkit_name and toolkit_version in Tree, remove parameters from unix adapter constructor ([#291](https://github.com/AccessKit/accesskit/issues/291)) ([5313860](https://github.com/AccessKit/accesskit/commit/531386023257150f49b5e4be942f359855fb7cb6)) +* Support live regions on Unix ([#299](https://github.com/AccessKit/accesskit/issues/299)) ([8d52a5f](https://github.com/AccessKit/accesskit/commit/8d52a5fc4271a3b5edcc602b23fd7b920446eab0)) +* Support multiple top-level windows on Unix ([#292](https://github.com/AccessKit/accesskit/issues/292)) ([43ecf4b](https://github.com/AccessKit/accesskit/commit/43ecf4b3ab96d9e8f7d2c2222c7e664c4f4f4abf)) + + +### Bug Fixes + +* Don't require tokio rt-multi-thread feature ([#290](https://github.com/AccessKit/accesskit/issues/290)) ([cf61e47](https://github.com/AccessKit/accesskit/commit/cf61e477adff26b032fa0b24502c0ae0a96c1987)) +* Use common filters across platform adapters ([#287](https://github.com/AccessKit/accesskit/issues/287)) ([09c1204](https://github.com/AccessKit/accesskit/commit/09c12045ff4ccdb22f0cf643077a27465013572d)) + + +### Code Refactoring + +* Clean up roles and properties ([#289](https://github.com/AccessKit/accesskit/issues/289)) ([4fc9c55](https://github.com/AccessKit/accesskit/commit/4fc9c55c91812472593923d93ff89d75ff305ee4)) +* Decouple in-tree focus from host window/view focus ([#278](https://github.com/AccessKit/accesskit/issues/278)) ([d360d20](https://github.com/AccessKit/accesskit/commit/d360d20cf951e7643b81a5303006c9f7daa5bd56)) +* Make `ActionHandler::do_action` take `&mut self` ([#296](https://github.com/AccessKit/accesskit/issues/296)) ([4fc7846](https://github.com/AccessKit/accesskit/commit/4fc7846d732d61fb45c023060ebab96801a0053e)) +* Switch to simple unsigned 64-bit integer for node IDs ([#276](https://github.com/AccessKit/accesskit/issues/276)) ([3eadd48](https://github.com/AccessKit/accesskit/commit/3eadd48ec47854faa94a94ebf910ec08f514642f)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.11.2 to 0.12.0 + * accesskit_consumer bumped from 0.15.2 to 0.16.0 + +## [0.5.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.4.0...accesskit_unix-v0.5.0) (2023-05-21) + + +### Features + +* Add features for async runtimes on Unix ([#248](https://github.com/AccessKit/accesskit/issues/248)) ([b56b4ea](https://github.com/AccessKit/accesskit/commit/b56b4ea7c967ee5a1dae21a2fa0dcd385346031e)) + +## [0.4.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.3.3...accesskit_unix-v0.4.0) (2023-03-30) + + +### ⚠ BREAKING CHANGES + +* Force a semver-breaking version bump in downstream crates ([#234](https://github.com/AccessKit/accesskit/issues/234)) + +### Bug Fixes + +* Force a semver-breaking version bump in downstream crates ([#234](https://github.com/AccessKit/accesskit/issues/234)) ([773389b](https://github.com/AccessKit/accesskit/commit/773389bff857fa18edf15de426e029251fc34591)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit_consumer bumped from 0.14.2 to 0.15.0 + +## [0.3.1](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.3.0...accesskit_unix-v0.3.1) (2023-02-20) + + +### Bug Fixes + +* Update atspi dependency ([#217](https://github.com/AccessKit/accesskit/issues/217)) ([93f2dc9](https://github.com/AccessKit/accesskit/commit/93f2dc9bf0a57a8b7592c3a4cf4aa3885a3356f2)) + +## [0.3.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.2.0...accesskit_unix-v0.3.0) (2023-02-12) + + +### ⚠ BREAKING CHANGES + +* Move thread synchronization into platform adapters; drop parking_lot ([#212](https://github.com/AccessKit/accesskit/issues/212)) + +### Code Refactoring + +* Move thread synchronization into platform adapters; drop parking_lot ([#212](https://github.com/AccessKit/accesskit/issues/212)) ([5df52e5](https://github.com/AccessKit/accesskit/commit/5df52e5545faddf6a51905409013c2f5be23981e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.9.0 to 0.10.0 + * accesskit_consumer bumped from 0.13.0 to 0.14.0 + +## [0.2.0](https://github.com/AccessKit/accesskit/compare/accesskit_unix-v0.1.1...accesskit_unix-v0.2.0) (2023-02-05) + + +### ⚠ BREAKING CHANGES + +* Make `Node` opaque and optimize it for size ([#205](https://github.com/AccessKit/accesskit/issues/205)) + +### Code Refactoring + +* Make `Node` opaque and optimize it for size ([#205](https://github.com/AccessKit/accesskit/issues/205)) ([4811152](https://github.com/AccessKit/accesskit/commit/48111521439b76c1a8687418a4b20f9b705eac6d)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit bumped from 0.8.1 to 0.9.0 + * accesskit_consumer bumped from 0.12.1 to 0.13.0 + +## 0.1.0 (2023-01-05) + + +### Features + +* Basic Unix platform adapter ([#198](https://github.com/AccessKit/accesskit/issues/198)) ([1cea32e](https://github.com/AccessKit/accesskit/commit/1cea32e44ee743b778ac941ceff9087ae745cb37)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * accesskit_consumer bumped from 0.11.0 to 0.12.0 diff --git a/patches/accesskit_unix/Cargo.toml b/patches/accesskit_unix/Cargo.toml new file mode 100644 index 0000000..ba5e26f --- /dev/null +++ b/patches/accesskit_unix/Cargo.toml @@ -0,0 +1,104 @@ +# 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_unix" +version = "0.22.1" +authors = ["The AccessKit contributors"] +build = false +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "AccessKit UI accessibility infrastructure: Linux adapter" +readme = "README.md" +keywords = [ + "gui", + "ui", + "accessibility", +] +categories = ["gui"] +license = "MIT OR Apache-2.0" +repository = "https://github.com/AccessKit/accesskit" +resolver = "2" + +[features] +async-io = [ + "dep:async-channel", + "dep:async-executor", + "dep:async-task", + "dep:futures-util", +] +default = ["async-io"] +tokio = [ + "dep:tokio", + "dep:tokio-stream", +] + +[lib] +name = "accesskit_unix" +path = "src/lib.rs" + +[dependencies.accesskit] +version = "0.24.1" + +[dependencies.accesskit_atspi_common] +version = "0.19.1" + +[dependencies.async-channel] +version = "2.1.1" +optional = true + +[dependencies.async-executor] +version = "1.5.0" +optional = true + +[dependencies.async-task] +version = "4.3.0" +optional = true + +[dependencies.atspi] +version = "0.29" +features = ["proxies"] +default-features = false + +[dependencies.futures-lite] +version = "2.3" + +[dependencies.futures-util] +version = "0.3.27" +optional = true + +[dependencies.serde] +version = "1.0" + +[dependencies.tokio] +version = "1.32.0" +features = [ + "macros", + "net", + "rt", + "sync", + "time", +] +optional = true + +[dependencies.tokio-stream] +version = "0.1.14" +optional = true + +[dependencies.zbus] +version = "6.1" +features = ["default-rt", "proxy", "service", "object-manager"] +default-features = false diff --git a/patches/accesskit_unix/LICENSE-APACHE b/patches/accesskit_unix/LICENSE-APACHE new file mode 100644 index 0000000..1b5ec8b --- /dev/null +++ b/patches/accesskit_unix/LICENSE-APACHE @@ -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 diff --git a/patches/accesskit_unix/LICENSE-MIT b/patches/accesskit_unix/LICENSE-MIT new file mode 100644 index 0000000..31aa793 --- /dev/null +++ b/patches/accesskit_unix/LICENSE-MIT @@ -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. diff --git a/patches/accesskit_unix/README.md b/patches/accesskit_unix/README.md new file mode 100644 index 0000000..5663fc4 --- /dev/null +++ b/patches/accesskit_unix/README.md @@ -0,0 +1,10 @@ +# AccessKit Unix adapter + +This is the Unix adapter for [AccessKit](https://accesskit.dev/). It exposes an AccessKit accessibility tree through the AT-SPI protocol. + +## Compatibility with async runtimes + +While this crate's API is purely blocking, it internally spawns asynchronous tasks on an executor. + +- If you use tokio, make sure to enable the `tokio` feature of this crate. +- If you use another async runtime or if you don't use one at all, the default feature will suit your needs. diff --git a/patches/accesskit_unix/VNOX-PATCH.md b/patches/accesskit_unix/VNOX-PATCH.md new file mode 100644 index 0000000..c84c20b --- /dev/null +++ b/patches/accesskit_unix/VNOX-PATCH.md @@ -0,0 +1,9 @@ +# Vnox maintenance patch: accesskit_unix 0.22.1 + +Source: published crates.io accesskit_unix 0.22.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. diff --git a/patches/accesskit_unix/src/adapter.rs b/patches/accesskit_unix/src/adapter.rs new file mode 100644 index 0000000..afca31f --- /dev/null +++ b/patches/accesskit_unix/src/adapter.rs @@ -0,0 +1,271 @@ +// 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::{ActionHandler, ActivationHandler, DeactivationHandler, Rect, TreeUpdate}; +use accesskit_atspi_common::{ + ActionHandlerNoMut, ActionHandlerWrapper, Adapter as AdapterImpl, AdapterCallback, CacheEvent, + Event, NodeId, PlatformNode, WindowBounds, next_adapter_id, +}; +#[cfg(not(feature = "tokio"))] +use async_channel::Sender; +use atspi::InterfaceSet; +use std::fmt::{Debug, Formatter}; +use std::sync::{Arc, Mutex}; +#[cfg(feature = "tokio")] +use tokio::sync::mpsc::UnboundedSender as Sender; + +use crate::context::{get_or_init_app_context, get_or_init_messages}; + +pub(crate) struct Callback { + messages: Sender, +} + +impl Callback { + pub(crate) fn new() -> Self { + let messages = get_or_init_messages(); + Self { messages } + } + + fn send_message(&self, message: Message) { + #[cfg(not(feature = "tokio"))] + let _ = self.messages.try_send(message); + #[cfg(feature = "tokio")] + let _ = self.messages.send(message); + } +} + +impl AdapterCallback for Callback { + fn register_interfaces(&self, adapter: &AdapterImpl, id: NodeId, interfaces: InterfaceSet) { + let node = adapter.platform_node(id); + self.send_message(Message::RegisterInterfaces { node, interfaces }); + } + + fn unregister_interfaces(&self, adapter: &AdapterImpl, id: NodeId, interfaces: InterfaceSet) { + self.send_message(Message::UnregisterInterfaces { + adapter_id: adapter.id(), + node_id: id, + interfaces, + }) + } + + fn emit_event(&self, adapter: &AdapterImpl, event: Event) { + match event { + Event::Cache(CacheEvent::Added(id)) => { + let node = adapter.platform_node(id); + self.send_message(Message::EmitCacheAdd { node }); + } + Event::Cache(CacheEvent::Removed(id)) => { + self.send_message(Message::EmitCacheRemove { + adapter_id: adapter.id(), + node_id: id, + }); + } + event => { + self.send_message(Message::EmitEvent { + adapter_id: adapter.id(), + event, + }); + } + } + } +} + +pub(crate) enum AdapterState { + Inactive { + is_window_focused: bool, + root_window_bounds: WindowBounds, + action_handler: Arc, + }, + Pending { + is_window_focused: bool, + root_window_bounds: WindowBounds, + action_handler: Arc, + }, + Active(AdapterImpl), +} + +impl Debug for AdapterState { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match self { + AdapterState::Inactive { + is_window_focused, + root_window_bounds, + action_handler: _, + } => f + .debug_struct("Inactive") + .field("is_window_focused", is_window_focused) + .field("root_window_bounds", root_window_bounds) + .field("action_handler", &"ActionHandler") + .finish(), + AdapterState::Pending { + is_window_focused, + root_window_bounds, + action_handler: _, + } => f + .debug_struct("Pending") + .field("is_window_focused", is_window_focused) + .field("root_window_bounds", root_window_bounds) + .field("action_handler", &"ActionHandler") + .finish(), + AdapterState::Active(r#impl) => f.debug_tuple("Active").field(r#impl).finish(), + } + } +} + +#[derive(Debug)] +pub struct Adapter { + messages: Sender, + id: usize, + state: Arc>, +} + +impl Adapter { + /// Create a new Unix adapter. + /// + /// All of the handlers will always be called from another thread. + pub fn new( + activation_handler: impl 'static + ActivationHandler + Send, + action_handler: impl 'static + ActionHandler + Send, + deactivation_handler: impl 'static + DeactivationHandler + Send, + ) -> Self { + let id = next_adapter_id(); + let messages = get_or_init_messages(); + let state = Arc::new(Mutex::new(AdapterState::Inactive { + is_window_focused: false, + root_window_bounds: Default::default(), + action_handler: Arc::new(ActionHandlerWrapper::new(action_handler)), + })); + let adapter = Self { + id, + messages, + state: Arc::clone(&state), + }; + adapter.send_message(Message::AddAdapter { + id, + activation_handler: Box::new(activation_handler), + deactivation_handler: Box::new(deactivation_handler), + state, + }); + adapter + } + + pub(crate) fn send_message(&self, message: Message) { + #[cfg(not(feature = "tokio"))] + let _ = self.messages.try_send(message); + #[cfg(feature = "tokio")] + let _ = self.messages.send(message); + } + + /// Set the bounds of the top-level window. The outer bounds contain any + /// window decoration and borders. + /// + /// # Caveats + /// + /// Since an application can not get the position of its window under + /// Wayland, calling this method only makes sense under X11. + pub fn set_root_window_bounds(&mut self, outer: Rect, inner: Rect) { + let new_bounds = WindowBounds::new(outer, inner); + let mut state = self.state.lock().unwrap(); + match &mut *state { + AdapterState::Inactive { + root_window_bounds, .. + } => { + *root_window_bounds = new_bounds; + } + AdapterState::Pending { + root_window_bounds, .. + } => { + *root_window_bounds = new_bounds; + } + AdapterState::Active(r#impl) => r#impl.set_root_window_bounds(new_bounds), + } + } + + /// If and only if the tree has been initialized, call the provided function + /// and apply the resulting update. Note: If the caller's implementation of + /// [`ActivationHandler::request_initial_tree`] initially returned `None`, + /// the [`TreeUpdate`] returned by the provided function must contain + /// a full tree. + pub fn update_if_active(&mut self, update_factory: impl FnOnce() -> TreeUpdate) { + let mut state = self.state.lock().unwrap(); + match &mut *state { + AdapterState::Inactive { .. } => (), + AdapterState::Pending { + is_window_focused, + root_window_bounds, + action_handler, + } => { + let initial_state = update_factory(); + let r#impl = AdapterImpl::with_wrapped_action_handler( + self.id, + get_or_init_app_context(), + Callback::new(), + initial_state, + *is_window_focused, + *root_window_bounds, + Arc::clone(action_handler), + ); + *state = AdapterState::Active(r#impl); + } + AdapterState::Active(r#impl) => r#impl.update(update_factory()), + } + } + + /// Update the tree state based on whether the window is focused. + pub fn update_window_focus_state(&mut self, is_focused: bool) { + let mut state = self.state.lock().unwrap(); + match &mut *state { + AdapterState::Inactive { + is_window_focused, .. + } => { + *is_window_focused = is_focused; + } + AdapterState::Pending { + is_window_focused, .. + } => { + *is_window_focused = is_focused; + } + AdapterState::Active(r#impl) => r#impl.update_window_focus_state(is_focused), + } + } +} + +impl Drop for Adapter { + fn drop(&mut self) { + self.send_message(Message::RemoveAdapter { id: self.id }); + } +} + +pub(crate) enum Message { + AddAdapter { + id: usize, + activation_handler: Box, + deactivation_handler: Box, + state: Arc>, + }, + RemoveAdapter { + id: usize, + }, + RegisterInterfaces { + node: PlatformNode, + interfaces: InterfaceSet, + }, + UnregisterInterfaces { + adapter_id: usize, + node_id: NodeId, + interfaces: InterfaceSet, + }, + EmitEvent { + adapter_id: usize, + event: Event, + }, + EmitCacheAdd { + node: PlatformNode, + }, + EmitCacheRemove { + adapter_id: usize, + node_id: NodeId, + }, +} diff --git a/patches/accesskit_unix/src/atspi/bus.rs b/patches/accesskit_unix/src/atspi/bus.rs new file mode 100644 index 0000000..d5b9e9e --- /dev/null +++ b/patches/accesskit_unix/src/atspi/bus.rs @@ -0,0 +1,461 @@ +// 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 crate::{ + atspi::{ObjectId, cache_path, interfaces::*}, + context::get_or_init_app_context, +}; +use accesskit_atspi_common::{ + NodeId, NodeIdOrRoot, ObjectEvent, PlatformNode, PlatformRoot, Property, WindowEvent, +}; +use atspi::{ + Interface, InterfaceSet, ObjectRefOwned, + events::EventBodyBorrowed, + proxy::{bus::BusProxy, socket::SocketProxy}, +}; +use std::{ + env::var, + sync::{Arc, OnceLock}, +}; +use zbus::{ + Address, Connection, Result, + connection::Builder, + names::{BusName, InterfaceName, MemberName, OwnedUniqueName}, + wire::{Str, Variant as Value}, +}; + +pub(crate) struct Bus { + conn: Connection, + socket_proxy: SocketProxy<'static>, + desktop: Arc>, +} + +impl Bus { + pub(crate) async fn new( + session_bus: &Connection, + ) -> zbus::Result { + let address = match var("AT_SPI_BUS_ADDRESS") { + Ok(address) if !address.is_empty() => address, + _ => BusProxy::new(session_bus).await?.get_address().await?, + }; + let address: Address = address.as_str().try_into()?; + // zbus 6 selects and drives its maintained default runtime. + let conn = Builder::address(address).build().await?; + let socket_proxy = SocketProxy::new(&conn).await?; + let mut bus = Bus { + conn, + socket_proxy, + desktop: Arc::new(OnceLock::new()), + }; + bus.register_root_node().await?; + Ok(bus) + } + + fn unique_name(&self) -> &OwnedUniqueName { + self.conn.unique_name().unwrap() + } + + async fn register_root_node(&mut self) -> Result<()> { + let node = PlatformRoot::new(get_or_init_app_context()); + let path = ObjectId::Root.path(); + + if self + .conn + .object_server() + .at(path.clone(), ApplicationInterface(node.clone())) + .await? + .is_none() + { + let desktop = self + .socket_proxy + .embed(&(self.unique_name().as_str(), ObjectId::Root.path().into())) + .await?; + let _ = self.desktop.set(desktop); + + self.conn + .object_server() + .at( + path, + RootAccessibleInterface::new( + self.unique_name().to_owned(), + node.clone(), + Arc::clone(&self.desktop), + ), + ) + .await?; + + self.conn + .object_server() + .at( + cache_path(), + CacheInterface::new( + self.unique_name().to_owned(), + node, + Arc::clone(&self.desktop), + ), + ) + .await?; + } + + Ok(()) + } + + pub(crate) async fn register_interfaces( + &self, + node: PlatformNode, + new_interfaces: InterfaceSet, + ) -> zbus::Result<()> { + let path = ObjectId::from(&node).path(); + let bus_name = self.unique_name().to_owned(); + if new_interfaces.contains(Interface::Accessible) { + self.register_interface( + &path, + NodeAccessibleInterface::new(bus_name.clone(), node.clone()), + ) + .await?; + } + if new_interfaces.contains(Interface::Action) { + self.register_interface(&path, ActionInterface::new(node.clone())) + .await?; + } + if new_interfaces.contains(Interface::Component) { + self.register_interface( + &path, + ComponentInterface::new(bus_name.clone(), node.clone()), + ) + .await?; + } + if new_interfaces.contains(Interface::Hyperlink) { + self.register_interface( + &path, + HyperlinkInterface::new(bus_name.clone(), node.clone()), + ) + .await?; + } + if new_interfaces.contains(Interface::Selection) { + self.register_interface( + &path, + SelectionInterface::new(bus_name.clone(), node.clone()), + ) + .await?; + } + if new_interfaces.contains(Interface::Text) { + self.register_interface(&path, TextInterface::new(node.clone())) + .await?; + } + if new_interfaces.contains(Interface::Value) { + self.register_interface(&path, ValueInterface::new(node.clone())) + .await?; + } + + Ok(()) + } + + async fn register_interface(&self, path: &str, interface: T) -> Result + where + T: zbus::object_server::Interface, + { + map_or_ignoring_recoverable_error( + self.conn.object_server().at(path, interface).await, + false, + |result| result.is_none(), + ) + } + + pub(crate) async fn unregister_interfaces( + &self, + adapter_id: usize, + node_id: NodeId, + old_interfaces: InterfaceSet, + ) -> zbus::Result<()> { + let path = ObjectId::Node { + adapter: adapter_id, + node: node_id, + } + .path(); + if old_interfaces.contains(Interface::Accessible) { + self.unregister_interface::(&path) + .await?; + } + if old_interfaces.contains(Interface::Action) { + self.unregister_interface::(&path).await?; + } + if old_interfaces.contains(Interface::Component) { + self.unregister_interface::(&path) + .await?; + } + if old_interfaces.contains(Interface::Hyperlink) { + self.unregister_interface::(&path) + .await?; + } + if old_interfaces.contains(Interface::Selection) { + self.unregister_interface::(&path) + .await?; + } + if old_interfaces.contains(Interface::Text) { + self.unregister_interface::(&path).await?; + } + if old_interfaces.contains(Interface::Value) { + self.unregister_interface::(&path).await?; + } + + Ok(()) + } + + async fn unregister_interface(&self, path: &str) -> Result + where + T: zbus::object_server::Interface, + { + map_or_ignoring_recoverable_error( + self.conn.object_server().remove::(path).await, + false, + |result| result, + ) + } + + pub(crate) async fn emit_object_event( + &self, + adapter_id: usize, + target: NodeIdOrRoot, + event: ObjectEvent, + ) -> Result<()> { + let target = match target { + NodeIdOrRoot::Node(node) => ObjectId::Node { + adapter: adapter_id, + node, + }, + NodeIdOrRoot::Root => ObjectId::Root, + }; + let interface = "org.a11y.atspi.Event.Object"; + let signal = match event { + ObjectEvent::ActiveDescendantChanged(_) => "ActiveDescendantChanged", + ObjectEvent::Announcement(_, _) => "Announcement", + ObjectEvent::BoundsChanged(_) => "BoundsChanged", + ObjectEvent::CaretMoved(_) => "TextCaretMoved", + ObjectEvent::ChildAdded(_, _) | ObjectEvent::ChildRemoved(_) => "ChildrenChanged", + ObjectEvent::PropertyChanged(_) => "PropertyChange", + ObjectEvent::SelectionChanged => "SelectionChanged", + ObjectEvent::StateChanged(_, _) => "StateChanged", + ObjectEvent::TextInserted { .. } | ObjectEvent::TextRemoved { .. } => "TextChanged", + ObjectEvent::TextSelectionChanged => "TextSelectionChanged", + }; + match event { + ObjectEvent::ActiveDescendantChanged(child) => { + let child = ObjectId::Node { + adapter: adapter_id, + node: child, + }; + let mut body = EventBodyBorrowed::default(); + body.any_data = child.to_address(self.unique_name().inner()).into(); + self.emit_event(target, interface, signal, body).await + } + ObjectEvent::Announcement(message, politeness) => { + let mut body = EventBodyBorrowed::default(); + body.detail1 = politeness as i32; + body.any_data = message.into(); + self.emit_event(target, interface, signal, body).await + } + ObjectEvent::BoundsChanged(bounds) => { + let mut body = EventBodyBorrowed::default(); + body.any_data = Value::from(bounds); + self.emit_event(target, interface, signal, body).await + } + ObjectEvent::CaretMoved(offset) => { + let mut body = EventBodyBorrowed::default(); + body.detail1 = offset; + self.emit_event(target, interface, signal, body).await + } + ObjectEvent::ChildAdded(index, child) => { + let child = ObjectId::Node { + adapter: adapter_id, + node: child, + }; + let mut body = EventBodyBorrowed::default(); + body.kind = "add"; + body.detail1 = index as i32; + body.any_data = child.to_address(self.unique_name().inner()).into(); + self.emit_event(target, interface, signal, body).await + } + ObjectEvent::ChildRemoved(child) => { + let child = ObjectId::Node { + adapter: adapter_id, + node: child, + }; + let mut body = EventBodyBorrowed::default(); + body.kind = "remove"; + body.detail1 = -1; + body.any_data = child.to_address(self.unique_name().inner()).into(); + self.emit_event(target, interface, signal, body).await + } + ObjectEvent::PropertyChanged(property) => { + let mut body = EventBodyBorrowed::default(); + body.kind = match property { + Property::Name(_) => "accessible-name", + Property::Description(_) => "accessible-description", + Property::Parent(_) => "accessible-parent", + Property::Role(_) => "accessible-role", + Property::Value(_) => "accessible-value", + }; + body.any_data = match property { + Property::Name(value) => Str::from(value).into(), + Property::Description(value) => Str::from(value).into(), + Property::Parent(parent) => { + let parent = match parent { + NodeIdOrRoot::Node(node) => ObjectId::Node { + adapter: adapter_id, + node, + }, + NodeIdOrRoot::Root => ObjectId::Root, + }; + parent.to_address(self.unique_name().inner()).into() + } + Property::Role(value) => Value::U32(value as u32), + Property::Value(value) => Value::F64(value), + }; + self.emit_event(target, interface, signal, body).await + } + ObjectEvent::SelectionChanged => { + self.emit_event(target, interface, signal, EventBodyBorrowed::default()) + .await + } + ObjectEvent::StateChanged(state, value) => { + let mut body = EventBodyBorrowed::default(); + body.kind = state.to_static_str(); + body.detail1 = value as i32; + self.emit_event(target, interface, signal, body).await + } + ObjectEvent::TextInserted { + start_index, + length, + content, + } => { + let mut body = EventBodyBorrowed::default(); + body.kind = "insert"; + body.detail1 = start_index; + body.detail2 = length; + body.any_data = content.into(); + self.emit_event(target, interface, signal, body).await + } + ObjectEvent::TextRemoved { + start_index, + length, + content, + } => { + let mut body = EventBodyBorrowed::default(); + body.kind = "delete"; + body.detail1 = start_index; + body.detail2 = length; + body.any_data = content.into(); + self.emit_event(target, interface, signal, body).await + } + ObjectEvent::TextSelectionChanged => { + self.emit_event(target, interface, signal, EventBodyBorrowed::default()) + .await + } + } + } + + pub(crate) async fn emit_window_event( + &self, + adapter_id: usize, + target: NodeId, + window_name: String, + event: WindowEvent, + ) -> Result<()> { + let target = ObjectId::Node { + adapter: adapter_id, + node: target, + }; + let signal = match event { + WindowEvent::Activated => "Activate", + WindowEvent::Deactivated => "Deactivate", + }; + let mut body = EventBodyBorrowed::default(); + body.any_data = window_name.into(); + self.emit_event(target, "org.a11y.atspi.Event.Window", signal, body) + .await + } + + pub(crate) async fn emit_cache_add(&self, node: PlatformNode) -> Result<()> { + let Ok(item) = cache_item_for_node(self.unique_name().inner(), &node) else { + return Ok(()); + }; + self.emit_cache_signal("AddAccessible", &item).await + } + + pub(crate) async fn emit_cache_remove(&self, adapter_id: usize, node_id: NodeId) -> Result<()> { + let reference = object_ref( + self.unique_name().inner(), + ObjectId::Node { + adapter: adapter_id, + node: node_id, + }, + ); + self.emit_cache_signal("RemoveAccessible", &reference).await + } + + async fn emit_cache_signal(&self, signal_name: &str, body: &B) -> Result<()> + where + B: serde::Serialize + zbus::wire::DynamicType, + { + map_or_ignoring_recoverable_error( + self.conn + .emit_signal( + Option::::None, + cache_path(), + InterfaceName::from_str_unchecked("org.a11y.atspi.Cache"), + MemberName::from_str_unchecked(signal_name), + body, + ) + .await, + (), + |_| (), + ) + } + + async fn emit_event( + &self, + target: ObjectId, + interface: &str, + signal_name: &str, + body: EventBodyBorrowed<'_>, + ) -> Result<()> { + map_or_ignoring_recoverable_error( + self.conn + .emit_signal( + Option::::None, + target.path(), + InterfaceName::from_str_unchecked(interface), + MemberName::from_str_unchecked(signal_name), + &body, + ) + .await, + (), + |_| (), + ) + } +} + +pub(crate) fn zbus_error_is_unrecoverable(error: &zbus::Error) -> bool { + matches!( + error, + zbus::Error::InterfaceExists(..) | zbus::Error::MissingParameter(..) + ) +} + +pub(crate) fn map_or_ignoring_recoverable_error( + result: zbus::Result, + default: U, + f: F, +) -> zbus::Result +where + F: FnOnce(T) -> U, +{ + match result { + Ok(result) => Ok(f(result)), + Err(error) if zbus_error_is_unrecoverable(&error) => Err(error), + Err(_) => Ok(default), + } +} diff --git a/patches/accesskit_unix/src/atspi/interfaces/accessible.rs b/patches/accesskit_unix/src/atspi/interfaces/accessible.rs new file mode 100644 index 0000000..ad61060 --- /dev/null +++ b/patches/accesskit_unix/src/atspi/interfaces/accessible.rs @@ -0,0 +1,246 @@ +// 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::{ + collections::HashMap, + sync::{Arc, OnceLock}, +}; + +use accesskit_atspi_common::{NodeIdOrRoot, PlatformNode, PlatformRoot}; +use atspi::{InterfaceSet, ObjectRefOwned, RelationType, Role, StateSet}; +use zbus::{fdo, interface, names::OwnedUniqueName}; + +use super::map_root_error; +use crate::atspi::{ObjectId, OwnedObjectAddress}; + +pub(crate) struct NodeAccessibleInterface { + bus_name: OwnedUniqueName, + node: PlatformNode, +} + +impl NodeAccessibleInterface { + pub fn new(bus_name: OwnedUniqueName, node: PlatformNode) -> Self { + Self { bus_name, node } + } + + fn map_error(&self) -> impl '_ + FnOnce(accesskit_atspi_common::Error) -> fdo::Error { + |error| crate::util::map_error_from_node(&self.node, error) + } +} + +#[interface(name = "org.a11y.atspi.Accessible")] +impl NodeAccessibleInterface { + #[zbus(property)] + fn name(&self) -> fdo::Result { + self.node.name().map_err(self.map_error()) + } + + #[zbus(property)] + fn description(&self) -> fdo::Result { + self.node.description().map_err(self.map_error()) + } + + #[zbus(property)] + fn parent(&self) -> fdo::Result { + self.node.parent().map_err(self.map_error()).map(|parent| { + match parent { + NodeIdOrRoot::Node(node) => ObjectId::Node { + adapter: self.node.adapter_id(), + node, + }, + NodeIdOrRoot::Root => ObjectId::Root, + } + .to_address(self.bus_name.inner()) + }) + } + + #[zbus(property)] + fn child_count(&self) -> fdo::Result { + self.node.child_count().map_err(self.map_error()) + } + + #[zbus(property)] + fn locale(&self) -> &str { + "" + } + + #[zbus(property)] + fn accessible_id(&self) -> fdo::Result { + self.node.accessible_id().map_err(self.map_error()) + } + + fn get_child_at_index(&self, index: i32) -> fdo::Result<(OwnedObjectAddress,)> { + let index = index + .try_into() + .map_err(|_| fdo::Error::InvalidArgs("Index can't be negative.".into()))?; + let child = self + .node + .child_at_index(index) + .map_err(self.map_error())? + .map(|child| ObjectId::Node { + adapter: self.node.adapter_id(), + node: child, + }); + Ok(super::optional_object_address(&self.bus_name, child)) + } + + fn get_children(&self) -> fdo::Result> { + self.node + .map_children(|child| { + ObjectId::Node { + adapter: self.node.adapter_id(), + node: child, + } + .to_address(self.bus_name.inner()) + }) + .map_err(self.map_error()) + } + + fn get_index_in_parent(&self) -> fdo::Result { + self.node.index_in_parent().map_err(self.map_error()) + } + + fn get_relation_set(&self) -> fdo::Result)>> { + self.node + .relation_set(|relation| { + ObjectId::Node { + adapter: self.node.adapter_id(), + node: relation, + } + .to_address(self.bus_name.inner()) + }) + .map(|set| { + set.into_iter() + .collect::)>>() + }) + .map_err(self.map_error()) + } + + fn get_role(&self) -> fdo::Result { + self.node.role().map_err(self.map_error()) + } + + fn get_localized_role_name(&self) -> fdo::Result { + self.node.localized_role_name().map_err(self.map_error()) + } + + fn get_state(&self) -> StateSet { + self.node.state() + } + + fn get_attributes(&self) -> fdo::Result> { + self.node.attributes().map_err(self.map_error()) + } + + fn get_application(&self) -> (OwnedObjectAddress,) { + (ObjectId::Root.to_address(self.bus_name.inner()),) + } + + fn get_interfaces(&self) -> fdo::Result { + self.node.interfaces().map_err(self.map_error()) + } +} + +pub(crate) struct RootAccessibleInterface { + bus_name: OwnedUniqueName, + root: PlatformRoot, + desktop: Arc>, +} + +impl RootAccessibleInterface { + pub fn new( + bus_name: OwnedUniqueName, + root: PlatformRoot, + desktop: Arc>, + ) -> Self { + Self { + bus_name, + root, + desktop, + } + } +} + +#[interface(name = "org.a11y.atspi.Accessible")] +impl RootAccessibleInterface { + #[zbus(property)] + fn name(&self) -> fdo::Result { + self.root.name().map_err(map_root_error) + } + + #[zbus(property)] + fn description(&self) -> fdo::Result { + self.root.description().map_err(map_root_error) + } + + #[zbus(property)] + fn parent(&self) -> OwnedObjectAddress { + self.desktop + .get() + .cloned() + .unwrap_or_default() + .into_inner() + .into() + } + + #[zbus(property)] + fn child_count(&self) -> fdo::Result { + self.root.child_count().map_err(map_root_error) + } + + #[zbus(property)] + fn locale(&self) -> &str { + "" + } + + #[zbus(property)] + fn accessible_id(&self) -> &str { + "" + } + + fn get_child_at_index(&self, index: i32) -> fdo::Result<(OwnedObjectAddress,)> { + let index = index + .try_into() + .map_err(|_| fdo::Error::InvalidArgs("Index can't be negative.".into()))?; + let child = self + .root + .child_id_at_index(index) + .map_err(map_root_error)? + .map(|(adapter, node)| ObjectId::Node { adapter, node }); + Ok(super::optional_object_address(&self.bus_name, child)) + } + + fn get_children(&self) -> fdo::Result> { + self.root + .map_child_ids(|(adapter, node)| { + ObjectId::Node { adapter, node }.to_address(self.bus_name.inner()) + }) + .map_err(map_root_error) + } + + fn get_index_in_parent(&self) -> i32 { + self.root.index_in_parent() + } + + fn get_relation_set(&self) -> Vec<(RelationType, Vec)> { + Vec::new() + } + + fn get_role(&self) -> Role { + self.root.role() + } + + fn get_state(&self) -> StateSet { + self.root.state() + } + + fn get_application(&self) -> (OwnedObjectAddress,) { + (ObjectId::Root.to_address(self.bus_name.inner()),) + } + + fn get_interfaces(&self) -> InterfaceSet { + self.root.interfaces() + } +} diff --git a/patches/accesskit_unix/src/atspi/interfaces/action.rs b/patches/accesskit_unix/src/atspi/interfaces/action.rs new file mode 100644 index 0000000..e982468 --- /dev/null +++ b/patches/accesskit_unix/src/atspi/interfaces/action.rs @@ -0,0 +1,51 @@ +// 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_atspi_common::{Action, PlatformNode}; +use zbus::{fdo, interface}; + +pub(crate) struct ActionInterface(PlatformNode); + +impl ActionInterface { + pub fn new(node: PlatformNode) -> Self { + Self(node) + } + + fn map_error(&self) -> impl '_ + FnOnce(accesskit_atspi_common::Error) -> fdo::Error { + |error| crate::util::map_error_from_node(&self.0, error) + } +} + +#[interface(name = "org.a11y.atspi.Action")] +impl ActionInterface { + #[zbus(property)] + fn n_actions(&self) -> fdo::Result { + self.0.n_actions().map_err(self.map_error()) + } + + fn get_description(&self, _index: i32) -> &str { + "" + } + + fn get_name(&self, index: i32) -> fdo::Result { + self.0.action_name(index).map_err(self.map_error()) + } + + fn get_localized_name(&self, index: i32) -> fdo::Result { + self.0.action_name(index).map_err(self.map_error()) + } + + fn get_key_binding(&self, _index: i32) -> &str { + "" + } + + fn get_actions(&self) -> fdo::Result> { + self.0.actions().map_err(self.map_error()) + } + + fn do_action(&self, index: i32) -> fdo::Result { + self.0.do_action(index).map_err(self.map_error()) + } +} diff --git a/patches/accesskit_unix/src/atspi/interfaces/application.rs b/patches/accesskit_unix/src/atspi/interfaces/application.rs new file mode 100644 index 0000000..6ad408b --- /dev/null +++ b/patches/accesskit_unix/src/atspi/interfaces/application.rs @@ -0,0 +1,39 @@ +// 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_atspi_common::PlatformRoot; +use zbus::{fdo, interface}; + +use super::map_root_error; + +pub(crate) struct ApplicationInterface(pub PlatformRoot); + +#[interface(name = "org.a11y.atspi.Application")] +impl ApplicationInterface { + #[zbus(property)] + fn toolkit_name(&self) -> fdo::Result { + self.0.toolkit_name().map_err(map_root_error) + } + + #[zbus(property)] + fn version(&self) -> fdo::Result { + self.0.toolkit_version().map_err(map_root_error) + } + + #[zbus(property)] + fn atspi_version(&self) -> &str { + "2.1" + } + + #[zbus(property)] + fn id(&self) -> fdo::Result { + self.0.id().map_err(map_root_error) + } + + #[zbus(property)] + fn set_id(&mut self, id: i32) -> fdo::Result<()> { + self.0.set_id(id).map_err(map_root_error) + } +} diff --git a/patches/accesskit_unix/src/atspi/interfaces/cache.rs b/patches/accesskit_unix/src/atspi/interfaces/cache.rs new file mode 100644 index 0000000..349eb50 --- /dev/null +++ b/patches/accesskit_unix/src/atspi/interfaces/cache.rs @@ -0,0 +1,314 @@ +// 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_atspi_common::{CacheNode, Error, NodeIdOrRoot, PlatformNode, PlatformRoot}; +use atspi::{CacheItem, ObjectRef, ObjectRefOwned}; +use std::sync::{Arc, OnceLock}; +use zbus::{ + fdo, interface, + names::{OwnedUniqueName, UniqueName}, +}; + +use super::map_root_error; +use crate::atspi::ObjectId; + +pub(crate) fn object_ref(bus_name: &UniqueName, id: ObjectId) -> ObjectRefOwned { + ObjectRef::new_owned(bus_name.to_owned(), id.path()) +} + +pub(crate) fn cache_item_for_node( + bus_name: &UniqueName, + node: &PlatformNode, +) -> Result { + Ok(cache_item(bus_name, node.cache_node()?)) +} + +fn cache_item(bus_name: &UniqueName, node: CacheNode) -> CacheItem { + let parent = match node.parent { + NodeIdOrRoot::Root => ObjectId::Root, + NodeIdOrRoot::Node(node_id) => ObjectId::Node { + adapter: node.adapter_id, + node: node_id, + }, + }; + CacheItem { + object: object_ref( + bus_name, + ObjectId::Node { + adapter: node.adapter_id, + node: node.id, + }, + ), + app: object_ref(bus_name, ObjectId::Root), + parent: object_ref(bus_name, parent), + index: node.index_in_parent, + children: node.child_count, + ifaces: node.interfaces, + short_name: node.name, + role: node.role, + name: node.description, + states: node.states, + } +} + +fn application_cache_item( + bus_name: &UniqueName, + root: &PlatformRoot, + desktop: ObjectRefOwned, +) -> Result { + Ok(CacheItem { + object: object_ref(bus_name, ObjectId::Root), + app: object_ref(bus_name, ObjectId::Root), + parent: desktop, + index: root.index_in_parent(), + children: root.child_count()?, + ifaces: root.interfaces(), + short_name: root.name()?, + role: root.role(), + name: root.description()?, + states: root.state(), + }) +} + +pub(crate) struct CacheInterface { + bus_name: OwnedUniqueName, + root: PlatformRoot, + desktop: Arc>, +} + +impl CacheInterface { + pub fn new( + bus_name: OwnedUniqueName, + root: PlatformRoot, + desktop: Arc>, + ) -> Self { + Self { + bus_name, + root, + desktop, + } + } + + fn items(&self) -> Result, Error> { + let bus_name = self.bus_name.inner(); + let descendants: Vec = self + .root + .map_descendant_cache_nodes(|node| cache_item(bus_name, node))?; + + let desktop = self.desktop.get().cloned().unwrap_or_default(); + let mut items = Vec::with_capacity(descendants.len() + 1); + items.push(application_cache_item(bus_name, &self.root, desktop)?); + items.extend(descendants); + Ok(items) + } +} + +#[interface(name = "org.a11y.atspi.Cache")] +impl CacheInterface { + fn get_items(&self) -> fdo::Result> { + self.items().map_err(map_root_error) + } +} + +#[cfg(test)] +mod tests { + use super::{CacheInterface, object_ref}; + use crate::atspi::ObjectId; + use accesskit::{ + ActionHandler, ActionRequest, Node, NodeId as LocalNodeId, Role, Tree, TreeId, TreeUpdate, + }; + use accesskit_atspi_common::{ + Adapter, AdapterCallback, AppContext, Event, NodeId, PlatformRoot, WindowBounds, + }; + use atspi::{Interface, ObjectRefOwned, Role as AtspiRole}; + use std::sync::{Arc, OnceLock}; + use zbus::names::{OwnedUniqueName, UniqueName}; + + struct NoOpActionHandler; + impl ActionHandler for NoOpActionHandler { + fn do_action(&mut self, _request: ActionRequest) {} + } + + struct NoOpCallback; + impl AdapterCallback for NoOpCallback { + fn register_interfaces(&self, _: &Adapter, _: NodeId, _: atspi::InterfaceSet) {} + fn unregister_interfaces(&self, _: &Adapter, _: NodeId, _: atspi::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 + } + + const BUS_NAME: &str = ":1.0"; + + fn root_for(update: TreeUpdate) -> (Adapter, PlatformRoot) { + let app_context = AppContext::new(None); + let adapter = Adapter::new( + &app_context, + NoOpCallback, + update, + false, + WindowBounds::default(), + NoOpActionHandler, + ); + let root = adapter.platform_root(); + (adapter, root) + } + + fn bus_name() -> OwnedUniqueName { + OwnedUniqueName::try_from(BUS_NAME).unwrap() + } + + fn cache(update: TreeUpdate) -> (Adapter, CacheInterface) { + let (adapter, root) = root_for(update); + let desktop = Arc::new(OnceLock::new()); + desktop.set(desktop_ref()).unwrap(); + (adapter, CacheInterface::new(bus_name(), root, desktop)) + } + + fn window_with_button() -> 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 root_ref() -> ObjectRefOwned { + object_ref( + &UniqueName::from_static_str_unchecked(BUS_NAME), + ObjectId::Root, + ) + } + + fn desktop_ref() -> ObjectRefOwned { + ObjectRefOwned::from_static_str_unchecked(":1.1", "/org/a11y/atspi/accessible/root") + } + + #[test] + fn get_items_prepends_application_root() { + let (_adapter, iface) = cache(window_with_button()); + let items = iface.items().unwrap(); + let [app, _window, _button] = items.as_slice() else { + panic!("expected application root, window, and button"); + }; + assert_eq!(app.object, root_ref()); + assert_eq!(app.app, root_ref()); + assert_eq!(app.parent, desktop_ref()); + assert_eq!(app.index, -1); + assert_eq!(app.children, 1); + assert_eq!(app.role, AtspiRole::Application); + assert!(app.ifaces.contains(Interface::Application)); + } + + #[test] + fn top_window_parent_is_application_root() { + let (_adapter, iface) = cache(window_with_button()); + let items = iface.items().unwrap(); + let [_app, window, _button] = items.as_slice() else { + panic!("expected application root, window, and button"); + }; + assert_eq!(window.parent, root_ref()); + assert_eq!(window.index, 0); + assert!( + window + .object + .path_as_str() + .starts_with("/org/a11y/atspi/accessible/") + ); + assert_eq!(window.object.name_as_str(), Some(BUS_NAME)); + } + + #[test] + fn filtered_child_excluded_from_items_and_counts() { + let mut hidden = Node::new(Role::Button); + hidden.set_hidden(); + let update = 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), + }; + let (_adapter, iface) = cache(update); + let items = iface.items().unwrap(); + let [app_root, window, _visible_button] = items.as_slice() else { + panic!("expected application root, window, and visible button only"); + }; + assert_eq!(app_root.children, 1); + assert_eq!(window.children, 1); + } + + #[test] + fn object_ref_encodes_bus_name_and_node_path() { + let (_adapter, root) = root_for(window_with_button()); + let (adapter_id, node_id) = root.child_id_at_index(0).unwrap().unwrap(); + let expected_path = ObjectId::Node { + adapter: adapter_id, + node: node_id, + } + .path(); + let reference = object_ref( + &UniqueName::from_static_str_unchecked(BUS_NAME), + ObjectId::Node { + adapter: adapter_id, + node: node_id, + }, + ); + assert_eq!(reference.name_as_str(), Some(BUS_NAME)); + assert_eq!(reference.path_as_str(), expected_path.as_str()); + } + + #[test] + fn multi_adapter_windows_have_distinct_indices() { + let app_context = AppContext::new(None); + let _a0 = Adapter::new( + &app_context, + NoOpCallback, + window_with_button(), + false, + WindowBounds::default(), + NoOpActionHandler, + ); + let _a1 = Adapter::new( + &app_context, + NoOpCallback, + window_with_button(), + false, + WindowBounds::default(), + NoOpActionHandler, + ); + let iface = CacheInterface::new( + bus_name(), + PlatformRoot::new(&app_context), + Arc::new(OnceLock::new()), + ); + let items = iface.items().unwrap(); + + let app_root = &items[0]; + assert_eq!(app_root.children, 2); + + let windows = items.iter().filter(|item| item.parent == root_ref()); + let mut window_indices: Vec = windows.map(|item| item.index).collect(); + window_indices.sort(); + assert_eq!(window_indices, vec![0, 1]); + } +} diff --git a/patches/accesskit_unix/src/atspi/interfaces/component.rs b/patches/accesskit_unix/src/atspi/interfaces/component.rs new file mode 100644 index 0000000..a457b52 --- /dev/null +++ b/patches/accesskit_unix/src/atspi/interfaces/component.rs @@ -0,0 +1,76 @@ +// 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_atspi_common::{PlatformNode, Rect}; +use atspi::{CoordType, Layer, ScrollType}; +use zbus::{fdo, interface, names::OwnedUniqueName}; + +use crate::atspi::{ObjectId, OwnedObjectAddress}; + +pub(crate) struct ComponentInterface { + bus_name: OwnedUniqueName, + node: PlatformNode, +} + +impl ComponentInterface { + pub fn new(bus_name: OwnedUniqueName, node: PlatformNode) -> Self { + Self { bus_name, node } + } + + fn map_error(&self) -> impl '_ + FnOnce(accesskit_atspi_common::Error) -> fdo::Error { + |error| crate::util::map_error_from_node(&self.node, error) + } +} + +#[interface(name = "org.a11y.atspi.Component")] +impl ComponentInterface { + fn contains(&self, x: i32, y: i32, coord_type: CoordType) -> fdo::Result { + self.node + .contains(x, y, coord_type) + .map_err(self.map_error()) + } + + fn get_accessible_at_point( + &self, + x: i32, + y: i32, + coord_type: CoordType, + ) -> fdo::Result<(OwnedObjectAddress,)> { + let accessible = self + .node + .accessible_at_point(x, y, coord_type) + .map_err(self.map_error())? + .map(|node| ObjectId::Node { + adapter: self.node.adapter_id(), + node, + }); + Ok(super::optional_object_address(&self.bus_name, accessible)) + } + + fn get_extents(&self, coord_type: CoordType) -> fdo::Result<(Rect,)> { + self.node + .extents(coord_type) + .map(|rect| (rect,)) + .map_err(self.map_error()) + } + + fn get_layer(&self) -> fdo::Result { + self.node.layer().map_err(self.map_error()) + } + + fn grab_focus(&self) -> fdo::Result { + self.node.grab_focus().map_err(self.map_error()) + } + + fn scroll_to(&self, scroll_type: ScrollType) -> fdo::Result { + self.node.scroll_to(scroll_type).map_err(self.map_error()) + } + + fn scroll_to_point(&self, coord_type: CoordType, x: i32, y: i32) -> fdo::Result { + self.node + .scroll_to_point(coord_type, x, y) + .map_err(self.map_error()) + } +} diff --git a/patches/accesskit_unix/src/atspi/interfaces/hyperlink.rs b/patches/accesskit_unix/src/atspi/interfaces/hyperlink.rs new file mode 100644 index 0000000..fbb12f7 --- /dev/null +++ b/patches/accesskit_unix/src/atspi/interfaces/hyperlink.rs @@ -0,0 +1,63 @@ +// 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_atspi_common::PlatformNode; +use zbus::{fdo, interface, names::OwnedUniqueName}; + +use crate::atspi::{ObjectId, OwnedObjectAddress}; + +pub(crate) struct HyperlinkInterface { + bus_name: OwnedUniqueName, + node: PlatformNode, +} + +impl HyperlinkInterface { + pub fn new(bus_name: OwnedUniqueName, node: PlatformNode) -> Self { + Self { bus_name, node } + } + + fn map_error(&self) -> impl '_ + FnOnce(accesskit_atspi_common::Error) -> fdo::Error { + |error| crate::util::map_error_from_node(&self.node, error) + } +} + +#[interface(name = "org.a11y.atspi.Hyperlink")] +impl HyperlinkInterface { + #[zbus(property)] + fn n_anchors(&self) -> fdo::Result { + self.node.n_anchors().map_err(self.map_error()) + } + + #[zbus(property)] + fn start_index(&self) -> fdo::Result { + self.node.hyperlink_start_index().map_err(self.map_error()) + } + + #[zbus(property)] + fn end_index(&self) -> fdo::Result { + self.node.hyperlink_end_index().map_err(self.map_error()) + } + + fn get_object(&self, index: i32) -> fdo::Result<(OwnedObjectAddress,)> { + let object = self + .node + .hyperlink_object(index) + .map_err(self.map_error())? + .map(|node| ObjectId::Node { + adapter: self.node.adapter_id(), + node, + }); + Ok(super::optional_object_address(&self.bus_name, object)) + } + + #[zbus(name = "GetURI")] + fn get_uri(&self, index: i32) -> fdo::Result { + self.node.uri(index).map_err(self.map_error()) + } + + fn is_valid(&self) -> fdo::Result { + self.node.hyperlink_is_valid().map_err(self.map_error()) + } +} diff --git a/patches/accesskit_unix/src/atspi/interfaces/mod.rs b/patches/accesskit_unix/src/atspi/interfaces/mod.rs new file mode 100644 index 0000000..7e33c1e --- /dev/null +++ b/patches/accesskit_unix/src/atspi/interfaces/mod.rs @@ -0,0 +1,41 @@ +// 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 accessible; +mod action; +mod application; +mod cache; +mod component; +mod hyperlink; +mod selection; +mod text; +mod value; + +use crate::atspi::{ObjectId, OwnedObjectAddress}; +use zbus::{fdo, names::UniqueName}; + +fn map_root_error(error: accesskit_atspi_common::Error) -> fdo::Error { + crate::util::map_error(ObjectId::Root, error) +} + +fn optional_object_address( + bus_name: &UniqueName, + object_id: Option, +) -> (OwnedObjectAddress,) { + match object_id { + Some(id) => (id.to_address(bus_name),), + None => (OwnedObjectAddress::null(),), + } +} + +pub(crate) use accessible::*; +pub(crate) use action::*; +pub(crate) use application::*; +pub(crate) use cache::*; +pub(crate) use component::*; +pub(crate) use hyperlink::*; +pub(crate) use selection::*; +pub(crate) use text::*; +pub(crate) use value::*; diff --git a/patches/accesskit_unix/src/atspi/interfaces/selection.rs b/patches/accesskit_unix/src/atspi/interfaces/selection.rs new file mode 100644 index 0000000..b311a90 --- /dev/null +++ b/patches/accesskit_unix/src/atspi/interfaces/selection.rs @@ -0,0 +1,82 @@ +// 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. + +use accesskit_atspi_common::PlatformNode; +use zbus::{fdo, interface, names::OwnedUniqueName}; + +use crate::atspi::{ObjectId, OwnedObjectAddress}; + +pub(crate) struct SelectionInterface { + bus_name: OwnedUniqueName, + node: PlatformNode, +} + +impl SelectionInterface { + pub fn new(bus_name: OwnedUniqueName, node: PlatformNode) -> Self { + Self { bus_name, node } + } + + fn map_error(&self) -> impl '_ + FnOnce(accesskit_atspi_common::Error) -> fdo::Error { + |error| crate::util::map_error_from_node(&self.node, error) + } +} + +#[interface(name = "org.a11y.atspi.Selection")] +impl SelectionInterface { + #[zbus(property)] + fn n_selected_children(&self) -> fdo::Result { + self.node.n_selected_children().map_err(self.map_error()) + } + + fn get_selected_child(&self, selected_child_index: i32) -> fdo::Result<(OwnedObjectAddress,)> { + let child = self + .node + .selected_child(map_child_index(selected_child_index)?) + .map_err(self.map_error())? + .map(|child| ObjectId::Node { + adapter: self.node.adapter_id(), + node: child, + }); + Ok(super::optional_object_address(&self.bus_name, child)) + } + + fn select_child(&self, child_index: i32) -> fdo::Result { + self.node + .select_child(map_child_index(child_index)?) + .map_err(self.map_error()) + } + + fn deselect_selected_child(&self, selected_child_index: i32) -> fdo::Result { + self.node + .deselect_selected_child(map_child_index(selected_child_index)?) + .map_err(self.map_error()) + } + + fn is_child_selected(&self, child_index: i32) -> fdo::Result { + self.node + .is_child_selected(map_child_index(child_index)?) + .map_err(self.map_error()) + } + + fn select_all(&self) -> fdo::Result { + self.node.select_all().map_err(self.map_error()) + } + + fn clear_selection(&self) -> fdo::Result { + self.node.clear_selection().map_err(self.map_error()) + } + + fn deselect_child(&self, child_index: i32) -> fdo::Result { + self.node + .deselect_child(map_child_index(child_index)?) + .map_err(self.map_error()) + } +} + +fn map_child_index(index: i32) -> fdo::Result { + index + .try_into() + .map_err(|_| fdo::Error::InvalidArgs("Index can't be negative.".into())) +} diff --git a/patches/accesskit_unix/src/atspi/interfaces/text.rs b/patches/accesskit_unix/src/atspi/interfaces/text.rs new file mode 100644 index 0000000..c861cbd --- /dev/null +++ b/patches/accesskit_unix/src/atspi/interfaces/text.rs @@ -0,0 +1,163 @@ +// 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. + +use accesskit_atspi_common::{PlatformNode, Rect}; +use atspi::{CoordType, Granularity, ScrollType}; +use std::collections::HashMap; +use zbus::{fdo, interface}; + +pub(crate) struct TextInterface { + node: PlatformNode, +} + +impl TextInterface { + pub fn new(node: PlatformNode) -> Self { + Self { node } + } + + fn map_error(&self) -> impl '_ + FnOnce(accesskit_atspi_common::Error) -> fdo::Error { + |error| crate::util::map_error_from_node(&self.node, error) + } +} + +#[interface(name = "org.a11y.atspi.Text")] +impl TextInterface { + #[zbus(property)] + fn character_count(&self) -> fdo::Result { + self.node.character_count().map_err(self.map_error()) + } + + #[zbus(property)] + fn caret_offset(&self) -> fdo::Result { + self.node.caret_offset().map_err(self.map_error()) + } + + fn get_string_at_offset( + &self, + offset: i32, + granularity: Granularity, + ) -> fdo::Result<(String, i32, i32)> { + self.node + .string_at_offset(offset, granularity) + .map_err(self.map_error()) + } + + fn get_text(&self, start_offset: i32, end_offset: i32) -> fdo::Result { + self.node + .text(start_offset, end_offset) + .map_err(self.map_error()) + } + + fn set_caret_offset(&self, offset: i32) -> fdo::Result { + self.node.set_caret_offset(offset).map_err(self.map_error()) + } + + fn get_attribute_value(&self, offset: i32, attribute_name: &str) -> fdo::Result { + self.node + .text_attribute_value(offset, attribute_name) + .map_err(self.map_error()) + } + + fn get_attributes( + &self, + offset: i32, + ) -> fdo::Result<(HashMap<&'static str, String>, i32, i32)> { + self.node.text_attributes(offset).map_err(self.map_error()) + } + + fn get_default_attributes(&self) -> fdo::Result> { + self.node + .default_text_attributes() + .map_err(self.map_error()) + } + + fn get_character_extents(&self, offset: i32, coord_type: CoordType) -> fdo::Result { + self.node + .character_extents(offset, coord_type) + .map_err(self.map_error()) + } + + fn get_offset_at_point(&self, x: i32, y: i32, coord_type: CoordType) -> fdo::Result { + self.node + .offset_at_point(x, y, coord_type) + .map_err(self.map_error()) + } + + fn get_n_selections(&self) -> fdo::Result { + self.node.n_selections().map_err(self.map_error()) + } + + fn get_selection(&self, selection_num: i32) -> fdo::Result<(i32, i32)> { + self.node.selection(selection_num).map_err(self.map_error()) + } + + fn add_selection(&self, start_offset: i32, end_offset: i32) -> fdo::Result { + self.node + .add_selection(start_offset, end_offset) + .map_err(self.map_error()) + } + + fn remove_selection(&self, selection_num: i32) -> fdo::Result { + self.node + .remove_selection(selection_num) + .map_err(self.map_error()) + } + + fn set_selection( + &self, + selection_num: i32, + start_offset: i32, + end_offset: i32, + ) -> fdo::Result { + self.node + .set_selection(selection_num, start_offset, end_offset) + .map_err(self.map_error()) + } + + fn get_range_extents( + &self, + start_offset: i32, + end_offset: i32, + coord_type: CoordType, + ) -> fdo::Result { + self.node + .range_extents(start_offset, end_offset, coord_type) + .map_err(self.map_error()) + } + + fn get_attribute_run( + &self, + offset: i32, + include_defaults: bool, + ) -> fdo::Result<(HashMap<&'static str, String>, i32, i32)> { + self.node + .text_attribute_run(offset, include_defaults) + .map_err(self.map_error()) + } + + fn scroll_substring_to( + &self, + start_offset: i32, + end_offset: i32, + scroll_type: ScrollType, + ) -> fdo::Result { + self.node + .scroll_substring_to(start_offset, end_offset, scroll_type) + .map_err(self.map_error()) + } + + fn scroll_substring_to_point( + &self, + start_offset: i32, + end_offset: i32, + coord_type: CoordType, + x: i32, + y: i32, + ) -> fdo::Result { + self.node + .scroll_substring_to_point(start_offset, end_offset, coord_type, x, y) + .map_err(self.map_error()) + } +} diff --git a/patches/accesskit_unix/src/atspi/interfaces/value.rs b/patches/accesskit_unix/src/atspi/interfaces/value.rs new file mode 100644 index 0000000..e410acd --- /dev/null +++ b/patches/accesskit_unix/src/atspi/interfaces/value.rs @@ -0,0 +1,49 @@ +// 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_atspi_common::PlatformNode; +use zbus::{fdo, interface}; + +pub(crate) struct ValueInterface { + node: PlatformNode, +} + +impl ValueInterface { + pub fn new(node: PlatformNode) -> Self { + Self { node } + } + + fn map_error(&self) -> impl '_ + FnOnce(accesskit_atspi_common::Error) -> fdo::Error { + |error| crate::util::map_error_from_node(&self.node, error) + } +} + +#[interface(name = "org.a11y.atspi.Value")] +impl ValueInterface { + #[zbus(property)] + fn minimum_value(&self) -> fdo::Result { + self.node.minimum_value().map_err(self.map_error()) + } + + #[zbus(property)] + fn maximum_value(&self) -> fdo::Result { + self.node.maximum_value().map_err(self.map_error()) + } + + #[zbus(property)] + fn minimum_increment(&self) -> fdo::Result { + self.node.minimum_increment().map_err(self.map_error()) + } + + #[zbus(property)] + fn current_value(&self) -> fdo::Result { + self.node.current_value().map_err(self.map_error()) + } + + #[zbus(property)] + fn set_current_value(&mut self, value: f64) -> fdo::Result<()> { + self.node.set_current_value(value).map_err(self.map_error()) + } +} diff --git a/patches/accesskit_unix/src/atspi/mod.rs b/patches/accesskit_unix/src/atspi/mod.rs new file mode 100644 index 0000000..799e9f3 --- /dev/null +++ b/patches/accesskit_unix/src/atspi/mod.rs @@ -0,0 +1,13 @@ +// 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 bus; +pub(crate) mod interfaces; +mod object_address; +mod object_id; + +pub(crate) use bus::*; +pub(crate) use object_address::OwnedObjectAddress; +pub(crate) use object_id::{ObjectId, cache_path}; diff --git a/patches/accesskit_unix/src/atspi/object_address.rs b/patches/accesskit_unix/src/atspi/object_address.rs new file mode 100644 index 0000000..1fae5cb --- /dev/null +++ b/patches/accesskit_unix/src/atspi/object_address.rs @@ -0,0 +1,45 @@ +// 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 atspi::ObjectRef; +use serde::{Deserialize, Serialize}; +use zbus::{ + names::UniqueName, + wire::{ObjectPath, OwnedObjectPath, OwnedVariant as OwnedValue, Type, Variant as Value}, +}; + +// https://gnome.pages.gitlab.gnome.org/at-spi2-core/libatspi/const.DBUS_PATH_NULL.html +const NULL_PATH: &str = "/org/a11y/atspi/null"; + +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, OwnedValue, Type, Value)] +pub(crate) struct OwnedObjectAddress { + bus_name: String, + path: OwnedObjectPath, +} + +impl OwnedObjectAddress { + pub(crate) fn new(bus_name: &UniqueName, path: OwnedObjectPath) -> Self { + Self { + bus_name: bus_name.to_string(), + path, + } + } + + pub(crate) fn null() -> Self { + Self { + bus_name: String::new(), + path: ObjectPath::from_str_unchecked(NULL_PATH).into(), + } + } +} + +impl<'a> From> for OwnedObjectAddress { + fn from(object: ObjectRef<'a>) -> Self { + Self { + bus_name: object.name().map(|s| s.to_string()).unwrap_or_default(), + path: object.path().to_owned().into(), + } + } +} diff --git a/patches/accesskit_unix/src/atspi/object_id.rs b/patches/accesskit_unix/src/atspi/object_id.rs new file mode 100644 index 0000000..c7f4be9 --- /dev/null +++ b/patches/accesskit_unix/src/atspi/object_id.rs @@ -0,0 +1,79 @@ +// 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 crate::atspi::OwnedObjectAddress; +use accesskit_atspi_common::{NodeId, PlatformNode}; +use serde::{Serialize, Serializer}; +use zbus::{ + names::UniqueName, + wire::{ObjectPath, OwnedObjectPath, Signature, Structure, Type}, +}; + +const ACCESSIBLE_PATH_PREFIX: &str = "/org/a11y/atspi/accessible/"; +const ROOT_PATH: &str = "/org/a11y/atspi/accessible/root"; +const CACHE_PATH: &str = "/org/a11y/atspi/cache"; + +pub(crate) fn cache_path() -> OwnedObjectPath { + ObjectPath::from_str_unchecked(CACHE_PATH).into() +} + +#[derive(Debug, PartialEq)] +pub(crate) enum ObjectId { + Root, + Node { adapter: usize, node: NodeId }, +} + +impl ObjectId { + pub(crate) fn to_address(&self, bus_name: &UniqueName) -> OwnedObjectAddress { + OwnedObjectAddress::new(bus_name, self.path()) + } + + pub(crate) fn path(&self) -> OwnedObjectPath { + match self { + Self::Root => ObjectPath::from_str_unchecked(ROOT_PATH), + Self::Node { adapter, node } => ObjectPath::from_string_unchecked(format!( + "{}{}/{}", + ACCESSIBLE_PATH_PREFIX, + adapter, + u128::from(*node) + )), + } + .into() + } +} + +impl Serialize for ObjectId { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::Root => serializer.serialize_str("root"), + Self::Node { node, .. } => serializer.serialize_str(&u128::from(*node).to_string()), + } + } +} + +impl Type for ObjectId { + const SIGNATURE: &'static Signature = <&str>::SIGNATURE; +} + +impl From for Structure<'_> { + fn from(id: ObjectId) -> Self { + Self::from((match id { + ObjectId::Root => "root".into(), + ObjectId::Node { node, .. } => u128::from(node).to_string(), + },)) + } +} + +impl From<&PlatformNode> for ObjectId { + fn from(node: &PlatformNode) -> Self { + Self::Node { + adapter: node.adapter_id(), + node: node.id(), + } + } +} diff --git a/patches/accesskit_unix/src/context.rs b/patches/accesskit_unix/src/context.rs new file mode 100644 index 0000000..dae38dd --- /dev/null +++ b/patches/accesskit_unix/src/context.rs @@ -0,0 +1,283 @@ +// 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::{ActivationHandler, DeactivationHandler}; +use accesskit_atspi_common::{Adapter as AdapterImpl, AppContext, Event}; +#[cfg(not(feature = "tokio"))] +use async_channel::{Receiver, Sender}; +use atspi::proxy::bus::StatusProxy; +#[cfg(not(feature = "tokio"))] +use futures_util::{StreamExt, pin_mut as pin, select}; +use std::{ + sync::{Arc, Mutex, OnceLock, RwLock}, + thread, +}; +#[cfg(feature = "tokio")] +use tokio::{ + pin, select, + sync::mpsc::{UnboundedReceiver as Receiver, UnboundedSender as Sender}, +}; +#[cfg(feature = "tokio")] +use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream}; +use zbus::{Connection, connection::Builder, proxy::PropertyChanged}; + +use crate::{ + adapter::{AdapterState, Callback, Message}, + atspi::{Bus, map_or_ignoring_recoverable_error, zbus_error_is_unrecoverable}, + util::block_on, +}; + +static APP_CONTEXT: OnceLock>> = OnceLock::new(); +static MESSAGES: OnceLock> = OnceLock::new(); + +fn app_name() -> Option { + std::env::current_exe().ok().and_then(|path| { + path.file_name() + .map(|name| name.to_string_lossy().to_string()) + }) +} + +pub(crate) fn get_or_init_app_context<'a>() -> &'a Arc> { + APP_CONTEXT.get_or_init(|| AppContext::new(app_name())) +} + +pub(crate) fn get_or_init_messages() -> Sender { + MESSAGES + .get_or_init(|| { + #[cfg(not(feature = "tokio"))] + let (tx, rx) = async_channel::unbounded(); + #[cfg(feature = "tokio")] + let (tx, rx) = tokio::sync::mpsc::unbounded_channel(); + + thread::spawn(|| { + // zbus 6's default runtime drives its connection tasks itself. + // Only this AccessKit event loop remains on our dedicated thread. + block_on(async { + if let Ok(session_bus) = Builder::session().build().await { + if let Err(error) = run_event_loop(session_bus, rx).await { + if zbus_error_is_unrecoverable(&error) { + panic!("Accessibility event loop failed: {error}"); + } + } + } + }) + }); + + tx + }) + .clone() +} + +struct AdapterEntry { + id: usize, + activation_handler: Box, + deactivation_handler: Box, + state: Arc>, +} + +fn activate_adapter(entry: &mut AdapterEntry) { + let mut state = entry.state.lock().unwrap(); + if let AdapterState::Inactive { + is_window_focused, + root_window_bounds, + action_handler, + } = &*state + { + *state = match entry.activation_handler.request_initial_tree() { + Some(initial_state) => { + let r#impl = AdapterImpl::with_wrapped_action_handler( + entry.id, + get_or_init_app_context(), + Callback::new(), + initial_state, + *is_window_focused, + *root_window_bounds, + Arc::clone(action_handler), + ); + AdapterState::Active(r#impl) + } + None => AdapterState::Pending { + is_window_focused: *is_window_focused, + root_window_bounds: *root_window_bounds, + action_handler: Arc::clone(action_handler), + }, + }; + } +} + +fn deactivate_adapter(entry: &mut AdapterEntry) { + let mut state = entry.state.lock().unwrap(); + match &*state { + AdapterState::Inactive { .. } => (), + AdapterState::Pending { + is_window_focused, + root_window_bounds, + action_handler, + } => { + *state = AdapterState::Inactive { + is_window_focused: *is_window_focused, + root_window_bounds: *root_window_bounds, + action_handler: Arc::clone(action_handler), + }; + drop(state); + entry.deactivation_handler.deactivate_accessibility(); + } + AdapterState::Active(r#impl) => { + *state = AdapterState::Inactive { + is_window_focused: r#impl.is_window_focused(), + root_window_bounds: r#impl.root_window_bounds(), + action_handler: r#impl.wrapped_action_handler(), + }; + drop(state); + entry.deactivation_handler.deactivate_accessibility(); + } + } +} + +async fn bus_after_status_change( + change: Option>, + session_bus: &Connection, +) -> zbus::Result> { + let enabled = match change { + Some(change) => change.get().await?, + None => false, + }; + if enabled { + map_or_ignoring_recoverable_error(Bus::new(session_bus).await, None, Some) + } else { + Ok(None) + } +} + +fn sync_adapters(adapters: &mut [AdapterEntry], atspi_bus: &Option) { + let active = atspi_bus.is_some(); + for entry in adapters { + if active { + activate_adapter(entry); + } else { + deactivate_adapter(entry); + } + } +} + +async fn run_event_loop( + session_bus: Connection, + rx: Receiver, +) -> zbus::Result<()> { + let status = StatusProxy::new(&session_bus).await?; + let changes = status.receive_is_enabled_changed().await.fuse(); + pin!(changes); + + #[cfg(not(feature = "tokio"))] + let messages = rx.fuse(); + #[cfg(feature = "tokio")] + let messages = UnboundedReceiverStream::new(rx).fuse(); + pin!(messages); + + let mut atspi_bus = None; + let mut adapters: Vec = Vec::new(); + + loop { + select! { + change = changes.next() => { + atspi_bus = bus_after_status_change(change, &session_bus).await?; + sync_adapters(&mut adapters, &atspi_bus); + + } + message = messages.next() => { + if let Some(message) = message { + process_adapter_message(&atspi_bus, &mut adapters, message).await?; + } + } + } + } +} + +async fn process_adapter_message( + atspi_bus: &Option, + adapters: &mut Vec, + message: Message, +) -> zbus::Result<()> { + match message { + Message::AddAdapter { + id, + activation_handler, + deactivation_handler, + state, + } => { + adapters.push(AdapterEntry { + id, + activation_handler, + deactivation_handler, + state, + }); + if atspi_bus.is_some() { + let entry = adapters.last_mut().unwrap(); + activate_adapter(entry); + } + } + Message::RemoveAdapter { id } => { + if let Ok(index) = adapters.binary_search_by(|entry| entry.id.cmp(&id)) { + adapters.remove(index); + } + } + Message::RegisterInterfaces { node, interfaces } => { + if let Some(bus) = atspi_bus { + bus.register_interfaces(node, interfaces).await? + } + } + Message::UnregisterInterfaces { + adapter_id, + node_id, + interfaces, + } => { + if let Some(bus) = atspi_bus { + bus.unregister_interfaces(adapter_id, node_id, interfaces) + .await? + } + } + Message::EmitEvent { + adapter_id, + event: Event::Object { target, event }, + } => { + if let Some(bus) = atspi_bus { + bus.emit_object_event(adapter_id, target, event).await? + } + } + Message::EmitEvent { + adapter_id, + event: + Event::Window { + target, + name, + event, + }, + } => { + if let Some(bus) = atspi_bus { + bus.emit_window_event(adapter_id, target, name, event) + .await?; + } + } + Message::EmitEvent { + event: Event::Cache(_), + .. + } => unreachable!("cache events are sent as EmitCacheAdd/EmitCacheRemove"), + Message::EmitCacheAdd { node } => { + if let Some(bus) = atspi_bus { + bus.emit_cache_add(node).await?; + } + } + Message::EmitCacheRemove { + adapter_id, + node_id, + } => { + if let Some(bus) = atspi_bus { + bus.emit_cache_remove(adapter_id, node_id).await?; + } + } + } + + Ok(()) +} diff --git a/patches/accesskit_unix/src/executor.rs b/patches/accesskit_unix/src/executor.rs new file mode 100644 index 0000000..f227af4 --- /dev/null +++ b/patches/accesskit_unix/src/executor.rs @@ -0,0 +1,158 @@ +// 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. + +// Derived from zbus. +// Copyright 2024 Zeeshan Ali Khan. +// Licensed under the MIT license (found in the LICENSE-MIT file). + +#[cfg(not(feature = "tokio"))] +use async_executor::Executor as AsyncExecutor; +#[cfg(not(feature = "tokio"))] +use async_task::Task as AsyncTask; +#[cfg(feature = "tokio")] +use std::marker::PhantomData; +#[cfg(not(feature = "tokio"))] +use std::sync::Arc; +use std::{ + future::Future, + pin::Pin, + task::{Context, Poll}, +}; +#[cfg(feature = "tokio")] +use tokio::task::JoinHandle; + +/// A wrapper around the underlying runtime/executor. +/// +/// This is used to run asynchronous tasks internally and allows integration with various runtimes. +/// See [`crate::Connection::executor`] for an example of integration with external runtimes. +/// +/// **Note:** You can (and should) completely ignore this type when building with `tokio` feature +/// enabled. +#[cfg(not(feature = "tokio"))] +#[derive(Debug, Clone)] +pub(crate) struct Executor<'a> { + executor: Arc>, +} +#[cfg(feature = "tokio")] +#[derive(Debug, Clone)] +pub(crate) struct Executor<'a> { + phantom: PhantomData<&'a ()>, +} + +impl Executor<'_> { + /// Spawns a task onto the executor. + pub(crate) fn spawn( + &self, + future: impl Future + Send + 'static, + #[allow(unused)] name: &str, + ) -> Task { + #[cfg(not(feature = "tokio"))] + { + Task(Some(self.executor.spawn(future))) + } + + #[cfg(feature = "tokio")] + { + Task(Some(tokio::task::spawn(future))) + } + } + + /// Create a new `Executor`. + pub(crate) fn new() -> Self { + #[cfg(not(feature = "tokio"))] + { + Self { + executor: Arc::new(AsyncExecutor::new()), + } + } + + #[cfg(feature = "tokio")] + { + Self { + phantom: PhantomData, + } + } + } + + /// Runs the executor until the given future completes. + /// + /// With `tokio` feature enabled, it just awaits on the `future`. + pub(crate) async fn run(&self, future: impl Future) -> T { + #[cfg(not(feature = "tokio"))] + { + self.executor.run(future).await + } + #[cfg(feature = "tokio")] + { + future.await + } + } +} + +/// A wrapper around the task API of the underlying runtime/executor. +/// +/// This follows the semantics of `async_task::Task` on drop: +/// +/// * it will be cancelled, rather than detached. For detaching, use the `detach` method. +/// * errors from the task cancellation will will be ignored. If you need to know about task errors, +/// convert the task to a `FallibleTask` using the `fallible` method. +#[cfg(not(feature = "tokio"))] +#[derive(Debug)] +pub(crate) struct Task(Option>); +#[cfg(feature = "tokio")] +#[derive(Debug)] +pub(crate) struct Task(Option>); + +impl Task { + /// Detaches the task to let it keep running in the background. + #[allow(unused_mut)] + #[allow(unused)] + pub(crate) fn detach(mut self) { + #[cfg(not(feature = "tokio"))] + { + self.0.take().expect("async_task::Task is none").detach() + } + + #[cfg(feature = "tokio")] + { + self.0.take().expect("tokio::task::JoinHandle is none"); + } + } +} + +impl Drop for Task { + fn drop(&mut self) { + #[cfg(feature = "tokio")] + { + if let Some(join_handle) = self.0.take() { + join_handle.abort(); + } + } + } +} + +impl Future for Task { + type Output = T; + + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + #[cfg(not(feature = "tokio"))] + { + Pin::new(&mut self.get_mut().0.as_mut().expect("async_task::Task is none")).poll(cx) + } + + #[cfg(feature = "tokio")] + { + Pin::new( + &mut self + .get_mut() + .0 + .as_mut() + .expect("tokio::task::JoinHandle is none"), + ) + .poll(cx) + .map(|r| r.expect("tokio::task::JoinHandle error")) + } + } +} diff --git a/patches/accesskit_unix/src/lib.rs b/patches/accesskit_unix/src/lib.rs new file mode 100644 index 0000000..a747558 --- /dev/null +++ b/patches/accesskit_unix/src/lib.rs @@ -0,0 +1,26 @@ +// 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. + +/// ## Compatibility with async runtimes +/// +/// While this crate's API is purely blocking, it internally spawns asynchronous tasks on an executor. +/// +/// - If you use tokio, make sure to enable the `tokio` feature of this crate. +/// - If you use another async runtime or if you don't use one at all, the default feature will suit your needs. + +#[cfg(all(not(feature = "async-io"), not(feature = "tokio")))] +compile_error!("Either \"async-io\" (default) or \"tokio\" feature must be enabled."); + +#[cfg(all(feature = "async-io", feature = "tokio"))] +compile_error!( + "Both \"async-io\" (default) and \"tokio\" features cannot be enabled at the same time." +); + +mod adapter; +mod atspi; +mod context; +mod util; + +pub use adapter::Adapter; diff --git a/patches/accesskit_unix/src/util.rs b/patches/accesskit_unix/src/util.rs new file mode 100644 index 0000000..1507302 --- /dev/null +++ b/patches/accesskit_unix/src/util.rs @@ -0,0 +1,42 @@ +// 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_atspi_common::{Error as InternalError, PlatformNode}; +use zbus::fdo::Error as FdoError; + +use crate::atspi::ObjectId; + +#[cfg(not(feature = "tokio"))] +pub(crate) fn block_on(future: F) -> F::Output { + futures_lite::future::block_on(future) +} + +#[cfg(feature = "tokio")] +pub(crate) fn block_on(future: F) -> F::Output { + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_io() + .enable_time() + .build() + .expect("launch of single-threaded tokio runtime"); + runtime.block_on(future) +} + +pub(crate) fn map_error(source: ObjectId, error: InternalError) -> FdoError { + match error { + InternalError::Defunct | InternalError::UnsupportedInterface => { + FdoError::UnknownObject(source.path().to_string()) + } + InternalError::TooManyChildren => FdoError::Failed("Too many children.".into()), + InternalError::IndexOutOfRange => FdoError::Failed("Index is too big.".into()), + InternalError::TooManyCharacters => FdoError::Failed("Too many characters.".into()), + InternalError::UnsupportedTextGranularity => { + FdoError::Failed("Unsupported text granularity.".into()) + } + } +} + +pub(crate) fn map_error_from_node(source: &PlatformNode, error: InternalError) -> FdoError { + map_error(ObjectId::from(source), error) +} diff --git a/patches/atspi-common/Cargo.toml b/patches/atspi-common/Cargo.toml new file mode 100644 index 0000000..7d15545 --- /dev/null +++ b/patches/atspi-common/Cargo.toml @@ -0,0 +1,110 @@ +# 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 = "2021" +rust-version = "1.77.2" +name = "atspi-common" +version = "0.13.0" +build = false +include = [ + "LICENSE-*", + "README.md", + "src/**/*", + "xml/*", +] +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "Primitive types used for sending and receiving Linux accessibility events." +readme = "README.md" +keywords = [ + "Accessibility", + "Macros", +] +categories = [ + "accessibility", + "api-bindings", +] +license = "Apache-2.0 OR MIT" +repository = "https://github.com/odilia-app/atspi" + +[features] +default = [ + "wrappers", + "zbus", +] +wrappers = [] +zbus = [] + +[lib] +name = "atspi_common" +path = "src/lib.rs" + +[dependencies.enumflags2] +version = "0.7.9" + +[dependencies.serde] +version = "1.0.200" + +[dependencies.static_assertions] +version = "1.1.0" + +[dependencies.zbus] +version = "6.1" +features = ["default-rt", "proxy", "service", "object-manager"] +default-features = false + +[dependencies.zbus-lockstep] +version = "0.5.1" + +[dependencies.zbus-lockstep-macros] +version = "0.5.1" + + + +[dev-dependencies.assert_matches] +version = "1.5.0" + +[dev-dependencies.rename-item] +version = "0.1.0" + +[dev-dependencies.serde_plain] +version = "1.0.1" + +[dev-dependencies.static_assertions] +version = "1.1.0" + +[dev-dependencies.tokio] +version = "1.38.2" +features = [ + "macros", + "rt-multi-thread", +] +default-features = false + +[dev-dependencies.tokio-stream] +version = "0.1.1" +features = ["time"] +default-features = false + +[dev-dependencies.tokio-test] +version = "0.4.2" + +[dev-dependencies.zbus] +version = "6.1" +features = ["default-rt", "proxy", "service", "object-manager"] +default-features = false + +[dev-dependencies.zbus_xml] +version = "6" diff --git a/patches/atspi-common/LICENSE-APACHE2.txt b/patches/atspi-common/LICENSE-APACHE2.txt new file mode 100644 index 0000000..b09cd78 --- /dev/null +++ b/patches/atspi-common/LICENSE-APACHE2.txt @@ -0,0 +1,201 @@ +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 + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/patches/atspi-common/LICENSE-MIT.txt b/patches/atspi-common/LICENSE-MIT.txt new file mode 100644 index 0000000..95c4383 --- /dev/null +++ b/patches/atspi-common/LICENSE-MIT.txt @@ -0,0 +1,19 @@ +Copyright (c) 2022 Tait Hoyem + +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. diff --git a/patches/atspi-common/README.md b/patches/atspi-common/README.md new file mode 100644 index 0000000..04a3c7c --- /dev/null +++ b/patches/atspi-common/README.md @@ -0,0 +1,13 @@ +# `atspi-common` + +Common data structures for the `atspi` crate. +This crate is meant to only contain the absolute lowest common denominator for libraries to talk to each other about `atspi` information; +therefore, it attempts to be able to compile on basically any architecture (including WASM). + +Please use the internal documentation to learn how to use these data structures. + +## Feature Flags + +- `default`: `zbus`, `wrappers` +- `zbus`: include support for serializing/deserializing from `zbus::Message`s over DBus. +- `wrappers`: container enum types that group events by AT-SPI interface, as well as `Event` wrapper that contains any possible event. diff --git a/patches/atspi-common/VNOX-PATCH.md b/patches/atspi-common/VNOX-PATCH.md new file mode 100644 index 0000000..8b63437 --- /dev/null +++ b/patches/atspi-common/VNOX-PATCH.md @@ -0,0 +1,9 @@ +# Vnox maintenance patch: atspi-common 0.13.0 + +Source: published crates.io atspi-common 0.13.0, 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. diff --git a/patches/atspi-common/src/action.rs b/patches/atspi-common/src/action.rs new file mode 100644 index 0000000..4c99096 --- /dev/null +++ b/patches/atspi-common/src/action.rs @@ -0,0 +1,28 @@ +use serde::{Deserialize, Serialize}; +use zbus::wire::Type; + +/// An action which may be triggered through the accessibility API. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] +pub struct Action { + /// The name of the action + pub name: String, + /// Description of the action + pub description: String, + // TODO: should be an enum/stricter type; this is why it's in its own file. + /// The keybinding(s) used to trigger it (without the AT). + pub keybinding: String, +} + +#[cfg(test)] +mod test { + use super::Action; + use zbus_lockstep::method_return_signature; + use zbus::wire::Type; + #[test] + fn validate_action_signature() { + // signature is of type `a(sss)`, where `(sss)` is the type we're validating. + let action_signature = + method_return_signature!(member: "GetActions", interface: "org.a11y.atspi.Action"); + assert_eq!(Vec::::SIGNATURE, &action_signature); + } +} diff --git a/patches/atspi-common/src/cache.rs b/patches/atspi-common/src/cache.rs new file mode 100644 index 0000000..9a2f02f --- /dev/null +++ b/patches/atspi-common/src/cache.rs @@ -0,0 +1,122 @@ +//! Common types for `org.a11y.atspi.Cache` events. +//! + +use crate::{object_ref::ObjectRefOwned, InterfaceSet, ObjectRef, Role, StateSet}; +use serde::{Deserialize, Serialize}; +use zbus_lockstep_macros::validate; +use zbus::wire::Type; + +/// The item type provided by `Cache:Add` signals +#[allow(clippy::module_name_repetitions)] +#[derive(Clone, Debug, Serialize, Deserialize, Type, PartialEq, Eq, Hash)] +#[validate(signal: "AddAccessible")] +pub struct CacheItem { + /// The accessible object (within the application) (so) + pub object: ObjectRefOwned, + /// The application (root object(?) (so) + pub app: ObjectRefOwned, + /// The parent object. (so) + pub parent: ObjectRefOwned, + /// The accessbile index in parent. i + pub index: i32, + /// Child count of the accessible i + pub children: i32, + /// The exposed interface(s) set. as + pub ifaces: InterfaceSet, + /// The short localized name. s + pub short_name: String, + /// `ObjectRef` role. u + pub role: Role, + /// More detailed localized name. + pub name: String, + /// The states applicable to the accessible. au + pub states: StateSet, +} + +impl Default for CacheItem { + fn default() -> Self { + Self { + object: ObjectRefOwned::from_static_str_unchecked( + ":0.0", + "/org/a11y/atspi/accessible/object", + ), + app: ObjectRefOwned::from_static_str_unchecked( + ":0.0", + "/org/a11y/atspi/accessible/application", + ), + parent: ObjectRefOwned::from_static_str_unchecked( + ":0.0", + "/org/a11y/atspi/accessible/parent", + ), + index: 0, + children: 0, + ifaces: InterfaceSet::empty(), + short_name: String::default(), + role: Role::Invalid, + name: String::default(), + states: StateSet::empty(), + } + } +} + +/// The item type provided by `Cache:Add` signals +#[allow(clippy::module_name_repetitions)] +#[derive(Clone, Debug, Serialize, Deserialize, Type, PartialEq, Eq, Hash)] +pub struct LegacyCacheItem { + /// The accessible object (within the application) (so) + pub object: ObjectRefOwned, + /// The application (root object(?) (so) + pub app: ObjectRefOwned, + /// The parent object. (so) + pub parent: ObjectRefOwned, + /// List of references to the accessible's children. a(so) + pub children: Vec, + /// The exposed interface(s) set. as + pub ifaces: InterfaceSet, + /// The short localized name. s + pub short_name: String, + /// `ObjectRef` role. u + pub role: Role, + /// More detailed localized name. + pub name: String, + /// The states applicable to the accessible. au + pub states: StateSet, +} + +impl Default for LegacyCacheItem { + fn default() -> Self { + Self { + object: ObjectRef::from_static_str_unchecked( + ":0.0", + "/org/a11y/atspi/accessible/object", + ) + .into(), + app: ObjectRef::from_static_str_unchecked( + ":0.0", + "/org/a11y/atspi/accessible/application", + ) + .into(), + parent: ObjectRef::from_static_str_unchecked( + ":0.0", + "/org/a11y/atspi/accessible/parent", + ) + .into(), + children: Vec::new(), + ifaces: InterfaceSet::empty(), + short_name: String::default(), + role: Role::Invalid, + name: String::default(), + states: StateSet::empty(), + } + } +} + +#[cfg(test)] +#[test] +fn zvariant_type_signature_of_legacy_cache_item() { + use std::str::FromStr; + assert_eq!( + *::SIGNATURE, + zbus::wire::Signature::from_str("((so)(so)(so)a(so)assusau)").unwrap() + ); +} diff --git a/patches/atspi-common/src/error.rs b/patches/atspi-common/src/error.rs new file mode 100644 index 0000000..966a396 --- /dev/null +++ b/patches/atspi-common/src/error.rs @@ -0,0 +1,210 @@ +#[allow(clippy::module_name_repetitions)] +#[derive(Debug)] +#[non_exhaustive] +/// An error type that can describe atspi and `std` and different `zbus` errors. +pub enum AtspiError { + /// Converting one type into another failure + Conversion(&'static str), + + /// When testing on either variant, we might find the we are not interested in. + CacheVariantMismatch, + + /// On specific types, if the event / message member does not match the Event's name. + MemberMatch(String), + + /// On specific types, if the event / message member does not match the Event's name. + InterfaceMatch(String), + + /// On specific types, if the kind (string variant) does not match the Event's kind. + KindMatch(String), + + /// When an interface is not available. + InterfaceNotAvailable(&'static str), + + /// To indicate a match or equality test on a signal body signature failed. + SignatureMatch(String), + + /// When matching on an unknown interface + UnknownInterface, + + /// No interface on event. + MissingInterface, + + /// No member on event. + MissingMember, + + /// No path on event. + MissingPath, + + /// When matching on an unknown role + UnknownRole(u32), + + /// No name on bus. + MissingName, + + /// The signal that was encountered is unknown. + UnknownSignal, + + /// Other errors. + Owned(String), + + /// Null-reference error. This is used when an `ObjectRef` is expected to be non-null, but it is null. + NullRef(&'static str), + + /// A `zbus` or `zbus::Fdo` error. variant. + Zbus(String), + + /// A `zbus_names` error variant + ZBusNames(zbus::Error), + + /// A `zbus_names` error variant + Zvariant(zbus::Error), + + /// Failed to parse a string into an enum variant + ParseError(&'static str), + + /// Failed to get the ID of a path. + PathConversionError(ObjectPathConversionError), + + /// Std i/o error variant. + IO(std::io::Error), + + /// Failed to convert an integer into another type of integer (usually i32 -> usize). + IntConversionError(std::num::TryFromIntError), + + /// An infallible error; this is just something to satisfy the compiler. + Infallible, +} + +impl std::error::Error for AtspiError {} + +impl std::fmt::Display for AtspiError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Conversion(e) => f.write_str(&format!("atspi: conversion failure: {e}")), + Self::MemberMatch(e) => { + f.write_str("atspi: member mismatch in conversion: ")?; + e.fmt(f) + } + Self::InterfaceMatch(e) => { + f.write_str("atspi: interface mismatch in conversion: ")?; + e.fmt(f) + } + Self::KindMatch(e) => { + f.write_str(format!("atspi: kind mismatch in conversion: {e}").as_str()) + } + Self::SignatureMatch(e) => { + f.write_str(format!("atspi: body signature mismatch in conversion: {e:?}").as_str()) + } + Self::InterfaceNotAvailable(e) => { + f.write_str(format!("atspi: interface not available: {e}").as_str()) + } + Self::UnknownInterface => f.write_str("Unknown interface."), + Self::MissingInterface => f.write_str("Missing interface."), + Self::MissingMember => f.write_str("Missing member."), + Self::MissingPath => f.write_str("Missing path."), + Self::UnknownRole(e) => { + f.write_str("atspi: Unknown role: ")?; + e.fmt(f) + } + Self::UnknownSignal => f.write_str("atspi: Unknown signal"), + Self::CacheVariantMismatch => f.write_str("atspi: Cache variant mismatch"), + Self::Owned(e) => { + f.write_str("atspi: other error: ")?; + e.fmt(f) + } + Self::NullRef(e) => { + f.write_str("atspi: null reference: ")?; + f.write_str(e) + } + Self::Zbus(e) => { + f.write_str("ZBus Error: ")?; + e.fmt(f) + } + Self::Zvariant(e) => { + f.write_str("Zvariant error: ")?; + e.fmt(f) + } + Self::ZBusNames(e) => { + f.write_str("ZBus_names Error: ")?; + e.fmt(f) + } + Self::ParseError(e) => f.write_str(e), + Self::PathConversionError(e) => { + f.write_str("ID cannot be extracted from the path: ")?; + e.fmt(f) + } + Self::IO(e) => { + f.write_str("std IO Error: ")?; + e.fmt(f) + } + Self::IntConversionError(e) => { + f.write_str("Integer conversion error: ")?; + e.fmt(f) + } + Self::MissingName => f.write_str("Missing name for a bus."), + Self::Infallible => { + f.write_str("Infallible; only to trick the compiler. This should never happen.") + } + } + } +} + +impl From for AtspiError { + fn from(_e: std::convert::Infallible) -> Self { + Self::Infallible + } +} +impl From for AtspiError { + fn from(e: std::num::TryFromIntError) -> Self { + Self::IntConversionError(e) + } +} + +#[cfg(feature = "zbus")] +impl From for AtspiError { + fn from(e: zbus::fdo::Error) -> Self { + Self::Zbus(format!("{e:?}")) + } +} + +impl From for AtspiError { + fn from(e: zbus::Error) -> Self { + Self::Zbus(format!("{e:?}")) + } +} + + + + + +impl From for AtspiError { + fn from(e: std::io::Error) -> Self { + Self::IO(e) + } +} + +impl From for AtspiError { + fn from(e: ObjectPathConversionError) -> AtspiError { + Self::PathConversionError(e) + } +} + +#[allow(clippy::module_name_repetitions)] +#[derive(Clone, Debug)] +pub enum ObjectPathConversionError { + NoIdAvailable, + ParseError(::Err), +} +impl std::fmt::Display for ObjectPathConversionError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::NoIdAvailable => f.write_str("No ID available in the path."), + Self::ParseError(e) => { + f.write_str("Failure to parse: ")?; + e.fmt(f) + } + } + } +} +impl std::error::Error for ObjectPathConversionError {} diff --git a/patches/atspi-common/src/events/cache.rs b/patches/atspi-common/src/events/cache.rs new file mode 100644 index 0000000..d1d975e --- /dev/null +++ b/patches/atspi-common/src/events/cache.rs @@ -0,0 +1,168 @@ +use crate::cache::{CacheItem, LegacyCacheItem}; +#[cfg(feature = "zbus")] +use crate::error::AtspiError; +#[cfg(feature = "zbus")] +use crate::object_ref::ObjectRef; +#[cfg(feature = "zbus")] +use crate::EventProperties; +use crate::{ + events::{DBusInterface, DBusMatchRule, DBusMember, RegistryEventString}, + object_ref::ObjectRefOwned, +}; +use serde::{Deserialize, Serialize}; +#[cfg(feature = "zbus")] +use zbus::message::{Body as DbusBody, Header}; + +#[cfg(feature = "zbus")] +use super::{MessageConversion, MessageConversionExt}; + +/// Type that contains the `zbus::Message` for meta information and +/// the [`crate::cache::LegacyCacheItem`] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default, Eq, Hash)] +pub struct LegacyAddAccessibleEvent { + /// The [`ObjectRef`] the event applies to. + pub item: ObjectRefOwned, + /// A cache item to add to the internal cache. + pub node_added: LegacyCacheItem, +} + +impl_event_type_properties_for_event!(LegacyAddAccessibleEvent); + +event_test_cases!(LegacyAddAccessibleEvent, Explicit); +impl_from_dbus_message!(LegacyAddAccessibleEvent, Explicit); +impl_event_properties!(LegacyAddAccessibleEvent); +impl_to_dbus_message!(LegacyAddAccessibleEvent); + +impl_member_interface_registry_string_and_match_rule_for_event!( + LegacyAddAccessibleEvent, + "AddAccessible", + "org.a11y.atspi.Cache", + "cache:add", + "type='signal',interface='org.a11y.atspi.Cache',member='AddAccessible'" +); + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for LegacyAddAccessibleEvent { + type Body<'msg> = LegacyCacheItem; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + Ok(Self { item: item.into(), node_added: body.deserialize_ignore_signature::>()? }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + self.node_added.clone() + } +} + +/// Type that contains the `zbus::Message` for meta information and +/// the [`crate::cache::CacheItem`] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default, Eq, Hash)] +pub struct AddAccessibleEvent { + /// The [`ObjectRef`] the event applies to. + pub item: ObjectRefOwned, + /// A cache item to add to the internal cache. + pub node_added: CacheItem, +} + +impl_event_type_properties_for_event!(AddAccessibleEvent); + +event_test_cases!(AddAccessibleEvent, Explicit); + +impl_member_interface_registry_string_and_match_rule_for_event!( + AddAccessibleEvent, + "AddAccessible", + "org.a11y.atspi.Cache", + "cache:add", + "type='signal',interface='org.a11y.atspi.Cache',member='AddAccessible'" +); + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for AddAccessibleEvent { + type Body<'msg> = CacheItem; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + Ok(Self { item: item.into(), node_added: body.deserialize_ignore_signature::>()? }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + self.node_added.clone() + } +} + +impl_msg_conversion_ext_for_target_type_with_specified_body_type!(target: AddAccessibleEvent, body: CacheItem); +impl_from_dbus_message!(AddAccessibleEvent, Explicit); +impl_event_properties!(AddAccessibleEvent); +impl_to_dbus_message!(AddAccessibleEvent); + +/// `Cache::RemoveAccessible` signal event type. +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default, Eq, Hash)] +pub struct RemoveAccessibleEvent { + /// The application that emitted the signal TODO Check Me + /// The [`ObjectRef`] the event applies to. + pub item: ObjectRefOwned, + /// The node that was removed from the application tree TODO Check Me + pub node_removed: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(RemoveAccessibleEvent); + +event_test_cases!(RemoveAccessibleEvent, Explicit); + +impl_member_interface_registry_string_and_match_rule_for_event!( + RemoveAccessibleEvent, + "RemoveAccessible", + "org.a11y.atspi.Cache", + "cache:remove", + "type='signal',interface='org.a11y.atspi.Cache',member='RemoveAccessible'" +); + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for RemoveAccessibleEvent { + type Body<'msg> = ObjectRefOwned; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + Ok(Self { + item: item.into(), + node_removed: body.deserialize_ignore_signature::>()?, + }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + self.node_removed.clone() + } +} + +#[cfg(feature = "zbus")] +impl MessageConversionExt<'_, LegacyCacheItem> for LegacyAddAccessibleEvent { + fn try_from_message(msg: &zbus::Message, hdr: &Header) -> Result { + >::validate_interface(hdr)?; + >::validate_member(hdr)?; + >::validate_body( + msg, + )?; + ::from_message_unchecked(msg, hdr) + } +} + +impl_msg_conversion_ext_for_target_type_with_specified_body_type!(target: RemoveAccessibleEvent, body: ObjectRefOwned); +impl_from_dbus_message!(RemoveAccessibleEvent, Explicit); +impl_event_properties!(RemoveAccessibleEvent); +impl_to_dbus_message!(RemoveAccessibleEvent); diff --git a/patches/atspi-common/src/events/document.rs b/patches/atspi-common/src/events/document.rs new file mode 100644 index 0000000..fb59b15 --- /dev/null +++ b/patches/atspi-common/src/events/document.rs @@ -0,0 +1,166 @@ +use crate::events::{DBusInterface, DBusMatchRule, DBusMember, RegistryEventString}; +use crate::object_ref::ObjectRefOwned; +#[cfg(feature = "zbus")] +use crate::EventProperties; + +#[cfg(feature = "zbus")] +use crate::AtspiError; +#[cfg(feature = "zbus")] +use zbus::message::Header; + +/// An event triggered by the completion of a document load action. +/// For example: a web page has finished loading its initial payload, or +/// `LibreOffice` has loaded a document from disk. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct LoadCompleteEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +/// An event triggered by a reloading of a document. +/// For example: pressing F5, or `Control + r` will reload a page in a web browser. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct ReloadEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +/// An event triggered by the cancelling of a document load. +/// For example: during the loading of a large web page, a user may press `Escape` to stop loading the page. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct LoadStoppedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct ContentChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct AttributesChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +/// The focused page has changed. +/// +/// This event is usually sent only by document readers, signaling +/// that the _physical page equivalent is now different. +/// This event does not encode _which_ page is the new one, only that a new page is now the primary +/// one. +/// +/// See `atspi_proxies::document::DocumentProxy::current_page_number` to actively find the +/// page number. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct PageChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_member_interface_registry_string_and_match_rule_for_event!( + LoadCompleteEvent, + "LoadComplete", + "org.a11y.atspi.Event.Document", + "document:load-complete", + "type='signal',interface='org.a11y.atspi.Event.Document',member='LoadComplete'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + ReloadEvent, + "Reload", + "org.a11y.atspi.Event.Document", + "document:reload", + "type='signal',interface='org.a11y.atspi.Event.Document',member='LoadStopped'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + LoadStoppedEvent, + "LoadStopped", + "org.a11y.atspi.Event.Document", + "document:load-stopped", + "type='signal',interface='org.a11y.atspi.Event.Document',member='LoadStopped'" +); + +// TODO confirm registry event string, not found in grep at at-spi2-core +impl_member_interface_registry_string_and_match_rule_for_event!( + ContentChangedEvent, + "ContentChanged", + "org.a11y.atspi.Event.Document", + "document:content-changed", + "type='signal',interface='org.a11y.atspi.Event.Document',member='ContentChanged'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + AttributesChangedEvent, + "AttributesChanged", + "org.a11y.atspi.Event.Document", + "document:attributes-changed", + "type='signal',interface='org.a11y.atspi.Event.Document',member='AttributesChanged'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + PageChangedEvent, + "PageChanged", + "org.a11y.atspi.Event.Document", + "document:page-changed", + "type='signal',interface='org.a11y.atspi.Event.Document',member='PageChanged'" +); + +impl_event_type_properties_for_event!(LoadCompleteEvent); + +event_test_cases!(LoadCompleteEvent); +impl_to_dbus_message!(LoadCompleteEvent); +impl_from_dbus_message!(LoadCompleteEvent); +impl_event_properties!(LoadCompleteEvent); +impl_from_object_ref!(LoadCompleteEvent); + +impl_event_type_properties_for_event!(ReloadEvent); +event_test_cases!(ReloadEvent); +impl_to_dbus_message!(ReloadEvent); +impl_from_dbus_message!(ReloadEvent); +impl_event_properties!(ReloadEvent); +impl_from_object_ref!(ReloadEvent); + +impl_event_type_properties_for_event!(LoadStoppedEvent); +event_test_cases!(LoadStoppedEvent); +impl_to_dbus_message!(LoadStoppedEvent); +impl_from_dbus_message!(LoadStoppedEvent); +impl_event_properties!(LoadStoppedEvent); +impl_from_object_ref!(LoadStoppedEvent); + +impl_event_type_properties_for_event!(ContentChangedEvent); +event_test_cases!(ContentChangedEvent); +impl_to_dbus_message!(ContentChangedEvent); +impl_from_dbus_message!(ContentChangedEvent); +impl_event_properties!(ContentChangedEvent); +impl_from_object_ref!(ContentChangedEvent); + +impl_event_type_properties_for_event!(AttributesChangedEvent); +event_test_cases!(AttributesChangedEvent); +impl_to_dbus_message!(AttributesChangedEvent); +impl_from_dbus_message!(AttributesChangedEvent); +impl_event_properties!(AttributesChangedEvent); +impl_from_object_ref!(AttributesChangedEvent); + +impl_event_type_properties_for_event!(PageChangedEvent); +event_test_cases!(PageChangedEvent); +impl_to_dbus_message!(PageChangedEvent); +impl_from_dbus_message!(PageChangedEvent); +impl_event_properties!(PageChangedEvent); +impl_from_object_ref!(PageChangedEvent); +impl_msg_conversion_ext_for_target_type!(LoadCompleteEvent); +impl_msg_conversion_ext_for_target_type!(ReloadEvent); +impl_msg_conversion_ext_for_target_type!(LoadStoppedEvent); +impl_msg_conversion_ext_for_target_type!(ContentChangedEvent); +impl_msg_conversion_ext_for_target_type!(AttributesChangedEvent); +impl_msg_conversion_ext_for_target_type!(PageChangedEvent); + +impl_msg_conversion_for_types_built_from_object_ref!(LoadCompleteEvent); +impl_msg_conversion_for_types_built_from_object_ref!(ReloadEvent); +impl_msg_conversion_for_types_built_from_object_ref!(LoadStoppedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(ContentChangedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(AttributesChangedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(PageChangedEvent); diff --git a/patches/atspi-common/src/events/event_body.rs b/patches/atspi-common/src/events/event_body.rs new file mode 100644 index 0000000..4bac8a5 --- /dev/null +++ b/patches/atspi-common/src/events/event_body.rs @@ -0,0 +1,1078 @@ +use crate::AtspiError; +use serde::{ + ser::{SerializeMap, SerializeTuple}, + Deserialize, Serialize, +}; +use zbus_lockstep_macros::validate; +use zbus::wire::{ObjectPath, OwnedVariant as OwnedValue, Type, Variant as Value}; + +/// Event body as used exclusively by 'Qt' toolkit. +/// +/// Signature: "siiv(so)" +#[derive(Debug, Serialize, Deserialize, PartialEq, Type)] +pub struct EventBodyQtOwned { + /// kind variant, used for specifying an event triple "object:state-changed:focused", + /// the "focus" part of this event is what is contained within the kind. + #[serde(rename = "type")] + pub kind: String, + + /// Generic detail1 value described by AT-SPI. + pub detail1: i32, + + /// Generic detail2 value described by AT-SPI. + pub detail2: i32, + + /// Generic `any_data` value described by AT-SPI. + /// This can be any type. + pub any_data: OwnedValue, + + /// Not in use. + /// See: [`QtProperties`]. + #[serde(skip_deserializing)] + pub(crate) properties: QtProperties, +} + +impl Clone for EventBodyQtOwned { + /// # Safety + /// + /// This implementation of [`Clone`] *can panic!* although chances are slim. + /// + /// If the following conditions are met: + /// 1. the `any_data` field contains an [`std::os::fd::OwnedFd`] type, and + /// 2. the maximum number of open files for the process is exceeded. + /// + /// Then this function panic. + /// None of the types in [`crate::events`] use [`std::os::fd::OwnedFd`]. + /// Events on the AT-SPI bus *could, theoretically* send a file descriptor, but nothing in the current + /// specification describes that. + /// See [`zbus::wire::Variant::try_clone`] for more information. + fn clone(&self) -> Self { + let cloned_any_data = self.any_data.try_clone().unwrap_or_else(|err| { + panic!("Failure cloning 'any_data' field: {err:?}"); + }); + + Self { + kind: self.kind.clone(), + detail1: self.detail1, + detail2: self.detail2, + any_data: cloned_any_data, + properties: QtProperties, + } + } +} + +/// Unit struct placeholder for `EventBodyQtOwned.properties` +/// +/// AT-SPI2 never reads or writes to `EventBodyQT.properties`. +/// `QtProperties` has the appropriate implementations for `Serialize` and `Deserialize` +/// to make it serialize as an a valid tuple and valid bytes deserialize as placeholder. +#[derive(Debug, Copy, Clone, Deserialize, Type, Default, PartialEq)] +#[zvariant(signature = "(so)")] +pub(crate) struct QtProperties; + +impl Serialize for QtProperties { + fn serialize(&self, serializer: S) -> Result + where + S: serde::ser::Serializer, + { + let mut tup = serializer.serialize_tuple(2)?; + tup.serialize_element(":0.0")?; + tup.serialize_element(&ObjectPath::from_static_str_unchecked("/"))?; + tup.end() + } +} + +impl Default for EventBodyQtOwned { + fn default() -> Self { + Self { + kind: String::new(), + detail1: 0, + detail2: 0, + any_data: 0_u32.into(), + properties: QtProperties, + } + } +} + +/// Unit struct placeholder for `EventBody.properties` +/// +/// AT-SPI2 never reads or writes to `EventBody.properties`. +/// `Properties` has the appropriate implementations for `Serialize` and `Deserialize` +/// to make it serialize as an a valid dictionary and valid bytes deserialize as placeholder. +#[derive(Debug, Copy, Clone, Type, Default, Deserialize, PartialEq)] +#[zvariant(signature = "a{sv}")] +pub(crate) struct Properties; + +impl Serialize for Properties { + fn serialize(&self, serializer: S) -> Result + where + S: serde::ser::Serializer, + { + serializer.serialize_map(Some(0))?.end() + } +} + +/// AT-SPI2 protocol native event body type. +/// +/// All of the various signals in the AT-SPI2 protocol share this shape. +/// Most toolkits and implementors emit this type, except for `Qt`, which has has its +/// own type: [`EventBodyQtOwned`]. +/// +/// Signature `(siiva{sv})`, +#[validate(signal: "PropertyChange")] +#[derive(Debug, Serialize, Deserialize, PartialEq, Type)] +pub struct EventBodyOwned { + /// kind variant, used for specifying an event triple "object:state-changed:focused", + /// the "focus" part of this event is what is contained within the kind. + #[serde(rename = "type")] + pub kind: String, + + /// Generic detail1 value described by AT-SPI. + pub detail1: i32, + + /// Generic detail2 value described by AT-SPI. + pub detail2: i32, + + /// Generic `any_data` value described by AT-SPI. + /// This can be any type. + /// + pub any_data: OwnedValue, + + /// Not in use. + /// See: [`Properties`]. + pub(crate) properties: Properties, +} + +impl Default for EventBodyOwned { + fn default() -> Self { + Self { + kind: String::new(), + detail1: 0, + detail2: 0, + any_data: 0_u32.into(), + properties: Properties, + } + } +} + +impl Clone for EventBodyOwned { + /// # Safety + /// + /// This implementation of [`Clone`] *can panic!* although chances are slim. + /// + /// If the following conditions are met: + /// 1. the `any_data` field contains an [`std::os::fd::OwnedFd`] type, and + /// 2. the maximum number of open files for the process is exceeded. + /// + /// Then this function panic. + /// None of the types in [`crate::events`] use [`std::os::fd::OwnedFd`]. + /// Events on the AT-SPI bus *could, theoretically* send a file descriptor, but nothing in the current + /// specification describes that. + /// See [`zbus::wire::Variant::try_clone`] for more information. + fn clone(&self) -> Self { + let cloned_any_data = self.any_data.try_clone().unwrap_or_else(|err| { + panic!("Failure cloning 'any_data' field: {err:?}"); + }); + + Self { + kind: self.kind.clone(), + detail1: self.detail1, + detail2: self.detail2, + any_data: cloned_any_data, + properties: Properties, + } + } +} + +#[derive(Debug, Serialize, Deserialize, PartialEq, Type)] +pub struct EventBodyBorrowed<'a> { + /// kind variant, used for specifying an event triple "object:state-changed:focused", + /// the "focus" part of this event is what is contained within the kind. + #[serde(rename = "type")] + #[serde(borrow)] + pub kind: &'a str, + + /// Generic detail1 value described by AT-SPI. + pub detail1: i32, + + /// Generic detail2 value described by AT-SPI. + pub detail2: i32, + + /// Generic `any_data` value described by AT-SPI. + /// This can be any type. + #[serde(borrow)] + pub any_data: Value<'a>, + + /// Not in use. + /// See: [`Properties`]. + #[serde(skip_deserializing)] + pub(crate) properties: Properties, +} + +impl Default for EventBodyBorrowed<'_> { + fn default() -> Self { + Self { + kind: "", + detail1: 0, + detail2: 0, + any_data: Value::new(0_u32), + properties: Properties, + } + } +} + +impl EventBodyBorrowed<'_> { + /// Convert this borrowed event body to an owned event body. + /// + /// # Errors + /// + /// This will error if the following conditions are met: + /// 1. the `any_data` field contains an [`std::os::fd::OwnedFd`] type, and + /// 2. the maximum number of open files for the process is exceeded. + /// + /// Chances are slim because none of the types in [`crate::events`] use [`std::os::fd::OwnedFd`]. + /// See [`zbus::wire::Variant::try_clone`] for more information. + pub fn to_fully_owned(&self) -> Result { + let owned_any_data = self.any_data.try_to_owned()?; + + Ok(EventBodyOwned { + kind: self.kind.into(), + detail1: self.detail1, + detail2: self.detail2, + any_data: owned_any_data, + properties: Properties, + }) + } +} + +impl Clone for EventBodyBorrowed<'_> { + /// # Safety + /// + /// This implementation of [`Clone`] *can panic!* although chances are slim. + /// + /// If the following conditions are met: + /// 1. the `any_data` field contains an [`std::os::fd::OwnedFd`] type, and + /// 2. the maximum number of open files for the process is exceeded. + /// + /// Then this function panic. + /// None of the types in [`crate::events`] use [`std::os::fd::OwnedFd`]. + /// Events on the AT-SPI bus *could, theoretically* send a file descriptor, but nothing in the current + /// specification describes that. + /// See [`zbus::wire::Variant::try_clone`] for more information. + fn clone(&self) -> Self { + let cloned_any_data = self.any_data.try_clone().unwrap_or_else(|err| { + panic!("Failure cloning 'any_data' field: {err:?}"); + }); + + Self { + kind: self.kind, + detail1: self.detail1, + detail2: self.detail2, + any_data: cloned_any_data, + properties: Properties, + } + } +} + +#[derive(Debug, Type, Deserialize, PartialEq)] +pub struct EventBodyQtBorrowed<'m> { + /// kind variant, used for specifying an event triple "object:state-changed:focused", + /// the "focus" part of this event is what is contained within the kind. + #[serde(rename = "type")] + pub kind: &'m str, + + /// Generic detail1 value described by AT-SPI. + pub detail1: i32, + + /// Generic detail2 value described by AT-SPI. + pub detail2: i32, + + /// Generic `any_data` value described by AT-SPI. + /// This can be any type. + #[serde(borrow)] + pub any_data: Value<'m>, + + /// Not in use. + /// See: [`QtProperties`]. + #[serde(skip_deserializing)] + pub(crate) properties: QtProperties, +} + +impl Default for EventBodyQtBorrowed<'_> { + fn default() -> Self { + Self { + kind: "", + detail1: 0, + detail2: 0, + any_data: Value::new(0_u32), + properties: QtProperties, + } + } +} + +impl Clone for EventBodyQtBorrowed<'_> { + /// # Safety + /// + /// This implementation of [`Clone`] *can panic!* although chances are slim. + /// + /// If the following conditions are met: + /// 1. the `any_data` field contains an [`std::os::fd::OwnedFd`] type, and + /// 2. the maximum number of open files for the process is exceeded. + /// + /// Then this function panics. + /// None of the types in [`crate::events`] use [`std::os::fd::OwnedFd`]. + /// Events on the AT-SPI bus *could, theoretically* send a file descriptor, but nothing in the current + /// specification describes that. + /// See [`zbus::wire::Variant::try_clone`] for more information. + fn clone(&self) -> Self { + let cloned_any_data = self.any_data.try_clone().unwrap_or_else(|err| { + panic!("Failure cloning 'any_data' field: {err:?}"); + }); + + Self { + kind: self.kind, + detail1: self.detail1, + detail2: self.detail2, + any_data: cloned_any_data, + properties: QtProperties, + } + } +} + +impl EventBodyQtBorrowed<'_> { + /// Convert partially borrowed Qt event body to an owned event body. + /// + /// # Errors + /// + /// This will error if the following conditions are met: + /// 1. the `any_data` field contains an [`std::os::fd::OwnedFd`] type, and + /// 2. the maximum number of open files for the process is exceeded. + pub fn try_to_owned(&self) -> Result { + let any_data = self.any_data.try_to_owned()?; + + Ok(EventBodyQtOwned { + kind: self.kind.to_owned(), + detail1: self.detail1, + detail2: self.detail2, + any_data, + properties: self.properties, + }) + } +} + +impl<'de> From> for EventBodyBorrowed<'de> { + fn from(borrow: EventBodyQtBorrowed<'de>) -> Self { + let EventBodyQtBorrowed { kind, detail1, detail2, any_data, properties: _ } = borrow; + + Self { kind, detail1, detail2, any_data, properties: Properties } + } +} + +impl From for EventBodyOwned { + fn from(body: EventBodyQtOwned) -> Self { + Self { + kind: body.kind, + detail1: body.detail1, + detail2: body.detail2, + any_data: body.any_data, + properties: Properties, + } + } +} + +/// Common event body that can be either owned or borrowed. +/// +/// This is useful for APIs that can return either owned or borrowed event bodies. +/// Having this type allows to be generic over the event body type. +#[derive(Debug, Clone, PartialEq)] +pub enum EventBody<'a> { + Owned(EventBodyOwned), + Borrowed(EventBodyBorrowed<'a>), +} + +impl Default for EventBody<'_> { + fn default() -> Self { + Self::Borrowed(EventBodyBorrowed::default()) + } +} + +impl<'a> EventBody<'_> { + /// Non-consuming conversion to an owned event body. + /// + /// Does cloning. + /// + /// # Errors + /// The borrowed variant will error if the following conditions are met: + /// 1. the `any_data` field contains an [`std::os::fd::OwnedFd`] type, and + /// 2. the maximum number of open files for the process is exceeded. + pub fn as_owned(&self) -> Result { + match self { + Self::Owned(owned) => Ok(owned.clone()), + Self::Borrowed(borrowed) => borrowed.to_fully_owned(), + } + } + + /// Consuming conversion to an owned event body. + /// + /// Does cloning. + /// + /// # Errors + /// The borrowed variant will error if the following conditions are met: + /// 1. the `any_data` field contains an [`std::os::fd::OwnedFd`] type, and + /// 2. the maximum number of open files for the process is exceeded. + pub fn into_owned(self) -> Result { + match self { + Self::Owned(owned) => Ok(owned), + Self::Borrowed(borrowed) => borrowed.to_fully_owned(), + } + } + + /// The `kind` field as `&str`. + /// + /// With both variants, this method returns a reference to the `kind` field. + #[must_use] + pub fn kind(&'a self) -> &'a str { + match self { + Self::Owned(owned) => owned.kind.as_str(), + Self::Borrowed(borrowed) => borrowed.kind, + } + } + + /// Take or convert the `kind` field as `String`. + /// + /// With the owned variant, this method takes the `kind` field and replaces it with an empty string. + /// With the borrowed variant, this method clones and allocates the `kind` field. + pub fn take_kind(&mut self) -> String { + match self { + Self::Owned(owned) => std::mem::take(&mut owned.kind), + Self::Borrowed(borrowed) => borrowed.kind.to_owned(), + } + } + + /// The `detail1` field. + #[must_use] + pub fn detail1(&self) -> i32 { + match self { + Self::Owned(owned) => owned.detail1, + Self::Borrowed(borrowed) => borrowed.detail1, + } + } + + /// The `detail2` field. + #[must_use] + pub fn detail2(&self) -> i32 { + match self { + Self::Owned(owned) => owned.detail2, + Self::Borrowed(borrowed) => borrowed.detail2, + } + } + + /// The `any_data` field as `&Value`. + /// With both variants, this method returns a reference to the `any_data` field. + #[must_use] + pub fn any_data(&'a self) -> &'a Value<'a> { + match self { + Self::Owned(owned) => &owned.any_data, + Self::Borrowed(borrowed) => &borrowed.any_data, + } + } + + /// Take or convert the `any_data` field as `OwnedValue`. + /// With the owned variant, this method takes the `any_data` field and replaces it with a default value. + /// As `Value` does not have a default value, we will replace with `0_u32`, a nbon-allocating value. + /// + /// With the borrowed variant, this method clones and allocates the `any_data` field. + /// + /// # Panics + /// This method will panic if the `any_data` field contains an [`std::os::fd::OwnedFd`] type, and + /// the maximum number of open files for the process is exceeded. + /// + /// None of the types in [`crate::events`] use [`std::os::fd::OwnedFd`]. + /// Events on the AT-SPI bus *could, theoretically* send a file descriptor, but nothing in the current + /// specification describes that. + pub fn take_any_data(&mut self) -> OwnedValue { + match self { + Self::Owned(owned) => std::mem::replace(&mut owned.any_data, 0_u32.into()), + Self::Borrowed(borrowed) => borrowed.any_data.try_to_owned().expect("cloning 'any_data' field should not fail because we do not expect it to hold an fd"), + } + } +} + +impl Type for EventBody<'_> { + const SIGNATURE: &'static zbus::wire::Signature = EventBodyOwned::SIGNATURE; +} + +impl<'de> Deserialize<'de> for EventBody<'de> { + fn deserialize(deserializer: D) -> Result, D::Error> + where + D: serde::de::Deserializer<'de>, + { + let borrowed = EventBodyBorrowed::deserialize(deserializer)?; + Ok(borrowed.into()) + } +} + +impl Serialize for EventBody<'_> { + fn serialize(&self, serializer: S) -> Result + where + S: serde::ser::Serializer, + { + match self { + EventBody::Owned(owned) => owned.serialize(serializer), + EventBody::Borrowed(borrowed) => borrowed.serialize(serializer), + } + } +} + +impl From for EventBody<'_> { + fn from(owned: EventBodyOwned) -> Self { + EventBody::Owned(owned) + } +} + +impl<'b> From> for EventBody<'b> { + fn from(borrowed: EventBodyBorrowed<'b>) -> Self { + EventBody::Borrowed(borrowed) + } +} + +impl From for EventBody<'_> { + fn from(qt_owned: EventBodyQtOwned) -> Self { + EventBody::Owned(qt_owned.into()) + } +} + +impl<'a> From> for EventBody<'a> { + fn from(qt_borrowed: EventBodyQtBorrowed<'a>) -> Self { + EventBody::Borrowed(qt_borrowed.into()) + } +} + +impl From for EventBodyQtOwned { + fn from(owned: EventBodyOwned) -> Self { + Self { + kind: owned.kind, + detail1: owned.detail1, + detail2: owned.detail2, + any_data: owned.any_data, + properties: QtProperties, + } + } +} + +impl<'a> From> for EventBodyQtOwned { + fn from(borrowed: EventBodyBorrowed<'a>) -> Self { + Self { + kind: borrowed.kind.to_owned(), + detail1: borrowed.detail1, + detail2: borrowed.detail2, + any_data: borrowed + .any_data + .try_to_owned() + .expect("converting borrowed to owned should not fail"), + properties: QtProperties, + } + } +} + +impl From> for EventBodyQtOwned { + fn from(event: EventBody) -> Self { + match event { + EventBody::Owned(owned) => owned.into(), + EventBody::Borrowed(borrowed) => borrowed.into(), + } + } +} + +impl PartialEq for EventBodyQtOwned { + fn eq(&self, other: &EventBodyOwned) -> bool { + self.kind == other.kind + && self.detail1 == other.detail1 + && self.detail2 == other.detail2 + && self.any_data == other.any_data + } +} + +impl PartialEq for EventBodyOwned { + fn eq(&self, other: &EventBodyQtOwned) -> bool { + self.kind == other.kind + && self.detail1 == other.detail1 + && self.detail2 == other.detail2 + && self.any_data == other.any_data + } +} + +impl PartialEq> for EventBodyQtBorrowed<'_> { + fn eq(&self, other: &EventBodyBorrowed<'_>) -> bool { + self.kind == other.kind + && self.detail1 == other.detail1 + && self.detail2 == other.detail2 + && self.any_data == other.any_data + } +} + +impl PartialEq> for EventBodyBorrowed<'_> { + fn eq(&self, other: &EventBodyQtBorrowed<'_>) -> bool { + self.kind == other.kind + && self.detail1 == other.detail1 + && self.detail2 == other.detail2 + && self.any_data == other.any_data + } +} + +#[cfg(test)] +mod test { + use super::*; + use crate::ObjectRef; + use std::collections::HashMap; + use zbus::wire::{serialized::Context, LE}; + use zbus::wire::{Array, ObjectPath, Variant as Value}; + + #[test] + fn owned_event_body_clone() { + let event = EventBodyOwned::default(); + let cloned = event.clone(); + + assert_eq!(event, cloned); + } + + #[test] + fn event_body_qt_clone() { + let event = EventBodyQtOwned::default(); + let cloned = event.clone(); + + assert_eq!(event, cloned); + } + + #[test] + fn event_body_borrowed_clone() { + let event = EventBodyBorrowed::default(); + let cloned = event.clone(); + + assert_eq!(event, cloned); + } + + #[test] + fn event_body_qt_borrowed_clone() { + let event = EventBodyQtBorrowed::default(); + let cloned = event.clone(); + + assert_eq!(event, cloned); + } + + #[test] + fn owned_event_body_default() { + let event = EventBodyOwned::default(); + + assert_eq!(event.kind, ""); + assert_eq!(event.detail1, 0); + assert_eq!(event.detail2, 0); + assert_eq!(event.any_data, 0_u32.into()); + } + + #[test] + fn qt_event_body_default() { + let event = EventBodyQtOwned::default(); + + assert_eq!(event.kind, ""); + assert_eq!(event.detail1, 0); + assert_eq!(event.detail2, 0); + assert_eq!(event.any_data, 0_u32.into()); + assert_eq!(event.properties, QtProperties); + } + + #[test] + fn event_body_borrowed_default() { + let event = EventBodyBorrowed::default(); + + assert_eq!(event.kind, ""); + assert_eq!(event.detail1, 0); + assert_eq!(event.detail2, 0); + assert_eq!(event.any_data, Value::new(0_u32)); + } + + #[test] + fn qt_event_body_borrowed_default() { + let event = EventBodyQtBorrowed::default(); + + assert_eq!(event.kind, ""); + assert_eq!(event.detail1, 0); + assert_eq!(event.detail2, 0); + assert_eq!(event.any_data, Value::new(0_u32)); + assert_eq!(event.properties, QtProperties); + } + + #[test] + fn event_body_default() { + let event = EventBody::default(); + + assert_eq!(event, EventBody::Borrowed(EventBodyBorrowed::default())); + } + + #[test] + fn qt_to_owned() { + let qt = EventBodyQtOwned::default(); + let owned: EventBodyOwned = EventBodyQtOwned::default().into(); + + assert_eq!(owned, qt); + } + + #[test] + fn borrowed_to_qt() { + let borrowed: EventBodyBorrowed = EventBodyQtBorrowed::default().into(); + + assert_eq!(borrowed, EventBodyBorrowed::default()); + } + + #[test] + fn event_body_deserialize_as_owned() { + let event = EventBodyOwned::default(); + + let ctxt = Context::new(LE, 0); + let bytes = zbus::wire::to_bytes::(ctxt, &event).unwrap(); + + let (deserialized, _) = bytes.deserialize::().unwrap(); + + assert_eq!(deserialized, event); + } + + #[test] + fn owned_event_body_deserialize_as_borrowed() { + let event = EventBodyOwned::default(); + + let ctxt = Context::new(LE, 0); + let bytes = zbus::wire::to_bytes::(ctxt, &event).unwrap(); + + let (deserialized, _) = bytes.deserialize::().unwrap(); + + assert_eq!(deserialized, EventBodyBorrowed::default()); + assert_eq!(deserialized.kind, event.kind.as_str()); + assert_eq!(deserialized.detail1, event.detail1); + assert_eq!(deserialized.detail2, event.detail2); + assert_eq!(deserialized.any_data, *event.any_data); + } + + #[test] + fn qt_owned_event_body_deserialize_as_borrowed() { + let event = EventBodyQtOwned::default(); + + let ctxt = Context::new(LE, 0); + let bytes = zbus::wire::to_bytes::(ctxt, &event).unwrap(); + + let (deserialized, _) = bytes.deserialize::().unwrap(); + + assert_eq!(deserialized, EventBodyBorrowed::default()); + assert_eq!(deserialized.kind, event.kind.as_str()); + assert_eq!(deserialized.detail1, event.detail1); + assert_eq!(deserialized.detail2, event.detail2); + assert_eq!(deserialized.any_data, *event.any_data); + } + + #[test] + fn event_body_default_deserialize_as_event_body() { + let event = EventBody::default(); + + let ctxt = Context::new(LE, 0); + let bytes = zbus::wire::to_bytes::(ctxt, &event).unwrap(); + + let (deserialized, _) = bytes.deserialize::().unwrap(); + + assert_eq!(deserialized, event); + } + + #[test] + fn event_body_owned_default_deserialize_as_event_body() { + let event = EventBodyOwned::default(); + + let ctxt = Context::new(LE, 0); + let bytes = zbus::wire::to_bytes::(ctxt, &event).unwrap(); + + let (deserialized, _) = bytes.deserialize::().unwrap(); + + assert_eq!(deserialized.kind(), event.kind.as_str()); + assert_eq!(deserialized.detail1(), event.detail1); + assert_eq!(deserialized.detail2(), event.detail2); + assert_eq!(*deserialized.any_data(), *event.any_data); + } + + #[test] + fn complex_body_deserialize_as_event_body() { + let boots = Array::from(vec!["these", "boots", "are", "made", "for", "walking"]); + let boots = Value::from(boots); + let event = ( + "object:state-changed:focused", + 1, + 2, + boots.clone(), + HashMap::from([("key", Value::from(55_u32)), ("key2", Value::from(56_u32))]), + ); + + let ctxt = Context::new(LE, 0); + let bytes = + zbus::wire::to_bytes::<(&str, i32, i32, Value, HashMap<&str, Value>)>(ctxt, &event) + .unwrap(); + + let (deserialized, _) = bytes.deserialize::().unwrap(); + + assert_eq!(deserialized.kind(), "object:state-changed:focused"); + assert_eq!(deserialized.detail1(), 1); + assert_eq!(deserialized.detail2(), 2); + assert_eq!(*deserialized.any_data(), boots); + } + + #[test] + fn complex_body_deserialize_as_owned_event_body() { + let boots = Array::from(vec!["these", "boots", "are", "made", "for", "walking"]); + let boots = Value::from(boots); + let event = ( + "object:state-changed:focused", + 1, + 2, + boots.clone(), + HashMap::from([("key", Value::from(55_u32)), ("key2", Value::from(56_u32))]), + ); + + let ctxt = Context::new(LE, 0); + let bytes = + zbus::wire::to_bytes::<(&str, i32, i32, Value, HashMap<&str, Value>)>(ctxt, &event) + .unwrap(); + + let (deserialized, _) = bytes.deserialize::().unwrap(); + + assert_eq!(deserialized.kind, "object:state-changed:focused"); + assert_eq!(deserialized.detail1, 1); + assert_eq!(deserialized.detail2, 2); + assert_eq!(*deserialized.any_data, boots); + } + + #[test] + fn complex_qt_body_as_bytes_deserialize_as_event_body() { + let boots = Array::from(vec!["these", "boots", "are", "made", "for", "walking"]); + let boots = Value::from(boots); + let event = ( + "and that is what they'll do", + 1, + 2, + boots.clone(), + (":0.0", ObjectPath::from_static_str_unchecked("/")), + ); + + let ctxt = Context::new(LE, 0); + let bytes = zbus::wire::to_bytes::<(&str, i32, i32, Value, (&str, ObjectPath))>(ctxt, &event) + .unwrap(); + + let (deserialized, _) = bytes.deserialize::().unwrap(); + + assert_eq!(deserialized.kind(), "and that is what they'll do"); + assert_eq!(deserialized.detail1(), 1); + assert_eq!(deserialized.detail2(), 2); + assert_eq!(*deserialized.any_data(), boots); + } + + #[test] + fn complex_qt_body_as_message_deserialize_as_event_body() { + let boots = Array::from(vec!["these", "boots", "are", "made", "for", "walking"]); + let boots = Value::from(boots); + let event = ( + "and that is what they'll do", + 1, + 2, + boots.clone(), + (":0.0", ObjectPath::from_static_str_unchecked("/")), + ); + + let msg = zbus::Message::signal("/", "org.a11y.atspi.Object", "StateChange") + .build(&event) + .unwrap(); + + let body = msg.body(); + let deserialized = body.deserialize_ignore_signature::().unwrap(); + + assert_eq!(deserialized.kind(), "and that is what they'll do"); + assert_eq!(deserialized.detail1(), 1); + assert_eq!(deserialized.detail2(), 2); + assert_eq!(*deserialized.any_data(), boots); + } + + #[test] + fn illegal_body_as_bytes_deserialize_as_event_body() { + let boots = Array::from(vec!["these", "boots", "are", "made", "for", "walking"]); + let boots = Value::from(boots); + let event = ( + "and that is what they'll do", + 1, + 2, + 4_u32, + boots.clone(), + (":0.0", ObjectPath::from_static_str_unchecked("/")), + ); + + let ctxt = Context::new(LE, 0); + let bytes = zbus::wire::to_bytes::<(&str, i32, i32, u32, Value<'_>, (&str, ObjectPath<'_>))>( + ctxt, &event, + ) + .unwrap(); + + assert!(bytes.deserialize::().is_err()); + } + + #[test] + fn complex_body_deserialize_as_borrowed_event_body() { + let boots = Array::from(vec!["these", "boots", "are", "made", "for", "walking"]); + let boots = Value::from(boots); + let event = ( + "object:state-changed:focused", + 1, + 2, + boots.clone(), + HashMap::from([("key", Value::from(55_u32)), ("key2", Value::from(56_u32))]), + ); + + let ctxt = Context::new(LE, 0); + let bytes = + zbus::wire::to_bytes::<(&str, i32, i32, Value, HashMap<&str, Value>)>(ctxt, &event) + .unwrap(); + + let (deserialized, _) = bytes.deserialize::().unwrap(); + + assert_eq!(deserialized.kind, "object:state-changed:focused"); + assert_eq!(deserialized.detail1, 1); + assert_eq!(deserialized.detail2, 2); + assert_eq!(deserialized.any_data, boots); + } + + #[test] + fn deserialize_message_from_complex_message_data() { + let boots = Array::from(vec!["these", "boots", "are", "made", "for", "walking"]); + let boots = Value::from(boots); + let body = ( + "object:state-changed:focused", + 1, + 2, + boots.clone(), + HashMap::from([("key", Value::from(55_u32)), ("key2", Value::from(56_u32))]), + ); + + let message = zbus::Message::signal("/", "org.a11y.atspi.Object", "StateChange") + .build(&body) + .unwrap(); + + let msg_body = message.body(); + + let deserialized = msg_body.deserialize::().unwrap(); + + assert_eq!(deserialized.kind, "object:state-changed:focused"); + assert_eq!(deserialized.detail1, 1); + assert_eq!(deserialized.detail2, 2); + assert_eq!(*deserialized.any_data, boots); + } + + #[test] + fn simple_data_deserialization() { + let body = "hello"; + + let message = zbus::Message::signal("/bus/driver/zeenix", "org.Zbus", "TicketCheck") + .build(&body) + .unwrap(); + + let msg_body = message.body(); + let deserialized = msg_body.deserialize::<&str>().unwrap(); + + assert_eq!(deserialized, body); + } + + #[test] + fn test_valid_hashmap_of_string_value_deserializes_as_properties() { + let val = Value::from(0_u32); + let key = "test"; + let map = HashMap::from([(key, val)]); + + let ctxt = Context::new(LE, 0); + let bytes = zbus::wire::to_bytes::>(ctxt, &map).unwrap(); + + let (properties, _) = bytes.deserialize::().unwrap(); + + assert_eq!(properties, Properties); + } + + #[test] + fn test_object_ref_deserializes_as_qt_properties() { + let object_ref = ObjectRef::default(); + + let ctxt = Context::new(LE, 0); + let bytes = zbus::wire::to_bytes::(ctxt, &object_ref).unwrap(); + + let (qt_props, _) = bytes.deserialize::().unwrap(); + + assert_eq!(qt_props, QtProperties); + } + + #[test] + fn test_properties_serializes_as_valid_hashmap() { + let properties = Properties; + let ctxt = Context::new(LE, 0); + let bytes = zbus::wire::to_bytes::(ctxt, &properties).unwrap(); + + let (map, _) = bytes.deserialize::>().unwrap(); + + assert_eq!(map, HashMap::new()); + } + + #[test] + fn test_qt_properties_serializes_as_valid_string_objpath_tuple() { + let qt_properties = QtProperties; + let ctxt = Context::new(LE, 0); + let bytes = zbus::wire::to_bytes::(ctxt, &qt_properties).unwrap(); + + let (tuple, _) = bytes.deserialize::<(&str, ObjectPath)>().unwrap(); + + assert_eq!(tuple, (":0.0", ObjectPath::from_static_str_unchecked("/"))); + } + + #[test] + fn test_qt_properties_serializes_as_valid_object_ref() { + let qt_properties = QtProperties; + let ctxt = Context::new(LE, 0); + let bytes = zbus::wire::to_bytes::(ctxt, &qt_properties).unwrap(); + + let (objectref, _) = bytes.deserialize::().unwrap(); + + assert_eq!(objectref.name().unwrap().as_str(), ":0.0"); + assert_eq!(objectref.path(), &ObjectPath::from_static_str_unchecked("/")); + } + + #[cfg(test)] + mod signatures { + use crate::events::EventBodyQtOwned; + use zbus::wire::{signature::Fields, Signature, Type}; + + #[test] + fn test_event_body_signature_equals_borrowed_event_body_signature() { + use super::*; + use zbus::wire::Type; + + let borrowed = EventBodyBorrowed::SIGNATURE; + let owned = EventBodyOwned::SIGNATURE; + + assert_eq!(borrowed, owned); + } + + // We have no definition of the Qt event body, so we can't compare the type + // to a signature definition in XML. + // That is why we keep a copy here. + const QSPI_EVENT_SIGNATURE: &Signature = &Signature::static_structure(&[ + &Signature::Str, + &Signature::I32, + &Signature::I32, + &Signature::Variant, + &Signature::Structure(Fields::Static { + fields: &[&Signature::Str, &Signature::ObjectPath], + }), + ]); + + #[test] + fn check_event_body_qt_signature() { + assert_eq!(::SIGNATURE, QSPI_EVENT_SIGNATURE); + } + } +} diff --git a/patches/atspi-common/src/events/event_wrappers.rs b/patches/atspi-common/src/events/event_wrappers.rs new file mode 100644 index 0000000..151666e --- /dev/null +++ b/patches/atspi-common/src/events/event_wrappers.rs @@ -0,0 +1,2220 @@ +use crate::events::registry::socket::AvailableEvent; + +use crate::events::registry::{EventListenerDeregisteredEvent, EventListenerRegisteredEvent}; +#[cfg(feature = "zbus")] +use crate::events::traits::{EventWrapperMessageConversion, TryFromMessage}; +#[cfg(feature = "zbus")] +use crate::events::MessageConversion; +use crate::{ + error::AtspiError, + events::{ + cache::{AddAccessibleEvent, LegacyAddAccessibleEvent, RemoveAccessibleEvent}, + document::{ + AttributesChangedEvent as DocumentAttributesChangedEvent, ContentChangedEvent, + LoadCompleteEvent, LoadStoppedEvent, PageChangedEvent, ReloadEvent, + }, + focus::FocusEvent, + keyboard::ModifiersEvent, + mouse::{AbsEvent, ButtonEvent, RelEvent}, + object::{ + ActiveDescendantChangedEvent, AnnouncementEvent, + AttributesChangedEvent as ObjectAttributesChangedEvent, BoundsChangedEvent, + ChildrenChangedEvent, ColumnDeletedEvent, ColumnInsertedEvent, ColumnReorderedEvent, + LinkSelectedEvent, ModelChangedEvent, PropertyChangeEvent as ObjectPropertyChangeEvent, + RowDeletedEvent, RowInsertedEvent, RowReorderedEvent, SelectionChangedEvent, + StateChangedEvent, TextAttributesChangedEvent, TextBoundsChangedEvent, + TextCaretMovedEvent, TextChangedEvent, TextSelectionChangedEvent, + VisibleDataChangedEvent, + }, + terminal::{ + ApplicationChangedEvent, CharWidthChangedEvent, ColumnCountChangedEvent, + LineChangedEvent, LineCountChangedEvent, + }, + window::{ + ActivateEvent, CloseEvent, CreateEvent, DeactivateEvent, DesktopCreateEvent, + DesktopDestroyEvent, DestroyEvent, LowerEvent, MaximizeEvent, MinimizeEvent, MoveEvent, + PropertyChangeEvent as WindowPropertyChangeEvent, RaiseEvent, ReparentEvent, + ResizeEvent, RestoreEvent, RestyleEvent, ShadeEvent, UUshadeEvent, + }, + DBusInterface, DBusMatchRule, EventTypeProperties, RegistryEventString, + }, + EventProperties, +}; +#[cfg(feature = "zbus")] +use crate::{events::DBusMember, CacheItem, LegacyCacheItem}; +use serde::{Deserialize, Serialize}; +#[cfg(feature = "zbus")] +use zbus::message::Header; +use zbus::names::UniqueName; +use zbus::wire::ObjectPath; +#[cfg(feature = "zbus")] +use zbus::wire::Type; + +impl_from_user_facing_event_for_interface_event_enum!( + EventListenerRegisteredEvent, + EventListenerEvents, + EventListenerEvents::Registered +); + +impl_from_user_facing_type_for_event_enum!(EventListenerRegisteredEvent, Event::Listener); + +impl_try_from_event_for_user_facing_type!( + EventListenerRegisteredEvent, + EventListenerEvents::Registered, + Event::Listener +); + +impl_from_user_facing_event_for_interface_event_enum!( + EventListenerDeregisteredEvent, + EventListenerEvents, + EventListenerEvents::Deregistered +); + +impl_from_user_facing_type_for_event_enum!(EventListenerDeregisteredEvent, Event::Listener); +impl_try_from_event_for_user_facing_type!( + EventListenerDeregisteredEvent, + EventListenerEvents::Deregistered, + Event::Listener +); + +#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)] +pub enum KeyboardEvents { + /// See: [`ModifiersEvent`]. + Modifiers(ModifiersEvent), +} + +impl_tryfrommessage_for_event_wrapper!(KeyboardEvents); +impl_try_from_event_for_interface_enum!(KeyboardEvents, Event::Keyboard); +impl_from_interface_event_enum_for_event!(KeyboardEvents, Event::Keyboard); + +impl_from_user_facing_event_for_interface_event_enum!( + ModifiersEvent, + KeyboardEvents, + KeyboardEvents::Modifiers +); +impl EventTypeProperties for KeyboardEvents { + fn member(&self) -> &'static str { + match self { + Self::Modifiers(inner) => inner.member(), + } + } + fn match_rule(&self) -> &'static str { + match self { + Self::Modifiers(inner) => inner.match_rule(), + } + } + fn interface(&self) -> &'static str { + match self { + Self::Modifiers(inner) => inner.interface(), + } + } + fn registry_string(&self) -> &'static str { + match self { + Self::Modifiers(inner) => inner.registry_string(), + } + } +} + +impl EventProperties for KeyboardEvents { + fn path(&self) -> ObjectPath<'_> { + match self { + Self::Modifiers(inner) => inner.path(), + } + } + fn sender(&self) -> UniqueName<'_> { + match self { + Self::Modifiers(inner) => inner.sender(), + } + } +} + +event_wrapper_test_cases!(KeyboardEvents, ModifiersEvent); + +impl DBusMatchRule for KeyboardEvents { + const MATCH_RULE_STRING: &'static str = + "type='signal',interface='org.a11y.atspi.Event.Keyboard'"; +} + +impl DBusInterface for KeyboardEvents { + const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Keyboard"; +} + +impl RegistryEventString for KeyboardEvents { + const REGISTRY_EVENT_STRING: &'static str = "keyboard:"; +} + +impl_from_user_facing_type_for_event_enum!(ModifiersEvent, Event::Keyboard); + +#[cfg(feature = "zbus")] +impl TryFrom<&zbus::Message> for KeyboardEvents { + type Error = AtspiError; + fn try_from(msg: &zbus::Message) -> Result { + Self::try_from_message(msg) + } +} + +impl_try_from_event_for_user_facing_type!( + ModifiersEvent, + KeyboardEvents::Modifiers, + Event::Keyboard +); + +#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)] +pub enum MouseEvents { + /// See: [`AbsEvent`]. + Abs(AbsEvent), + + /// See: [`RelEvent`]. + Rel(RelEvent), + + /// See: [`ButtonEvent`]. + Button(ButtonEvent), +} + +impl DBusMatchRule for MouseEvents { + const MATCH_RULE_STRING: &'static str = "type='signal',interface='org.a11y.atspi.Event.Mouse'"; +} + +impl DBusInterface for MouseEvents { + const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Mouse"; +} + +impl RegistryEventString for MouseEvents { + const REGISTRY_EVENT_STRING: &'static str = "mouse:"; +} + +impl_tryfrommessage_for_event_wrapper!(MouseEvents); + +#[cfg(feature = "zbus")] +impl EventWrapperMessageConversion for KeyboardEvents { + fn try_from_message_interface_checked( + msg: &zbus::Message, + hdr: &Header, + ) -> Result { + let member = hdr + .member() + .ok_or(AtspiError::MemberMatch("Event without member".into()))?; + match member.as_str() { + ModifiersEvent::DBUS_MEMBER => { + Ok(KeyboardEvents::Modifiers(ModifiersEvent::from_message_unchecked(msg, hdr)?)) + } + _ => Err(AtspiError::MemberMatch("No matching member for Keyboard".into())), + } + } +} + +impl EventProperties for MouseEvents { + fn path(&self) -> ObjectPath<'_> { + match self { + Self::Abs(inner) => inner.path(), + Self::Rel(inner) => inner.path(), + Self::Button(inner) => inner.path(), + } + } + fn sender(&self) -> UniqueName<'_> { + match self { + Self::Abs(inner) => inner.sender(), + Self::Rel(inner) => inner.sender(), + Self::Button(inner) => inner.sender(), + } + } +} + +impl EventTypeProperties for MouseEvents { + fn member(&self) -> &'static str { + match self { + Self::Abs(inner) => inner.member(), + Self::Rel(inner) => inner.member(), + Self::Button(inner) => inner.member(), + } + } + fn interface(&self) -> &'static str { + match self { + Self::Abs(inner) => inner.interface(), + Self::Rel(inner) => inner.interface(), + Self::Button(inner) => inner.interface(), + } + } + fn match_rule(&self) -> &'static str { + match self { + Self::Abs(inner) => inner.match_rule(), + Self::Rel(inner) => inner.match_rule(), + Self::Button(inner) => inner.match_rule(), + } + } + fn registry_string(&self) -> &'static str { + match self { + Self::Abs(inner) => inner.registry_string(), + Self::Rel(inner) => inner.registry_string(), + Self::Button(inner) => inner.registry_string(), + } + } +} + +event_wrapper_test_cases!(MouseEvents, AbsEvent); +impl_try_from_event_for_interface_enum!(MouseEvents, Event::Mouse); +impl_from_interface_event_enum_for_event!(MouseEvents, Event::Mouse); + +impl_from_user_facing_event_for_interface_event_enum!(RelEvent, MouseEvents, MouseEvents::Rel); +impl_try_from_event_for_user_facing_type!(RelEvent, MouseEvents::Rel, Event::Mouse); +impl_from_user_facing_event_for_interface_event_enum!( + ButtonEvent, + MouseEvents, + MouseEvents::Button +); +impl_try_from_event_for_user_facing_type!(ButtonEvent, MouseEvents::Button, Event::Mouse); + +#[cfg(feature = "zbus")] +impl EventWrapperMessageConversion for MouseEvents { + fn try_from_message_interface_checked( + msg: &zbus::Message, + hdr: &Header, + ) -> Result { + let member = hdr.member().ok_or(AtspiError::MissingMember)?; + match member.as_str() { + AbsEvent::DBUS_MEMBER => { + Ok(MouseEvents::Abs(AbsEvent::from_message_unchecked(msg, hdr)?)) + } + RelEvent::DBUS_MEMBER => { + Ok(MouseEvents::Rel(RelEvent::from_message_unchecked(msg, hdr)?)) + } + ButtonEvent::DBUS_MEMBER => { + Ok(MouseEvents::Button(ButtonEvent::from_message_unchecked(msg, hdr)?)) + } + _ => Err(AtspiError::MemberMatch("No matching member for Mouse".into())), + } + } +} + +#[cfg(feature = "zbus")] +impl TryFrom<&zbus::Message> for MouseEvents { + type Error = AtspiError; + fn try_from(msg: &zbus::Message) -> Result { + Self::try_from_message(msg) + } +} + +impl_from_user_facing_type_for_event_enum!(ButtonEvent, Event::Mouse); +impl_from_user_facing_type_for_event_enum!(RelEvent, Event::Mouse); +impl_from_user_facing_type_for_event_enum!(AbsEvent, Event::Mouse); + +impl_from_user_facing_event_for_interface_event_enum!(AbsEvent, MouseEvents, MouseEvents::Abs); +impl_try_from_event_for_user_facing_type!(AbsEvent, MouseEvents::Abs, Event::Mouse); + +#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)] +pub enum ObjectEvents { + /// See: [`ObjectPropertyChangeEvent`]. + PropertyChange(ObjectPropertyChangeEvent), + /// See: [`BoundsChangedEvent`]. + BoundsChanged(BoundsChangedEvent), + /// See: [`LinkSelectedEvent`]. + LinkSelected(LinkSelectedEvent), + /// See: [`StateChangedEvent`]. + StateChanged(StateChangedEvent), + /// See: [`ChildrenChangedEvent`]. + ChildrenChanged(ChildrenChangedEvent), + /// See: [`VisibleDataChangedEvent`]. + VisibleDataChanged(VisibleDataChangedEvent), + /// See: [`SelectionChangedEvent`]. + SelectionChanged(SelectionChangedEvent), + /// See: [`ModelChangedEvent`]. + ModelChanged(ModelChangedEvent), + /// See: [`ActiveDescendantChangedEvent`]. + ActiveDescendantChanged(ActiveDescendantChangedEvent), + /// See: [`AnnouncementEvent`]. + Announcement(AnnouncementEvent), + /// See: [`ObjectAttributesChangedEvent`]. + AttributesChanged(ObjectAttributesChangedEvent), + /// See: [`RowInsertedEvent`]. + RowInserted(RowInsertedEvent), + /// See: [`RowReorderedEvent`]. + RowReordered(RowReorderedEvent), + /// See: [`RowDeletedEvent`]. + RowDeleted(RowDeletedEvent), + /// See: [`ColumnInsertedEvent`]. + ColumnInserted(ColumnInsertedEvent), + /// See: [`ColumnReorderedEvent`]. + ColumnReordered(ColumnReorderedEvent), + /// See: [`ColumnDeletedEvent`]. + ColumnDeleted(ColumnDeletedEvent), + /// See: [`TextBoundsChangedEvent`]. + TextBoundsChanged(TextBoundsChangedEvent), + /// See: [`TextSelectionChangedEvent`]. + TextSelectionChanged(TextSelectionChangedEvent), + /// See: [`TextChangedEvent`]. + TextChanged(TextChangedEvent), + /// See: [`TextAttributesChangedEvent`]. + TextAttributesChanged(TextAttributesChangedEvent), + /// See: [`TextCaretMovedEvent`]. + TextCaretMoved(TextCaretMovedEvent), +} + +impl_tryfrommessage_for_event_wrapper!(ObjectEvents); + +impl EventTypeProperties for ObjectEvents { + fn member(&self) -> &'static str { + match self { + Self::PropertyChange(inner) => inner.member(), + Self::BoundsChanged(inner) => inner.member(), + Self::LinkSelected(inner) => inner.member(), + Self::StateChanged(inner) => inner.member(), + Self::ChildrenChanged(inner) => inner.member(), + Self::VisibleDataChanged(inner) => inner.member(), + Self::SelectionChanged(inner) => inner.member(), + Self::ModelChanged(inner) => inner.member(), + Self::ActiveDescendantChanged(inner) => inner.member(), + Self::Announcement(inner) => inner.member(), + Self::AttributesChanged(inner) => inner.member(), + Self::RowInserted(inner) => inner.member(), + Self::RowReordered(inner) => inner.member(), + Self::RowDeleted(inner) => inner.member(), + Self::ColumnInserted(inner) => inner.member(), + Self::ColumnReordered(inner) => inner.member(), + Self::ColumnDeleted(inner) => inner.member(), + Self::TextBoundsChanged(inner) => inner.member(), + Self::TextSelectionChanged(inner) => inner.member(), + Self::TextChanged(inner) => inner.member(), + Self::TextAttributesChanged(inner) => inner.member(), + Self::TextCaretMoved(inner) => inner.member(), + } + } + fn interface(&self) -> &'static str { + match self { + Self::PropertyChange(inner) => inner.interface(), + Self::BoundsChanged(inner) => inner.interface(), + Self::LinkSelected(inner) => inner.interface(), + Self::StateChanged(inner) => inner.interface(), + Self::ChildrenChanged(inner) => inner.interface(), + Self::VisibleDataChanged(inner) => inner.interface(), + Self::SelectionChanged(inner) => inner.interface(), + Self::ModelChanged(inner) => inner.interface(), + Self::ActiveDescendantChanged(inner) => inner.interface(), + Self::Announcement(inner) => inner.interface(), + Self::AttributesChanged(inner) => inner.interface(), + Self::RowInserted(inner) => inner.interface(), + Self::RowReordered(inner) => inner.interface(), + Self::RowDeleted(inner) => inner.interface(), + Self::ColumnInserted(inner) => inner.interface(), + Self::ColumnReordered(inner) => inner.interface(), + Self::ColumnDeleted(inner) => inner.interface(), + Self::TextBoundsChanged(inner) => inner.interface(), + Self::TextSelectionChanged(inner) => inner.interface(), + Self::TextChanged(inner) => inner.interface(), + Self::TextAttributesChanged(inner) => inner.interface(), + Self::TextCaretMoved(inner) => inner.interface(), + } + } + fn match_rule(&self) -> &'static str { + match self { + Self::PropertyChange(inner) => inner.match_rule(), + Self::BoundsChanged(inner) => inner.match_rule(), + Self::LinkSelected(inner) => inner.match_rule(), + Self::StateChanged(inner) => inner.match_rule(), + Self::ChildrenChanged(inner) => inner.match_rule(), + Self::VisibleDataChanged(inner) => inner.match_rule(), + Self::SelectionChanged(inner) => inner.match_rule(), + Self::ModelChanged(inner) => inner.match_rule(), + Self::ActiveDescendantChanged(inner) => inner.match_rule(), + Self::Announcement(inner) => inner.match_rule(), + Self::AttributesChanged(inner) => inner.match_rule(), + Self::RowInserted(inner) => inner.match_rule(), + Self::RowReordered(inner) => inner.match_rule(), + Self::RowDeleted(inner) => inner.match_rule(), + Self::ColumnInserted(inner) => inner.match_rule(), + Self::ColumnReordered(inner) => inner.match_rule(), + Self::ColumnDeleted(inner) => inner.match_rule(), + Self::TextBoundsChanged(inner) => inner.match_rule(), + Self::TextSelectionChanged(inner) => inner.match_rule(), + Self::TextChanged(inner) => inner.match_rule(), + Self::TextAttributesChanged(inner) => inner.match_rule(), + Self::TextCaretMoved(inner) => inner.match_rule(), + } + } + fn registry_string(&self) -> &'static str { + match self { + Self::PropertyChange(inner) => inner.registry_string(), + Self::BoundsChanged(inner) => inner.registry_string(), + Self::LinkSelected(inner) => inner.registry_string(), + Self::StateChanged(inner) => inner.registry_string(), + Self::ChildrenChanged(inner) => inner.registry_string(), + Self::VisibleDataChanged(inner) => inner.registry_string(), + Self::SelectionChanged(inner) => inner.registry_string(), + Self::ModelChanged(inner) => inner.registry_string(), + Self::ActiveDescendantChanged(inner) => inner.registry_string(), + Self::Announcement(inner) => inner.registry_string(), + Self::AttributesChanged(inner) => inner.registry_string(), + Self::RowInserted(inner) => inner.registry_string(), + Self::RowReordered(inner) => inner.registry_string(), + Self::RowDeleted(inner) => inner.registry_string(), + Self::ColumnInserted(inner) => inner.registry_string(), + Self::ColumnReordered(inner) => inner.registry_string(), + Self::ColumnDeleted(inner) => inner.registry_string(), + Self::TextBoundsChanged(inner) => inner.registry_string(), + Self::TextSelectionChanged(inner) => inner.registry_string(), + Self::TextChanged(inner) => inner.registry_string(), + Self::TextAttributesChanged(inner) => inner.registry_string(), + Self::TextCaretMoved(inner) => inner.registry_string(), + } + } +} + +impl EventProperties for ObjectEvents { + fn path(&self) -> ObjectPath<'_> { + match self { + Self::PropertyChange(inner) => inner.path(), + Self::BoundsChanged(inner) => inner.path(), + Self::LinkSelected(inner) => inner.path(), + Self::StateChanged(inner) => inner.path(), + Self::ChildrenChanged(inner) => inner.path(), + Self::VisibleDataChanged(inner) => inner.path(), + Self::SelectionChanged(inner) => inner.path(), + Self::ModelChanged(inner) => inner.path(), + Self::ActiveDescendantChanged(inner) => inner.path(), + Self::Announcement(inner) => inner.path(), + Self::AttributesChanged(inner) => inner.path(), + Self::RowInserted(inner) => inner.path(), + Self::RowReordered(inner) => inner.path(), + Self::RowDeleted(inner) => inner.path(), + Self::ColumnInserted(inner) => inner.path(), + Self::ColumnReordered(inner) => inner.path(), + Self::ColumnDeleted(inner) => inner.path(), + Self::TextBoundsChanged(inner) => inner.path(), + Self::TextSelectionChanged(inner) => inner.path(), + Self::TextChanged(inner) => inner.path(), + Self::TextAttributesChanged(inner) => inner.path(), + Self::TextCaretMoved(inner) => inner.path(), + } + } + fn sender(&self) -> UniqueName<'_> { + match self { + Self::PropertyChange(inner) => inner.sender(), + Self::BoundsChanged(inner) => inner.sender(), + Self::LinkSelected(inner) => inner.sender(), + Self::StateChanged(inner) => inner.sender(), + Self::ChildrenChanged(inner) => inner.sender(), + Self::VisibleDataChanged(inner) => inner.sender(), + Self::SelectionChanged(inner) => inner.sender(), + Self::ModelChanged(inner) => inner.sender(), + Self::ActiveDescendantChanged(inner) => inner.sender(), + Self::Announcement(inner) => inner.sender(), + Self::AttributesChanged(inner) => inner.sender(), + Self::RowInserted(inner) => inner.sender(), + Self::RowReordered(inner) => inner.sender(), + Self::RowDeleted(inner) => inner.sender(), + Self::ColumnInserted(inner) => inner.sender(), + Self::ColumnReordered(inner) => inner.sender(), + Self::ColumnDeleted(inner) => inner.sender(), + Self::TextBoundsChanged(inner) => inner.sender(), + Self::TextSelectionChanged(inner) => inner.sender(), + Self::TextChanged(inner) => inner.sender(), + Self::TextAttributesChanged(inner) => inner.sender(), + Self::TextCaretMoved(inner) => inner.sender(), + } + } +} + +impl_try_from_event_for_interface_enum!(ObjectEvents, Event::Object); +impl_from_interface_event_enum_for_event!(ObjectEvents, Event::Object); + +event_wrapper_test_cases!(ObjectEvents, ObjectPropertyChangeEvent); + +impl_from_user_facing_event_for_interface_event_enum!( + TextChangedEvent, + ObjectEvents, + ObjectEvents::TextChanged +); +impl_try_from_event_for_user_facing_type!( + TextChangedEvent, + ObjectEvents::TextChanged, + Event::Object +); + +#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)] +pub enum DocumentEvents { + /// See: [`LoadCompleteEvent`]. + LoadComplete(LoadCompleteEvent), + /// See: [`ReloadEvent`]. + Reload(ReloadEvent), + /// See: [`LoadStoppedEvent`]. + LoadStopped(LoadStoppedEvent), + /// See: [`ContentChangedEvent`]. + ContentChanged(ContentChangedEvent), + /// See: [`DocumentAttributesChangedEvent`]. + AttributesChanged(DocumentAttributesChangedEvent), + /// See: [`PageChangedEvent`]. + PageChanged(PageChangedEvent), +} + +impl_tryfrommessage_for_event_wrapper!(DocumentEvents); + +impl DBusInterface for DocumentEvents { + const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Document"; +} + +impl DBusMatchRule for DocumentEvents { + const MATCH_RULE_STRING: &'static str = + "type='signal',interface='org.a11y.atspi.Event.Document'"; +} + +impl RegistryEventString for DocumentEvents { + const REGISTRY_EVENT_STRING: &'static str = "Document:"; +} + +impl EventTypeProperties for DocumentEvents { + fn member(&self) -> &'static str { + match self { + Self::LoadComplete(inner) => inner.member(), + Self::Reload(inner) => inner.member(), + Self::LoadStopped(inner) => inner.member(), + Self::ContentChanged(inner) => inner.member(), + Self::AttributesChanged(inner) => inner.member(), + Self::PageChanged(inner) => inner.member(), + } + } + fn interface(&self) -> &'static str { + match self { + Self::LoadComplete(inner) => inner.interface(), + Self::Reload(inner) => inner.interface(), + Self::LoadStopped(inner) => inner.interface(), + Self::ContentChanged(inner) => inner.interface(), + Self::AttributesChanged(inner) => inner.interface(), + Self::PageChanged(inner) => inner.interface(), + } + } + fn match_rule(&self) -> &'static str { + match self { + Self::LoadComplete(inner) => inner.match_rule(), + Self::Reload(inner) => inner.match_rule(), + Self::LoadStopped(inner) => inner.match_rule(), + Self::ContentChanged(inner) => inner.match_rule(), + Self::AttributesChanged(inner) => inner.match_rule(), + Self::PageChanged(inner) => inner.match_rule(), + } + } + fn registry_string(&self) -> &'static str { + match self { + Self::LoadComplete(inner) => inner.registry_string(), + Self::Reload(inner) => inner.registry_string(), + Self::LoadStopped(inner) => inner.registry_string(), + Self::ContentChanged(inner) => inner.registry_string(), + Self::AttributesChanged(inner) => inner.registry_string(), + Self::PageChanged(inner) => inner.registry_string(), + } + } +} + +impl EventProperties for DocumentEvents { + fn path(&self) -> ObjectPath<'_> { + match self { + Self::LoadComplete(inner) => inner.path(), + Self::Reload(inner) => inner.path(), + Self::LoadStopped(inner) => inner.path(), + Self::ContentChanged(inner) => inner.path(), + Self::AttributesChanged(inner) => inner.path(), + Self::PageChanged(inner) => inner.path(), + } + } + fn sender(&self) -> UniqueName<'_> { + match self { + Self::LoadComplete(inner) => inner.sender(), + Self::Reload(inner) => inner.sender(), + Self::LoadStopped(inner) => inner.sender(), + Self::ContentChanged(inner) => inner.sender(), + Self::AttributesChanged(inner) => inner.sender(), + Self::PageChanged(inner) => inner.sender(), + } + } +} + +impl_from_user_facing_type_for_event_enum!(PageChangedEvent, Event::Document); +impl_from_user_facing_type_for_event_enum!(DocumentAttributesChangedEvent, Event::Document); +impl_from_user_facing_type_for_event_enum!(ContentChangedEvent, Event::Document); +impl_from_user_facing_type_for_event_enum!(LoadStoppedEvent, Event::Document); +impl_from_user_facing_type_for_event_enum!(ReloadEvent, Event::Document); +impl_from_user_facing_type_for_event_enum!(LoadCompleteEvent, Event::Document); + +impl_try_from_event_for_interface_enum!(DocumentEvents, Event::Document); +impl_from_interface_event_enum_for_event!(DocumentEvents, Event::Document); + +event_wrapper_test_cases!(DocumentEvents, LoadCompleteEvent); + +#[cfg(feature = "zbus")] +impl EventWrapperMessageConversion for DocumentEvents { + fn try_from_message_interface_checked( + msg: &zbus::Message, + hdr: &Header, + ) -> Result { + let member = hdr.member().ok_or(AtspiError::MissingMember)?; + match member.as_str() { + LoadCompleteEvent::DBUS_MEMBER => Ok(DocumentEvents::LoadComplete( + LoadCompleteEvent::from_message_unchecked(msg, hdr)?, + )), + ReloadEvent::DBUS_MEMBER => { + Ok(DocumentEvents::Reload(ReloadEvent::from_message_unchecked(msg, hdr)?)) + } + LoadStoppedEvent::DBUS_MEMBER => { + Ok(DocumentEvents::LoadStopped(LoadStoppedEvent::from_message_unchecked(msg, hdr)?)) + } + ContentChangedEvent::DBUS_MEMBER => Ok(DocumentEvents::ContentChanged( + ContentChangedEvent::from_message_unchecked(msg, hdr)?, + )), + DocumentAttributesChangedEvent::DBUS_MEMBER => Ok(DocumentEvents::AttributesChanged( + DocumentAttributesChangedEvent::from_message_unchecked(msg, hdr)?, + )), + PageChangedEvent::DBUS_MEMBER => { + Ok(DocumentEvents::PageChanged(PageChangedEvent::from_message_unchecked(msg, hdr)?)) + } + _ => Err(AtspiError::MemberMatch("No matching member for Document".into())), + } + } +} + +#[cfg(feature = "zbus")] +impl TryFrom<&zbus::Message> for DocumentEvents { + type Error = AtspiError; + fn try_from(msg: &zbus::Message) -> Result { + Self::try_from_message(msg) + } +} + +impl_from_user_facing_event_for_interface_event_enum!( + LoadCompleteEvent, + DocumentEvents, + DocumentEvents::LoadComplete +); +impl_try_from_event_for_user_facing_type!( + LoadCompleteEvent, + DocumentEvents::LoadComplete, + Event::Document +); + +impl_from_user_facing_event_for_interface_event_enum!( + ReloadEvent, + DocumentEvents, + DocumentEvents::Reload +); +impl_try_from_event_for_user_facing_type!(ReloadEvent, DocumentEvents::Reload, Event::Document); + +impl_from_user_facing_event_for_interface_event_enum!( + LoadStoppedEvent, + DocumentEvents, + DocumentEvents::LoadStopped +); +impl_try_from_event_for_user_facing_type!( + LoadStoppedEvent, + DocumentEvents::LoadStopped, + Event::Document +); + +impl_from_user_facing_event_for_interface_event_enum!( + ContentChangedEvent, + DocumentEvents, + DocumentEvents::ContentChanged +); +impl_try_from_event_for_user_facing_type!( + ContentChangedEvent, + DocumentEvents::ContentChanged, + Event::Document +); + +impl_from_user_facing_event_for_interface_event_enum!( + DocumentAttributesChangedEvent, + DocumentEvents, + DocumentEvents::AttributesChanged +); +impl_try_from_event_for_user_facing_type!( + DocumentAttributesChangedEvent, + DocumentEvents::AttributesChanged, + Event::Document +); + +impl_from_user_facing_event_for_interface_event_enum!( + PageChangedEvent, + DocumentEvents, + DocumentEvents::PageChanged +); +impl_try_from_event_for_user_facing_type!( + PageChangedEvent, + DocumentEvents::PageChanged, + Event::Document +); + +/// Encapsulates the various different accessibility bus signal types. +/// +/// Assumes being non exhaustive to allow for future- or custom signals. +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] +#[non_exhaustive] +pub enum Event { + /// See: [`DocumentEvents`]. + Document(DocumentEvents), + /// See: [`FocusEvents`]. + Focus(FocusEvents), + /// See: [`KeyboardEvents`]. + Keyboard(KeyboardEvents), + /// See: [`MouseEvents`]. + Mouse(MouseEvents), + /// See: [`ObjectEvents`]. + Object(ObjectEvents), + /// See: [`TerminalEvents`]. + Terminal(TerminalEvents), + /// See: [`WindowEvents`]. + Window(WindowEvents), + /// See: [`AvailableEvent`]. + Available(AvailableEvent), + /// See: [`CacheEvents`]. + Cache(CacheEvents), + /// See: [`EventListenerEvents`]. + Listener(EventListenerEvents), +} + +impl EventTypeProperties for Event { + fn member(&self) -> &'static str { + match self { + Self::Document(inner) => inner.member(), + Self::Focus(inner) => inner.member(), + Self::Keyboard(inner) => inner.member(), + Self::Mouse(inner) => inner.member(), + Self::Object(inner) => inner.member(), + Self::Terminal(inner) => inner.member(), + Self::Window(inner) => inner.member(), + Self::Available(inner) => inner.member(), + Self::Cache(inner) => inner.member(), + Self::Listener(inner) => inner.member(), + } + } + fn interface(&self) -> &'static str { + match self { + Self::Document(inner) => inner.interface(), + Self::Focus(inner) => inner.interface(), + Self::Keyboard(inner) => inner.interface(), + Self::Mouse(inner) => inner.interface(), + Self::Object(inner) => inner.interface(), + Self::Terminal(inner) => inner.interface(), + Self::Window(inner) => inner.interface(), + Self::Available(inner) => inner.interface(), + Self::Cache(inner) => inner.interface(), + Self::Listener(inner) => inner.interface(), + } + } + fn match_rule(&self) -> &'static str { + match self { + Self::Document(inner) => inner.match_rule(), + Self::Focus(inner) => inner.match_rule(), + Self::Keyboard(inner) => inner.match_rule(), + Self::Mouse(inner) => inner.match_rule(), + Self::Object(inner) => inner.match_rule(), + Self::Terminal(inner) => inner.match_rule(), + Self::Window(inner) => inner.match_rule(), + Self::Available(inner) => inner.match_rule(), + Self::Cache(inner) => inner.match_rule(), + Self::Listener(inner) => inner.match_rule(), + } + } + fn registry_string(&self) -> &'static str { + match self { + Self::Document(inner) => inner.registry_string(), + Self::Focus(inner) => inner.registry_string(), + Self::Keyboard(inner) => inner.registry_string(), + Self::Mouse(inner) => inner.registry_string(), + Self::Object(inner) => inner.registry_string(), + Self::Terminal(inner) => inner.registry_string(), + Self::Window(inner) => inner.registry_string(), + Self::Available(inner) => inner.registry_string(), + Self::Cache(inner) => inner.registry_string(), + Self::Listener(inner) => inner.registry_string(), + } + } +} + +impl EventProperties for Event { + fn path(&self) -> ObjectPath<'_> { + match self { + Self::Document(inner) => inner.path(), + Self::Focus(inner) => inner.path(), + Self::Keyboard(inner) => inner.path(), + Self::Mouse(inner) => inner.path(), + Self::Object(inner) => inner.path(), + Self::Terminal(inner) => inner.path(), + Self::Window(inner) => inner.path(), + Self::Available(inner) => inner.path(), + Self::Cache(inner) => inner.path(), + Self::Listener(inner) => inner.path(), + } + } + fn sender(&self) -> UniqueName<'_> { + match self { + Self::Document(inner) => inner.sender(), + Self::Focus(inner) => inner.sender(), + Self::Keyboard(inner) => inner.sender(), + Self::Mouse(inner) => inner.sender(), + Self::Object(inner) => inner.sender(), + Self::Terminal(inner) => inner.sender(), + Self::Window(inner) => inner.sender(), + Self::Available(inner) => inner.sender(), + Self::Cache(inner) => inner.sender(), + Self::Listener(inner) => inner.sender(), + } + } +} + +#[cfg(feature = "zbus")] +impl TryFrom<&zbus::Message> for Event { + type Error = AtspiError; + + fn try_from(msg: &zbus::Message) -> Result { + let header = msg.header(); + let interface = header.interface().ok_or(AtspiError::MissingInterface)?; + let interface_str = interface.as_str(); + + match interface_str { + ::DBUS_INTERFACE => { + Ok(Event::Object(ObjectEvents::try_from_message_interface_checked(msg, &header)?)) + } + ::DBUS_INTERFACE => { + Ok(Event::Focus(FocusEvents::try_from_message_interface_checked(msg, &header)?)) + } + ::DBUS_INTERFACE => { + Ok(Event::Cache(CacheEvents::try_from_message_interface_checked(msg, &header)?)) + } + ::DBUS_INTERFACE => { + Ok(Event::Window(WindowEvents::try_from_message_interface_checked(msg, &header)?)) + } + ::DBUS_INTERFACE => { + Ok(Event::Mouse(MouseEvents::try_from_message_interface_checked(msg, &header)?)) + } + ::DBUS_INTERFACE => Ok(Event::Terminal( + TerminalEvents::try_from_message_interface_checked(msg, &header)?, + )), + ::DBUS_INTERFACE => Ok(Event::Document( + DocumentEvents::try_from_message_interface_checked(msg, &header)?, + )), + ::DBUS_INTERFACE => Ok(Event::Keyboard( + KeyboardEvents::try_from_message_interface_checked(msg, &header)?, + )), + ::DBUS_INTERFACE => Ok(Event::Listener( + EventListenerEvents::try_from_message_interface_checked(msg, &header)?, + )), + ::DBUS_INTERFACE => { + Ok(AvailableEvent::try_from(msg)?.into()) + } + _ => Err(AtspiError::InterfaceMatch(format!( + "No events found with interface {interface_str}" + ))), + } + } +} + +impl_from_user_facing_type_for_event_enum!(TextCaretMovedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(TextAttributesChangedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(TextChangedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(TextSelectionChangedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(TextBoundsChangedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(ColumnDeletedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(ColumnReorderedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(ColumnInsertedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(RowDeletedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(RowReorderedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(RowInsertedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(ObjectAttributesChangedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(AnnouncementEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(ActiveDescendantChangedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(ModelChangedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(SelectionChangedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(VisibleDataChangedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(ChildrenChangedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(StateChangedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(LinkSelectedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(BoundsChangedEvent, Event::Object); +impl_from_user_facing_type_for_event_enum!(ObjectPropertyChangeEvent, Event::Object); + +impl_from_user_facing_event_for_interface_event_enum!( + ObjectPropertyChangeEvent, + ObjectEvents, + ObjectEvents::PropertyChange +); +impl_try_from_event_for_user_facing_type!( + ObjectPropertyChangeEvent, + ObjectEvents::PropertyChange, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + BoundsChangedEvent, + ObjectEvents, + ObjectEvents::BoundsChanged +); +impl_try_from_event_for_user_facing_type!( + BoundsChangedEvent, + ObjectEvents::BoundsChanged, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + LinkSelectedEvent, + ObjectEvents, + ObjectEvents::LinkSelected +); +impl_try_from_event_for_user_facing_type!( + LinkSelectedEvent, + ObjectEvents::LinkSelected, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + StateChangedEvent, + ObjectEvents, + ObjectEvents::StateChanged +); +impl_try_from_event_for_user_facing_type!( + StateChangedEvent, + ObjectEvents::StateChanged, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + ChildrenChangedEvent, + ObjectEvents, + ObjectEvents::ChildrenChanged +); +impl_try_from_event_for_user_facing_type!( + ChildrenChangedEvent, + ObjectEvents::ChildrenChanged, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + VisibleDataChangedEvent, + ObjectEvents, + ObjectEvents::VisibleDataChanged +); +impl_try_from_event_for_user_facing_type!( + VisibleDataChangedEvent, + ObjectEvents::VisibleDataChanged, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + SelectionChangedEvent, + ObjectEvents, + ObjectEvents::SelectionChanged +); +impl_try_from_event_for_user_facing_type!( + SelectionChangedEvent, + ObjectEvents::SelectionChanged, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + ModelChangedEvent, + ObjectEvents, + ObjectEvents::ModelChanged +); +impl_try_from_event_for_user_facing_type!( + ModelChangedEvent, + ObjectEvents::ModelChanged, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + ActiveDescendantChangedEvent, + ObjectEvents, + ObjectEvents::ActiveDescendantChanged +); +impl_try_from_event_for_user_facing_type!( + ActiveDescendantChangedEvent, + ObjectEvents::ActiveDescendantChanged, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + AnnouncementEvent, + ObjectEvents, + ObjectEvents::Announcement +); +impl_try_from_event_for_user_facing_type!( + AnnouncementEvent, + ObjectEvents::Announcement, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + ObjectAttributesChangedEvent, + ObjectEvents, + ObjectEvents::AttributesChanged +); +impl_try_from_event_for_user_facing_type!( + ObjectAttributesChangedEvent, + ObjectEvents::AttributesChanged, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + RowInsertedEvent, + ObjectEvents, + ObjectEvents::RowInserted +); +impl_try_from_event_for_user_facing_type!( + RowInsertedEvent, + ObjectEvents::RowInserted, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + RowReorderedEvent, + ObjectEvents, + ObjectEvents::RowReordered +); +impl_try_from_event_for_user_facing_type!( + RowReorderedEvent, + ObjectEvents::RowReordered, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + RowDeletedEvent, + ObjectEvents, + ObjectEvents::RowDeleted +); +impl_try_from_event_for_user_facing_type!(RowDeletedEvent, ObjectEvents::RowDeleted, Event::Object); +impl_from_user_facing_event_for_interface_event_enum!( + ColumnInsertedEvent, + ObjectEvents, + ObjectEvents::ColumnInserted +); +impl_try_from_event_for_user_facing_type!( + ColumnInsertedEvent, + ObjectEvents::ColumnInserted, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + ColumnReorderedEvent, + ObjectEvents, + ObjectEvents::ColumnReordered +); +impl_try_from_event_for_user_facing_type!( + ColumnReorderedEvent, + ObjectEvents::ColumnReordered, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + ColumnDeletedEvent, + ObjectEvents, + ObjectEvents::ColumnDeleted +); +impl_try_from_event_for_user_facing_type!( + ColumnDeletedEvent, + ObjectEvents::ColumnDeleted, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + TextBoundsChangedEvent, + ObjectEvents, + ObjectEvents::TextBoundsChanged +); +impl_try_from_event_for_user_facing_type!( + TextBoundsChangedEvent, + ObjectEvents::TextBoundsChanged, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + TextSelectionChangedEvent, + ObjectEvents, + ObjectEvents::TextSelectionChanged +); +impl_try_from_event_for_user_facing_type!( + TextSelectionChangedEvent, + ObjectEvents::TextSelectionChanged, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + TextAttributesChangedEvent, + ObjectEvents, + ObjectEvents::TextAttributesChanged +); +impl_try_from_event_for_user_facing_type!( + TextAttributesChangedEvent, + ObjectEvents::TextAttributesChanged, + Event::Object +); +impl_from_user_facing_event_for_interface_event_enum!( + TextCaretMovedEvent, + ObjectEvents, + ObjectEvents::TextCaretMoved +); +impl_try_from_event_for_user_facing_type!( + TextCaretMovedEvent, + ObjectEvents::TextCaretMoved, + Event::Object +); + +impl DBusMatchRule for ObjectEvents { + const MATCH_RULE_STRING: &'static str = "type='signal',interface='org.a11y.atspi.Event.Object'"; +} + +impl DBusInterface for ObjectEvents { + const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Object"; +} + +impl RegistryEventString for ObjectEvents { + const REGISTRY_EVENT_STRING: &'static str = "object:"; +} + +#[cfg(feature = "zbus")] +impl EventWrapperMessageConversion for ObjectEvents { + fn try_from_message_interface_checked( + msg: &zbus::Message, + hdr: &Header, + ) -> Result { + let member = hdr.member().ok_or(AtspiError::MissingMember)?; + match member.as_str() { + ObjectPropertyChangeEvent::DBUS_MEMBER => Ok(ObjectEvents::PropertyChange( + ObjectPropertyChangeEvent::from_message_unchecked(msg, hdr)?, + )), + BoundsChangedEvent::DBUS_MEMBER => Ok(ObjectEvents::BoundsChanged( + BoundsChangedEvent::from_message_unchecked(msg, hdr)?, + )), + LinkSelectedEvent::DBUS_MEMBER => { + Ok(ObjectEvents::LinkSelected(LinkSelectedEvent::from_message_unchecked(msg, hdr)?)) + } + StateChangedEvent::DBUS_MEMBER => { + Ok(ObjectEvents::StateChanged(StateChangedEvent::from_message_unchecked(msg, hdr)?)) + } + ChildrenChangedEvent::DBUS_MEMBER => Ok(ObjectEvents::ChildrenChanged( + ChildrenChangedEvent::from_message_unchecked(msg, hdr)?, + )), + VisibleDataChangedEvent::DBUS_MEMBER => Ok(ObjectEvents::VisibleDataChanged( + VisibleDataChangedEvent::from_message_unchecked(msg, hdr)?, + )), + SelectionChangedEvent::DBUS_MEMBER => Ok(ObjectEvents::SelectionChanged( + SelectionChangedEvent::from_message_unchecked(msg, hdr)?, + )), + ModelChangedEvent::DBUS_MEMBER => { + Ok(ObjectEvents::ModelChanged(ModelChangedEvent::from_message_unchecked(msg, hdr)?)) + } + ActiveDescendantChangedEvent::DBUS_MEMBER => Ok(ObjectEvents::ActiveDescendantChanged( + ActiveDescendantChangedEvent::from_message_unchecked(msg, hdr)?, + )), + AnnouncementEvent::DBUS_MEMBER => { + Ok(ObjectEvents::Announcement(AnnouncementEvent::from_message_unchecked(msg, hdr)?)) + } + ObjectAttributesChangedEvent::DBUS_MEMBER => Ok(ObjectEvents::AttributesChanged( + ObjectAttributesChangedEvent::from_message_unchecked(msg, hdr)?, + )), + RowInsertedEvent::DBUS_MEMBER => { + Ok(ObjectEvents::RowInserted(RowInsertedEvent::from_message_unchecked(msg, hdr)?)) + } + RowReorderedEvent::DBUS_MEMBER => { + Ok(ObjectEvents::RowReordered(RowReorderedEvent::from_message_unchecked(msg, hdr)?)) + } + RowDeletedEvent::DBUS_MEMBER => { + Ok(ObjectEvents::RowDeleted(RowDeletedEvent::from_message_unchecked(msg, hdr)?)) + } + ColumnInsertedEvent::DBUS_MEMBER => Ok(ObjectEvents::ColumnInserted( + ColumnInsertedEvent::from_message_unchecked(msg, hdr)?, + )), + ColumnReorderedEvent::DBUS_MEMBER => Ok(ObjectEvents::ColumnReordered( + ColumnReorderedEvent::from_message_unchecked(msg, hdr)?, + )), + ColumnDeletedEvent::DBUS_MEMBER => Ok(ObjectEvents::ColumnDeleted( + ColumnDeletedEvent::from_message_unchecked(msg, hdr)?, + )), + TextBoundsChangedEvent::DBUS_MEMBER => Ok(ObjectEvents::TextBoundsChanged( + TextBoundsChangedEvent::from_message_unchecked(msg, hdr)?, + )), + TextSelectionChangedEvent::DBUS_MEMBER => Ok(ObjectEvents::TextSelectionChanged( + TextSelectionChangedEvent::from_message_unchecked(msg, hdr)?, + )), + TextChangedEvent::DBUS_MEMBER => { + Ok(ObjectEvents::TextChanged(TextChangedEvent::from_message_unchecked(msg, hdr)?)) + } + TextAttributesChangedEvent::DBUS_MEMBER => Ok(ObjectEvents::TextAttributesChanged( + TextAttributesChangedEvent::from_message_unchecked(msg, hdr)?, + )), + TextCaretMovedEvent::DBUS_MEMBER => Ok(ObjectEvents::TextCaretMoved( + TextCaretMovedEvent::from_message_unchecked(msg, hdr)?, + )), + _ => Err(AtspiError::MemberMatch(format!( + "No matching member {member} for interface {}", + Self::DBUS_INTERFACE, + ))), + } + } +} + +#[cfg(feature = "zbus")] +impl TryFrom<&zbus::Message> for ObjectEvents { + type Error = AtspiError; + fn try_from(msg: &zbus::Message) -> Result { + Self::try_from_message(msg) + } +} + +/// All events related to the `org.a11y.atspi.Cache` interface. +/// Note that these are not telling the client that an item *has been added* to a cache. +/// It is telling the client "here is a bunch of information to store it in your cache". +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq, Hash)] +#[allow(clippy::module_name_repetitions)] +pub enum CacheEvents { + /// See: [`AddAccessibleEvent`]. + Add(AddAccessibleEvent), + /// See: [`LegacyAddAccessibleEvent`]. + LegacyAdd(LegacyAddAccessibleEvent), + /// See: [`RemoveAccessibleEvent`]. + Remove(RemoveAccessibleEvent), +} + +impl_from_user_facing_type_for_event_enum!(RemoveAccessibleEvent, Event::Cache); +impl_from_user_facing_type_for_event_enum!(AddAccessibleEvent, Event::Cache); +impl_from_user_facing_type_for_event_enum!(LegacyAddAccessibleEvent, Event::Cache); + +impl DBusMatchRule for CacheEvents { + const MATCH_RULE_STRING: &'static str = "type='signal',interface='org.a11y.atspi.Cache'"; +} + +impl RegistryEventString for CacheEvents { + const REGISTRY_EVENT_STRING: &'static str = "Cache"; +} + +impl DBusInterface for CacheEvents { + const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Cache"; +} + +impl EventTypeProperties for CacheEvents { + fn member(&self) -> &'static str { + match self { + Self::Add(inner) => inner.member(), + Self::LegacyAdd(inner) => inner.member(), + Self::Remove(inner) => inner.member(), + } + } + fn interface(&self) -> &'static str { + match self { + Self::Add(inner) => inner.interface(), + Self::LegacyAdd(inner) => inner.interface(), + Self::Remove(inner) => inner.interface(), + } + } + fn match_rule(&self) -> &'static str { + match self { + Self::Add(inner) => inner.match_rule(), + Self::LegacyAdd(inner) => inner.match_rule(), + Self::Remove(inner) => inner.match_rule(), + } + } + fn registry_string(&self) -> &'static str { + match self { + Self::Add(inner) => inner.registry_string(), + Self::LegacyAdd(inner) => inner.registry_string(), + Self::Remove(inner) => inner.registry_string(), + } + } +} + +impl EventProperties for CacheEvents { + fn path(&self) -> ObjectPath<'_> { + match self { + Self::Add(inner) => inner.path(), + Self::LegacyAdd(inner) => inner.path(), + Self::Remove(inner) => inner.path(), + } + } + fn sender(&self) -> UniqueName<'_> { + match self { + Self::Add(inner) => inner.sender(), + Self::LegacyAdd(inner) => inner.sender(), + Self::Remove(inner) => inner.sender(), + } + } +} + +#[cfg(feature = "zbus")] +impl EventWrapperMessageConversion for CacheEvents { + fn try_from_message_interface_checked( + msg: &zbus::Message, + hdr: &Header, + ) -> Result { + let member = hdr.member().ok_or(AtspiError::MissingMember)?; + match member.as_str() { + AddAccessibleEvent::DBUS_MEMBER => { + let body = msg.body(); + let sig = body.signature(); + if sig == CacheItem::SIGNATURE { + Ok(CacheEvents::Add(AddAccessibleEvent::from_message_unchecked(msg, hdr)?)) + } else if sig == LegacyCacheItem::SIGNATURE { + Ok(CacheEvents::LegacyAdd(LegacyAddAccessibleEvent::from_message_unchecked( + msg, hdr, + )?)) + } else { + Err(AtspiError::SignatureMatch(format!( + "No matching event for signature {} in interface {}", + &sig.to_string(), + Self::DBUS_INTERFACE + ))) + } + } + RemoveAccessibleEvent::DBUS_MEMBER => { + Ok(CacheEvents::Remove(RemoveAccessibleEvent::from_message_unchecked(msg, hdr)?)) + } + _ => Err(AtspiError::MemberMatch(format!( + "No member {} in {}", + member.as_str(), + Self::DBUS_INTERFACE + ))), + } + } +} + +impl_tryfrommessage_for_event_wrapper!(CacheEvents); + +#[cfg(feature = "zbus")] +impl TryFrom<&zbus::Message> for CacheEvents { + type Error = AtspiError; + fn try_from(msg: &zbus::Message) -> Result { + Self::try_from_message(msg) + } +} + +impl_from_user_facing_event_for_interface_event_enum!( + LegacyAddAccessibleEvent, + CacheEvents, + CacheEvents::LegacyAdd +); +impl_try_from_event_for_user_facing_type!( + LegacyAddAccessibleEvent, + CacheEvents::LegacyAdd, + Event::Cache +); +impl_from_user_facing_event_for_interface_event_enum!( + AddAccessibleEvent, + CacheEvents, + CacheEvents::Add +); +impl_try_from_event_for_user_facing_type!(AddAccessibleEvent, CacheEvents::Add, Event::Cache); +impl_from_user_facing_event_for_interface_event_enum!( + RemoveAccessibleEvent, + CacheEvents, + CacheEvents::Remove +); +impl_try_from_event_for_user_facing_type!(RemoveAccessibleEvent, CacheEvents::Remove, Event::Cache); +impl_try_from_event_for_interface_enum!(CacheEvents, Event::Cache); + +#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)] +pub enum FocusEvents { + /// See: [`FocusEvent`]. + Focus(FocusEvent), +} + +impl_tryfrommessage_for_event_wrapper!(FocusEvents); + +#[cfg(feature = "zbus")] +impl TryFrom<&zbus::Message> for FocusEvents { + type Error = AtspiError; + fn try_from(msg: &zbus::Message) -> Result { + Self::try_from_message(msg) + } +} + +impl_from_interface_event_enum_for_event!(FocusEvents, Event::Focus); +impl_try_from_event_for_user_facing_type!(FocusEvent, FocusEvents::Focus, Event::Focus); + +impl EventTypeProperties for FocusEvents { + fn member(&self) -> &'static str { + match self { + Self::Focus(inner) => inner.member(), + } + } + fn match_rule(&self) -> &'static str { + match self { + Self::Focus(inner) => inner.match_rule(), + } + } + fn interface(&self) -> &'static str { + match self { + Self::Focus(inner) => inner.interface(), + } + } + fn registry_string(&self) -> &'static str { + match self { + Self::Focus(inner) => inner.registry_string(), + } + } +} + +impl EventProperties for FocusEvents { + fn path(&self) -> ObjectPath<'_> { + match self { + Self::Focus(inner) => inner.path(), + } + } + fn sender(&self) -> UniqueName<'_> { + match self { + Self::Focus(inner) => inner.sender(), + } + } +} + +impl_try_from_event_for_interface_enum!(FocusEvents, Event::Focus); + +impl_from_user_facing_event_for_interface_event_enum!(FocusEvent, FocusEvents, FocusEvents::Focus); +impl_from_user_facing_type_for_event_enum!(FocusEvent, Event::Focus); +event_wrapper_test_cases!(FocusEvents, FocusEvent); + +#[cfg(feature = "zbus")] +impl EventWrapperMessageConversion for FocusEvents { + fn try_from_message_interface_checked( + msg: &zbus::Message, + hdr: &Header, + ) -> Result { + let member = hdr.member().ok_or(AtspiError::MissingMember)?; + match member.as_str() { + FocusEvent::DBUS_MEMBER => { + Ok(FocusEvents::Focus(FocusEvent::from_message_unchecked(msg, hdr)?)) + } + _ => Err(AtspiError::MemberMatch(format!( + "No matching member {member} for interface {}", + Self::DBUS_INTERFACE, + ))), + } + } +} + +impl DBusMatchRule for FocusEvents { + const MATCH_RULE_STRING: &'static str = "type='signal',interface='org.a11y.atspi.Event.Focus'"; +} + +impl RegistryEventString for FocusEvents { + const REGISTRY_EVENT_STRING: &'static str = "focus:"; +} + +impl DBusInterface for FocusEvents { + const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Focus"; +} + +/// All events related to the `org.a11y.atspi.Event.Terminal` interface. +#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)] +pub enum TerminalEvents { + /// See: [`LineChangedEvent`]. + LineChanged(LineChangedEvent), + /// See: [`ColumnCountChangedEvent`]. + ColumnCountChanged(ColumnCountChangedEvent), + /// See: [`LineCountChangedEvent`]. + LineCountChanged(LineCountChangedEvent), + /// See: [`ApplicationChangedEvent`]. + ApplicationChanged(ApplicationChangedEvent), + /// See: [`CharWidthChangedEvent`]. + CharWidthChanged(CharWidthChangedEvent), +} + +impl_tryfrommessage_for_event_wrapper!(TerminalEvents); + +impl EventTypeProperties for TerminalEvents { + fn member(&self) -> &'static str { + match self { + Self::LineChanged(inner) => inner.member(), + Self::ColumnCountChanged(inner) => inner.member(), + Self::LineCountChanged(inner) => inner.member(), + Self::ApplicationChanged(inner) => inner.member(), + Self::CharWidthChanged(inner) => inner.member(), + } + } + fn interface(&self) -> &'static str { + match self { + Self::LineChanged(inner) => inner.interface(), + Self::ColumnCountChanged(inner) => inner.interface(), + Self::LineCountChanged(inner) => inner.interface(), + Self::ApplicationChanged(inner) => inner.interface(), + Self::CharWidthChanged(inner) => inner.interface(), + } + } + fn match_rule(&self) -> &'static str { + match self { + Self::LineChanged(inner) => inner.match_rule(), + Self::ColumnCountChanged(inner) => inner.match_rule(), + Self::LineCountChanged(inner) => inner.match_rule(), + Self::ApplicationChanged(inner) => inner.match_rule(), + Self::CharWidthChanged(inner) => inner.match_rule(), + } + } + fn registry_string(&self) -> &'static str { + match self { + Self::LineChanged(inner) => inner.registry_string(), + Self::ColumnCountChanged(inner) => inner.registry_string(), + Self::LineCountChanged(inner) => inner.registry_string(), + Self::ApplicationChanged(inner) => inner.registry_string(), + Self::CharWidthChanged(inner) => inner.registry_string(), + } + } +} + +impl EventProperties for TerminalEvents { + fn path(&self) -> ObjectPath<'_> { + match self { + Self::LineChanged(inner) => inner.path(), + Self::ColumnCountChanged(inner) => inner.path(), + Self::LineCountChanged(inner) => inner.path(), + Self::ApplicationChanged(inner) => inner.path(), + Self::CharWidthChanged(inner) => inner.path(), + } + } + fn sender(&self) -> UniqueName<'_> { + match self { + Self::LineChanged(inner) => inner.sender(), + Self::ColumnCountChanged(inner) => inner.sender(), + Self::LineCountChanged(inner) => inner.sender(), + Self::ApplicationChanged(inner) => inner.sender(), + Self::CharWidthChanged(inner) => inner.sender(), + } + } +} + +impl_from_user_facing_type_for_event_enum!(CharWidthChangedEvent, Event::Terminal); +impl_from_user_facing_type_for_event_enum!(ApplicationChangedEvent, Event::Terminal); +impl_from_user_facing_type_for_event_enum!(LineCountChangedEvent, Event::Terminal); +impl_from_user_facing_type_for_event_enum!(ColumnCountChangedEvent, Event::Terminal); +impl_from_user_facing_type_for_event_enum!(LineChangedEvent, Event::Terminal); + +impl_try_from_event_for_interface_enum!(TerminalEvents, Event::Terminal); +impl_from_interface_event_enum_for_event!(TerminalEvents, Event::Terminal); + +event_wrapper_test_cases!(TerminalEvents, LineChangedEvent); + +impl DBusMatchRule for TerminalEvents { + const MATCH_RULE_STRING: &'static str = + "type='signal',interface='org.a11y.atspi.Event.Terminal'"; +} + +impl RegistryEventString for TerminalEvents { + const REGISTRY_EVENT_STRING: &'static str = "terminal:"; +} + +impl DBusInterface for TerminalEvents { + const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Terminal"; +} + +#[cfg(feature = "zbus")] +impl EventWrapperMessageConversion for TerminalEvents { + fn try_from_message_interface_checked( + msg: &zbus::Message, + hdr: &Header, + ) -> Result { + let member = hdr + .member() + .ok_or(AtspiError::MemberMatch("Event without member".into()))?; + match member.as_str() { + LineChangedEvent::DBUS_MEMBER => { + Ok(TerminalEvents::LineChanged(LineChangedEvent::from_message_unchecked(msg, hdr)?)) + } + ColumnCountChangedEvent::DBUS_MEMBER => Ok(TerminalEvents::ColumnCountChanged( + ColumnCountChangedEvent::from_message_unchecked(msg, hdr)?, + )), + LineCountChangedEvent::DBUS_MEMBER => Ok(TerminalEvents::LineCountChanged( + LineCountChangedEvent::from_message_unchecked(msg, hdr)?, + )), + ApplicationChangedEvent::DBUS_MEMBER => Ok(TerminalEvents::ApplicationChanged( + ApplicationChangedEvent::from_message_unchecked(msg, hdr)?, + )), + CharWidthChangedEvent::DBUS_MEMBER => Ok(TerminalEvents::CharWidthChanged( + CharWidthChangedEvent::from_message_unchecked(msg, hdr)?, + )), + _ => Err(AtspiError::MemberMatch("No matching member for Terminal".into())), + } + } +} + +#[cfg(feature = "zbus")] +impl TryFrom<&zbus::Message> for TerminalEvents { + type Error = AtspiError; + fn try_from(msg: &zbus::Message) -> Result { + Self::try_from_message(msg) + } +} + +impl_from_user_facing_event_for_interface_event_enum!( + LineChangedEvent, + TerminalEvents, + TerminalEvents::LineChanged +); +impl_try_from_event_for_user_facing_type!( + LineChangedEvent, + TerminalEvents::LineChanged, + Event::Terminal +); +impl_from_user_facing_event_for_interface_event_enum!( + ColumnCountChangedEvent, + TerminalEvents, + TerminalEvents::ColumnCountChanged +); +impl_try_from_event_for_user_facing_type!( + ColumnCountChangedEvent, + TerminalEvents::ColumnCountChanged, + Event::Terminal +); +impl_from_user_facing_event_for_interface_event_enum!( + LineCountChangedEvent, + TerminalEvents, + TerminalEvents::LineCountChanged +); +impl_try_from_event_for_user_facing_type!( + LineCountChangedEvent, + TerminalEvents::LineCountChanged, + Event::Terminal +); +impl_from_user_facing_event_for_interface_event_enum!( + ApplicationChangedEvent, + TerminalEvents, + TerminalEvents::ApplicationChanged +); +impl_try_from_event_for_user_facing_type!( + ApplicationChangedEvent, + TerminalEvents::ApplicationChanged, + Event::Terminal +); +impl_from_user_facing_event_for_interface_event_enum!( + CharWidthChangedEvent, + TerminalEvents, + TerminalEvents::CharWidthChanged +); +impl_try_from_event_for_user_facing_type!( + CharWidthChangedEvent, + TerminalEvents::CharWidthChanged, + Event::Terminal +); + +/// All events on the `org.a11y.atspi.Event.Window` interface. +#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)] +pub enum WindowEvents { + /// See: [`WindowPropertyChangeEvent`]. + PropertyChange(WindowPropertyChangeEvent), + /// See: [`MinimizeEvent`]. + Minimize(MinimizeEvent), + /// See: [`MaximizeEvent`]. + Maximize(MaximizeEvent), + /// See: [`RestoreEvent`]. + Restore(RestoreEvent), + /// See: [`CloseEvent`]. + Close(CloseEvent), + /// See: [`CreateEvent`]. + Create(CreateEvent), + /// See: [`ReparentEvent`]. + Reparent(ReparentEvent), + /// See: [`DesktopCreateEvent`]. + DesktopCreate(DesktopCreateEvent), + /// See: [`DesktopDestroyEvent`]. + DesktopDestroy(DesktopDestroyEvent), + /// See: [`DestroyEvent`]. + Destroy(DestroyEvent), + /// See: [`ActivateEvent`]. + Activate(ActivateEvent), + /// See: [`DeactivateEvent`]. + Deactivate(DeactivateEvent), + /// See: [`RaiseEvent`]. + Raise(RaiseEvent), + /// See: [`LowerEvent`]. + Lower(LowerEvent), + /// See: [`MoveEvent`]. + Move(MoveEvent), + /// See: [`ResizeEvent`]. + Resize(ResizeEvent), + /// See: [`ShadeEvent`]. + Shade(ShadeEvent), + /// See: [`UUshadeEvent`]. + UUshade(UUshadeEvent), + /// See: [`RestyleEvent`]. + Restyle(RestyleEvent), +} + +impl_tryfrommessage_for_event_wrapper!(WindowEvents); + +impl EventTypeProperties for WindowEvents { + fn member(&self) -> &'static str { + match self { + Self::PropertyChange(inner) => inner.member(), + Self::Minimize(inner) => inner.member(), + Self::Maximize(inner) => inner.member(), + Self::Restore(inner) => inner.member(), + Self::Close(inner) => inner.member(), + Self::Create(inner) => inner.member(), + Self::Reparent(inner) => inner.member(), + Self::DesktopCreate(inner) => inner.member(), + Self::DesktopDestroy(inner) => inner.member(), + Self::Destroy(inner) => inner.member(), + Self::Activate(inner) => inner.member(), + Self::Deactivate(inner) => inner.member(), + Self::Raise(inner) => inner.member(), + Self::Lower(inner) => inner.member(), + Self::Move(inner) => inner.member(), + Self::Resize(inner) => inner.member(), + Self::Shade(inner) => inner.member(), + Self::UUshade(inner) => inner.member(), + Self::Restyle(inner) => inner.member(), + } + } + fn interface(&self) -> &'static str { + match self { + Self::PropertyChange(inner) => inner.interface(), + Self::Minimize(inner) => inner.interface(), + Self::Maximize(inner) => inner.interface(), + Self::Restore(inner) => inner.interface(), + Self::Close(inner) => inner.interface(), + Self::Create(inner) => inner.interface(), + Self::Reparent(inner) => inner.interface(), + Self::DesktopCreate(inner) => inner.interface(), + Self::DesktopDestroy(inner) => inner.interface(), + Self::Destroy(inner) => inner.interface(), + Self::Activate(inner) => inner.interface(), + Self::Deactivate(inner) => inner.interface(), + Self::Raise(inner) => inner.interface(), + Self::Lower(inner) => inner.interface(), + Self::Move(inner) => inner.interface(), + Self::Resize(inner) => inner.interface(), + Self::Shade(inner) => inner.interface(), + Self::UUshade(inner) => inner.interface(), + Self::Restyle(inner) => inner.interface(), + } + } + fn match_rule(&self) -> &'static str { + match self { + Self::PropertyChange(inner) => inner.match_rule(), + Self::Minimize(inner) => inner.match_rule(), + Self::Maximize(inner) => inner.match_rule(), + Self::Restore(inner) => inner.match_rule(), + Self::Close(inner) => inner.match_rule(), + Self::Create(inner) => inner.match_rule(), + Self::Reparent(inner) => inner.match_rule(), + Self::DesktopCreate(inner) => inner.match_rule(), + Self::DesktopDestroy(inner) => inner.match_rule(), + Self::Destroy(inner) => inner.match_rule(), + Self::Activate(inner) => inner.match_rule(), + Self::Deactivate(inner) => inner.match_rule(), + Self::Raise(inner) => inner.match_rule(), + Self::Lower(inner) => inner.match_rule(), + Self::Move(inner) => inner.match_rule(), + Self::Resize(inner) => inner.match_rule(), + Self::Shade(inner) => inner.match_rule(), + Self::UUshade(inner) => inner.match_rule(), + Self::Restyle(inner) => inner.match_rule(), + } + } + fn registry_string(&self) -> &'static str { + match self { + Self::PropertyChange(inner) => inner.registry_string(), + Self::Minimize(inner) => inner.registry_string(), + Self::Maximize(inner) => inner.registry_string(), + Self::Restore(inner) => inner.registry_string(), + Self::Close(inner) => inner.registry_string(), + Self::Create(inner) => inner.registry_string(), + Self::Reparent(inner) => inner.registry_string(), + Self::DesktopCreate(inner) => inner.registry_string(), + Self::DesktopDestroy(inner) => inner.registry_string(), + Self::Destroy(inner) => inner.registry_string(), + Self::Activate(inner) => inner.registry_string(), + Self::Deactivate(inner) => inner.registry_string(), + Self::Raise(inner) => inner.registry_string(), + Self::Lower(inner) => inner.registry_string(), + Self::Move(inner) => inner.registry_string(), + Self::Resize(inner) => inner.registry_string(), + Self::Shade(inner) => inner.registry_string(), + Self::UUshade(inner) => inner.registry_string(), + Self::Restyle(inner) => inner.registry_string(), + } + } +} + +impl EventProperties for WindowEvents { + fn path(&self) -> ObjectPath<'_> { + match self { + Self::PropertyChange(inner) => inner.path(), + Self::Minimize(inner) => inner.path(), + Self::Maximize(inner) => inner.path(), + Self::Restore(inner) => inner.path(), + Self::Close(inner) => inner.path(), + Self::Create(inner) => inner.path(), + Self::Reparent(inner) => inner.path(), + Self::DesktopCreate(inner) => inner.path(), + Self::DesktopDestroy(inner) => inner.path(), + Self::Destroy(inner) => inner.path(), + Self::Activate(inner) => inner.path(), + Self::Deactivate(inner) => inner.path(), + Self::Raise(inner) => inner.path(), + Self::Lower(inner) => inner.path(), + Self::Move(inner) => inner.path(), + Self::Resize(inner) => inner.path(), + Self::Shade(inner) => inner.path(), + Self::UUshade(inner) => inner.path(), + Self::Restyle(inner) => inner.path(), + } + } + fn sender(&self) -> UniqueName<'_> { + match self { + Self::PropertyChange(inner) => inner.sender(), + Self::Minimize(inner) => inner.sender(), + Self::Maximize(inner) => inner.sender(), + Self::Restore(inner) => inner.sender(), + Self::Close(inner) => inner.sender(), + Self::Create(inner) => inner.sender(), + Self::Reparent(inner) => inner.sender(), + Self::DesktopCreate(inner) => inner.sender(), + Self::DesktopDestroy(inner) => inner.sender(), + Self::Destroy(inner) => inner.sender(), + Self::Activate(inner) => inner.sender(), + Self::Deactivate(inner) => inner.sender(), + Self::Raise(inner) => inner.sender(), + Self::Lower(inner) => inner.sender(), + Self::Move(inner) => inner.sender(), + Self::Resize(inner) => inner.sender(), + Self::Shade(inner) => inner.sender(), + Self::UUshade(inner) => inner.sender(), + Self::Restyle(inner) => inner.sender(), + } + } +} + +impl_from_user_facing_type_for_event_enum!(ReparentEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(CloseEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(RestoreEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(MaximizeEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(MinimizeEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(WindowPropertyChangeEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(RestyleEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(UUshadeEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(ShadeEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(ResizeEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(MoveEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(LowerEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(RaiseEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(DeactivateEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(ActivateEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(DestroyEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(DesktopDestroyEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(DesktopCreateEvent, Event::Window); +impl_from_user_facing_type_for_event_enum!(CreateEvent, Event::Window); + +impl_try_from_event_for_interface_enum!(WindowEvents, Event::Window); +impl_from_interface_event_enum_for_event!(WindowEvents, Event::Window); + +event_wrapper_test_cases!(WindowEvents, MoveEvent); + +impl DBusMatchRule for WindowEvents { + const MATCH_RULE_STRING: &'static str = "type='signal',interface='org.a11y.atspi.Event.Window'"; +} + +impl DBusInterface for WindowEvents { + const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Window"; +} + +impl RegistryEventString for WindowEvents { + const REGISTRY_EVENT_STRING: &'static str = "window:"; +} + +#[cfg(feature = "zbus")] +impl EventWrapperMessageConversion for WindowEvents { + fn try_from_message_interface_checked( + msg: &zbus::Message, + hdr: &Header, + ) -> Result { + let member = hdr.member().ok_or(AtspiError::MissingMember)?; + match member.as_str() { + WindowPropertyChangeEvent::DBUS_MEMBER => Ok(WindowEvents::PropertyChange( + WindowPropertyChangeEvent::from_message_unchecked(msg, hdr)?, + )), + MinimizeEvent::DBUS_MEMBER => { + Ok(WindowEvents::Minimize(MinimizeEvent::from_message_unchecked(msg, hdr)?)) + } + MaximizeEvent::DBUS_MEMBER => { + Ok(WindowEvents::Maximize(MaximizeEvent::from_message_unchecked(msg, hdr)?)) + } + RestoreEvent::DBUS_MEMBER => { + Ok(WindowEvents::Restore(RestoreEvent::from_message_unchecked(msg, hdr)?)) + } + CloseEvent::DBUS_MEMBER => { + Ok(WindowEvents::Close(CloseEvent::from_message_unchecked(msg, hdr)?)) + } + CreateEvent::DBUS_MEMBER => { + Ok(WindowEvents::Create(CreateEvent::from_message_unchecked(msg, hdr)?)) + } + ReparentEvent::DBUS_MEMBER => { + Ok(WindowEvents::Reparent(ReparentEvent::from_message_unchecked(msg, hdr)?)) + } + DesktopCreateEvent::DBUS_MEMBER => Ok(WindowEvents::DesktopCreate( + DesktopCreateEvent::from_message_unchecked(msg, hdr)?, + )), + DesktopDestroyEvent::DBUS_MEMBER => Ok(WindowEvents::DesktopDestroy( + DesktopDestroyEvent::from_message_unchecked(msg, hdr)?, + )), + DestroyEvent::DBUS_MEMBER => { + Ok(WindowEvents::Destroy(DestroyEvent::from_message_unchecked(msg, hdr)?)) + } + ActivateEvent::DBUS_MEMBER => { + Ok(WindowEvents::Activate(ActivateEvent::from_message_unchecked(msg, hdr)?)) + } + DeactivateEvent::DBUS_MEMBER => { + Ok(WindowEvents::Deactivate(DeactivateEvent::from_message_unchecked(msg, hdr)?)) + } + RaiseEvent::DBUS_MEMBER => { + Ok(WindowEvents::Raise(RaiseEvent::from_message_unchecked(msg, hdr)?)) + } + LowerEvent::DBUS_MEMBER => { + Ok(WindowEvents::Lower(LowerEvent::from_message_unchecked(msg, hdr)?)) + } + MoveEvent::DBUS_MEMBER => { + Ok(WindowEvents::Move(MoveEvent::from_message_unchecked(msg, hdr)?)) + } + ResizeEvent::DBUS_MEMBER => { + Ok(WindowEvents::Resize(ResizeEvent::from_message_unchecked(msg, hdr)?)) + } + ShadeEvent::DBUS_MEMBER => { + Ok(WindowEvents::Shade(ShadeEvent::from_message_unchecked(msg, hdr)?)) + } + UUshadeEvent::DBUS_MEMBER => { + Ok(WindowEvents::UUshade(UUshadeEvent::from_message_unchecked(msg, hdr)?)) + } + RestyleEvent::DBUS_MEMBER => { + Ok(WindowEvents::Restyle(RestyleEvent::from_message_unchecked(msg, hdr)?)) + } + _ => Err(AtspiError::MemberMatch("No matching member for Window".into())), + } + } +} + +#[cfg(feature = "zbus")] +impl TryFrom<&zbus::Message> for WindowEvents { + type Error = AtspiError; + fn try_from(msg: &zbus::Message) -> Result { + Self::try_from_message(msg) + } +} + +impl_from_user_facing_event_for_interface_event_enum!( + WindowPropertyChangeEvent, + WindowEvents, + WindowEvents::PropertyChange +); +impl_try_from_event_for_user_facing_type!( + WindowPropertyChangeEvent, + WindowEvents::PropertyChange, + Event::Window +); +impl_from_user_facing_event_for_interface_event_enum!( + MinimizeEvent, + WindowEvents, + WindowEvents::Minimize +); +impl_try_from_event_for_user_facing_type!(MinimizeEvent, WindowEvents::Minimize, Event::Window); +impl_from_user_facing_event_for_interface_event_enum!( + MaximizeEvent, + WindowEvents, + WindowEvents::Maximize +); +impl_try_from_event_for_user_facing_type!(MaximizeEvent, WindowEvents::Maximize, Event::Window); +impl_from_user_facing_event_for_interface_event_enum!( + RestoreEvent, + WindowEvents, + WindowEvents::Restore +); +impl_try_from_event_for_user_facing_type!(RestoreEvent, WindowEvents::Restore, Event::Window); +impl_from_user_facing_event_for_interface_event_enum!( + CloseEvent, + WindowEvents, + WindowEvents::Close +); +impl_try_from_event_for_user_facing_type!(CloseEvent, WindowEvents::Close, Event::Window); +impl_from_user_facing_event_for_interface_event_enum!( + CreateEvent, + WindowEvents, + WindowEvents::Create +); +impl_try_from_event_for_user_facing_type!(CreateEvent, WindowEvents::Create, Event::Window); +impl_from_user_facing_event_for_interface_event_enum!( + ReparentEvent, + WindowEvents, + WindowEvents::Reparent +); +impl_try_from_event_for_user_facing_type!(ReparentEvent, WindowEvents::Reparent, Event::Window); +impl_from_user_facing_event_for_interface_event_enum!( + DesktopCreateEvent, + WindowEvents, + WindowEvents::DesktopCreate +); +impl_try_from_event_for_user_facing_type!( + DesktopCreateEvent, + WindowEvents::DesktopCreate, + Event::Window +); +impl_from_user_facing_event_for_interface_event_enum!( + DesktopDestroyEvent, + WindowEvents, + WindowEvents::DesktopDestroy +); +impl_try_from_event_for_user_facing_type!( + DesktopDestroyEvent, + WindowEvents::DesktopDestroy, + Event::Window +); +impl_from_user_facing_event_for_interface_event_enum!( + DestroyEvent, + WindowEvents, + WindowEvents::Destroy +); +impl_try_from_event_for_user_facing_type!(DestroyEvent, WindowEvents::Destroy, Event::Window); +impl_from_user_facing_event_for_interface_event_enum!( + ActivateEvent, + WindowEvents, + WindowEvents::Activate +); +impl_try_from_event_for_user_facing_type!(ActivateEvent, WindowEvents::Activate, Event::Window); +impl_from_user_facing_event_for_interface_event_enum!( + DeactivateEvent, + WindowEvents, + WindowEvents::Deactivate +); +impl_try_from_event_for_user_facing_type!(DeactivateEvent, WindowEvents::Deactivate, Event::Window); +impl_from_user_facing_event_for_interface_event_enum!( + RaiseEvent, + WindowEvents, + WindowEvents::Raise +); +impl_try_from_event_for_user_facing_type!(RaiseEvent, WindowEvents::Raise, Event::Window); +impl_from_user_facing_event_for_interface_event_enum!( + LowerEvent, + WindowEvents, + WindowEvents::Lower +); +impl_try_from_event_for_user_facing_type!(LowerEvent, WindowEvents::Lower, Event::Window); +impl_from_user_facing_event_for_interface_event_enum!(MoveEvent, WindowEvents, WindowEvents::Move); +impl_try_from_event_for_user_facing_type!(MoveEvent, WindowEvents::Move, Event::Window); +impl_from_user_facing_event_for_interface_event_enum!( + ResizeEvent, + WindowEvents, + WindowEvents::Resize +); +impl_try_from_event_for_user_facing_type!(ResizeEvent, WindowEvents::Resize, Event::Window); +impl_from_user_facing_event_for_interface_event_enum!( + ShadeEvent, + WindowEvents, + WindowEvents::Shade +); +impl_try_from_event_for_user_facing_type!(ShadeEvent, WindowEvents::Shade, Event::Window); +impl_from_user_facing_event_for_interface_event_enum!( + UUshadeEvent, + WindowEvents, + WindowEvents::UUshade +); +impl_try_from_event_for_user_facing_type!(UUshadeEvent, WindowEvents::UUshade, Event::Window); +impl_from_user_facing_event_for_interface_event_enum!( + RestyleEvent, + WindowEvents, + WindowEvents::Restyle +); +impl_try_from_event_for_user_facing_type!(RestyleEvent, WindowEvents::Restyle, Event::Window); + +/// The events that can be emitted by the registry daemon. +/// This enum is used to wrap the events that are emitted by the registry daemon. +/// The events are [`EventListenerRegisteredEvent`] and [`EventListenerDeregisteredEvent`]. +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] +#[allow(clippy::module_name_repetitions)] +pub enum EventListenerEvents { + /// See: [`EventListenerRegisteredEvent`]. + Registered(EventListenerRegisteredEvent), + /// See: [`EventListenerDeregisteredEvent`]. + Deregistered(EventListenerDeregisteredEvent), +} + +impl_tryfrommessage_for_event_wrapper!(EventListenerEvents); + +impl DBusInterface for EventListenerEvents { + const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Registry"; +} + +impl DBusMatchRule for EventListenerEvents { + const MATCH_RULE_STRING: &'static str = "type='signal',interface='org.a11y.atspi.Registry'"; +} + +impl RegistryEventString for EventListenerEvents { + const REGISTRY_EVENT_STRING: &'static str = "Event"; +} + +impl EventTypeProperties for EventListenerEvents { + fn member(&self) -> &'static str { + match self { + Self::Registered(inner) => inner.member(), + Self::Deregistered(inner) => inner.member(), + } + } + + fn match_rule(&self) -> &'static str { + match self { + Self::Registered(inner) => inner.match_rule(), + Self::Deregistered(inner) => inner.match_rule(), + } + } + + fn interface(&self) -> &'static str { + match self { + Self::Registered(inner) => inner.interface(), + Self::Deregistered(inner) => inner.interface(), + } + } + + fn registry_string(&self) -> &'static str { + match self { + Self::Registered(inner) => inner.registry_string(), + Self::Deregistered(inner) => inner.registry_string(), + } + } +} + +impl EventProperties for EventListenerEvents { + fn path(&self) -> ObjectPath<'_> { + match self { + Self::Registered(inner) => inner.path(), + Self::Deregistered(inner) => inner.path(), + } + } + fn sender(&self) -> UniqueName<'_> { + match self { + Self::Registered(inner) => inner.sender(), + Self::Deregistered(inner) => inner.sender(), + } + } +} + +#[cfg(feature = "zbus")] +impl crate::events::traits::EventWrapperMessageConversion for EventListenerEvents { + fn try_from_message_interface_checked( + msg: &zbus::Message, + hdr: &zbus::message::Header, + ) -> Result { + let member = hdr.member().ok_or(AtspiError::MissingMember)?; + match member.as_str() { + EventListenerRegisteredEvent::DBUS_MEMBER => Ok(EventListenerEvents::Registered( + EventListenerRegisteredEvent::from_message_unchecked(msg, hdr)?, + )), + EventListenerDeregisteredEvent::DBUS_MEMBER => Ok(EventListenerEvents::Deregistered( + EventListenerDeregisteredEvent::from_message_unchecked(msg, hdr)?, + )), + _ => Err(AtspiError::MemberMatch(format!( + "No member {} in {}", + member.as_str(), + Self::DBUS_INTERFACE + ))), + } + } +} + +#[cfg(feature = "zbus")] +impl TryFrom<&zbus::Message> for EventListenerEvents { + type Error = AtspiError; + fn try_from(msg: &zbus::Message) -> Result { + ::try_from_message(msg) + } +} + +impl_try_from_event_for_interface_enum!(EventListenerEvents, Event::Listener); +impl_from_interface_event_enum_for_event!(EventListenerEvents, Event::Listener); + +impl From for Event { + fn from(ev: AvailableEvent) -> Event { + Event::Available(ev) + } +} + +#[cfg(feature = "zbus")] +impl TryFrom for AvailableEvent { + type Error = AtspiError; + fn try_from(generic_event: Event) -> Result { + if let Event::Available(specific_event) = generic_event { + Ok(specific_event) + } else { + Err(AtspiError::Conversion("Invalid type")) + } + } +} + +event_wrapper_test_cases!(EventListenerEvents, EventListenerRegisteredEvent); diff --git a/patches/atspi-common/src/events/focus.rs b/patches/atspi-common/src/events/focus.rs new file mode 100644 index 0000000..74144b3 --- /dev/null +++ b/patches/atspi-common/src/events/focus.rs @@ -0,0 +1,36 @@ +#[cfg(feature = "zbus")] +use crate::error::AtspiError; +#[cfg(feature = "zbus")] +use crate::EventProperties; +use crate::{ + events::{DBusInterface, DBusMatchRule, DBusMember, RegistryEventString}, + object_ref::ObjectRefOwned, +}; + +#[cfg(feature = "zbus")] +use zbus::message::Header; + +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct FocusEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(FocusEvent); + +impl_member_interface_registry_string_and_match_rule_for_event! { + FocusEvent, + "Focus", + "org.a11y.atspi.Event.Focus", + "focus:", + "type='signal',interface='org.a11y.atspi.Event.Focus',member='Focus'" +} + +impl_msg_conversion_ext_for_target_type!(FocusEvent); +impl_msg_conversion_for_types_built_from_object_ref!(FocusEvent); + +event_test_cases!(FocusEvent); +impl_to_dbus_message!(FocusEvent); +impl_from_dbus_message!(FocusEvent); +impl_event_properties!(FocusEvent); +impl_from_object_ref!(FocusEvent); diff --git a/patches/atspi-common/src/events/keyboard.rs b/patches/atspi-common/src/events/keyboard.rs new file mode 100644 index 0000000..5928f96 --- /dev/null +++ b/patches/atspi-common/src/events/keyboard.rs @@ -0,0 +1,77 @@ +#[cfg(feature = "zbus")] +use super::event_body::EventBody; +#[cfg(feature = "zbus")] +use crate::error::AtspiError; +use crate::{ + events::{DBusInterface, DBusMatchRule, DBusMember, EventBodyOwned, RegistryEventString}, + object_ref::ObjectRefOwned, +}; + +#[cfg(feature = "zbus")] +use crate::{events::MessageConversion, EventProperties, ObjectRef}; +#[cfg(feature = "zbus")] +use zbus::message::{Body as DbusBody, Header}; + +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct ModifiersEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, + pub previous_modifiers: i32, + pub current_modifiers: i32, +} + +impl_event_type_properties_for_event!(ModifiersEvent); + +impl_member_interface_registry_string_and_match_rule_for_event! { + ModifiersEvent, + "Modifiers", + "org.a11y.atspi.Event.Keyboard", + "keyboard:modifiers", + "type='signal',interface='org.a11y.atspi.Event.Keyboard',member='Modifiers'" +} + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for ModifiersEvent { + type Body<'msg> = EventBody<'msg>; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + let body = body.deserialize_ignore_signature::>()?; + Ok(Self { + item: item.into(), + previous_modifiers: body.detail1(), + current_modifiers: body.detail2(), + }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + EventBodyOwned { + detail1: self.previous_modifiers, + detail2: self.current_modifiers, + ..Default::default() + } + .into() + } +} + +impl_msg_conversion_ext_for_target_type!(ModifiersEvent); + +event_test_cases!(ModifiersEvent); +impl_to_dbus_message!(ModifiersEvent); +impl_from_dbus_message!(ModifiersEvent); +impl_event_properties!(ModifiersEvent); + +impl From for EventBodyOwned { + fn from(event: ModifiersEvent) -> Self { + EventBodyOwned { + detail1: event.previous_modifiers, + detail2: event.current_modifiers, + ..Default::default() + } + } +} diff --git a/patches/atspi-common/src/events/mod.rs b/patches/atspi-common/src/events/mod.rs new file mode 100644 index 0000000..1691532 --- /dev/null +++ b/patches/atspi-common/src/events/mod.rs @@ -0,0 +1,27 @@ +pub mod cache; +pub mod document; +pub mod event_body; +#[cfg(feature = "wrappers")] +pub mod event_wrappers; +pub mod focus; +pub mod keyboard; +pub mod mouse; +pub mod object; +pub mod registry; +pub mod terminal; +pub mod traits; +pub mod window; +pub use event_body::{ + EventBody, EventBodyBorrowed, EventBodyOwned, EventBodyQtBorrowed, EventBodyQtOwned, +}; +#[cfg(feature = "wrappers")] +pub use event_wrappers::{ + CacheEvents, DocumentEvents, Event, EventListenerEvents, FocusEvents, KeyboardEvents, + MouseEvents, ObjectEvents, TerminalEvents, WindowEvents, +}; +pub use traits::{ + DBusInterface, DBusMatchRule, DBusMember, DBusProperties, EventProperties, EventTypeProperties, + RegistryEventString, +}; +#[cfg(feature = "zbus")] +pub use traits::{MessageConversion, MessageConversionExt}; diff --git a/patches/atspi-common/src/events/mouse.rs b/patches/atspi-common/src/events/mouse.rs new file mode 100644 index 0000000..7125c23 --- /dev/null +++ b/patches/atspi-common/src/events/mouse.rs @@ -0,0 +1,213 @@ +#[cfg(feature = "zbus")] +use crate::events::MessageConversion; +use crate::events::{ + DBusInterface, DBusMatchRule, DBusMember, EventBody, EventBodyOwned, RegistryEventString, +}; +use crate::object_ref::ObjectRefOwned; +#[cfg(feature = "zbus")] +use crate::EventProperties; +#[cfg(feature = "zbus")] +use crate::{error::AtspiError, ObjectRef}; +#[cfg(feature = "zbus")] +use zbus::message::{Body as DbusBody, Header}; + +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct AbsEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, + pub x: i32, + pub y: i32, +} + +impl_event_type_properties_for_event!(AbsEvent); + +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct RelEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, + pub x: i32, + pub y: i32, +} + +impl_event_type_properties_for_event!(RelEvent); + +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct ButtonEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, + pub detail: String, + pub mouse_x: i32, + pub mouse_y: i32, +} + +impl_event_type_properties_for_event!(ButtonEvent); + +impl_member_interface_registry_string_and_match_rule_for_event! { + AbsEvent, + "Abs", + "org.a11y.atspi.Event.Mouse", + "mouse:abs", + "type='signal',interface='org.a11y.atspi.Event.Mouse',member='Abs'" +} + +impl_member_interface_registry_string_and_match_rule_for_event! { + RelEvent, + "Rel", + "org.a11y.atspi.Event.Mouse", + "mouse:rel", + "type='signal',interface='org.a11y.atspi.Event.Mouse',member='Rel'" +} + +impl_member_interface_registry_string_and_match_rule_for_event! { + ButtonEvent, + "Button", + "org.a11y.atspi.Event.Mouse", + "mouse:button", + "type='signal',interface='org.a11y.atspi.Event.Mouse',member='Button'" +} + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for AbsEvent { + type Body<'a> = EventBody<'a>; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + let body = body.deserialize_ignore_signature::>()?; + Ok(Self { item: item.into(), x: body.detail1(), y: body.detail2() }) + } + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + fn body(&self) -> Self::Body<'_> { + EventBodyOwned { detail1: self.x, detail2: self.y, ..Default::default() }.into() + } +} + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for RelEvent { + type Body<'a> = EventBody<'a>; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + let body = body.deserialize_ignore_signature::>()?; + Ok(Self { item: item.into(), x: body.detail1(), y: body.detail2() }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + EventBodyOwned { detail1: self.x, detail2: self.y, ..Default::default() }.into() + } +} + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for ButtonEvent { + type Body<'a> = EventBody<'a>; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + let mut body = body.deserialize_ignore_signature::>()?; + Ok(Self { + item: item.into(), + detail: body.take_kind(), + mouse_x: body.detail1(), + mouse_y: body.detail2(), + }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + EventBodyOwned::from(self).into() + } +} + +event_test_cases!(AbsEvent); +impl_to_dbus_message!(AbsEvent); +impl_from_dbus_message!(AbsEvent); +impl_event_properties!(AbsEvent); + +impl From for EventBodyOwned { + fn from(event: AbsEvent) -> Self { + EventBodyOwned { detail1: event.x, detail2: event.y, ..Default::default() } + } +} + +impl From<&AbsEvent> for EventBodyOwned { + fn from(event: &AbsEvent) -> Self { + EventBodyOwned { detail1: event.x, detail2: event.y, ..Default::default() } + } +} + +impl From for EventBody<'_> { + fn from(event: AbsEvent) -> Self { + EventBodyOwned::from(event).into() + } +} + +event_test_cases!(RelEvent); +impl_to_dbus_message!(RelEvent); +impl_from_dbus_message!(RelEvent); +impl_event_properties!(RelEvent); + +impl From for EventBodyOwned { + fn from(event: RelEvent) -> Self { + EventBodyOwned { detail1: event.x, detail2: event.y, ..Default::default() } + } +} + +impl From<&RelEvent> for EventBodyOwned { + fn from(event: &RelEvent) -> Self { + EventBodyOwned { detail1: event.x, detail2: event.y, ..Default::default() } + } +} + +impl From for EventBody<'_> { + fn from(event: RelEvent) -> Self { + EventBodyOwned::from(event).into() + } +} + +event_test_cases!(ButtonEvent); +impl_to_dbus_message!(ButtonEvent); +impl_from_dbus_message!(ButtonEvent); + +impl_event_properties!(ButtonEvent); +impl From for EventBodyOwned { + fn from(event: ButtonEvent) -> Self { + EventBodyOwned { + kind: event.detail, + detail1: event.mouse_x, + detail2: event.mouse_y, + ..Default::default() + } + } +} + +impl From for EventBody<'_> { + fn from(event: ButtonEvent) -> Self { + EventBodyOwned::from(event).into() + } +} + +impl From<&ButtonEvent> for EventBodyOwned { + fn from(event: &ButtonEvent) -> Self { + EventBodyOwned { + kind: event.detail.clone(), + detail1: event.mouse_x, + detail2: event.mouse_y, + ..Default::default() + } + } +} + +impl_msg_conversion_ext_for_target_type!(AbsEvent); +impl_msg_conversion_ext_for_target_type!(RelEvent); +impl_msg_conversion_ext_for_target_type!(ButtonEvent); diff --git a/patches/atspi-common/src/events/object.rs b/patches/atspi-common/src/events/object.rs new file mode 100644 index 0000000..85f9b51 --- /dev/null +++ b/patches/atspi-common/src/events/object.rs @@ -0,0 +1,1237 @@ +//! All events which can be received by the `org.a11y.atspi.Object` interface. + +#![deny(missing_docs)] + +#[cfg(feature = "zbus")] +use crate::events::MessageConversion; +#[cfg(feature = "zbus")] +use crate::object_ref::ObjectRef; +#[cfg(feature = "zbus")] +use crate::EventProperties; +use crate::{ + error::AtspiError, + events::{ + DBusInterface, DBusMatchRule, DBusMember, EventBody, EventBodyOwned, RegistryEventString, + }, + object_ref::ObjectRefOwned, + State, +}; +use std::hash::Hash; +#[cfg(feature = "zbus")] +use zbus::message::{Body as DbusBody, Header}; +use zbus::wire::{OwnedVariant as OwnedValue, Variant as Value}; + +const ACCESSIBLE_NAME_PROPERTY_NAME: &str = "accessible-name"; +const ACCESSIBLE_DESCRIPTION_PROPERTY_NAME: &str = "accessible-description"; +const ACCESSIBLE_HELP_TEXT_PROPERTY_NAME: &str = "accessible-help-text"; +const ACCESSIBLE_PARENT_PROPERTY_NAME: &str = "accessible-parent"; +const ACCESSIBLE_ROLE_PROPERTY_NAME: &str = "accessible-role"; +const ACCESSIBLE_TABLE_CAPTION_PROPERTY_NAME: &str = "accessible-table-caption"; +const ACCESSIBLE_TABLE_COLUMN_DESCRIPTION_PROPERTY_NAME: &str = + "accessible-table-column-description"; +const ACCESSIBLE_TABLE_COLUMN_HEADER_PROPERTY_NAME: &str = "accessible-table-column-header"; +const ACCESSIBLE_TABLE_ROW_DESCRIPTION_PROPERTY_NAME: &str = "accessible-table-row-description"; +const ACCESSIBLE_TABLE_ROW_HEADER_PROPERTY_NAME: &str = "accessible-table-row-header"; +const ACCESSIBLE_TABLE_SUMMARY_PROPERTY_NAME: &str = "accessible-table-summary"; + +/// An event representing a property change on UI item `item` with new value `value`. +#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct PropertyChangeEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, + /// The name of the property. + // TODO: this is not necessary since the string is encoded in the `Property` type. + pub property: String, + /// The value of the property. + pub value: Property, +} + +impl_event_type_properties_for_event!(PropertyChangeEvent); + +impl Hash for PropertyChangeEvent { + fn hash(&self, state: &mut H) { + self.item.hash(state); + self.property.hash(state); + } +} + +// Do not derive Eq if not all fields implement Eq +impl Eq for PropertyChangeEvent {} + +// TODO: Looks like a false positive Clippy lint +// Derive me. +#[allow(clippy::derivable_impls)] +impl Default for PropertyChangeEvent { + fn default() -> Self { + Self { + item: ObjectRefOwned::default(), + property: String::default(), + value: Property::default(), + } + } +} + +/// Any accessibility related property on an [`crate::ObjectRef`]. +/// This is used only in the [`PropertyChangeEvent`]; this event gets triggered if a role or accessible +/// description of an item changes. +#[derive(Debug, PartialEq, serde::Serialize, serde::Deserialize)] +#[non_exhaustive] +pub enum Property { + /// Name of the element; this can either be the text of a simple UI element like a [`crate::Role::Button`], but it could also be alternative text via [`aria-label`](https://www.w3.org/TR/wai-aria/#aria-label). + Name(String), + /// The extended description of an item (usually via [`aria-describedby`](https://www.w3.org/TR/wai-aria/#aria-describedby)). + Description(String), + /// The [ARIA role](https://www.w3.org/TR/wai-aria/#roles) of a given item. + Role(crate::Role), + /// Parent of the item in a hierarchical tree. + Parent(ObjectRefOwned), + /// A description of the table as a whole: in HTML this is achieved via the + /// `...
VALUE_HERE
` pattern + TableCaption(String), + /// Similar to [`Self::TableColumnHeader`] except it's the attached description instead of the + /// data in the header. + TableColumnDescription(String), + /// A column header: in HTML this is accomplished with the use of `` in an aligned column with a given `` cell element + TableColumnHeader(String), + /// Similar to [`Self::TableRowHeader`] except it's the attached description instead of the + /// data in the header. + TableRowDescription(String), + /// Row header: in HTML this is accomplished with the use of `` at the beginning of a `` + TableRowHeader(String), + /// The table summary is a shorter description of the table. In HTML this would be accomplished + /// with the [figure/figcaption pattern](https://www.w3.org/WAI/tutorials/tables/caption-summary/#using-the-figure-element-to-mark-up-a-table-summary) + TableSummary(String), + /// The attached help text of the item. + HelpText(String), + /// Any other attribute not explicitly laid out above. + Other((String, OwnedValue)), +} + +impl Clone for Property { + fn clone(&self) -> Self { + match self { + Property::Name(name) => Self::Name(name.clone()), + Property::Description(description) => Self::Description(description.clone()), + Property::Role(role) => Self::Role(*role), + Property::Parent(parent) => Self::Parent(parent.clone()), + Property::TableCaption(table_caption) => Self::TableCaption(table_caption.clone()), + Property::TableColumnDescription(table_column_description) => { + Self::TableColumnDescription(table_column_description.clone()) + } + Property::TableColumnHeader(table_column_header) => { + Self::TableColumnHeader(table_column_header.clone()) + } + Property::TableRowDescription(table_row_description) => { + Self::TableRowDescription(table_row_description.clone()) + } + Property::TableRowHeader(table_row_header) => { + Self::TableRowHeader(table_row_header.clone()) + } + Property::TableSummary(table_summary) => Self::TableSummary(table_summary.clone()), + Property::HelpText(help_text) => Self::HelpText(help_text.clone()), + Property::Other((property, value)) => Self::Other(( + property.clone(), + value + .try_clone() + .expect("Could not clone 'value'. Since properties are not known to carry files, we do not expect to exceed open file limit."), + )), + } + } +} + +impl Default for Property { + fn default() -> Self { + Self::Other((String::default(), u64::default().into())) + } +} + +impl TryFrom> for Property { + type Error = AtspiError; + + fn try_from(mut body: EventBody<'_>) -> Result { + let property = body.kind(); + + match property { + ACCESSIBLE_NAME_PROPERTY_NAME => Ok(Self::Name( + body.take_any_data() + .try_into() + .map_err(|_| AtspiError::ParseError(ACCESSIBLE_NAME_PROPERTY_NAME))?, + )), + ACCESSIBLE_DESCRIPTION_PROPERTY_NAME => Ok(Self::Description( + body.take_any_data() + .try_into() + .map_err(|_| AtspiError::ParseError(ACCESSIBLE_DESCRIPTION_PROPERTY_NAME))?, + )), + ACCESSIBLE_ROLE_PROPERTY_NAME => Ok(Self::Role({ + let role_int: u32 = body + .any_data() + .try_into() + .map_err(|_| AtspiError::ParseError(ACCESSIBLE_ROLE_PROPERTY_NAME))?; + let role: crate::Role = crate::Role::try_from(role_int) + .map_err(|_| AtspiError::ParseError("accessible-role"))?; + role + })), + ACCESSIBLE_PARENT_PROPERTY_NAME => Ok(Self::Parent( + body.take_any_data() + .try_into() + .map_err(|_| AtspiError::ParseError(ACCESSIBLE_PARENT_PROPERTY_NAME))?, + )), + ACCESSIBLE_TABLE_CAPTION_PROPERTY_NAME => Ok(Self::TableCaption( + body.take_any_data() + .try_into() + .map_err(|_| AtspiError::ParseError(ACCESSIBLE_TABLE_CAPTION_PROPERTY_NAME))?, + )), + ACCESSIBLE_TABLE_COLUMN_DESCRIPTION_PROPERTY_NAME => { + Ok(Self::TableColumnDescription(body.take_any_data().try_into().map_err(|_| { + AtspiError::ParseError(ACCESSIBLE_TABLE_COLUMN_DESCRIPTION_PROPERTY_NAME) + })?)) + } + ACCESSIBLE_TABLE_COLUMN_HEADER_PROPERTY_NAME => { + Ok(Self::TableColumnHeader(body.take_any_data().try_into().map_err(|_| { + AtspiError::ParseError(ACCESSIBLE_TABLE_COLUMN_HEADER_PROPERTY_NAME) + })?)) + } + ACCESSIBLE_TABLE_ROW_DESCRIPTION_PROPERTY_NAME => { + Ok(Self::TableRowDescription(body.take_any_data().try_into().map_err(|_| { + AtspiError::ParseError(ACCESSIBLE_TABLE_ROW_DESCRIPTION_PROPERTY_NAME) + })?)) + } + ACCESSIBLE_TABLE_ROW_HEADER_PROPERTY_NAME => { + Ok(Self::TableRowHeader(body.take_any_data().try_into().map_err(|_| { + AtspiError::ParseError(ACCESSIBLE_TABLE_ROW_HEADER_PROPERTY_NAME) + })?)) + } + ACCESSIBLE_TABLE_SUMMARY_PROPERTY_NAME => Ok(Self::TableSummary( + body.take_any_data() + .try_into() + .map_err(|_| AtspiError::ParseError(ACCESSIBLE_TABLE_SUMMARY_PROPERTY_NAME))?, + )), + ACCESSIBLE_HELP_TEXT_PROPERTY_NAME => Ok(Self::HelpText( + body.take_any_data() + .try_into() + .map_err(|_| AtspiError::ParseError(ACCESSIBLE_HELP_TEXT_PROPERTY_NAME))?, + )), + _ => Ok(Self::Other((property.to_string(), body.take_any_data()))), + } + } +} + +impl From for OwnedValue { + fn from(property: Property) -> Self { + let value = match property { + Property::Name(name) => Value::from(name), + Property::Description(description) => Value::from(description), + Property::Role(role) => Value::from(role as u32), + Property::Parent(parent) => Value::from(parent), + Property::TableCaption(table_caption) => Value::from(table_caption), + Property::TableColumnDescription(table_column_description) => { + Value::from(table_column_description) + } + Property::TableColumnHeader(table_column_header) => Value::from(table_column_header), + Property::TableRowDescription(table_row_description) => { + Value::from(table_row_description) + } + Property::TableRowHeader(table_row_header) => Value::from(table_row_header), + Property::TableSummary(table_summary) => Value::from(table_summary), + Property::HelpText(help_text) => Value::from(help_text), + Property::Other((_, value)) => value.into(), + }; + value.try_into().expect("Should succeed as there are no borrowed file descriptors involved that could, potentially, exceed the open file limit when converted to OwnedValue") + } +} + +#[cfg(test)] +mod test_property { + use crate::events::object::{Property, PropertyChangeEvent}; + use crate::events::{EventBody, EventBodyOwned}; + use crate::{ObjectRef, Role}; + + static TEST_OBJECT_REF: &ObjectRef = + &ObjectRef::from_static_str_unchecked(":0.0", "/org/a11y/atspi/test/path"); + + macro_rules! property_subtype_test { + ($name:ident, $key:expr, $prop:path, $val:expr) => { + #[test] + fn $name() { + let prop = $prop($val); + let prop_ev = PropertyChangeEvent { + item: TEST_OBJECT_REF.clone().into(), + property: $key.to_string(), + value: prop.clone(), + }; + let ev_body: EventBodyOwned = prop_ev.try_into().expect("Valid event body!"); + let ev: EventBody<'_> = ev_body.into(); + let prop2: Property = ev.try_into().expect("Valid Property value"); + assert_eq!(prop, prop2); + } + }; + } + property_subtype_test!( + test_prop_type_desc, + "accessible-description", + Property::Description, + "Accessible description text here!".to_string() + ); + property_subtype_test!( + test_prop_type_name, + "accessible-name", + Property::Name, + "Accessible name here!".to_string() + ); + property_subtype_test!(test_prop_type_role, "accessible-role", Property::Role, Role::Invalid); + property_subtype_test!( + test_prop_type_parent, + "accessible-parent", + Property::Parent, + ObjectRef::from_static_str_unchecked(":420.69", "/fake/a11y/addr").into() + ); + property_subtype_test!( + test_prop_type_table_caption, + "accessible-table-caption", + Property::TableCaption, + "Accessible table description here".to_string() + ); + property_subtype_test!( + test_prop_type_table_cd, + "accessible-table-column-description", + Property::TableColumnDescription, + "Accessible table column description here!".to_string() + ); + property_subtype_test!( + test_prop_type_table_ch, + "accessible-table-column-header", + Property::TableColumnHeader, + "Accessible table column header here!".to_string() + ); + property_subtype_test!( + test_prop_type_table_rd, + "accessible-table-row-description", + Property::TableRowDescription, + "Accessible table row description here!".to_string() + ); + property_subtype_test!( + test_prop_type_table_rh, + "accessible-table-row-header", + Property::TableRowHeader, + "Accessible table row header here!".to_string() + ); + property_subtype_test!( + test_prop_help_text, + "accessible-help-text", + Property::HelpText, + "Accessible help text here!".to_string() + ); +} + +/// An event triggered when the visual bounds for an item have changed. +/// This usually happens either: +/// +/// 1. due to a re-draw on a window whose size has changed and dynamically adjusted said item's visual size, or +/// 2. content within the bounds of said item has changed to change its size. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct BoundsChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(BoundsChangedEvent); + +/// A link has been selected. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct LinkSelectedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(LinkSelectedEvent); + +/// A state of an object has been modified. +/// A [`State`] can be added or removed from any [`crate::ObjectRef`]. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct StateChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, + /// The state to be enabled/disabled. + pub state: State, + /// Whether the state was enabled or disabled. + #[serde(with = "i32_bool_conversion")] + pub enabled: bool, +} + +impl_event_type_properties_for_event!(StateChangedEvent); + +mod i32_bool_conversion { + use serde::{Deserialize, Deserializer, Serializer}; + /// Convert an integer flag to a boolean. + /// returns true if value is more than 0, otherwise false + pub fn deserialize<'de, D>(de: D) -> Result + where + D: Deserializer<'de>, + { + let int: i32 = Deserialize::deserialize(de)?; + Ok(int > 0) + } + + /// Convert a boolean flag to an integer. + /// returns 0 if false and 1 if true + // TODO: Will the world REALLY fall apart if we were not to use a reference here? + // In other words, see if &bool can be replaced with bool. + #[allow(clippy::trivially_copy_pass_by_ref)] + pub fn serialize(b: &bool, ser: S) -> Result + where + S: Serializer, + { + let val: i32 = (*b).into(); + ser.serialize_i32(val) + } +} + +/// A child of `item` has been added or removed. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct ChildrenChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, + /// The [`crate::Operation`] being performed. + pub operation: crate::Operation, + /// Index to remove from/add to. + pub index_in_parent: i32, + /// A reference to the new child. + pub child: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(ChildrenChangedEvent); + +/// A change in whether a particular item is visible or invisible (but still present). +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct VisibleDataChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(VisibleDataChangedEvent); + +/// The selection of this item has changed. +/// For example: when a selection from a series of checkboxes is changed, this will change the state of the child, _and_ cause a [`SelectionChangedEvent`] on the parent. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct SelectionChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(SelectionChangedEvent); + +/// An event sent when the method of selecting items in a list/set of options changes. +/// Also see: +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct ModelChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(ModelChangedEvent); + +/// An event fired when the focus has moved within a tree. +/// The parent: `item` and descendant (may not be a direct child): `descebdant` are both referenced for convenience. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct ActiveDescendantChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, + /// The descendant which is now the active one. + pub descendant: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(ActiveDescendantChangedEvent); + +/// An announcement with a defined text string and an [ARIA politeness level](https://www.w3.org/TR/2009/WD-wai-aria-20091215/states_and_properties#aria-live). +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct AnnouncementEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, + /// Text of the announcement. + pub text: String, + /// Politeness level. + pub live: crate::Politeness, +} + +impl_event_type_properties_for_event!(AnnouncementEvent); + +/// Signal that some attribute of an object (usually styling) has changed. +/// This event does not encode _what_ has changed about the attributes, merely that they have +/// changed. +/// +/// To query the updated information, use `atspi_proxies::AccessibleProxy`'s `get_attribute` method. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct AttributesChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(AttributesChangedEvent); + +/// A row has been added to a table. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct RowInsertedEvent { + /// The table which has had a row inserted. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(RowInsertedEvent); + +/// A row has been moved within a table. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct RowReorderedEvent { + /// The table which has had a row re-ordered. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(RowReorderedEvent); + +/// A row has been deleted from a table. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct RowDeletedEvent { + /// The table which has had a row removed. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(RowDeletedEvent); + +/// A column has been added to a table. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct ColumnInsertedEvent { + /// The table which has had a column inserted. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(ColumnInsertedEvent); + +/// A column has been re-ordered within a table. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct ColumnReorderedEvent { + /// The table which has had a column re-ordered. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(ColumnReorderedEvent); + +/// A column has been removed from a table. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct ColumnDeletedEvent { + /// The table which has had a column removed. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(ColumnDeletedEvent); + +/// The bounds of a piece of text have changed. +/// This event does _not_ specify what the new bounds are; it is only to notify an AT that the bounds have changed. +/// To query information about the new state of the selection, use `atspi_proxies::TextProxy`'s `get_bounded_ranges` function. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct TextBoundsChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(TextBoundsChangedEvent); + +/// The user's selection of a piece of text has changed. +/// This event does _not_ specify what the new selection is, nor its indecies; it is only to notify an AT that the selection has changed. +/// To query information about the new state of the selection, use `atspi_proxies::TextProxy`'s methods. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct TextSelectionChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(TextSelectionChangedEvent); + +/// Text has changed within the UI element `item`. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct TextChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, + /// The [`crate::Operation`] being performed. + pub operation: crate::Operation, + /// starting index of the insertion/deletion + /// + /// NOTE: This gives the Unicode index (not the byte index). I.e., it groups unicode sequences + /// into one character. + /// Always use the appropriate insertion methods to deal with this, i.e., do not use + /// [`String::insert_str`]. + pub start_pos: i32, + /// length of the insertion/deletion + /// + /// NOTE: This gives the unicode length (not the byte length). + pub length: i32, + /// the text being inserted/deleted + pub text: String, +} + +impl_event_type_properties_for_event!(TextChangedEvent); + +/// Signal that some attributes about the text (usually styling) have changed. +/// This event does not encode _what_ has changed about the attributes, merely that they have +/// changed. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct TextAttributesChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(TextAttributesChangedEvent); + +/// The caret of the user also known as a cursor (not to be confused with mouse pointer) has changed position. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct TextCaretMovedEvent { + /// The object on which the caret has been moved on. + pub item: ObjectRefOwned, + /// New position of the caret. + /// NOTE: this provide the Unicode index (not the byte index) and therefore when referencing + /// locations in a string, you should be using the [`std::str::Chars`] iterator, and not use + /// anything like [`str::get`] (as this uses the byte index). + /// + /// See also: [`TextChangedEvent`]. + pub position: i32, +} + +impl_event_type_properties_for_event!(TextCaretMovedEvent); + +impl_member_interface_registry_string_and_match_rule_for_event!( + PropertyChangeEvent, + "PropertyChange", + "org.a11y.atspi.Event.Object", + "object:property-change", + "type='signal',interface='org.a11y.atspi.Event.Object',member='PropertyChange'" +); + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for PropertyChangeEvent { + type Body<'b> = EventBody<'b>; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + let mut body = body.deserialize_ignore_signature::>()?; + let property: String = body.take_kind(); + let value: Property = body.try_into()?; + Ok(Self { item: item.into(), property, value }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + let copy = self.clone(); + EventBodyOwned::from(copy).into() + } +} + +impl_member_interface_registry_string_and_match_rule_for_event!( + BoundsChangedEvent, + "BoundsChanged", + "org.a11y.atspi.Event.Object", + "object:bounds-changed", + "type='signal',interface='org.a11y.atspi.Event.Object',member='BoundsChanged'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + LinkSelectedEvent, + "LinkSelected", + "org.a11y.atspi.Event.Object", + "object:link-selected", + "type='signal',interface='org.a11y.atspi.Event.Object',member='LinkSelected'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + StateChangedEvent, + "StateChanged", + "org.a11y.atspi.Event.Object", + "object:state-changed", + "type='signal',interface='org.a11y.atspi.Event.Object',member='StateChanged'" +); + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for StateChangedEvent { + type Body<'a> = EventBody<'a>; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + let body: Self::Body<'_> = body.deserialize_ignore_signature()?; + Ok(Self { item: item.into(), state: body.kind().into(), enabled: body.detail1() > 0 }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + let copy = self.clone(); + copy.into() + } +} + +impl_member_interface_registry_string_and_match_rule_for_event!( + ChildrenChangedEvent, + "ChildrenChanged", + "org.a11y.atspi.Event.Object", + "object:children-changed", + "type='signal',interface='org.a11y.atspi.Event.Object',member='ChildrenChanged'" +); + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for ChildrenChangedEvent { + type Body<'a> = EventBody<'a>; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + let mut body = body.deserialize_ignore_signature::>()?; + Ok(Self { + item: item.into(), + operation: body.kind().parse()?, + index_in_parent: body.detail1(), + child: body.take_any_data().try_into()?, + }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + EventBodyOwned::from(self.clone()).into() + } +} + +impl_member_interface_registry_string_and_match_rule_for_event!( + VisibleDataChangedEvent, + "VisibleDataChanged", + "org.a11y.atspi.Event.Object", + "object:visible-data-changed", + "type='signal',interface='org.a11y.atspi.Event.Object',member='VisibleDataChanged'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + SelectionChangedEvent, + "SelectionChanged", + "org.a11y.atspi.Event.Object", + "object:selection-changed", + "type='signal',interface='org.a11y.atspi.Event.Object',member='SelectionChanged'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + ModelChangedEvent, + "ModelChanged", + "org.a11y.atspi.Event.Object", + "object:model-changed", + "type='signal',interface='org.a11y.atspi.Event.Object',member='ModelChanged'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + ActiveDescendantChangedEvent, + "ActiveDescendantChanged", + "org.a11y.atspi.Event.Object", + "object:active-descendant-changed", + "type='signal',interface='org.a11y.atspi.Event.Object',member='ActiveDescendantChanged'" +); + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for ActiveDescendantChangedEvent { + type Body<'a> = EventBody<'a>; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + let mut body = body.deserialize_ignore_signature::>()?; + Ok(Self { item: item.into(), descendant: body.take_any_data().try_into()? }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + EventBodyOwned::from(self.clone()).into() + } +} + +impl_member_interface_registry_string_and_match_rule_for_event!( + AnnouncementEvent, + "Announcement", + "org.a11y.atspi.Event.Object", + "object:announcement", + "type='signal',interface='org.a11y.atspi.Event.Object',member='Announcement'" +); + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for AnnouncementEvent { + type Body<'a> = EventBody<'a>; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + let mut body = body.deserialize_ignore_signature::>()?; + Ok(Self { + item: item.into(), + text: body + .take_any_data() + .try_into() + .map_err(|_| AtspiError::Conversion("text"))?, + live: body.detail1().try_into()?, + }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + EventBodyOwned::from(self.clone()).into() + } +} + +impl_member_interface_registry_string_and_match_rule_for_event!( + AttributesChangedEvent, + "AttributesChanged", + "org.a11y.atspi.Event.Object", + "object:attributes-changed", + "type='signal',interface='org.a11y.atspi.Event.Object',member='AttributesChanged'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + RowInsertedEvent, + "RowInserted", + "org.a11y.atspi.Event.Object", + "object:row-inserted", + "type='signal',interface='org.a11y.atspi.Event.Object',member='RowInserted'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + RowReorderedEvent, + "RowReordered", + "org.a11y.atspi.Event.Object", + "object:row-reordered", + "type='signal',interface='org.a11y.atspi.Event.Object',member='RowReordered'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + RowDeletedEvent, + "RowDeleted", + "org.a11y.atspi.Event.Object", + "object:row-deleted", + "type='signal',interface='org.a11y.atspi.Event.Object',member='RowDeleted'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + ColumnInsertedEvent, + "ColumnInserted", + "org.a11y.atspi.Event.Object", + "object:column-inserted", + "type='signal',interface='org.a11y.atspi.Event.Object',member='ColumnInserted'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + ColumnReorderedEvent, + "ColumnReordered", + "org.a11y.atspi.Event.Object", + "object:column-reordered", + "type='signal',interface='org.a11y.atspi.Event.Object',member='ColumnReordered'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + ColumnDeletedEvent, + "ColumnDeleted", + "org.a11y.atspi.Event.Object", + "object:column-deleted", + "type='signal',interface='org.a11y.atspi.Event.Object',member='ColumnDeleted'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + TextBoundsChangedEvent, + "TextBoundsChanged", + "org.a11y.atspi.Event.Object", + "object:text-bounds-changed", + "type='signal',interface='org.a11y.atspi.Event.Object',member='TextBoundsChanged'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + TextSelectionChangedEvent, + "TextSelectionChanged", + "org.a11y.atspi.Event.Object", + "object:text-selection-changed", + "type='signal',interface='org.a11y.atspi.Event.Object',member='TextSelectionChanged'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + TextChangedEvent, + "TextChanged", + "org.a11y.atspi.Event.Object", + "object:text-changed", + "type='signal',interface='org.a11y.atspi.Event.Object',member='TextChanged'" +); + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for TextChangedEvent { + type Body<'a> = EventBody<'a>; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + let mut body = body.deserialize_ignore_signature::>()?; + Ok(Self { + item: item.into(), + operation: body.kind().parse()?, + start_pos: body.detail1(), + length: body.detail2(), + text: body.take_any_data().try_into()?, + }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + EventBodyOwned::from(self.clone()).into() + } +} + +impl_member_interface_registry_string_and_match_rule_for_event!( + TextAttributesChangedEvent, + "TextAttributesChanged", + "org.a11y.atspi.Event.Object", + "object:text-attributes-changed", + "type='signal',interface='org.a11y.atspi.Event.Object',member='TextAttributesChanged'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + TextCaretMovedEvent, + "TextCaretMoved", + "org.a11y.atspi.Event.Object", + "object:text-caret-moved", + "type='signal',interface='org.a11y.atspi.Event.Object',member='TextCaretMoved'" +); + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for TextCaretMovedEvent { + type Body<'a> = EventBody<'a>; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + let body = body.deserialize_ignore_signature::>()?; + Ok(Self { item: item.into(), position: body.detail1() }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + EventBodyOwned::from(self.clone()).into() + } +} + +event_test_cases!(PropertyChangeEvent); +impl_to_dbus_message!(PropertyChangeEvent); +impl_from_dbus_message!(PropertyChangeEvent); +impl_event_properties!(PropertyChangeEvent); + +impl From for EventBodyOwned { + fn from(event: PropertyChangeEvent) -> Self { + EventBodyOwned { kind: event.property, any_data: event.value.into(), ..Default::default() } + } +} + +impl From<&PropertyChangeEvent> for EventBodyOwned { + fn from(event: &PropertyChangeEvent) -> Self { + EventBodyOwned { + kind: event.property.clone(), + any_data: event.value.clone().into(), + ..Default::default() + } + } +} + +impl From for EventBody<'_> { + fn from(event: PropertyChangeEvent) -> Self { + EventBodyOwned::from(event).into() + } +} + +event_test_cases!(BoundsChangedEvent); +impl_to_dbus_message!(BoundsChangedEvent); +impl_from_dbus_message!(BoundsChangedEvent); +impl_event_properties!(BoundsChangedEvent); +impl_from_object_ref!(BoundsChangedEvent); + +event_test_cases!(LinkSelectedEvent); +impl_to_dbus_message!(LinkSelectedEvent); +impl_from_dbus_message!(LinkSelectedEvent); +impl_event_properties!(LinkSelectedEvent); +impl_from_object_ref!(LinkSelectedEvent); + +event_test_cases!(StateChangedEvent); +impl_to_dbus_message!(StateChangedEvent); +impl_from_dbus_message!(StateChangedEvent); +impl_event_properties!(StateChangedEvent); + +impl From for EventBodyOwned { + fn from(event: StateChangedEvent) -> Self { + EventBodyOwned { + kind: event.state.to_string(), + detail1: event.enabled.into(), + ..Default::default() + } + } +} + +impl From<&StateChangedEvent> for EventBodyOwned { + fn from(event: &StateChangedEvent) -> Self { + EventBodyOwned { + kind: event.state.to_string(), + detail1: event.enabled.into(), + ..Default::default() + } + } +} + +impl From for EventBody<'_> { + fn from(event: StateChangedEvent) -> Self { + EventBodyOwned::from(event).into() + } +} + +event_test_cases!(ChildrenChangedEvent); +impl_to_dbus_message!(ChildrenChangedEvent); +impl_from_dbus_message!(ChildrenChangedEvent); +impl_event_properties!(ChildrenChangedEvent); + +impl From for EventBodyOwned { + fn from(event: ChildrenChangedEvent) -> Self { + EventBodyOwned { + kind: event.operation.to_string(), + detail1: event.index_in_parent, + + // `OwnedValue` is constructed from the `crate::ObjectRef` + // Only way to fail is to convert a `Fd` into an `OwnedValue`. + // Therefore, this is safe. + any_data: Value::from(event.child) + .try_into() + .expect("Failed to convert child to OwnedValue"), + ..Default::default() + } + } +} + +impl From<&ChildrenChangedEvent> for EventBodyOwned { + fn from(event: &ChildrenChangedEvent) -> Self { + EventBodyOwned { + kind: event.operation.to_string(), + detail1: event.index_in_parent, + detail2: i32::default(), + // `OwnedValue` is constructed from the `crate::ObjectRef` + // Only path to fail is to convert a `Fd` into an `OwnedValue`. + // Therefore, this is safe. + any_data: Value::from(event.child.clone()) + .try_into() + .expect("ObjectRef should convert to OwnedValue without error"), + properties: super::event_body::Properties, + } + } +} + +impl From for EventBody<'_> { + fn from(event: ChildrenChangedEvent) -> Self { + EventBodyOwned::from(event).into() + } +} + +event_test_cases!(VisibleDataChangedEvent); +impl_to_dbus_message!(VisibleDataChangedEvent); +impl_from_dbus_message!(VisibleDataChangedEvent); +impl_event_properties!(VisibleDataChangedEvent); +impl_from_object_ref!(VisibleDataChangedEvent); + +event_test_cases!(SelectionChangedEvent); +impl_to_dbus_message!(SelectionChangedEvent); +impl_from_dbus_message!(SelectionChangedEvent); +impl_event_properties!(SelectionChangedEvent); +impl_from_object_ref!(SelectionChangedEvent); + +event_test_cases!(ModelChangedEvent); +impl_to_dbus_message!(ModelChangedEvent); +impl_from_dbus_message!(ModelChangedEvent); +impl_event_properties!(ModelChangedEvent); +impl_from_object_ref!(ModelChangedEvent); + +event_test_cases!(ActiveDescendantChangedEvent); +impl_to_dbus_message!(ActiveDescendantChangedEvent); +impl_from_dbus_message!(ActiveDescendantChangedEvent); +impl_event_properties!(ActiveDescendantChangedEvent); +impl From for EventBodyOwned { + fn from(event: ActiveDescendantChangedEvent) -> Self { + EventBodyOwned { + // `OwnedValue` is constructed from the `crate::ObjectRef` + // Only way to fail is to convert a Fd into an `OwnedValue`. + // Therefore, this is safe. + any_data: Value::from(event.descendant) + .try_to_owned() + .expect("Failed to convert descendant to OwnedValue"), + ..Default::default() + } + } +} + +event_test_cases!(AnnouncementEvent); +impl_to_dbus_message!(AnnouncementEvent); +impl_from_dbus_message!(AnnouncementEvent); +impl_event_properties!(AnnouncementEvent); +impl From for EventBodyOwned { + fn from(event: AnnouncementEvent) -> Self { + EventBodyOwned { + detail1: event.live as i32, + // `OwnedValue` is constructed from `String` + // Therefore, this is safe. + any_data: Value::from(event.text) + .try_to_owned() + .expect("Failed to convert text to OwnedValue"), + ..Default::default() + } + } +} + +event_test_cases!(AttributesChangedEvent); +impl_to_dbus_message!(AttributesChangedEvent); +impl_from_dbus_message!(AttributesChangedEvent); +impl_event_properties!(AttributesChangedEvent); +impl_from_object_ref!(AttributesChangedEvent); + +event_test_cases!(RowInsertedEvent); +impl_to_dbus_message!(RowInsertedEvent); +impl_from_dbus_message!(RowInsertedEvent); +impl_event_properties!(RowInsertedEvent); +impl_from_object_ref!(RowInsertedEvent); + +event_test_cases!(RowReorderedEvent); +impl_to_dbus_message!(RowReorderedEvent); +impl_from_dbus_message!(RowReorderedEvent); +impl_event_properties!(RowReorderedEvent); +impl_from_object_ref!(RowReorderedEvent); + +event_test_cases!(RowDeletedEvent); +impl_to_dbus_message!(RowDeletedEvent); +impl_from_dbus_message!(RowDeletedEvent); +impl_event_properties!(RowDeletedEvent); +impl_from_object_ref!(RowDeletedEvent); + +event_test_cases!(ColumnInsertedEvent); +impl_to_dbus_message!(ColumnInsertedEvent); +impl_from_dbus_message!(ColumnInsertedEvent); +impl_event_properties!(ColumnInsertedEvent); +impl_from_object_ref!(ColumnInsertedEvent); + +event_test_cases!(ColumnReorderedEvent); +impl_to_dbus_message!(ColumnReorderedEvent); +impl_from_dbus_message!(ColumnReorderedEvent); +impl_event_properties!(ColumnReorderedEvent); +impl_from_object_ref!(ColumnReorderedEvent); + +event_test_cases!(ColumnDeletedEvent); +impl_to_dbus_message!(ColumnDeletedEvent); +impl_from_dbus_message!(ColumnDeletedEvent); +impl_event_properties!(ColumnDeletedEvent); +impl_from_object_ref!(ColumnDeletedEvent); + +event_test_cases!(TextBoundsChangedEvent); +impl_to_dbus_message!(TextBoundsChangedEvent); +impl_from_dbus_message!(TextBoundsChangedEvent); +impl_event_properties!(TextBoundsChangedEvent); +impl_from_object_ref!(TextBoundsChangedEvent); + +event_test_cases!(TextSelectionChangedEvent); +impl_to_dbus_message!(TextSelectionChangedEvent); +impl_from_dbus_message!(TextSelectionChangedEvent); +impl_event_properties!(TextSelectionChangedEvent); +impl_from_object_ref!(TextSelectionChangedEvent); + +event_test_cases!(TextChangedEvent); + +assert_impl_all!(TextChangedEvent:Clone,std::fmt::Debug,serde::Serialize,serde::Deserialize<'static>,Default,PartialEq,Eq,std::hash::Hash,crate::EventProperties,crate::EventTypeProperties); +#[cfg(feature = "zbus")] +assert_impl_all!(zbus::Message:TryFrom); + +impl_to_dbus_message!(TextChangedEvent); +impl_from_dbus_message!(TextChangedEvent); +impl_event_properties!(TextChangedEvent); +impl From for EventBodyOwned { + fn from(event: TextChangedEvent) -> Self { + EventBodyOwned { + kind: event.operation.to_string(), + detail1: event.start_pos, + detail2: event.length, + // `OwnedValue` is constructed from a `String` + // Therefore, this is safe. + any_data: Value::from(event.text) + .try_to_owned() + .expect("Failed to convert child to OwnedValue"), + ..Default::default() + } + } +} + +event_test_cases!(TextAttributesChangedEvent); +impl_to_dbus_message!(TextAttributesChangedEvent); +impl_from_dbus_message!(TextAttributesChangedEvent); +impl_event_properties!(TextAttributesChangedEvent); +impl_from_object_ref!(TextAttributesChangedEvent); + +event_test_cases!(TextCaretMovedEvent); +impl_to_dbus_message!(TextCaretMovedEvent); +impl_from_dbus_message!(TextCaretMovedEvent); +impl_event_properties!(TextCaretMovedEvent); +impl From for EventBodyOwned { + fn from(event: TextCaretMovedEvent) -> Self { + EventBodyOwned { detail1: event.position, ..Default::default() } + } +} + +impl_msg_conversion_ext_for_target_type!(PropertyChangeEvent); +impl_msg_conversion_ext_for_target_type!(BoundsChangedEvent); +impl_msg_conversion_ext_for_target_type!(LinkSelectedEvent); +impl_msg_conversion_ext_for_target_type!(StateChangedEvent); +impl_msg_conversion_ext_for_target_type!(ChildrenChangedEvent); +impl_msg_conversion_ext_for_target_type!(VisibleDataChangedEvent); +impl_msg_conversion_ext_for_target_type!(SelectionChangedEvent); +impl_msg_conversion_ext_for_target_type!(ModelChangedEvent); +impl_msg_conversion_ext_for_target_type!(ActiveDescendantChangedEvent); +impl_msg_conversion_ext_for_target_type!(AnnouncementEvent); +impl_msg_conversion_ext_for_target_type!(AttributesChangedEvent); +impl_msg_conversion_ext_for_target_type!(RowInsertedEvent); +impl_msg_conversion_ext_for_target_type!(RowReorderedEvent); +impl_msg_conversion_ext_for_target_type!(RowDeletedEvent); +impl_msg_conversion_ext_for_target_type!(ColumnInsertedEvent); +impl_msg_conversion_ext_for_target_type!(ColumnReorderedEvent); +impl_msg_conversion_ext_for_target_type!(ColumnDeletedEvent); +impl_msg_conversion_ext_for_target_type!(TextBoundsChangedEvent); +impl_msg_conversion_ext_for_target_type!(TextSelectionChangedEvent); +impl_msg_conversion_ext_for_target_type!(TextChangedEvent); +impl_msg_conversion_ext_for_target_type!(TextAttributesChangedEvent); +impl_msg_conversion_ext_for_target_type!(TextCaretMovedEvent); + +impl_msg_conversion_for_types_built_from_object_ref!(BoundsChangedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(LinkSelectedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(VisibleDataChangedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(SelectionChangedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(ModelChangedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(AttributesChangedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(RowInsertedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(RowReorderedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(RowDeletedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(ColumnInsertedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(ColumnReorderedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(ColumnDeletedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(TextBoundsChangedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(TextSelectionChangedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(TextAttributesChangedEvent); diff --git a/patches/atspi-common/src/events/registry.rs b/patches/atspi-common/src/events/registry.rs new file mode 100644 index 0000000..b0e6569 --- /dev/null +++ b/patches/atspi-common/src/events/registry.rs @@ -0,0 +1,231 @@ +//! This module contains the events that are emitted by the registry daemon. +//! The events are [`EventListenerRegisteredEvent`] and [`EventListenerDeregisteredEvent`]. + +#[cfg(feature = "zbus")] +use crate::object_ref::ObjectRef; +#[cfg(feature = "zbus")] +use crate::{error::AtspiError, events::MessageConversion, EventProperties}; +use serde::{Deserialize, Serialize}; +#[cfg(feature = "zbus")] +use zbus::message::{Body as DbusBody, Header}; +use zbus_lockstep_macros::validate; +use zbus::names::{OwnedUniqueName, UniqueName}; +use zbus::wire::Type; + +use crate::{ + events::{DBusInterface, DBusMatchRule, DBusMember, RegistryEventString}, + object_ref::ObjectRefOwned, +}; + +/// An event that is emitted by the registry daemon, to inform that an event has been deregistered +/// to no longer listen for. +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default, Eq, Hash)] +pub struct EventListenerDeregisteredEvent { + /// The [`ObjectRef`] the event applies to. + pub item: ObjectRefOwned, + /// A list of events that have been deregistered via the registry interface. + /// See `atspi-connection`. + pub deregistered_event: EventListeners, +} + +impl_event_type_properties_for_event!(EventListenerDeregisteredEvent); + +event_test_cases!(EventListenerDeregisteredEvent, Explicit); + +// The registry string cannot be found in upstrream at-spi2-core. + +impl_member_interface_registry_string_and_match_rule_for_event!( + EventListenerDeregisteredEvent, + "EventListenerDeregistered", + "org.a11y.atspi.Registry", + "registry:event-listener-deregistered", + "type='signal',interface='org.a11y.atspi.Registry',member='EventListenerDeregistered'" +); + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for EventListenerDeregisteredEvent { + type Body<'a> = EventListeners; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + let deregistered_event = body.deserialize_ignore_signature::>()?; + Ok(Self { item: item.into(), deregistered_event }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + self.deregistered_event.clone() + } +} + +impl_msg_conversion_ext_for_target_type_with_specified_body_type!(target: EventListenerDeregisteredEvent, body: EventListeners); +impl_from_dbus_message!(EventListenerDeregisteredEvent, Explicit); +impl_event_properties!(EventListenerDeregisteredEvent); +impl_to_dbus_message!(EventListenerDeregisteredEvent); + +/// An event that is emitted by the regostry daemon to signal that an event has been registered to listen for. +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default, Eq, Hash)] +pub struct EventListenerRegisteredEvent { + /// The [`ObjectRef`] the event applies to. + pub item: ObjectRefOwned, + /// A list of events that have been registered via the registry interface. + /// See `atspi-connection`. + pub registered_event: EventListeners, +} + +impl_event_type_properties_for_event!(EventListenerRegisteredEvent); + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for EventListenerRegisteredEvent { + type Body<'a> = EventListeners; + + fn from_message_unchecked_parts( + item: ObjectRef, + registered_event: DbusBody, + ) -> Result { + let registered_event = registered_event.deserialize_ignore_signature()?; + Ok(Self { item: item.into(), registered_event }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + self.registered_event.clone() + } +} + +impl_msg_conversion_ext_for_target_type_with_specified_body_type!(target: EventListenerRegisteredEvent, body: EventListeners); +impl_from_dbus_message!(EventListenerRegisteredEvent, Explicit); +impl_event_properties!(EventListenerRegisteredEvent); +impl_to_dbus_message!(EventListenerRegisteredEvent); + +event_test_cases!(EventListenerRegisteredEvent, Explicit); + +// The registry string cannot be found in upstrream at-spi2-core. +impl_member_interface_registry_string_and_match_rule_for_event!( + EventListenerRegisteredEvent, + "EventListenerRegistered", + "org.a11y.atspi.Registry", + "registry:event-listener-registered", + "type='signal',interface='org.a11y.atspi.Registry',member='EventListenerRegistered'" +); + +/// Signal type emitted by `EventListenerRegistered` and `EventListenerDeregistered` signals, +/// which belong to the `Registry` interface, implemented by the registry-daemon. +#[validate(signal: "EventListenerRegistered")] +#[derive(Debug, Clone, Serialize, Deserialize, Type, PartialEq, Eq, Hash)] +pub struct EventListeners { + pub bus_name: OwnedUniqueName, + // TODO: `path` should be a `zbus::wire::ObjectPath` but that requires changing the signature with an attribute + // and `Serialize`/`Deserialize` impls. + pub path: String, +} + +impl Default for EventListeners { + fn default() -> Self { + Self { + bus_name: UniqueName::from_static_str_unchecked(":0.0").into(), + path: String::from("/org/a11y/atspi/null"), + } + } +} + +#[cfg(test)] +mod event_listener_tests { + use super::*; + + #[test] + fn test_event_listener_default_no_panic() { + let el = EventListeners::default(); + assert_eq!(el.bus_name.as_str(), ":0.0"); + assert_eq!(el.path.as_str(), "/org/a11y/atspi/null"); + } +} + +pub mod socket { + //! This module contains the event that is emitted by the registry daemon's `Socket` interface. + + #[cfg(feature = "zbus")] + use crate::events::MessageConversion; + use crate::events::{DBusInterface, DBusMatchRule, DBusMember, RegistryEventString}; + use crate::object_ref::ObjectRefOwned; + #[cfg(feature = "zbus")] + use crate::AtspiError; + #[cfg(feature = "zbus")] + use crate::EventProperties; + #[cfg(feature = "zbus")] + use crate::ObjectRef; + #[cfg(feature = "zbus")] + use zbus::message::{Body as DbusBody, Header}; + + use serde::{Deserialize, Serialize}; + + /// An event that is emitted when the registry daemon has started. + /// + /// The accessibility registry emits this signal early during startup, + /// when it has registered with the `DBus` daemon and is available for + /// calls from applications. + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default, Eq, Hash)] + pub struct AvailableEvent { + /// The emitting [`ObjectRef`]. + pub item: ObjectRefOwned, + + /// The [`ObjectRef`] for the Registry's root object. + pub socket: ObjectRefOwned, + } + + impl_event_type_properties_for_event!(AvailableEvent); + + event_test_cases!(AvailableEvent, Explicit); + + // We cannot register at Registry for this event, as it is emitted by the Registry itself at early startup. + // So, we do not have a registry event string for this event. + // The `Available` event is unconditionally emitted: + // [at-spi2-core/registryd/registry.c:1437](https://github.com/GNOME/at-spi2-core/blob/019d1a4013216d7d01040cf4eb3b8647bffc0dc9/registryd/registry.c#L1437) + impl_member_interface_registry_string_and_match_rule_for_event!( + AvailableEvent, + "Available", + "org.a11y.atspi.Socket", + "", + "type='signal',interface='org.a11y.atspi.Socket',member='Available'" + ); + + #[cfg(feature = "zbus")] + impl MessageConversion<'_> for AvailableEvent { + type Body<'a> = ObjectRef<'a>; + + fn from_message_unchecked_parts( + item: ObjectRef<'_>, + body: DbusBody, + ) -> Result { + let socket = body.deserialize_ignore_signature::>()?; + Ok(Self { item: item.into(), socket: socket.into() }) + } + + fn from_message_unchecked( + msg: &zbus::Message, + header: &Header, + ) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + self.socket.clone().into_inner() + } + } + + impl_msg_conversion_ext_for_target_type_with_specified_body_type!(target: AvailableEvent, body: ObjectRef<'a>); + impl_from_dbus_message!(AvailableEvent, Explicit); + impl_event_properties!(AvailableEvent); + impl_to_dbus_message!(AvailableEvent); +} diff --git a/patches/atspi-common/src/events/terminal.rs b/patches/atspi-common/src/events/terminal.rs new file mode 100644 index 0000000..fbd8766 --- /dev/null +++ b/patches/atspi-common/src/events/terminal.rs @@ -0,0 +1,139 @@ +#[cfg(feature = "zbus")] +use crate::error::AtspiError; +#[cfg(feature = "zbus")] +use crate::EventProperties; +use crate::{ + events::{DBusInterface, DBusMatchRule, DBusMember, RegistryEventString}, + object_ref::ObjectRefOwned, +}; +#[cfg(feature = "zbus")] +use zbus::message::Header; + +/// A line of text has been changed. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct LineChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(LineChangedEvent); + +/// The width of a terminal emulator has changed sufficiently such that the number of characters +/// able to fit on one *visual* line has changed. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct ColumnCountChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(ColumnCountChangedEvent); + +/// The height of a terminal emulator has changed sufficiently such that the number of lines +/// able to fit within the terminal has changed. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct LineCountChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(LineCountChangedEvent); + +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct ApplicationChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(ApplicationChangedEvent); + +/// The width of a terminal emulator has changed sufficiently such that the number of characters +/// able to fit on one *visual* line has changed. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct CharWidthChangedEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(CharWidthChangedEvent); + +impl_member_interface_registry_string_and_match_rule_for_event!( + LineChangedEvent, + "LineChanged", + "org.a11y.atspi.Event.Terminal", + "terminal:line-changed", + "type='signal',interface='org.a11y.atspi.Event.Terminal',member='LineChanged'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + ColumnCountChangedEvent, + "ColumncountChanged", + "org.a11y.atspi.Event.Terminal", + "terminal:columncount-changed", + "type='signal',interface='org.a11y.atspi.Event.Terminal',member='ColumncountChanged'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + LineCountChangedEvent, + "LinecountChanged", + "org.a11y.atspi.Event.Terminal", + "terminal:linecount-changed", + "type='signal',interface='org.a11y.atspi.Event.Terminal',member='LinecountChanged'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + ApplicationChangedEvent, + "ApplicationChanged", + "org.a11y.atspi.Event.Terminal", + "terminal:application-changed", + "type='signal',interface='org.a11y.atspi.Event.Terminal',member='ApplicationChanged'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + CharWidthChangedEvent, + "CharwidthChanged", + "org.a11y.atspi.Event.Terminal", + "terminal:char-width-changed", + "type='signal',interface='org.a11y.atspi.Event.Terminal',member='CharwidthChanged'" +); + +event_test_cases!(LineChangedEvent); +impl_to_dbus_message!(LineChangedEvent); +impl_from_dbus_message!(LineChangedEvent); +impl_event_properties!(LineChangedEvent); +impl_from_object_ref!(LineChangedEvent); + +event_test_cases!(ColumnCountChangedEvent); +impl_to_dbus_message!(ColumnCountChangedEvent); +impl_from_dbus_message!(ColumnCountChangedEvent); +impl_event_properties!(ColumnCountChangedEvent); +impl_from_object_ref!(ColumnCountChangedEvent); + +event_test_cases!(LineCountChangedEvent); +impl_to_dbus_message!(LineCountChangedEvent); +impl_from_dbus_message!(LineCountChangedEvent); +impl_event_properties!(LineCountChangedEvent); +impl_from_object_ref!(LineCountChangedEvent); + +event_test_cases!(ApplicationChangedEvent); +impl_to_dbus_message!(ApplicationChangedEvent); +impl_from_dbus_message!(ApplicationChangedEvent); +impl_event_properties!(ApplicationChangedEvent); +impl_from_object_ref!(ApplicationChangedEvent); + +event_test_cases!(CharWidthChangedEvent); +impl_to_dbus_message!(CharWidthChangedEvent); +impl_from_dbus_message!(CharWidthChangedEvent); +impl_event_properties!(CharWidthChangedEvent); +impl_from_object_ref!(CharWidthChangedEvent); + +impl_msg_conversion_ext_for_target_type!(LineChangedEvent); +impl_msg_conversion_ext_for_target_type!(ColumnCountChangedEvent); +impl_msg_conversion_ext_for_target_type!(LineCountChangedEvent); +impl_msg_conversion_ext_for_target_type!(ApplicationChangedEvent); +impl_msg_conversion_ext_for_target_type!(CharWidthChangedEvent); + +impl_msg_conversion_for_types_built_from_object_ref!(LineChangedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(ColumnCountChangedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(LineCountChangedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(ApplicationChangedEvent); +impl_msg_conversion_for_types_built_from_object_ref!(CharWidthChangedEvent); diff --git a/patches/atspi-common/src/events/traits.rs b/patches/atspi-common/src/events/traits.rs new file mode 100644 index 0000000..a0722bf --- /dev/null +++ b/patches/atspi-common/src/events/traits.rs @@ -0,0 +1,239 @@ +#[cfg(feature = "zbus")] +use crate::AtspiError; +use crate::ObjectRef; +#[cfg(feature = "zbus")] +use serde::{Deserialize, Serialize}; +#[cfg(feature = "zbus")] +use zbus::message::{Body as DbusBody, Header}; +use zbus::names::UniqueName; +use zbus::wire::ObjectPath; +#[cfg(feature = "zbus")] +use zbus::wire::Type; + +/// Describes properties of a specific event _type_. +/// +/// - `DBus` member name +/// - `DBus` interface name +/// +/// Together, the member and interface name can describe a specific event _type_. +/// Likewise, the path and sender bus name collectively make up an [`ObjectRef`], which is a way to uniquely identify an individual accessible item available to `atspi`. +/// The latter is available via the [`EventProperties`] trait. +/// +/// This can also be generalized, for example this is implemented for [`crate::Event`] by dispatching to the matching variants. +/// NOTE: to use `EventProperties` on wrapper types, like `Event`, you must enable the "enum-dispatch" feature. +/// +/// This trait *is* object-safe. +pub trait EventTypeProperties { + fn member(&self) -> &'static str; + fn interface(&self) -> &'static str; + fn match_rule(&self) -> &'static str; + fn registry_string(&self) -> &'static str; +} + +/// `EventProperties` allows access to the internals of an event, specifically: +/// +/// - The `DBUs` name which sent the event. +/// - The `ObjectPath`, a unique id for a given application. +/// - Collectively, this is called an [`ObjectRef`]. +/// +/// This trait *is* object-safe. +pub trait EventProperties { + fn sender(&self) -> UniqueName<'_>; + fn path(&self) -> ObjectPath<'_>; + fn object_ref(&self) -> ObjectRef<'_> { + ObjectRef::new(self.sender(), self.path()) + } +} + +assert_obj_safe!(EventTypeProperties); +assert_obj_safe!(EventProperties); + +/// A way to convert a [`zbus::Message`] without checking its interface. +#[cfg(all(feature = "zbus", feature = "wrappers"))] +pub(crate) trait EventWrapperMessageConversion { + /// # Errors + /// Will fail if no matching member or body signature is found. + fn try_from_message_interface_checked( + msg: &zbus::Message, + hdr: &Header, + ) -> Result + where + Self: Sized; +} + +// TODO: Document why this can't be `TryFrom<&zbus::Message>`. +#[cfg(all(feature = "zbus", feature = "wrappers"))] +pub(crate) trait TryFromMessage { + fn try_from_message(msg: &zbus::Message) -> Result + where + Self: Sized; +} + +/// The `DBus` member for the event. +/// For example, for an [`crate::events::object::TextChangedEvent`] this should be `"TextChanged"` +pub trait DBusMember { + /// The event's `DBus` member. + const DBUS_MEMBER: &'static str; +} + +/// The `DBus` interface name for an event - or a wrapper type. +/// For example, for any event within the "Object" interface, this should be "org.a11y.atspi.Event.Object". +pub trait DBusInterface { + /// A static interface string for `DBus`. + /// This should usually be a string that looks like this: `"org.a11y.atspi.Event.*"`; + const DBUS_INTERFACE: &'static str; +} + +/// A static `DBus` match rule string. +/// This should usually be a string that looks like this: +/// `"type='signal',interface='org.a11y.atspi.Event.Object',member='PropertyChange'"`; +// We cannot concat! consts, so we (at time of writing) need to have a separate trait for this. +// Otherwise composing from `DBusMember` and `DBusInterface` would be preferred. +pub trait DBusMatchRule { + /// A static match rule string for `DBus`. + const MATCH_RULE_STRING: &'static str; +} + +/// A static `Registry` event string for registering with the `RegistryProxy` for receiving events. +pub trait RegistryEventString { + /// A registry event string for registering for event receiving via the `RegistryProxy`. + /// This should be deprecated in favour of composing the string from [`DBusMember::DBUS_MEMBER`] and [`DBusInterface::DBUS_INTERFACE`]. + const REGISTRY_EVENT_STRING: &'static str; +} + +/// A 'alias'-trait that combines all the `DBus` related traits. +pub trait DBusProperties: DBusMember + DBusInterface + DBusMatchRule + RegistryEventString {} + +#[cfg(feature = "zbus")] +pub trait MessageConversionExt<'a, B>: 'a + MessageConversion<'a, Body<'a> = B> +where + B: Type + Serialize + Deserialize<'a>, +{ + /// Convert a [`zbus::Message`] into this event type. + /// Does all the validation for you. + /// + /// # Errors + /// + /// - The message does not have an interface: [`type@AtspiError::MissingInterface`] + /// - The message interface does not match the one for the event: [`type@AtspiError::InterfaceMatch`] + /// - The message does not have an member: [`type@AtspiError::MissingMember`] + /// - The message member does not match the one for the event: [`type@AtspiError::MemberMatch`] + /// - The message signature does not match the one for the event: [`type@AtspiError::SignatureMatch`] + /// + /// See [`MessageConversion::from_message_unchecked`] for info on panic condition that should never + /// happen. + fn try_from_message(msg: &'a zbus::Message, hdr: &Header) -> Result + where + Self: Sized + 'a; + + /// Validate the interface string via [`zbus::message::Header::interface`] against `Self`'s assignment of [`DBusInterface::DBUS_INTERFACE`] + /// + /// # Errors + /// + /// - [`type@AtspiError::MissingInterface`] if there is no interface + /// - [`type@AtspiError::InterfaceMatch`] if the interfaces do not match + fn validate_interface(header: &Header) -> Result<(), AtspiError> { + let interface = header.interface().ok_or(AtspiError::MissingInterface)?; + if interface != Self::DBUS_INTERFACE { + return Err(AtspiError::InterfaceMatch(format!( + "The interface {} does not match the signal's interface: {}", + interface, + Self::DBUS_INTERFACE, + ))); + } + Ok(()) + } + + /// Validate the member string via [`zbus::message::Header::member`] against `Self`'s assignment of [`DBusMember::DBUS_MEMBER`] + /// + /// # Errors + /// + /// - [`type@AtspiError::MissingMember`] if there is no member + /// - [`type@AtspiError::MemberMatch`] if the members do not match + fn validate_member(hdr: &Header) -> Result<(), AtspiError> { + let member = hdr.member().ok_or(AtspiError::MissingMember)?; + if member != Self::DBUS_MEMBER { + return Err(AtspiError::MemberMatch(format!( + "The member {} does not match the signal's member: {}", + // unwrap is safe here because of guard above + member, + Self::DBUS_MEMBER, + ))); + } + Ok(()) + } + + /// Validate the body signature against the [`zbus::wire::Signature`] of [`MessageConversion::Body`] + /// + /// # Errors + /// + /// - [`type@AtspiError::SignatureMatch`] if the signatures do not match + fn validate_body(msg: &zbus::Message) -> Result<(), AtspiError> { + let body = msg.body(); + let body_signature = body.signature(); + + let expected_signature = B::SIGNATURE; + if body_signature != expected_signature { + return Err(AtspiError::SignatureMatch(format!( + "The message signature {} does not match the signal's body signature: {}", + body_signature, + &expected_signature.to_string(), + ))); + } + Ok(()) + } +} + +#[cfg(feature = "zbus")] +pub trait MessageConversion<'a>: DBusProperties { + /// What is the body type of this event. + type Body<'msg>: Type + Deserialize<'msg> + Serialize + where + Self: 'msg; + + /// Build an event from a [`zbus::Message`] reference. + /// This function will not check for any of the following error conditions: + /// + /// - That the message has an interface: [`type@AtspiError::MissingInterface`] + /// - That the message interface matches the one for the event: [`type@AtspiError::InterfaceMatch`] + /// - That the message has an member: [`type@AtspiError::MissingMember`] + /// - That the message member matches the one for the event: [`type@AtspiError::MemberMatch`] + /// - That the message signature matches the one for the event: [`type@AtspiError::SignatureMatch`] + /// + /// Therefore, this should only be used when one has checked the above conditions. + /// These must be checked manually. + /// Alternatively, there is the [`MessageConversionExt::try_from_message`] that will check these + /// conditions for you. + /// + /// This type also implements `TryFrom<&zbus::Message>`; consider using this if you are not an + /// internal developer. + /// + /// # Errors + /// + /// It is possible to get a [`type@AtspiError::Zvariant`] error if you do not check the proper + /// conditions before calling this. + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result + where + Self: Sized + 'a; + + /// Build an event from an [`ObjectRef`] and [`Self::Body`]. + /// This function will not check for any of the following error conditions: + /// + /// - That the message has an interface: [`type@AtspiError::MissingInterface`] + /// - That the message interface matches the one for the event: [`type@AtspiError::InterfaceMatch`] + /// - That the message has an member: [`type@AtspiError::MissingMember`] + /// - That the message member matches the one for the event: [`type@AtspiError::MemberMatch`] + /// + /// Therefore, this should only be used when one has checked the above conditions. + /// + /// # Errors + /// + /// Some [`Self::Body`] types may fallibly convert data fields contained in the body. + /// If this happens, then the function will return an error. + fn from_message_unchecked_parts(obj_ref: ObjectRef, body: DbusBody) -> Result + where + Self: Sized; + + /// The body of the object. + fn body(&self) -> Self::Body<'_>; +} diff --git a/patches/atspi-common/src/events/window.rs b/patches/atspi-common/src/events/window.rs new file mode 100644 index 0000000..8ed6862 --- /dev/null +++ b/patches/atspi-common/src/events/window.rs @@ -0,0 +1,504 @@ +#[cfg(feature = "zbus")] +use crate::error::AtspiError; +#[cfg(feature = "zbus")] +use crate::events::EventBody; +#[cfg(feature = "zbus")] +use crate::events::MessageConversion; +use crate::events::{ + DBusInterface, DBusMatchRule, DBusMember, EventBodyOwned, RegistryEventString, +}; +use crate::object_ref::ObjectRefOwned; +#[cfg(feature = "zbus")] +use crate::{EventProperties, ObjectRef}; +use serde::Deserialize; +use serde::Serialize; +#[cfg(feature = "zbus")] +use zbus::message::{Body as DbusBody, Header}; + +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Eq, Hash, Default)] +pub struct PropertyChangeEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, + pub property: String, +} + +impl_event_type_properties_for_event!(PropertyChangeEvent); + +/// The window has been minimized. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct MinimizeEvent { + /// The application which has been minimized. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(MinimizeEvent); + +/// The window has been maximized. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct MaximizeEvent { + /// The application which has been maximized. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(MaximizeEvent); + +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct RestoreEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(RestoreEvent); + +/// A window has been closed. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct CloseEvent { + /// The application which has been closed. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(CloseEvent); + +/// A new window has been created. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct CreateEvent { + /// An application to query for additional events from. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(CreateEvent); + +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct ReparentEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(ReparentEvent); + +/// A new virtual desktop has been created. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub struct DesktopCreateEvent { + /// A reference to a new desktop + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(DesktopCreateEvent); + +/// A virtual desktop has been deleted. +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Eq, Hash, Default)] +pub struct DesktopDestroyEvent { + /// A reference to the destroyed desktop. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(DesktopDestroyEvent); + +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Eq, Hash, Default)] +pub struct DestroyEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} +impl_event_type_properties_for_event!(DestroyEvent); + +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Eq, Hash, Default)] +pub struct ActivateEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(ActivateEvent); + +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Eq, Hash, Default)] +pub struct DeactivateEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(DeactivateEvent); + +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Eq, Hash, Default)] +pub struct RaiseEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(RaiseEvent); + +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Eq, Hash, Default)] +pub struct LowerEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(LowerEvent); + +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Eq, Hash, Default)] +pub struct MoveEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(MoveEvent); + +/// A window has been resized. +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Eq, Hash, Default)] +pub struct ResizeEvent { + /// The application which has been resized. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(ResizeEvent); + +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Eq, Hash, Default)] +pub struct ShadeEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(ShadeEvent); + +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Eq, Hash, Default)] +pub struct UUshadeEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(UUshadeEvent); + +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Eq, Hash, Default)] +pub struct RestyleEvent { + /// The [`crate::ObjectRef`] which the event applies to. + pub item: ObjectRefOwned, +} + +impl_event_type_properties_for_event!(RestyleEvent); + +impl_member_interface_registry_string_and_match_rule_for_event!( + PropertyChangeEvent, + "PropertyChange", + "org.a11y.atspi.Event.Window", + "window:property-change", + "type='signal',interface='org.a11y.atspi.Event.Window',member='PropertyChange'" +); + +#[cfg(feature = "zbus")] +impl MessageConversion<'_> for PropertyChangeEvent { + type Body<'a> = EventBody<'a>; + + fn from_message_unchecked_parts(item: ObjectRef, body: DbusBody) -> Result { + let mut body = body.deserialize_ignore_signature::>()?; + Ok(Self { item: item.into(), property: body.take_kind() }) + } + + fn from_message_unchecked(msg: &zbus::Message, header: &Header) -> Result { + let item = header.try_into()?; + let body = msg.body(); + Self::from_message_unchecked_parts(item, body) + } + + fn body(&self) -> Self::Body<'_> { + EventBody::Owned(EventBodyOwned { kind: self.property.clone(), ..Default::default() }) + } +} + +impl_member_interface_registry_string_and_match_rule_for_event!( + MinimizeEvent, + "Minimize", + "org.a11y.atspi.Event.Window", + "window:minimize", + "type='signal',interface='org.a11y.atspi.Event.Window',member='Minimize'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + MaximizeEvent, + "Maximize", + "org.a11y.atspi.Event.Window", + "window:maximize", + "type='signal',interface='org.a11y.atspi.Event.Window',member='Maximize'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + RestoreEvent, + "Restore", + "org.a11y.atspi.Event.Window", + "window:restore", + "type='signal',interface='org.a11y.atspi.Event.Window',member='Restore'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + CloseEvent, + "Close", + "org.a11y.atspi.Event.Window", + "window:close", + "type='signal',interface='org.a11y.atspi.Event.Window',member='Close'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + CreateEvent, + "Create", + "org.a11y.atspi.Event.Window", + "window:create", + "type='signal',interface='org.a11y.atspi.Event.Window',member='Create'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + ReparentEvent, + "Reparent", + "org.a11y.atspi.Event.Window", + "window:reparent", + "type='signal',interface='org.a11y.atspi.Event.Window',member='Reparent'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + DesktopCreateEvent, + "DesktopCreate", + "org.a11y.atspi.Event.Window", + "window:desktop-create", + "type='signal',interface='org.a11y.atspi.Event.Window',member='DesktopCreate'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + DesktopDestroyEvent, + "DesktopDestroy", + "org.a11y.atspi.Event.Window", + "window:desktop-destroy", + "type='signal',interface='org.a11y.atspi.Event.Window',member='DesktopDestroy'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + DestroyEvent, + "Destroy", + "org.a11y.atspi.Event.Window", + "window:destroy", + "type='signal',interface='org.a11y.atspi.Event.Window',member='Destroy'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + ActivateEvent, + "Activate", + "org.a11y.atspi.Event.Window", + "window:activate", + "type='signal',interface='org.a11y.atspi.Event.Window',member='Activate'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + DeactivateEvent, + "Deactivate", + "org.a11y.atspi.Event.Window", + "window:deactivate", + "type='signal',interface='org.a11y.atspi.Event.Window',member='Deactivate'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + RaiseEvent, + "Raise", + "org.a11y.atspi.Event.Window", + "window:raise", + "type='signal',interface='org.a11y.atspi.Event.Window',member='Raise'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + LowerEvent, + "Lower", + "org.a11y.atspi.Event.Window", + "window:lower", + "type='signal',interface='org.a11y.atspi.Event.Window',member='Lower'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + MoveEvent, + "Move", + "org.a11y.atspi.Event.Window", + "window:move", + "type='signal',interface='org.a11y.atspi.Event.Window',member='Move'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + ResizeEvent, + "Resize", + "org.a11y.atspi.Event.Window", + "window:resize", + "type='signal',interface='org.a11y.atspi.Event.Window',member='Resize'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + ShadeEvent, + "Shade", + "org.a11y.atspi.Event.Window", + "window:shade", + "type='signal',interface='org.a11y.atspi.Event.Window',member='Shade'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + UUshadeEvent, + "uUshade", + "org.a11y.atspi.Event.Window", + "window:uushade", + "type='signal',interface='org.a11y.atspi.Event.Window',member='uUshade'" +); + +impl_member_interface_registry_string_and_match_rule_for_event!( + RestyleEvent, + "Restyle", + "org.a11y.atspi.Event.Window", + "window:restyle", + "type='signal',interface='org.a11y.atspi.Event.Window',member='Restyle'" +); + +event_test_cases!(PropertyChangeEvent); +impl_to_dbus_message!(PropertyChangeEvent); +impl_from_dbus_message!(PropertyChangeEvent); +impl_event_properties!(PropertyChangeEvent); +impl From for EventBodyOwned { + fn from(event: PropertyChangeEvent) -> Self { + EventBodyOwned { kind: event.property, ..Default::default() } + } +} + +event_test_cases!(MinimizeEvent); +impl_to_dbus_message!(MinimizeEvent); +impl_from_dbus_message!(MinimizeEvent); +impl_event_properties!(MinimizeEvent); +impl_from_object_ref!(MinimizeEvent); + +event_test_cases!(MaximizeEvent); +impl_to_dbus_message!(MaximizeEvent); +impl_from_dbus_message!(MaximizeEvent); +impl_event_properties!(MaximizeEvent); +impl_from_object_ref!(MaximizeEvent); + +event_test_cases!(RestoreEvent); +impl_to_dbus_message!(RestoreEvent); +impl_from_dbus_message!(RestoreEvent); +impl_event_properties!(RestoreEvent); +impl_from_object_ref!(RestoreEvent); + +event_test_cases!(CloseEvent); +impl_to_dbus_message!(CloseEvent); +impl_from_dbus_message!(CloseEvent); +impl_event_properties!(CloseEvent); +impl_from_object_ref!(CloseEvent); + +event_test_cases!(CreateEvent); +impl_to_dbus_message!(CreateEvent); +impl_from_dbus_message!(CreateEvent); +impl_event_properties!(CreateEvent); +impl_from_object_ref!(CreateEvent); + +event_test_cases!(ReparentEvent); +impl_to_dbus_message!(ReparentEvent); +impl_from_dbus_message!(ReparentEvent); +impl_event_properties!(ReparentEvent); +impl_from_object_ref!(ReparentEvent); + +event_test_cases!(DesktopCreateEvent); +impl_to_dbus_message!(DesktopCreateEvent); +impl_from_dbus_message!(DesktopCreateEvent); +impl_event_properties!(DesktopCreateEvent); +impl_from_object_ref!(DesktopCreateEvent); + +event_test_cases!(DesktopDestroyEvent); +impl_to_dbus_message!(DesktopDestroyEvent); +impl_from_dbus_message!(DesktopDestroyEvent); +impl_event_properties!(DesktopDestroyEvent); +impl_from_object_ref!(DesktopDestroyEvent); + +event_test_cases!(DestroyEvent); +impl_to_dbus_message!(DestroyEvent); +impl_from_dbus_message!(DestroyEvent); +impl_event_properties!(DestroyEvent); +impl_from_object_ref!(DestroyEvent); + +event_test_cases!(ActivateEvent); +impl_to_dbus_message!(ActivateEvent); +impl_from_dbus_message!(ActivateEvent); +impl_event_properties!(ActivateEvent); +impl_from_object_ref!(ActivateEvent); + +event_test_cases!(DeactivateEvent); +impl_to_dbus_message!(DeactivateEvent); +impl_from_dbus_message!(DeactivateEvent); +impl_event_properties!(DeactivateEvent); +impl_from_object_ref!(DeactivateEvent); + +event_test_cases!(RaiseEvent); +impl_to_dbus_message!(RaiseEvent); +impl_from_dbus_message!(RaiseEvent); +impl_event_properties!(RaiseEvent); +impl_from_object_ref!(RaiseEvent); + +event_test_cases!(LowerEvent); +impl_to_dbus_message!(LowerEvent); +impl_from_dbus_message!(LowerEvent); +impl_event_properties!(LowerEvent); +impl_from_object_ref!(LowerEvent); + +event_test_cases!(MoveEvent); +impl_to_dbus_message!(MoveEvent); +impl_from_dbus_message!(MoveEvent); +impl_event_properties!(MoveEvent); +impl_from_object_ref!(MoveEvent); + +event_test_cases!(ResizeEvent); +impl_to_dbus_message!(ResizeEvent); +impl_from_dbus_message!(ResizeEvent); +impl_event_properties!(ResizeEvent); +impl_from_object_ref!(ResizeEvent); + +event_test_cases!(ShadeEvent); +impl_to_dbus_message!(ShadeEvent); +impl_from_dbus_message!(ShadeEvent); +impl_event_properties!(ShadeEvent); +impl_from_object_ref!(ShadeEvent); + +event_test_cases!(UUshadeEvent); +impl_to_dbus_message!(UUshadeEvent); +impl_from_dbus_message!(UUshadeEvent); +impl_event_properties!(UUshadeEvent); +impl_from_object_ref!(UUshadeEvent); + +event_test_cases!(RestyleEvent); +impl_to_dbus_message!(RestyleEvent); +impl_from_dbus_message!(RestyleEvent); +impl_event_properties!(RestyleEvent); +impl_from_object_ref!(RestyleEvent); + +impl_msg_conversion_ext_for_target_type!(PropertyChangeEvent); +impl_msg_conversion_ext_for_target_type!(MinimizeEvent); +impl_msg_conversion_ext_for_target_type!(MaximizeEvent); +impl_msg_conversion_ext_for_target_type!(RestoreEvent); +impl_msg_conversion_ext_for_target_type!(CloseEvent); +impl_msg_conversion_ext_for_target_type!(CreateEvent); +impl_msg_conversion_ext_for_target_type!(ReparentEvent); +impl_msg_conversion_ext_for_target_type!(DesktopCreateEvent); +impl_msg_conversion_ext_for_target_type!(DesktopDestroyEvent); +impl_msg_conversion_ext_for_target_type!(DestroyEvent); +impl_msg_conversion_ext_for_target_type!(ActivateEvent); +impl_msg_conversion_ext_for_target_type!(DeactivateEvent); +impl_msg_conversion_ext_for_target_type!(RaiseEvent); +impl_msg_conversion_ext_for_target_type!(LowerEvent); +impl_msg_conversion_ext_for_target_type!(MoveEvent); +impl_msg_conversion_ext_for_target_type!(ResizeEvent); +impl_msg_conversion_ext_for_target_type!(ShadeEvent); +impl_msg_conversion_ext_for_target_type!(UUshadeEvent); +impl_msg_conversion_ext_for_target_type!(RestyleEvent); + +impl_msg_conversion_for_types_built_from_object_ref!(MinimizeEvent); +impl_msg_conversion_for_types_built_from_object_ref!(MaximizeEvent); +impl_msg_conversion_for_types_built_from_object_ref!(RestoreEvent); +impl_msg_conversion_for_types_built_from_object_ref!(CloseEvent); +impl_msg_conversion_for_types_built_from_object_ref!(CreateEvent); +impl_msg_conversion_for_types_built_from_object_ref!(ReparentEvent); +impl_msg_conversion_for_types_built_from_object_ref!(DesktopCreateEvent); +impl_msg_conversion_for_types_built_from_object_ref!(DesktopDestroyEvent); +impl_msg_conversion_for_types_built_from_object_ref!(DestroyEvent); +impl_msg_conversion_for_types_built_from_object_ref!(ActivateEvent); +impl_msg_conversion_for_types_built_from_object_ref!(DeactivateEvent); +impl_msg_conversion_for_types_built_from_object_ref!(RaiseEvent); +impl_msg_conversion_for_types_built_from_object_ref!(LowerEvent); +impl_msg_conversion_for_types_built_from_object_ref!(MoveEvent); +impl_msg_conversion_for_types_built_from_object_ref!(ResizeEvent); +impl_msg_conversion_for_types_built_from_object_ref!(ShadeEvent); +impl_msg_conversion_for_types_built_from_object_ref!(UUshadeEvent); +impl_msg_conversion_for_types_built_from_object_ref!(RestyleEvent); diff --git a/patches/atspi-common/src/interface.rs b/patches/atspi-common/src/interface.rs new file mode 100644 index 0000000..f4dffee --- /dev/null +++ b/patches/atspi-common/src/interface.rs @@ -0,0 +1,308 @@ +//! Conversion functions and types representing a set of [`Interface`]s. +//! +//! Each `AccessibleProxy` will implement some set of these interfaces, +//! represented by a [`InterfaceSet`]. + +use enumflags2::{bitflags, BitFlag, BitFlags}; +use serde::{ + de::{self, Deserializer, Visitor}, + ser::{self, Serializer}, + Deserialize, Serialize, +}; +use std::fmt; +use zbus::wire::{Signature, Type}; + +/// AT-SPI interfaces an accessible object can implement. +#[bitflags] +#[repr(u32)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub enum Interface { + /// Interface to indicate implementation of `AccessibleProxy`. + #[serde(rename = "org.a11y.atspi.Accessible")] + Accessible, + /// Interface to indicate implementation of `ActionProxy`. + #[serde(rename = "org.a11y.atspi.Action")] + Action, + /// Interface to indicate implementation of `ApplicationProxy`. + #[serde(rename = "org.a11y.atspi.Application")] + Application, + /// Interface to indicate implementation of `CacheProxy`. + #[serde(rename = "org.a11y.atspi.Cache")] + Cache, + /// Interface to indicate implementation of `CollectionProxy`. + #[serde(rename = "org.a11y.atspi.Collection")] + Collection, + /// Interface to indicate implementation of `ComponentProxy`. + #[serde(rename = "org.a11y.atspi.Component")] + Component, + /// Interface to indicate implementation of `DocumentProxy`. + #[serde(rename = "org.a11y.atspi.Document")] + Document, + /// Interface to indicate implementation of `DeviceEventControllerProxy`. + #[serde(rename = "org.a11y.atspi.DeviceEventController")] + DeviceEventController, + /// Interface to indicate implementation of `DeviceEventListenerProxy`. + #[serde(rename = "org.a11y.atspi.DeviceEventListener")] + DeviceEventListener, + /// Interface to indicate implementation of `EditableTextProxy`. + #[serde(rename = "org.a11y.atspi.EditableText")] + EditableText, + /// Interface to indicate implementation of `HyperlinkProxy`. + #[serde(rename = "org.a11y.atspi.Hyperlink")] + Hyperlink, + /// Interface to indicate implementation of `HypertextProxy`. + #[serde(rename = "org.a11y.atspi.Hypertext")] + Hypertext, + /// Interface to indicate implementation of `ImageProxy`. + #[serde(rename = "org.a11y.atspi.Image")] + Image, + /// Interface to indicate implementation of `RegistryProxy`. + #[serde(rename = "org.a11y.atspi.Registry")] + Registry, + /// Interface to indicate implementation of `SelectionProxy`. + #[serde(rename = "org.a11y.atspi.Selection")] + Selection, + /// Interface to indicate implementation of `SocketProxy`. + #[serde(rename = "org.a11y.atspi.Socket")] + Socket, + /// Interface to indicate implementation of `TableProxy`. + #[serde(rename = "org.a11y.atspi.Table")] + Table, + /// Interface to indicate implementation of `TableCellProxy`. + #[serde(rename = "org.a11y.atspi.TableCell")] + TableCell, + /// Interface to indicate implementation of `TextProxy`. + #[serde(rename = "org.a11y.atspi.Text")] + Text, + /// Interface to indicate implementation of `ValueProxy`. + #[serde(rename = "org.a11y.atspi.Value")] + Value, +} + +/// A collection type which encodes the AT-SPI interfaces an accessible object has implemented. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub struct InterfaceSet(BitFlags); + +impl InterfaceSet { + pub fn new>>(value: B) -> Self { + Self(value.into()) + } + + #[must_use] + pub fn empty() -> InterfaceSet { + InterfaceSet(Interface::empty()) + } + + #[must_use] + pub fn bits(&self) -> u32 { + self.0.bits() + } + + #[must_use] + pub fn all() -> InterfaceSet { + InterfaceSet(Interface::all()) + } + + pub fn contains>>(self, other: B) -> bool { + self.0.contains(other) + } + + pub fn insert>>(&mut self, other: B) { + self.0.insert(other); + } + + #[must_use] + pub fn iter(&self) -> enumflags2::Iter { + self.0.iter() + } +} + +impl IntoIterator for InterfaceSet { + type IntoIter = enumflags2::Iter; + type Item = Interface; + + fn into_iter(self) -> Self::IntoIter { + self.iter() + } +} + +impl IntoIterator for &InterfaceSet { + type IntoIter = enumflags2::Iter; + type Item = Interface; + + fn into_iter(self) -> Self::IntoIter { + self.iter() + } +} + +impl Default for InterfaceSet { + fn default() -> Self { + Self::empty() + } +} + +impl<'de> de::Deserialize<'de> for InterfaceSet { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct InterfaceSetVisitor; + + impl<'de> Visitor<'de> for InterfaceSetVisitor { + type Value = InterfaceSet; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("a sequence comprised of valid AT-SPI interface names") + } + + fn visit_newtype_struct(self, deserializer: D) -> Result + where + D: Deserializer<'de>, + { + match as Deserialize>::deserialize(deserializer) { + Ok(interfaces) => Ok(InterfaceSet(BitFlags::from_iter(interfaces))), + Err(e) => Err(e), + } + } + } + + deserializer.deserialize_newtype_struct("InterfaceSet", InterfaceSetVisitor) + } +} + +impl ser::Serialize for InterfaceSet { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer + .serialize_newtype_struct("InterfaceSet", &self.0.iter().collect::>()) + } +} + +impl Type for InterfaceSet { + const SIGNATURE: &'static Signature = as Type>::SIGNATURE; +} + +impl FromIterator for InterfaceSet { + fn from_iter>(iter: T) -> Self { + Self(BitFlags::from_iter(iter)) + } +} + +impl<'a> FromIterator<&'a Interface> for InterfaceSet { + fn from_iter>(iter: I) -> Self { + InterfaceSet(iter.into_iter().copied().collect()) + } +} + +impl From for InterfaceSet { + fn from(value: Interface) -> Self { + Self(value.into()) + } +} + +impl std::ops::BitAnd for InterfaceSet { + type Output = InterfaceSet; + + fn bitand(self, other: Self) -> Self::Output { + InterfaceSet(self.0 & other.0) + } +} + +impl std::ops::BitXor for InterfaceSet { + type Output = InterfaceSet; + + fn bitxor(self, other: Self) -> Self::Output { + InterfaceSet(self.0 ^ other.0) + } +} + +impl std::ops::BitOr for InterfaceSet { + type Output = InterfaceSet; + + fn bitor(self, other: Self) -> Self::Output { + InterfaceSet(self.0 | other.0) + } +} + +#[cfg(test)] +mod tests { + use super::{Interface, InterfaceSet}; + use zbus::wire::serialized::Data; + use zbus::wire::{serialized::Context, to_bytes, LE}; + + #[test] + fn serialize_empty_interface_set() { + let ctxt = Context::new(LE, 0); + let encoded = to_bytes(ctxt, &InterfaceSet::empty()).unwrap(); + assert_eq!(encoded.bytes(), &[0, 0, 0, 0]); + } + + #[test] + fn deserialize_empty_interface_set() { + let ctxt = Context::new(LE, 0); + let encoded = to_bytes(ctxt, &InterfaceSet::empty()).unwrap(); + let (decoded, _) = encoded.deserialize::().unwrap(); + assert_eq!(decoded, InterfaceSet::empty()); + } + + #[test] + fn serialize_interface_set_accessible() { + let ctxt = Context::new(LE, 0); + let encoded = to_bytes(ctxt, &InterfaceSet::new(Interface::Accessible)).unwrap(); + assert_eq!( + encoded.bytes(), + &[ + 30, 0, 0, 0, 25, 0, 0, 0, 111, 114, 103, 46, 97, 49, 49, 121, 46, 97, 116, 115, + 112, 105, 46, 65, 99, 99, 101, 115, 115, 105, 98, 108, 101, 0 + ] + ); + } + + #[test] + fn deserialize_interface_set_accessible() { + let ctxt = Context::new(LE, 0); + let data = Data::new::<&[u8]>( + &[ + 30, 0, 0, 0, 25, 0, 0, 0, 111, 114, 103, 46, 97, 49, 49, 121, 46, 97, 116, 115, + 112, 105, 46, 65, 99, 99, 101, 115, 115, 105, 98, 108, 101, 0, + ], + ctxt, + ); + + let (ifaceset, _) = data.deserialize::().unwrap(); + assert_eq!(ifaceset, InterfaceSet::new(Interface::Accessible)); + } + + #[test] + fn can_handle_multiple_interfaces() { + let ctxt = Context::new(LE, 0); + let object = + InterfaceSet::new(Interface::Accessible | Interface::Action | Interface::Component); + let encoded = to_bytes(ctxt, &object).unwrap(); + let (decoded, _) = encoded.deserialize::().unwrap(); + assert!(object == decoded); + } + + // The order of appearance of the interfaces is equal to the order in the enum. + #[test] + fn iterator_on_interface_set() { + let set = + InterfaceSet::new(Interface::Accessible | Interface::Action | Interface::Component); + let mut iter = set.into_iter(); + assert_eq!(iter.next(), Some(Interface::Accessible)); + assert_eq!(iter.next(), Some(Interface::Action)); + assert_eq!(iter.next(), Some(Interface::Component)); + assert_eq!(iter.next(), None); + } + + #[test] + fn iterator_on_interface_set_ref() { + let set = InterfaceSet::new(Interface::Text | Interface::Collection | Interface::Component); + let mut iter = (&set).into_iter(); + assert_eq!(iter.next(), Some(Interface::Collection)); + assert_eq!(iter.next(), Some(Interface::Component)); + assert_eq!(iter.next(), Some(Interface::Text)); + } +} diff --git a/patches/atspi-common/src/lib.rs b/patches/atspi-common/src/lib.rs new file mode 100644 index 0000000..452224c --- /dev/null +++ b/patches/atspi-common/src/lib.rs @@ -0,0 +1,278 @@ +#![deny(clippy::all, clippy::pedantic, clippy::cargo, unsafe_code, rustdoc::all)] +#![allow(clippy::module_name_repetitions)] +#![allow(clippy::multiple_crate_versions)] + +//! # atspi-common +//! +//! Defines all common types, events, and data structures for `atspi-proxies` and `atspi-connection`. +//! Since `atspi-proxies` and `atspi-connection` are downstream crates, the documentation can not link to it directly. +//! Any type ending in `*Proxy` is in `atspi-proxies`. +//! + +#[macro_use] +extern crate static_assertions; +#[macro_use] +pub(crate) mod macros; + +pub mod action; +#[cfg(feature = "wrappers")] +pub use crate::events::event_wrappers::{ + CacheEvents, DocumentEvents, Event, EventListenerEvents, FocusEvents, KeyboardEvents, + MouseEvents, ObjectEvents, TerminalEvents, WindowEvents, +}; +pub use action::Action; +pub mod object_match; +pub use object_match::{MatchType, ObjectMatchRule, SortOrder, TreeTraversalType}; +pub mod object_ref; +pub use object_ref::{ObjectRef, ObjectRefOwned}; +pub mod operation; +pub use operation::Operation; +pub mod interface; +pub use interface::{Interface, InterfaceSet}; +pub mod state; +pub use state::{State, StateSet}; +pub mod cache; +pub use cache::{CacheItem, LegacyCacheItem}; +pub mod error; +pub use error::AtspiError; +pub mod events; +pub use events::{EventProperties, EventTypeProperties}; +mod role; +pub use role::Role; +mod relation_type; +pub use relation_type::RelationType; + +use serde::{Deserialize, Serialize}; +use zbus::wire::Type; + +pub type Result = std::result::Result; + +/// Describes a selection of text, including selections across object boundaries. +/// +/// For example, selecting from the beginning of a paragraph to half way through a link would cause +/// the start and end object references to be different. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] +pub struct TextSelection { + /// starting object reference + start_obj: ObjectRefOwned, + /// text offset within `start_obj` + start_idx: i32, + /// ending object reference + end_obj: ObjectRefOwned, + /// text offset within `end_obj` + end_idx: i32, + /// is the `start_obj` active; + /// + /// This is the same as querying for the [`StateSet`], then checking if [`State::Active`] is contained. + /// See `atspi_proxies::accessible::AccessibleProxy` for more information on checking state. + start_is_active: bool, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] +#[repr(u32)] +/// The coordinate type encodes the frame of reference. +pub enum CoordType { + /// In relation to the entire screen. + Screen, + /// In relation to only the window. + Window, + /// In relation to the parent of the element being checked. + Parent, +} + +#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Serialize, Deserialize, Type)] +#[repr(u32)] +/// Enumeration used by `TextProxy` to indicate how to treat characters intersecting bounding boxes. +pub enum ClipType { + /// No characters/glyphs are omitted. + Neither, + /// Characters/glyphs clipped by the minimum coordinate are omitted. + Min, + /// Characters/glyphs which intersect the maximum coordinate are omitted. + Max, + /// Only glyphs falling entirely within the region bounded by min and max are retained. + Both, +} + +#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Serialize, Deserialize, Type)] +#[repr(u32)] +/// Level of granularity to get text of, in relation to a cursor position. +pub enum Granularity { + /// Gives the character at the index of the cursor. With a line-style cursor (which is standard) this will get the character that appears after the cursor. + Char, + /// Gives the entire word in front of, or which contains, the cursor. TODO: confirm that it always chooses the word in front of the cursor. + Word, + /// Gives entire sentence in front of, or which contains, the cursor. TODO: confirm that it always chooses the sentence after the cursor. + Sentence, + /// Gives the line, as seen visually of which the cursor is situated within. + Line, + /// Gives the entire block of text, regardless of where the cursor lies within it. + Paragraph, +} + +/// Indicates relative stacking order of a `atspi_proxies::component::ComponentProxy` with respect to the +/// onscreen visual representation of the UI. +/// +/// The layer index, in combination with the component's extents, +/// can be used to compute the visibility of all or part of a component. +/// This is important in programmatic determination of region-of-interest for magnification, +/// and in flat screen review models of the screen, as well as for other uses. +/// Objects residing in two of the `Layer` categories support further z-ordering information, +/// with respect to their peers in the same layer: +/// namely, [`Layer::Window`] and [`Layer::Mdi`]. +/// Relative stacking order for other objects within the same layer is not available; +/// the recommended heuristic is first child paints first. In other words, +/// assume that the first siblings in the child list are subject to being +/// overpainted by later siblings if their bounds intersect. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] +pub enum Layer { + /// Indicates an error condition or uninitialized value. + Invalid, + /// Reserved for the desktop background; this is the bottom-most layer, + /// over which everything else is painted. + Background, + /// The 'background' layer for most content renderers and + /// UI `atspi_proxies::component::ComponentProxy` containers. + Canvas, + /// The layer in which the majority of ordinary 'foreground' widgets reside. + Widget, + /// A special layer between [`Layer::Canvas`] and [`Layer::Widget`], in which the + /// 'pseudo windows' (e.g. the Multiple-Document Interface frames) reside. + /// + /// See `atspi_proxies::component::ComponentProxy::get_mdizorder`. + Mdi, + /// A layer for popup window content, above [`Layer::Widget`]. + Popup, + /// The topmost layer. + Overlay, + /// The layer in which a toplevel window background usually resides. + Window, +} + +/// Enumeration used by interface the [`crate::interface::Interface::Accessible`] to specify where an object should be placed on the screen when using `scroll_to`. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] +pub enum ScrollType { + /// Scroll the object to the top left corner of the window. + TopLeft, + /// Scroll the object to the bottom right corner of the window. + BottomRight, + /// Scroll the object to the top edge of the window. + TopEdge, + /// Scroll the object to the bottom edge of the window. + BottomEdge, + /// Scroll the object to the left edge of the window. + LeftEdge, + /// Scroll the object to the right edge of the window. + RightEdge, + /// Scroll the object to application-dependent position on the window. + Anywhere, +} + +/// Enumeration used to indicate a type of live region and how assertive it +/// should be in terms of speaking notifications. +/// +/// Currently, this is only used +/// for `Announcement` events, but it may be used for additional purposes +/// in the future. +/// The argument in the `Announcement` event is named `politeness`. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize, Type)] +#[repr(i32)] +pub enum Politeness { + /// No live region. + #[default] + None = 0, + /// This live region should be considered polite. + Polite = 1, + /// This live region should be considered assertive. + Assertive = 2, +} + +impl TryFrom for Politeness { + type Error = AtspiError; + + fn try_from(value: i32) -> std::result::Result { + match value { + 0 => Ok(Politeness::None), + 1 => Ok(Politeness::Polite), + 2 => Ok(Politeness::Assertive), + _ => Err(AtspiError::Conversion("Unknown Politeness variant")), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::str::FromStr; + use zbus_lockstep::{ + method_args_signature, method_return_signature, signal_body_type_signature, + }; + use zbus::wire::Signature; + + #[test] + fn convert_i32_to_live() { + assert_eq!(Politeness::None, Politeness::try_from(0).unwrap()); + assert_eq!(Politeness::Polite, Politeness::try_from(1).unwrap()); + assert_eq!(Politeness::Assertive, Politeness::try_from(2).unwrap()); + assert!(Politeness::try_from(3).is_err()); + assert!(Politeness::try_from(-1).is_err()); + } + + #[test] + fn validate_live_signature() { + let signature = signal_body_type_signature!("Announcement"); + let politeness_signature_str = &signature.to_string_no_parens(); + let politeness_signature = Signature::from_str(&politeness_signature_str.as_str()[1..2]) + .expect("Valid signature pattern"); + assert_eq!(*::SIGNATURE, politeness_signature); + } + + #[test] + fn validate_scroll_type_signature() { + let signature = method_args_signature!(member: "ScrollTo", interface: "org.a11y.atspi.Component", argument: "type"); + assert_eq!(*::SIGNATURE, signature); + } + + #[test] + fn validate_layer_signature() { + let signature = method_return_signature!("GetLayer"); + assert_eq!(*::SIGNATURE, signature); + } + + #[test] + fn validate_granularity_signature() { + let signature = method_args_signature!(member: "GetStringAtOffset", interface: "org.a11y.atspi.Text", argument: "granularity"); + assert_eq!(*::SIGNATURE, signature); + } + + #[test] + fn validate_clip_type_signature() { + let signature = method_args_signature!(member: "GetTextAtOffset", interface: "org.a11y.atspi.Text", argument: "type"); + assert_eq!(*::SIGNATURE, signature); + } + + #[test] + fn validate_coord_type_signature() { + let signature = method_args_signature!(member: "GetImagePosition", interface: "org.a11y.atspi.Image", argument: "coordType"); + assert_eq!(*::SIGNATURE, signature); + } + + #[test] + fn validate_match_type_signature() { + let rule_signature = method_args_signature!(member: "GetMatchesTo", interface: "org.a11y.atspi.Collection", argument: "rule"); + let match_type_signature_str = rule_signature.to_string(); + let match_type_signature = Signature::from_str(&match_type_signature_str.as_str()[3..4]) + .expect("Valid signature pattern"); + assert_eq!(*::SIGNATURE, match_type_signature); + } + + #[test] + fn validate_text_selection_signature() { + let selection_signature = method_args_signature!(member: "GetTextSelections", interface: "org.a11y.atspi.Document", argument: "selections"); + let selection_signature_str = selection_signature.to_string(); + let selection_signature = Signature::from_str(&selection_signature_str.as_str()[1..]) + .expect("Valid signature pattern"); + // this signature is written: `a(...)`, where `(...)` is the signature we want to compare against + assert_eq!(*::SIGNATURE, selection_signature); + } +} diff --git a/patches/atspi-common/src/macros.rs b/patches/atspi-common/src/macros.rs new file mode 100644 index 0000000..984a5f3 --- /dev/null +++ b/patches/atspi-common/src/macros.rs @@ -0,0 +1,1174 @@ +/// Expands to implement the required methods for the [`crate::EventProperties`] trait. +/// This depends on the struct to have an `item` field of type [`crate::ObjectRef`]. +/// +/// ```ignore +/// impl_from_interface_event_enum_for_event!(TextCaretMovedEvent); +/// ``` +/// +/// Expands to: +/// +/// ```ignore +/// impl EventProperties for TextCaretMovedEvent { +/// fn sender(&self) -> UniqueName<'_> { +/// self.item +/// .name() +/// .expect("Events are constructed with valid ObjetRef") +/// .as_ref() +/// } +/// fn path(&self) -> ObjectPath<'_> { +/// self.item.path().as_ref() +/// } +/// } +/// ``` +macro_rules! impl_event_properties { + ($type:ty) => { + impl crate::EventProperties for $type { + fn sender(&self) -> zbus::names::UniqueName<'_> { + self.item + .name() + .expect("Events are received with valid ObjetRef") + .as_ref() + } + + fn path(&self) -> zbus::wire::ObjectPath<'_> { + self.item.path().as_ref() + } + } + }; +} + +/// Expands to implement From for [`crate::ObjectRef`]. +/// This depends on the struct to have an `item` field of type [`crate::ObjectRef`]. +/// +/// ```ignore +/// impl_from_object_ref!(TextAttributesChangedEvent); +/// ``` +/// +/// Exapnds to: +/// +/// ```ignore +/// impl From for TextAttributesChangedEvent { +/// fn from(obj_ref: ObjectRef) -> Self { +/// Self { item: obj_ref.into() } +/// } +/// } +/// ``` +macro_rules! impl_from_object_ref { + ($type:ty) => { + impl From> for $type { + fn from(obj_ref: crate::ObjectRef) -> Self { + Self { item: obj_ref.into() } + } + } + }; +} + +#[cfg(feature = "wrappers")] +/// Expands to a conversion given the enclosed event type and outer `Event` variant. +/// +/// eg +/// ```ignore +/// impl_from_interface_event_enum_for_event!(ObjectEvents, Event::Object); +/// ``` +/// expands to: +/// +/// ```ignore +/// impl From for Event { +/// fn from(event_variant: ObjectEvents) -> Event { +/// Event::Object(event_variant.into()) +/// } +/// } +/// ``` +macro_rules! impl_from_interface_event_enum_for_event { + ($outer_type:ty, $outer_variant:path) => { + #[cfg(feature = "wrappers")] + impl From<$outer_type> for Event { + fn from(event_variant: $outer_type) -> Event { + $outer_variant(event_variant.into()) + } + } + }; +} + +#[cfg(feature = "wrappers")] +/// Expands to a conversion given the enclosed event enum type and outer `Event` variant. +/// +/// eg +/// ```ignore +/// impl_try_from_event_for_interface_enum!(ObjectEvents, Event::Object); +/// ``` +/// expands to: +/// +/// ```ignore +/// impl TryFrom for ObjectEvents { +/// type Error = AtspiError; +/// fn try_from(generic_event: Event) -> Result { +/// if let Event::Object(event_type) = generic_event { +/// Ok(event_type) +/// } else { +/// Err(AtspiError::Conversion("Invalid type")) +/// } +/// } +/// } +/// ``` +macro_rules! impl_try_from_event_for_interface_enum { + ($outer_type:ty, $outer_variant:path) => { + impl TryFrom for $outer_type { + type Error = AtspiError; + fn try_from(generic_event: Event) -> Result<$outer_type, Self::Error> { + if let $outer_variant(event_type) = generic_event { + Ok(event_type) + } else { + Err(AtspiError::Conversion("Invalid type")) + } + } + } + }; +} + +#[cfg(feature = "wrappers")] +/// Expands to a conversion given the user facing event type, +/// the wrapping interface enum variant, and the outer `Event` variant. +/// +/// ```ignore +/// impl_from_user_facing_event_for_interface_event_enum!(StateChangedEvent, ObjectEvents, ObjectEvents::StateChanged); +/// ``` +/// +/// expands to: +/// +/// ```ignore +/// impl From for ObjectEvents { +/// fn from(specific_event: StateChangedEvent) -> ObjectEvents { +/// ObjectEvents::StateChanged(specific_event) +/// } +/// } +/// ``` +macro_rules! impl_from_user_facing_event_for_interface_event_enum { + ($inner_type:ty, $outer_type:ty, $inner_variant:path) => { + impl From<$inner_type> for $outer_type { + fn from(specific_event: $inner_type) -> $outer_type { + $inner_variant(specific_event) + } + } + }; +} + +#[cfg(feature = "wrappers")] +/// Expands to a conversion given two arguments, +/// 1. the user facing event type `(inner_type)` +/// which relies on a conversion to its interface variant enum type variant. +/// 2. the outer `Event::)>` wrapper., +/// the enum type and outtermost variant. +/// +/// ```ignore user facing type, outer event variant +/// impl_from_user_facing_type_for_event_enum!(StateChangedEvent, Event::Object); +/// ``` +/// +/// expands to: +/// +/// ```ignore +/// impl From for Event { +/// fn from(event_variant: StateChangedEvent) -> Event { +/// Event::Object(ObjectEvents::StateChanged(event_variant)) +/// } +/// } +/// ``` +macro_rules! impl_from_user_facing_type_for_event_enum { + ($inner_type:ty, $outer_variant:path) => { + #[cfg(feature = "wrappers")] + impl From<$inner_type> for Event { + fn from(event_variant: $inner_type) -> Event { + $outer_variant(event_variant.into()) + } + } + }; +} + +#[cfg(feature = "wrappers")] +/// Expands to a `TryFrom for T` where T is the user facing type. +/// The macro takes three arguments: +/// +/// 1. The user facing type. +/// 2. The inner variant of the user facing type. +/// 3. The outer variant of the `Event` enum. +/// +/// ```ignore +/// impl_try_from_event_for_user_facing_type!( +/// StateChangedEvent, +/// ObjectEvents::StateChanged, +/// Event::Object +/// ); +/// ``` +/// expands to: +/// +/// ```ignore +/// impl TryFrom for StateChangedEvent { +/// type Error = AtspiError; +/// fn try_from(generic_event: Event) -> Result { +/// if let Event::Object(ObjectEvents::StateChanged(specific_event)) = generic_event { +/// Ok(specific_event) +/// } else { +/// Err(AtspiError::Conversion("Invalid type")) +/// } +/// } +/// } +/// ``` +/// +macro_rules! impl_try_from_event_for_user_facing_type { + ($inner_type:ty, $inner_variant:path, $outer_variant:path) => { + #[cfg(feature = "wrappers")] + impl TryFrom for $inner_type { + type Error = AtspiError; + fn try_from(generic_event: crate::Event) -> Result<$inner_type, Self::Error> { + if let $outer_variant($inner_variant(specific_event)) = generic_event { + Ok(specific_event) + } else { + Err(AtspiError::Conversion("Invalid type")) + } + } + } + }; +} + +/// Implements the `TryFrom` trait for a given event type. +/// Converts a user facing event type into a `zbus::Message`. +/// +/// # Example +/// ```ignore +/// impl_to_dbus_message!(StateChangedEvent); +/// ``` +/// expands to: +/// +/// ```ignore +/// impl TryFrom for zbus::Message { +/// type Error = AtspiError; +/// fn try_from(event: StateChangedEvent) -> Result { +/// Ok(zbus::Message::signal( +/// event.path(), +/// StateChangedEvent::DBUS_INTERFACE, +/// StateChangedEvent::DBUS_MEMBER, +/// )? +/// .sender(event.sender())? +/// .build(&event.body())?) +/// } +/// } +/// +macro_rules! impl_to_dbus_message { + ($type:ty) => { + #[cfg(feature = "zbus")] + impl TryFrom<$type> for zbus::Message { + type Error = AtspiError; + fn try_from(event: $type) -> Result { + use crate::events::{DBusInterface, DBusMember, MessageConversion}; + Ok(zbus::Message::signal( + event.path(), + <$type as DBusInterface>::DBUS_INTERFACE, + <$type as DBusMember>::DBUS_MEMBER, + ) + .sender(event.sender().to_string()) + .build(&event.body())?) + } + } + }; +} + +/// Implements the `TryFrom` trait for a given event type. +/// Converts a `zbus::Message` into a user facing event type. +/// +/// See [`crate::events::MessageConversion`] for details on implementation. +/// +/// # Example +/// ```ignore +/// impl_from_dbus_message!(StateChangedEvent); +/// ``` +/// expands to: +/// +/// ```ignore +/// impl TryFrom<&zbus::Message> for StateChangedEvents { +/// type Error = AtspiError; +/// fn try_from(msg: &zbus::Message) -> Result { +/// let hdr = msg.header(); +/// <$type as MessageConversion>::try_from_message(msg, hdr) +/// } +/// } +/// ``` +/// +/// There is also a variant that can be used for events whose [`crate::events::MessageConversion::Body`] is not +/// [`crate::events::event_body::EventBodyOwned`]. You can call this by setting the second parameter to `Explicit`. +macro_rules! impl_from_dbus_message { + ($type:ty) => { + impl_from_dbus_message!($type, Auto); + }; + + ($type:ty, Auto) => { + #[cfg(feature = "zbus")] + impl<'msg> TryFrom<&'msg zbus::Message> for $type { + type Error = AtspiError; + fn try_from(msg: &'msg zbus::Message) -> Result { + use crate::events::{EventBody, EventBodyQtBorrowed}; + use crate::events::traits::{MessageConversion, MessageConversionExt}; + use zbus::wire::Type; + use crate::ObjectRef; + + let hdr = msg.header(); + ::Body<'_>>>::validate_interface(&hdr)?; + ::Body<'_>>>::validate_member(&hdr)?; + let item = ObjectRef::try_from(&hdr)?; + + let body = msg.body(); + let signature = body.signature(); + + if signature == EventBody::SIGNATURE || signature == EventBodyQtBorrowed::SIGNATURE { + Ok(Self::from_message_unchecked_parts(item, body)?) + } else { + Err(AtspiError::SignatureMatch(format!( + "signature mismatch: expected: {}, signal body: {}", + msg.body().signature(), + ::Body::SIGNATURE, + ))) + } + } + } + }; + + ($type:ty, Explicit) => { + #[cfg(feature = "zbus")] + impl TryFrom<&zbus::Message> for $type { + type Error = crate::AtspiError; + fn try_from(msg: &zbus::Message) -> Result { + let hdr = msg.header(); + <$type as crate::events::MessageConversionExt<<$type as MessageConversion>::Body<'_>>>::try_from_message(msg, &hdr) + } + } + }; +} + +// We decorate the macro with a `#[cfg(test)]` attribute. +// This prevents Clippy from complaining about the macro not being used. +// It is being used, but only in test mode. +// +/// Tests `Default` and `BusProperties::from_message_unchecked` for a given event struct. +/// +/// Obtains a default for the given event struct. +/// Asserts that the path and sender are the default. +/// +/// Breaks the struct down into item (the associated object) and body. +/// Then tests `BusProperties::from_message_unchecked` with the item and body. +#[cfg(test)] +macro_rules! generic_event_test_case { + ($type:ty) => { + #[test] + fn generic_event_uses() { + use crate::events::traits::MessageConversion; + + let event_struct = <$type>::default(); + assert_eq!(event_struct.path().as_str(), crate::object_ref::TEST_OBJECT_PATH_STR); + assert_eq!(event_struct.sender().as_str(), crate::object_ref::TEST_OBJECT_BUS_NAME); + let body = event_struct.body(); + let body2 = Message::method_call( + event_struct.path().as_str(), + <$type as crate::events::DBusMember>::DBUS_MEMBER, + ) + .sender(event_struct.sender().as_str()) + .build(&(body,)) + .unwrap(); + let header = body2.header(); + let build_struct = <$type>::from_message_unchecked(&body2, &header) + .expect("<$type as Default>'s parts should build a valid ObjectRef"); + assert_eq!(event_struct, build_struct); + } + }; +} + +// We decorate the macro with a `#[cfg(test)]` attribute. +// This prevents Clippy from complaining about the macro not being used. +// It is being used, but only in test mode. +// +/// Tests conversion to and from the `Event` enum. +/// +/// Obtains a default for the given event struct. +/// Converts the struct into the `Event` enum, wrapping the struct. +/// Converts the `Event` enum into the given event struct. +/// Asserts that the original struct and the converted struct are equal. +#[cfg(test)] +macro_rules! event_has_matching_xml_definition { + ($type:ty) => { + #[test] + fn event_has_matching_xml_definition() { + + use zbus_xml; + use crate::events::{DBusInterface, DBusMember}; + + let fname = match <$type>::DBUS_INTERFACE.split(".").last().expect("Has last section") { + "Cache" => "xml/Cache.xml", + "Socket" => "xml/Socket.xml", + "Registry" => "xml/Registry.xml", + _ => "xml/Event.xml", + }; + + let reader = std::fs::File::open(fname).expect("Valid file path!"); + let xml = zbus_xml::Node::from_reader(reader).expect("Valid DBus XML file!"); + let Some(interface) = xml.interfaces().iter().find(|int| int.name() == <$type>::DBUS_INTERFACE) else { + + let possible_names: Vec = xml.interfaces().iter().map(|int| int.name().as_str().to_string()).collect(); + panic!("{} has interface name {}, but it was not found in the list of interfaces defined in the XML: {:?}", std::any::type_name::<$type>(), <$type>::DBUS_INTERFACE, possible_names); + }; + let Some(_member) = interface.signals().find(|mem| mem.name() == <$type>::DBUS_MEMBER) else { + let possible_names: Vec = interface.signals().map(|mem| mem.name().as_str().to_string()).collect(); + panic!("{} has interface name {} and member name {}, but it was not found in the list of members defined in the corresponding interface in the XML: {:?}", std::any::type_name::<$type>(), <$type>::DBUS_INTERFACE, <$type>::DBUS_MEMBER, possible_names); + }; + } + }; +} + +#[cfg(test)] +macro_rules! zbus_message_qtspi_test_case { + ($type:ty, Auto) => { + #[cfg(feature = "zbus")] + #[test] + fn zbus_message_conversion_qtspi() { + use crate::events::EventTypeProperties; + use crate::events::MessageConversion; + + // in the case that the body type is EventBodyOwned, we need to also check successful + // conversion from a QSPI-style body. + let ev = <$type>::default(); + let qt: crate::events::EventBodyQtOwned = ev.body().into(); + let msg = zbus::Message::signal( + ev.path(), + ev.interface(), + ev.member(), + ) + .sender(":0.0") + .build(&(qt,)) + .unwrap(); + <$type>::try_from(&msg).expect("Should be able to use an EventBodyQtOwned for any type whose BusProperties::Body = EventBodyOwned"); + } + #[cfg(feature = "zbus")] + #[test] + fn zbus_message_conversion_qtspi_event_enum() { + use crate::events::EventTypeProperties; + use crate::events::MessageConversion; + use crate::Event; + + // in the case that the body type is EventBodyOwned, we need to also check successful + // conversion from a QSPI-style body. + let ev = <$type>::default(); + let qt: crate::events::EventBodyQtOwned = ev.body().into(); + let msg = zbus::Message::signal( + ev.path(), + ev.interface(), + ev.member(), + ) + .sender(":0.0") + .build(&(qt,)) + .unwrap(); + assert_matches!(Event::try_from(&msg), Ok(_)); + } + }; + ($type:ty, Explicit) => {}; +} + +// We decorate the macro with a `#[cfg(test)]` attribute. +// This prevents Clippy from complaining about the macro not being used. +// It is being used, but only in test mode. +// +/// As of writing, this macro is expanded only once: in the `event_test_cases!` macro. +#[cfg(test)] +macro_rules! zbus_message_test_case { + ($type:ty) => { + zbus_message_test_case!($type, Auto); + }; + ($type:ty, $extra:tt) => { + zbus_message_qtspi_test_case!($type, $extra); + #[cfg(feature = "zbus")] + #[test] + fn zbus_msg_conversion_to_specific_event_type() { + let struct_event = <$type>::default(); + let msg: zbus::Message = zbus::Message::try_from(<$type>::default()).expect("Should convert a `$type::default()` into a message. Check the `impl_to_dbus_message` macro ."); + + let struct_event_back = + <$type>::try_from(&msg).expect("Should convert from `$type::default()` originated `Message` back into a specific event type. Check the `impl_from_dbus_message` macro."); + assert_eq!(struct_event, struct_event_back, "Events converted into a message and back must be the same"); + } + + #[cfg(feature = "zbus")] + #[test] + fn zbus_msg_conversion_to_event_enum_type() { + let struct_event = <$type>::default(); + let msg: zbus::Message = zbus::Message::try_from(struct_event.clone()).expect("Should convert a `$type::default()` into a message. Check the `impl_to_dbus_message` macro."); + let event_enum_back = + crate::Event::try_from(&msg).expect("Should convert a from `$type::default()` built `Message` into an event enum. Check the `impl_from_dbus_message` macro."); + let event_enum: crate::Event = struct_event.into(); + assert_eq!(event_enum, event_enum_back); + } + // may want to consider parameterized tests here, no need for fuzz testing, but one level lower than that may be nice + // try having a matching member, matching interface, path, or body type, but that has some other piece which is not right + #[cfg(feature = "zbus")] + #[test] + fn zbus_msg_conversion_failure_fake_msg() -> () { + let fake_msg = zbus::Message::signal( + "/org/a11y/sixtynine/fourtwenty", + "org.a11y.atspi.technically.valid", + "MadeUpMember", + ) + .sender(":0.0") + .build(&()) + .unwrap(); + let event = <$type>::try_from(&fake_msg); + assert_matches!(event, Err(_), "This conversion should fail"); + } + + #[cfg(feature = "zbus")] + #[test] + fn zbus_msg_conversion_validated_message_with_body() -> () { + use crate::events::MessageConversion; + + let fake_msg = zbus::Message::signal( + "/org/a11y/sixtynine/fourtwenty", + "org.a11y.atspi.technically.valid", + "MadeUpMember", + ) + .sender(":0.0") + .build(&<$type>::default().body()) + .unwrap(); + let hdr = fake_msg.header(); + let event = <$type>::from_message_unchecked(&fake_msg, &hdr); + event.expect("The from_message_unchecked function should work, despite mismatching interface and member"); + } + + #[cfg(feature = "zbus")] + #[test] + fn zbus_msg_conversion_failure_correct_interface() -> () { + let fake_msg = zbus::Message::signal( + "/org/a11y/sixtynine/fourtwenty", + <$type as crate::events::DBusInterface>::DBUS_INTERFACE, + "MadeUpMember", + ) + .sender(":0.0") + .build(&()) + .unwrap(); + let event = <$type>::try_from(&fake_msg); + assert_matches!(event, Err(AtspiError::MemberMatch(_)), "Wrong kind of error"); + } + + #[cfg(feature = "zbus")] + #[test] + fn zbus_msg_conversion_failure_correct_interface_and_member() -> () { + let fake_msg = zbus::Message::signal( + "/org/a11y/sixtynine/fourtwenty", + <$type as crate::events::DBusInterface>::DBUS_INTERFACE, + <$type as crate::events::DBusMember>::DBUS_MEMBER, + ) + .sender(":0.0") + .build(&()) + .unwrap(); + let event = <$type>::try_from(&fake_msg); + assert_matches!(event, Err(AtspiError::SignatureMatch(_)), "Wrong kind of error"); + } + + #[cfg(feature = "zbus")] + #[test] + fn zbus_msg_conversion_failure_correct_interface_and_member_invalid_body() -> () { + // known invalid body for AT-SPI events + let invalid_body: (i32, u64, String, String) = (0, 0, String::new(), String::new()); + let fake_msg = zbus::Message::signal( + "/org/a11y/sixtynine/fourtwenty", + <$type as crate::events::DBusInterface>::DBUS_INTERFACE, + <$type as crate::events::DBusMember>::DBUS_MEMBER, + ) + .sender(":0.0") + .build(&invalid_body) + .unwrap(); + let event = <$type>::try_from(&fake_msg); + assert_matches!(event, Err(AtspiError::SignatureMatch(_)), "Wrong kind of error"); + } + + #[cfg(feature = "zbus")] + #[test] + fn zbus_msg_conversion_failure_correct_body() -> () { + use crate::events::MessageConversion; + let fake_msg = zbus::Message::signal( + "/org/a11y/sixtynine/fourtwenty", + "org.a11y.atspi.accessible.technically.valid", + "FakeMember", + ) + .sender(":0.0") + .build(&<$type>::default().body()) + .unwrap(); + let event = <$type>::try_from(&fake_msg); + assert_matches!(event, Err(_)); + } + + #[cfg(feature = "zbus")] + #[test] + fn zbus_msg_conversion_failure_correct_body_and_member() -> () { + use crate::events::MessageConversion; + + let fake_msg = zbus::Message::signal( + "/org/a11y/sixtynine/fourtwenty", + "org.a11y.atspi.accessible.technically.valid", + <$type as crate::events::DBusMember>::DBUS_MEMBER, + ) + .sender(":0.0") + .build(&<$type>::default().body()) + .unwrap(); + let event = <$type>::try_from(&fake_msg); + assert_matches!(event, Err(AtspiError::InterfaceMatch(_)), "Wrong kind of error"); + } + #[cfg(feature = "zbus")] + #[test] + fn zbus_msg_conversion_failure_correct_body_and_interface() -> () { + use crate::events::MessageConversion; + + let fake_msg = zbus::Message::signal( + "/org/a11y/sixtynine/fourtwenty", + <$type as crate::events::DBusInterface>::DBUS_INTERFACE, + "MadeUpMember", + ) + .sender(":0.0") + .build(&<$type>::default().body()) + .unwrap(); + let event = <$type>::try_from(&fake_msg); + assert_matches!(event, Err(AtspiError::MemberMatch(_)), "Wrong kind of error"); + } + }; +} + +#[cfg(feature = "wrappers")] +/// Expands to five tests: +/// +/// 1. `into_and_try_from_event` +/// 2. `zbus_msg_invalid_interface` +/// 3. `zbus_msg_invalid_member` +/// 4. `zbus_msg_invalid_member_and_interface` +/// 5. `zbus_msg_conversion` +/// +/// The macro takes two arguments: +/// 1. The event's interface enum type. +/// 2. Any user facing event type that is wrapped by the interface enum. +/// +/// # Examples +/// +/// ```ignore +/// event_wrapper_test_cases!(MouseEvents, AbsEvent); +/// ``` +/// +/// For each of the types, the macro will create a module with the name `events_tests_{foo}` +/// where `{foo}` is the snake case of the 'interface enum' name. +macro_rules! event_wrapper_test_cases { + // The macro takes two arguments: the interface enum type and the user facing event type (ufet). + ($iface_enum:ty, $ufet:ty) => { + #[cfg(test)] + #[rename_item::rename(name($iface_enum), prefix = "events_tests_", case = "snake")] + mod foo { + use super::{$ufet, $iface_enum, AtspiError, Event, MessageConversion}; + + // TODO: replace with [`std::assert_matches::assert_matches`] when stabilized + use assert_matches::assert_matches; + + #[test] + fn into_and_try_from_user_facing_event() { + // Create a default event struct from its type's `Default::default()` impl. + let sub_type = <$ufet>::default(); + + // Wrap the event struct in the event enum + let mod_type = <$iface_enum>::from(sub_type); + let hint_iface = "Check macro `impl_from_user_facing_event_for_interface_event_enum!`"; + + // Wrap the inner event enum into the `Event` enum. + let event = Event::from(mod_type.clone()); + let hint_event = "Check macro `impl_from_interface_event_enum_for_event!`"; + + // Unwrap the `Event` enum into the inner event enum. + let hint_event_try = "Check macro `impl_try_from_event_for_interface_enum!`"; + let mod_type2 = <$iface_enum>::try_from(event.clone()) + .expect("Should convert outer `Event` enum into interface enum. hints: {hint_event} and {hint_event_try}"); + + assert_eq!( + mod_type, mod_type2, + "Interface enums should match. hint: {hint_iface}, {hint_event} and {hint_event_try}" + ); + } + + #[cfg(feature = "zbus")] + #[test] + fn zbus_msg_invalid_interface() { + let fake_msg = zbus::Message::signal( + "/org/a11y/sixtynine/fourtwenty", + "org.a11y.atspi.technically.valid.lol", + <$ufet as crate::events::DBusMember>::DBUS_MEMBER, + ) + .sender(":0.0") + .build(&<$ufet>::default().body()) + .unwrap(); + + // It is hard to see what eventually is tested here. Let's unravel it: + // + // Below we call `TryFrom<&zbus::Message> for $type` where `$type` the interface enum name. (eg. `MouseEvents`, `ObjectEvents`, etc.) and + // `mod_type` is an 'interface enum' variant (eg. `MouseEvents::Abs(AbsEvent)`). + // This conversion is found in the `/src/events/{iface_name}.rs`` file. + // This conversion in turn leans on the `impl_from_dbus_message` macro. + // In `MouseEvents::Abs(msg.try_into()?)`, it is the `msg.try_into()?` that should fail. + // The `msg.try_into()?` is provided through the `impl_from_dbus_message` macro. + + // Additioanlly, we check against the same method in `Event`; the overarchive enum that + // contains all other events as variants. + + let mod_type = <$iface_enum>::try_from(&fake_msg); + let event_type = Event::try_from(&fake_msg); + + assert_matches!(mod_type, Err(AtspiError::InterfaceMatch(_)), "Wrong kind of error"); + assert_matches!(event_type, Err(AtspiError::InterfaceMatch(_)), "Wrong kind of error"); + } + + #[cfg(feature = "zbus")] + #[test] + fn zbus_msg_invalid_member() { + let fake_msg = zbus::Message::signal( + "/org/a11y/sixtynine/fourtwenty", + <$ufet as crate::events::DBusInterface>::DBUS_INTERFACE, + "FakeFunctionLol", + ) + .sender(":0.0") + .build(&<$ufet>::default().body()) + .unwrap(); + // As above, the `msg.try_into()?` is provided through the `impl_from_dbus_message` macro. + let mod_type = <$iface_enum>::try_from(&fake_msg); + assert_matches!(mod_type, Err(AtspiError::MemberMatch(_)), "Wrong kind of error"); + } + #[cfg(feature = "zbus")] + #[test] + fn zbus_msg_invalid_member_and_interface() { + let fake_msg = zbus::Message::signal( + "/org/a11y/sixtynine/fourtwenty", + "org.a11y.atspi.technically.allowed", + "FakeFunctionLol", + ) + .sender(":0.0") + .build(&<$ufet>::default().body()) + .unwrap(); + // As above, the `msg.try_into()?` is provided through the `impl_from_dbus_message` macro. + let mod_type = <$iface_enum>::try_from(&fake_msg); + + // Note that the non-matching interface is the first error, so the member match error is not reached. + assert_matches!(mod_type, Err(AtspiError::InterfaceMatch(_)), "Wrong kind of error"); + } + + #[cfg(feature = "zbus")] + #[test] + fn zbus_msg_conversion() { + let valid_msg = zbus::Message::signal( + "/org/a11y/sixtynine/fourtwenty", + <$ufet as crate::events::DBusInterface>::DBUS_INTERFACE, + <$ufet as crate::events::DBusMember>::DBUS_MEMBER, + ) + .sender(":0.0") + .build(&<$ufet>::default().body()) + .unwrap(); + // As above, the `msg.try_into()?` is provided through the `impl_from_dbus_message` macro. + let mod_type = <$iface_enum>::try_from(&valid_msg); + mod_type.expect("Should convert from `$ufet::default()` built `Message` back into a interface event enum variant wrapping an inner type. Check the `impl_from_dbus_message` macro."); + } + + + } + }; +} + +macro_rules! event_test_cases { + ($ufet:ty) => { + event_test_cases!($ufet, Auto); + }; + ($ufet:ty, $qt:tt) => { + #[cfg(test)] + #[rename_item::rename(name($ufet), prefix = "event_tests_", case = "snake")] + mod foo { + use super::{$ufet, AtspiError, EventProperties }; + use crate::events::traits::EventTypeProperties; + #[cfg(feature = "zbus")] + use zbus::Message; + use crate::Event; + + // TODO: use [`std::assert_matches::assert_matches`] when stabilized + use assert_matches::assert_matches; + + #[test] + #[cfg(feature = "wrappers")] + fn event_enum_conversion() { + let event_struct = <$ufet>::default(); + let event_enum = Event::from(event_struct.clone()); + let event_struct_back = <$ufet>::try_from(event_enum) + .expect("Should convert event enum into specific event type because it was created from it. Check the `impl_from_interface_event_enum_for_event` macro"); + assert_eq!(event_struct, event_struct_back); + } + + #[test] + #[cfg(feature = "wrappers")] + fn event_enum_transparency_test_case() { + let specific_event = <$ufet>::default(); + + let generic_event = Event::from(specific_event.clone()); + let hint = "Check macro `impl_from_user_facing_type_for_event_enum!`."; + + assert_eq!( + specific_event.member(), + generic_event.member(), + "DBus members do not match. hint: {hint}" + ); + assert_eq!( + specific_event.interface(), + generic_event.interface(), + "DBus interfaces do not match. hint: {hint}" + ); + assert_eq!( + specific_event.registry_string(), + generic_event.registry_string(), + "Registry strings do not match. hint: {hint}" + ); + assert_eq!( + specific_event.match_rule(), + generic_event.match_rule(), + "Match rule strings do not match. hint: {hint}" + ); + assert_eq!(specific_event.path(), generic_event.path(), "Paths do not match. hint: {hint}"); + assert_eq!(specific_event.sender(), generic_event.sender(), "Senders do not match. hint: {hint}"); + } + + zbus_message_test_case!($ufet, $qt); + event_has_matching_xml_definition!($ufet); + generic_event_test_case!($ufet); + } + assert_impl_all!( + $ufet: Clone, + std::fmt::Debug, + serde::Serialize, + serde::Deserialize<'static>, + Default, + PartialEq, + Eq, + std::hash::Hash, + crate::events::traits::EventProperties, + crate::events::traits::EventTypeProperties, + crate::events::traits::DBusInterface, + crate::events::traits::DBusMember, + crate::events::traits::DBusMatchRule, + crate::events::traits::RegistryEventString + ); + + #[cfg(feature = "zbus")] + assert_impl_all!(zbus::Message: TryFrom<$ufet>); + }; +} + +/// Implements `MessageConversionExt` for a given target event type with a given body type. +/// +/// # Example +/// ```ignore +/// # // 'ignore'd for bevity's sake because `impl`s require that the *example crate* defines traits `MessageConversionExt`, +/// # // `MessageConversion` as well as the body and target types. +/// +/// impl_msg_conversion_ext_for_target_type_with_specified_body_type!(target: RemoveAccessibleEvent, body: ObjectRef); +/// ``` +/// expands to: +/// +/// ```ignore +/// #[cfg(feature = "zbus")] +/// impl<'a> MessageConversionExt<'_, ObjectRef> for RemoveAccessibleEvent { +/// fn try_from_message(msg: &zbus::Message, hdr: &Header) -> Result { +/// >::validate_interface(hdr)?; +/// >::validate_member(hdr)?; +/// >::validate_body(msg)?; +/// >::from_message_unchecked(msg, hdr) +/// } +/// } +/// ``` +macro_rules! impl_msg_conversion_ext_for_target_type_with_specified_body_type { + (target: $target_type:ty, body: $body_type:ty) => { + #[cfg(feature = "zbus")] + impl<'a> crate::events::MessageConversionExt<'a, $body_type> for $target_type { + fn try_from_message(msg: &zbus::Message, hdr: &Header) -> Result { + use crate::events::MessageConversionExt; + >::validate_interface(hdr)?; + >::validate_member(hdr)?; + >::validate_body(msg)?; + >::from_message_unchecked(msg, hdr) + } + } + }; +} + +/// Implements `MessageConversionExt` for a given target event type. +/// +/// # Example +/// +/// ```ignore +/// impl_msg_conversion_ext_for_target_type!(LoadCompleteEvent); +/// ``` +/// expands to: +/// +/// ```ignore +/// #[cfg(feature = "zbus")] +/// impl<'msg> MessageConversionExt<'msg, EventBody<'msg>> for LoadCompleteEvent { +/// fn try_from_message(msg: &'msg zbus::Message, header: &Header) -> Result { +/// Self::validate_interface(header)?; +/// Self::validate_member(header)?; +/// +/// let item = ObjectRefOwned::try_from(header)?; +/// let msg_body = msg.body(); +/// let signature = msg_body.signature(); +/// +/// if signature == crate::events::EventBodyOwned::SIGNATURE +/// || signature == crate::events::EventBodyQtOwned::SIGNATURE +/// { +/// Self::from_message_unchecked_parts(item, msg_body) +/// } else { +/// Err(AtspiError::SignatureMatch(format!( +/// "The message signature {} does not match a valid signal body signature: {} or {}", +/// msg.body().signature(), +/// crate::events::EventBodyOwned::SIGNATURE, +/// crate::events::EventBodyQtOwned::SIGNATURE, +/// ))) +/// } +/// } +/// } +/// ``` +macro_rules! impl_msg_conversion_ext_for_target_type { + ($target_type:ty) => { + #[cfg(feature = "zbus")] + impl<'msg> crate::events::MessageConversionExt<'msg, crate::events::EventBody<'msg>> for $target_type { + fn try_from_message(msg: &'msg zbus::Message, header: &Header) -> Result { + use zbus::wire::Type; + use crate::events::traits::MessageConversion; + Self::validate_interface(header)?; + Self::validate_member(header)?; + + let item = ObjectRefOwned::try_from(header)?; + let msg_body = msg.body(); + let signature = msg_body.signature(); + + if signature == crate::events::EventBodyOwned::SIGNATURE + || signature == crate::events::EventBodyQtOwned::SIGNATURE + { + Self::from_message_unchecked_parts(item.into_inner(), msg_body) + } else { + Err(AtspiError::SignatureMatch(format!( + "The message signature {} does not match a valid signal body signature: {} or {}", + msg.body().signature(), + crate::events::EventBodyOwned::SIGNATURE, + crate::events::EventBodyQtOwned::SIGNATURE, + ))) + } + } + } + }; +} + +#[cfg(feature = "wrappers")] +/// Implements `TryFromMessage` for a given event wrapper type. +/// +/// # Example +/// ```ignore +/// impl_tryfrommessage_for_event_wrapper!(StateChangedEvent); +/// ``` +/// expands to: +/// +/// ```ignore +/// #[cfg(feature = "zbus")] +/// impl TryFromMessage for StateChangedEvent { +/// fn try_from_message(msg: &zbus::Message) -> Result { +/// let header = msg.header(); +/// let interface = header.interface().ok_or(AtspiError::MissingInterface)?; +/// if interface != Self::DBUS_INTERFACE { +/// return Err(AtspiError::InterfaceMatch(format!( +/// "Interface {} does not match require interface for event: {}", +/// interface, +/// Self::DBUS_INTERFACE +/// ))); +/// } +/// Self::try_from_message_interface_checked(msg, &header) +/// } +/// } +/// ``` +macro_rules! impl_tryfrommessage_for_event_wrapper { + ($wrapper:ty) => { + #[cfg(feature = "zbus")] + impl crate::events::traits::TryFromMessage for $wrapper { + fn try_from_message(msg: &zbus::Message) -> Result<$wrapper, AtspiError> { + use crate::events::traits::EventWrapperMessageConversion; + + let header = msg.header(); + let interface = header.interface().ok_or(AtspiError::MissingInterface)?; + if interface != Self::DBUS_INTERFACE { + return Err(AtspiError::InterfaceMatch(format!( + "Interface {} does not match require interface for event: {}", + interface, + Self::DBUS_INTERFACE + ))); + } + Self::try_from_message_interface_checked(msg, &header) + } + } + }; +} + +/// Implement the `MessageConversion` trait for the given types. +/// +/// This macro is used to implement the `MessageConversion` trait for types that are built from an +/// `ObjectRef` and a `zbus::message::Body` only - no `EventBody` needed. +/// +/// # Example +/// +/// ```ignore +/// impl_msg_conversion_for_types_built_from_object_ref!(FocusEvent, FocusEvents); +/// ``` +/// +/// This will generate the following implementations: +/// +/// ```ignore +/// #[cfg(feature = "zbus")] +/// impl MessageConversion<'_> for FocusEvent { +/// type Body<'msg> = crate::events::EventBody<'msg>; +/// +/// fn from_message_unchecked_parts( +/// obj_ref: ObjectRefOwned, +/// _body: zbus::message::Body, +/// ) -> Result { +/// Ok(obj_ref.into()) +/// } +/// +/// fn from_message_unchecked(_: &zbus::Message, header: &Header) -> Result { +/// let obj_ref: ObjectRefOwned = header.try_into()?; +/// Ok(obj_ref.into()) +/// } +/// +/// fn body(&self) -> Self::Body<'_> { +/// crate::events::EventBodyOwned::default().into() +/// } +/// } +/// ``` +macro_rules! impl_msg_conversion_for_types_built_from_object_ref { + ($($type:ty),*) => { + $( + #[cfg(feature = "zbus")] + impl crate::events::MessageConversion<'_> for $type { + type Body<'msg> = crate::events::EventBody<'msg>; + + fn from_message_unchecked_parts( + obj_ref: crate::object_ref::ObjectRef<'_>, + _body: zbus::message::Body, + ) -> Result { + Ok(obj_ref.into()) + } + + fn from_message_unchecked(_: &zbus::Message, header: &Header) -> Result { + let obj_ref: ObjectRefOwned = header.try_into()?; + Ok( Self { item: obj_ref }) + } + + fn body(&self) -> Self::Body<'_> { + crate::events::EventBodyOwned::default().into() + } + } + )* + }; +} + +/// Implement `DBusMember`, `DBusInterface`, `DBusMatchRule`, and `RegistryEventString` +/// for a given event type. +/// +/// This macro takes 5 arguments in the order: +/// - The target type +/// - The member string +/// - The interface string +/// - The registry string +/// - The match rule string +/// +/// # Example +/// ```ignore +/// impl_member_interface_registry_string_and_match_rule_for_event!( +/// FocusEvent, "Focus", "org.a11y.atspi.Event.Focus", "focus", +/// "type='signal',interface='org.a11y.atspi.Event.Focus'"); +/// ``` +/// expands to: +/// +/// ```ignore +/// impl DBusMember for FocusEvent { +/// const DBUS_MEMBER: &'static str = "Focus"; +/// } +/// impl DBusInterface for FocusEvent { +/// const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Focus"; +/// } +/// impl MatchRule for FocusEvent { +/// const MATCH_RULE: &'static str = "type='signal',interface='org.a11y.atspi.Event.Focus'"; +/// } +/// impl RegistryEventString for FocusEvent { +/// const REGISTRY_STRING: &'static str = "focus"; +/// } +/// impl DBusProperties for FocusEvent {} +/// ``` +macro_rules! impl_member_interface_registry_string_and_match_rule_for_event { + ($target_type:ty, $member_str:literal, $interface_str:literal, $registry_str:literal, $match_rule_str:literal) => { + impl crate::events::DBusMember for $target_type { + const DBUS_MEMBER: &'static str = $member_str; + } + impl crate::events::DBusInterface for $target_type { + const DBUS_INTERFACE: &'static str = $interface_str; + } + impl crate::events::DBusMatchRule for $target_type { + const MATCH_RULE_STRING: &'static str = $match_rule_str; + } + impl crate::events::RegistryEventString for $target_type { + const REGISTRY_EVENT_STRING: &'static str = $registry_str; + } + impl crate::events::DBusProperties for $target_type {} + }; +} + +/// Implement `EventTypeProperties` for a given event type. +/// +/// This macro takes one argument: the target type. +/// +/// # Example +/// ```ignore +/// impl_event_type_properties_for_event!(FocusEvent); +/// ``` +/// expands to: +/// +/// ```ignore +/// impl EventTypeProperties for FocusEvent { +/// fn member(&self) -> &'static str { +/// Self::DBUS_MEMBER +/// } +/// fn interface(&self) -> &'static str { +/// Self::DBUS_INTERFACE +/// } +/// fn registry_string(&self) -> &'static str { +/// Self::REGISTRY_EVENT_STRING +/// } +/// fn match_rule(&self) -> &'static str { +/// Self::MATCH_RULE_STRING +/// } +/// } +/// +macro_rules! impl_event_type_properties_for_event { + ($target_type:ty) => { + impl crate::events::EventTypeProperties for $target_type { + fn member(&self) -> &'static str { + Self::DBUS_MEMBER + } + + fn interface(&self) -> &'static str { + Self::DBUS_INTERFACE + } + + fn registry_string(&self) -> &'static str { + Self::REGISTRY_EVENT_STRING + } + + fn match_rule(&self) -> &'static str { + Self::MATCH_RULE_STRING + } + } + }; +} diff --git a/patches/atspi-common/src/object_match.rs b/patches/atspi-common/src/object_match.rs new file mode 100644 index 0000000..29b79ee --- /dev/null +++ b/patches/atspi-common/src/object_match.rs @@ -0,0 +1,304 @@ +use std::{borrow::Borrow, collections::HashMap, marker::PhantomData}; + +use serde::{Deserialize, Serialize}; +use zbus::wire::{Signature, Type}; + +use crate::{Interface, InterfaceSet, Role, State, StateSet}; + +/// Defines how an object-tree is to be traversed. +/// Used in `CollectionProxy`. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] +#[repr(u32)] +pub enum TreeTraversalType { + /// When traversing the tree, restrict to children of the current object. + RestrictChildren, + + /// When traversing the tree, restrict to siblings of the current object. + RestrictSibling, + + /// Traverse the tree in order of appearance. + #[default] + Inorder, +} + +/// Definition of match rules for accessible objects. +/// Rule(s) against which we can match an object or a collection thereof. +/// +/// # Examples +/// ```rust +/// # use zbus::MatchRule; +/// let builder = MatchRule::builder(); +/// ``` +/// +#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)] +pub struct ObjectMatchRule { + pub states: StateSet, + pub states_mt: MatchType, + pub attr: HashMap, + pub attr_mt: MatchType, + pub roles: Vec, + pub roles_mt: MatchType, + pub ifaces: InterfaceSet, + pub ifaces_mt: MatchType, + pub invert: bool, + // Private phantom, gets compiled away. + // Here to ensure the builder is the only route to obtain a `MatchRule` + #[serde(skip)] + _marker: std::marker::PhantomData<()>, +} + +/// !!! WARNING !!! : +/// +/// State and Role are defined as u32 in Accessible.xml but as i32 in Collection.xml +/// +/// The signature on `StateSet` is defined inconsistently in the XMLs: +/// +/// - `Accessible.xml`: `GetState type="au"` +/// - `Collection.xml`: `GetMatches` argument `name="rule" type="(aiia{ss}iaiiasib)"` +/// +/// The latter starts with ai, which is a signature for an array of signed ints i32. +/// +/// +impl Type for ObjectMatchRule { + const SIGNATURE: &'static Signature = &Signature::static_structure(&[ + >::SIGNATURE, + &Signature::I32, + >::SIGNATURE, + &Signature::I32, + >::SIGNATURE, + &Signature::I32, + >::SIGNATURE, + &Signature::I32, + &Signature::Bool, + ]); +} + +impl ObjectMatchRule { + /// Create a new `MatchRuleBuilder` + #[must_use] + pub fn builder() -> ObjectMatchRuleBuilder { + ObjectMatchRuleBuilder::default() + } +} + +/// The 'builder' type for `MatchRule`. +/// Use its methods to set match criteria. +#[derive(Debug, Clone, Default)] +pub struct ObjectMatchRuleBuilder { + states: StateSet, + states_mt: MatchType, + attr: HashMap, + attr_mt: MatchType, + roles: Vec, + roles_mt: MatchType, + ifaces: InterfaceSet, + ifaces_mt: MatchType, + invert: bool, +} + +impl ObjectMatchRuleBuilder { + /// Insert a `StateSet` to the builder + #[must_use] + pub fn states(mut self, states: I, mt: MatchType) -> Self + where + I: IntoIterator, + I::Item: Borrow, + { + self.states = states.into_iter().map(|state| *state.borrow()).collect(); + self.states_mt = mt; + self + } + + /// Insert a map of attributes + #[must_use] + pub fn attributes(mut self, attributes: HashMap, mt: MatchType) -> Self { + self.attr = attributes; + self.attr_mt = mt; + self + } + + /// Insert a slice of `Role`s + #[must_use] + pub fn roles(mut self, roles: &[Role], mt: MatchType) -> Self { + self.roles = roles.into(); + self.roles_mt = mt; + self + } + + /// Insert an `InterfaceSet` from a collection of `Interface`s + #[must_use] + pub fn interfaces(mut self, interfaces: I, mt: MatchType) -> Self + where + I: IntoIterator, + I::Item: Borrow, + { + self.ifaces = interfaces.into_iter().map(|iface| *iface.borrow()).collect(); + self.ifaces_mt = mt; + self + } + + /// Sets the inversion of the `MatchRule`, defaults to `false`, no inversion. + #[must_use] + pub fn invert(mut self, invert: bool) -> Self { + self.invert = invert; + self + } + + /// Builds the [`ObjectMatchRule`] + /// + /// [`ObjectMatchRule``]: crate::object_match::ObjectMatchRule + #[must_use] + pub fn build(self) -> ObjectMatchRule { + ObjectMatchRule { + states: self.states, + states_mt: self.states_mt, + attr: self.attr, + attr_mt: self.attr_mt, + roles: self.roles, + roles_mt: self.roles_mt, + ifaces: self.ifaces, + ifaces_mt: self.ifaces_mt, + invert: self.invert, + _marker: PhantomData, + } + } +} + +/// Enumeration used by [`ObjectMatchRule`] to specify how to interpret [`ObjectRef`] objects. +/// +/// [`ObjectRef`]: crate::object_ref::ObjectRef +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type, Default)] +#[repr(i32)] +pub enum MatchType { + #[default] + /// Invalidates match criterion. Meanting: the search of this property will not be performed. + Invalid, + + /// All of the criteria must be met. + All, + + /// Any of the criteria must criteria must be met. + Any, + + /// None of the criteria must be met. + NA, + + /// Same as [`Self::All`] if the criterion item is non-empty - All of the criteria must be met. + /// For empty criteria this rule requires the returned value to also have empty set. + Empty, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] +#[repr(u32)] +/// Enumeration used by interface `CollectionProxy` to specify the way [`ObjectRef`] +/// objects should be sorted. +/// +/// # Note +/// +/// Only `Canonical` and `ReverseCanonical` are currently implemented in the known implementation of `Collection`. +/// +/// see: [issue 140. "Are all the AtspiCollectionSortOrder types really a thing?"](https://gitlab.gnome.org/GNOME/at-spi2-core/-/issues/140) +/// +/// [`ObjectRef`]: crate::object_ref::ObjectRef +pub enum SortOrder { + /// Invalid sort order + /// + /// Unimplemented + Invalid, + + /// Canonical sort order + Canonical, + + /// Flow sort order + /// + /// Unimplemented + Flow, + + /// Tab sort order + /// + /// Unimplemented + Tab, + + /// Reverse canonical sort order + ReverseCanonical, + + /// Reverse flow sort order + /// + /// Unimplemented + ReverseFlow, + + /// Reverse tab sort order + /// + /// Unimplemented + ReverseTab, +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{SortOrder, State}; + use std::str::FromStr; + use zbus_lockstep::method_args_signature; + + #[test] + fn validate_match_rule_signature() { + let signature = method_args_signature!(member: "GetMatchesTo", interface: "org.a11y.atspi.Collection", argument: "rule"); + assert_eq!(*::SIGNATURE, signature); + } + + #[test] + fn validate_match_type_signature() { + let rule_signature = method_args_signature!(member: "GetMatchesTo", interface: "org.a11y.atspi.Collection", argument: "rule"); + // The match type signature is the fourth element in the signature + let match_type_signature_str = rule_signature.to_string(); + let match_type_signature = Signature::from_str(&match_type_signature_str.as_str()[3..4]) + .expect("Valid signature pattern"); + assert_eq!(*::SIGNATURE, match_type_signature); + } + + #[test] + fn validate_tree_traversal_type_signature() { + let signature = method_args_signature!(member: "GetMatchesTo", interface: "org.a11y.atspi.Collection", argument: "tree"); + assert_eq!(*::SIGNATURE, signature); + } + + #[test] + fn validate_sort_order_signature() { + let signature = method_args_signature!(member: "GetMatches", interface: "org.a11y.atspi.Collection", argument: "sortby"); + assert_eq!(*::SIGNATURE, signature); + } + + #[test] + fn create_empty_object_match_rule() { + let rule = ObjectMatchRule::builder().build(); + + assert_eq!(rule.states, StateSet::default()); + assert_eq!(rule.attr, HashMap::new()); + assert_eq!(rule.roles, Vec::new()); + assert_eq!(rule.ifaces, InterfaceSet::default()); + assert!(!rule.invert); + } + + #[test] + fn create_object_match_rule() { + let rule = ObjectMatchRule::builder() + .states(StateSet::new(State::Active), MatchType::All) + .attributes( + [("name".to_string(), "value".to_string())].iter().cloned().collect(), + MatchType::Any, + ) + .roles(&[Role::Alert], MatchType::All) + .interfaces([Interface::Action], MatchType::Any) + .invert(true) + .build(); + + assert_eq!(rule.states, StateSet::new(State::Active)); + assert_eq!( + rule.attr, + [("name".to_string(), "value".to_string())].iter().cloned().collect() + ); + assert_eq!(rule.roles, vec![Role::Alert]); + assert_eq!(rule.ifaces, InterfaceSet::new(Interface::Action)); + assert!(rule.invert); + } +} diff --git a/patches/atspi-common/src/object_ref.rs b/patches/atspi-common/src/object_ref.rs new file mode 100644 index 0000000..bb8a8db --- /dev/null +++ b/patches/atspi-common/src/object_ref.rs @@ -0,0 +1,871 @@ +use crate::AtspiError; +use serde::{Deserialize, Serialize}; +use std::hash::{Hash, Hasher}; +use zbus_lockstep_macros::validate; +use zbus::names::{BusName, UniqueName}; +use zbus::wire::{ObjectPath, Structure, Type}; + +const NULL_PATH_STR: &str = "/org/a11y/atspi/null"; +const NULL_OBJECT_PATH: &ObjectPath<'static> = + &ObjectPath::from_static_str_unchecked(NULL_PATH_STR); + +#[cfg(test)] +pub(crate) const TEST_OBJECT_BUS_NAME: &str = ":0.0"; +#[cfg(test)] +pub(crate) const TEST_OBJECT_PATH_STR: &str = "/org/a11y/atspi/test/default"; +#[cfg(test)] +pub(crate) const TEST_DEFAULT_OBJECT_REF: ObjectRef<'static> = + ObjectRef::from_static_str_unchecked(TEST_OBJECT_BUS_NAME, TEST_OBJECT_PATH_STR); + +/// A unique identifier for an object in the accessibility tree. +/// +/// A ubiquitous type used to refer to an object in the accessibility tree. +/// +/// In AT-SPI2, objects in the applications' UI object tree are uniquely identified +/// using an application's bus name and object path. "(so)" +/// +/// Emitted by `RemoveAccessible` and `Available` +#[validate(signal: "Available")] +#[derive(Clone, Debug, Eq, Type)] +#[zvariant(signature = "(so)")] +pub enum ObjectRef<'o> { + Null, + Owned { name: UniqueName<'static>, path: ObjectPath<'static> }, + Borrowed { name: UniqueName<'o>, path: ObjectPath<'o> }, +} + +impl<'o> ObjectRef<'o> { + /// Create a new `ObjectRef::Borrowed` from a `UniqueName` and `ObjectPath`. + #[must_use] + pub fn new(name: UniqueName<'o>, path: ObjectPath<'o>) -> Self { + Self::new_borrowed(name, path) + } + + /// Create a new, owned `ObjectRef`. + /// + /// # Example + /// ```rust + /// use zbus::names::UniqueName; + /// use zbus::wire::ObjectPath; + /// use atspi_common::ObjectRef; + /// + /// let name = UniqueName::from_static_str_unchecked(":1.23"); + /// let path = ObjectPath::from_static_str_unchecked("/org/a11y/example/path/007"); + /// + /// let object_ref = ObjectRef::new_owned(name, path); + /// # assert_eq!(object_ref.name_as_str(), Some(":1.23")); + /// # assert_eq!(object_ref.path_as_str(), "/org/a11y/example/path/007"); + /// ``` + pub fn new_owned(name: N, path: P) -> ObjectRefOwned + where + N: Into>, + P: Into>, + { + let name: UniqueName<'static> = name.into(); + let path: ObjectPath<'static> = path.into(); + + ObjectRefOwned(ObjectRef::Owned { name, path }) + } + + /// Create a new, borrowed `ObjectRef`. + /// + /// # Example + /// ```rust + /// use zbus::names::UniqueName; + /// use zbus::wire::ObjectPath; + /// use atspi_common::ObjectRef; + /// + /// let name = UniqueName::from_static_str_unchecked(":1.23"); + /// let path = ObjectPath::from_static_str_unchecked("/org/a11y/example/path/007"); + /// + /// let object_ref = ObjectRef::new_borrowed(name, path); + /// # assert_eq!(object_ref.name_as_str(), Some(":1.23")); + /// # assert_eq!(object_ref.path_as_str(), "/org/a11y/example/path/007"); + /// ``` + pub fn new_borrowed(name: N, path: P) -> ObjectRef<'o> + where + N: Into>, + P: Into>, + { + let name: UniqueName<'o> = name.into(); + let path: ObjectPath<'o> = path.into(); + + ObjectRef::Borrowed { name, path } + } + + /// Create a new `ObjectRef`, from `BusName` and `ObjectPath`. + /// + /// # Errors + /// Will fail if the `sender` is not a `UniqueName`. + pub fn try_from_bus_name_and_path( + sender: BusName<'o>, + path: ObjectPath<'o>, + ) -> Result { + // Check whether `BusName` matches `UniqueName` + if let BusName::Unique(unique_sender) = sender { + Ok(ObjectRef::new(unique_sender, path)) + } else { + Err(AtspiError::ParseError("Expected UniqueName")) + } + } + + /// Create a new `ObjectRef`, unchecked. + /// + /// # Safety + /// The caller must ensure that the strings are valid. + #[must_use] + pub const fn from_static_str_unchecked(name: &'static str, path: &'static str) -> Self { + let name = UniqueName::from_static_str_unchecked(name); + let path = ObjectPath::from_static_str_unchecked(path); + + ObjectRef::Owned { name, path } + } + + /// Returns `true` if the object reference is `Null`, otherwise returns `false`. + /// + /// Toolkits may use the `Null` object reference to indicate that an object is not available or does not exist. + /// For example, when calling `Accessible::get_parent` on an object that has no parent, + /// it may return a `Null` object reference. + #[must_use] + pub fn is_null(&self) -> bool { + matches!(self, Self::Null) + } + + /// Returns the name of the object reference. + /// If the object reference is `Null`, it returns `None`. + /// If the object reference is `Owned` or `Borrowed`, it returns the name. + /// + /// # Example + /// ```rust + /// use zbus::names::UniqueName; + /// use zbus::wire::ObjectPath; + /// use atspi_common::ObjectRef; + /// + /// let name = UniqueName::from_static_str_unchecked(":1.23"); + /// let path = ObjectPath::from_static_str_unchecked("/org/a11y/example/path/007"); + /// let object_ref = ObjectRef::new_borrowed(name, path); + /// + /// // Check the name of the object reference + /// assert!(object_ref.name().is_some()); + /// assert_eq!(object_ref.name().unwrap().as_str(), ":1.23"); + /// ``` + #[must_use] + pub fn name(&self) -> Option<&UniqueName<'o>> { + match self { + Self::Owned { name: own_name, .. } => Some(own_name), + Self::Borrowed { name: borrow_name, .. } => Some(borrow_name), + Self::Null => None, + } + } + + /// Returns the path of the object reference.\ + /// + /// # Example + /// ```rust + /// use zbus::names::UniqueName; + /// use zbus::wire::ObjectPath; + /// use atspi_common::ObjectRef; + /// + /// let name = UniqueName::from_static_str_unchecked(":1.23"); + /// let path = ObjectPath::from_static_str_unchecked("/org/a11y/example/path/007"); + /// let object_ref = ObjectRef::new_borrowed(name, path); + /// + /// // Check the path of the object reference + /// assert_eq!(object_ref.path().as_str(), "/org/a11y/example/path/007"); + /// ``` + #[must_use] + pub fn path(&self) -> &ObjectPath<'o> { + match self { + Self::Owned { path: own_path, .. } => own_path, + Self::Borrowed { path: borrow_path, .. } => borrow_path, + Self::Null => NULL_OBJECT_PATH, + } + } + + /// Converts the `ObjectRef` into an owned instance, consuming `self`.\ + /// If the object reference is `Null`, it returns `ObjectRef::Null`.\ + /// If the object reference is `Owned`, it returns the same `ObjectRef::Owned`.\ + /// If the object reference is `Borrowed`, it converts the name and path to owned versions and returns `ObjectRef::Owned`. + /// + /// # Extending lifetime 'magic' (from 'o -> 'static') + /// + /// `ObjectRef<'_>` leans on the implementation of `UniqueName` and `ObjectPath` to + /// convert the inner types to `'static`. + /// These types have an `Inner` enum that can contain an `Owned`, `Borrowed`, or `Static` `Str` type. + /// The `Str`type is either a `&'static str` (static), `&str` (borrowed), or an `Arc` (owned). + /// + /// # Example + /// ```rust + /// use zbus::names::UniqueName; + /// use zbus::wire::ObjectPath; + /// use atspi_common::ObjectRef; + /// + /// let name = UniqueName::from_static_str_unchecked(":1.23"); + /// let path = ObjectPath::from_static_str_unchecked("/org/a11y/example/path/007"); + /// let object_ref = ObjectRef::new_borrowed(name, path); + /// + /// // Check whether the object reference can be converted to an owned version + /// assert!(!object_ref.is_null()); + /// let object_ref = object_ref.into_owned(); + /// assert!(matches!(object_ref, ObjectRef::Owned { .. })); + /// ``` + #[must_use] + pub fn into_owned(self) -> ObjectRef<'static> { + match self { + Self::Null => ObjectRef::Null, + Self::Owned { name, path } => ObjectRef::Owned { name, path }, + Self::Borrowed { name, path } => { + ObjectRef::Owned { name: name.to_owned(), path: path.to_owned() } + } + } + } + + /// Returns the name of the object reference as a string slice. + #[must_use] + pub fn name_as_str(&self) -> Option<&str> { + match self { + ObjectRef::Null => None, + ObjectRef::Owned { name, .. } | ObjectRef::Borrowed { name, .. } => Some(name.as_str()), + } + } + + /// Returns the path of the object reference as a string slice. + #[must_use] + pub fn path_as_str(&self) -> &str { + match self { + ObjectRef::Null => NULL_PATH_STR, + ObjectRef::Owned { path, .. } | ObjectRef::Borrowed { path, .. } => path.as_str(), + } + } +} + +// Event tests lean on the `Default` implementation of `ObjectRef`. +// This is a workaround for the fact that `ObjectRef::Null` in +// `#[cfg(test)]` context is inconvenient. +// Events are guaranteed to have a non-null `ObjectRef` on their `item` field, because we receive signals over +// regular (non-p2p) DBus. Which means the `Message` `Header` has valid `Sender` and `Path` fields which +// are used to construct the `ObjectRef` from a `Message`. +#[cfg(test)] +impl Default for ObjectRef<'_> { + /// Returns a non-Null object reference. (test implementation) + fn default() -> Self { + TEST_DEFAULT_OBJECT_REF + } +} + +#[cfg(not(test))] +impl Default for ObjectRef<'_> { + /// Returns a `Null` object reference. + fn default() -> Self { + ObjectRef::Null + } +} + +/// A wrapper around the static variant of `ObjectRef`. +/// This is guaranteed to have a `'static` lifetime. +#[validate(signal: "Available")] +#[derive(Clone, Debug, Default, Eq, Type)] +pub struct ObjectRefOwned(pub(crate) ObjectRef<'static>); + +impl From> for ObjectRefOwned { + /// Convert an `ObjectRef<'_>` into an `ObjectRefOwned`. + /// + /// # Extending lifetime 'magic' (from 'o -> 'static') + /// + /// `ObjectRef<'_>` leans on the implementation of `UniqueName` and `ObjectPath` to + /// convert the inner types to `'static`. + /// These types have an `Inner` enum that can contain an `Owned`, `Borrowed`, or `Static` `Str` type. + /// The `Str`type is either a `&'static str` (static), `&str` (borrowed), or an `Arc` (owned). + fn from(object_ref: ObjectRef<'_>) -> Self { + ObjectRefOwned(object_ref.into_owned()) + } +} + +impl ObjectRefOwned { + /// Create a new `ObjectRefOwned` from an `ObjectRef<'static>`. + #[must_use] + pub const fn new(object_ref: ObjectRef<'static>) -> Self { + Self(object_ref) + } + + /// Create a new `ObjectRefOwned` from `&'static str` unchecked. + /// + /// # Safety + /// The caller must ensure that the strings are valid. + #[must_use] + pub const fn from_static_str_unchecked(name: &'static str, path: &'static str) -> Self { + let name = UniqueName::from_static_str_unchecked(name); + let path = ObjectPath::from_static_str_unchecked(path); + + ObjectRefOwned(ObjectRef::Owned { name, path }) + } + + /// Returns `true` if the object reference is `Null`, otherwise returns `false`. + #[must_use] + pub fn is_null(&self) -> bool { + matches!(self.0, ObjectRef::Null) + } + + /// Returns the inner `ObjectRef`, consuming `self`. + #[must_use] + pub fn into_inner(self) -> ObjectRef<'static> { + self.0 + } + + /// Returns the name of the object reference. + /// If the object reference is `Null`, it returns `None`. + /// If the object reference is `Owned` or `Borrowed`, it returns the name. + /// + /// # Example + /// ```rust + /// use zbus::names::UniqueName; + /// use zbus::wire::ObjectPath; + /// use atspi_common::ObjectRef; + /// + /// let name = UniqueName::from_static_str_unchecked(":1.23"); + /// let path = ObjectPath::from_static_str_unchecked("/org/a11y/example/path/007"); + /// let object_ref = ObjectRef::new_borrowed(name, path); + /// + /// // Check the name of the object reference + /// assert!(object_ref.name().is_some()); + /// assert_eq!(object_ref.name_as_str().unwrap(), ":1.23"); + /// ``` + #[must_use] + pub fn name(&self) -> Option<&UniqueName<'static>> { + match &self.0 { + ObjectRef::Owned { name, .. } | ObjectRef::Borrowed { name, .. } => Some(name), + ObjectRef::Null => None, + } + } + + /// Returns the path of the object reference.\ + /// If the object reference is `Null`, it returns the null-path. + /// + /// # Example + /// ```rust + /// use zbus::names::UniqueName; + /// use zbus::wire::ObjectPath; + /// use atspi_common::ObjectRef; + /// + /// let name = UniqueName::from_static_str_unchecked(":1.23"); + /// let path = ObjectPath::from_static_str_unchecked("/org/a11y/example/path/007"); + /// let object_ref = ObjectRef::new_borrowed(name, path); + /// + /// assert_eq!(object_ref.path_as_str(), "/org/a11y/example/path/007"); + /// ``` + #[must_use] + pub fn path(&self) -> &ObjectPath<'static> { + match &self.0 { + ObjectRef::Owned { path, .. } | ObjectRef::Borrowed { path, .. } => path, + ObjectRef::Null => NULL_OBJECT_PATH, + } + } + + /// Returns the name of the object reference as a string slice. + #[must_use] + pub fn name_as_str(&self) -> Option<&str> { + match &self.0 { + ObjectRef::Null => None, + ObjectRef::Owned { name, .. } | ObjectRef::Borrowed { name, .. } => Some(name.as_str()), + } + } + + /// Returns the path of the object reference as a string slice. + #[must_use] + pub fn path_as_str(&self) -> &str { + match &self.0 { + ObjectRef::Null => NULL_PATH_STR, + ObjectRef::Owned { path, .. } | ObjectRef::Borrowed { path, .. } => path.as_str(), + } + } +} + +impl Serialize for ObjectRef<'_> { + /// `ObjectRef`'s wire format is `(&str, ObjectPath)`. + /// The `Null` variant, the "Null object", is serialized as `("", ObjectPath("/org/a11y/atspi/null"))`. + /// Both `Owned` and `Borrowed` variants are serialized as `(&str, ObjectPath)` with the object's\ + /// unique name and path. + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + match &self { + ObjectRef::Null => ("", NULL_OBJECT_PATH).serialize(serializer), + ObjectRef::Owned { name, path } | ObjectRef::Borrowed { name, path } => { + (name.as_str(), path).serialize(serializer) + } + } + } +} + +impl Serialize for ObjectRefOwned { + /// `ObjectRefOwned` is serialized as the inner `ObjectRef`. + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + self.0.serialize(serializer) + } +} + +impl<'de: 'o, 'o> Deserialize<'de> for ObjectRef<'o> { + /// `ObjectRef`'s wire format is `(&str, ObjectPath)`. + /// An empty `&str` with a "/org/a11y/atspi/null" path is considered a `Null` object, + /// this is deserialized as `ObjectRef::Null`.\ + /// Any other valid `(&str, ObjectPath)` will deserialize into `ObjectRef::Borrowed`. + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct ObjectRefVisitor; + + impl<'de> serde::de::Visitor<'de> for ObjectRefVisitor { + type Value = ObjectRef<'de>; + + fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + formatter.write_str("a tuple of (&str, ObjectPath)") + } + + fn visit_seq(self, mut seq: A) -> Result + where + A: serde::de::SeqAccess<'de>, + { + let name: &str = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(0, &self))?; + let path: ObjectPath<'de> = seq + .next_element()? + .ok_or_else(|| serde::de::Error::invalid_length(1, &self))?; + + if path == *NULL_OBJECT_PATH { + Ok(ObjectRef::Null) + } else { + assert!( + !name.is_empty(), + "A non-null ObjectRef requires a name and a path but got: (\"\", {path})" + ); + Ok(ObjectRef::Borrowed { + name: UniqueName::try_from(name).map_err(serde::de::Error::custom)?, + path, + }) + } + } + } + + deserializer.deserialize_tuple(2, ObjectRefVisitor) + } +} + +impl<'de> Deserialize<'de> for ObjectRefOwned { + /// `ObjectRefOwned` is deserialized as "Owned" variant `ObjectRef<'static>`. + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let object_ref: ObjectRef<'_> = Deserialize::deserialize(deserializer)?; + Ok(object_ref.into()) + } +} + +impl PartialEq for ObjectRef<'_> { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + // Match order is relevant here. Null == Null, but Null != any other object. + (ObjectRef::Null, ObjectRef::Null) => true, + (ObjectRef::Null, _) | (_, ObjectRef::Null) => false, + _ => self.name() == other.name() && self.path() == other.path(), + } + } +} + +// `Hash` requires that hashes are equal if values are equal. +// If a == b, then a.hash() == b.hash() must hold true. +// +// Because PartialEq treats Owned and Borrowed variants with identical (name, path) as equal, +// we must implement Hash manually to ignore the variant discriminant and preserve hash/equality +// consistency. +impl Hash for ObjectRef<'_> { + fn hash(&self, state: &mut H) { + match self { + ObjectRef::Null => { + // Hashing a Null object reference. + "Null".hash(state); + } + ObjectRef::Owned { name, path } | ObjectRef::Borrowed { name, path } => { + name.as_str().hash(state); + path.as_str().hash(state); + } + } + } +} + +impl Hash for ObjectRefOwned { + fn hash(&self, state: &mut H) { + self.0.hash(state); + } +} + +impl PartialEq for ObjectRefOwned { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } +} + +impl PartialEq> for ObjectRefOwned { + fn eq(&self, other: &ObjectRef<'_>) -> bool { + self.0 == *other + } +} + +impl PartialEq for ObjectRef<'_> { + fn eq(&self, other: &ObjectRefOwned) -> bool { + *self == other.0 + } +} + +#[cfg(feature = "zbus")] +impl<'m: 'o, 'o> TryFrom<&'m zbus::message::Header<'_>> for ObjectRef<'o> { + type Error = crate::AtspiError; + + // Construct an ObjectRef<'o> by reborrowing from the Header’s data. + // 'm: 'o, 'm outlives 'o, so the references returned by this function + // are guaranteed to be valid for the lifetime of the header. + + /// Construct an `ObjectRef` from a `zbus::message::Header`. + /// + /// # Header fields + /// + /// `Path` is a mandatory field on method calls and signals, + /// `Sender` is an optional field, see: + /// [DBus specification - header fields]())., + /// + /// ```quote + /// On a message bus, this header field is controlled by the message bus, + /// so it is as reliable and trustworthy as the message bus itself. + /// Otherwise, (eg. P2P) this header field is controlled by the message sender, + /// unless there is out-of-band information that indicates otherwise. + /// ``` + /// + /// While unlikely, it is possible that `Sender` or `Path` are not set on the header. + /// This could happen if the server implementation does not set these fields for any reason. + /// + /// # Errors + /// Will return an `AtspiError::ParseError` if the header does not contain a valid path or sender. + fn try_from(header: &'m zbus::message::Header) -> Result { + let path = header.path().ok_or(crate::AtspiError::MissingPath)?; + let name = header.sender().ok_or(crate::AtspiError::MissingName)?; + + Ok(ObjectRef::Borrowed { name: name.clone(), path: path.clone() }) + } +} + +#[cfg(feature = "zbus")] +impl<'m> TryFrom<&'m zbus::message::Header<'_>> for ObjectRefOwned { + type Error = crate::AtspiError; + + /// Construct an `ObjectRefOwned` from a `zbus::message::Header`. + fn try_from(header: &'m zbus::message::Header) -> Result { + let path = header.path().ok_or(crate::AtspiError::MissingPath)?; + let name = header.sender().ok_or(crate::AtspiError::MissingName)?; + + let object_ref = + ObjectRef::Owned { name: name.clone().into_owned(), path: path.clone().into_owned() }; + Ok(ObjectRefOwned(object_ref)) + } +} + +impl<'v> TryFrom> for ObjectRef<'v> { + type Error = zbus::wire::Error; + + fn try_from(value: zbus::wire::Variant<'v>) -> Result { + // Relies on the generic `Value` to tuple conversion `(UniqueName, ObjectPath)`. + let (name, path): (UniqueName, ObjectPath) = value.try_into()?; + Ok(ObjectRef::new_borrowed(name, path)) + } +} + +impl<'v> TryFrom> for ObjectRefOwned { + type Error = zbus::wire::Error; + + fn try_from(value: zbus::wire::Variant<'v>) -> Result { + // Relies on the generic `Value` to tuple conversion `(UniqueName, ObjectPath)`. + let (name, path): (UniqueName, ObjectPath) = value.try_into()?; + Ok(ObjectRef::new_borrowed(name, path).into()) + } +} + +impl TryFrom for ObjectRef<'static> { + type Error = zbus::wire::Error; + fn try_from(value: zbus::wire::OwnedVariant) -> Result { + let (name, path): (UniqueName<'static>, ObjectPath<'static>) = value.try_into()?; + Ok(ObjectRef::Owned { name, path }) + } +} + +impl TryFrom for ObjectRefOwned { + type Error = zbus::wire::Error; + fn try_from(value: zbus::wire::OwnedVariant) -> Result { + let (name, path): (UniqueName<'static>, ObjectPath<'static>) = value.try_into()?; + let obj = ObjectRef::Owned { name, path }; + Ok(ObjectRefOwned(obj)) + } +} + +impl<'reference: 'structure, 'object: 'structure, 'structure> From<&'reference ObjectRef<'object>> + for zbus::wire::Structure<'structure> +{ + fn from(obj: &'reference ObjectRef<'object>) -> Self { + match obj { + ObjectRef::Null => ("", NULL_OBJECT_PATH).into(), + ObjectRef::Borrowed { name, path } => Structure::from((name.clone(), path)), + ObjectRef::Owned { name, path } => Structure::from((name.as_str(), path.as_ref())), + } + } +} + +impl<'o> From> for zbus::wire::Structure<'o> { + fn from(obj: ObjectRef<'o>) -> Self { + match obj { + ObjectRef::Null => Structure::from(("", NULL_OBJECT_PATH)), + ObjectRef::Borrowed { name, path } | ObjectRef::Owned { name, path } => { + Structure::from((name, path)) + } + } + } +} + +impl From for zbus::wire::Structure<'_> { + fn from(obj: ObjectRefOwned) -> Self { + let object_ref = obj.into_inner(); + object_ref.into() + } +} + +#[cfg(test)] +mod tests { + use std::hash::{DefaultHasher, Hash, Hasher}; + + use super::ObjectRef; + use crate::object_ref::{NULL_OBJECT_PATH, NULL_PATH_STR}; + use zbus::{names::UniqueName, wire::ObjectPath}; + use zbus::wire::{serialized::Context, to_bytes, OwnedVariant as OwnedValue, Variant as Value, LE}; + + const TEST_OBJECT_PATH: &str = "/org/a11y/atspi/path/007"; + + #[test] + fn owned_object_ref_creation() { + let name = UniqueName::from_static_str_unchecked(":1.23"); + let path = ObjectPath::from_static_str_unchecked(TEST_OBJECT_PATH); + + let object_ref = ObjectRef::new_owned(name, path); + + assert_eq!(object_ref.name_as_str(), Some(":1.23")); + assert_eq!(object_ref.path_as_str(), TEST_OBJECT_PATH); + } + + #[test] + fn borrowed_object_ref_creation() { + let object_ref = ObjectRef::new_borrowed( + UniqueName::from_static_str(":1.23").unwrap(), + ObjectPath::from_static_str_unchecked(TEST_OBJECT_PATH), + ); + assert_eq!(object_ref.name_as_str(), Some(":1.23")); + assert_eq!(object_ref.path_as_str(), TEST_OBJECT_PATH); + } + + #[test] + fn null_object_ref() { + let null_object_ref: ObjectRef = ObjectRef::Null; + assert!(null_object_ref.is_null()); + assert!(null_object_ref.name().is_none()); + assert_eq!(null_object_ref.path(), NULL_OBJECT_PATH); + } + + #[test] + fn object_ref_into_owned() { + let borrowed_object_ref = ObjectRef::new_borrowed( + UniqueName::from_static_str(":1.23").unwrap(), + ObjectPath::from_static_str_unchecked(TEST_OBJECT_PATH), + ); + let owned_object_ref = borrowed_object_ref.into_owned(); + assert!(matches!(owned_object_ref, ObjectRef::Owned { .. })); + assert_eq!(owned_object_ref.name_as_str(), Some(":1.23")); + assert_eq!(owned_object_ref.path_as_str(), TEST_OBJECT_PATH); + } + + #[test] + fn object_ref_into_name_and_path() { + let object_ref = ObjectRef::new_borrowed( + UniqueName::from_static_str(":1.23").unwrap(), + ObjectPath::from_static_str_unchecked(TEST_OBJECT_PATH), + ); + let name = object_ref.name().unwrap(); + let path = object_ref.path(); + assert_eq!(name.as_str(), ":1.23"); + assert_eq!(path.as_str(), TEST_OBJECT_PATH); + } + + #[test] + fn serialization_null_object_ref() { + let null_object_ref: ObjectRef = ObjectRef::Null; + assert!(null_object_ref.is_null()); + + let ctxt = Context::new(LE, 0); + let encoded = to_bytes(ctxt, &null_object_ref).unwrap(); + + let (obj, _) = encoded.deserialize::().unwrap(); + + assert!(obj.is_null()); + assert!(obj.name().is_none()); + assert_eq!(obj.path(), NULL_OBJECT_PATH); + } + + #[test] + fn serialization_owned_object_ref() { + let name = UniqueName::from_static_str_unchecked(":1.23"); + let path = ObjectPath::from_static_str_unchecked(TEST_OBJECT_PATH); + + let object_ref = ObjectRef::new_owned(name, path); + + let ctxt = Context::new(LE, 0); + let encoded = to_bytes(ctxt, &object_ref).unwrap(); + + let (obj, _) = encoded.deserialize::().unwrap(); + + // Deserialization alwayys results in a borrowed object reference. + // On the wire the distinction between owned and borrowed is not preserved. + // As borrowed is the cheaper option, we always deserialize to that. + assert!(matches!(obj, ObjectRef::Borrowed { .. })); + assert_eq!(obj.name().unwrap().as_str(), ":1.23"); + assert_eq!(obj.path_as_str(), TEST_OBJECT_PATH); + } + + #[test] + fn serialization_borrowed_object_ref() { + let object_ref = ObjectRef::new_borrowed( + UniqueName::from_static_str(":1.23").unwrap(), + ObjectPath::from_static_str_unchecked(TEST_OBJECT_PATH), + ); + + let ctxt = Context::new(LE, 0); + let encoded = to_bytes(ctxt, &object_ref).unwrap(); + + let (obj, _) = encoded.deserialize::().unwrap(); + assert!(matches!(obj, ObjectRef::Borrowed { .. })); + + assert_eq!(obj.name().unwrap().as_str(), ":1.23"); + assert_eq!(obj.path_as_str(), TEST_OBJECT_PATH); + } + + #[test] + fn object_ref_equality() { + let object_ref1 = ObjectRef::new_borrowed( + UniqueName::from_static_str(":1.23").unwrap(), + ObjectPath::from_static_str_unchecked(TEST_OBJECT_PATH), + ); + let object_ref2 = ObjectRef::new_borrowed( + UniqueName::from_static_str(":1.23").unwrap(), + ObjectPath::from_static_str_unchecked(TEST_OBJECT_PATH), + ); + assert_eq!(object_ref1, object_ref2); + + let object_ref3 = ObjectRef::new_borrowed( + UniqueName::from_static_str(":1.24").unwrap(), + ObjectPath::from_static_str_unchecked(TEST_OBJECT_PATH), + ); + assert_ne!(object_ref1, object_ref3); + + let object_ref4 = ObjectRef::new_owned( + UniqueName::from_static_str_unchecked(":1.23"), + ObjectPath::from_static_str_unchecked(TEST_OBJECT_PATH), + ); + assert_eq!(object_ref1, object_ref4); + + let null_object_ref: ObjectRef = ObjectRef::Null; + assert_ne!(object_ref1, null_object_ref); + assert_ne!(null_object_ref, object_ref1); + + let null_object_ref2: ObjectRef = ObjectRef::Null; + assert_eq!(null_object_ref, null_object_ref2); + } + + #[test] + fn try_from_value_for_objectref() { + let name = UniqueName::from_static_str_unchecked(":0.0"); + let path = ObjectPath::from_static_str_unchecked("/org/a11y/atspi/testpath"); + + let objref = ObjectRef::new_borrowed(name, path); + let value: Value = objref.into(); + + let objref_2: ObjectRef = value.try_into().unwrap(); + + assert_eq!(objref_2.name().unwrap().as_str(), ":0.0"); + assert_eq!(objref_2.path_as_str(), "/org/a11y/atspi/testpath"); + } + + #[test] + fn try_from_owned_value_for_objectref() { + let name = UniqueName::from_static_str_unchecked(":0.0"); + let path = ObjectPath::from_static_str_unchecked("/org/a11y/atspi/testpath"); + + let objref = ObjectRef::new_borrowed(name, path); + + let value: Value = objref.into(); + let value: OwnedValue = value.try_into().unwrap(); + let objref_2: ObjectRef = value.try_into().unwrap(); + + assert_eq!(objref_2.name_as_str(), Some(":0.0")); + assert_eq!(objref_2.path_as_str(), "/org/a11y/atspi/testpath"); + } + + // Must fail test: + + #[test] + fn must_fail_test_try_from_invalid_value_for_object_ref() { + let value = zbus::wire::Variant::from((42, true)); + let obj: Result = value.try_into(); + assert!(obj.is_err()); + } + + #[test] + fn hash_and_object_coherence() { + let name = UniqueName::from_static_str_unchecked(":1.23"); + let path = ObjectPath::from_static_str_unchecked(TEST_OBJECT_PATH); + + let object_ref1 = ObjectRef::new_borrowed(&name, &path); + let object_ref2 = ObjectRef::new_borrowed(name, path); + + let mut hasher1 = DefaultHasher::new(); + let mut hasher2 = DefaultHasher::new(); + assert_eq!(object_ref1, object_ref2); + object_ref1.hash(&mut hasher1); + object_ref2.hash(&mut hasher2); + assert_eq!(hasher1.finish(), hasher2.finish()); + } + + #[test] + #[should_panic(expected = "assertion failed: matches!(obj, ObjectRef::Borrowed { .. })")] + fn valid_name_null_path_object_ref() { + let object_ref = ObjectRef::from_static_str_unchecked("1.23", NULL_PATH_STR); + + let ctxt = Context::new(LE, 0); + let encoded = to_bytes(ctxt, &object_ref).unwrap(); + + let (obj, _) = encoded.deserialize::().unwrap(); + assert!(matches!(obj, ObjectRef::Borrowed { .. })); + } + + // Check that the Deserialize implementation correctly panics + #[test] + #[should_panic( + expected = r#"A non-null ObjectRef requires a name and a path but got: ("", /org/a11y/atspi/path/007)"# + )] + fn empty_name_valid_path_object_ref() { + let object_ref = ObjectRef::from_static_str_unchecked("", TEST_OBJECT_PATH); + + let ctxt = Context::new(LE, 0); + let encoded = to_bytes(ctxt, &object_ref).unwrap(); + + let (_obj, _) = encoded.deserialize::().unwrap(); + } +} diff --git a/patches/atspi-common/src/operation.rs b/patches/atspi-common/src/operation.rs new file mode 100644 index 0000000..748d9fa --- /dev/null +++ b/patches/atspi-common/src/operation.rs @@ -0,0 +1,39 @@ +use crate::AtspiError; +use std::{fmt, str::FromStr}; + +/// An operation can either be [`Self::Insert`] or [`Self::Delete`]. +/// These correspond to methods available on [`Vec`]. +#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)] +pub enum Operation { + #[default] + #[serde(rename = "add")] + #[serde(alias = "add/system")] + #[serde(alias = "insert")] + #[serde(alias = "insert/system")] + Insert, + #[serde(rename = "delete")] + #[serde(alias = "delete/system")] + #[serde(alias = "remove")] + #[serde(alias = "remove/system")] + Delete, +} + +impl FromStr for Operation { + type Err = AtspiError; + fn from_str(s: &str) -> Result { + match s { + "add" | "add/system" | "insert" | "insert/system" => Ok(Operation::Insert), + "delete" | "delete/system" | "remove" | "remove/system" => Ok(Operation::Delete), + _ => Err(AtspiError::KindMatch(format!("{s} is not a type of Operation"))), + } + } +} + +impl fmt::Display for Operation { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Operation::Insert => write!(f, "insert"), + Operation::Delete => write!(f, "delete"), + } + } +} diff --git a/patches/atspi-common/src/relation_type.rs b/patches/atspi-common/src/relation_type.rs new file mode 100644 index 0000000..1e35510 --- /dev/null +++ b/patches/atspi-common/src/relation_type.rs @@ -0,0 +1,121 @@ +use serde::{Deserialize, Serialize}; +use zbus::wire::Type; + +/// Describes a relationship between one object and another. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type, Hash)] +pub enum RelationType { + /// Not a meaningful relationship; clients should not normally encounter this value. + Null = 0, + + /// Object is a label for one or more other objects. + LabelFor, + + /// Object is labelled by one or more other objects. + LabelledBy, + + /// Object is an interactive object which modifies the state, + /// onscreen location, or other attributes of one or more target objects. + ControllerFor, + + /// Object state, position, etc. is modified/controlled by user interaction + /// with one or more other objects. + /// For instance a viewport or scroll pane may be `ControlledBy` scrollbars. + ControlledBy, + + /// Object has a grouping relationship (e.g. 'same group as') to one or more other objects. + MemberOf, + + /// Object is a tooltip associated with another object. + TooltipFor, + + /// Object is a child of the target. + NodeChildOf, + + /// Object is a parent of the target. + NodeParentOf, + + /// Used to indicate that a relationship exists, but its type is not + /// specified in the enumeration. + Extended, + + /// Object renders content which flows logically to another object. + /// For instance, text in a paragraph may flow to another object + /// which is not the 'next sibling' in the accessibility hierarchy. + FlowsTo, + + /// Reciprocal of `FlowsTo`. + FlowsFrom, + + /// Object is visually and semantically considered a subwindow of another object, + /// even though it is not the object's child. + /// Useful when dealing with embedded applications and other cases where the + /// widget hierarchy does not map cleanly to the onscreen presentation. + SubwindowOf, + + /// Similar to `SubwindowOf`, but specifically used for cross-process embedding. + Embeds, + + /// Reciprocal of `Embeds`. Used to denote content rendered by embedded renderers + /// that live in a separate process space from the embedding context. + EmbeddedBy, + + ///Denotes that the object is a transient window or frame associated with another + /// onscreen object. Similar to `TooltipFor`, but more general. + /// Useful for windows which are technically toplevels but which, for one or more reasons, + /// do not explicitly cause their associated window to lose 'window focus'. + /// Creation of an [`crate::Role::Window`] object with the `PopupFor` relation usually requires + /// some presentation action on the part of assistive technology clients, + /// even though the previous toplevel [`crate::Role::Frame`] object may still be the active window. + PopupFor, + + /// This is the reciprocal relation to `PopupFor`. + ParentWindowOf, + + /// Reciprocal of `DescribedBy`. Indicates that this object provides descriptive information + /// about the target object(s). See also `DetailsFor` and `ErrorFor`. + DescriptionFor, + + /// Reciprocal of `DescriptionFor`. + /// Indicates that one or more target objects provide descriptive information + /// about this object. This relation type is most appropriate for information + /// that is not essential as its presentation may be user-configurable and/or + /// limited to an on-demand mechanism such as an assistive technology command. + /// For brief, essential information such as can be found in a widget's on-screen + /// label, use `LabelledBy`. For an on-screen error message, use `ErrorMessage`. + /// For lengthy extended descriptive information contained in an on-screen object, + /// consider using `Details` as assistive technologies may provide a means + /// for the user to navigate to objects containing detailed descriptions so that + /// their content can be more closely reviewed. + DescribedBy, + + /// Reciprocal of `DetailsFor`. + /// Indicates that this object has a detailed or extended description, + /// the contents of which can be found in the target object(s). + /// This relation type is most appropriate for information that is sufficiently lengthy + /// as to make navigation to the container of that information desirable. + /// For less verbose information suitable for announcement only, see `DescribedBy`. + /// If the detailed information describes an error condition, `ErrorFor` should be used instead. + /// Included in upstream [AT-SPI2-CORE](https://gitlab.gnome.org/GNOME/at-spi2-core) since 2.26. + Details, + + /// Reciprocal of `Details`. + /// Indicates that this object provides a detailed or extended description about the target + /// object(s). See also `DescriptionFor` and `ErrorFor`. + /// Included in upstream [AT-SPI2-CORE](https://gitlab.gnome.org/GNOME/at-spi2-core) since 2.26. + DetailsFor, + + /// Reciprocal of `ErrorFor`. + /// Indicates that this object has one or more errors, the nature of which is + /// described in the contents of the target object(s). Objects that have this + /// relation type should also contain [`crate::state::State::InvalidEntry`] when their + /// `GetState` method is called. + /// + /// Included in upstream [AT-SPI2-CORE](https://gitlab.gnome.org/GNOME/at-spi2-core) since 2.26. + ErrorMessage, + + /// Reciprocal of `ErrorMessage`. + /// Indicates that this object contains an error message describing an invalid condition + /// in the target object(s). + /// Included in upstream [AT-SPI2-CORE](https://gitlab.gnome.org/GNOME/at-spi2-core) since 2.26. + ErrorFor, +} diff --git a/patches/atspi-common/src/role.rs b/patches/atspi-common/src/role.rs new file mode 100644 index 0000000..9d2f7b1 --- /dev/null +++ b/patches/atspi-common/src/role.rs @@ -0,0 +1,651 @@ +use serde::{Deserialize, Serialize}; +use zbus::wire::Type; + +use crate::AtspiError; + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type, Hash)] +/// An accessible object role. +/// +/// To think of it in terms of HTML, any semantic element likely has a corollary in this enum. +/// For example: `