1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-27 10:42:35 +03:00

Smarted spawn hotkey behaviour on macOS to give the focus to the previous app on hide

This commit is contained in:
Eugene Pankov 2018-03-24 23:40:45 +01:00
parent 5e07dd5442
commit 3c3b14bf09
4 changed files with 8 additions and 12 deletions

View File

@ -56,14 +56,6 @@ setupWindowManagement = () => {
app.window.focus()
})
electron.ipcMain.on('window-toggle-focus', () => {
if (app.window.isFocused()) {
app.window.minimize()
} else {
app.window.focus()
}
})
electron.ipcMain.on('window-maximize', () => {
app.window.maximize()
})

View File

@ -130,11 +130,13 @@ export class AppRootComponent {
onGlobalHotkey () {
if (this.electron.app.window.isFocused()) {
// focused
this.electron.loseFocus()
this.electron.app.window.hide()
} else {
if (!this.electron.app.window.isVisible()) {
// unfocused, invisible
this.electron.app.window.show()
this.electron.app.window.focus()
} else {
if (this.config.store.appearance.dock === 'off') {
// not docked, visible

View File

@ -33,4 +33,10 @@ export class ElectronService {
remoteRequirePluginModule (plugin: string, module: string, globals: any): any {
return this.remoteRequire(globals.require.resolve(`${plugin}/node_modules/${module}`))
}
loseFocus () {
if (process.platform === 'darwin') {
this.remote.Menu.sendActionToFirstResponder('hide:')
}
}
}

View File

@ -86,10 +86,6 @@ export class HostAppService {
this.electron.ipcRenderer.send('window-focus')
}
toggleWindow () {
this.electron.ipcRenderer.send('window-toggle-focus')
}
minimize () {
this.electron.ipcRenderer.send('window-minimize')
}