Skip to content

Commit 2d29676

Browse files
committed
nw2: fix window events
Fix nwjs#7368
1 parent a4ed444 commit 2d29676

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/resources/api_nw_newwin.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ function NWWindow(cWindow) {
9292
self.cWindow.height = w.height;
9393

9494
if (oldState != 'minimized' && w.state == 'minimized') {
95-
dispatchEventIfExists(self, 'onMinimized');
95+
dispatchEventIfExists(self, 'onMinimized', [w.id]);
9696
} else if (oldState != 'maximized' && w.state == 'maximized') {
97-
dispatchEventIfExists(self, 'onMaximized');
97+
dispatchEventIfExists(self, 'onMaximized', [w.id]);
9898
} else if (oldState != 'fullscreen' && w.state == 'fullscreen') {
99-
dispatchEventIfExists(self, 'onFullscreen');
99+
dispatchEventIfExists(self, 'onFullscreen', [w.id]);
100100
} else if (oldState != 'normal' && w.state == 'normal') {
101-
dispatchEventIfExists(self, 'onRestore');
101+
dispatchEventIfExists(self, 'onRestore', [w.id]);
102102
} else if (oldWidth != w.width || oldHeight != w.height) {
103-
dispatchEventIfExists(self, 'onResized', [w.width, w.height]);
103+
dispatchEventIfExists(self, 'onResized', [w.id, w.width, w.height]);
104104
}
105105
}
106106
privates(this).menu = null;
@@ -254,7 +254,12 @@ NWWindow.prototype.on = function (event, callback, record) {
254254
break;
255255
}
256256
if (nwWinEventsMap.hasOwnProperty(event)) {
257-
this[nwWinEventsMap[event]].addListener(wrap());
257+
let cb = wrap(function(id, ...args) {
258+
if (id != self.cWindow.id)
259+
return;
260+
callback.call(self, ...args);
261+
});
262+
this[nwWinEventsMap[event]].addListener(cb);
258263
return this;
259264
}
260265
return this;

0 commit comments

Comments
 (0)