From 1c48160a6b9336b426d99200ad0c1d66002bf2cb Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Fri, 10 Nov 2017 16:12:45 +0100 Subject: fix(macOS): Fix the need for the High Pref GPU --- src/index.js | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/index.js b/src/index.js index f0fe56ae5..efb3be737 100644 --- a/src/index.js +++ b/src/index.js @@ -11,8 +11,8 @@ import Settings from './electron/Settings'; import { appId } from './package.json'; // eslint-disable-line import/no-unresolved import './electron/exception'; -// Keep a global reference of the window object, if you don't, the window will -// be closed automatically when the JavaScript object is garbage collected. +// Keep a global reference of the window object, if you don't, the window will +// be closed automatically when the JavaScript object is garbage collected. let mainWindow; let willQuitApp = false; @@ -37,6 +37,9 @@ if (isSecondInstance) { app.exit(); } +// Lets disable Hardware Acceleration until we have a better solution +// to deal with the high-perf-gpu requirement of some services +app.disableHardwareAcceleration(); // Initialize Settings const settings = new Settings(); @@ -48,8 +51,8 @@ const createWindow = async () => { defaultHeight: 600, }); - // Create the browser window. - mainWindow = new BrowserWindow({ + // Create the browser window. + mainWindow = new BrowserWindow({ x: mainWindowState.x, y: mainWindowState.y, width: mainWindowState.width, @@ -73,16 +76,16 @@ const createWindow = async () => { // and load the index.html of the app. mainWindow.loadURL(`file://${__dirname}/index.html`); - // Open the DevTools. + // Open the DevTools. if (isDevMode) { mainWindow.webContents.openDevTools(); } - - // Emitted when the window is closed. + + // Emitted when the window is closed. mainWindow.on('close', (e) => { - // Dereference the window object, usually you would store windows - // in an array if your app supports multi windows, this is the time - // when you should delete the corresponding element. + // Dereference the window object, usually you would store windows + // in an array if your app supports multi windows, this is the time + // when you should delete the corresponding element. if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) { e.preventDefault(); if (isWindows) { @@ -142,20 +145,20 @@ const createWindow = async () => { shell.openExternal(url); }); }; - -// This method will be called when Electron has finished -// initialization and is ready to create browser windows. -// Some APIs can only be used after this event occurs. -app.on('ready', createWindow); - -// Quit when all windows are closed. -app.on('window-all-closed', () => { - // On OS X it is common for applications and their menu bar - // to stay active until the user quits explicitly with Cmd + Q + +// This method will be called when Electron has finished +// initialization and is ready to create browser windows. +// Some APIs can only be used after this event occurs. +app.on('ready', createWindow); + +// Quit when all windows are closed. +app.on('window-all-closed', () => { + // On OS X it is common for applications and their menu bar + // to stay active until the user quits explicitly with Cmd + Q if (settings.get('runInBackground') === undefined || settings.get('runInBackground')) { - app.quit(); - } + app.quit(); + } }); app.on('before-quit', () => { -- cgit v1.2.3-70-g09d2