[Development] resolution independence (was Re: Retina display support)

Samuel Rødal samuel.rodal at digia.com
Wed Oct 3 11:57:38 CEST 2012


On 10/03/2012 12:10 AM, Andreas Holzammer wrote:

> I can only add that the reported physical dpi for windows are not the
> real physical. They report what the user has set in windows for it, or
> better to say it defaults to 96 dpi. There seems to be no api from
> windows to find out the actual api, in x11 you are able to get it
> somehow with some head stands. I also know that it is not so easy in mac
> os x to get it. So very unpleasant these days of touch times. Really sad.
> In windows I found a very ugly way to determine the dpi of a screen,
> where I did a implementation for kde:
> http://quickgit.kde.org/index.php?p=kdepim-runtime.git&a=blob&h=8a17d1d77ae22022cc5436a49cb7be7fa1fe8145&hb=b68e55a2eedd410b9c6a8ca1df63276afe18afe2&f=qml%2Fkde%2Fkdeintegration.cpp
> This looks in the registry for the copied edid data of the physical
> display and then decodes its physical screen size.

The Windows platform plugin in Qt 5 does this to get the physical size 
(from which QScreen computes the physical DPI):

data.physicalSizeMM = QSizeF(GetDeviceCaps(hdc, HORZSIZE), 
GetDeviceCaps(hdc, VERTSIZE));

Does this not give the actual physical size?

For the logical DPI we do:

return QDpi(GetDeviceCaps(hdc, LOGPIXELSX), GetDeviceCaps(hdc, LOGPIXELSY));

The xcb platform plugin gets the physical size from RANDR.

Currently the cocoa platform plugin computes the physical size based on 
the resolution and a hard-coded dpi of 72, which naturally will not give 
the correct results.

--
Samuel



More information about the Development mailing list