liballeg / allegro5

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

Functions to query the monitor DPI/DPI change events #560

Open SiegeLord opened 8 years ago

SiegeLord commented 8 years ago

This seems like a very useful feature, and has been asked for for a good time now. For Windows, see https://msdn.microsoft.com/en-us/library/windows/desktop/dn469266%28v=vs.85%29.aspx and https://msdn.microsoft.com/en-us/library/windows/desktop/dn312083%28v=vs.85%29.aspx.

elias-pschernig commented 7 years ago

On android you can use getResources().getDisplayMetrics().densityDpi (from Java): https://developer.android.com/reference/android/util/DisplayMetrics.html

fatcerberus commented 6 years ago

I for one would really like to see this implemented. Pig Slayer (my main desktop) has a 4K monitor set at 200% scale for which my usual scaling algorithm produces too-small windows. Since I can't query the DPI my only other option was to base scaling on desktop resolution, which means I now have absolutely massive windows in many cases.

I could easily make a pull to add an API to query the current DPI, but I only have experience in Windows, so I wouldn't know what to do for other platforms. I guess we could have the function return a default value, e.g. 96 dpi, for platforms where DPI awareness is not (yet) supported.

t-mw commented 4 years ago

Partially fixed by #913? Although dpi change events or a way to get the current display adapter for a window would still be useful, since afaict there's no way of knowing the dpi after moving a window between multiple physical monitors.