liballeg / allegro5

The official Allegro 5 git repository. Pull requests welcome!
https://liballeg.org
Other
1.82k stars 281 forks source link

Investigate Windows DPI scaling #1273

Open SiegeLord opened 3 years ago

SiegeLord commented 3 years ago

See complaints here https://www.allegro.cc/forums/thread/618454. We explicitly support windows DPI scaling, but perhaps we missed a spot with window placement.

SiegeLord commented 3 years ago

The issue appears to be that al_get_monitor_info does not reflect the scaling factor, while al_set_window_position does. When DPI awareness is disabled, this means that al_set_window_position will be getting values that are too large, causing the window to be placed too far down/right.

This appears to be consistent with OSX, so no problem there. It seems the solution here is to provide a separate al_get_monitor_info that reports the size of the virtual display.

SiegeLord commented 3 years ago

Actually, I am not so sure about OSX. The key question is whether toggling DPI awareness alters the values returned by al_get_monitor_info. If it does, then we should fix Windows.

Felix-The-Ghost commented 2 years ago

Any further developments on this?

SiegeLord commented 2 years ago

I tried this on OSX, and in apps which declare themselves as not high resolution capable, the al_get_monitor_info returns the virtual monitor sizes, so it sounds like we should fix this in the same context on Windows.

fatcerberus commented 2 years ago

I've never had a problem on Windows regularly using 125%, 150%, even 200% scaling, but I do have a long-standing issue on macOS, see #923.

SiegeLord commented 2 years ago

Heh, okay that's good to know. If we take the perspective of #923, then Windows behavior is fine and OSX is the one that's broken. We just need to decide whether al_get_monitor_info is affected by scaling and whether al_set_window_position is affected by scaling. This also has to be decided in cases where the app wants the OS to scale it, or it is scaling aware. Honestly, I don't understand why you'd want to write a scaling-unaware app in 2021, so I'd be willing to not spend effort on that use case.

I think the best solution is (for scaling aware apps) for both of those to use raw pixels. This is how it works in Windows, but as per #923 its broken on OSX. We should fix that.

fatcerberus commented 2 years ago

One key difference between Windows and OSX scaling IIRC is, I don't think it's always possible to use "raw pixels" on Mac because the OS can scale it back down after rendering the screen at a higher resolution. Windows never does this to my knowledge.

pedro-w commented 2 years ago

I know #923 is something on my list to sort out but I still have been struggling to find time for it; I thought it was nearly there but there are more ramifications than I realised at the time. And knowing what the cross-platform 'ideal' is will be helpful. On MacOS, the original retina screens were just 2X (and I have hardware for this) but as Bruce says, in later models they have a 2X (or 3X?) then scale down a non-integral amount to the true pixel resolution. So it would seem impossible to draw pixels which map to screen pixels - except I did see some references to setting the backing resolution independently per View, somewhere.