Skip to content

Commit f467fbc

Browse files
committed
main.addon.WindowPosition: resize logic #1464
1 parent 4020f63 commit f467fbc

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

src/Main.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,16 @@ class Main extends core.Base {
424424
/**
425425
* Move a popup window
426426
* @param {Object} data
427-
* @param {Number} data.height
428-
* @param {Number} data.width
427+
* @param {Number} [data.height]
428+
* @param {Number} [data.width]
429429
* @param {String} data.windowName
430430
*/
431431
windowResizeTo(data) {
432-
this.openWindows[data.windowName].resizeTo(data.width, data.height);
432+
let win = this.openWindows[data.windowName],
433+
height = data.height || win.outerHeight,
434+
width = data.width || win.outerWidth;
435+
436+
win.resizeTo(width, height);
433437
}
434438
}
435439

src/main/addon/WindowPosition.mjs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class WindowPosition extends Base {
6565
me.screenTop = win.screenTop;
6666

6767
win.addEventListener('mouseout', me.onMouseOut.bind(me));
68+
win.addEventListener('resize', me.onResize.bind(me));
6869
}
6970

7071
/**
@@ -149,6 +150,37 @@ class WindowPosition extends Base {
149150
}
150151
}
151152

153+
/**
154+
*
155+
* @param {Object} event
156+
*/
157+
onResize(event) {
158+
let me = this,
159+
winData = Neo.Main.getWindowData(),
160+
height, width;
161+
162+
Object.entries(me.windows).forEach(([key, value]) => {
163+
switch (value.dock) {
164+
case 'bottom':
165+
case 'top':
166+
width = winData.outerWidth;
167+
break;
168+
case 'left':
169+
case 'right':
170+
height = winData.outerHeight - 28;
171+
break;
172+
}
173+
174+
Neo.Main.windowResizeTo({
175+
height : height,
176+
width : width,
177+
windowName: key
178+
});
179+
});
180+
181+
me.adjustPositions(winData);
182+
}
183+
152184
/**
153185
*
154186
* @param {Object} data

0 commit comments

Comments
 (0)