From be73bdc5d2491d036e5a6334dada453ed808dbc0 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 18 Oct 2019 12:28:13 +0200 Subject: Only call ShowCaret if Windows 10 1709 or later is used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This amends cc873ec23a98ac32d10ac5fa569792fde2f6b2c8 which worked around a problem that was showing up on earlier versions of Windows. This extends the workaround up to Windows 10 1703 as the problem was still occurring up to that version. Fixes: QTBUG-79143 Change-Id: Ib7eace17fb8e3817c556e2bcd462e37834b1cbcf Reviewed-by: Friedemann Kleint Reviewed-by: André de la Rocha --- src/plugins/platforms/windows/qwindowsinputcontext.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index 8054f9fe83..bbfad7d712 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -280,13 +280,15 @@ void QWindowsInputContext::showInputPanel() // with Windows 10 if the Windows IME is (re)enabled _after_ the caret is shown. if (m_caretCreated) { cursorRectChanged(); - // We only call ShowCaret() on Windows 10 as in earlier versions the caret - // would actually be visible (QTBUG-74492) and the workaround for the - // Surface seems unnecessary there anyway. But leave it hidden for IME. - if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10) + // We only call ShowCaret() on Windows 10 after 1703 as in earlier versions + // the caret would actually be visible (QTBUG-74492) and the workaround for + // the Surface seems unnecessary there anyway. But leave it hidden for IME. + if (QOperatingSystemVersion::current() >= + QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 16299)) { ShowCaret(platformWindow->handle()); - else + } else { HideCaret(platformWindow->handle()); + } setWindowsImeEnabled(platformWindow, false); setWindowsImeEnabled(platformWindow, true); } -- cgit v1.2.3 From 39ed657b6393c850735857e367303800f1a04413 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 21 Oct 2019 10:23:27 +0200 Subject: Query the mouse buttons initially in case the middle button was used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I99a3ef598bdaaba1afb6bf6521d1ceafcc9b603c Reviewed-by: André de la Rocha --- src/plugins/platforms/windows/qwindowspointerhandler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp index 71a09304c5..fae01c9147 100644 --- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp +++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp @@ -579,7 +579,9 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin const QTabletEvent::TabletDevice device = QTabletEvent::Stylus; QTabletEvent::PointerType type; - Qt::MouseButtons mouseButtons; + // Since it may be the middle button, so if the checks fail then it should + // be set to Middle if it was used. + Qt::MouseButtons mouseButtons = queryMouseButtons(); const bool pointerInContact = IS_POINTER_INCONTACT_WPARAM(msg.wParam); if (pointerInContact) -- cgit v1.2.3 From ef54abae43db79792b40dfdca30ac0fa1b582354 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Tue, 29 Oct 2019 20:42:00 +0100 Subject: Windows QPA: Fix missing update when the display is sleeping If an item was updated while the display was in sleep mode then when the display came back from sleep it would not be updated. This change detects when the display returns from sleep and repaints the windows to ensure the updated items are presented. Fixes: QTBUG-76307 Change-Id: I5fff5209e8a5c359d06ba1df61944690e9475ea6 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowscontext.cpp | 58 ++++++++++++++++++++++ src/plugins/platforms/windows/qwindowscontext.h | 2 + .../platforms/windows/qwindowsintegration.cpp | 2 + 3 files changed, 62 insertions(+) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 38b9823d6b..5c1b00a1c9 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -273,6 +273,8 @@ struct QWindowsContextPrivate { const HRESULT m_oleInitializeResult; QWindow *m_lastActiveWindow = nullptr; bool m_asyncExpose = false; + HPOWERNOTIFY m_powerNotification = nullptr; + HWND m_powerDummyWindow = nullptr; }; QWindowsContextPrivate::QWindowsContextPrivate() @@ -313,6 +315,13 @@ QWindowsContext::~QWindowsContext() #if QT_CONFIG(tabletevent) d->m_tabletSupport.reset(); // Destroy internal window before unregistering classes. #endif + + if (d->m_powerNotification) + UnregisterPowerSettingNotification(d->m_powerNotification); + + if (d->m_powerDummyWindow) + DestroyWindow(d->m_powerDummyWindow); + unregisterWindowClasses(); if (d->m_oleInitializeResult == S_OK || d->m_oleInitializeResult == S_FALSE) OleUninitialize(); @@ -380,6 +389,55 @@ bool QWindowsContext::initPointer(unsigned integrationOptions) return true; } +extern "C" LRESULT QT_WIN_CALLBACK qWindowsPowerWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if (message != WM_POWERBROADCAST || wParam != PBT_POWERSETTINGCHANGE) + return DefWindowProc(hwnd, message, wParam, lParam); + + static bool initialized = false; // ignore the initial change + if (!initialized) { + initialized = true; + return DefWindowProc(hwnd, message, wParam, lParam); + } + + auto setting = reinterpret_cast(lParam); + if (setting) { + auto data = reinterpret_cast(&setting->Data); + if (*data == 1) { + // Repaint the windows when returning from sleeping display mode. + const auto tlw = QGuiApplication::topLevelWindows(); + for (auto w : tlw) { + if (w->isVisible() && w->windowState() != Qt::WindowMinimized) { + if (auto tw = QWindowsWindow::windowsWindowOf(w)) { + if (HWND hwnd = tw->handle()) { + InvalidateRect(hwnd, nullptr, false); + } + } + } + } + } + } + return DefWindowProc(hwnd, message, wParam, lParam); +} + +bool QWindowsContext::initPowerNotificationHandler() +{ + if (d->m_powerNotification) + return false; + + d->m_powerDummyWindow = createDummyWindow(QStringLiteral("QtPowerDummyWindow"), L"QtPowerDummyWindow", qWindowsPowerWindowProc); + if (!d->m_powerDummyWindow) + return false; + + d->m_powerNotification = RegisterPowerSettingNotification(d->m_powerDummyWindow, &GUID_MONITOR_POWER_ON, DEVICE_NOTIFY_WINDOW_HANDLE); + if (!d->m_powerNotification) { + DestroyWindow(d->m_powerDummyWindow); + d->m_powerDummyWindow = nullptr; + return false; + } + return true; +} + void QWindowsContext::setTabletAbsoluteRange(int a) { #if QT_CONFIG(tabletevent) diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h index 4908f14629..04290379db 100644 --- a/src/plugins/platforms/windows/qwindowscontext.h +++ b/src/plugins/platforms/windows/qwindowscontext.h @@ -176,6 +176,8 @@ public: bool initTablet(unsigned integrationOptions); bool initPointer(unsigned integrationOptions); + bool initPowerNotificationHandler(); + int defaultDPI() const; QString registerWindowClass(const QWindow *w); diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 5c1fa00088..849e6cf2d0 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -256,6 +256,8 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mL m_context.initTouch(m_options); QPlatformCursor::setCapability(QPlatformCursor::OverrideCursor); + + m_context.initPowerNotificationHandler(); } QWindowsIntegrationPrivate::~QWindowsIntegrationPrivate() -- cgit v1.2.3 From 26f8adb1eefd1a8822413e036f2878b8cc1e7029 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Thu, 7 Nov 2019 16:52:10 +0100 Subject: Windows QPA: Avoid returning UI Automation ValueProvider for static text Static text controls should not return a ValueProvider. Otherwise, Narrator reads out static texts and announces whether they are editable or not, which is confusing to users. It should only read out the text itself. Fixes: QTBUG-79613 Change-Id: I080cd6a5db10f6f673b50c40ac7d87c3737d9b55 Reviewed-by: Friedemann Kleint --- .../platforms/windows/uiautomation/qwindowsuiamainprovider.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index 5a05adbf81..96d64acc32 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -277,8 +277,9 @@ HRESULT QWindowsUiaMainProvider::GetPatternProvider(PATTERNID idPattern, IUnknow } break; case UIA_ValuePatternId: - // All accessible controls return text(QAccessible::Value) (which may be empty). - *pRetVal = new QWindowsUiaValueProvider(id()); + // All non-static controls support the Value pattern. + if (accessible->role() != QAccessible::StaticText) + *pRetVal = new QWindowsUiaValueProvider(id()); break; case UIA_RangeValuePatternId: // Controls providing a numeric value within a range (e.g., sliders, scroll bars, dials). -- cgit v1.2.3 From 8f2db974ab594125301aac62594510e146125cb4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 1 Nov 2019 11:15:32 +0100 Subject: Windows QPA: Fix wrong scaling of fixed size in window creation phase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a fixed size the window is moved to another screen by QPlatformWindow::initialGeometry(), the size constraints would be incorrectly scaled using the initial screen in the handling of WM_GETMINMAXINFO. To fix this, pass the resulting screen out of QPlatformWindow::initialGeometry() and use it during the window creation phase. Fixes: QTBUG-77307 Change-Id: I149a2a65e816da841a32abc14a495925bf9cc6f6 Reviewed-by: André de la Rocha Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/windows/qwindowswindow.cpp | 35 +++++++++++++++++------- src/plugins/platforms/windows/qwindowswindow.h | 10 +++++-- 2 files changed, 33 insertions(+), 12 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index a4f4099aa6..ea91e3bb2d 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -759,7 +759,10 @@ QWindowsWindowData const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w); - const QRect rect = QPlatformWindow::initialGeometry(w, data.geometry, defaultWindowWidth, defaultWindowHeight); + const QScreen *screen{}; + const QRect rect = QPlatformWindow::initialGeometry(w, data.geometry, + defaultWindowWidth, defaultWindowHeight, + &screen); if (title.isEmpty() && (result.flags & Qt::WindowTitleHint)) title = topLevel ? qAppName() : w->objectName(); @@ -769,7 +772,9 @@ QWindowsWindowData // Capture events before CreateWindowEx() returns. The context is cleared in // the QWindowsWindow constructor. - const QWindowCreationContextPtr context(new QWindowCreationContext(w, data.geometry, rect, data.customMargins, style, exStyle)); + const QWindowCreationContextPtr context(new QWindowCreationContext(w, screen, data.geometry, + rect, data.customMargins, + style, exStyle)); QWindowsContext::instance()->setWindowCreationContext(context); const bool hasFrame = (style & (WS_DLGFRAME | WS_THICKFRAME)); @@ -879,10 +884,10 @@ void WindowCreationData::initialize(const QWindow *w, HWND hwnd, bool frameChang // Scaling helpers for size constraints. -static QSize toNativeSizeConstrained(QSize dip, const QWindow *w) +static QSize toNativeSizeConstrained(QSize dip, const QScreen *s) { if (QHighDpiScaling::isActive()) { - const qreal factor = QHighDpiScaling::factor(w); + const qreal factor = QHighDpiScaling::factor(s); if (!qFuzzyCompare(factor, qreal(1))) { if (dip.width() > 0 && dip.width() < QWINDOWSIZE_MAX) dip.setWidth(qRound(qreal(dip.width()) * factor)); @@ -995,11 +1000,12 @@ bool QWindowsGeometryHint::handleCalculateSize(const QMargins &customMargins, co return true; } -void QWindowsGeometryHint::frameSizeConstraints(const QWindow *w, const QMargins &margins, +void QWindowsGeometryHint::frameSizeConstraints(const QWindow *w, const QScreen *screen, + const QMargins &margins, QSize *minimumSize, QSize *maximumSize) { - *minimumSize = toNativeSizeConstrained(w->minimumSize(), w); - *maximumSize = toNativeSizeConstrained(w->maximumSize(), w); + *minimumSize = toNativeSizeConstrained(w->minimumSize(), screen); + *maximumSize = toNativeSizeConstrained(w->maximumSize(), screen); const int maximumWidth = qMax(maximumSize->width(), minimumSize->width()); const int maximumHeight = qMax(maximumSize->height(), minimumSize->height()); @@ -1017,12 +1023,13 @@ void QWindowsGeometryHint::frameSizeConstraints(const QWindow *w, const QMargins } void QWindowsGeometryHint::applyToMinMaxInfo(const QWindow *w, + const QScreen *screen, const QMargins &margins, MINMAXINFO *mmi) { QSize minimumSize; QSize maximumSize; - frameSizeConstraints(w, margins, &minimumSize, &maximumSize); + frameSizeConstraints(w, screen, margins, &minimumSize, &maximumSize); qCDebug(lcQpaWindows).nospace() << '>' << __FUNCTION__ << '<' << " min=" << minimumSize.width() << ',' << minimumSize.height() << " max=" << maximumSize.width() << ',' << maximumSize.height() @@ -1041,6 +1048,13 @@ void QWindowsGeometryHint::applyToMinMaxInfo(const QWindow *w, qCDebug(lcQpaWindows).nospace() << '<' << __FUNCTION__ << " out " << *mmi; } +void QWindowsGeometryHint::applyToMinMaxInfo(const QWindow *w, + const QMargins &margins, + MINMAXINFO *mmi) +{ + applyToMinMaxInfo(w, w->screen(), margins, mmi); +} + bool QWindowsGeometryHint::positionIncludesFrame(const QWindow *w) { return qt_window_private(const_cast(w))->positionPolicy @@ -1226,11 +1240,12 @@ void QWindowsForeignWindow::setVisible(bool visible) \ingroup qt-lighthouse-win */ -QWindowCreationContext::QWindowCreationContext(const QWindow *w, +QWindowCreationContext::QWindowCreationContext(const QWindow *w, const QScreen *s, const QRect &geometryIn, const QRect &geometry, const QMargins &cm, DWORD style, DWORD exStyle) : window(w), + screen(s), requestedGeometryIn(geometryIn), requestedGeometry(geometry), obtainedPos(geometryIn.topLeft()), @@ -1270,7 +1285,7 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w, void QWindowCreationContext::applyToMinMaxInfo(MINMAXINFO *mmi) const { - QWindowsGeometryHint::applyToMinMaxInfo(window, margins + customMargins, mmi); + QWindowsGeometryHint::applyToMinMaxInfo(window, screen, margins + customMargins, mmi); } /*! diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 7efbcf900c..1f8800272b 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -66,9 +66,12 @@ struct QWindowsGeometryHint static QMargins frame(const QWindow *w, const QRect &geometry, DWORD style, DWORD exStyle); static bool handleCalculateSize(const QMargins &customMargins, const MSG &msg, LRESULT *result); + static void applyToMinMaxInfo(const QWindow *w, const QScreen *screen, + const QMargins &margins, MINMAXINFO *mmi); static void applyToMinMaxInfo(const QWindow *w, const QMargins &margins, MINMAXINFO *mmi); - static void frameSizeConstraints(const QWindow *w, const QMargins &margins, + static void frameSizeConstraints(const QWindow *w, const QScreen *screen, + const QMargins &margins, QSize *minimumSize, QSize *maximumSize); static inline QPoint mapToGlobal(HWND hwnd, const QPoint &); static inline QPoint mapToGlobal(const QWindow *w, const QPoint &); @@ -80,13 +83,16 @@ struct QWindowsGeometryHint struct QWindowCreationContext { - explicit QWindowCreationContext(const QWindow *w, + explicit QWindowCreationContext(const QWindow *w, const QScreen *s, const QRect &geometryIn, const QRect &geometry, const QMargins &customMargins, DWORD style, DWORD exStyle); void applyToMinMaxInfo(MINMAXINFO *mmi) const; const QWindow *window; + // The screen to use to scale size constraints, etc. Might differ from the + // screen of the window after QPlatformWindow::initialGeometry() (QTBUG-77307). + const QScreen *screen; QRect requestedGeometryIn; // QWindow scaled QRect requestedGeometry; // after QPlatformWindow::initialGeometry() QPoint obtainedPos; -- cgit v1.2.3 From c3556025951ec9b16c20d215985761a27fad52d4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 12 Nov 2019 12:45:36 +0100 Subject: Windows QPA: Port from QList to QVector Use a QVector where possible. Otherwise, try to introduce auto to make migration easier. Change-Id: I9deadb363fabd1755deca180ed5cb771390fcb30 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsdialoghelpers.cpp | 4 ++-- src/plugins/platforms/windows/qwindowsdropdataobject.cpp | 2 +- src/plugins/platforms/windows/qwindowskeymapper.cpp | 2 +- src/plugins/platforms/windows/qwindowsmime.cpp | 10 +++++----- src/plugins/platforms/windows/qwindowsmime.h | 3 +-- src/plugins/platforms/windows/qwindowsscreen.cpp | 6 +++--- src/plugins/platforms/windows/qwindowsscreen.h | 2 +- src/plugins/platforms/windows/qwindowswindow.cpp | 2 +- .../windows/uiautomation/qwindowsuiaselectionprovider.cpp | 3 ++- .../windows/uiautomation/qwindowsuiatableitemprovider.cpp | 4 ++-- 10 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index b7ab952a1d..cdb4e407d1 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -466,14 +466,14 @@ inline void QWindowsFileDialogSharedData::setSelectedNameFilter(const QString &f inline QList QWindowsFileDialogSharedData::selectedFiles() const { m_data->mutex.lock(); - const QList result = m_data->selectedFiles; + const auto result = m_data->selectedFiles; m_data->mutex.unlock(); return result; } inline QString QWindowsFileDialogSharedData::selectedFile() const { - const QList files = selectedFiles(); + const auto files = selectedFiles(); return files.isEmpty() ? QString() : files.front().toLocalFile(); } diff --git a/src/plugins/platforms/windows/qwindowsdropdataobject.cpp b/src/plugins/platforms/windows/qwindowsdropdataobject.cpp index e1a41c0ede..c9dd1c7c17 100644 --- a/src/plugins/platforms/windows/qwindowsdropdataobject.cpp +++ b/src/plugins/platforms/windows/qwindowsdropdataobject.cpp @@ -95,7 +95,7 @@ bool QWindowsDropDataObject::shouldIgnore(LPFORMATETC pformatetc) const || pformatetc->cfFormat == CF_TEXT || formatName == QStringLiteral("UniformResourceLocator") || formatName == QStringLiteral("UniformResourceLocatorW")) { - QList urls = dropData->urls(); + const auto urls = dropData->urls(); return std::all_of(urls.cbegin(), urls.cend(), [] (const QUrl &u) { return u.isLocalFile(); }); } } diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 4f0f846749..0509403267 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -1388,7 +1388,7 @@ QList QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) { const Qt::KeyboardModifiers missingMods = keyMods & ~neededMods; const int matchedKey = int(key) + missingMods; - const QList::iterator it = + const auto it = std::find_if(result.begin(), result.end(), [key] (int k) { return (k & ~Qt::KeyboardModifierMask) == key; }); // QTBUG-67200: Use the match with the least modifiers (prefer diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index b9d8b191f5..1c6c999f05 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -107,7 +107,7 @@ static inline QByteArray msgConversionError(const char *func, const char *format msg += ": Unable to convert DIB image. The image converter plugin for '"; msg += format; msg += "' is not available. Available formats: "; - const QList &formats = QImageReader::supportedImageFormats(); + const auto &formats = QImageReader::supportedImageFormats(); for (const QByteArray &af : formats) { msg += af; msg += ' '; @@ -747,7 +747,7 @@ QWindowsMimeURI::QWindowsMimeURI() bool QWindowsMimeURI::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const { if (mimeData->hasUrls() && getCf(formatetc) == CF_HDROP) { - const QList urls = mimeData->urls(); + const auto urls = mimeData->urls(); for (const QUrl &url : urls) { if (url.isLocalFile()) return true; @@ -760,7 +760,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat { if (canConvertFromMime(formatetc, mimeData)) { if (getCf(formatetc) == CF_HDROP) { - const QList &urls = mimeData->urls(); + const auto &urls = mimeData->urls(); QStringList fileNames; int size = sizeof(DROPFILES)+2; for (const QUrl &url : urls) { @@ -791,7 +791,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat return setData(result, pmedium); } if (getCf(formatetc) == CF_INETURL_W) { - QList urls = mimeData->urls(); + const auto urls = mimeData->urls(); QByteArray result; if (!urls.isEmpty()) { QString url = urls.at(0).toString(); @@ -803,7 +803,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat return setData(result, pmedium); } if (getCf(formatetc) == CF_INETURL) { - QList urls = mimeData->urls(); + const auto urls = mimeData->urls(); QByteArray result; if (!urls.isEmpty()) result = urls.at(0).toString().toLocal8Bit(); diff --git a/src/plugins/platforms/windows/qwindowsmime.h b/src/plugins/platforms/windows/qwindowsmime.h index 1c389e8800..f8708f1259 100644 --- a/src/plugins/platforms/windows/qwindowsmime.h +++ b/src/plugins/platforms/windows/qwindowsmime.h @@ -43,7 +43,6 @@ #include #include -#include #include QT_BEGIN_NAMESPACE @@ -95,7 +94,7 @@ public: private: void ensureInitialized() const; - mutable QList m_mimes; + mutable QVector m_mimes; mutable int m_internalMimeCount = 0; }; diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index df63adf558..4f76a82544 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -73,7 +73,7 @@ static inline QDpi monitorDPI(HMONITOR hMonitor) return {0, 0}; } -using WindowsScreenDataList = QList; +using WindowsScreenDataList = QVector; static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data) { @@ -467,7 +467,7 @@ bool QWindowsScreenManager::handleDisplayChange(WPARAM wParam, LPARAM lParam) return false; } -static inline int indexOfMonitor(const QList &screens, +static inline int indexOfMonitor(const QWindowsScreenManager::WindowsScreenList &screens, const QString &monitorName) { for (int i= 0; i < screens.size(); ++i) @@ -476,7 +476,7 @@ static inline int indexOfMonitor(const QList &screens, return -1; } -static inline int indexOfMonitor(const QList &screenData, +static inline int indexOfMonitor(const WindowsScreenDataList &screenData, const QString &monitorName) { for (int i = 0; i < screenData.size(); ++i) diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h index 2fd56f53cf..5c095808f2 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.h +++ b/src/plugins/platforms/windows/qwindowsscreen.h @@ -127,7 +127,7 @@ private: class QWindowsScreenManager { public: - using WindowsScreenList = QList; + using WindowsScreenList = QVector; QWindowsScreenManager(); diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index ea91e3bb2d..5a4f879d0f 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -592,7 +592,7 @@ static QPoint calcPosition(const QWindow *w, const QWindowCreationContextPtr &co return posFrame; // Find the original screen containing the coordinates. - const QList screens = screenForGL->virtualSiblings(); + const auto screens = screenForGL->virtualSiblings(); const QScreen *orgScreen = nullptr; for (QScreen *screen : screens) { if (screen->handle()->availableGeometry().contains(posFrame)) { diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp index 3305e9c5c4..fb41012cf4 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp @@ -49,6 +49,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -78,7 +79,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaSelectionProvider::GetSelection(SAFEARRAY * return UIA_E_ELEMENTNOTAVAILABLE; // First put selected items in a list, then build a safe array with the right size. - QList selectedList; + QVector selectedList; for (int i = 0; i < accessible->childCount(); ++i) { if (QAccessibleInterface *child = accessible->child(i)) { if (child->state().selected) { diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp index 2a94012590..1348ec7cc0 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp @@ -80,7 +80,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetRowHeaderItems(SAFEAR if (!tableCellInterface) return UIA_E_ELEMENTNOTAVAILABLE; - QList headers = tableCellInterface->rowHeaderCells(); + const auto headers = tableCellInterface->rowHeaderCells(); if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) { for (LONG i = 0; i < headers.size(); ++i) { @@ -110,7 +110,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetColumnHeaderItems(SAF if (!tableCellInterface) return UIA_E_ELEMENTNOTAVAILABLE; - QList headers = tableCellInterface->columnHeaderCells(); + const auto headers = tableCellInterface->columnHeaderCells(); if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) { for (LONG i = 0; i < headers.size(); ++i) { -- cgit v1.2.3 From 8bc4ea1e97c138034d08c705a75f75763361400b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 13 Nov 2019 10:27:25 +0100 Subject: Windows QPA: Fix deprecation warnings Fix warnings introduced by qtbase/72f57cc84244633ca69ede9a1fd510b9b1881c1d: qwindowstheme.cpp:167:62: warning: 'bool QWaitCondition::wait(QMutex*, long unsigned int)' is deprecated: Use wait(QMutex *lockedMutex, QDeadlineTimer deadline) instead [-Wdeprecated-declarations]qwindowstheme.cpp: In member function 'bool QShGetFileInfoThread::runWithParams(QShGetFileInfoParams*, long unsigned int)': qwindowstheme.cpp:201:63: warning: 'bool QWaitCondition::wait(QMutex*, long unsigned int)' is deprecated: Use wait(QMutex *lockedMutex, QDeadlineTimer deadline) instead [-Wdeprecated-declarations] Change-Id: Ie33f8b0e1e742f972d2a8065eba9e16a13ec43ee Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowstheme.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 40f9652cbd..32a65109af 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -164,7 +164,7 @@ public: QMutexLocker readyLocker(&m_readyMutex); while (!m_cancelled.loadRelaxed()) { if (!m_params && !m_cancelled.loadRelaxed() - && !m_readyCondition.wait(&m_readyMutex, 1000)) + && !m_readyCondition.wait(&m_readyMutex, QDeadlineTimer(1000ll))) continue; if (m_params) { @@ -189,7 +189,7 @@ public: CoUninitialize(); } - bool runWithParams(QShGetFileInfoParams *params, unsigned long timeOutMSecs) + bool runWithParams(QShGetFileInfoParams *params, qint64 timeOutMSecs) { QMutexLocker doneLocker(&m_doneMutex); @@ -198,7 +198,7 @@ public: m_readyCondition.wakeAll(); m_readyMutex.unlock(); - return m_doneCondition.wait(&m_doneMutex, timeOutMSecs); + return m_doneCondition.wait(&m_doneMutex, QDeadlineTimer(timeOutMSecs)); } void cancel() @@ -220,7 +220,7 @@ private: static bool shGetFileInfoBackground(const QString &fileName, DWORD attributes, SHFILEINFO *info, UINT flags, - unsigned long timeOutMSecs = 5000) + qint64 timeOutMSecs = 5000) { static QShGetFileInfoThread *getFileInfoThread = nullptr; if (!getFileInfoThread) { -- cgit v1.2.3 From 2c871dfd38d89d6415c2c25d47b4a0e9c8b2ef11 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 22 Nov 2019 15:34:38 +0100 Subject: Avoid initializing QFlags with 0 or nullptr in further cases Amends qtbase/af2daafde72db02454d24b7d691aa6861525ab99. Where applicable, port over to member initialization, thus also fixing nullptr warnings. Change-Id: Iaaf2dbbbcf2952253390b8839fd15a1b17be32c0 Reviewed-by: Allan Sandfeld Jensen --- src/plugins/platforms/windows/qwindowsglcontext.h | 2 +- src/plugins/platforms/windows/qwindowskeymapper.cpp | 4 ++-- src/plugins/platforms/windows/qwindowsmousehandler.cpp | 4 ++-- src/plugins/platforms/windows/qwindowspointerhandler.cpp | 2 +- src/plugins/platforms/windows/qwindowstheme.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowsglcontext.h b/src/plugins/platforms/windows/qwindowsglcontext.h index e5f6fefd5a..8794368fe4 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.h +++ b/src/plugins/platforms/windows/qwindowsglcontext.h @@ -89,7 +89,7 @@ struct QWindowsOpenGLContextFormat QSurfaceFormat::OpenGLContextProfile profile = QSurfaceFormat::NoProfile; int version = 0; //! majorVersion<<8 + minorVersion - QSurfaceFormat::FormatOptions options = nullptr; + QSurfaceFormat::FormatOptions options; }; #ifndef QT_NO_DEBUG_STREAM diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 0509403267..e3edf7e81e 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -1019,14 +1019,14 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, MSG msg, if (dirStatus == VK_LSHIFT && ((msg.wParam == VK_SHIFT && GetKeyState(VK_LCONTROL)) || (msg.wParam == VK_CONTROL && GetKeyState(VK_LSHIFT)))) { - sendExtendedPressRelease(receiver, Qt::Key_Direction_L, nullptr, + sendExtendedPressRelease(receiver, Qt::Key_Direction_L, {}, scancode, vk_key, nModifiers, QString(), false); result = true; dirStatus = 0; } else if (dirStatus == VK_RSHIFT && ( (msg.wParam == VK_SHIFT && GetKeyState(VK_RCONTROL)) || (msg.wParam == VK_CONTROL && GetKeyState(VK_RSHIFT)))) { - sendExtendedPressRelease(receiver, Qt::Key_Direction_R, nullptr, + sendExtendedPressRelease(receiver, Qt::Key_Direction_R, {}, scancode, vk_key, nModifiers, QString(), false); result = true; dirStatus = 0; diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 6df5e6aa27..b776efc942 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -165,7 +165,7 @@ void QWindowsMouseHandler::clearEvents() Qt::MouseButtons QWindowsMouseHandler::queryMouseButtons() { - Qt::MouseButtons result = nullptr; + Qt::MouseButtons result; const bool mouseSwapped = GetSystemMetrics(SM_SWAPBUTTON); if (GetAsyncKeyState(VK_LBUTTON) < 0) result |= mouseSwapped ? Qt::RightButton: Qt::LeftButton; @@ -630,7 +630,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, QTouchPointList touchPoints; touchPoints.reserve(winTouchPointCount); - Qt::TouchPointStates allStates = nullptr; + Qt::TouchPointStates allStates; GetTouchInputInfo(reinterpret_cast(msg.lParam), UINT(msg.wParam), winTouchInputs.data(), sizeof(TOUCHINPUT)); diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp index b477147da7..fba24d8696 100644 --- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp +++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp @@ -482,7 +482,7 @@ bool QWindowsPointerHandler::translateTouchEvent(QWindow *window, HWND hwnd, << " message=" << Qt::hex << msg.message << " count=" << Qt::dec << count; - Qt::TouchPointStates allStates = nullptr; + Qt::TouchPointStates allStates; for (quint32 i = 0; i < count; ++i) { if (QWindowsContext::verbose > 1) diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h index 07120230ce..7a8c321da4 100644 --- a/src/plugins/platforms/windows/qwindowstheme.h +++ b/src/plugins/platforms/windows/qwindowstheme.h @@ -71,7 +71,7 @@ public: QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override; - QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = nullptr) const override; + QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = {}) const override; void windowsThemeChanged(QWindow *window); void displayChanged() { refreshIconPixmapSizes(); } -- cgit v1.2.3