MCPcopy Index your code
hub / github.com/ZToolsCenter/ZTools / forceRepaintView

Method forceRepaintView

src/main/managers/pluginManager.ts:1248–1258  ·  view source on GitHub ↗

* 强制重绘 WebContentsView(修复部分 Windows 系统白屏问题) * 通过 bounds 微调迫使 Chromium compositor 重新合成 surface。 * * 关键:两次 setBounds 必须跨 event loop tick 执行。 * 若在同一 tick 内同步调用,Chromium compositor 会合并两次操作, * 只取最终值在下次 vsync 渲染,+1px 中间状态从未触达 GPU 合成阶段,修复失效。 * 用 setImmediate 将第二次调用推入下一 tick,使两次变化各自落在不同 vs

(view: WebContentsView)

Source from the content-addressed store, hash-verified

1246 * 从而确保第一次 +1px 真正触发 compositor 重绘。
1247 */
1248 private forceRepaintView(view: WebContentsView): void {
1249 if (view.webContents.isDestroyed()) return
1250 const bounds = view.getBounds()
1251 if (bounds.height <= 0) return
1252 view.setBounds({ ...bounds, height: bounds.height + 1 })
1253 setImmediate(() => {
1254 if (!view.webContents.isDestroyed()) {
1255 view.setBounds(bounds)
1256 }
1257 })
1258 }
1259
1260 /**
1261 * 强制重绘当前插件视图(供外部调用,如窗口唤醒时)

Calls

no outgoing calls

Tested by

no test coverage detected