mirror of
https://github.com/zadam/trilium.git
synced 2025-11-10 08:29:00 +01:00
Send global shortcut to current window (#7645)
This commit is contained in:
commit
051e2b4eef
@ -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 || targetWindow.isDestroyed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// window may be hidden / not in focus
|
// window may be hidden / not in focus
|
||||||
mainWindow.focus();
|
showAndFocusWindow(targetWindow);
|
||||||
|
|
||||||
mainWindow.webContents.send("globalShortcut", action.actionName);
|
targetWindow.webContents.send("globalShortcut", action.actionName);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -358,6 +359,17 @@ async function registerGlobalShortcuts() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showAndFocusWindow(window: BrowserWindow) {
|
||||||
|
if (!window) return;
|
||||||
|
|
||||||
|
if (window.isMinimized()) {
|
||||||
|
window.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
window.show();
|
||||||
|
window.focus();
|
||||||
|
}
|
||||||
|
|
||||||
function getMainWindow() {
|
function getMainWindow() {
|
||||||
return mainWindow;
|
return mainWindow;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user