mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
@@ -87,6 +87,22 @@ function createAPI() {
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Allows JS to register a callback to be invoked when size/positions
|
||||
* changes for any pop-out window (i.e., window.open). The main
|
||||
* process will emit IPC event 'boundsChange' (see below). Currently
|
||||
* only one window can register for bounds change.
|
||||
* @param {Function} callback Function invoked when bounds changes.
|
||||
*/
|
||||
registerBoundsChange: function(callback) {
|
||||
if (typeof callback === 'function') {
|
||||
local.boundsChangeCallback = callback;
|
||||
local.ipcRenderer.send(apiName, {
|
||||
cmd: apiCmds.registerBoundsChange
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* allows JS to register a logger that can be used by electron main process.
|
||||
* @param {Object} logger function that can be called accepting
|
||||
@@ -94,9 +110,6 @@ function createAPI() {
|
||||
* logLevel: 'ERROR'|'CONFLICT'|'WARN'|'ACTION'|'INFO'|'DEBUG',
|
||||
* logDetails: String
|
||||
* }
|
||||
*
|
||||
* note: only main window is allowed to register a logger, others are
|
||||
* ignored.
|
||||
*/
|
||||
registerLogger: function(logger) {
|
||||
if (typeof logger === 'function') {
|
||||
@@ -119,6 +132,20 @@ function createAPI() {
|
||||
}
|
||||
});
|
||||
|
||||
// listen for notifications that some window size/position has changed
|
||||
local.ipcRenderer.on('boundsChange', (event, arg) => {
|
||||
if (local.boundsChangeCallback && arg.windowName &&
|
||||
arg.x && arg.y && arg.width && arg.height) {
|
||||
local.boundsChangeCallback({
|
||||
x: arg.x,
|
||||
y: arg.y,
|
||||
width: arg.width,
|
||||
height: arg.height,
|
||||
windowName: arg.windowName
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Use render process to create badge count img and send back to main process.
|
||||
* If number is greater than 99 then 99+ img is returned.
|
||||
|
||||
Reference in New Issue
Block a user