aboutsummaryrefslogtreecommitdiffstats
path: root/src/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js80
1 files changed, 57 insertions, 23 deletions
diff --git a/src/index.js b/src/index.js
index 830166dcf..75da4ff88 100644
--- a/src/index.js
+++ b/src/index.js
@@ -46,35 +46,69 @@ if (isWindows) {
46} 46}
47 47
48// Force single window 48// Force single window
49const isSecondInstance = app.makeSingleInstance((argv) => { 49const gotTheLock = app.requestSingleInstanceLock();
50 if (mainWindow) { 50if (!gotTheLock) {
51 if (mainWindow.isMinimized()) mainWindow.restore(); 51 app.quit();
52 mainWindow.focus(); 52} else {
53 app.on('second-instance', (event, argv) => {
54 // Someone tried to run a second instance, we should focus our window.
55 if (mainWindow) {
56 if (mainWindow.isMinimized()) mainWindow.restore();
57 mainWindow.focus();
53 58
54 if (process.platform === 'win32') { 59 if (isWindows) {
55 // Keep only command line / deep linked arguments 60 // Keep only command line / deep linked arguments
56 const url = argv.slice(1); 61 const url = argv.slice(1);
57 62
58 if (url) { 63 if (url) {
59 handleDeepLink(mainWindow, url.toString()); 64 handleDeepLink(mainWindow, url.toString());
65 }
60 } 66 }
61 }
62 }
63 67
64 if (argv.includes('--reset-window')) { 68 if (argv.includes('--reset-window')) {
65 // Needs to be delayed to not interfere with mainWindow.restore(); 69 // Needs to be delayed to not interfere with mainWindow.restore();
66 setTimeout(() => { 70 setTimeout(() => {
67 debug('Resetting windows via Task'); 71 debug('Resetting windows via Task');
68 mainWindow.setPosition(DEFAULT_WINDOW_OPTIONS.x + 100, DEFAULT_WINDOW_OPTIONS.y + 100); 72 mainWindow.setPosition(DEFAULT_WINDOW_OPTIONS.x + 100, DEFAULT_WINDOW_OPTIONS.y + 100);
69 mainWindow.setSize(DEFAULT_WINDOW_OPTIONS.width, DEFAULT_WINDOW_OPTIONS.height); 73 mainWindow.setSize(DEFAULT_WINDOW_OPTIONS.width, DEFAULT_WINDOW_OPTIONS.height);
70 }, 1); 74 }, 1);
71 } 75 }
72}); 76 }
77 });
73 78
74if (isSecondInstance) { 79 // Create myWindow, load the rest of the app, etc...
75 console.log('An instance of Franz is already running. Exiting...'); 80 app.on('ready', () => {
76 app.exit(); 81 });
77} 82}
83// const isSecondInstance = app.makeSingleInstance((argv) => {
84// if (mainWindow) {
85// if (mainWindow.isMinimized()) mainWindow.restore();
86// mainWindow.focus();
87
88// if (process.platform === 'win32') {
89// // Keep only command line / deep linked arguments
90// const url = argv.slice(1);
91
92// if (url) {
93// handleDeepLink(mainWindow, url.toString());
94// }
95// }
96// }
97
98// if (argv.includes('--reset-window')) {
99// // Needs to be delayed to not interfere with mainWindow.restore();
100// setTimeout(() => {
101// debug('Resetting windows via Task');
102// mainWindow.setPosition(DEFAULT_WINDOW_OPTIONS.x + 100, DEFAULT_WINDOW_OPTIONS.y + 100);
103// mainWindow.setSize(DEFAULT_WINDOW_OPTIONS.width, DEFAULT_WINDOW_OPTIONS.height);
104// }, 1);
105// }
106// });
107
108// if (isSecondInstance) {
109// console.log('An instance of Franz is already running. Exiting...');
110// app.exit();
111// }
78 112
79// Fix Unity indicator issue 113// Fix Unity indicator issue
80// https://github.com/electron/electron/issues/9046 114// https://github.com/electron/electron/issues/9046