File tree Expand file tree Collapse file tree 3 files changed +21
-8
lines changed
Expand file tree Collapse file tree 3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 11module . exports = {
2- ALWAYSONTOP_WILL_CLOSE : 'will-close'
2+ ALWAYSONTOP_WILL_CLOSE : 'will-close' ,
3+ SIZE : {
4+ width : 320 ,
5+ height : 180
6+ }
37} ;
Original file line number Diff line number Diff line change 11const os = require ( 'os' ) ;
22const electron = require ( 'electron' ) ;
33const { 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.
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ const { EventEmitter } = require('events');
55const os = require ( 'os' ) ;
66const 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 } ;
You can’t perform that action at this time.
0 commit comments