add reusable showAndFocusWindow function

This commit is contained in:
contributor 2025-11-07 21:15:35 +02:00
parent 9a5f2f8d3b
commit f629f564cd

View File

@ -343,11 +343,7 @@ async function registerGlobalShortcuts() {
}
// window may be hidden / not in focus
if (targetWindow.isMinimized()) {
targetWindow.restore();
}
targetWindow.show();
targetWindow.focus();
showAndFocusWindow(targetWindow);
targetWindow.webContents.send("globalShortcut", action.actionName);
})
@ -363,6 +359,17 @@ async function registerGlobalShortcuts() {
}
}
function showAndFocusWindow(window: BrowserWindow) {
if (!window) return;
if (window.isMinimized()) {
window.restore();
}
window.show();
window.focus();
}
function getMainWindow() {
return mainWindow;
}