Skip to content

misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux

Screen readers see a window's contents the first time they read it (#131) (#138)

Ahmed Nefzaoui8ec3fbe013a3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 13705989..1b3e4304 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -311,6 +311,10 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see
### Fixed
+- **Screen readers see a window's contents the first time they read it**
+ ([#131](https://github.com/anefzaoui/misterdownloadmanager/issues/131)): a window read for the
+ first time (Link grabber, Options, About...) showed only its title bar until it was drawn
+ again. It now answers with what it shows at once, as soon as a screen reader is running.
- **A magnet link could wait minutes for its file list** ([#92](https://github.com/anefzaoui/misterdownloadmanager/issues/92)):
in 0.2.4 on Windows, the DHT (how MDM finds peers without trackers) could stop for the rest
of the session once a computer it asked was gone, so a magnet its trackers didn't serve never
diff --git a/Cargo.lock b/Cargo.lock
index 27884052..c604adf5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1827,7 +1827,7 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a"
dependencies = [
- "libloading 0.8.9",
+ "libloading 0.7.4",
]
[[package]]
@@ -1899,7 +1899,7 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555"
[[package]]
name = "ecolor"
version = "0.37.0"
-source = "git+https://github.com/anefzaoui/egui.git?rev=60b5751250171425d239f6580aaca7fc13d60c64#60b5751250171425d239f6580aaca7fc13d60c64"
+source = "git+https://github.com/anefzaoui/egui.git?rev=2385050619bb5c0233204184ce638678dfc2f340#2385050619bb5c0233204184ce638678dfc2f340"
dependencies = [
"bytemuck",
"emath",
@@ -1908,7 +1908,7 @@ dependencies = [
[[package]]
name = "eframe"
version = "0.37.0"
-source = "git+https://github.com/anefzaoui/egui.git?rev=60b5751250171425d239f6580aaca7fc13d60c64#60b5751250171425d239f6580aaca7fc13d60c64"
+source = "git+https://github.com/anefzaoui/egui.git?rev=2385050619bb5c0233204184ce638678dfc2f340#2385050619bb5c0233204184ce638678dfc2f340"
dependencies = [
"ahash",
"bytemuck",
@@ -1942,7 +1942,7 @@ dependencies = [
[[package]]
name = "egui"
version = "0.37.0"
-source = "git+https://github.com/anefzaoui/egui.git?rev=60b5751250171425d239f6580aaca7fc13d60c64#60b5751250171425d239f6580aaca7fc13d60c64"
+source = "git+https://github.com/anefzaoui/egui.git?rev=2385050619bb5c0233204184ce638678dfc2f340#2385050619bb5c0233204184ce638678dfc2f340"
dependencies = [
"accesskit",
"ahash",
@@ -1961,7 +1961,7 @@ dependencies = [
[[package]]
name = "egui-wgpu"
version = "0.37.0"
-source = "git+https://github.com/anefzaoui/egui.git?rev=60b5751250171425d239f6580aaca7fc13d60c64#60b5751250171425d239f6580aaca7fc13d60c64"
+source = "git+https://github.com/anefzaoui/egui.git?rev=2385050619bb5c0233204184ce638678dfc2f340#2385050619bb5c0233204184ce638678dfc2f340"
dependencies = [
"ahash",
"bytemuck",
@@ -1980,7 +1980,7 @@ dependencies = [
[[package]]
name = "egui-winit"
version = "0.37.0"
-source = "git+https://github.com/anefzaoui/egui.git?rev=60b5751250171425d239f6580aaca7fc13d60c64#60b5751250171425d239f6580aaca7fc13d60c64"
+source = "git+https://github.com/anefzaoui/egui.git?rev=2385050619bb5c0233204184ce638678dfc2f340#2385050619bb5c0233204184ce638678dfc2f340"
dependencies = [
"accesskit_winit",
"arboard",
@@ -2005,7 +2005,7 @@ dependencies = [
[[package]]
name = "egui_extras"
version = "0.37.0"
-source = "git+https://github.com/anefzaoui/egui.git?rev=60b5751250171425d239f6580aaca7fc13d60c64#60b5751250171425d239f6580aaca7fc13d60c64"
+source = "git+https://github.com/anefzaoui/egui.git?rev=2385050619bb5c0233204184ce638678dfc2f340#2385050619bb5c0233204184ce638678dfc2f340"
dependencies = [
"ahash",
"egui",
@@ -2021,7 +2021,7 @@ dependencies = [
[[package]]
name = "egui_glow"
version = "0.37.0"
-source = "git+https://github.com/anefzaoui/egui.git?rev=60b5751250171425d239f6580aaca7fc13d60c64#60b5751250171425d239f6580aaca7fc13d60c64"
+source = "git+https://github.com/anefzaoui/egui.git?rev=2385050619bb5c0233204184ce638678dfc2f340#2385050619bb5c0233204184ce638678dfc2f340"
dependencies = [
"bytemuck",
"egui",
@@ -2049,7 +2049,7 @@ dependencies = [
[[package]]
name = "emath"
version = "0.37.0"
-source = "git+https://github.com/anefzaoui/egui.git?rev=60b5751250171425d239f6580aaca7fc13d60c64#60b5751250171425d239f6580aaca7fc13d60c64"
+source = "git+https://github.com/anefzaoui/egui.git?rev=2385050619bb5c0233204184ce638678dfc2f340#2385050619bb5c0233204184ce638678dfc2f340"
dependencies = [
"bytemuck",
]
@@ -2118,7 +2118,7 @@ dependencies = [
[[package]]
name = "epaint"
version = "0.37.0"
-source = "git+https://github.com/anefzaoui/egui.git?rev=60b5751250171425d239f6580aaca7fc13d60c64#60b5751250171425d239f6580aaca7fc13d60c64"
+source = "git+https://github.com/anefzaoui/egui.git?rev=2385050619bb5c0233204184ce638678dfc2f340#2385050619bb5c0233204184ce638678dfc2f340"
dependencies = [
"ahash",
"bytemuck",
@@ -2144,7 +2144,7 @@ dependencies = [
[[package]]
name = "epaint_default_fonts"
version = "0.37.0"
-source = "git+https://github.com/anefzaoui/egui.git?rev=60b5751250171425d239f6580aaca7fc13d60c64#60b5751250171425d239f6580aaca7fc13d60c64"
+source = "git+https://github.com/anefzaoui/egui.git?rev=2385050619bb5c0233204184ce638678dfc2f340#2385050619bb5c0233204184ce638678dfc2f340"
[[package]]
name = "equivalent"
@@ -3303,7 +3303,7 @@ dependencies = [
"js-sys",
"log",
"wasm-bindgen",
- "windows-core 0.62.2",
+ "windows-core 0.58.0",
]
[[package]]
@@ -5231,7 +5231,7 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8"
dependencies = [
- "proc-macro-crate 3.5.0",
+ "proc-macro-crate 1.3.1",
"proc-macro2",
"quote",
"syn 2.0.119",
@@ -5702,7 +5702,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
dependencies = [
"libc",
- "windows-sys 0.61.2",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -9094,7 +9094,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
- "windows-sys 0.61.2",
+ "windows-sys 0.48.0",
]
[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index b8ea8520..682e854d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -57,6 +57,7 @@ windows-sys = { version = "0.61.2", features = [
"Win32_System_Registry",
"Win32_System_SystemInformation",
"Win32_System_Threading",
+ "Win32_UI_Accessibility",
"Win32_UI_Controls",
"Win32_UI_HiDpi",
"Win32_UI_Input_KeyboardAndMouse",
@@ -252,10 +253,11 @@ opt-level = 3
[profile.dev.package."*"]
debug = "line-tables-only"
-# storytold's egui fork (as storytold/craft-libs, D-003) plus two MDM commits on anefzaoui/egui
+# storytold's egui fork (as storytold/craft-libs, D-003) plus three MDM commits on anefzaoui/egui
# (branch mdm-accesskit-windows): every window created hidden gets an AccessKit adapter, so
-# screen readers read the dialogs and menus; and a dialog opened while the main window is
-# minimized no longer panics (emilk/egui#8470). craft-libs can take the same commits to share
+# screen readers read the dialogs and menus; a dialog opened while the main window is
+# minimized no longer panics (emilk/egui#8470); and a window's first accessibility request is
+# answered with its last tree, not an empty placeholder (#131). craft-libs can take the same commits to share
# one egui again.
[patch.crates-io]
# librqbit 9.1.0 with per-torrent rate limits that change while a torrent runs (#39), and a
@@ -272,13 +274,13 @@ librqbit-peer-protocol = { git = "https://github.com/anefzaoui/rqbit.git", rev =
librqbit-sha1-wrapper = { git = "https://github.com/anefzaoui/rqbit.git", rev = "9753b21b64bfd1eb74dc8c488763b67edba2bd26" }
librqbit-tracker-comms = { git = "https://github.com/anefzaoui/rqbit.git", rev = "9753b21b64bfd1eb74dc8c488763b67edba2bd26" }
librqbit-upnp = { git = "https://github.com/anefzaoui/rqbit.git", rev = "9753b21b64bfd1eb74dc8c488763b67edba2bd26" }
-ecolor = { git = "https://github.com/anefzaoui/egui.git", rev = "60b5751250171425d239f6580aaca7fc13d60c64" }
-emath = { git = "https://github.com/anefzaoui/egui.git", rev = "60b5751250171425d239f6580aaca7fc13d60c64" }
-epaint = { git = "https://github.com/anefzaoui/egui.git", rev = "60b5751250171425d239f6580aaca7fc13d60c64" }
-epaint_default_fonts = { git = "https://github.com/anefzaoui/egui.git", rev = "60b5751250171425d239f6580aaca7fc13d60c64" }
-egui = { git = "https://github.com/anefzaoui/egui.git", rev = "60b5751250171425d239f6580aaca7fc13d60c64" }
-egui-winit = { git = "https://github.com/anefzaoui/egui.git", rev = "60b5751250171425d239f6580aaca7fc13d60c64" }
-egui_glow = { git = "https://github.com/anefzaoui/egui.git", rev = "60b5751250171425d239f6580aaca7fc13d60c64" }
-egui_extras = { git = "https://github.com/anefzaoui/egui.git", rev = "60b5751250171425d239f6580aaca7fc13d60c64" }
-eframe = { git = "https://github.com/anefzaoui/egui.git", rev = "60b5751250171425d239f6580aaca7fc13d60c64" }
+ecolor = { git = "https://github.com/anefzaoui/egui.git", rev = "2385050619bb5c0233204184ce638678dfc2f340" }
+emath = { git = "https://github.com/anefzaoui/egui.git", rev = "2385050619bb5c0233204184ce638678dfc2f340" }
+epaint = { git = "https://github.com/anefzaoui/egui.git", rev = "2385050619bb5c0233204184ce638678dfc2f340" }
+epaint_default_fonts = { git = "https://github.com/anefzaoui/egui.git", rev = "2385050619bb5c0233204184ce638678dfc2f340" }
+egui = { git = "https://github.com/anefzaoui/egui.git", rev = "2385050619bb5c0233204184ce638678dfc2f340" }
+egui-winit = { git = "https://github.com/anefzaoui/egui.git", rev = "2385050619bb5c0233204184ce638678dfc2f340" }
+egui_glow = { git = "https://github.com/anefzaoui/egui.git", rev = "2385050619bb5c0233204184ce638678dfc2f340" }
+egui_extras = { git = "https://github.com/anefzaoui/egui.git", rev = "2385050619bb5c0233204184ce638678dfc2f340" }
+eframe = { git = "https://github.com/anefzaoui/egui.git", rev = "2385050619bb5c0233204184ce638678dfc2f340" }
winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" }
diff --git a/ROADMAP.md b/ROADMAP.md
index 50b87c1c..ddad3594 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -13,6 +13,8 @@ Everything below ships together, in one release.
### Done
+- ✅ Screen readers see a window's contents the first time they read it, not only its title bar
+ ([#131](https://github.com/anefzaoui/misterdownloadmanager/issues/131))
- ✅ Magnet links get their file list in seconds again: the DHT keeps going after a computer it
asked is gone, and Add torrent shows the wait (peers found, from where, what may be in the
way) ([#92](https://github.com/anefzaoui/misterdownloadmanager/issues/92))
diff --git a/crates/app/src/app.rs b/crates/app/src/app.rs
index 0cf3ee62..3fb75261 100644
--- a/crates/app/src/app.rs
+++ b/crates/app/src/app.rs
@@ -347,6 +347,8 @@ pub struct App {
/// Link grabber (#37): links from the browser, Tasks → Import, drops and pastes, in
/// packages to tick before adding.
grabber: Option<crate::grabber::Grabber>,
+ /// When `follow_assistive_technology` last asked (#131).
+ assistive_checked: Option<Instant>,
/// Archives extracted when their download completes (#37).
extracts: crate::extractq::Extracts,
/// Add category / Properties from the Categories tree.
@@ -795,6 +797,7 @@ impl App {
category_dlg: None,
category_for_file_info: false,
grabber: None,
+ assistive_checked: None,
extracts: Default::default(),
queue_pick: None,
drop_target: None,
@@ -2484,6 +2487,27 @@ impl App {
}
}
+ /// While an assistive technology is listening (a screen reader running, #131), every window
+ /// builds its accessibility tree with each frame, so the first time one is read it answers
+ /// with its contents rather than an empty window (egui keeps the last tree for that). Asked
+ /// once a second; never turned off here (the platform says when nobody listens any more).
+ fn follow_assistive_technology(&mut self, ctx: &egui::Context) {
+ if self
+ .assistive_checked
+ .is_some_and(|t| t.elapsed() < Duration::from_secs(1))
+ {
+ return;
+ }
+ self.assistive_checked = Some(Instant::now());
+ #[cfg(windows)]
+ let listening = crate::win32::assistive_technology_listening();
+ #[cfg(not(windows))]
+ let listening = crate::unix::assistive_technology_listening();
+ if listening {
+ ctx.enable_accesskit();
+ }
+ }
+
/// Options → General → "Offer to download links copied to the clipboard": a newly copied
/// link to a listed file type (Options → File types) is handled as if a browser had sent
/// it, so Download File Info opens with it (unless that window is turned off). Only read,
@@ -6905,6 +6929,7 @@ impl eframe::App for App {
crate::settings::share_dns(self.settings.dns());
crate::crash::window("main");
let ctx = ui.ctx().clone();
+ self.follow_assistive_technology(&ctx);
self.network_adapter_tick(&ctx);
self.debrid_tick();
dialogs::publish_main_rect(&ctx);
diff --git a/crates/app/src/unix.rs b/crates/app/src/unix.rs
index d20ceb8b..8c633f72 100644
--- a/crates/app/src/unix.rs
+++ b/crates/app/src/unix.rs
@@ -250,6 +250,14 @@ pub fn set_torrent_handlers(on: bool) {
}
}
+/// `win32::assistive_technology_listening`: Linux's AT-SPI adapter answers a screen reader with
+/// the first tree a frame produces (no placeholder to replace), and macOS has no such cheap
+/// question; there, as on Windows, a window's tree is ready at once for any window read after
+/// the first one (egui keeps AccessKit on from the first request).
+pub fn assistive_technology_listening() -> bool {
+ false
+}
+
/// `win32::wheel_lines`: Linux and macOS have no such setting shared by every toolkit; three
/// rows a notch, as GTK, Qt and Windows' default do.
pub fn wheel_lines() -> Option<f32> {
diff --git a/crates/app/src/win32.rs b/crates/app/src/win32.rs
index ab302470..f0dc9305 100644
--- a/crates/app/src/win32.rs
+++ b/crates/app/src/win32.rs
@@ -706,6 +706,14 @@ pub fn on_a_screen(x: i32, y: i32) -> bool {
!unsafe { MonitorFromPoint(POINT { x, y }, MONITOR_DEFAULTTONULL) }.is_null()
}
+/// Whether an assistive technology (a screen reader, a UI Automation client) is listening to
+/// this desktop's windows now (#131): the windows then keep their accessibility tree ready, so
+/// a window read for the first time answers with its contents at once.
+pub fn assistive_technology_listening() -> bool {
+ // SAFETY: a plain query, no arguments.
+ unsafe { windows_sys::Win32::UI::Accessibility::UiaClientsAreListening() != 0 }
+}
+
/// Rows a notch of the mouse wheel scrolls (Mouse settings → "lines to scroll at a time", 3
/// unless changed); None when it is set to a screen at a time.
pub fn wheel_lines() -> Option<f32> {