提交 3c3b14bf 编写于 作者: E Eugene Pankov

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

上级 5e07dd54
......@@ -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')
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册