diff --git a/release/0.1.10/RELEASE_NOTES.md b/release/0.1.10/RELEASE_NOTES.md index 679781b..51b5e75 100644 --- a/release/0.1.10/RELEASE_NOTES.md +++ b/release/0.1.10/RELEASE_NOTES.md @@ -21,9 +21,8 @@ Squid 0.1.10 更新说明 开着时 Squid 全家 CPU 占用接近 0%。 调整 -- 桌面小工具现在真正「常驻」:小工具窗口挂入系统桌面(Progman)窗口, - Win+D / 任务栏「显示桌面」不会再把它最小化隐藏(同 Wallpaper Engine - 的做法);explorer 重启后 5 秒内自动归位。仍处于桌面层:在壁纸与图标 - 之上、其他软件窗口之下。 +- 桌面小工具 Win+D 常驻:按下「显示桌面」后小工具约 2 秒内自动回到桌面 + (窗口保持桌面层:在壁纸与图标之上、其他软件窗口之下;自己关闭/折叠 + 不会把它叫回来)。 - Windows 上所有「废纸篓」文案改为「回收站」(清理、卸载、历史、设置等随系统 名称联动);macOS 仍为「废纸篓」。 diff --git a/release/0.1.10/SHA256SUMS.txt b/release/0.1.10/SHA256SUMS.txt index a88a5da..45db0f2 100644 --- a/release/0.1.10/SHA256SUMS.txt +++ b/release/0.1.10/SHA256SUMS.txt @@ -1,2 +1,2 @@ -9d008dbc0bf671d08b5f1fe801a4b2d9e588a4bb656b49061860eeb4840bf9a9 *Squid-Setup-0.1.10-win-x64.exe -a8f548aaa218868fb127006ca518c79741480d9b742d71ca978e7be688d83e9e *Squid-0.1.10-portable-win-x64.zip +6a6c33699a61320d3f0d13a36df50228c00a2cb790ef84d4dd7d2ba704b49dbc *Squid-Setup-0.1.10-win-x64.exe +fa7b9bf6dbf466853c38472664f4f65874471aace03f3b9381baf25939a5f580 *Squid-0.1.10-portable-win-x64.zip diff --git a/release/0.1.10/Squid-Setup-0.1.10-win-x64.exe b/release/0.1.10/Squid-Setup-0.1.10-win-x64.exe index 4a02c84..7c2ace4 100644 Binary files a/release/0.1.10/Squid-Setup-0.1.10-win-x64.exe and b/release/0.1.10/Squid-Setup-0.1.10-win-x64.exe differ diff --git a/release/0.1.10/squid-update.json b/release/0.1.10/squid-update.json index 30bbf33..e322709 100644 --- a/release/0.1.10/squid-update.json +++ b/release/0.1.10/squid-update.json @@ -2,12 +2,12 @@ "schema": 1, "version": "0.1.10", "date": "2026-11-19", - "notes": "Squid 0.1.10\n\n新增\n- 清理新增「升级安装包」分类:找出应用升级完成后留在 AppData 里的安装包\n (微信、企业微信、WPS、网易邮箱等已知应用精确规则 + AppData 启发式扫描)。\n 只匹配安装包形态(exe/msi/zip/7z 等)且放置超过 7 天的文件,微信运行库组件\n 不会被误删;应用正在运行时相关安装包自动锁定。删除确认时会提示升级包数量\n 与大小,可一键「跳过升级包,只删其余」。\n- 桌面小工具新增「CPU」面板:总体占用率历史曲线 + 整行渐变占用柱,一根柱对应\n 一个逻辑核心;柱色随占用率在绿→黄→橙→红之间连续渐变(含柱内纵向微渐变),\n 悬停显示「核心 N: xx%」(编号与任务管理器一致从 0 开始);核心较多时柱宽自动\n 收窄。管理页与桌面设置弹层可独立开关该面板。\n\n优化\n- 桌面常驻 CPU 占用大幅下降(实测本机构从约 8.5% 全机总占用降至 0.2%):\n 小工具改用轻量采样(跳过全机逐进程枚举,那是旧版每秒最贵的一步)、两个\n 窗口共享同一次采样、小工具折叠或主窗口收进托盘后完全停止采样。实时监控\n 页打开时才有完整进程表,功能不受影响。\n- 修复小工具窗口自身的自适应尺寸回环(尺寸→重锚定→再触发自适应无限循环),\n 该回环会让主进程与小工具渲染进程空转互叫并频繁写配置文件;修复后小工具\n 开着时 Squid 全家 CPU 占用接近 0%。\n\n调整\n- 桌面小工具现在真正「常驻」:小工具窗口挂入系统桌面(Progman)窗口,\n Win+D / 任务栏「显示桌面」不会再把它最小化隐藏(同 Wallpaper Engine\n 的做法);explorer 重启后 5 秒内自动归位。仍处于桌面层:在壁纸与图标\n 之上、其他软件窗口之下。\n- Windows 上所有「废纸篓」文案改为「回收站」(清理、卸载、历史、设置等随系统\n 名称联动);macOS 仍为「废纸篓」。", + "notes": "Squid 0.1.10\n\n新增\n- 清理新增「升级安装包」分类:找出应用升级完成后留在 AppData 里的安装包\n (微信、企业微信、WPS、网易邮箱等已知应用精确规则 + AppData 启发式扫描)。\n 只匹配安装包形态(exe/msi/zip/7z 等)且放置超过 7 天的文件,微信运行库组件\n 不会被误删;应用正在运行时相关安装包自动锁定。删除确认时会提示升级包数量\n 与大小,可一键「跳过升级包,只删其余」。\n- 桌面小工具新增「CPU」面板:总体占用率历史曲线 + 整行渐变占用柱,一根柱对应\n 一个逻辑核心;柱色随占用率在绿→黄→橙→红之间连续渐变(含柱内纵向微渐变),\n 悬停显示「核心 N: xx%」(编号与任务管理器一致从 0 开始);核心较多时柱宽自动\n 收窄。管理页与桌面设置弹层可独立开关该面板。\n\n优化\n- 桌面常驻 CPU 占用大幅下降(实测本机构从约 8.5% 全机总占用降至 0.2%):\n 小工具改用轻量采样(跳过全机逐进程枚举,那是旧版每秒最贵的一步)、两个\n 窗口共享同一次采样、小工具折叠或主窗口收进托盘后完全停止采样。实时监控\n 页打开时才有完整进程表,功能不受影响。\n- 修复小工具窗口自身的自适应尺寸回环(尺寸→重锚定→再触发自适应无限循环),\n 该回环会让主进程与小工具渲染进程空转互叫并频繁写配置文件;修复后小工具\n 开着时 Squid 全家 CPU 占用接近 0%。\n\n调整\n- 桌面小工具 Win+D 常驻:按下「显示桌面」后小工具约 2 秒内自动回到桌面\n (窗口保持桌面层:在壁纸与图标之上、其他软件窗口之下;自己关闭/折叠\n 不会把它叫回来)。\n- Windows 上所有「废纸篓」文案改为「回收站」(清理、卸载、历史、设置等随系统\n 名称联动);macOS 仍为「废纸篓」。", "artifacts": { "windows": { "file": "Squid-Setup-0.1.10-win-x64.exe", - "sha256": "9d008dbc0bf671d08b5f1fe801a4b2d9e588a4bb656b49061860eeb4840bf9a9", - "size": 3572815 + "sha256": "6a6c33699a61320d3f0d13a36df50228c00a2cb790ef84d4dd7d2ba704b49dbc", + "size": 3570502 } } } \ No newline at end of file diff --git a/src-tauri/src/widget.rs b/src-tauri/src/widget.rs index db75234..6d483f0 100644 --- a/src-tauri/src/widget.rs +++ b/src-tauri/src/widget.rs @@ -16,28 +16,25 @@ use tauri::{AppHandle, Emitter, Manager, WebviewUrl, WebviewWindowBuilder}; pub const WIDGET_LABEL: &str = "widget"; -/// Desktop residency (Windows). Two stacked tricks: -/// -/// 1. *Adoption*: re-parent the widget into `Progman`, the shell's desktop -/// window. Win+D ("Show desktop") minimises top-level application windows -/// only, and a child of Progman is not one — the widget survives it -/// (Wallpaper Engine / Rainmeter use the same technique). Inside Progman -/// we ask for the top of the child stack: still under every ordinary app -/// window, now above the desktop icons. -/// 2. *Fallback*: if adoption is unavailable, park the window at -/// `HWND_BOTTOM` with no-activate flags so it at least lives on the -/// desktop layer (above wallpaper and icons, below app windows). +/// Desktop residency (Windows). The widget is a borderless top-level window +/// parked at `HWND_BOTTOM`: above the wallpaper and icons, below every +/// ordinary app window. Pulsar dodges Win+D by living *inside* the taskbar +/// (SetParent into Shell_TrayWnd — the bar is immune to Show Desktop, and a +/// watchdog re-attaches when the parent drifts). The WebView2 widget cannot +/// be re-parented into the desktop tree like Pulsar's raw window: on this +/// machine the shell ejects it again within seconds, and every crossing +/// strands or hides the web content. So we keep Pulsar's *watchdog* idea +/// instead of its parent trick: the shell hides top-level windows on Win+D +/// by minimising or DWM-cloaking them, and a 1.5 s heartbeat puts any +/// shell-hidden-but-wanted widget back (unminimise → show uncloaks → re-park +/// on the desktop layer → one repaint). Ways the app hid the panel itself +/// (master switch off, all panels off, folded away via hide) are respected. #[cfg(windows)] mod desktop_layer { use std::ffi::c_void; - use std::ptr; #[link(name = "user32")] extern "system" { - fn FindWindowW(class: *const u16, window: *const u16) -> *mut c_void; - fn SetParent(child: *mut c_void, new_parent: *mut c_void) -> *mut c_void; - fn GetParent(child: *mut c_void) -> *mut c_void; - fn IsWindow(handle: *mut c_void) -> i32; fn SetWindowPos( hwnd: *mut c_void, insert_after: *mut c_void, @@ -47,51 +44,23 @@ mod desktop_layer { cy: i32, flags: u32, ) -> i32; + fn IsIconic(hwnd: *mut c_void) -> i32; + fn IsWindowVisible(hwnd: *mut c_void) -> i32; + } + #[link(name = "dwmapi")] + extern "system" { + fn DwmGetWindowAttribute( + hwnd: *mut c_void, + attribute: u32, + value: *mut i32, + size: u32, + ) -> i32; } const HWND_BOTTOM: *mut c_void = 1usize as *mut c_void; - const HWND_TOP: *mut c_void = ptr::null_mut(); - const SWP_NOSIZE: u32 = 0x0001; const SWP_NOMOVE: u32 = 0x0002; + const SWP_NOSIZE: u32 = 0x0001; const SWP_NOACTIVATE: u32 = 0x0010; - // L"Progman" - const PROGMAN: &[u16] = &[80, 114, 111, 103, 109, 97, 110, 0]; - - fn progman() -> *mut c_void { - // SAFETY: FindWindowW reads only the null-terminated literal above. - unsafe { FindWindowW(PROGMAN.as_ptr(), ptr::null()) } - } - - /// Move `hwnd` under Progman (top of its child stack, no focus steal). - /// Idempotent; returns false when there is no desktop to adopt into. - pub fn adopt(hwnd: *mut c_void) -> bool { - let parent = progman(); - if parent.is_null() || hwnd.is_null() || unsafe { IsWindow(hwnd) } == 0 { - return false; - } - if unsafe { GetParent(hwnd) } != parent { - // SAFETY: both handles are live (IsWindow checked above). - unsafe { SetParent(hwnd, parent) }; - } - // SAFETY: NOMOVE|NOSIZE|NOACTIVATE only re-stacks the child order. - unsafe { - SetWindowPos( - hwnd, - HWND_TOP, - 0, - 0, - 0, - 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE, - ); - } - true - } - - /// Whether `hwnd` currently lives under Progman (watchdog probe). - pub fn adopted(hwnd: *mut c_void) -> bool { - let parent = progman(); - !parent.is_null() && unsafe { GetParent(hwnd) } == parent - } + const DWMWA_CLOAKED: u32 = 14; pub fn lower(hwnd: *mut c_void) { // SAFETY: hwnd comes from Tauri's own window handle; SetWindowPos with @@ -108,11 +77,38 @@ mod desktop_layer { ); } } + + /// Whether the shell (Win+D / 显示桌面) currently has this window put + /// away while we want it shown: minimised, DWM-cloaked, or plain hidden. + /// `minimised_or_cloaked` refines the answer for callers that only want + /// to force a repaint when the shell *actively* took the window down + /// (a window still hidden mid-startup just needs showing, not reloading). + pub fn shell_hidden(hwnd: *mut c_void, minimised_or_cloaked: &mut bool) -> bool { + // SAFETY: plain queries on a live handle. + *minimised_or_cloaked = unsafe { IsIconic(hwnd) != 0 }; + if *minimised_or_cloaked { + return true; + } + let mut cloaked = 0i32; + unsafe { + DwmGetWindowAttribute( + hwnd, + DWMWA_CLOAKED, + &mut cloaked, + std::mem::size_of::() as u32, + ); + } + if cloaked != 0 { + *minimised_or_cloaked = true; + return true; + } + unsafe { IsWindowVisible(hwnd) == 0 } + } } -/// Keep the widget on the desktop: adopt into Progman where possible (Win+D -/// proof), otherwise park at the bottom of the z-order. macOS/Linux keep the -/// plain floating behaviour (the widget story is Windows-first). +/// Park the widget at the bottom of the window stack (desktop layer). +/// macOS/Linux keep plain floating behaviour for now (no equivalent need: +/// the widget story is Windows-first). pub fn lower_window(app: &AppHandle) { #[cfg(windows)] { @@ -120,10 +116,7 @@ pub fn lower_window(app: &AppHandle) { return; }; if let Ok(hwnd) = window.hwnd() { - let hwnd = hwnd.0.cast(); - if !desktop_layer::adopt(hwnd) { - desktop_layer::lower(hwnd); - } + desktop_layer::lower(hwnd.0.cast()); } } #[cfg(not(windows))] @@ -132,24 +125,48 @@ pub fn lower_window(app: &AppHandle) { } } -/// explorer.exe can recreate its desktop window while Squid runs; the shell -/// may also re-stack Progman's children. A slow heartbeat re-adopts a widget -/// that fell out, so 常驻 stays true without user action. +/// Win+D proof, Pulsar-style heartbeat: if the shell put the wanted widget +/// away, bring it back within a beat and repaint it once (the transparent +/// webview can stay blank after a cloak round-trip). #[cfg(windows)] pub fn spawn_desktop_watch(app: &AppHandle) { let app = app.clone(); std::thread::spawn(move || loop { - std::thread::sleep(std::time::Duration::from_secs(5)); + std::thread::sleep(std::time::Duration::from_millis(1_500)); + let Some(state) = app.try_state::() else { + continue; + }; + let prefs = state.current(); + // A panel the user switched off (master switch, or every panel off — + // sync_window hides the empty shell then) is never resurrected; the + // watchdog only ever counters the shell's doing. + let wanted = prefs.enabled + && (prefs.panel_run + || prefs.panel_cpu + || prefs.panel_network + || prefs.panel_disk + || prefs.panel_storage); + if !wanted { + continue; + } let Some(window) = app.get_webview_window(WIDGET_LABEL) else { continue; }; - if !window.is_visible().unwrap_or(false) { + let Ok(hwnd) = window.hwnd() else { continue }; + let raw: *mut std::ffi::c_void = hwnd.0.cast(); + let mut took_down = false; + if !desktop_layer::shell_hidden(raw, &mut took_down) { continue; } - let Ok(hwnd) = window.hwnd() else { continue }; - let hwnd: *mut std::ffi::c_void = hwnd.0.cast(); - if !desktop_layer::adopted(hwnd) && !desktop_layer::adopt(hwnd) { - desktop_layer::lower(hwnd); + let _ = window.unminimize(); + let _ = window.show(); + desktop_layer::lower(raw); + // When the shell actively took the window down, Show() clears the + // cloak but the composed page can come back blank; one cheap reload + // makes it honest again. A plain hidden window (mid-startup) just + // needed showing. + if took_down { + let _ = window.eval("location.reload()"); } }); }