aboutsummaryrefslogtreecommitdiffstats
path: root/src/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js55
1 files changed, 30 insertions, 25 deletions
diff --git a/src/index.js b/src/index.js
index f0fe56ae5..6a08e5e5a 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,25 +37,30 @@ 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
42
43// Disabled to test tweetdeck glitches
44// app.disableHardwareAcceleration();
40 45
41// Initialize Settings 46// Initialize Settings
42const settings = new Settings(); 47const settings = new Settings();
43 48
44const createWindow = async () => { 49const createWindow = () => {
45 // Remember window size 50 // Remember window size
46 const mainWindowState = windowStateKeeper({ 51 const mainWindowState = windowStateKeeper({
47 defaultWidth: 800, 52 defaultWidth: 800,
48 defaultHeight: 600, 53 defaultHeight: 600,
49 }); 54 });
50 55
51 // Create the browser window. 56 // Create the browser window.
52 mainWindow = new BrowserWindow({ 57 mainWindow = new BrowserWindow({
53 x: mainWindowState.x, 58 x: mainWindowState.x,
54 y: mainWindowState.y, 59 y: mainWindowState.y,
55 width: mainWindowState.width, 60 width: mainWindowState.width,
56 height: mainWindowState.height, 61 height: mainWindowState.height,
57 minWidth: 800, 62 minWidth: 600,
58 minHeight: 600, 63 minHeight: 500,
59 titleBarStyle: 'hidden', 64 titleBarStyle: 'hidden',
60 backgroundColor: '#3498db', 65 backgroundColor: '#3498db',
61 autoHideMenuBar: true, 66 autoHideMenuBar: true,
@@ -73,16 +78,16 @@ const createWindow = async () => {
73 // and load the index.html of the app. 78 // and load the index.html of the app.
74 mainWindow.loadURL(`file://${__dirname}/index.html`); 79 mainWindow.loadURL(`file://${__dirname}/index.html`);
75 80
76 // Open the DevTools. 81 // Open the DevTools.
77 if (isDevMode) { 82 if (isDevMode) {
78 mainWindow.webContents.openDevTools(); 83 mainWindow.webContents.openDevTools();
79 } 84 }
80 85
81 // Emitted when the window is closed. 86 // Emitted when the window is closed.
82 mainWindow.on('close', (e) => { 87 mainWindow.on('close', (e) => {
83 // Dereference the window object, usually you would store windows 88 // Dereference the window object, usually you would store windows
84 // in an array if your app supports multi windows, this is the time 89 // in an array if your app supports multi windows, this is the time
85 // when you should delete the corresponding element. 90 // when you should delete the corresponding element.
86 if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) { 91 if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) {
87 e.preventDefault(); 92 e.preventDefault();
88 if (isWindows) { 93 if (isWindows) {
@@ -142,20 +147,20 @@ const createWindow = async () => {
142 shell.openExternal(url); 147 shell.openExternal(url);
143 }); 148 });
144}; 149};
145 150
146// This method will be called when Electron has finished 151// This method will be called when Electron has finished
147// initialization and is ready to create browser windows. 152// initialization and is ready to create browser windows.
148// Some APIs can only be used after this event occurs. 153// Some APIs can only be used after this event occurs.
149app.on('ready', createWindow); 154app.on('ready', createWindow);
150 155
151// Quit when all windows are closed. 156// Quit when all windows are closed.
152app.on('window-all-closed', () => { 157app.on('window-all-closed', () => {
153 // On OS X it is common for applications and their menu bar 158 // On OS X it is common for applications and their menu bar
154 // to stay active until the user quits explicitly with Cmd + Q 159 // to stay active until the user quits explicitly with Cmd + Q
155 if (settings.get('runInBackground') === undefined 160 if (settings.get('runInBackground') === undefined
156 || settings.get('runInBackground')) { 161 || settings.get('runInBackground')) {
157 app.quit(); 162 app.quit();
158 } 163 }
159}); 164});
160 165
161app.on('before-quit', () => { 166app.on('before-quit', () => {