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:
parent
5e07dd5442
commit
3c3b14bf09
@ -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()
|
||||
})
|
||||
|
@ -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
|
||||
|
@ -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:')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user