mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-28 16:58:34 +00:00
throttle global hotkey - fixes #4371
This commit is contained in:
@@ -3,6 +3,7 @@ import * as promiseIpc from 'electron-promise-ipc'
|
|||||||
import * as remote from '@electron/remote/main'
|
import * as remote from '@electron/remote/main'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
|
import { Subject, throttleTime } from 'rxjs'
|
||||||
|
|
||||||
import { loadConfig } from './config'
|
import { loadConfig } from './config'
|
||||||
import { Window, WindowOptions } from './window'
|
import { Window, WindowOptions } from './window'
|
||||||
@@ -19,6 +20,7 @@ export class Application {
|
|||||||
private tray?: Tray
|
private tray?: Tray
|
||||||
private ptyManager = new PTYManager()
|
private ptyManager = new PTYManager()
|
||||||
private windows: Window[] = []
|
private windows: Window[] = []
|
||||||
|
private globalHotkey$ = new Subject<void>()
|
||||||
userPluginsPath: string
|
userPluginsPath: string
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
@@ -33,12 +35,14 @@ export class Application {
|
|||||||
ipcMain.on('app:register-global-hotkey', (_event, specs) => {
|
ipcMain.on('app:register-global-hotkey', (_event, specs) => {
|
||||||
globalShortcut.unregisterAll()
|
globalShortcut.unregisterAll()
|
||||||
for (const spec of specs) {
|
for (const spec of specs) {
|
||||||
globalShortcut.register(spec, () => {
|
globalShortcut.register(spec, () => this.globalHotkey$.next())
|
||||||
this.onGlobalHotkey()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.globalHotkey$.pipe(throttleTime(100)).subscribe(() => {
|
||||||
|
this.onGlobalHotkey()
|
||||||
|
})
|
||||||
|
|
||||||
;(promiseIpc as any).on('plugin-manager:install', (name, version) => {
|
;(promiseIpc as any).on('plugin-manager:install', (name, version) => {
|
||||||
return pluginManager.install(this.userPluginsPath, name, version)
|
return pluginManager.install(this.userPluginsPath, name, version)
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user