summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r--src/plugins/platforms/windows/accessible/comutils.cpp18
-rw-r--r--src/plugins/platforms/windows/accessible/comutils.h7
-rw-r--r--src/plugins/platforms/windows/accessible/iaccessible2.cpp120
-rw-r--r--src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp8
-rw-r--r--src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp20
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp56
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsthreadpoolrunner.h116
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp9
-rw-r--r--src/plugins/platforms/windows/windows.pri3
11 files changed, 265 insertions, 96 deletions
diff --git a/src/plugins/platforms/windows/accessible/comutils.cpp b/src/plugins/platforms/windows/accessible/comutils.cpp
index ac3683f4d5..7655bdf622 100644
--- a/src/plugins/platforms/windows/accessible/comutils.cpp
+++ b/src/plugins/platforms/windows/accessible/comutils.cpp
@@ -64,15 +64,15 @@ static DATE QDateTimeToDATE(const QDateTime &dt)
QDate date = dt.date();
QTime time = dt.time();
if (date.isValid() && !date.isNull()) {
- stime.wDay = date.day();
- stime.wMonth = date.month();
- stime.wYear = date.year();
+ stime.wDay = WORD(date.day());
+ stime.wMonth = WORD(date.month());
+ stime.wYear = WORD(date.year());
}
if (time.isValid() && !time.isNull()) {
- stime.wMilliseconds = time.msec();
- stime.wSecond = time.second();
- stime.wMinute = time.minute();
- stime.wHour = time.hour();
+ stime.wMilliseconds = WORD(time.msec());
+ stime.wSecond = WORD(time.second());
+ stime.wMinute = WORD(time.minute());
+ stime.wHour = WORD(time.hour());
}
double vtime;
@@ -98,8 +98,8 @@ bool QVariant2VARIANT(const QVariant &var, VARIANT &arg, const QByteArray &typeN
proptype = QVariant::Double;
}
if (proptype != QVariant::Invalid && proptype != QVariant::UserType && proptype != qvar.type()) {
- if (qvar.canConvert(proptype))
- qvar.convert(proptype);
+ if (qvar.canConvert(int(proptype)))
+ qvar.convert(int(proptype));
else
qvar = QVariant(proptype);
}
diff --git a/src/plugins/platforms/windows/accessible/comutils.h b/src/plugins/platforms/windows/accessible/comutils.h
index 468bc0e45c..b1e6183a0f 100644
--- a/src/plugins/platforms/windows/accessible/comutils.h
+++ b/src/plugins/platforms/windows/accessible/comutils.h
@@ -53,14 +53,9 @@ class QVariant;
// Originally QVariantToVARIANT copied from ActiveQt - renamed to avoid conflicts in static builds.
bool QVariant2VARIANT(const QVariant &var, VARIANT &arg, const QByteArray &typeName, bool out);
-inline QString BSTRToQString(const BSTR &bstr)
-{
- return QString((QChar*)bstr);
-}
-
inline BSTR QStringToBSTR(const QString &str)
{
- return SysAllocStringLen((OLECHAR*)str.unicode(), str.length());
+ return SysAllocStringLen(reinterpret_cast<const OLECHAR *>(str.unicode()), UINT(str.length()));
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp
index d81044cdda..f34649e327 100644
--- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp
+++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp
@@ -47,8 +47,16 @@
#include <QtGui/qguiapplication.h>
#include <QtCore/qdebug.h>
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
+template <class T>
+static inline T *coTaskMemAllocArray(int size)
+{
+ return static_cast<T *>(::CoTaskMemAlloc(sizeof(T) * size_t(size)));
+}
+
/**************************************************************\
* AccessibleApplication *
**************************************************************/
@@ -58,7 +66,7 @@ HRESULT STDMETHODCALLTYPE AccessibleApplication::QueryInterface(REFIID id, LPVOI
*iface = 0;
if (id == IID_IUnknown) {
qCDebug(lcQpaAccessibility) << "AccessibleApplication::QI(): IID_IUnknown";
- *iface = (IUnknown*)this;
+ *iface = static_cast<IUnknown *>(this);
} else if (id == IID_IAccessibleApplication) {
qCDebug(lcQpaAccessibility) << "AccessibleApplication::QI(): IID_IAccessibleApplication";
*iface = static_cast<IAccessibleApplication*>(this);
@@ -128,7 +136,7 @@ HRESULT STDMETHODCALLTYPE AccessibleRelation::QueryInterface(REFIID id, LPVOID *
{
*iface = 0;
if (id == IID_IUnknown || id == IID_IAccessibleRelation)
- *iface = (IUnknown*)this;
+ *iface = static_cast<IUnknown *>(this);
if (*iface) {
AddRef();
@@ -206,7 +214,7 @@ HRESULT STDMETHODCALLTYPE AccessibleRelation::get_targets(
/* [retval][out] */ long *nTargets)
{
- const int numTargets = qMin((int)maxTargets, m_targets.count());
+ const int numTargets = qMin(int(maxTargets), m_targets.count());
for (int i = 0; i < numTargets; ++i) {
QAccessibleInterface *iface = m_targets.at(i);
IAccessible *iacc = QWindowsAccessibility::wrap(iface);
@@ -235,42 +243,40 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::QueryInterface(REFIID id, LPVOI
HRESULT hr = QWindowsMsaaAccessible::QueryInterface(id, iface);
if (!SUCCEEDED(hr)) {
if (id == IID_IServiceProvider) {
- *iface = (IServiceProvider*)this;
+ *iface = static_cast<IServiceProvider *>(this);
} else if (id == IID_IAccessible2) {
- *iface = (IAccessible2*)this;
+ *iface = static_cast<IAccessible2 *>(this);
} else if (id == IID_IAccessibleAction) {
if (accessible->actionInterface())
- *iface = (IAccessibleAction*)this;
+ *iface = static_cast<IAccessibleAction *>(this);
} else if (id == IID_IAccessibleComponent) {
- *iface = (IAccessibleComponent*)this;
+ *iface = static_cast<IAccessibleComponent *>(this);
} else if (id == IID_IAccessibleEditableText) {
if (accessible->editableTextInterface() ||
accessible->role() == QAccessible::EditableText)
{
- *iface = (IAccessibleEditableText*)this;
+ *iface = static_cast<IAccessibleEditableText *>(this);
}
} else if (id == IID_IAccessibleHyperlink) {
- //*iface = (IAccessibleHyperlink*)this;
+ //*iface = static_cast<IAccessibleHyperlink *>(this);
} else if (id == IID_IAccessibleHypertext) {
- //*iface = (IAccessibleHypertext*)this;
+ //*iface = static_cast<IAccessibleHypertext *>(this);
} else if (id == IID_IAccessibleImage) {
- //*iface = (IAccessibleImage*)this;
- } else if (id == IID_IAccessibleRelation) {
- *iface = (IAccessibleRelation*)this;
+ //*iface = static_cast<IAccessibleImage *>(this);
} else if (id == IID_IAccessibleTable) {
- //*iface = (IAccessibleTable*)this; // not supported
+ //*iface = static_cast<IAccessibleTable *>(this); // not supported
} else if (id == IID_IAccessibleTable2) {
if (accessible->tableInterface())
- *iface = (IAccessibleTable2*)this;
+ *iface = static_cast<IAccessibleTable2 *>(this);
} else if (id == IID_IAccessibleTableCell) {
if (accessible->tableCellInterface())
- *iface = (IAccessibleTableCell*)this;
+ *iface = static_cast<IAccessibleTableCell *>(this);
} else if (id == IID_IAccessibleText) {
if (accessible->textInterface())
- *iface = (IAccessibleText*)this;
+ *iface = static_cast<IAccessibleText *>(this);
} else if (id == IID_IAccessibleValue) {
if (accessible->valueInterface())
- *iface = (IAccessibleValue*)this;
+ *iface = static_cast<IAccessibleValue *>(this);
}
if (*iface) {
AddRef();
@@ -599,9 +605,9 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_keyBinding(long actionIndex
numBindings = keyBindings.count();
if (numBindings > 0) {
// The IDL documents that the client must free with CoTaskMemFree
- arrayOfBindingsToReturn = (BSTR*)::CoTaskMemAlloc(sizeof(BSTR) * numBindings);
- for (int i = 0; i < numBindings; ++i)
- arrayOfBindingsToReturn[i] = QStringToBSTR(keyBindings.at(i));
+ arrayOfBindingsToReturn = coTaskMemAllocArray<BSTR>(numBindings);
+ std::transform(keyBindings.constBegin(), keyBindings.constEnd(),
+ arrayOfBindingsToReturn, QStringToBSTR);
}
}
*keyBindings = arrayOfBindingsToReturn;
@@ -674,7 +680,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_foreground(IA2Color *foregr
return E_FAIL;
// IA2Color is a typedef for long
- *foreground = (IA2Color)accessible->foregroundColor().rgb();
+ *foreground = static_cast<IA2Color>(accessible->foregroundColor().rgb());
return S_OK;
}
@@ -686,7 +692,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_background(IA2Color *backgr
return E_FAIL;
// IA2Color is a typedef for long
- *background = (IA2Color)accessible->backgroundColor().rgb();
+ *background = static_cast<IA2Color>(accessible->backgroundColor().rgb());
return S_OK;
}
@@ -760,7 +766,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::insertText(long offset, BSTR *t
{
QAccessibleInterface *accessible = accessibleInterface();
accessibleDebugClientCalls(accessible);
- const QString txt(BSTRToQString(*text));
+ const QString txt = QString::fromWCharArray(*text);
if (QAccessibleEditableTextInterface *editableTextIface = accessible->editableTextInterface())
editableTextIface->insertText(offset, txt);
else
@@ -805,7 +811,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::replaceText(long startOffset, l
{
QAccessibleInterface *accessible = accessibleInterface();
accessibleDebugClientCalls(accessible);
- const QString txt(BSTRToQString(*text));
+ const QString txt = QString::fromWCharArray(*text);
if (QAccessibleEditableTextInterface *editableTextIface = accessible->editableTextInterface())
editableTextIface->replaceText(startOffset, endOffset, txt);
else
@@ -978,12 +984,13 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_selectedColumns(long **sele
if (QAccessibleTableInterface *tableIface = tableInterface()) {
const QList<int> selectedIndices = tableIface->selectedColumns();
- const int &count = selectedIndices.count();
- long *selected = (count ? (long*)::CoTaskMemAlloc(sizeof(long) * count) : (long*)0);
- for (int i = 0; i < count; ++i)
- selected[i] = selectedIndices.at(i);
- *selectedColumns = selected;
+ const int count = selectedIndices.count();
*nColumns = count;
+ *selectedColumns = Q_NULLPTR;
+ if (count) {
+ *selectedColumns = coTaskMemAllocArray<long>(count);
+ std::copy(selectedIndices.constBegin(), selectedIndices.constEnd(), *selectedColumns);
+ }
return count ? S_OK : S_FALSE;
}
return E_FAIL;
@@ -999,12 +1006,13 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_selectedRows(long **selecte
if (QAccessibleTableInterface *tableIface = tableInterface()) {
const QList<int> selectedIndices = tableIface->selectedRows();
- const int &count = selectedIndices.count();
- long *selected = (count ? (long*)::CoTaskMemAlloc(sizeof(long) * count) : (long*)0);
- for (int i = 0; i < count; ++i)
- selected[i] = selectedIndices.at(i);
- *selectedRows = selected;
+ const int count = selectedIndices.count();
*nRows = count;
+ *selectedRows = Q_NULLPTR;
+ if (count) {
+ *selectedRows = coTaskMemAllocArray<long>(count);
+ std::copy(selectedIndices.constBegin(), selectedIndices.constEnd(), *selectedRows);
+ }
return count ? S_OK : S_FALSE;
}
return E_FAIL;
@@ -1204,10 +1212,10 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_rowColumnExtents(long *row,
if (!accessible || !tableCellInterface())
return E_FAIL;
- *row = (long)tableCellInterface()->rowIndex();
- *column = (long)tableCellInterface()->columnIndex();
- *rowExtents = (long)tableCellInterface()->rowExtent();
- *columnExtents = (long)tableCellInterface()->columnExtent();
+ *row = tableCellInterface()->rowIndex();
+ *column = tableCellInterface()->columnIndex();
+ *rowExtents = tableCellInterface()->rowExtent();
+ *columnExtents = tableCellInterface()->columnExtent();
*isSelected = tableCellInterface()->isSelected();
return S_OK;
}
@@ -1248,7 +1256,8 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_attributes(long offset,
QAccessibleInterface *accessible = accessibleInterface();
accessibleDebugClientCalls(accessible);
if (QAccessibleTextInterface *text = textInterface()) {
- const QString attrs = text->attributes(offset, (int*)startOffset, (int*)endOffset);
+ const QString attrs = text->attributes(offset, reinterpret_cast<int *>(startOffset),
+ reinterpret_cast<int *>(endOffset));
*textAttributes = QStringToBSTR(attrs);
return S_OK;
}
@@ -1320,7 +1329,8 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_selection(long selectionInd
QAccessibleInterface *accessible = accessibleInterface();
accessibleDebugClientCalls(accessible);
if (QAccessibleTextInterface *text = textInterface()) {
- text->selection(selectionIndex, (int*)startOffset, (int*)endOffset);
+ text->selection(selectionIndex, reinterpret_cast<int *>(startOffset),
+ reinterpret_cast<int *>(endOffset));
return S_OK;
}
return E_FAIL;
@@ -1352,7 +1362,10 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_textBeforeOffset(long offse
QAccessibleInterface *accessible = accessibleInterface();
accessibleDebugClientCalls(accessible);
if (QAccessibleTextInterface *textIface = textInterface()) {
- const QString txt = textIface->textBeforeOffset(offset, (QAccessible::TextBoundaryType)boundaryType, (int*)startOffset, (int*)endOffset);
+ const QString txt =
+ textIface->textBeforeOffset(offset, static_cast<QAccessible::TextBoundaryType>(boundaryType),
+ reinterpret_cast<int *>(startOffset),
+ reinterpret_cast<int *>(endOffset));
if (!txt.isEmpty()) {
*text = QStringToBSTR(txt);
return S_OK;
@@ -1372,7 +1385,10 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_textAfterOffset(
QAccessibleInterface *accessible = accessibleInterface();
accessibleDebugClientCalls(accessible);
if (QAccessibleTextInterface *textIface = textInterface()) {
- const QString txt = textIface->textAfterOffset(offset, (QAccessible::TextBoundaryType)boundaryType, (int*)startOffset, (int*)endOffset);
+ const QString txt =
+ textIface->textAfterOffset(offset, static_cast<QAccessible::TextBoundaryType>(boundaryType),
+ reinterpret_cast<int *>(startOffset),
+ reinterpret_cast<int *>(endOffset));
if (!txt.isEmpty()) {
*text = QStringToBSTR(txt);
return S_OK;
@@ -1391,7 +1407,10 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_textAtOffset(long offset,
QAccessibleInterface *accessible = accessibleInterface();
accessibleDebugClientCalls(accessible);
if (QAccessibleTextInterface *textIface = textInterface()) {
- const QString txt = textIface->textAtOffset(offset, (QAccessible::TextBoundaryType)boundaryType, (int*)startOffset, (int*)endOffset);
+ const QString txt =
+ textIface->textAtOffset(offset, static_cast<QAccessible::TextBoundaryType>(boundaryType),
+ reinterpret_cast<int *>(startOffset),
+ reinterpret_cast<int *>(endOffset));
if (!txt.isEmpty()) {
*text = QStringToBSTR(txt);
return S_OK;
@@ -1630,7 +1649,7 @@ HRESULT QWindowsIA2Accessible::getRelationsHelper(IAccessibleRelation **relation
QList<QAccessible::Relation> keys = relationMap.keys();
const int numRelations = keys.count();
if (relations) {
- for (int i = startIndex; i < qMin(startIndex + (int)maxRelations, numRelations); ++i) {
+ for (int i = startIndex; i < qMin(startIndex + int(maxRelations), numRelations); ++i) {
QAccessible::Relation relation = keys.at(i);
QList<QAccessibleInterface*> targets = relationMap.values(relation);
AccessibleRelation *rel = new AccessibleRelation(targets, relation);
@@ -1656,12 +1675,13 @@ HRESULT QWindowsIA2Accessible::wrapListOfCells(const QList<QAccessibleInterface*
{
const int count = inputCells.count();
// Server allocates array
- IUnknown **outputCells = count ? (IUnknown**)::CoTaskMemAlloc(sizeof(IUnknown*) * count ) : (IUnknown**)0;
- for (int i = 0; i < count; ++i)
- outputCells[i] = QWindowsAccessibility::wrap(inputCells.at(i));
-
- *outputAccessibles = outputCells;
*nCellCount = count;
+ *outputAccessibles = Q_NULLPTR;
+ if (count) {
+ *outputAccessibles = coTaskMemAllocArray<IUnknown *>(count);
+ std::transform(inputCells.constBegin(), inputCells.constEnd(),
+ *outputAccessibles, QWindowsAccessibility::wrap);
+ }
return count > 0 ? S_OK : S_FALSE;
}
diff --git a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp
index f91e57ae2f..4a3f0ccb2b 100644
--- a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp
+++ b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp
@@ -173,7 +173,7 @@ void QWindowsAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event)
QPlatformNativeInterface *platform = QGuiApplication::platformNativeInterface();
if (!window->handle()) // Called before show(), no native window yet.
return;
- HWND hWnd = (HWND)platform->nativeResourceForWindow("handle", window);
+ const HWND hWnd = reinterpret_cast<HWND>(platform->nativeResourceForWindow("handle", window));
if (event->type() != QAccessible::MenuCommand && // MenuCommand is faked
event->type() != QAccessible::ObjectDestroyed) {
@@ -220,7 +220,7 @@ IAccessible *QWindowsAccessibility::wrap(QAccessibleInterface *acc)
QWindowsIA2Accessible *wacc = new QWindowsIA2Accessible(acc);
# endif
IAccessible *iacc = 0;
- wacc->QueryInterface(IID_IAccessible, (void**)&iacc);
+ wacc->QueryInterface(IID_IAccessible, reinterpret_cast<void **>(&iacc));
return iacc;
#endif // defined(Q_OS_WINCE)
}
@@ -230,7 +230,7 @@ bool QWindowsAccessibility::handleAccessibleObjectFromWindowRequest(HWND hwnd, W
#if !defined(Q_OS_WINCE)
if (static_cast<long>(lParam) == static_cast<long>(UiaRootObjectId)) {
/* For UI Automation */
- } else if ((DWORD)lParam == DWORD(OBJID_CLIENT)) {
+ } else if (DWORD(lParam) == DWORD(OBJID_CLIENT)) {
// Start handling accessibility internally
QGuiApplicationPrivate::platformIntegration()->accessibility()->setActive(true);
// Ignoring all requests while starting up
@@ -244,7 +244,7 @@ bool QWindowsAccessibility::handleAccessibleObjectFromWindowRequest(HWND hwnd, W
if (!oleaccChecked) {
oleaccChecked = true;
- ptrLresultFromObject = (PtrLresultFromObject)QSystemLibrary::resolve(QLatin1String("oleacc"), "LresultFromObject");
+ ptrLresultFromObject = reinterpret_cast<PtrLresultFromObject>(QSystemLibrary::resolve(QLatin1String("oleacc"), "LresultFromObject"));
}
if (ptrLresultFromObject) {
diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp
index 0d3914d2ed..0fff804e29 100644
--- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp
+++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp
@@ -100,9 +100,9 @@ HRESULT STDMETHODCALLTYPE QWindowsEnumerate::QueryInterface(REFIID id, LPVOID *i
{
*iface = 0;
if (id == IID_IUnknown)
- *iface = (IUnknown*)this;
+ *iface = static_cast<IUnknown *>(this);
else if (id == IID_IEnumVARIANT)
- *iface = (IEnumVARIANT*)this;
+ *iface = static_cast<IEnumVARIANT *>(this);
if (*iface) {
AddRef();
@@ -150,13 +150,13 @@ HRESULT STDMETHODCALLTYPE QWindowsEnumerate::Next(unsigned long celt, VARIANT F
ULONG l;
for (l = 0; l < celt; l++) {
VariantInit(&rgVar[l]);
- if ((current+1) > (ULONG)array.size()) {
+ if (current + 1 > ULONG(array.size())) {
*pCeltFetched = l;
return S_FALSE;
}
rgVar[l].vt = VT_I4;
- rgVar[l].lVal = array[(int)current];
+ rgVar[l].lVal = array[int(current)];
++current;
}
*pCeltFetched = l;
@@ -172,8 +172,8 @@ HRESULT STDMETHODCALLTYPE QWindowsEnumerate::Reset()
HRESULT STDMETHODCALLTYPE QWindowsEnumerate::Skip(unsigned long celt)
{
current += celt;
- if (current > (ULONG)array.size()) {
- current = array.size();
+ if (current > ULONG(array.size())) {
+ current = ULONG(array.size());
return S_FALSE;
}
return S_OK;
@@ -201,13 +201,13 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::QueryInterface(REFIID id, LPVO
<< strIID << ", iface:" << accessibleInterface();
}
if (id == IID_IUnknown) {
- *iface = (IUnknown*)(IDispatch*)this;
+ *iface = static_cast<IUnknown *>(static_cast<IDispatch *>(this));
} else if (id == IID_IDispatch) {
- *iface = (IDispatch*)this;
+ *iface = static_cast<IDispatch *>(this);
} else if (id == IID_IAccessible) {
- *iface = (IAccessible*)this;
+ *iface = static_cast<IAccessible *>(this);
} else if (id == IID_IOleWindow) {
- *iface = (IOleWindow*)this;
+ *iface = static_cast<IOleWindow *>(this);
}
if (*iface) {
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index 5ae5ae3129..78fff65d84 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -430,7 +430,7 @@ bool QWindowsMouseHandler::translateMouseWheelEvent(QWindow *window, HWND,
int delta;
if (msg.message == WM_MOUSEWHEEL || msg.message == WM_MOUSEHWHEEL)
- delta = HIWORD (msg.wParam);
+ delta = GET_WHEEL_DELTA_WPARAM(msg.wParam);
else
delta = int(msg.wParam);
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index a7f00d5f6d..c64955be80 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -128,6 +128,41 @@ static inline QColor getSysColor(int index)
return COLORREFToQColor(GetSysColor(index));
}
+#ifndef QT_NO_WINCE_SHELLSDK
+// QTBUG-48823/Windows 10: SHGetFileInfo() (as called by item views on file system
+// models has been observed to trigger a WM_PAINT on the mainwindow. Suppress the
+// behavior by running it in a thread.
+class ShGetFileInfoFunction
+{
+public:
+ explicit ShGetFileInfoFunction(const wchar_t *fn, DWORD a, SHFILEINFO *i, UINT f, bool *r) :
+ m_fileName(fn), m_attributes(a), m_flags(f), m_info(i), m_result(r) {}
+
+ void operator()() const { *m_result = SHGetFileInfo(m_fileName, m_attributes, m_info, sizeof(SHFILEINFO), m_flags); }
+
+private:
+ const wchar_t *m_fileName;
+ const DWORD m_attributes;
+ const UINT m_flags;
+ SHFILEINFO *const m_info;
+ bool *m_result;
+};
+
+static bool shGetFileInfoBackground(QWindowsThreadPoolRunner &r,
+ const wchar_t *fileName, DWORD attributes,
+ SHFILEINFO *info, UINT flags,
+ unsigned long timeOutMSecs = 5000)
+{
+ bool result = false;
+ if (!r.run(ShGetFileInfoFunction(fileName, attributes, info, flags, &result), timeOutMSecs)) {
+ qWarning().noquote() << "ShGetFileInfoBackground() timed out for "
+ << QString::fromWCharArray(fileName);
+ return false;
+ }
+ return result;
+}
+#endif // !QT_NO_WINCE_SHELLSDK
+
// from QStyle::standardPalette
static inline QPalette standardPalette()
{
@@ -725,23 +760,22 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s
}
SHFILEINFO info;
- unsigned int flags =
+ const unsigned int flags =
#ifndef Q_OS_WINCE
SHGFI_ICON|iconSize|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX;
#else
iconSize|SHGFI_SYSICONINDEX;
#endif // Q_OS_WINCE
- unsigned long val = 0;
+
+
#if !defined(QT_NO_WINCE_SHELLSDK)
- if (cacheableDirIcon && useDefaultFolderIcon) {
- flags |= SHGFI_USEFILEATTRIBUTES;
- val = SHGetFileInfo(L"dummy",
- FILE_ATTRIBUTE_DIRECTORY,
- &info, sizeof(SHFILEINFO), flags);
- } else {
- val = SHGetFileInfo(reinterpret_cast<const wchar_t *>(filePath.utf16()), 0,
- &info, sizeof(SHFILEINFO), flags);
- }
+ const bool val = cacheableDirIcon && useDefaultFolderIcon
+ ? shGetFileInfoBackground(m_threadPoolRunner, L"dummy", FILE_ATTRIBUTE_DIRECTORY,
+ &info, flags | SHGFI_USEFILEATTRIBUTES)
+ : shGetFileInfoBackground(m_threadPoolRunner, reinterpret_cast<const wchar_t *>(filePath.utf16()), 0,
+ &info, flags);
+#else
+ const bool val = false;
#endif // !QT_NO_WINCE_SHELLSDK
// Even if GetFileInfo returns a valid result, hIcon can be empty in some cases
diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h
index 45db934e47..acf89306c2 100644
--- a/src/plugins/platforms/windows/qwindowstheme.h
+++ b/src/plugins/platforms/windows/qwindowstheme.h
@@ -40,6 +40,7 @@
#ifndef QWINDOWSTHEME_H
#define QWINDOWSTHEME_H
+#include "qwindowsthreadpoolrunner.h"
#include <qpa/qplatformtheme.h>
QT_BEGIN_NAMESPACE
@@ -80,6 +81,7 @@ private:
static QWindowsTheme *m_instance;
QPalette *m_palettes[NPalettes];
QFont *m_fonts[NFonts];
+ mutable QWindowsThreadPoolRunner m_threadPoolRunner;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsthreadpoolrunner.h b/src/plugins/platforms/windows/qwindowsthreadpoolrunner.h
new file mode 100644
index 0000000000..0361aa90f5
--- /dev/null
+++ b/src/plugins/platforms/windows/qwindowsthreadpoolrunner.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSTHREADPOOLRUNNER_H
+#define QWINDOWSTHREADPOOLRUNNER_H
+
+#include <QtCore/QMutex>
+#include <QtCore/QRunnable>
+#include <QtCore/QThreadPool>
+#include <QtCore/QWaitCondition>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QWindowsThreadPoolRunner
+ \brief Runs a task in the global instance of QThreadPool
+
+ QThreadPool does not provide a method to wait on a single task, so this needs
+ to be done by using QWaitCondition/QMutex.
+
+ \internal
+ \ingroup qt-lighthouse-win
+*/
+class QWindowsThreadPoolRunner
+{
+ Q_DISABLE_COPY(QWindowsThreadPoolRunner)
+
+#ifndef QT_NO_THREAD
+ template <class RunnableFunction> // nested class implementing QRunnable to execute a function.
+ class Runnable : public QRunnable
+ {
+ public:
+ explicit Runnable(QMutex *m, QWaitCondition *c, RunnableFunction f)
+ : m_mutex(m), m_condition(c), m_function(f) {}
+
+ void run() Q_DECL_OVERRIDE
+ {
+ m_function();
+ m_mutex->lock();
+ m_condition->wakeAll();
+ m_mutex->unlock();
+ }
+
+ private:
+ QMutex *m_mutex;
+ QWaitCondition *m_condition;
+ RunnableFunction m_function;
+ }; // class Runnable
+
+public:
+ QWindowsThreadPoolRunner() {}
+
+ template <class Function>
+ bool run(Function f, unsigned long timeOutMSecs = 5000)
+ {
+ QThreadPool *pool = QThreadPool::globalInstance();
+ Q_ASSERT(pool);
+ Runnable<Function> *runnable = new Runnable<Function>(&m_mutex, &m_condition, f);
+ m_mutex.lock();
+ pool->start(runnable);
+ const bool ok = m_condition.wait(&m_mutex, timeOutMSecs);
+ m_mutex.unlock();
+ if (!ok)
+ pool->cancel(runnable);
+ return ok;
+ }
+
+private:
+ QMutex m_mutex;
+ QWaitCondition m_condition;
+#else // !QT_NO_THREAD
+public:
+ QWindowsThreadPoolRunner() {}
+
+ template <class Function>
+ bool run(Function f, unsigned long /* timeOutMSecs */ = 5000)
+ {
+ f();
+ return true;
+ }
+#endif // QT_NO_THREAD
+};
+
+QT_END_NAMESPACE
+
+#endif // QWINDOWSTHREADPOOLRUNNER_H
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index c1a047e276..d9a7586096 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -2203,14 +2203,15 @@ void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const
// Documentation of MINMAXINFO states that it will only work for the primary screen
if (screen && screen == QGuiApplication::primaryScreen()) {
- mmi->ptMaxSize.y = screen->availableGeometry().height();
+ const QRect availableGeometry = QHighDpi::toNativePixels(screen->availableGeometry(), screen);
+ mmi->ptMaxSize.y = availableGeometry.height();
// Width, because you can have the taskbar on the sides too.
- mmi->ptMaxSize.x = screen->availableGeometry().width();
+ mmi->ptMaxSize.x = availableGeometry.width();
// If you have the taskbar on top, or on the left you don't want it at (0,0):
- mmi->ptMaxPosition.x = screen->availableGeometry().x();
- mmi->ptMaxPosition.y = screen->availableGeometry().y();
+ mmi->ptMaxPosition.x = availableGeometry.x();
+ mmi->ptMaxPosition.y = availableGeometry.y();
} else if (!screen){
qWarning() << "window()->screen() returned a null screen";
}
diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri
index 766168ccb8..d46cfbc43a 100644
--- a/src/plugins/platforms/windows/windows.pri
+++ b/src/plugins/platforms/windows/windows.pri
@@ -62,7 +62,8 @@ HEADERS += \
$$PWD/qplatformfunctions_wince.h \
$$PWD/qwindowsnativeimage.h \
$$PWD/qwindowsnativeinterface.h \
- $$PWD/qwindowsopengltester.h
+ $$PWD/qwindowsopengltester.h \
+ $$PWD/qwindowsthreadpoolrunner.h
INCLUDEPATH += $$PWD