Wrong dpi

On my Mac Mini I have an ASUS screen with (according to the specs) a resolution of 1920x1054 and a pixel size of 0.272mm.
These numbers make sense as my screen width is approx. 52.5cm with 1920 x 0.272 = 522 mm (to be compared to 52.5cm measured) while my screen height is approx.29 cm with 1054 x 0.272 = 287mm which is close enough to what I should measure.
So far so good. This yields to a confirmed pixel resolution of 25.4 / 0.272 = 93.4 dpi.

However when I call the following methods:

        double dpi = Desktop::getInstance().getDisplays().getMainDisplay().dpi;

        double scale = Desktop::getInstance().getDisplays().getMainDisplay().scale;

I get dpi = 72 and scale = 1.

Am I doing something wrong, or is it the screen that does not return the right dpi value to the system or what ?

Any help appreciated.


P.S. the setGlobalFactor is an awesome feature but I need the right dpi to calculate the right factor for it to be useful.

Can the OS even get the physical DPI from a monitor? I wouldn't have expected it to always be correct, and 72 is probably a default fallback value.

Ah! OK .


I am not sure how to use the setGlobalScaleFactor then. The idea is to have the same app window size on all platforms. Pixel width and heights obviously are not sufficient for that.

It's very unlikely you'll ever achieve that. Even if some OSes and some graphics drivers and some monitors manage to get the number right, there will always be ones that don't.