Fix #59 Fullscreen goes to a black screen when clicking close

This commit is contained in:
Jia Hao 2016-01-23 14:47:32 +08:00
parent aa384dc317
commit 40da693cb5
1 changed files with 14 additions and 5 deletions

View File

@ -92,15 +92,24 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
setDockBadge('');
});
mainWindow.on('close', (e) => {
if (isOSX()) {
// this is called when exiting from clicking the cross button on the window
e.preventDefault();
mainWindow.hide();
mainWindow.on('close', event => {
if (mainWindow.isFullScreen()) {
mainWindow.setFullScreen(false);
mainWindow.once('leave-full-screen', maybeHideWindow.bind(this, mainWindow, event));
}
maybeHideWindow(mainWindow, event)
});
return mainWindow;
}
function maybeHideWindow(window, event) {
if (isOSX()) {
// this is called when exiting from clicking the cross button on the window
event.preventDefault();
window.hide();
}
// will close the window on other platforms
}
module.exports = createMainWindow;