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>
bb10
Friedemann Kleint 2016-01-08 17:12:50 +01:00
parent f830102918
commit 644441eed3
3 changed files with 21 additions and 4 deletions

View File

@ -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())

View File

@ -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;

View File

@ -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);
}