Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4K Screen DPI awareness #97

Closed
AnonymousII opened this issue Aug 21, 2024 · 2 comments
Closed

4K Screen DPI awareness #97

AnonymousII opened this issue Aug 21, 2024 · 2 comments

Comments

@AnonymousII
Copy link
Contributor

AnonymousII commented Aug 21, 2024

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

@DubbleClick
Copy link
Member

Hi Andreas,

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

@AnonymousII
Copy link
Contributor Author

AnonymousII commented Aug 22, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants