Fixes: preserve taskbar monitor selection + widget vanishing when start menu opens#47
Conversation
Store the selected taskbar's monitor device name in settings and prefer it when reattaching the widget. This keeps the widget anchored to the same physical monitor when taskbar ordering changes after monitor connect, disconnect, or reconfiguration, while still falling back to the saved index for existing settings and compatibility.
The widget embeds as a child of the taskbar, which keeps it painted above the shell's Start/Search acrylic backdrop. The actual bug was the watchdog: opening the Start menu makes the taskbar briefly drop out of EnumWindows (~5s) even though its HWND is still valid, and the watchdog read that as an explorer restart and relaunched the whole process, wiping the widget. Guard the watchdog with IsWindow on the stored taskbar handle: if the handle still exists it is a transient Start-menu enumeration blip, so skip. Only relaunch when the handle is truly destroyed (a real explorer restart) and only after TASKBAR_MISSING_TICKS consecutive confirmations. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017m74C6QgGGawTbeTb8NkBG
Opening the Start menu/search makes the taskbar briefly drop out of EnumWindows (~5s) even though its HWND is still valid. The watchdog read that as an explorer restart and relaunched the process, wiping the widget. Guard the watchdog with IsWindow on the stored taskbar handle: if it still exists, treat it as a transient enumeration blip and skip. Only relaunch when the handle is truly gone for TASKBAR_MISSING_TICKS consecutive checks. Fix originally by André Escocard (andreescocard) in CodeZeno PR CodeZeno#47. Co-Authored-By: André Escocard <andreescocard@users.noreply.github.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Nice, I landed on the same device-name approach independently while looking at #43, so I can confirm the core mechanism is sound (and nice work on the start menu issue, I totally missed that!). I closed my PR (#48) in favor of yours as you got there first. A few suggestions from my PR you might consider folding in:
When the remembered device isn't found (first run, monitor swapped/renamed), // in TaskbarWindow: also capture the primary flag
// (MONITORINFO.dwFlags & MONITORINFOF_PRIMARY) != 0 → pub is_primary: bool
let index = requested_device
.filter(|d| !d.is_empty())
.and_then(|device| taskbars.iter().position(|t| t.device == device))
.or_else(|| taskbars.iter().position(|t| t.is_primary)) // <- primary before index
.unwrap_or_else(|| requested_index.min(taskbars.len().saturating_sub(1)));
A short retry in
A small |
No description provided.