Skip to content

Commit

Permalink
Fix focus when closing app on macos (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
whitecrownclown authored and sindresorhus committed Oct 31, 2019
1 parent ea8015e commit ed75400
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,23 +295,24 @@ function createMainWindow(): BrowserWindow {
// Workaround for https://github.com/electron/electron/issues/20263
// Closing the app window when on full screen leaves a black screen
// Exit fullscreen before closing
if (is.macos) {
if (mainWindow.isFullScreen()) {
mainWindow.once('leave-full-screen', () => {
mainWindow.hide();
});
mainWindow.setFullScreen(false);
} else {
if (is.macos && mainWindow.isFullScreen()) {
mainWindow.once('leave-full-screen', () => {
mainWindow.hide();
}
});
mainWindow.setFullScreen(false);
}

if (!isQuitting) {
e.preventDefault();

// Workaround for https://github.com/electron/electron/issues/10023
win.blur();
win.hide();
if (is.macos) {
// On macOS we're using `app.hide()` in order to focus the previous window correctly
app.hide();
} else {
win.hide();
}
}
});

Expand Down

0 comments on commit ed75400

Please sign in to comment.