Skip to content

🐞 fix: 修复嵌入桌面图标层后顶部白条残留 - #5

Merged
LanRhyme merged 3 commits into
LanRhyme:mainfrom
jingzhudezhong:fix/white-bar-on-embed
Jul 21, 2026
Merged

LanRhyme merged 3 commits into
LanRhyme:mainfrom
jingzhudezhong:fix/white-bar-on-embed

Conversation

@jingzhudezhong

Copy link
Copy Markdown
Contributor

问题:DeskZero 嵌入到桌面图标层(壁纸与桌面图标之间)后,窗口顶部出现一条白色标题栏,左上角显示 "deskzero" 字样。

根因:

  1. WNDPROC 子类化只拦截了 WM_NCCALCSIZE,但 Windows 11 仍会通过 WM_NCPAINT 和 WM_NCACTIVATE 触发非客户区重绘
  2. Windows 11 DWM 在窗口周围强制绘制几像素的"隐形边框"和圆角,仅靠 WNDPROC 拦截无法消除
  3. subclass_window 多次调用时会用 custom_wndproc 自身覆盖 OLD_WNDPROC,导致消息处理无限递归

修复:

  • 拦截 WM_NCPAINT(返回 0)阻止非客户区绘制
  • 拦截 WM_NCACTIVATE(返回 1)阻止激活态非客户区重绘
  • 通过 DwmSetWindowAttribute 禁用窗口圆角(DWMWA_WINDOW_CORNER_PREFERENCE = 1)和非客户区渲染(DWMWA_NCRENDERING_POLICY = 1)
  • 通过 DwmExtendFrameIntoClientArea 将所有边距设为 -1,扩展到整个窗口
  • 修复 subclass_window 递归 Bug,只在第一次记录 OLD_WNDPROC
  • 在 build.rs 链接 dwmapi.lib

验证:npm run tauri build 重新构建后,exe 启动并嵌入桌面图标层,顶部白条已完全消失。

问题:DeskZero 嵌入到桌面图标层(壁纸与桌面图标之间)后,窗口顶部出现一条白色标题栏,左上角显示 "deskzero" 字样。

根因:
1. WNDPROC 子类化只拦截了 WM_NCCALCSIZE,但 Windows 11 仍会通过 WM_NCPAINT 和 WM_NCACTIVATE 触发非客户区重绘
2. Windows 11 DWM 在窗口周围强制绘制几像素的"隐形边框"和圆角,仅靠 WNDPROC 拦截无法消除
3. subclass_window 多次调用时会用 custom_wndproc 自身覆盖 OLD_WNDPROC,导致消息处理无限递归

修复:
- 拦截 WM_NCPAINT(返回 0)阻止非客户区绘制
- 拦截 WM_NCACTIVATE(返回 1)阻止激活态非客户区重绘
- 通过 DwmSetWindowAttribute 禁用窗口圆角(DWMWA_WINDOW_CORNER_PREFERENCE = 1)和非客户区渲染(DWMWA_NCRENDERING_POLICY = 1)
- 通过 DwmExtendFrameIntoClientArea 将所有边距设为 -1,扩展到整个窗口
- 修复 subclass_window 递归 Bug,只在第一次记录 OLD_WNDPROC
- 在 build.rs 链接 dwmapi.lib

验证:npm run tauri build 重新构建后,exe 启动并嵌入桌面图标层,顶部白条已完全消失。

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces changes to eliminate Windows 11 invisible borders and rounded corners using the DWM API, and refactors window styling logic to handle embedding failures gracefully. The reviewer identified two critical issues: first, a potential data race and window procedure bypass involving the static mutable OLD_WNDPROC variable, which should be made thread-safe using an atomic type; second, a race condition in the fallback path where synchronous Win32 API calls in a background thread are overridden by asynchronous Tauri window operations, which should instead be dispatched to the main thread.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src-tauri/src/lib.rs Outdated
Comment thread src-tauri/src/lib.rs Outdated
LanRhyme added 2 commits July 21, 2026 20:06
- 将 OLD_WNDPROC 改为 AtomicIsize,保证线程安全
- 将回退路径的 Tauri 窗口操作分发到主线程执行,修复竞态条件
@LanRhyme
LanRhyme merged commit 017829f into LanRhyme:main Jul 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants