Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.
Play on phone: keep playing when the player is minimized
Bee771c5a19bf59
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0e6978d..b38b4ea 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -60,6 +60,11 @@ change things that need a step from you, and its notes say so.### Fixed- Turning on LocalSend closed the Windows app.+- Play on phone froze on the phone when the player's window was+ minimized, and showed the whole screen when it couldn't find the+ window. A minimized player now goes back behind your other windows and+ keeps playing on the phone; a window it can't find stops Play on phone+ instead of showing your screen.- Browsing the PC's files from the phone showed nothing. It works with**Your PC in your pocket** on, and says what to do when it can't list afolder.diff --git a/desktop/app/i18n/nectarlink_zh_CN.ts b/desktop/app/i18n/nectarlink_zh_CN.tsindex 8109fdf..14abf60 100644--- a/desktop/app/i18n/nectarlink_zh_CN.ts+++ b/desktop/app/i18n/nectarlink_zh_CN.ts@@ -4671,19 +4671,27 @@</message></context><context>- <name>PhoneMic</name>+ <name>PcMirror</name><message><location filename="rust_strings.h" line="282"/>+ <source>Can't find the player's window. Play the video on this PC again, then turn on Play on phone.</source>+ <translation>找不到播放器的窗口。请在此电脑上重新播放视频,然后打开“在手机上播放”。</translation>+ </message>+</context>+<context>+ <name>PhoneMic</name>+ <message>+ <location filename="rust_strings.h" line="283"/><source>Tap Start on %1 to use its microphone.</source><translation>在 %1 上轻触“开始”以使用其麦克风。</translation></message><message>- <location filename="rust_strings.h" line="283"/>+ <location filename="rust_strings.h" line="284"/><source>The microphone is turned off for this PC on %1.</source><translation>%1 上已为此电脑关闭麦克风。</translation></message><message>- <location filename="rust_strings.h" line="284"/>+ <location filename="rust_strings.h" line="285"/><source>Update NectarLink on %1 to use its microphone.</source><translation>请更新 %1 上的 NectarLink 以使用其麦克风。</translation></message>@@ -4691,67 +4699,67 @@<context><name>Photos</name><message>- <location filename="rust_strings.h" line="285"/>+ <location filename="rust_strings.h" line="286"/><source>Copied to clipboard.</source><translation>已复制到剪贴板。</translation></message><message>- <location filename="rust_strings.h" line="286"/>+ <location filename="rust_strings.h" line="287"/><source>From %1</source><translation>来自 %1</translation></message><message>- <location filename="rust_strings.h" line="287"/>+ <location filename="rust_strings.h" line="288"/><source>New photo</source><translation>新照片</translation></message><message>- <location filename="rust_strings.h" line="288"/>+ <location filename="rust_strings.h" line="289"/><source>New screenshot</source><translation>新截图</translation></message><message>- <location filename="rust_strings.h" line="289"/>+ <location filename="rust_strings.h" line="290"/><source>No recent photos found on the phone.</source><translation>手机上没有最近的照片。</translation></message><message>- <location filename="rust_strings.h" line="290"/>+ <location filename="rust_strings.h" line="291"/><source>Opening latest photo…</source><translation>正在打开最新照片…</translation></message><message>- <location filename="rust_strings.h" line="291"/>+ <location filename="rust_strings.h" line="292"/><source>Saved %1 items to %2.</source><translation>已将 %1 个项目保存到 %2。</translation></message><message>- <location filename="rust_strings.h" line="292"/>+ <location filename="rust_strings.h" line="293"/><source>Saved %1 to %2.</source><translation>已将 %1 保存到 %2。</translation></message><message>- <location filename="rust_strings.h" line="293"/>+ <location filename="rust_strings.h" line="294"/><source>That photo isn't on the phone anymore.</source><translation>该照片已不在手机上。</translation></message><message>- <location filename="rust_strings.h" line="294"/>+ <location filename="rust_strings.h" line="295"/><source>The phone doesn't share photos or files with this PC.</source><translation>手机未与此电脑共享照片或文件。</translation></message><message>- <location filename="rust_strings.h" line="295"/>+ <location filename="rust_strings.h" line="296"/><source>The phone isn't connected right now.</source><translation>手机当前未连接。</translation></message><message>- <location filename="rust_strings.h" line="296"/>+ <location filename="rust_strings.h" line="297"/><source>The photo couldn't be copied to the clipboard.</source><translation>无法将照片复制到剪贴板。</translation></message><message>- <location filename="rust_strings.h" line="297"/>+ <location filename="rust_strings.h" line="298"/><source>The photo couldn't be copied. It's in Downloads\Nectarlink.</source><translation>无法复制照片。它在 Downloads\Nectarlink 中。</translation></message>@@ -5031,32 +5039,32 @@<context><name>PlayOnPhone</name><message>- <location filename="rust_strings.h" line="298"/>+ <location filename="rust_strings.h" line="299"/><source>Connect your phone to play on it.</source><translation>请连接手机后再在其上播放。</translation></message><message>- <location filename="rust_strings.h" line="299"/>+ <location filename="rust_strings.h" line="300"/><source>Media is turned off for %1.</source><translation>已为 %1 关闭媒体。</translation></message><message>- <location filename="rust_strings.h" line="300"/>+ <location filename="rust_strings.h" line="301"/><source>Opening in %1 on %2. Tap the notification there.</source><translation>正在 %2 上用 %1 打开。请轻触那里的通知。</translation></message><message>- <location filename="rust_strings.h" line="301"/>+ <location filename="rust_strings.h" line="302"/><source>Sent to %1. Tap the notification there.</source><translation>已发送到 %1。请轻触那里的通知。</translation></message><message>- <location filename="rust_strings.h" line="302"/>+ <location filename="rust_strings.h" line="303"/><source>Tap the notification on %1 to watch.</source><translation>轻触 %1 上的通知即可观看。</translation></message><message>- <location filename="rust_strings.h" line="303"/>+ <location filename="rust_strings.h" line="304"/><source>Update NectarLink on %1 to play on it.</source><translation>请更新 %1 上的 NectarLink 以在其上播放。</translation></message>@@ -5064,7 +5072,7 @@<context><name>Prefs</name><message>- <location filename="rust_strings.h" line="304"/>+ <location filename="rust_strings.h" line="305"/><source>Connected to OBS.</source><translation>已连接到 OBS。</translation></message>@@ -5072,7 +5080,7 @@<context><name>Recordings</name><message>- <location filename="rust_strings.h" line="305"/>+ <location filename="rust_strings.h" line="306"/><source>Recording from %1 saved</source><translation>已保存来自 %1 的录音</translation></message>@@ -5088,57 +5096,57 @@<context><name>SendTo</name><message>- <location filename="rust_strings.h" line="306"/>+ <location filename="rust_strings.h" line="307"/><source>Copied to your phone's clipboard.</source><translation>已复制到手机的剪贴板。</translation></message><message>- <location filename="rust_strings.h" line="307"/>+ <location filename="rust_strings.h" line="308"/><source>Couldn't reach %1.</source><translation>无法连接 %1。</translation></message><message>- <location filename="rust_strings.h" line="308"/>+ <location filename="rust_strings.h" line="309"/><source>Couldn't send %1</source><translation>无法发送 %1</translation></message><message>- <location filename="rust_strings.h" line="309"/>+ <location filename="rust_strings.h" line="310"/><source>Couldn't send to %1</source><translation>无法发送到 %1</translation></message><message>- <location filename="rust_strings.h" line="310"/>+ <location filename="rust_strings.h" line="311"/><source>Couldn't share with %1</source><translation>无法与 %1 共享</translation></message><message>- <location filename="rust_strings.h" line="311"/>+ <location filename="rust_strings.h" line="312"/><source>File failed integrity check; partial file kept to resume.</source><translation>文件未通过完整性校验;已保留部分文件以便继续。</translation></message><message>- <location filename="rust_strings.h" line="312"/>+ <location filename="rust_strings.h" line="313"/><source>Send to %1 with NectarLink</source><translation>用 NectarLink 发送到 %1</translation></message><message>- <location filename="rust_strings.h" line="313"/>+ <location filename="rust_strings.h" line="314"/><source>Sending to %1…</source><translation>正在发送到 %1…</translation></message><message>- <location filename="rust_strings.h" line="314"/>+ <location filename="rust_strings.h" line="315"/><source>Sent to %1</source><translation>已发送到 %1</translation></message><message>- <location filename="rust_strings.h" line="315"/>+ <location filename="rust_strings.h" line="316"/><source>The transfer didn't go through.</source><translation>传输未完成。</translation></message><message>- <location filename="rust_strings.h" line="316"/>+ <location filename="rust_strings.h" line="317"/><source>Waiting for %1…</source><translation>正在等待 %1…</translation></message>@@ -6504,22 +6512,22 @@<context><name>Setup</name><message>- <location filename="rust_strings.h" line="317"/>+ <location filename="rust_strings.h" line="318"/><source>Couldn't start setup: %1</source><translation>无法启动安装程序:%1</translation></message><message>- <location filename="rust_strings.h" line="318"/>+ <location filename="rust_strings.h" line="319"/><source>Setup is taking too long. Try again after restarting the PC.</source><translation>安装时间过长。请重启电脑后再试。</translation></message><message>- <location filename="rust_strings.h" line="319"/>+ <location filename="rust_strings.h" line="320"/><source>Setup stopped with code %1.</source><translation>安装已停止,代码 %1。</translation></message><message>- <location filename="rust_strings.h" line="320"/>+ <location filename="rust_strings.h" line="321"/><source>The uninstaller is missing. Reinstall NectarLink, then uninstall it.</source><translation>缺少卸载程序。请重新安装 NectarLink,然后再卸载。</translation></message>@@ -6889,97 +6897,97 @@<context><name>Timeline</name><message>- <location filename="rust_strings.h" line="321"/>+ <location filename="rust_strings.h" line="322"/><source>Clip (removed from clipboard history)</source><translation>剪贴内容(已从剪贴板历史中删除)</translation></message><message>- <location filename="rust_strings.h" line="322"/>+ <location filename="rust_strings.h" line="323"/><source>Copied image</source><translation>已复制的图片</translation></message><message>- <location filename="rust_strings.h" line="323"/>+ <location filename="rust_strings.h" line="324"/><source>Copied link to clipboard.</source><translation>已将链接复制到剪贴板。</translation></message><message>- <location filename="rust_strings.h" line="324"/>+ <location filename="rust_strings.h" line="325"/><source>Copied to clipboard.</source><translation>已复制到剪贴板。</translation></message><message>- <location filename="rust_strings.h" line="325"/>+ <location filename="rust_strings.h" line="326"/><source>In progress</source><translation>进行中</translation></message><message>- <location filename="rust_strings.h" line="326"/>+ <location filename="rust_strings.h" line="327"/><source>No phone is paired yet.</source><translation>尚未配对手机。</translation></message><message>- <location filename="rust_strings.h" line="327"/>+ <location filename="rust_strings.h" line="328"/><source>Phone microphone</source><translation>手机麦克风</translation></message><message>- <location filename="rust_strings.h" line="328"/>+ <location filename="rust_strings.h" line="329"/><source>Phone webcam</source><translation>手机摄像头</translation></message><message>- <location filename="rust_strings.h" line="329"/>+ <location filename="rust_strings.h" line="330"/><source>Screen mirroring</source><translation>屏幕镜像</translation></message><message>- <location filename="rust_strings.h" line="330"/>+ <location filename="rust_strings.h" line="331"/><source>Sending to %1…</source><translation>正在发送到 %1…</translation></message><message>- <location filename="rust_strings.h" line="331"/>+ <location filename="rust_strings.h" line="332"/><source>Sent clip to %1.</source><translation>已将剪贴内容发送到 %1。</translation></message><message>- <location filename="rust_strings.h" line="332"/>+ <location filename="rust_strings.h" line="333"/><source>That clip is no longer in clipboard history.</source><translation>该剪贴内容已不在剪贴板历史中。</translation></message><message>- <location filename="rust_strings.h" line="333"/>+ <location filename="rust_strings.h" line="334"/><source>That entry couldn't be removed. Try again.</source><translation>无法删除该条目,请重试。</translation></message><message>- <location filename="rust_strings.h" line="334"/>+ <location filename="rust_strings.h" line="335"/><source>That file was moved or deleted.</source><translation>该文件已被移动或删除。</translation></message><message>- <location filename="rust_strings.h" line="335"/>+ <location filename="rust_strings.h" line="336"/><source>That isn't a web link.</source><translation>这不是网页链接。</translation></message><message>- <location filename="rust_strings.h" line="336"/>+ <location filename="rust_strings.h" line="337"/><source>That photo was moved or deleted.</source><translation>该照片已被移动或删除。</translation></message><message>- <location filename="rust_strings.h" line="337"/>+ <location filename="rust_strings.h" line="338"/><source>The Timeline couldn't be cleared. Try again.</source><translation>无法清除时间线,请重试。</translation></message><message>- <location filename="rust_strings.h" line="338"/>+ <location filename="rust_strings.h" line="339"/><source>The photo couldn't be copied to the clipboard.</source><translation>无法将照片复制到剪贴板。</translation></message><message>- <location filename="rust_strings.h" line="339"/>+ <location filename="rust_strings.h" line="340"/><source>Voice recording</source><translation>录音</translation></message>@@ -7271,37 +7279,37 @@<context><name>Transfers</name><message>- <location filename="rust_strings.h" line="340"/>+ <location filename="rust_strings.h" line="341"/><source>Accept in NectarLink to save to Downloads\Nectarlink</source><translation>在 NectarLink 中接受即可保存到 Downloads\Nectarlink</translation></message><message>- <location filename="rust_strings.h" line="341"/>+ <location filename="rust_strings.h" line="342"/><source>Files are turned off for that device.</source><translation>已为该设备关闭文件。</translation></message><message>- <location filename="rust_strings.h" line="342"/>+ <location filename="rust_strings.h" line="343"/><source>From %1, opened from Downloads\Nectarlink</source><translation>来自 %1,已从 Downloads\Nectarlink 打开</translation></message><message>- <location filename="rust_strings.h" line="343"/>+ <location filename="rust_strings.h" line="344"/><source>From %1, saved in Downloads\Nectarlink</source><translation>来自 %1,已保存到 Downloads\Nectarlink</translation></message><message>- <location filename="rust_strings.h" line="344"/>+ <location filename="rust_strings.h" line="345"/><source>Nearby device</source><translation>附近的设备</translation></message><message>- <location filename="rust_strings.h" line="345"/>+ <location filename="rust_strings.h" line="346"/><source>That's too many files to send at once.</source><translation>文件太多,无法一次发送。</translation></message><message>- <location filename="rust_strings.h" line="346"/>+ <location filename="rust_strings.h" line="347"/><source>There's nothing to send in there.</source><translation>那里没有可发送的内容。</translation></message>@@ -7309,67 +7317,67 @@<context><name>Updater</name><message>- <location filename="rust_strings.h" line="347"/>+ <location filename="rust_strings.h" line="348"/><source>Couldn't check for updates. Check your internet connection.</source><translation>无法检查更新。请检查网络连接。</translation></message><message>- <location filename="rust_strings.h" line="348"/>+ <location filename="rust_strings.h" line="349"/><source>NectarLink %1 is available</source><translation>NectarLink %1 已发布</translation></message><message>- <location filename="rust_strings.h" line="349"/>+ <location filename="rust_strings.h" line="350"/><source>NectarLink %1 is available.</source><translation>NectarLink %1 已发布。</translation></message><message>- <location filename="rust_strings.h" line="350"/>+ <location filename="rust_strings.h" line="351"/><source>NectarLink is still on the version you had. Try again from Settings.</source><translation>NectarLink 仍是原来的版本。请在设置中重试。</translation></message><message>- <location filename="rust_strings.h" line="351"/>+ <location filename="rust_strings.h" line="352"/><source>NectarLink is up to date.</source><translation>NectarLink 已是最新版本。</translation></message><message>- <location filename="rust_strings.h" line="352"/>+ <location filename="rust_strings.h" line="353"/><source>NectarLink is updated to %1</source><translation>NectarLink 已更新到 %1</translation></message><message>- <location filename="rust_strings.h" line="353"/>+ <location filename="rust_strings.h" line="354"/><source>The download was damaged, so it wasn't installed. Try again.</source><translation>下载的文件已损坏,因此未安装。请重试。</translation></message><message>- <location filename="rust_strings.h" line="354"/>+ <location filename="rust_strings.h" line="355"/><source>The update couldn't be downloaded. Check your internet connection and try again.</source><translation>无法下载更新。请检查网络连接后重试。</translation></message><message>- <location filename="rust_strings.h" line="355"/>+ <location filename="rust_strings.h" line="356"/><source>The update couldn't be saved. Check that there's free space and try again.</source><translation>无法保存更新。请确认有足够的空间后重试。</translation></message><message>- <location filename="rust_strings.h" line="356"/>+ <location filename="rust_strings.h" line="357"/><source>The update couldn't be started. Try again.</source><translation>无法启动更新。请重试。</translation></message><message>- <location filename="rust_strings.h" line="357"/>+ <location filename="rust_strings.h" line="358"/><source>The update didn't install</source><translation>更新未安装</translation></message><message>- <location filename="rust_strings.h" line="358"/>+ <location filename="rust_strings.h" line="359"/><source>Update now, or later from Settings.</source><translation>立即更新,或稍后在设置中更新。</translation></message><message>- <location filename="rust_strings.h" line="359"/>+ <location filename="rust_strings.h" line="360"/><source>Your phone reconnects on its own.</source><translation>手机会自动重新连接。</translation></message>@@ -7569,12 +7577,12 @@<context><name>Webcam</name><message>- <location filename="rust_strings.h" line="360"/>+ <location filename="rust_strings.h" line="361"/><source>Starting camera on %1…</source><translation>正在启动 %1 上的相机…</translation></message><message>- <location filename="rust_strings.h" line="361"/>+ <location filename="rust_strings.h" line="362"/><source>Streaming %1 × %2 · %3 fps from %4</source><translation>正在从 %4 传输 %1 × %2 · %3 fps</translation></message>@@ -7605,17 +7613,17 @@<context><name>Widget</name><message>- <location filename="rust_strings.h" line="362"/>+ <location filename="rust_strings.h" line="363"/><source>No phone connected</source><translation>未连接手机</translation></message><message>- <location filename="rust_strings.h" line="363"/>+ <location filename="rust_strings.h" line="364"/><source>No recent clipboard items</source><translation>没有最近的剪贴板内容</translation></message><message>- <location filename="rust_strings.h" line="364"/>+ <location filename="rust_strings.h" line="365"/><source>Not available</source><translation>不可用</translation></message>diff --git a/desktop/app/i18n/rust_strings.h b/desktop/app/i18n/rust_strings.hindex f1a2712..e687479 100644--- a/desktop/app/i18n/rust_strings.h+++ b/desktop/app/i18n/rust_strings.h@@ -279,6 +279,7 @@ static const char *const nectarlink_rust_strings[] = {QT_TRANSLATE_NOOP("Obs", "OBS isn't reachable on port %1. Turn on its WebSocket server."), // desktop/app/src/obs.rsQT_TRANSLATE_NOOP("Obs", "OBS: %1"), // desktop/app/src/obs.rsQT_TRANSLATE_NOOP("Obs", "The service on that port isn't OBS."), // desktop/app/src/obs.rs+ QT_TRANSLATE_NOOP("PcMirror", "Can't find the player's window. Play the video on this PC again, then turn on Play on phone."), // desktop/app/src/pc_mirror.rsQT_TRANSLATE_NOOP("PhoneMic", "Tap Start on %1 to use its microphone."), // desktop/app/src/phone_mic.rsQT_TRANSLATE_NOOP("PhoneMic", "The microphone is turned off for this PC on %1."), // desktop/app/src/phone_mic.rsQT_TRANSLATE_NOOP("PhoneMic", "Update NectarLink on %1 to use its microphone."), // desktop/app/src/phone_mic.rsdiff --git a/desktop/app/src/pc_mirror.rs b/desktop/app/src/pc_mirror.rsindex 4e729ce..d6f7f6c 100644--- a/desktop/app/src/pc_mirror.rs+++ b/desktop/app/src/pc_mirror.rs@@ -707,7 +707,6 @@ fn run_capture_loop(}let watched = options.watch.as_deref().map(crate::play_on_phone::Watched::follow);let mut window_capture: Option<win::window_capture::WindowCapture> = None;- let mut fell_back = false;let _sound = watched.is_some().then(|| SoundToPhone::start(peer));if watched.is_some() {tracing::info!(%peer, fps, bitrate, "streaming a player to the phone");@@ -724,11 +723,15 @@ fn run_capture_loop(std::thread::sleep(frame_interval);continue;}- if watched.is_some() && place.is_none() && !fell_back {- // The player's window can't be found: the phone gets the screen- // rather than nothing.- tracing::info!(%peer, "can't find the player's window; streaming the screen");- fell_back = true;+ if watched.is_some() && place.is_none() {+ // The player's window can't be found. Not the screen instead:+ // that would show the phone whatever else is on it.+ tracing::info!(%peer, "can't find the player's window; stopping");+ crate::bridge::app::show_message(crate::i18n::tr!(+ "PcMirror",+ "Can't find the player's window. Play the video on this PC again, then turn on Play on phone."+ ));+ break;}if let Some(place) = place {let r = place.on_screen;diff --git a/desktop/app/src/play_on_phone.rs b/desktop/app/src/play_on_phone.rsindex 1c72143..55fd756 100644--- a/desktop/app/src/play_on_phone.rs+++ b/desktop/app/src/play_on_phone.rs@@ -278,6 +278,16 @@ impl Watched {let (title, _) = now_playing(&player);window = browser::window_for(&player, &title);}+ // Minimized, it draws nothing and the phone's picture stops:+ // back behind the other windows, it plays on out of the way.+ if let Some(w) = window.as_ref().filter(|w| browser::is_minimized(w.hwnd)) {+ tracing::info!(+ "the watched player's window was minimized; restoring it behind the others"+ );+ browser::restore_behind(w.hwnd);+ std::thread::sleep(FOLLOW_EVERY);+ continue;+ }let place = window.as_ref().and_then(|w| {let frame = browser::frame_of(w.hwnd)?;let on_screen = match &automation {diff --git a/desktop/app/src/win/browser.rs b/desktop/app/src/win/browser.rsindex e91e903..2115a56 100644--- a/desktop/app/src/win/browser.rs+++ b/desktop/app/src/win/browser.rs@@ -31,8 +31,9 @@ use windows::{},HiDpi::{DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, SetThreadDpiAwarenessContext},WindowsAndMessaging::{- EnumWindows, GW_OWNER, GetWindow, GetWindowTextW, GetWindowThreadProcessId, IsIconic,- IsWindowVisible,+ EnumWindows, GW_OWNER, GetWindow, GetWindowTextW, GetWindowThreadProcessId, HWND_BOTTOM,+ IsIconic, IsWindowVisible, SW_SHOWNOACTIVATE, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOSIZE,+ SetWindowPos, ShowWindow,},},},@@ -108,6 +109,15 @@ pub struct Window {/// The visible, uncloaked top-level windows that aren't minimized, front/// to back.pub fn windows() -> Vec<Window> {+ listed(false)+}++/// As [`windows`], with minimized ones too: a minimized player still plays.+fn windows_and_minimized() -> Vec<Window> {+ listed(true)+}++fn listed(minimized: bool) -> Vec<Window> {unsafe extern "system" fn each(hwnd: HWND, found: LPARAM) -> BOOL {// SAFETY: `found` is the Vec passed to EnumWindows below, alive for the call.let found = unsafe { &mut *(found.0 as *mut Vec<HWND>) };@@ -119,15 +129,15 @@ pub fn windows() -> Vec<Window> {let _ = unsafe { EnumWindows(Some(each), LPARAM(&mut handles as *mut Vec<HWND> as isize)) };handles.into_iter()- .filter(|&hwnd| shown(hwnd))+ .filter(|&hwnd| shown(hwnd, minimized)).filter_map(|hwnd| Some(Window { hwnd, program: program_of(hwnd)?, title: title_of(hwnd) })).collect()}-fn shown(hwnd: HWND) -> bool {+fn shown(hwnd: HWND, minimized: bool) -> bool {// SAFETY: plain queries on a window handle (a stale one just fails).unsafe {- if !IsWindowVisible(hwnd).as_bool() || IsIconic(hwnd).as_bool() {+ if !IsWindowVisible(hwnd).as_bool() || (!minimized && IsIconic(hwnd).as_bool()) {return false;}if GetWindow(hwnd, GW_OWNER).is_ok_and(|owner| !owner.is_invalid()) {@@ -177,7 +187,7 @@ fn program_of(hwnd: HWND) -> Option<String> {/// browser's shows its active tab's), or its only window.pub fn window_for(player: &str, title: &str) -> Option<Window> {let programs = programs_for(player);- let all = windows();+ let all = windows_and_minimized();let candidates: Vec<Window> = all.iter().filter(|w| programs.contains(&w.program)).cloned().collect();pick(candidates, title).or_else(|| by_title(all, title))}@@ -300,6 +310,23 @@ impl Automation {}/// A window's frame on screen, without its invisible resize borders.+/// Whether `hwnd` is minimized: Windows draws nothing of it then, so a+/// capture of it stays on its last picture.+pub fn is_minimized(hwnd: HWND) -> bool {+ // SAFETY: a plain query on a window handle.+ unsafe { IsIconic(hwnd).as_bool() }+}++/// Restores a minimized window behind every other one, without bringing it+/// forward or taking the focus: it draws again, out of the way.+pub fn restore_behind(hwnd: HWND) {+ // SAFETY: plain window calls on a handle (a stale one just fails).+ unsafe {+ let _ = ShowWindow(hwnd, SW_SHOWNOACTIVATE);+ let _ = SetWindowPos(hwnd, Some(HWND_BOTTOM), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);+ }+}+pub fn frame_of(hwnd: HWND) -> Option<RECT> {let mut rect = RECT::default();// SAFETY: writes one RECT.