Hide Heynote when global hotkey is pressed if the window is already focused

This commit is contained in:
Jonatan Heyman 2023-12-10 23:44:58 +01:00
parent 9e50446417
commit f8678a91ec

View File

@ -153,9 +153,16 @@ function registerGlobalHotkey() {
if (CONFIG.get("settings.enableGlobalHotkey")) {
try {
const ret = globalShortcut.register(CONFIG.get("settings.globalHotkey"), () => {
app.focus({steal: true})
if (win?.isMinimized()) {
win?.restore()
if (!win) {
return
}
if (win.isFocused()) {
app.hide()
} else {
app.focus({steal: true})
if (win.isMinimized()) {
win.restore()
}
}
})
} catch (error) {