2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2025-01-24 07:38:36 +00:00

Merge branch 'upstream' into feature/window-state-manager

This commit is contained in:
zweicoder 2016-01-23 15:20:21 +08:00
parent 26ce134de8
commit b6862d0c06

View File

@ -31,6 +31,7 @@ function createMainWindow(options, {quit: onAppQuit, dock}) {
height: mainWindowState.height, height: mainWindowState.height,
x: mainWindowState.x, x: mainWindowState.x,
y: mainWindowState.y, y: mainWindowState.y,
title: options.name,
'web-preferences': { 'web-preferences': {
javascript: true, javascript: true,
plugins: true, plugins: true,
@ -100,17 +101,25 @@ function createMainWindow(options, {quit: onAppQuit, dock}) {
setDockBadge(''); setDockBadge('');
}); });
mainWindow.on('close', (e) => { mainWindow.on('close', event => {
if (isOSX()) { if (mainWindow.isFullScreen()) {
// this is called when exiting from clicking the cross button on the window mainWindow.setFullScreen(false);
e.preventDefault(); mainWindow.once('leave-full-screen', maybeHideWindow.bind(this, mainWindow, event));
mainWindow.hide();
} }
maybeHideWindow(mainWindow, event)
}); });
mainWindowState.manage(mainWindow); mainWindowState.manage(mainWindow);
return mainWindow; 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; module.exports = createMainWindow;