fix: 修复副屏任务栏重启后不显示及高度异常问题 - #495
Open
Hsyoungtick wants to merge 1 commit into
Open
Conversation
- FindHandles 不再 fallback 到主屏,副屏未就绪时返回 Zero 触发重试 - 新增 IsOnCorrectScreen 检测句柄是否挂载在正确屏幕 - Tick 中增加 isWrongScreen 检查,挂载错误屏幕时触发重新查找 - 句柄变化时立即重新挂载,解决 Win10 策略缓存过期问题 - 修复 DPI 缩放导致 Screen.Bounds 与 WorkingArea 坐标空间不一致
|
求尽快合入 |
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.
问题
在多显示器环境下,将任务栏设置到副屏后,每次重启程序都无法在副屏任务栏显示,需要手动切回主屏再切回副屏才能恢复。同时副屏任务栏会占位但内容不可见。
根因
FindHandles fallback 到主屏:启动时副屏任务栏(
Shell_SecondaryTrayWnd)可能尚未就绪,原代码会 fallback 到主屏Shell_TrayWnd,且 Tick 重试逻辑无法检测到这个错误,导致永远停留在主屏。DPI 缩放导致坐标空间不一致:
Screen.Bounds返回物理像素,Screen.WorkingArea返回逻辑像素,两者相减得到错误的高度(如 424px 而非 40px),导致窗口被拉伸但内容不可见。修复
FindHandles找不到副屏任务栏时返回IntPtr.Zero,不再 fallback 到主屏,让 Tick 重试机制生效IsOnCorrectScreen()检测当前句柄是否挂载在目标屏幕上isWrongScreen检查,挂载到错误屏幕时触发重新查找GetTaskbarRect中当物理矩形高度已是合理任务栏高度(20~100px)时直接使用,绕过 DPI 缩放不一致问题测试环境