diff --git a/src/resources/api_nw_newwin.js b/src/resources/api_nw_newwin.js index 0cb8dcfbe7..ab34aaf6bb 100644 --- a/src/resources/api_nw_newwin.js +++ b/src/resources/api_nw_newwin.js @@ -92,15 +92,15 @@ function NWWindow(cWindow) { self.cWindow.height = w.height; if (oldState != 'minimized' && w.state == 'minimized') { - dispatchEventIfExists(self, 'onMinimized'); + dispatchEventIfExists(self, 'onMinimized', [w.id]); } else if (oldState != 'maximized' && w.state == 'maximized') { - dispatchEventIfExists(self, 'onMaximized'); + dispatchEventIfExists(self, 'onMaximized', [w.id]); } else if (oldState != 'fullscreen' && w.state == 'fullscreen') { - dispatchEventIfExists(self, 'onFullscreen'); + dispatchEventIfExists(self, 'onFullscreen', [w.id]); } else if (oldState != 'normal' && w.state == 'normal') { - dispatchEventIfExists(self, 'onRestore'); + dispatchEventIfExists(self, 'onRestore', [w.id]); } else if (oldWidth != w.width || oldHeight != w.height) { - dispatchEventIfExists(self, 'onResized', [w.width, w.height]); + dispatchEventIfExists(self, 'onResized', [w.id, w.width, w.height]); } } privates(this).menu = null; @@ -254,7 +254,12 @@ NWWindow.prototype.on = function (event, callback, record) { break; } if (nwWinEventsMap.hasOwnProperty(event)) { - this[nwWinEventsMap[event]].addListener(wrap()); + let cb = wrap(function(id, ...args) { + if (id != self.cWindow.id) + return; + callback.call(self, ...args); + }); + this[nwWinEventsMap[event]].addListener(cb); return this; } return this;