fix: disable ctrl+alt+(left/right) shortcut on linux

This commit is contained in:
Fabio Di Stasio 2022-07-21 11:01:10 +02:00
parent 8c83b3f144
commit 8ecaedbf6c
2 changed files with 34 additions and 12 deletions

View File

@ -2,38 +2,57 @@ interface ShortcutRecord {
event: string;
keys: Electron.Accelerator[];
description: string;
os: NodeJS.Platform[];
}
const shortcuts: ShortcutRecord[] = [
{
event: 'open-new-tab',
keys: ['CommandOrControl+T'],
description: 'Open a new query tab'
description: 'Open a new query tab',
os: ['darwin', 'linux', 'win32']
},
{
event: 'close-tab',
keys: ['CommandOrControl+W'],
description: 'Close tab'
description: 'Close tab',
os: ['darwin', 'linux', 'win32']
},
{
event: 'next-tab',
keys: ['Alt+CommandOrControl+Right', 'CommandOrControl+PageDown'],
description: 'Next tab'
description: 'Next tab',
os: ['darwin', 'win32']
},
{
event: 'prev-tab',
keys: ['Alt+CommandOrControl+Left', 'CommandOrControl+PageUp'],
description: 'Previous tab'
description: 'Previous tab',
os: ['darwin', 'win32']
},
{
event: 'next-tab',
keys: ['CommandOrControl+PageDown'],
description: 'Next tab',
os: ['linux']
},
{
event: 'prev-tab',
keys: ['CommandOrControl+PageUp'],
description: 'Previous tab',
os: ['linux']
},
{
event: 'open-connections-modal',
keys: ['Shift+CommandOrControl+Space'],
description: 'Show all connections'
description: 'Show all connections',
os: ['darwin', 'linux', 'win32']
},
{
event: 'toggle-console',
keys: ['CommandOrControl+F12', 'CommandOrControl+`'],
description: 'Toggle console'
description: 'Toggle console',
os: ['darwin', 'linux', 'win32']
}
];
@ -42,7 +61,8 @@ for (let i = 1; i <= 9; i++) {
{
event: `select-tab-${i}`,
keys: [`CommandOrControl+${i}`],
description: `Select tab number ${i}`
description: `Select tab number ${i}`,
os: ['darwin', 'linux', 'win32']
});
}

View File

@ -147,11 +147,13 @@ else {
app.on('browser-window-focus', () => {
// Send registered shortcut events to window
for (const shortcut of shortcuts) {
for (const key of shortcut.keys) {
globalShortcut.register(key, () => {
mainWindow.webContents.send(shortcut.event);
if (isDevelopment) console.log('EVENT:', shortcut);
});
if (shortcut.os.includes(process.platform)) {
for (const key of shortcut.keys) {
globalShortcut.register(key, () => {
mainWindow.webContents.send(shortcut.event);
if (isDevelopment) console.log('EVENT:', shortcut);
});
}
}
}