diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-04-30 11:26:43 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-30 22:43:49 +0200 |
commit | 2e44a9e4918cd6d9d7f33f61330c456249dd9b0f (patch) | |
tree | a4f81644f729077ff54c4b9617a7ae9577b5d435 /src/plugins/platforms/windows/qwindowsscreen.cpp | |
parent | ae7bbe34005d704f0c1fd3ca0335095c1df48cde (diff) |
Windows: Start using High DPI API available from Windows 8.1 onwards.
Dynamically load shcore.dll, use SetProcessDpiAwareness() instead
of SetProcessDPIAware() when available. Add command line parameter
to control level.
Task-number: QTBUG-37347
Change-Id: I1259b0943b41e50066e7e3870ed3136afd8f18fe
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsscreen.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsscreen.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index a6e2aabaf0..4d6b822793 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -68,6 +68,21 @@ static inline QDpi deviceDPI(HDC hdc) return QDpi(GetDeviceCaps(hdc, LOGPIXELSX), GetDeviceCaps(hdc, LOGPIXELSY)); } +#ifndef Q_OS_WINCE + +static inline QDpi monitorDPI(HMONITOR hMonitor) +{ + if (QWindowsContext::shcoredll.isValid()) { + UINT dpiX; + UINT dpiY; + if (SUCCEEDED(QWindowsContext::shcoredll.getDpiForMonitor(hMonitor, 0, &dpiX, &dpiY))) + return QDpi(dpiX, dpiY); + } + return QDpi(0, 0); +} + +#endif // !Q_OS_WINCE + static inline QSizeF deviceSizeMM(const QSize &pixels, const QDpi &dpi) { const qreal inchToMM = 25.4; @@ -110,7 +125,12 @@ BOOL QT_WIN_CALLBACK monitorEnumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM HDC hdc = CreateDC(info.szDevice, NULL, NULL, NULL); #endif if (hdc) { +#ifndef Q_OS_WINCE + const QDpi dpi = monitorDPI(hMonitor); + data.dpi = dpi.first ? dpi : deviceDPI(hdc); +#else data.dpi = deviceDPI(hdc); +#endif data.depth = GetDeviceCaps(hdc, BITSPIXEL); data.format = data.depth == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32; data.physicalSizeMM = QSizeF(GetDeviceCaps(hdc, HORZSIZE), GetDeviceCaps(hdc, VERTSIZE)); |