Skip to content

fix(desktop): restore macOS window bounds after zoom - #2523

Merged
Tioit-Wang merged 1 commit into
vastsa:mainfrom
Linuxdazhao:codex/macos-zoom-restore-2520
Nov 24, 2026
Merged

Tioit-Wang merged 1 commit into
vastsa:mainfrom
Linuxdazhao:codex/macos-zoom-restore-2520

Conversation

@Linuxdazhao

Copy link
Copy Markdown
Contributor

概要

解决 macOS 上 PI-Desktop 窗口最大化后无法恢复原尺寸和位置的问题。

macOS 的原生 Zoom/Restore 和边缘拖动都会进入 Electron 的 will-resize。原保护逻辑在最大化后取消这个事件,也会取消恢复原尺寸所需的调整。因此即使 isMaximized() 已变为 false,窗口也可能仍占满工作区。

将边缘保护限定在 Windows。macOS 的边缘拖动和 Zoom/Restore 交给 AppKit,应用原有的标题栏双击恢复仍走原生窗口接口。

关联议题

Fixes #2520

验证

  • macOS 27.2.1 arm64,Electron 43.6.0。强化现有原生测试,让它比较恢复前后的整个窗口矩形。旧逻辑下复现了 704×650 无法恢复、尺寸停在 1728×1030 的故障。修复后不透明和半透明窗口都通过。
  • node --test apps/desktop/test/window-native-behavior.test.mjs apps/desktop/test/maximized-window-chrome.test.mjs,14 项通过。
  • 桌面构建通过。隔离配置中的完整桌面通过生产 preload/IPC 验证了标题栏双击,原生窗口矩形恢复到 (264, 95, 1200, 800)。
  • 完整 test:e2e:window-controls 在工作面板动画阶段发生 CDP 超时,未走到窗口恢复断言。
  • 更新了窗口交互规格和 E2E-167。候选分支基于 6b8ff1e803b6,通过 PR 基线检查。

@Tioit-Wang

Copy link
Copy Markdown
Collaborator

Review: the reported maximized-frame restoration failure is reproduced on macOS, and removing the macOS will-resize cancellation is a focused fix for that path. The latest issue report adds a separate case: after native fullscreen enter/exit, the window is no longer maximized and resizable, but the renderer can retain data-window-maximized=true, leaving the caption app-region: no-drag. In current main, the leave-full-screen handler only sends fullscreen state; windowMaximized is sent on maximize/unmaximize, not on leave-full-screen. Please add a regression test for that fullscreen-exit state (and resync the maximized flag after the native transition if reproduced) before landing. Also refresh this head: base 6b8ff1e is 40 commits behind/diverged from current origin/main d07b742. Not approved or merged.

@Tioit-Wang Tioit-Wang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The latest reproduction adds a case not covered by the PR: after native fullscreen enter/exit, the window is no longer maximized and is resizable, but the renderer still has data-window-maximized=true, which leaves the caption region no-drag. Current main sends a maximize-state event on maximize/unmaximize, while the leave-full-screen handler only sends fullscreen state. Please add a regression test for this transition and resync the maximized marker after the native fullscreen transition if reproduced. The PR also needs refreshing against current main before landing.

@Tioit-Wang
Tioit-Wang merged commit 91997ff into vastsa:main Nov 24, 2026
7 checks passed
@Tioit-Wang

Copy link
Copy Markdown
Collaborator

This issue is fixed by merged PR #2561, which continues the original zoom/restore implementation and adds the reproduced fullscreen-exit maximize-state resync. Your original commit is preserved. The refreshed Windows CI and Electron checks passed; native macOS gesture E2E remains platform validation not run in this Windows environment. I am closing this superseded PR to avoid duplicate window fixes.

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.

[Bug] Mac端调整窗口大小及拖动窗口方式失效

2 participants