Skip to content

fix(window): 修复 Windows 全屏、窗口切换及 Win10 边角显示 - #1708

Closed
xuesecanmeng wants to merge 10 commits into
vastsa:mainfrom
xuesecanmeng:fix/windows-fullscreen-window-stacking
Closed

xuesecanmeng wants to merge 10 commits into
vastsa:mainfrom
xuesecanmeng:fix/windows-fullscreen-window-stacking

Conversation

@xuesecanmeng

@xuesecanmeng xuesecanmeng commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

修复 Windows 下 F11 全屏状态不同步、特定情况下 Alt+Tab 切换受置顶影响,以及 Win10 自定义圆角显示异常的问题。

问题与修复

问题 原因 修复方案
F11 全屏后仍能拖动上边框,最大化按钮状态不同步;小窗进入或退出全屏时按钮状态不变。 关闭原生缩放边框后,窗口的原生全屏状态与应用记录的状态不一致。 保留原生缩放边框,使用 Electron 原生全屏/最大化状态,并在状态稳定后同步窗口控制按钮。
Windows 在特定情况下(如提交者使用 Seelen UI 替换 Windows 原生 UI 的环境),使用 Alt+Tab 切换到其他应用时,PI-Desktop 可能仍覆盖目标窗口,表现为无法正常切换窗口。 异常尺寸恢复逻辑会调用 setAlwaysOnTop(true) 临时置顶,但负责在约 4 秒后解除置顶的定时检查仅在 macOS 启用;特定情况下 Windows 触发该路径后,会导致 PI-Desktop 持续置顶。 将临时置顶限定到 macOS;Windows 恢复窗口时保持普通层级,避免持续置顶干扰 Alt+Tab 切换,同时保留正常的聚焦和尺寸恢复行为。
Win10 自定义圆角出现参差毛边。 自定义圆角区域裁剪与 Windows 原生边框不匹配。 移除 Win10 自定义圆角裁剪,恢复 0.20.1 的直角外观;Win11 继续使用系统原生圆角。

验证结果

  • 窗口相关回归测试 96 项通过。
  • Windows 原生窗口控制、6 组边缘拖拽及全屏/最大化/恢复流程通过。
  • Win11 原生圆角与 Win10 直角策略共 12 组显示用例通过;探针已修正高 DPI、原生边框和自动隐藏任务栏的判断。
  • 桌面端构建、类型检查及 Host 发布构建通过。

本轮原生测试环境为 Win11、175% 缩放;Win10 策略用例不等同于真实 Win10 系统验收。此前安装包已由提交者在 Win10 虚拟机中验证。

问题截图

展开查看 3 张问题截图

F11 全屏后拖动上边框,最大化按钮状态仍未更新

截图_17921176945965

小窗进入 F11 全屏后,最大化按钮状态未变化

codex-clipboard-17dac4de-0177-4b6c-b1d0-76cb05b0dd78

Win10 自定义圆角出现毛边

截图_17921353224242

Keep Windows main windows opaque with their thick frame so Chromium owns
fullscreen and maximized restore without a transient normal-size window.
Publish settled native state to keep titlebar controls and corners aligned.

Restrict temporary recovery pinning to macOS, where its watchdog clears
the pin, so Windows and Linux recovery cannot leave the app above other
windows. Cover the transitions with regression tests and synchronized specs.
Client-sized shape regions use the outer HWND origin and expose the
left frame while truncating content. Keep Windows 10 unclipped so
native resize targets and fullscreen restore remain intact.

Retain Windows 11 DWM corners and theme radius acknowledgements, with
regression coverage and native probes for the platform-specific policy.
Preserve the native maximize state and settle interval supplied by the
previous integration merge so recovery tests exercise the upstream
restore handler after rebasing onto the latest main.
Opaque thick-frame windows include invisible resize margins and a
DWM-owned outline. Use physical monitor and visible window bounds so
hidden taskbars and native borders do not produce false failures.

Wait for foreground and native resize completion before sampling or
restoring the cursor, and cover taskbar probe geometry with regressions.
The resolver uses native filesystem separators. Normalize the expected
fixture path so the same contract is checked on Windows and POSIX hosts.
Client close completion can precede the server's socket close event.
Observe delivery and connection removal with bounded polling so parallel
validation does not depend on fixed 20 or 50 millisecond delays.
This test builds the complete sidecar and starts a real image worker.
Give that integration path a bounded 30-second timeout under parallel
transformation load while retaining every bundle and worker assertion.
Include the latest upstream changes before validating the native
window fixes and submitting the pull request.
@xuesecanmeng xuesecanmeng changed the title fix(window): restore native Windows fullscreen and frame behavior fix(window): preserve native Windows fullscreen and borders Oct 16, 2026
@xuesecanmeng xuesecanmeng reopened this Oct 16, 2026
@xuesecanmeng
xuesecanmeng marked this pull request as ready for review October 16, 2026 08:33
@xuesecanmeng
xuesecanmeng marked this pull request as draft October 16, 2026 08:34
@xuesecanmeng xuesecanmeng changed the title fix(window): preserve native Windows fullscreen and borders fix(window): 修复 Windows 全屏状态与 Win10 边框显示 Oct 16, 2026
@xuesecanmeng xuesecanmeng changed the title fix(window): 修复 Windows 全屏状态与 Win10 边框显示 fix(window): 修复 Windows 全屏、窗口切换及 Win10 边角显示 Oct 16, 2026
@xuesecanmeng
xuesecanmeng marked this pull request as ready for review October 16, 2026 08:50

vastsa commented Oct 17, 2026

Copy link
Copy Markdown
Owner

感谢补充 Windows 复现、探针和测试说明。我暂不合入,当前 diff 还有几个实质阻塞点:

  1. PR 中 F11/最大化改动覆盖了已关闭的 [Bug] 双屏显示器,F11全屏后pi-desktop白屏 #1655。当前 main 已包含针对双屏白屏的处理:进入全屏前先取消最大化,并跟踪 Win32 无边框全屏状态;本 PR 删除这两处保护,改用原生 isFullScreen() 和 thickFrame: true,可能重开同一条已修复路径。请先在最新 main 复现仍存在的问题;若只剩按钮状态问题,请把修复收窄到该状态同步,并保留 [Bug] 双屏显示器,F11全屏后pi-desktop白屏 #1655 的工作区恢复保护。
  2. 51 个文件里同时改 F11 状态、Alt+Tab 置顶和 Win10 圆角,还改了 agent-runtime、host-runtime、racp 的测试及插件文档。它们是不同故障和附带变更,当前 diff 超出最小修复范围。请拆开仍能在最新 main 复现的问题,并移除无关测试/文档变更。
  3. PR 基于旧 main,当前 CI、Docs check 和 PR-base 都是 action_required,没有实际验证结果。刷新到最新 main 后再运行必需检查。

Alt+Tab 和 Win10 圆角如能在当前版本稳定复现,可以分别带最小修复和对应验证回来。我核对后会继续 review。

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

需要修改后再考虑合入。当前 main 已针对 #1655 的双屏白屏保留了“进入全屏前取消最大化”和 Win32 无边框全屏状态跟踪;本 PR 移除这两处保护,存在重开已修复回归的风险。请基于最新 main 重新验证,并收窄到仍可复现的问题;F11、Alt+Tab、Win10 圆角分别处理,删掉无关包测试和文档改动。刷新后让 CI、Docs check 和 PR-base 有实际通过结果,再提交复审。

Bring the current upstream main into the shared development branch while
preserving the existing PR changes and commit history.

Keep the review-driven scope reduction deferred so it can be reconsidered
separately from this upstream synchronization.
Keep the Windows window-fix review focused by restoring the runtime
package tests and plugin documentation to the merged main baseline.
Retain window behavior, regression coverage, and related specifications.
@xuesecanmeng

Copy link
Copy Markdown
Contributor Author

感谢 review,补充说明 #1655 原修复、当前窗口方案及本次验证结果。
main分支原先设置 thickFrame: false,是为了解决 #1168 中主题无法去掉窗口左、下、右三侧黑色边框的问题。在这一窗口策略下,Electron 采用无厚边框的全屏回退路径,应用需要额外跟踪全屏状态。#1667 保留了该策略,通过进入全屏前取消最大化、退出时恢复最大化,并调整工作区适配,处理 #1655 中“最大化窗口按 F11 后跳到另一块屏幕并白屏”的问题。
但我在进行本次PR前测试 main 时发现了两个新的行为问题:

  1. 最大化状态按 F11,窗口实际经过“最大化 → 小窗 → 全屏”,中间的小窗状态会造成瞬间闪烁。
  2. 退出全屏后虽然恢复为最大化,但再次还原小窗时,尺寸变成了桌面工作区大小,丢失原来的小窗尺寸。代码中存在退出事件发生后、原生矩形尚未恢复完成就执行工作区修正的路径,会把过渡矩形用于普通窗口尺寸调整,干扰后续恢复。

当前方案将 Windows 主窗口统一设置为 transparent: false、thickFrame: true,由 Electron/Chromium 的完整全屏流程管理显示器归属、窗口状态和恢复矩形。进入全屏时直接切换,不再手动取消最大化;退出时由原生流程恢复此前状态。应用延后读取并同步状态,仅对普通窗口执行必要的工作区适配,保留最大化窗口的原生恢复矩形。标题栏按钮也同时根据最大化和全屏状态更新。因此,额外全屏标记的移除,是配合底层全屏路径的切换。

Win10 改回原生直角,是因为旧圆角方案使用内容区尺寸生成 setShape() 区域,却从整个窗口的左上角裁剪;恢复厚边框后,内容区和窗口外框的偏移会造成边框露出、内容截断及边角不齐。直接裁到内容区又会移除原生边缘、角落的缩放区域。Win10 没有 Win11 的 DWM 原生圆角接口,因此当前移除自定义裁剪,优先保证内容完整、原生缩放和全屏恢复;Win11 继续使用 DWM 圆角。这里有明确的外观取舍:Win10 的主题圆角请求仍被接受,但窗口保持直角;alpha 背景色合成为不透明颜色。

我已在Win11双屏实机验证当前修复版本,窗口行为正常,未复现 #1655 中的跳屏、白屏问题,全屏切换及小窗尺寸恢复也正常。同时检查了窗口外观,在当前 Win11 环境中未复现 #1168 的三侧黑色边框问题。上述结果是本次环境下的实测结论,不扩展为所有系统、主题和缩放组合均已覆盖。

PR 已更新至 c55caac,包含 main 589e580。另外已撤回三个无关包的测试修改和六份插件文档的附带修改,差异从 51 个文件减至 42 个,保留窗口相关测试和必要说明。本地 37 项窗口测试、文档检查、类型检查、桌面及 Rust 发布构建、Windows 打包校验均已通过。

@xuesecanmeng
xuesecanmeng requested a review from vastsa October 19, 2026 06:32

vastsa commented Oct 19, 2026

Copy link
Copy Markdown
Owner

需要补充一个 review 结论:当前 head 改动了 WindowControls.tsx 的全屏/最大化状态显示,也切换了原生窗口边框与表面策略,属于可见界面变更,不符合这次“只合入无界面改动 fix”的条件,因此本轮不会合入。

另外,当前 diff 仍移除了 main 已有的 Win32 无边框全屏状态跟踪和进入全屏前取消最大化的保护,#1655 的双屏恢复路径仍有回归风险;请按最新 main 分别收窄并验证这些改动后再请求复审。感谢你补充 Windows 实机、探针和回归测试结果。

@xuesecanmeng

Copy link
Copy Markdown
Contributor Author

需要补充一个 review 结论:当前 head 改动了 WindowControls.tsx 的全屏/最大化状态显示,也切换了原生窗口边框与表面策略,属于可见界面变更,不符合这次“只合入无界面改动 fix”的条件,因此本轮不会合入。

另外,当前 diff 仍移除了 main 已有的 Win32 无边框全屏状态跟踪和进入全屏前取消最大化的保护,#1655 的双屏恢复路径仍有回归风险;请按最新 main 分别收窄并验证这些改动后再请求复审。感谢你补充 Windows 实机、探针和回归测试结果。

#1667 保留了无厚边框的全屏回退路径,通过进入全屏前取消最大化来规避 #1655。本 PR 则调整主窗口配置,采用 Electron/Chromium 的完整全屏流程,由其管理显示器归属、窗口状态和恢复矩形,从而替代原来的手动切换步骤,并解决这些步骤引入的闪烁和小窗尺寸恢复异常。

因此,这次是对窗口全屏实现路径的调整,而非单纯删除已有保护。当前PR中的变更是main合并了#1655 之后进行的,在 Win11 双屏实测未复现原问题,但窗口外观和主题兼容性的取舍仍需单独评估。

请确认“因此不符合只接收无界面改动 fix 的条件”具体含义,给我一个明确的PR接收范围,方便我对当前PR进行精简或者拆分。

vastsa commented Oct 20, 2026

Copy link
Copy Markdown
Owner

本轮接收范围明确为不改变用户可见界面或原生窗口行为策略的 fix。这不是说问题不真实,也不是否定修复方向。#1708 修改标题栏的全屏/最大化状态,同时调整 Windows 厚边框、透明表面和 Win10 圆角策略;Alt+Tab 置顶行为也属于操作系统窗口层级变化,因此都超出本批范围,当前不合入。

后续窗口/UI 变更进入 review 范围时,请基于最新 main 分别提交最小改动,并保留 #1655 的双屏恢复保护。感谢补充实机复现和方案细节。

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