max-mapper / menubar

➖ high level way to create menubar desktop applications with electron
BSD 2-Clause "Simplified" License
6.64k stars 363 forks source link

Incorrect position on multiple monitor #435

Closed kaiserdj closed 1 week ago

kaiserdj commented 1 year ago

Description

When I create a new menubar instance, it is generated in the center (between the two screens) but instead later when I open it from the menuTray it opens correctly and even when I click on the menubar to open the menu. Then it is always displayed correctly.

Steps to Reproduce the Problem

https://user-images.githubusercontent.com/5487950/226194574-78fb6a9b-4a14-44f9-a2e6-f941ab7e313c.mp4

Expected Behaviour

Position of the menubar according to the monitor where the application is.

Actual Behaviour

When opened the menubar is displayed in the center between the two monitors

Specifications

Other information

kaiserdj commented 1 year ago

Workaround while fixing this bug (probably due to Win11) https://github.com/kaiserdj/Darkorbit-client/commit/bf68ebe7444755f6447988158fe40a8cd0d8a3ef

Basically I install the "electron-positioner" library and force the position:

const Positioner = require('electron-positioner');
var positioner = new Positioner(mb.window)
if(mb.getOption("windowPosition") == "trayBottomCenter" && process.platform == "win32") {
     positioner. move('bottomRight');
}