Repository navigation
Conversation
新增 window-monitor 原生模块,通过 Win32 读取前台窗口矩形,判断其是否 完整覆盖所在显示器,据此在他人全屏(游戏 / 视频 / 演示 / 浏览器全屏) 时隐藏灵动岛,退出全屏后恢复显示与置顶,避免常驻 topmost 层级压在全屏 内容之上。 - native/window-monitor:无状态单次查询,排除最大化窗口与桌面类窗口 (最大化同样铺满屏幕但不算全屏),支持传入自身 HWND 避免自我判定 - services/foreground.ts:300ms 轮询,仅在状态变化时回调,非 Windows 平台降级为始终显示 - dynamicIsland:全屏隐藏、退出后 showInactive 恢复(不抢焦点); ready-to-show 时若已处于全屏则跳过显示,避免"先闪一下再消失" - 设置项 dynamicIsland.hideOnFullscreen,默认开启,仅 Windows 显示
This branch has not been deployed
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.
改动类型
是否包含破坏性变更
改动说明
动机:灵动岛当前用
setAlwaysOnTop(true, "screen-saver")一刀切常驻置顶,没有任何前台全屏探测。用户玩游戏、看视频、演示或浏览器全屏时,灵动岛会一直压在全屏内容之上,既挡视线也无法被全屏窗口覆盖。方案:新增一个只做「前台窗口是否全屏」判断的原生模块,主进程轮询该状态,全屏时隐藏灵动岛、退出后恢复显示并重新置顶。
之所以选择隐藏而不是取消置顶:topmost 窗口与全屏窗口是同层竞争关系,只要灵动岛还在屏幕上,要么压住全屏内容,要么被全屏内容压住,隐藏是唯一干净的处理。
主要变更
1. 新增原生模块
native/window-monitor(仅 Windows)导出单个函数
isForegroundFullscreen(excludeHwnd?: number): boolean,无状态、只做单次同步查询,不持有任何窗口句柄。判定链:其中 排除最大化是必须的:Windows 上最大化窗口的
GetWindowRect返回-8,-8,w+8,h+8,同样完整覆盖显示器,不排除会导致用户只是最大化窗口时灵动岛就消失。2.
electron/main/services/foreground.ts300ms 轮询,仅在状态变化时回调(单次查询只有几个 Win32 调用,开销可忽略);非 Windows 平台恒返回
false,即保持原有「始终显示」行为。3.
electron/main/window/dynamicIsland.tsready-to-show时能读到初始判定;hide();恢复 →showInactive()(不抢焦点,保持非侵入定位)+ 重设setAlwaysOnTop(..., "screen-saver");ready-to-show时若已处于全屏则跳过show(),避免「先闪一下再消失」;closed时停止监听。4. 设置项
dynamicIsland.hideOnFullscreen默认开启,仅 Windows 显示,中英文案已补。改动时通过 IPC 走
applyDynamicIslandHideOnFullscreen即时生效。关联 Issue
测试情况
平台:Windows 11(2560×1440)
原生模块单独验证(用 Node 直接
require编译产物,不启动 Electron):truefalsefalse(未误判)false联动验证(通过 CDP 驱动主窗口全屏,用
document.visibilityState判断灵动岛是否被隐藏):visibilityState变为hidden;visible。回归检查:
tsc(node)、vue-tsc(web)、eslint、electron-vite build全部通过。截图 / 录屏
灵动岛正常显示(隐藏生效前后的差异主要体现在窗口可见性,静态截图不易体现,故从略)。
自查清单
pnpm format,并确认pnpm typecheck、pnpm lint通过pnpm build:native验证;未手写native/*/index.d.tsdev分支提交关于最后一项的说明
本地
napi build无法执行:rustc在编译proc-macro2/quote的 build script 时崩溃(STATUS_ACCESS_VIOLATION,退出码0xC0000005),加--jobs 1也一样。因此改用cargo build -p window-monitor直接编译并手动复制产物为native/window-monitor/window-monitor.node,编译过程无警告。native/window-monitor/index.d.ts是按 NAPI-RS 生成格式手写的,内容与 Rust 签名一致(已通过 Node 实际加载验证导出名与参数行为):合并前建议维护者在正常环境下执行一次
pnpm build:native覆盖生成,确认无误。