1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-08-10 22:11:50 +02:00

Desktop: Fix secondary window controls greyed out when first opened (#12685)

This commit is contained in:
Henry Heino
2025-07-09 00:43:06 -07:00
committed by GitHub
parent 7212269107
commit 2c50ad36c5

View File

@@ -343,6 +343,14 @@ export default class ElectronAppWrapper {
}, 1000);
}
const sendWindowFocused = (focusedWebContents: WebContents) => {
const joplinId = this.windowIdFromWebContents(focusedWebContents);
if (joplinId !== null) {
this.win_.webContents.send('window-focused', joplinId);
}
};
const addWindowEventHandlers = (webContents: WebContents) => {
// will-frame-navigate is fired by clicking on a link within the BrowserWindow.
webContents.on('will-frame-navigate', event => {
@@ -376,13 +384,10 @@ export default class ElectronAppWrapper {
addWindowEventHandlers(event.webContents);
});
webContents.on('focus', () => {
const joplinId = this.windowIdFromWebContents(webContents);
if (joplinId !== null) {
this.win_.webContents.send('window-focused', joplinId);
}
});
const onFocus = () => {
sendWindowFocused(webContents);
};
webContents.on('focus', onFocus);
};
addWindowEventHandlers(this.win_.webContents);
@@ -454,6 +459,10 @@ export default class ElectronAppWrapper {
this.win_.close();
}
});
if (window.isFocused()) {
sendWindowFocused(window.webContents);
}
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied