Skip to content

Commit 109b135

Browse files
horymuryhristoterezov
authored andcommitted
Fix window resize issue on window move
electron/electron#9477
1 parent 1cf8882 commit 109b135

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

alwaysontop/constants.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
module.exports = {
2-
ALWAYSONTOP_WILL_CLOSE: 'will-close'
2+
ALWAYSONTOP_WILL_CLOSE: 'will-close',
3+
SIZE: {
4+
width: 320,
5+
height: 180
6+
}
37
};

alwaysontop/main.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
const os = require('os');
22
const electron = require('electron');
33
const { BrowserWindow, ipcMain } = electron;
4-
5-
const SIZE = {
6-
width: 320,
7-
height: 180
8-
};
4+
const { SIZE } = require('./constants');
95

106
/**
117
* The coordinates(x and y) of the always on top window.

alwaysontop/render.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { EventEmitter } = require('events');
55
const os = require('os');
66
const path = require('path');
77

8-
const { ALWAYSONTOP_WILL_CLOSE } = require('./constants');
8+
const { ALWAYSONTOP_WILL_CLOSE, SIZE } = require('./constants');
99

1010
/**
1111
* Returieves and trying to parse a numeric value from the local storage.
@@ -257,9 +257,22 @@ class AlwaysOnTop extends EventEmitter {
257257
* this we'll implement drag ourselves.
258258
*/
259259
shouldImplementDrag: os.type() !== 'Darwin',
260+
/**
261+
* Custom implementation for window move.
262+
* We use setBounds in order to preserve the initial size of the window
263+
* during drag. This is in order to fix:
264+
* https://github.com/electron/electron/issues/9477
265+
* @param x
266+
* @param y
267+
*/
260268
move: (x, y) => {
261269
if (this._alwaysOnTopBrowserWindow) {
262-
this._alwaysOnTopBrowserWindow.setPosition(x, y);
270+
this._alwaysOnTopBrowserWindow.setBounds({
271+
x,
272+
y,
273+
width: SIZE.width,
274+
height: SIZE.height
275+
});
263276
}
264277
}
265278
};

0 commit comments

Comments
 (0)