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( const result = globalShortcut.register(
translatedShortcut, translatedShortcut,
cls.wrap(() => { cls.wrap(() => {
if (!mainWindow) { const targetWindow = getLastFocusedWindow() || mainWindow;
if (!targetWindow) {
return; return;
} }
// window may be hidden / not in focus // window may be hidden / not in focus
mainWindow.focus(); targetWindow.focus();
mainWindow.webContents.send("globalShortcut", action.actionName); targetWindow.webContents.send("globalShortcut", action.actionName);
}) })
); );