File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -60,11 +60,19 @@ app.on('ready', function() {
6060 }
6161
6262 function showWindow ( trayPos ) {
63- // Thanks to https://github.com/maxogden/menubar/
64- // Default the window to the right if `trayPos` bounds are undefined or null.
63+ var screen = require ( 'screen' ) ;
64+ var cursorPointer = screen . getCursorScreenPoint ( ) ;
65+ var displaySize = screen . getPrimaryDisplay ( ) . workAreaSize ;
66+ var x = ( cursorPointer . x < ( displaySize . width / 2 ) ) ? 'left' : 'right' ;
67+ var y = ( cursorPointer . y < ( displaySize . height / 2 ) ) ? 'top' : 'bottom' ;
68+
6569 var noBoundsPosition ;
66- if ( trayPos === undefined || trayPos . x === 0 ) {
67- noBoundsPosition = ( process . platform === 'win32' ) ? 'bottomRight' : 'topRight' ;
70+ if ( x === 'right' && y === 'bottom' ) {
71+ noBoundsPosition = ( isWindows ) ? 'trayBottomCenter' : 'bottomRight' ;
72+ } else if ( x === 'left' && y === 'bottom' ) {
73+ noBoundsPosition = 'bottomLeft' ;
74+ } else if ( y === 'top' ) {
75+ noBoundsPosition = ( isWindows ) ? 'trayCenter' : 'topRight' ;
6876 }
6977
7078 var position = appIcon . positioner . calculate ( noBoundsPosition || windowPosition , trayPos ) ;
You can’t perform that action at this time.
0 commit comments