Skip to content

Commit

Permalink
gui: Hide dock icon on macOS by default (#2086)
Browse files Browse the repository at this point in the history
Recent changes in Electron might have altered the behavior of
`Window.setVisibleOnAllWorkspaces()` effectively making the app icon in
the macOS dock show whenever we create a new window and call this
function (e.g. the Tray window which is hidden by default).

Besides, it seems that displaying an Electron app icon in the dock
prevents the OS from shutting down, displaying an error message to the
user inviting them to force-kill the application.

Since we don't need to show our windows on all workspaces (we only want
it displayed on the workspace it was opened from) we can stop using
this function and thus kill two birds with one stone by preventing
unexpected icons in the dock and leaving the OS shutdown correctly.
  • Loading branch information
taratatach authored May 6, 2021
1 parent 1a47e75 commit eaf5351
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 0 additions & 2 deletions gui/js/window_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ module.exports = class WindowManager {
}
})

this.win.setVisibleOnAllWorkspaces(true)

// noMenu
this.win.setMenu(null)
this.win.setAutoHideMenuBar(true)
Expand Down
10 changes: 4 additions & 6 deletions gui/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,13 +505,11 @@ app.on('open-file', async (event, filePath) => {
})

app.on('ready', async () => {
// Once configured and running in the tray, the app doesn't need to be
// visible anymore in macOS dock (and cmd+tab), even when the tray popover
// is visible, until another window shows up.
// Once configured and running in the tray, the app doesn't need to be visible
// anymore in macOS dock (and cmd+tab), even when the tray popover is visible,
// until another window shows up.
if (process.platform === 'darwin') {
setTimeout(() => {
app.dock.hide()
}, 1000)
app.dock.hide()
}

const { session } = require('electron')
Expand Down

0 comments on commit eaf5351

Please sign in to comment.