Skip to content

Setting browser window position causes incorrect default window options to be set #345

@ddaspit

Description

@ddaspit
  • Version: 5.30.1
  • Target: Windows 10

If the X and Y properties are set when creating a browser window, then some of the default values for properties in BrowserWindowOptions are set incorrectly. The most noticeable issue is that the default font size is no longer correct (16) and set to a very small value (6). This occurs because the CreateWindowAsync method in WindowManager disables ignoring default values during serialization when X and Y are set. Many of the primitive properties in BrowserWindowOptions and WebPreferences (such as DefaultFontSize) do not have the correct default values set. A possible solution might be to re-enable ignoring default values and adding [DefaultValue(-1)] attribute to the X and Y properties in BrowserWindowOptions.

Also, when setting the position of the window on Windows 10, CreateWindowAsync subtracts 7 from the X property. This seems to be added to correct for a bug in Electron. On my Windows 10 machine, this results in the window being incorrectly positioned too far to the left. For example, if I set the X to 0, a small amount of the left side of the window is off of the screen. If I set X to 7, the window is positioned exactly on the left side of the screen. It might be worth checking if the Electron bug is still an issue. Right now, I have to add 7 to X in order to get the correct position.

Steps to Reproduce:

  1. Set X and Y in the BrowserWindowOptions when calling CreateWindowAsync.
  2. Start the app.
  3. The default font size is too small in the browser window.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions