Skip to content

Commit f93a798

Browse files
committed
fix positioning for Windows and Linux
1 parent 4432c1f commit f93a798

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

main.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)