fix mac os issue of darwinForceToQuit not being defined

This commit is contained in:
Johannes Millan 2017-08-16 11:51:10 +02:00
parent 38b8c9b711
commit dd453f72bd
2 changed files with 11 additions and 6 deletions

View file

@ -5,12 +5,14 @@ const url = require('url');
const open = require('open');
let mainWin;
function createWindow(params) {
const IS_DEV = params.IS_DEV;
const ICONS_FOLDER = params.ICONS_FOLDER;
const IS_MAC = params.IS_MAC;
const quitApp = params.quitApp;
const app = params.app;
const nestedWinParams = params.nestedWinParams;
let frontendDir;
@ -37,7 +39,7 @@ function createWindow(params) {
// Open the DevTools.
//mainWin.webContents.openDevTools();
initWinEventListeners(app, IS_MAC);
initWinEventListeners(app, IS_MAC, nestedWinParams);
if (IS_MAC) {
createMenu(quitApp);
@ -46,7 +48,7 @@ function createWindow(params) {
return mainWin;
}
function initWinEventListeners(app, IS_MAC) {
function initWinEventListeners(app, IS_MAC, nestedWinParams) {
// open new window links in browser
mainWin.webContents.on('new-window', function (event, url) {
event.preventDefault();
@ -56,7 +58,7 @@ function initWinEventListeners(app, IS_MAC) {
mainWin.on('close', function (event) {
// handle darwin
if (IS_MAC) {
if (!darwinForceQuit) {
if (!nestedWinParams.isDarwinForceQuit) {
event.preventDefault();
mainWin.hide();
}

View file

@ -25,7 +25,7 @@ const app = electron.app;
let mainWin;
let lastIdleTime;
let currentIdleStart;
let darwinForceQuit = false;
let nestedWinParams = { isDarwinForceQuit: false };
// keep app active to keep time tracking running
powerSaveBlocker.start('prevent-app-suspension');
@ -48,7 +48,7 @@ if (shouldQuitBecauseAppIsAnotherInstance) {
app.on('ready', createMainWin);
app.on('ready', createIndicator);
app.on('activate', function () {
app.on('activate', function() {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWin === null) {
@ -65,7 +65,7 @@ app.on('ready', () => {
app.on('before-quit', () => {
// handle darwin
if (IS_MAC) {
darwinForceQuit = true;
nestedWinParams.isDarwinForceQuit = true;
}
// un-register all shortcuts.
@ -110,6 +110,7 @@ function createIndicator() {
ICONS_FOLDER,
});
}
function createMainWin() {
mainWin = mainWinMod.createWindow({
app,
@ -117,6 +118,7 @@ function createMainWin() {
ICONS_FOLDER,
IS_MAC,
quitApp,
nestedWinParams
});
}
@ -151,6 +153,7 @@ function showIdleDialog(idleTimeInMs) {
function showApp() {
showOrFocus(mainWin);
}
function quitApp() {
app.isQuiting = true;
app.quit();