aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/index.js47
1 files changed, 25 insertions, 22 deletions
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';
11import { appId } from './package.json'; // eslint-disable-line import/no-unresolved 11import { appId } from './package.json'; // eslint-disable-line import/no-unresolved
12import './electron/exception'; 12import './electron/exception';
13 13
14// Keep a global reference of the window object, if you don't, the window will 14// Keep a global reference of the window object, if you don't, the window will
15// be closed automatically when the JavaScript object is garbage collected. 15// be closed automatically when the JavaScript object is garbage collected.
16let mainWindow; 16let mainWindow;
17let willQuitApp = false; 17let willQuitApp = false;
18 18
@@ -37,6 +37,9 @@ if (isSecondInstance) {
37 app.exit(); 37 app.exit();
38} 38}
39 39
40// Lets disable Hardware Acceleration until we have a better solution
41// to deal with the high-perf-gpu requirement of some services
42app.disableHardwareAcceleration();
40 43
41// Initialize Settings 44// Initialize Settings
42const settings = new Settings(); 45const settings = new Settings();
@@ -48,8 +51,8 @@ const createWindow = async () => {
48 defaultHeight: 600, 51 defaultHeight: 600,
49 }); 52 });
50 53
51 // Create the browser window. 54 // Create the browser window.
52 mainWindow = new BrowserWindow({ 55 mainWindow = new BrowserWindow({
53 x: mainWindowState.x, 56 x: mainWindowState.x,
54 y: mainWindowState.y, 57 y: mainWindowState.y,
55 width: mainWindowState.width, 58 width: mainWindowState.width,
@@ -73,16 +76,16 @@ const createWindow = async () => {
73 // and load the index.html of the app. 76 // and load the index.html of the app.
74 mainWindow.loadURL(`file://${__dirname}/index.html`); 77 mainWindow.loadURL(`file://${__dirname}/index.html`);
75 78
76 // Open the DevTools. 79 // Open the DevTools.
77 if (isDevMode) { 80 if (isDevMode) {
78 mainWindow.webContents.openDevTools(); 81 mainWindow.webContents.openDevTools();
79 } 82 }
80 83
81 // Emitted when the window is closed. 84 // Emitted when the window is closed.
82 mainWindow.on('close', (e) => { 85 mainWindow.on('close', (e) => {
83 // Dereference the window object, usually you would store windows 86 // Dereference the window object, usually you would store windows
84 // in an array if your app supports multi windows, this is the time 87 // in an array if your app supports multi windows, this is the time
85 // when you should delete the corresponding element. 88 // when you should delete the corresponding element.
86 if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) { 89 if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) {
87 e.preventDefault(); 90 e.preventDefault();
88 if (isWindows) { 91 if (isWindows) {
@@ -142,20 +145,20 @@ const createWindow = async () => {
142 shell.openExternal(url); 145 shell.openExternal(url);
143 }); 146 });
144}; 147};
145 148
146// This method will be called when Electron has finished 149// This method will be called when Electron has finished
147// initialization and is ready to create browser windows. 150// initialization and is ready to create browser windows.
148// Some APIs can only be used after this event occurs. 151// Some APIs can only be used after this event occurs.
149app.on('ready', createWindow); 152app.on('ready', createWindow);
150 153
151// Quit when all windows are closed. 154// Quit when all windows are closed.
152app.on('window-all-closed', () => { 155app.on('window-all-closed', () => {
153 // On OS X it is common for applications and their menu bar 156 // On OS X it is common for applications and their menu bar
154 // to stay active until the user quits explicitly with Cmd + Q 157 // to stay active until the user quits explicitly with Cmd + Q
155 if (settings.get('runInBackground') === undefined 158 if (settings.get('runInBackground') === undefined
156 || settings.get('runInBackground')) { 159 || settings.get('runInBackground')) {
157 app.quit(); 160 app.quit();
158 } 161 }
159}); 162});
160 163
161app.on('before-quit', () => { 164app.on('before-quit', () => {