send global shortcut to current window, not the first one

This commit is contained in:
contributor 2025-11-07 19:55:38 +02:00
parent 71d7403690
commit 44b34d1ea0

View File

@ -337,14 +337,15 @@ async function registerGlobalShortcuts() {
const result = globalShortcut.register(
translatedShortcut,
cls.wrap(() => {
if (!mainWindow) {
const targetWindow = getLastFocusedWindow() || mainWindow;
if (!targetWindow) {
return;
}
// window may be hidden / not in focus
mainWindow.focus();
targetWindow.focus();
mainWindow.webContents.send("globalShortcut", action.actionName);
targetWindow.webContents.send("globalShortcut", action.actionName);
})
);