handle toggleTray global shortcut differently from other global shortcuts #7730

This commit is contained in:
contributor 2025-11-14 11:15:28 +02:00
parent 5dd21ac539
commit d69dd2a83f

View File

@ -6,6 +6,7 @@ import optionService from "./options.js";
import log from "./log.js";
import sqlInit from "./sql_init.js";
import cls from "./cls.js";
import { KeyboardActionNames } from "@triliumnext/commons";
import keyboardActionsService from "./keyboard_actions.js";
import electron from "electron";
import type { App, BrowserWindowConstructorOptions, BrowserWindow, WebContents, IpcMainEvent } from "electron";
@ -319,6 +320,7 @@ function closeSetupWindow() {
}
async function registerGlobalShortcuts() {
const toggleTrayAction: KeyboardActionNames = "toggleTray";
const { globalShortcut } = await import("electron");
await sqlInit.dbReady;
@ -342,8 +344,11 @@ async function registerGlobalShortcuts() {
return;
}
// window may be hidden / not in focus
if (action.actionName === toggleTrayAction) {
targetWindow.focus();
} else {
showAndFocusWindow(targetWindow);
}
targetWindow.webContents.send("globalShortcut", action.actionName);
})