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

Menubar window is incorrectly positioned when opened while the tray icon is hidden on Windows #438

Open leolabs opened 1 year ago

leolabs commented 1 year ago

Description

I'm working on an app that runs in the menubar and opens its window on launch. This works well when the tray icon is visible on Windows, but when it isn't, the window is incorrectly positioned as if it was horizontally centered around x=0. Pinning the tray icon to the tray area solves the problem but it still looks weird to first-time users.

https://user-images.githubusercontent.com/541628/227804777-9f70354c-297a-4ca9-bf76-e884efea9148.mp4

Steps to Reproduce the Problem

I instantiated menubar with these settings:

const mb = menubar({
  preloadWindow: true,
  icon: `AppIcon.png`, // abridged for brevity
  index: "http://localhost:3009/",
  browserWindow: {
    width: 420,
    height: 460,
    resizable: false,
    vibrancy: "popover",
  },
});

mb.on("ready", () => {
  mb.showWindow();
});

Expected Behaviour

When the tray icon's position is unknown, the window should be positioned on the bottom right as a fallback.

Actual Behaviour

The window is partially hidden on the bottom left of the screen.

Specifications

kaiserdj commented 1 year ago

Here is a way to work around the problem temporarily until the bug is fixed: https://github.com/maxogden/menubar/issues/435#issuecomment-1581628798