electron: [Bug]: `BrowserWindow.getBounds()` cannot be restored as they were in this case with multiple monitors and differing scale levels

Preflight Checklist

Electron Version

12.0.10

What operating system are you using?

Windows

Operating System Version

Windows 10, version 19043

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

A window can be asked for getBounds and be restored with these values when restarting to preserve the location on screen.

Actual Behavior

The window restores wrongly.

Testcase Gist URL

https://github.com/electron/electron/files/6624616/Archive.zip

Additional Information

Steps:

  • attach a laptop with screen resolution 2560x1440 and 150% scale to an external monitor with 2560x1440 resolution and 100% scale
  • configure displays to extend and not copy the desktop (primary monitor is laptop left and secondary monitor is external right)
  • run a simple hello world fiddle to opens a window
  • instrument the code to console.log(mainWindow.getBounds()) e.g. from a setInterval
  • move the window to the second monitor right corner so that it snaps and split in half of the screen size
  • close the window
  • note the x, y, width and height values printed
  • start the fiddle again, this time setting x, y, width and height values in the creation options

=> 🐛 the window does not appear as it was before

This does not reproduce when the 150% scaling is turned off on the laptop so it seems to be related to the fact that one display has scaling turned on while the other does not.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 21 (10 by maintainers)

Most upvoted comments

Still not fixed as of Electron 20. Many users in production complaining about DPI affecting their window states. Possibly related: https://github.com/electron/electron/issues/10862#issuecomment-1369198257