summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-01-08 17:12:50 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-01-08 22:04:28 +0000
commit644441eed3997bc8cf7cfe5b4f56adee6e232ffd (patch)
treeef1bfebcf79e5109d1252e0ebb7693ef10d93f0d /src/plugins/platforms/windows
parentf8301029183a0ff653243d932b135405adee20b0 (diff)
Windows: Output resulting DPI awareness in debug and warning output.
Fix the signature of QWindowsShcoreDLL::GetProcessDpiAwareness and output the value in the warning about failures of SetProcessDpiAwareness and in debug output. Failures occur when Qt is embedded into another application, for example Active Qt servers. Task-number: QTBUG-41186 Task-number: QTBUG-50206 Change-Id: I3fd6cba26826ee8bbfa0a34f129deb64797c947f Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp19
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.h3
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp3
3 files changed, 21 insertions, 4 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index f2f6402889..4934b6c6e4 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -405,14 +405,29 @@ void QWindowsContext::setTabletAbsoluteRange(int a)
#endif
}
+int QWindowsContext::processDpiAwareness()
+{
+#ifndef Q_OS_WINCE
+ int result;
+ if (QWindowsContext::shcoredll.getProcessDpiAwareness
+ && SUCCEEDED(QWindowsContext::shcoredll.getProcessDpiAwareness(NULL, &result))) {
+ return result;
+ }
+#endif // !Q_OS_WINCE
+ return -1;
+}
+
void QWindowsContext::setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiAwareness)
{
#ifndef Q_OS_WINCE
qCDebug(lcQpaWindows) << __FUNCTION__ << dpiAwareness;
if (QWindowsContext::shcoredll.isValid()) {
const HRESULT hr = QWindowsContext::shcoredll.setProcessDpiAwareness(dpiAwareness);
- if (FAILED(hr))
- qWarning() << "SetProcessDpiAwareness failed:" << QWindowsContext::comErrorString(hr);
+ if (FAILED(hr)) {
+ qWarning().noquote().nospace() << "SetProcessDpiAwareness("
+ << dpiAwareness << ") failed: " << QWindowsContext::comErrorString(hr)
+ << ", using " << QWindowsContext::processDpiAwareness();
+ }
} else {
if (dpiAwareness != QtWindows::ProcessDpiUnaware && QWindowsContext::user32dll.setProcessDPIAware) {
if (!QWindowsContext::user32dll.setProcessDPIAware())
diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h
index d08fc8f726..14baec96d8 100644
--- a/src/plugins/platforms/windows/qwindowscontext.h
+++ b/src/plugins/platforms/windows/qwindowscontext.h
@@ -148,7 +148,7 @@ struct QWindowsShcoreDLL {
void init();
inline bool isValid() const { return getProcessDpiAwareness && setProcessDpiAwareness && getDpiForMonitor; }
- typedef HRESULT (WINAPI *GetProcessDpiAwareness)(HANDLE,int);
+ typedef HRESULT (WINAPI *GetProcessDpiAwareness)(HANDLE,int *);
typedef HRESULT (WINAPI *SetProcessDpiAwareness)(int);
typedef HRESULT (WINAPI *GetDpiForMonitor)(HMONITOR,int,UINT *,UINT *);
@@ -219,6 +219,7 @@ public:
void setTabletAbsoluteRange(int a);
void setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiAwareness);
+ static int processDpiAwareness();
// Returns a combination of SystemInfoFlags
unsigned systemInfo() const;
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 55e6d55e5b..bd2014b8f2 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -224,7 +224,8 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList &paramL
dpiAwarenessSet = true;
}
qCDebug(lcQpaWindows)
- << __FUNCTION__ << "DpiAwareness=" << dpiAwareness;
+ << __FUNCTION__ << "DpiAwareness=" << dpiAwareness
+ << "effective process DPI awareness=" << QWindowsContext::processDpiAwareness();
m_context.initTouch(m_options);
}