fix: 禁用后台节流,修复软隐藏后快捷键与工具条悬停失效 - #68
Merged
ooboqoo merged 1 commit intoSep 1, 2026
Merged
Conversation
Windows 上"隐藏窗口"采用软隐藏实现:不调用 hide(),而是 setOpacity(0) 并将窗口移至屏幕外。这会触发 Chromium 的原生窗口遮挡检测 (CalculateNativeWinOcclusion),渲染进程被判定为 occluded 后进入 后台节流/冻结状态。 恢复显示时遮挡状态不会自动重算(需窗口聚焦才重算),导致: - 除纯主进程操作(窗口移动)外,所有快捷键看似失效 (主进程逻辑实际已执行,webContents.send 的 IPC 在冻结的渲染 进程中排队,点击聚焦后一次性刷出) - 悬浮工具条的鼠标悬停失效(dwell 判定基于渲染进程 setTimeout, 被节流钳制) 为主窗口与工具条窗口的 webPreferences 设置 backgroundThrottling: false, 覆盖层应用需要渲染进程在隐藏/遮挡期间保持响应。
ooboqoo
approved these changes
Sep 1, 2026
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.
问题现象
Windows 上使用「显示/隐藏窗口」快捷键隐藏窗口后再显示:
根因分析
Windows 上「隐藏窗口」采用软隐藏实现(
softHideWindow):不调用hide(),而是setOpacity(0)+ 将窗口移动到所有显示器之外(x = 屏幕最右缘 + 2000)。这会触发 Chromium 的原生窗口遮挡检测(
CalculateNativeWinOcclusion,Windows 默认启用):窗口完全离屏 → 判定为 occluded → 渲染进程进入后台节流/冻结状态(定时器钳制、任务队列暂停)。恢复显示时
restoreSoftHiddenWindow只把窗口搬回屏幕,但 occlusion 状态不会随位置变化自动重算,要等窗口被激活/聚焦才重算。因此两个渲染进程(主窗口 + 工具条)在恢复后仍处于冻结状态,直到用户点击聚焦。各症状的对应关系:
globalShortcut回调在主进程照常执行(截图已写盘、AI 请求已发出),但webContents.send()的 IPC 在冻结的渲染进程中排队moveMainWindow*是唯一纯主进程操作(仅setPosition),不依赖渲染进程、不检查state.inCoderPagesetTimeout(OverlayToolbar.tsx),被节流钳制隐蔽性:失效期间按的截图键实际已完成截图写盘和 AI 请求(产生了 API 调用),只是界面未刷新。
修复
为主窗口与工具条窗口的
webPreferences设置backgroundThrottling: false。悬浮窗类应用需要渲染进程在隐藏/遮挡期间保持响应。测试
Windows 11 + Electron 37 实测:修复前可稳定复现上述现象;加上本改动后,隐藏 → 显示 → 直接使用快捷键与工具条悬停均正常,无需点击聚焦。