Fix taskbar buttons on wrong monitor after slow multi-monitor wakeup#1354
Merged
dremin merged 1 commit intoMar 10, 2026
Merged
Conversation
When a monitor wakes up slowly, Windows may assign it a new HMonitor handle while keeping bounds and device name unchanged. haveDisplaysChanged() only compared Bounds/DeviceName/Primary (using WinForms Screen objects which have no HMonitor field), so it missed such changes and skipped ReopenTaskbars(). As a result, each taskbar's Host.Screen.HMonitor stayed stale, causing Tasks_Filter to mismatch windows to the wrong taskbar even when live filtering re-evaluated. Fix: use AppBarScreen.FromAllScreens() (which fetches fresh HMonitors via MonitorFromPoint) instead of Screen.AllScreens, and include HMonitor in the equality check. When an HMonitor change is detected, ReopenTaskbars() is called, creating new taskbars with correct handles. https://claude.ai/code/session_01FpcNUJRXQN59TNdE93aKSk
|
Download the artifacts for this pull request: |
Owner
|
Interesting! Even though it seems odd that Windows would be assigning a new handle to the monitor, the fix is reasonable and I probably should have done this in the first place. Thanks! |
dremin
approved these changes
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have two monitors connected to laptop via dock and for some silly reasons the wakeup after sleep is very slow. First laptop screen turns on, then those monitors wakeup a few second later. This has been causing a weird issue.
When I login, the taskbar buttons don't appear on the same screen as the window. Most buttons gather on primary monitor, some remain on other screens. Even if I move windows to other displays, the buttons stay on wrong taskbar.
Work around I have is to open settings, then uncheck "Show on multiple displays" then check it again. That puts buttons on correct task bars.
It was bothering me a lot. I used Claude to find and fix it. And it is working fine for me.
Because I used AI, I cant say that this is the correct solution. Close the PR if it isn't.
Blurb Claude wrote about this fix