mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-24 23:05:49 +00:00
fix(electron): Win10 HUD click-through recovery
This commit is contained in:
@@ -166,6 +166,15 @@ function focusOrCreateMainWindow() {
|
||||
win.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
// On Win32, calling show/moveTop/focus on the transparent HUD overlay
|
||||
// permanently corrupts setIgnoreMouseEvents forwarding, making it
|
||||
// click-through. Only focus the editor window; the HUD is alwaysOnTop
|
||||
// so it doesn't need explicit focus.
|
||||
if (process.platform === "win32" && !isEditorWindow(mainWindow)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainWindow.show();
|
||||
if (mainWindow.isMinimized()) mainWindow.restore();
|
||||
mainWindow.moveTop();
|
||||
@@ -173,6 +182,32 @@ function focusOrCreateMainWindow() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On Windows 10, focus changes and native notifications can break
|
||||
* {@link BrowserWindow.setIgnoreMouseEvents} forwarding on the transparent HUD
|
||||
* overlay, causing it to become permanently click-through. Call this after any
|
||||
* operation that may alter focus or z-order so that hover detection keeps working.
|
||||
*/
|
||||
function reassertHudOverlayMouseState() {
|
||||
if (process.platform !== "win32") {
|
||||
return;
|
||||
}
|
||||
|
||||
const hud = getHudOverlayWindow();
|
||||
if (!hud) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Toggle off then back on so the native WS_EX_TRANSPARENT flag is fully
|
||||
// re-initialised rather than merely re-asserted in a potentially broken state.
|
||||
hud.setIgnoreMouseEvents(false);
|
||||
setTimeout(() => {
|
||||
if (!hud.isDestroyed()) {
|
||||
hud.setIgnoreMouseEvents(true, { forward: true });
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
|
||||
function isEditorWindow(window: BrowserWindow) {
|
||||
return window.webContents.getURL().includes("windowType=editor");
|
||||
}
|
||||
@@ -411,6 +446,10 @@ function sendUpdateToastToWindows(channel: "update-toast-state", payload: unknow
|
||||
});
|
||||
|
||||
notification.show();
|
||||
// On Win10, showing a native notification can break setIgnoreMouseEvents
|
||||
// forwarding on the transparent HUD overlay. Re-assert it after a short
|
||||
// delay so the renderer's hover detection keeps working.
|
||||
reassertHudOverlayMouseState();
|
||||
activeUpdateNotification = notification;
|
||||
activeUpdateNotificationKey = notificationKey;
|
||||
return true;
|
||||
|
||||
@@ -322,6 +322,24 @@ export function createHudOverlayWindow(): BrowserWindow {
|
||||
|
||||
win.setIgnoreMouseEvents(true, { forward: true });
|
||||
|
||||
// On Windows 10, focus changes (e.g. showing a native notification) can break
|
||||
// setIgnoreMouseEvents forwarding on a transparent always-on-top window, making
|
||||
// it permanently click-through without hover detection. Re-initialise the
|
||||
// pass-through-with-forwarding state whenever the window gains focus by toggling
|
||||
// the flag off then back on so the native WS_EX_TRANSPARENT flag is fully reset.
|
||||
if (process.platform === "win32") {
|
||||
win.on("focus", () => {
|
||||
if (!win.isDestroyed()) {
|
||||
win.setIgnoreMouseEvents(false);
|
||||
setTimeout(() => {
|
||||
if (!win.isDestroyed()) {
|
||||
win.setIgnoreMouseEvents(true, { forward: true });
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
win.webContents.on("did-finish-load", () => {
|
||||
win?.webContents.send("main-process-message", new Date().toLocaleString());
|
||||
setTimeout(() => {
|
||||
|
||||
Reference in New Issue
Block a user