Fix Windows pet input after reload
This commit is contained in:
parent
05bb979362
commit
68a44a6602
2 changed files with 17 additions and 1 deletions
|
|
@ -114,6 +114,7 @@ assert.match(petWindowSource, /function installMousePassthroughAndDrag/, "pet wi
|
|||
assert.match(petWindowSource, /setIgnoreMouseEvents\(true, \{ forward: true \}\)/, "transparent pet window background must use OS-level mouse passthrough.");
|
||||
assert.match(petWindowSource, /setIgnoreMouseEvents\(false\)/, "visible pet and bubble hit targets must re-enable mouse handling.");
|
||||
assert.match(petWindowSource, /openpets:pet-ready/, "pet windows must resync passthrough after each renderer reload.");
|
||||
assert.match(petWindowSource, /function installMousePassthroughAndDrag[\s\S]*?const rearmPassthroughAfterLoad[\s\S]*?process\.platform !== "win32"[\s\S]*?window\.setIgnoreMouseEvents\(false\);[\s\S]*?window\.setIgnoreMouseEvents\(true, \{ forward: true \}\);/, "Windows pet reloads must toggle forwarded mouse passthrough to re-register hover and drag tracking.");
|
||||
assert.match(petWindowSource, /did-finish-load", rearmAfterLoad/, "pet windows must re-arm mouse passthrough after every content load.");
|
||||
assert.match(petWindowSource, /did-fail-load", handleLoadFailure/, "pet windows must restore passthrough after failed content loads.");
|
||||
assert.match(petWindowSource, /window\.setIgnoreMouseEvents\(false\);[\s\S]*?await window\.loadFile/, "pet reloads must reset OS mouse passthrough before navigation.");
|
||||
|
|
|
|||
|
|
@ -148,6 +148,21 @@ function installMousePassthroughAndDrag(window: BrowserWindow): void {
|
|||
else window.setIgnoreMouseEvents(false);
|
||||
};
|
||||
|
||||
const rearmPassthroughAfterLoad = (): void => {
|
||||
if (window.isDestroyed()) return;
|
||||
if (process.platform !== "win32") {
|
||||
setPassthrough(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// On Windows, rapid pet HTML reloads can leave Chromium's forwarded mouse
|
||||
// tracking stale while the cursor is already over the transparent window.
|
||||
// Toggle passthrough after each completed reload so hover/drag mousemove
|
||||
// forwarding is re-registered without requiring the cursor to leave/re-enter.
|
||||
window.setIgnoreMouseEvents(false);
|
||||
window.setIgnoreMouseEvents(true, { forward: true });
|
||||
};
|
||||
|
||||
const handleHitTest = (event: IpcMainEvent, interactive: unknown): void => {
|
||||
if (!isFromWindow(event)) return;
|
||||
rendererReady = true;
|
||||
|
|
@ -190,7 +205,7 @@ function installMousePassthroughAndDrag(window: BrowserWindow): void {
|
|||
const rearmAfterLoad = (): void => {
|
||||
dragging = null;
|
||||
debug("pet.window", "load rearm passthrough", { windowId: window.id });
|
||||
setPassthrough(true);
|
||||
rearmPassthroughAfterLoad();
|
||||
};
|
||||
|
||||
const handleDomReady = (): void => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue