Feature/ctrl + D分离窗口显示窗口控件 + 解决linux环境下无法最大化的问题 - #662
Open
zx1095971114 wants to merge 2 commits into
Open
Conversation
分离窗口在主进程中以 frame:false 创建,因此 Linux 上窗口管理器不会自动绘制窗口控件。\n扩展 DetachedTitlebar.vue 的 platform 类型为 'darwin' | 'win32' | 'linux',\n并将窗口控制按钮的 v-if 条件改为同时匹配 win32 和 linux,让 Linux 用户\n也能在独立窗口右上角看到最小化、最大化、关闭按钮。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
回到只动 resize 监听器旁加 maximize/unmaximize 兜底,不再触碰 IPC
handler、BrowserWindow 几何和持久化逻辑。
修复:
- win.on('maximize'/'unmaximize', ...) 时调用 syncPluginViewBoundsOnly,
通过 syncPluginViewBoundsOnly → pluginView.setBounds 把 pluginView
位置拉到新窗口尺寸。Linux 上 WM 走 _NET_WM_STATE_MAXIMIZED_* 时常
不发 ConfigureNotify,resize 事件可能不触发,导致 pluginView 保持
旧 bounds、看起来“窗口最大化但内容没放大”。这个兜底就是为了补上
这种情况。
- syncAfterStateChange 在三个时间点同步:立即、setImmediate、100ms,
覆盖 WM 异步处理状态切换的不同延迟。
- resize 监听器增加 win.isMaximized()/isFullScreen() 守卫:最大化/
全屏触发的 resize 不写数据库,避免把屏幕工作区尺寸误存为下次
Ctrl+D 的“默认尺寸”。
注意:syncPluginViewBoundsOnly 内部不调用 schedulePersistWindowSize,
也不修改 BrowserWindow 几何。持久化逻辑完全由 resize 事件处理,
最大化/全屏状态下被守卫拦截。
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.
变更内容
本 PR 修复 ZTools 分离窗口在 Linux 平台 的两个问题,涉及 2 个 commit:
e79a3e4Linux 分离窗口显示最小化/最大化/关闭按钮DetachedTitlebar.vue:platform类型扩展为'darwin' | 'win32' | 'linux'v-if条件同步匹配linux,让 Linux 用户也能在独立窗口右上角看到最小化、最大化、关闭按钮frame: false创建,Linux WM 不会自动绘制窗口控件,必须由 HTML 自绘25d43ccLinux 分离窗口 maximize 时同步 WebContentsView bounds(保守修复)detachedWindowManager.ts新增maximize/unmaximize监听器,触发syncPluginViewBoundsOnlysyncAfterStateChange在三个时间点同步:立即、setImmediate、100ms,覆盖 WM 异步处理状态切换的不同延迟win.isMaximized() / win.isFullScreen()守卫:最大化/全屏触发的 resize 不写数据库,避免把屏幕工作区尺寸误存为下次 Ctrl+D 的"默认尺寸"_NET_WM_STATE_MAXIMIZED_*时常不发ConfigureNotify,resize 事件可能不触发,导致pluginView保持旧 bounds、看起来"窗口最大化但内容没放大"文件改动
src/main/core/detachedWindowManager.tssrc/renderer/src/components/detached/DetachedTitlebar.vue动机
Linux 平台上分离窗口体验存在两个缺陷:
截图
改动前linux的无窗口控件

改动前linux调出窗口控件后点击最大化按钮

改动后linux的窗口控件可见

改动后linux窗口最大化时内容等比例放大

手动验证(Linux GNOME Wayland / KDE X11)
窗口控件可见性
Ctrl+D分离窗口最大化同步
持久化不被污染
不影响其他平台
v-if条件)相关 Issue
无
影响范围
v-if仅扩展,maximize监听器为 no-op,因为 Windows 上maximize事件正常触发 resize)检查清单
pnpm typecheck:node通过pnpm typecheck:web通过pnpm lint(改动文件)通过 —detachedWindowManager.ts/DetachedTitlebar.vue均为 0 错误fix:+ 详细 body)any使用