Skip to content

Commit

Permalink
nw2: fix window events
Browse files Browse the repository at this point in the history
Fix #7368
  • Loading branch information
rogerwang committed Feb 23, 2020
1 parent a4ed444 commit 2d29676
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/resources/api_nw_newwin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2d29676

Please sign in to comment.