mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-28 09:51:06 -06:00
Electron-470 (Add a new boolean check whether to activate main window) (#361)
- Add a new boolean check whether to activate main window - update params to object
This commit is contained in:
parent
6a782efa25
commit
0a66fc90f2
@ -287,7 +287,10 @@ function getTemplate(app) {
|
||||
checked: isAlwaysOnTop,
|
||||
click: (item) => {
|
||||
isAlwaysOnTop = item.checked;
|
||||
eventEmitter.emit('isAlwaysOnTop', isAlwaysOnTop);
|
||||
eventEmitter.emit('isAlwaysOnTop', {
|
||||
isAlwaysOnTop,
|
||||
shouldActivateMainWindow: true
|
||||
});
|
||||
updateConfigField('alwaysOnTop', isAlwaysOnTop);
|
||||
}
|
||||
});
|
||||
@ -374,7 +377,10 @@ function setCheckboxValues() {
|
||||
break;
|
||||
case 'alwaysOnTop':
|
||||
isAlwaysOnTop = configData[key];
|
||||
eventEmitter.emit('isAlwaysOnTop', configData[key]);
|
||||
eventEmitter.emit('isAlwaysOnTop', {
|
||||
isAlwaysOnTop: configData[key],
|
||||
shouldActivateMainWindow: true
|
||||
});
|
||||
break;
|
||||
case 'notificationSettings':
|
||||
eventEmitter.emit('notificationSettings', configData[key]);
|
||||
|
@ -70,7 +70,10 @@ class ScreenSnippet {
|
||||
if (windows && windows.length > 0) {
|
||||
isAlwaysOnTop = windows[ 0 ].isAlwaysOnTop();
|
||||
if (isAlwaysOnTop) {
|
||||
eventEmitter.emit('isAlwaysOnTop', false);
|
||||
eventEmitter.emit('isAlwaysOnTop', {
|
||||
isAlwaysOnTop: false,
|
||||
shouldActivateMainWindow: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,7 +90,10 @@ class ScreenSnippet {
|
||||
child = childProcess.execFile(captureUtil, captureUtilArgs, (error) => {
|
||||
// Method to reset always on top feature
|
||||
if (isAlwaysOnTop) {
|
||||
eventEmitter.emit('isAlwaysOnTop', true);
|
||||
eventEmitter.emit('isAlwaysOnTop', {
|
||||
isAlwaysOnTop: true,
|
||||
shouldActivateMainWindow: false
|
||||
});
|
||||
}
|
||||
// will be called when child process exits.
|
||||
if (error && error.killed) {
|
||||
|
@ -747,9 +747,10 @@ function openUrlInDefaultBrowser(urlToOpen) {
|
||||
|
||||
/**
|
||||
* Called when an event is received from menu
|
||||
* @param boolean weather to enable or disable alwaysOnTop.
|
||||
* @param {boolean} boolean whether to enable or disable alwaysOnTop.
|
||||
* @param {boolean} shouldActivateMainWindow whether to activate main window
|
||||
*/
|
||||
function isAlwaysOnTop(boolean) {
|
||||
function isAlwaysOnTop(boolean, shouldActivateMainWindow = true) {
|
||||
alwaysOnTop = boolean;
|
||||
let browserWins = BrowserWindow.getAllWindows();
|
||||
if (browserWins.length > 0) {
|
||||
@ -761,16 +762,16 @@ function isAlwaysOnTop(boolean) {
|
||||
|
||||
// An issue where changing the alwaysOnTop property
|
||||
// focus the pop-out window
|
||||
// Issue - Electron-209
|
||||
if (mainWindow && mainWindow.winName) {
|
||||
// Issue - Electron-209/470
|
||||
if (mainWindow && mainWindow.winName && shouldActivateMainWindow) {
|
||||
activate(mainWindow.winName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// node event emitter to update always on top
|
||||
eventEmitter.on('isAlwaysOnTop', (boolean) => {
|
||||
isAlwaysOnTop(boolean);
|
||||
eventEmitter.on('isAlwaysOnTop', (params) => {
|
||||
isAlwaysOnTop(params.isAlwaysOnTop, params.shouldActivateMainWindow);
|
||||
});
|
||||
|
||||
// node event emitter for notification settings
|
||||
|
Loading…
Reference in New Issue
Block a user