Skip to content

Commit e94ac4b

Browse files
committed
newwin: move and resize event
1 parent 36ed2a7 commit e94ac4b

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/resources/api_nw_newwin.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ var appWinEventsMap = {
5555
'maximize': 'onMaximized',
5656
'restore': 'onRestored',
5757
'enter-fullscreen': 'onFullscreened',
58-
'closed': 'onClosed',
59-
'move': 'onMoved',
60-
'resize': 'onResized'
58+
'closed': 'onClosed'
6159
};
6260

6361
var nwWinEventsMap = {
@@ -72,8 +70,10 @@ var nwWrapEventsMap = {
7270
};
7371

7472
var wrapEventsMapNewWin = {
75-
'focus': 'onFocusChanged',
76-
'blur': 'onFocusChanged'
73+
'resize': 'onResize',
74+
'move': 'onMove',
75+
'focus': 'onFocusChanged',
76+
'blur': 'onFocusChanged'
7777
};
7878

7979
nw_internal.registerCustomHook(function(bindingsAPI) {
@@ -239,17 +239,21 @@ NWWindow.prototype.on = function (event, callback, record) {
239239
this.onNavigation.addListener(j);
240240
break;
241241
case 'move':
242-
var k = wrap(function() {
243-
callback.call(self, self.x, self.y);
242+
var k = wrap(function(w) {
243+
if (w.id != self.cWindow.id)
244+
return;
245+
callback.call(self, w.left, w.top);
244246
});
245-
this.appWindow.onMoved.addListener(k);
247+
chrome.windows.onMove.addListener(k);
246248
return this; //return early
247249
break;
248250
case 'resize':
249-
var l = wrap(function() {
250-
callback.call(self, self.width, self.height);
251+
var l = wrap(function(w) {
252+
if (w.id != self.cWindow.id)
253+
return;
254+
callback.call(self, w.width, w.height);
251255
});
252-
this.appWindow.onResized.addListener(l);
256+
chrome.windows.onResize.addListener(l);
253257
return this; //return early
254258
break;
255259
}

0 commit comments

Comments
 (0)