diff --git a/installer/win/Symphony-x64.aip b/installer/win/Symphony-x64.aip old mode 100644 new mode 100755 index a7fbe9ad..1413215f --- a/installer/win/Symphony-x64.aip +++ b/installer/win/Symphony-x64.aip @@ -392,7 +392,7 @@ - + @@ -465,7 +465,7 @@ - + diff --git a/installer/win/Symphony-x86.aip b/installer/win/Symphony-x86.aip old mode 100644 new mode 100755 index 3a6c56f8..d1560922 --- a/installer/win/Symphony-x86.aip +++ b/installer/win/Symphony-x86.aip @@ -375,7 +375,7 @@ - + @@ -450,7 +450,7 @@ - + diff --git a/js/bringToFront.js b/js/bringToFront.js index 74abcbc4..5912273e 100644 --- a/js/bringToFront.js +++ b/js/bringToFront.js @@ -17,7 +17,7 @@ function bringToFront(windowName, reason) { .then((bringToFrontSetting) => { if (typeof bringToFrontSetting === 'boolean' && bringToFrontSetting) { log.send(logLevels.INFO, 'Window has been activated for: ' + reason); - windowMgr.activate(windowName || 'main'); + windowMgr.activate(windowName || 'main', false); } }) .catch((error) => { diff --git a/js/menus/menuTemplate.js b/js/menus/menuTemplate.js index 8752e443..9e1d4d44 100644 --- a/js/menus/menuTemplate.js +++ b/js/menus/menuTemplate.js @@ -266,7 +266,7 @@ function getTemplate(app) { // Window menu -> bringToFront template[index].submenu.push({ - label: 'Bring to Front on Notifications', + label: isWindowsOS ? 'Flash Notification in Taskbar' : 'Bring to Front on Notifications', type: 'checkbox', checked: bringToFront, click: function(item) { diff --git a/js/windowMgr.js b/js/windowMgr.js index 2882a649..5efb2c22 100644 --- a/js/windowMgr.js +++ b/js/windowMgr.js @@ -20,7 +20,7 @@ const notify = require('./notify/electron-notify.js'); const eventEmitter = require('./eventEmitter'); const throttle = require('./utils/throttle.js'); const { getConfigField, updateConfigField, getGlobalConfigField } = require('./config.js'); -const { isMac, isNodeEnv, isWindows10 } = require('./utils/misc'); +const { isMac, isNodeEnv, isWindows10, isWindowsOS } = require('./utils/misc'); const { deleteIndexFolder } = require('./search/search.js'); const { isWhitelisted } = require('./utils/whitelistHandler'); @@ -603,23 +603,35 @@ function setIsOnline(status) { /** * Tries finding a window we have created with given name. If found, then * brings to front and gives focus. - * @param {String} windowName Name of target window. Note: main window has + * @param {String} windowName Name of target window. Note: main window has * name 'main'. + * @param {Boolean} shouldFocus whether to get window to focus or just show + * without giving focus */ -function activate(windowName) { +function activate(windowName, shouldFocus = true) { let keys = Object.keys(windows); for (let i = 0, len = keys.length; i < len; i++) { let window = windows[keys[i]]; if (window && !window.isDestroyed() && window.winName === windowName) { - if (window.isMinimized()) { - window.restore(); - window.focus(); - } else { - window.show(); + + // Flash task bar icon in Windows + if (isWindowsOS && !shouldFocus) { + return window.flashFrame(true); } - return; + + // brings window without giving focus on mac + if (isMac && !shouldFocus) { + return window.showInactive(); + } + + if (window.isMinimized()) { + return window.restore(); + } + + return window.show(); } } + return null; } /** diff --git a/tests/spectron/bringToFront.spectron.js b/tests/spectron/bringToFront.spectron.js index 4f686555..4bfe064d 100644 --- a/tests/spectron/bringToFront.spectron.js +++ b/tests/spectron/bringToFront.spectron.js @@ -1,8 +1,16 @@ const Application = require('./spectronSetup'); -const constants = require('./spectronConstants'); +const bluebird = require('bluebird'); +const { isMac, isWindowsOS } = require('../../js/utils/misc'); +const robot = require('robotjs'); let app = new Application({}); +function blurBrowserWindow() { + robot.setMouseDelay(200); + robot.moveMouse(0, 100); + robot.mouseClick(); +} + describe('Tests for Bring to front', () => { let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; @@ -28,7 +36,7 @@ describe('Tests for Bring to front', () => { } }); - it('should launch the app', (done) => { + it('should launch the app and verify window count', (done) => { return app.client.waitUntilWindowLoaded().then(() => { return app.client.getWindowCount().then((count) => { expect(count === 1).toBeTruthy(); @@ -41,7 +49,7 @@ describe('Tests for Bring to front', () => { }); }); - it('should minimize the app', (done) => { + it('should minimize the app and verify if the window isMinimized', (done) => { return app.browserWindow.minimize().then(() => { return app.browserWindow.isMinimized().then((isMinimized) => { expect(isMinimized).toBeTruthy(); @@ -49,40 +57,62 @@ describe('Tests for Bring to front', () => { }).catch((err) => { done.fail(new Error(`bringToFront failed in isMinimized with error: ${err}`)); }); - }).catch((err) => { - done.fail(new Error(`bringToFront failed in minimize with error: ${err}`)); }); }); - it('should not be focused', (done) => { - return app.browserWindow.isFocused().then((isFocused) => { - expect(isFocused).toBeFalsy(); + it('should restore the browser window and verify window focus', (done) => { + bluebird.all([ + blurBrowserWindow, + app.browserWindow.restore, + app.browserWindow.isMinimized, + app.browserWindow.isFocused, + ]).mapSeries((method) => { + return method(); + }).then((results) => { + if (isMac) { + expect(results[2]).toBe(false); + expect(results[3]).toBe(false); + } + + if (isWindowsOS) { + expect(results[2]).toBe(false); + expect(results[3]).toBe(true); + } done(); }).catch((err) => { - done.fail(new Error(`bringToFront failed in isFocused with error: ${err}`)); + done.fail(new Error(`bringToFront failed to restore with error: ${err}`)); }); }); - it('should maximize browser window', (done) => { - return app.browserWindow.restore().then(() => { + it('should minimize and verify if the window isMinimized again', function () { + return app.browserWindow.minimize().then(() => { return app.browserWindow.isMinimized().then((isMinimized) => { - expect(isMinimized).toBeFalsy(); - done(); + expect(isMinimized).toBeTruthy(); }).catch((err) => { - done.fail(new Error(`bringToFront failed in isMinimized with error: ${err}`)); + done.fail(new Error(`bringToFront failed to minimize with error: ${err}`)); }); - }).catch((err) => { - done.fail(new Error(`bringToFront failed in restore with error: ${err}`)); }); }); - it('should be focused', (done) => { - return app.browserWindow.isFocused().then((isFocused) => { - expect(isFocused).toBeTruthy(); + it('should show the browser window and verify window focus', (done) => { + bluebird.all([ + blurBrowserWindow, + app.browserWindow.showInactive, + app.browserWindow.isFocused + ]).mapSeries((method) => { + return method(); + }).then((results) => { + if (isMac) { + expect(results[2]).toBe(false); + } + + if (isWindowsOS) { + expect(results[2]).toBe(true); + } done(); }).catch((err) => { - done.fail(new Error(`bringToFront failed in isFocused with error: ${err}`)); + done.fail(new Error(`bringToFront failed to focus with error: ${err}`)); }); }); -}); +}); \ No newline at end of file