From c48681b9c04a3d55e0048a54dba25360718aca08 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Mon, 16 Oct 2023 08:01:10 -0500 Subject: [PATCH 1/2] Update accesskit and accesskit_winit. --- .github/workflows/rust.yml | 2 +- Cargo.lock | 79 +++++++++++++------- crates/egui-winit/Cargo.toml | 2 +- crates/egui/Cargo.toml | 2 +- crates/egui/src/context.rs | 11 ++- crates/egui/src/id.rs | 2 +- crates/egui/src/response.rs | 12 +-- crates/egui/src/widgets/text_edit/builder.rs | 6 +- 8 files changed, 73 insertions(+), 43 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2b952ef6b9c..18ae5833509 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -96,7 +96,7 @@ jobs: toolchain: 1.70.0 targets: wasm32-unknown-unknown - - run: sudo apt-get update && sudo apt-get install libgtk-3-dev + - run: sudo apt-get update && sudo apt-get install libgtk-3-dev libatk1.0-dev libgtk-3-dev - name: Set up cargo cache uses: Swatinem/rust-cache@v2 diff --git a/Cargo.lock b/Cargo.lock index 5238da31255..60012903a78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,9 +20,9 @@ checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" [[package]] name = "accesskit" -version = "0.11.2" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76eb1adf08c5bcaa8490b9851fd53cca27fa9880076f178ea9d29f05196728a8" +checksum = "b0cc53b7e5d8f45ebe687178cf91af0f45fdba6e78fedf94f0269c5be5b9f296" dependencies = [ "enumn", "serde", @@ -30,18 +30,18 @@ dependencies = [ [[package]] name = "accesskit_consumer" -version = "0.15.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04bb4d9e4772fe0d47df57d0d5dbe5d85dd05e2f37ae1ddb6b105e76be58fb00" +checksum = "39dfcfd32eb0c1b525daaf4b02adcd2fa529c22cd713491e15bf002a01a714f5" dependencies = [ "accesskit", ] [[package]] name = "accesskit_macos" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134d0acf6acb667c89d3332999b1a5df4edbc8d6113910f392ebb73f2b03bb56" +checksum = "89c7e8406319ac3149d7b59983637984f0864bbf738319b1c443976268b6426c" dependencies = [ "accesskit", "accesskit_consumer", @@ -51,38 +51,40 @@ dependencies = [ [[package]] name = "accesskit_unix" -version = "0.5.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e084cb5168790c0c112626175412dc5ad127083441a8248ae49ddf6725519e83" +checksum = "0b0c84552a7995c981d5f22e2d4b24ba9a55718bb12fba883506d6d7344acaf1" dependencies = [ "accesskit", "accesskit_consumer", "async-channel", + "async-once-cell", "atspi", "futures-lite", + "once_cell", "serde", "zbus", ] [[package]] name = "accesskit_windows" -version = "0.14.3" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eac0a7f2d7cd7a93b938af401d3d8e8b7094217989a7c25c55a953023436e31" +checksum = "314d4a797fc82d182b04f4f0665a368924fb556ad9557fccd2d39d38dc8c1c1b" dependencies = [ "accesskit", "accesskit_consumer", - "arrayvec", "once_cell", "paste", + "static_assertions", "windows 0.48.0", ] [[package]] name = "accesskit_winit" -version = "0.14.4" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "825d23acee1bd6d25cbaa3ca6ed6e73faf24122a774ec33d52c5c86c6ab423c0" +checksum = "88e39fcec2e10971e188730b7a76bab60647dacc973d4591855ebebcadfaa738" dependencies = [ "accesskit", "accesskit_macos", @@ -298,6 +300,12 @@ dependencies = [ "event-listener 2.5.3", ] +[[package]] +name = "async-once-cell" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9338790e78aa95a416786ec8389546c4b6a1dfc3dc36071ed9518a9413a542eb" + [[package]] name = "async-process" version = "1.8.0" @@ -382,29 +390,50 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "atspi" -version = "0.10.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "674e7a3376837b2e7d12d34d58ac47073c491dc3bf6f71a7adaf687d4d817faa" +checksum = "6059f350ab6f593ea00727b334265c4dfc7fd442ee32d264794bd9bdc68e87ca" +dependencies = [ + "atspi-common", + "atspi-connection", + "atspi-proxies", +] + +[[package]] +name = "atspi-common" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92af95f966d2431f962bc632c2e68eda7777330158bf640c4af4249349b2cdf5" dependencies = [ - "async-recursion", - "async-trait", - "atspi-macros", "enumflags2", - "futures-lite", "serde", - "tracing", + "static_assertions", "zbus", "zbus_names", + "zvariant", ] [[package]] -name = "atspi-macros" -version = "0.2.0" +name = "atspi-connection" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb4870a32c0eaa17e35bca0e6b16020635157121fb7d45593d242c295bc768" +checksum = "a0c65e7d70f86d4c0e3b2d585d9bf3f979f0b19d635a336725a88d279f76b939" dependencies = [ - "quote", - "syn 1.0.109", + "atspi-common", + "atspi-proxies", + "futures-lite", + "zbus", +] + +[[package]] +name = "atspi-proxies" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6495661273703e7a229356dcbe8c8f38223d697aacfaf0e13590a9ac9977bb52" +dependencies = [ + "atspi-common", + "serde", + "zbus", ] [[package]] diff --git a/crates/egui-winit/Cargo.toml b/crates/egui-winit/Cargo.toml index e48c2b074c0..0c8434850c6 100644 --- a/crates/egui-winit/Cargo.toml +++ b/crates/egui-winit/Cargo.toml @@ -66,7 +66,7 @@ winit = { version = "0.28", default-features = false } #! ### Optional dependencies # feature accesskit -accesskit_winit = { version = "0.14.0", optional = true } +accesskit_winit = { version = "0.15.0", optional = true } ## Enable this when generating docs. document-features = { version = "0.2", optional = true } diff --git a/crates/egui/Cargo.toml b/crates/egui/Cargo.toml index 349f0849aa3..145f1d63cf9 100644 --- a/crates/egui/Cargo.toml +++ b/crates/egui/Cargo.toml @@ -85,7 +85,7 @@ ahash = { version = "0.8.1", default-features = false, features = [ nohash-hasher = "0.2" #! ### Optional dependencies -accesskit = { version = "0.11", optional = true } +accesskit = { version = "0.12", optional = true } backtrace = { version = "0.3", optional = true } diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 27060021bd5..168489752d0 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -1291,7 +1291,6 @@ impl Context { crate::profile_scope!("accesskit"); let state = self.frame_state_mut(|fs| fs.accesskit_state.take()); if let Some(state) = state { - let has_focus = self.input(|i| i.raw.focused); let root_id = crate::accesskit_root_id().accesskit_id(); let nodes = self.write(|ctx| { state @@ -1305,13 +1304,13 @@ impl Context { }) .collect() }); + let focus_id = self + .memory(|mem| mem.focus()) + .map_or(root_id, |id| id.accesskit_id()); platform_output.accesskit_update = Some(accesskit::TreeUpdate { nodes, tree: Some(accesskit::Tree::new(root_id)), - focus: has_focus.then(|| { - let focus_id = self.memory(|mem| mem.focus()); - focus_id.map_or(root_id, |id| id.accesskit_id()) - }), + focus: focus_id, }); } } @@ -1941,7 +1940,7 @@ impl Context { NodeBuilder::new(Role::Window).build(&mut ctx.accesskit_node_classes), )], tree: Some(Tree::new(root_id)), - focus: None, + focus: root_id, }) } } diff --git a/crates/egui/src/id.rs b/crates/egui/src/id.rs index 612314312fd..75cc9f8568f 100644 --- a/crates/egui/src/id.rs +++ b/crates/egui/src/id.rs @@ -72,7 +72,7 @@ impl Id { #[cfg(feature = "accesskit")] pub(crate) fn accesskit_id(&self) -> accesskit::NodeId { - std::num::NonZeroU64::new(self.0).unwrap().into() + self.0.into() } } diff --git a/crates/egui/src/response.rs b/crates/egui/src/response.rs index e95d07c204a..1f387361d71 100644 --- a/crates/egui/src/response.rs +++ b/crates/egui/src/response.rs @@ -620,20 +620,20 @@ impl Response { info: crate::WidgetInfo, ) { use crate::WidgetType; - use accesskit::{CheckedState, Role}; + use accesskit::{Checked, Role}; self.fill_accesskit_node_common(builder); builder.set_role(match info.typ { WidgetType::Label => Role::StaticText, WidgetType::Link => Role::Link, - WidgetType::TextEdit => Role::TextField, + WidgetType::TextEdit => Role::TextInput, WidgetType::Button | WidgetType::ImageButton | WidgetType::CollapsingHeader => { Role::Button } WidgetType::Checkbox => Role::CheckBox, WidgetType::RadioButton => Role::RadioButton, WidgetType::SelectableLabel => Role::ToggleButton, - WidgetType::ComboBox => Role::PopupButton, + WidgetType::ComboBox => Role::ComboBox, WidgetType::Slider => Role::Slider, WidgetType::DragValue => Role::SpinButton, WidgetType::ColorButton => Role::ColorWell, @@ -649,10 +649,10 @@ impl Response { builder.set_numeric_value(value); } if let Some(selected) = info.selected { - builder.set_checked_state(if selected { - CheckedState::True + builder.set_checked(if selected { + Checked::True } else { - CheckedState::False + Checked::False }); } } diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index 7de4733a059..612f04cea9c 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -1,5 +1,7 @@ use std::sync::Arc; +#[cfg(feature = "accesskit")] +use accesskit::Role; use epaint::text::{cursor::*, Galley, LayoutJob}; use crate::{output::OutputEvent, *}; @@ -751,7 +753,7 @@ impl<'t> TextEdit<'t> { builder.set_default_action_verb(accesskit::DefaultActionVerb::Focus); if self.multiline { - builder.set_multiline(); + builder.set_role(Role::MultilineTextInput); } parent_id @@ -759,7 +761,7 @@ impl<'t> TextEdit<'t> { if let Some(parent_id) = parent_id { // drop ctx lock before further processing - use accesskit::{Role, TextDirection}; + use accesskit::TextDirection; ui.ctx().with_accessibility_parent(parent_id, || { for (i, row) in galley.rows.iter().enumerate() { From 590dfc974a87716c7c6c845fa3b9ab19e8882a47 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 10 Nov 2023 11:15:47 +0100 Subject: [PATCH 2/2] Remove duplicated `libgtk-3-dev` --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 18ae5833509..167d18dbb9d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -96,7 +96,7 @@ jobs: toolchain: 1.70.0 targets: wasm32-unknown-unknown - - run: sudo apt-get update && sudo apt-get install libgtk-3-dev libatk1.0-dev libgtk-3-dev + - run: sudo apt-get update && sudo apt-get install libgtk-3-dev libatk1.0-dev - name: Set up cargo cache uses: Swatinem/rust-cache@v2