Skip to content

Commit

Permalink
Show window if hidden when second instance attempts to start (#1897)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg committed Dec 14, 2017
1 parent 8a919ef commit 5cf320e
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,33 @@ const config = require("./app/config");
// userData directory.
const userConfig = require('./app/user_config');

function showWindow() {
// Using focus() instead of show() seems to be important on Windows when our window
// has been docked using Aero Snap/Snap Assist. A full .show() call here will cause
// the window to reposition:
// https://github.com/WhisperSystems/Signal-Desktop/issues/1429
if (mainWindow.isVisible()) {
mainWindow.focus();
} else {
mainWindow.show();
}

// toggle the visibility of the show/hide tray icon menu entries
if (tray) {
tray.updateContextMenu();
}
}

if (!process.mas) {
console.log('making app single instance');
var shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) {
// Someone tried to run a second instance, we should focus our window
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
if (mainWindow.isMinimized()) {
mainWindow.restore();
}

showWindow();
}
return true;
});
Expand Down Expand Up @@ -280,20 +300,7 @@ function createWindow () {
});

ipc.on('show-window', function() {
// Using focus() instead of show() seems to be important on Windows when our window
// has been docked using Aero Snap/Snap Assist. A full .show() call here will cause
// the window to reposition:
// https://github.com/WhisperSystems/Signal-Desktop/issues/1429
if (mainWindow.isVisible()) {
mainWindow.focus();
} else {
mainWindow.show();
}

// toggle the visibility of the show/hide tray icon menu entries
if (tray) {
tray.updateContextMenu();
}
showWindow();
});
}

Expand Down

0 comments on commit 5cf320e

Please sign in to comment.