gwdevhub/gwlauncher

4K Screen DPI awareness

Closed this issue · 2 comments

Hi,

when starting GWLauncher (latest release) on my Win10 PC with 4K Screen Resolution (225% scaling), after clicking the tray icon to get to the main form and launch an account, the MainForm shows up in the bottom right corner of the rightmost screen, just a few pixels above the task bar so I cannot see the account list - therefore I need to drag the window into position manually every time I click the tray icon:

Screen

I've been debugging GWLauncher a bit to identify the issue - it seems in MainForm.cs Method NotifyIcon_MouseClick the problem is that Windows reads wrong values for the primary Screen object (e.g. Screen.PrimaryScreen.Bounds) beause GWLauncher is not set as DPIAware (see https://stackoverflow.com/questions/36089452/problems-with-screen-resolution-displaying-on-4k )

For me the problem seems to be fixed by setting the DPI-Awareness to application level (PROCESS_PER_MONITOR_DPI_AWARE, see StackOverflow answer):
This allows the Screen Object to read the correct resolution - however this also affects the scaling of the main form which would need some adaptions as well:

Screen2

Therefore the issue would probably require a few more adjustments to fix the HighDPI scaling properly.

Thanks and kind regards,
Andreas

Hi Andreas,

as I do not have access to 4k screens at the moment, would you mind creating a PR for this?

Hi,

sure I just created the PR #98 .

As changing the application to DPI-awareness would require a major redesign of the GUI and Forms I circumvented this by manually calculating the scaling factor and taking it into account for the calculations in MainForm::NotifyIcon_MouseClick (tested on scale factors 100% - 225%, works perfectly fine) and also added a final check to shift the window back on screen if the bottom right corner is off screen by previous calculations.

Note: This change will be fully transparent for anyone not using screen scaling ( X/1 = X*1 = X, so old calculations remain unchanged here)

Just let me know if you're fine with merging this PR or need any further adjustments.

By the way: You probably don't need a 4K screen to replicate the issue, it's probably sufficient to set screen scaling under System -> Screen: Scaling to any value above 100% (however I tested on a 4K screen)

Kind regards,
Andreas