misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux
Rust bittorrent-clientdebriddownload-acceleratordownload-managerdownloadmanagereguifile-downloadergallery-dlidmidm-alternativeinternet-download-managerm3u8-downloadermagnetplaylist-downloaderreal-debridrusttorrent-clientvideo-downloaderyoutube-downloaderyt-dlp
A download or magnet sent while the window is minimized opens at once (#162) (#173)
Ahmed Nefzaoui86333a4a49c8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex adf8fbb1..3bbbc977 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -344,6 +344,11 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see### Fixed+- **A download or magnet link sent while the window is minimized opens at once**+ ([#162](https://github.com/anefzaoui/misterdownloadmanager/issues/162)): with the main window+ minimized (not to the notification area), a download from the browser or a magnet link was+ accepted but its window waited until MDM was restored. Download File Info and Add torrent now+ open right away, as they do with the window open or in the notification area.- **Linux: Ubuntu's Firefox reaches MDM** (part of [#164](https://github.com/anefzaoui/misterdownloadmanager/issues/164)):the Snap Firefox never makes the folder MDM looked for, so browser integration wasn't set upfor it and its extension couldn't find MDM. It is now, and the Snap goes through the desktop,diff --git a/Cargo.toml b/Cargo.tomlindex 56deba25..49214b72 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -179,8 +179,8 @@ debug = "line-tables-only"# (emilk/egui#8470); and a window's first accessibility request is answered with its last tree# (#131); Direct3D keeps only the graphics adapter in use (a laptop's other GPU sleeps) and, on# Intel Iris Xe, uploads no all-zero texel blocks (gfx-rs/wgpu#10651, #89); a hidden viewport-# can ask for a pass (Context::request_ui_pass); OpenGL without a usable configuration is an error,-# not a panic, so the next renderer is tried. craft-libs can take the same commits to share+# can ask for a pass (Context::request_ui_pass: a dialog opened while minimized, #162); OpenGL+# without a usable configuration is an error, not a panic, so the next renderer is tried. 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 adiff --git a/ROADMAP.md b/ROADMAP.mdindex 6302d295..16ac4b79 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -13,6 +13,8 @@ Everything below ships together, in one release.### Done+- ✅ A download or magnet link sent while the window is minimized opens its window at once+ ([#162](https://github.com/anefzaoui/misterdownloadmanager/issues/162))- ✅ Linux: Ubuntu's Firefox (the Snap) reaches MDM: browser integration is set up for it, and thehelp says what the desktop asks the first time; Chromium as a Snap, which can't reach MDM, is nolonger offered (part of [#164](https://github.com/anefzaoui/misterdownloadmanager/issues/164))diff --git a/crates/app/src/app.rs b/crates/app/src/app.rsindex 6c376a81..84708458 100644--- a/crates/app/src/app.rs+++ b/crates/app/src/app.rs@@ -1636,6 +1636,8 @@ impl App {"about" => self.run(Cmd::About, None, ctx),// The main window into the tray, as closing it does (tests and #72's measurements)."tray" => self.hide_to_tray(ctx),+ // The main window minimized, not to the tray (tests of #162).+ "minimized" => ctx.send_viewport_cmd(egui::ViewportCommand::Minimized(true)),// Off-screen test copies: the interface zoomed (`zoom:1.5`) while running, as a// display's scale changing does to every window (#89's checks)."zoom" if crate::offscreen() => {@@ -7013,6 +7015,27 @@ impl App {}impl eframe::App for App {+ /// What comes in from outside (a second launch, the browser's native host, the automation+ /// API) is handled here, which runs at every frame: `ui` doesn't run while the main window+ /// is minimized, and a magnet or a download handed over then waited until it was restored+ /// (#162). A command that opens a window gets the UI pass that creates it, minimized or not+ /// (no window is raised or focused for it beyond what the command itself does).+ fn logic(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {+ let mut handled = false;+ while let Ok(inc) = self.commands.try_recv() {+ handled = true;+ match inc.reply {+ Some(reply) => {+ let _ = reply.send(self.answer(&inc.cmd));+ }+ None => self.handle_command(inc.cmd, ctx),+ }+ }+ if handled {+ ctx.request_ui_pass(egui::ViewportId::ROOT);+ }+ }+fn ui(&mut self, ui: &mut Ui, _frame: &mut eframe::Frame) {// The freeze watchdog times every frame (crash.rs).crate::crash::frame_begin();@@ -7033,14 +7056,7 @@ impl eframe::App for App {self.network_adapter_tick(&ctx);self.debrid_tick();dialogs::publish_main_rect(&ctx);- while let Ok(inc) = self.commands.try_recv() {- match inc.reply {- Some(reply) => {- let _ = reply.send(self.answer(&inc.cmd));- }- None => self.handle_command(inc.cmd, &ctx),- }- }+ // Incoming commands: `logic`, just before.self.poll(&ctx);// What failed in any window, told here (dialogs::tell).if let Some((title, text)) = dialogs::told().pop() {diff --git a/crates/app/tests/handoff_hidden.rs b/crates/app/tests/handoff_hidden.rsindex c5495c58..9c2c0f80 100644--- a/crates/app/tests/handoff_hidden.rs+++ b/crates/app/tests/handoff_hidden.rs@@ -1,5 +1,6 @@//! Issue #145: what the browser hands over while the main window is hidden in the notification-//! area. 0.2.4 closed on it ("egui backend is implemented incorrectly - the user callback was+//! area; #162: or minimized (egui ran only the app's logic then, and the commands waited in its+//! UI until the window was restored). 0.2.4 closed on it ("egui backend is implemented incorrectly - the user callback was//! never called"): Add torrent or Download File Info, opened in a pass that ran while no window//! was being drawn, had no event loop to create its window with. The real app, off the screens//! (MDM_OFFSCREEN), with a data folder of its own: hidden with `/show tray`, then handed a magnet@@ -58,16 +59,19 @@ fn second_launch(data: &Path, args: &[&str]) {assert!(status.success(), "second launch {args:?}: {status}");}-#[test]-#[ignore = "opens the app's windows (off-screen): needs OpenGL or Direct3D; run with --ignored"]-fn browser_hand_overs_while_hidden_in_the_tray() {+/// The app, off the screens, with a data folder of its own; `away` puts the main window out of+/// sight (`/show tray` or `/show minimized`) before each hand-over: a magnet link (as Windows+/// starts the program for one) and a download (`/d`, the channel the browser's host uses). Both+/// dialogs must open, and the app must keep running.+fn hand_overs_while(away: &str) {let dir = tempfile::tempdir().unwrap();let data = dir.path();// No update check, no first-start questions; the torrent engine stays on this computer- // (the magnet names no tracker, so its look-up just waits).+ // (the magnet names no tracker, so its look-up just waits). Minimize stays a minimize (not+ // the notification area), for `/show minimized`.let settings = serde_json::json!({"update_check": false, "helpers_asked": true, "language_asked": true,- "extension_never_ask": true,+ "extension_never_ask": true, "minimize_to_tray": false,"torrent_dht": false, "torrent_lsd": false, "torrent_upnp": false,"torrent_incoming": false,});@@ -86,13 +90,13 @@ fn browser_hand_overs_while_hidden_in_the_tray() {let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {wait_for(&mut app, data, "window opened: main", wait);- second_launch(data, &["/show", "tray"]);+ second_launch(data, &["/show", away]);std::thread::sleep(Duration::from_millis(1500));let magnet = "magnet:?xt=urn:btih:5b4f0c3a9e1d27f86c0b3a4e9d1f2a7c6e8b0d14&dn=MDM%20test";second_launch(data, &[magnet]);wait_for(&mut app, data, "window opened: add-torrent", wait);- second_launch(data, &["/show", "tray"]);+ second_launch(data, &["/show", away]);std::thread::sleep(Duration::from_millis(1500));// Port 9 on this computer: nothing answers, and nothing leaves it.second_launch(data, &["/d", "http://127.0.0.1:9/mdm-test-145.zip"]);@@ -117,3 +121,15 @@ fn browser_hand_overs_while_hidden_in_the_tray() {std::panic::resume_unwind(e);}}++#[test]+#[ignore = "opens the app's windows (off-screen): needs OpenGL or Direct3D; run with --ignored"]+fn browser_hand_overs_while_hidden_in_the_tray() {+ hand_overs_while("tray");+}++#[test]+#[ignore = "opens the app's windows (off-screen): needs OpenGL or Direct3D; run with --ignored"]+fn browser_hand_overs_while_minimized() {+ hand_overs_while("minimized");+}