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

[Feature Request] High DPI support #5

Open
Tim-Paik opened this issue Aug 3, 2021 · 3 comments
Open

[Feature Request] High DPI support #5

Tim-Paik opened this issue Aug 3, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@Tim-Paik
Copy link

Tim-Paik commented Aug 3, 2021

High-resolution screen users need support, the demo now looks very vague (Windows11 125% zoom)
image

@jchv
Copy link
Owner

jchv commented Aug 3, 2021

This is a bit confounding because DPI awareness is per-process on Windows. For example, go-webview2 will magically work fine with high DPI if you do:

	dll := syscall.MustLoadDLL("user32")
	if proc, err := dll.FindProc("SetProcessDpiAwarenessContext"); err == nil {
		aware := -4
		proc.Call(uintptr(aware))
	}

…but it will also impact everything else in process too, so doing this automatically may not be desirable.

The same can be accomplished using manifests as well.

Since this feature is really about making better Win32 apps with Go, maybe there can be some kind of helper package or recommended boilerplate that helps you get an ideal binary with backwards-compatible DPI awareness.

@jchv jchv added the enhancement New feature or request label Aug 3, 2021
@Tim-Paik
Copy link
Author

Tim-Paik commented Aug 3, 2021

This can indeed become clear, but the window will be smaller than when the system is zoomed, and the content will not be zoomed.
I think this feature should work out of the box

@jchv
Copy link
Owner

jchv commented Aug 3, 2021

Hmm? This method should work just fine. Try doing it in init() to ensure it occurs early enough.

I understand that it would be nice to have it be automatic, but even if this library does have this method it has to be optional. Otherwise, it would make the library unusable for users using any other Win32 code that is not DPI aware. I apologize for the inconvenience.

(Also, calls to SetProcessDpiAwarenessContext require Windows 10 1703. You can get DPI awareness on older Windows versions, but it works differently. When it comes to display scaling on Windows, there's enough nuance to fill a small book!)

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

No branches or pull requests

2 participants