mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-03 21:25:13 +00:00
Setting browser window position causes incorrect default window options to be set #421
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ddaspit on GitHub (Nov 29, 2019).
Originally assigned to: @GregorBiswanger on GitHub.
If the
XandYproperties are set when creating a browser window, then some of the default values for properties inBrowserWindowOptionsare 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 theCreateWindowAsyncmethod inWindowManagerdisables ignoring default values during serialization whenXandYare set. Many of the primitive properties inBrowserWindowOptionsandWebPreferences(such asDefaultFontSize) 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 theXandYproperties inBrowserWindowOptions.Also, when setting the position of the window on Windows 10,
CreateWindowAsyncsubtracts 7 from theXproperty. 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 theXto0, a small amount of the left side of the window is off of the screen. If I setXto7, 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 add7toXin order to get the correct position.Steps to Reproduce:
XandYin theBrowserWindowOptionswhen callingCreateWindowAsync.@GregorBiswanger commented on GitHub (Dec 3, 2019):
I have tried it with the latest Electron.NET version (7.30.2). For me, the window position works and the font stays in the default size.
@ddaspit commented on GitHub (Dec 4, 2019):
I forked and updated the music player sample app to demonstrate the issue. I set the


XandYproperties to0in the issue345 branch. With theXandYproperties set, I get:Without the
XandYproperties set (the master branch), I get:@GregorBiswanger commented on GitHub (May 10, 2020):
Fixed and use the new Electron.NET 8.31.1.
@duncanawoods commented on GitHub (Aug 13, 2020):
@GregorBiswanger I'm seeing this problem in 9.31.2.0. If I set the browser window size, fonts using rem become tiny. Can you please point me towards the cause and the commit that fixed it last time and I'll try to fix it?
@duncanawoods commented on GitHub (Aug 13, 2020):
@GregorBiswanger The problem in
WindowManager.cs, if the position is set then it uses a different serialiser for the BrowserWindowOptions:However, not all default values are set:
Setting this value seems to fix the issue but we need to 100% certain all the option defaults are correct.