diff options
Diffstat (limited to 'src/plugins/platforms/windows')
97 files changed, 2384 insertions, 913 deletions
diff --git a/src/plugins/platforms/windows/main.cpp b/src/plugins/platforms/windows/main.cpp index 980de88e72..8bde87c975 100644 --- a/src/plugins/platforms/windows/main.cpp +++ b/src/plugins/platforms/windows/main.cpp @@ -39,7 +39,7 @@ #include <qpa/qplatformintegrationplugin.h> -#include <QtCore/QStringList> +#include <QtCore/qstringlist.h> #include "qwindowsgdiintegration.h" diff --git a/src/plugins/platforms/windows/openglblacklists/default.json b/src/plugins/platforms/windows/openglblacklists/default.json index d1e9f85247..3cfa7e3856 100644 --- a/src/plugins/platforms/windows/openglblacklists/default.json +++ b/src/plugins/platforms/windows/openglblacklists/default.json @@ -141,6 +141,17 @@ "features": [ "disable_desktopgl", "disable_d3d11", "disable_d3d9" ] + }, + { + "id": 12, + "description": "Intel HD Graphics crash in conjunction with shader caches (QTBUG-64697) - disable for all Intel GPUs", + "vendor_id": "0x8086", + "os": { + "type": "win" + }, + "features": [ + "disable_program_cache" + ] } ] } diff --git a/src/plugins/platforms/windows/qtwindowsglobal.h b/src/plugins/platforms/windows/qtwindowsglobal.h index 6c44541314..985f13bdc5 100644 --- a/src/plugins/platforms/windows/qtwindowsglobal.h +++ b/src/plugins/platforms/windows/qtwindowsglobal.h @@ -60,6 +60,22 @@ # define WM_DPICHANGED 0x02E0 #endif +// WM_POINTER support from Windows 8 onwards (WINVER >= 0x0602) +#ifndef WM_POINTERUPDATE +# define WM_NCPOINTERUPDATE 0x0241 +# define WM_NCPOINTERDOWN 0x0242 +# define WM_NCPOINTERUP 0x0243 +# define WM_POINTERUPDATE 0x0245 +# define WM_POINTERDOWN 0x0246 +# define WM_POINTERUP 0x0247 +# define WM_POINTERENTER 0x0249 +# define WM_POINTERLEAVE 0x024A +# define WM_POINTERACTIVATE 0x024B +# define WM_POINTERCAPTURECHANGED 0x024C +# define WM_POINTERWHEEL 0x024E +# define WM_POINTERHWHEEL 0x024F +#endif // WM_POINTERUPDATE + QT_BEGIN_NAMESPACE namespace QtWindows @@ -78,6 +94,7 @@ enum ApplicationEventFlag = 0x1000000, ThemingEventFlag = 0x2000000, GenericEventFlag = 0x4000000, // Misc + PointerEventFlag = 0x8000000, }; enum WindowsEventType // Simplify event types @@ -103,13 +120,16 @@ enum WindowsEventType // Simplify event types DpiChangedEvent = WindowEventFlag + 21, EnterSizeMoveEvent = WindowEventFlag + 22, ExitSizeMoveEvent = WindowEventFlag + 23, + PointerActivateWindowEvent = WindowEventFlag + 24, MouseEvent = MouseEventFlag + 1, MouseWheelEvent = MouseEventFlag + 2, CursorEvent = MouseEventFlag + 3, TouchEvent = TouchEventFlag + 1, + PointerEvent = PointerEventFlag + 1, NonClientMouseEvent = NonClientEventFlag + MouseEventFlag + 1, NonClientHitTest = NonClientEventFlag + 2, NonClientCreate = NonClientEventFlag + 3, + NonClientPointerEvent = NonClientEventFlag + PointerEventFlag + 4, KeyEvent = KeyEventFlag + 1, KeyDownEvent = KeyEventFlag + KeyDownEventFlag + 1, KeyboardLayoutChangeEvent = KeyEventFlag + 2, @@ -167,6 +187,8 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI QtWindows::ActivateApplicationEvent : QtWindows::DeactivateApplicationEvent; case WM_MOUSEACTIVATE: return QtWindows::MouseActivateWindowEvent; + case WM_POINTERACTIVATE: + return QtWindows::PointerActivateWindowEvent; case WM_ACTIVATE: return LOWORD(wParamIn) == WA_INACTIVE ? QtWindows::DeactivateWindowEvent : QtWindows::ActivateWindowEvent; @@ -297,6 +319,10 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI if ((message >= WM_MOUSEFIRST && message <= WM_MOUSELAST) || (message >= WM_XBUTTONDOWN && message <= WM_XBUTTONDBLCLK)) return QtWindows::MouseEvent; + if (message >= WM_NCPOINTERUPDATE && message <= WM_NCPOINTERUP) + return QtWindows::NonClientPointerEvent; + if (message >= WM_POINTERUPDATE && message <= WM_POINTERHWHEEL) + return QtWindows::PointerEvent; return QtWindows::UnknownEvent; } diff --git a/src/plugins/platforms/windows/qwin10helpers.cpp b/src/plugins/platforms/windows/qwin10helpers.cpp index 5976fd23c0..cc17d8798f 100644 --- a/src/plugins/platforms/windows/qwin10helpers.cpp +++ b/src/plugins/platforms/windows/qwin10helpers.cpp @@ -39,8 +39,8 @@ #include "qwin10helpers.h" -#include <QtCore/QDebug> -#include <QtCore/QOperatingSystemVersion> +#include <QtCore/qdebug.h> +#include <QtCore/qoperatingsystemversion.h> #include <QtCore/private/qsystemlibrary_p.h> #if defined(Q_CC_MINGW) || defined(Q_CC_CLANG) diff --git a/src/plugins/platforms/windows/qwin10helpers.h b/src/plugins/platforms/windows/qwin10helpers.h index e1485003dd..4f364dfc59 100644 --- a/src/plugins/platforms/windows/qwin10helpers.h +++ b/src/plugins/platforms/windows/qwin10helpers.h @@ -40,7 +40,7 @@ #ifndef QWIN10HELPERS_H #define QWIN10HELPERS_H -#include <QtCore/QtGlobal> +#include <QtCore/qglobal.h> #include <QtCore/qt_windows.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp index 80872c3ea3..03b44458ac 100644 --- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp +++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp @@ -41,13 +41,13 @@ #include "qwindowswindow.h" #include "qwindowscontext.h" -#include <QtGui/QWindow> -#include <QtGui/QPainter> +#include <QtGui/qwindow.h> +#include <QtGui/qpainter.h> #include <QtFontDatabaseSupport/private/qwindowsnativeimage_p.h> #include <private/qhighdpiscaling_p.h> #include <private/qimage_p.h> -#include <QtCore/QDebug> +#include <QtCore/qdebug.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.h b/src/plugins/platforms/windows/qwindowsbackingstore.h index 9e62266697..088ab3b257 100644 --- a/src/plugins/platforms/windows/qwindowsbackingstore.h +++ b/src/plugins/platforms/windows/qwindowsbackingstore.h @@ -43,7 +43,7 @@ #include <QtCore/qt_windows.h> #include <qpa/qplatformbackingstore.h> -#include <QtCore/QScopedPointer> +#include <QtCore/qscopedpointer.h> QT_BEGIN_NAMESPACE @@ -55,7 +55,7 @@ class QWindowsBackingStore : public QPlatformBackingStore Q_DISABLE_COPY(QWindowsBackingStore) public: QWindowsBackingStore(QWindow *window); - ~QWindowsBackingStore(); + ~QWindowsBackingStore() override; QPaintDevice *paintDevice() override; void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override; diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp index 01191a7dc1..8b386da9f7 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.cpp +++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp @@ -42,16 +42,17 @@ #include "qwindowsole.h" #include "qwindowsmime.h" -#include <QtGui/QGuiApplication> -#include <QtGui/QClipboard> -#include <QtGui/QColor> -#include <QtGui/QImage> - -#include <QtCore/QDebug> -#include <QtCore/QMimeData> -#include <QtCore/QStringList> -#include <QtCore/QVariant> -#include <QtCore/QUrl> +#include <QtGui/qguiapplication.h> +#include <QtGui/qclipboard.h> +#include <QtGui/qcolor.h> +#include <QtGui/qimage.h> + +#include <QtCore/qdebug.h> +#include <QtCore/qmimedata.h> +#include <QtCore/qstringlist.h> +#include <QtCore/qthread.h> +#include <QtCore/qvariant.h> +#include <QtCore/qurl.h> #include <QtEventDispatcherSupport/private/qwindowsguieventdispatcher_p.h> @@ -318,7 +319,15 @@ void QWindowsClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode) m_data = new QWindowsOleDataObject(mimeData); } - const HRESULT src = OleSetClipboard(m_data); + HRESULT src = S_FALSE; + int attempts = 0; + for (; attempts < 3; ++attempts) { + src = OleSetClipboard(m_data); + if (src != CLIPBRD_E_CANT_OPEN || QWindowsContext::isSessionLocked()) + break; + QThread::msleep(100); + } + if (src != S_OK) { QString mimeDataFormats = mimeData ? mimeData->formats().join(QLatin1String(", ")) : QString(QStringLiteral("NULL")); diff --git a/src/plugins/platforms/windows/qwindowsclipboard.h b/src/plugins/platforms/windows/qwindowsclipboard.h index 4f3e7437f6..469d638b89 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.h +++ b/src/plugins/platforms/windows/qwindowsclipboard.h @@ -58,9 +58,10 @@ protected: class QWindowsClipboard : public QPlatformClipboard { + Q_DISABLE_COPY(QWindowsClipboard) public: QWindowsClipboard(); - ~QWindowsClipboard(); + ~QWindowsClipboard() override; void registerViewer(); // Call in initialization, when context is up. void cleanup(); diff --git a/src/plugins/platforms/windows/qwindowscombase.h b/src/plugins/platforms/windows/qwindowscombase.h index 5e51b6b7b7..6b25d665dc 100644 --- a/src/plugins/platforms/windows/qwindowscombase.h +++ b/src/plugins/platforms/windows/qwindowscombase.h @@ -40,7 +40,7 @@ #ifndef QWINDOWSCOMBASE_H #define QWINDOWSCOMBASE_H -#include <QtCore/QtGlobal> +#include <QtCore/qglobal.h> #include <unknwn.h> @@ -83,7 +83,7 @@ template <class ComInterface> class QWindowsComBase : public ComInterface Q_DISABLE_COPY(QWindowsComBase) public: explicit QWindowsComBase(ULONG initialRefCount = 1) : m_ref(initialRefCount) {} - virtual ~QWindowsComBase() {} + virtual ~QWindowsComBase() = default; HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, LPVOID *iface) { diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index b0c9349da5..1f80ac5872 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -43,6 +43,7 @@ #include "qwindowswindow.h" #include "qwindowskeymapper.h" #include "qwindowsmousehandler.h" +#include "qwindowspointerhandler.h" #include "qtwindowsglobal.h" #include "qwindowsmenu.h" #include "qwindowsmime.h" @@ -52,7 +53,7 @@ #endif #include "qwindowstheme.h" #include <private/qguiapplication_p.h> -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) # include "uiautomation/qwindowsuiaaccessibility.h" #endif #if QT_CONFIG(sessionmanager) @@ -62,20 +63,20 @@ #include "qwindowsscreen.h" #include "qwindowstheme.h" -#include <QtGui/qtguiglobal.h> -#include <QtGui/QWindow> +#include <QtGui/qwindow.h> #include <qpa/qwindowsysteminterface.h> +#include <qpa/qwindowsysteminterface_p.h> #include <qpa/qplatformnativeinterface.h> -#include <QtGui/QGuiApplication> -#include <QtGui/QOpenGLContext> - -#include <QtCore/QSet> -#include <QtCore/QHash> -#include <QtCore/QStringList> -#include <QtCore/QDebug> -#include <QtCore/QOperatingSystemVersion> -#include <QtCore/QSysInfo> -#include <QtCore/QScopedArrayPointer> +#include <QtGui/qguiapplication.h> +#include <QtGui/qopenglcontext.h> + +#include <QtCore/qset.h> +#include <QtCore/qhash.h> +#include <QtCore/qstringlist.h> +#include <QtCore/qdebug.h> +#include <QtCore/qoperatingsystemversion.h> +#include <QtCore/qsysinfo.h> +#include <QtCore/qscopedpointer.h> #include <QtCore/private/qsystemlibrary_p.h> #include <QtEventDispatcherSupport/private/qwindowsguieventdispatcher_p.h> @@ -85,11 +86,11 @@ #include <windowsx.h> #include <comdef.h> #include <dbt.h> +#include <wtsapi32.h> QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcQpaWindows, "qt.qpa.windows") -Q_LOGGING_CATEGORY(lcQpaBackingStore, "qt.qpa.backingstore") Q_LOGGING_CATEGORY(lcQpaEvents, "qt.qpa.events") Q_LOGGING_CATEGORY(lcQpaGl, "qt.qpa.gl") Q_LOGGING_CATEGORY(lcQpaMime, "qt.qpa.mime") @@ -147,7 +148,7 @@ static inline bool sessionManagerInteractionBlocked() { return false; } static inline int windowDpiAwareness(HWND hwnd) { - return QWindowsContext::user32dll.getWindowDpiAwarenessContext && QWindowsContext::user32dll.getWindowDpiAwarenessContext + return QWindowsContext::user32dll.getWindowDpiAwarenessContext && QWindowsContext::user32dll.getAwarenessFromDpiAwarenessContext ? QWindowsContext::user32dll.getAwarenessFromDpiAwarenessContext(QWindowsContext::user32dll.getWindowDpiAwarenessContext(hwnd)) : -1; } @@ -194,14 +195,35 @@ void QWindowsUser32DLL::init() getDisplayAutoRotationPreferences = (GetDisplayAutoRotationPreferences)library.resolve("GetDisplayAutoRotationPreferences"); setDisplayAutoRotationPreferences = (SetDisplayAutoRotationPreferences)library.resolve("SetDisplayAutoRotationPreferences"); + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8) { + enableMouseInPointer = (EnableMouseInPointer)library.resolve("EnableMouseInPointer"); + getPointerType = (GetPointerType)library.resolve("GetPointerType"); + getPointerInfo = (GetPointerInfo)library.resolve("GetPointerInfo"); + getPointerDeviceRects = (GetPointerDeviceRects)library.resolve("GetPointerDeviceRects"); + getPointerTouchInfo = (GetPointerTouchInfo)library.resolve("GetPointerTouchInfo"); + getPointerFrameTouchInfo = (GetPointerFrameTouchInfo)library.resolve("GetPointerFrameTouchInfo"); + getPointerFrameTouchInfoHistory = (GetPointerFrameTouchInfoHistory)library.resolve("GetPointerFrameTouchInfoHistory"); + getPointerPenInfo = (GetPointerPenInfo)library.resolve("GetPointerPenInfo"); + getPointerPenInfoHistory = (GetPointerPenInfoHistory)library.resolve("GetPointerPenInfoHistory"); + skipPointerFrameMessages = (SkipPointerFrameMessages)library.resolve("SkipPointerFrameMessages"); + } + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 14393)) { enableNonClientDpiScaling = (EnableNonClientDpiScaling)library.resolve("EnableNonClientDpiScaling"); getWindowDpiAwarenessContext = (GetWindowDpiAwarenessContext)library.resolve("GetWindowDpiAwarenessContext"); getAwarenessFromDpiAwarenessContext = (GetAwarenessFromDpiAwarenessContext)library.resolve("GetAwarenessFromDpiAwarenessContext"); + systemParametersInfoForDpi = (SystemParametersInfoForDpi)library.resolve("SystemParametersInfoForDpi"); } } +bool QWindowsUser32DLL::supportsPointerApi() +{ + return enableMouseInPointer && getPointerType && getPointerInfo && getPointerDeviceRects + && getPointerTouchInfo && getPointerFrameTouchInfo && getPointerFrameTouchInfoHistory + && getPointerPenInfo && getPointerPenInfoHistory && skipPointerFrameMessages; +} + void QWindowsShcoreDLL::init() { if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8_1) @@ -239,6 +261,7 @@ struct QWindowsContextPrivate { int m_defaultDPI = 96; QWindowsKeyMapper m_keyMapper; QWindowsMouseHandler m_mouseHandler; + QWindowsPointerHandler m_pointerHandler; QWindowsMimeConverter m_mimeConverter; QWindowsScreenManager m_screenManager; QSharedPointer<QWindowCreationContext> m_creationContext; @@ -256,7 +279,7 @@ QWindowsContextPrivate::QWindowsContextPrivate() QWindowsContext::user32dll.init(); QWindowsContext::shcoredll.init(); - if (m_mouseHandler.touchDevice()) + if (m_pointerHandler.touchDevice() || m_mouseHandler.touchDevice()) m_systemInfo |= QWindowsContext::SI_SupportsTouch; m_displayContext = GetDC(0); m_defaultDPI = GetDeviceCaps(m_displayContext, LOGPIXELSY); @@ -281,10 +304,6 @@ QWindowsContext::QWindowsContext() : const QByteArray bv = qgetenv("QT_QPA_VERBOSE"); if (!bv.isEmpty()) QLoggingCategory::setFilterRules(QString::fromLocal8Bit(bv)); -#if QT_CONFIG(tabletevent) - d->m_tabletSupport.reset(QWindowsTabletSupport::create()); - qCDebug(lcQpaTablet) << "Tablet support: " << (d->m_tabletSupport.isNull() ? QStringLiteral("None") : d->m_tabletSupport->description()); -#endif } QWindowsContext::~QWindowsContext() @@ -310,12 +329,17 @@ bool QWindowsContext::initTouch(unsigned integrationOptions) if (d->m_systemInfo & QWindowsContext::SI_SupportsTouch) return true; - QTouchDevice *touchDevice = d->m_mouseHandler.ensureTouchDevice(); + QTouchDevice *touchDevice = (d->m_systemInfo & QWindowsContext::SI_SupportsPointer) ? + d->m_pointerHandler.ensureTouchDevice() : d->m_mouseHandler.ensureTouchDevice(); if (!touchDevice) return false; - if (!(integrationOptions & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch)) - touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation); + if (d->m_systemInfo & QWindowsContext::SI_SupportsPointer) { + QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(false); + } else { + if (!(integrationOptions & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch)) + touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation); + } QWindowSystemInterface::registerTouchDevice(touchDevice); @@ -330,6 +354,33 @@ bool QWindowsContext::initTouch(unsigned integrationOptions) return true; } +bool QWindowsContext::initTablet(unsigned integrationOptions) +{ + Q_UNUSED(integrationOptions); +#if QT_CONFIG(tabletevent) + d->m_tabletSupport.reset(QWindowsTabletSupport::create()); + return true; +#else + return false; +#endif +} + +bool QWindowsContext::initPointer(unsigned integrationOptions) +{ + if (integrationOptions & QWindowsIntegration::DontUseWMPointer) + return false; + + if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8) + return false; + + if (!QWindowsContext::user32dll.supportsPointerApi()) + return false; + + QWindowsContext::user32dll.enableMouseInPointer(TRUE); + d->m_systemInfo |= QWindowsContext::SI_SupportsPointer; + return true; +} + void QWindowsContext::setTabletAbsoluteRange(int a) { #if QT_CONFIG(tabletevent) @@ -340,6 +391,11 @@ void QWindowsContext::setTabletAbsoluteRange(int a) #endif } +void QWindowsContext::setDetectAltGrModifier(bool a) +{ + d->m_keyMapper.setDetectAltGrModifier(a); +} + int QWindowsContext::processDpiAwareness() { int result; @@ -548,7 +604,7 @@ void QWindowsContext::unregisterWindowClasses() { const HINSTANCE appInstance = static_cast<HINSTANCE>(GetModuleHandle(0)); - foreach (const QString &name, d->m_registeredWindowClassNames) { + for (const QString &name : qAsConst(d->m_registeredWindowClassNames)) { if (!UnregisterClass(reinterpret_cast<LPCWSTR>(name.utf16()), appInstance) && QWindowsContext::verbose) qErrnoWarning("UnregisterClass failed for '%s'", qPrintable(name)); } @@ -632,12 +688,16 @@ QWindow *QWindowsContext::findWindow(HWND hwnd) const QWindow *QWindowsContext::windowUnderMouse() const { - return d->m_mouseHandler.windowUnderMouse(); + return (d->m_systemInfo & QWindowsContext::SI_SupportsPointer) ? + d->m_pointerHandler.windowUnderMouse() : d->m_mouseHandler.windowUnderMouse(); } void QWindowsContext::clearWindowUnderMouse() { - d->m_mouseHandler.clearWindowUnderMouse(); + if (d->m_systemInfo & QWindowsContext::SI_SupportsPointer) + d->m_pointerHandler.clearWindowUnderMouse(); + else + d->m_mouseHandler.clearWindowUnderMouse(); } /*! @@ -696,6 +756,37 @@ QWindowsWindow *QWindowsContext::findPlatformWindowAt(HWND parent, return result; } +bool QWindowsContext::isSessionLocked() +{ + bool result = false; + const DWORD sessionId = WTSGetActiveConsoleSessionId(); + if (sessionId != 0xFFFFFFFF) { + LPTSTR buffer = nullptr; + DWORD size = 0; +#if !defined(Q_CC_MINGW) + if (WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, sessionId, + WTSSessionInfoEx, &buffer, &size) == TRUE + && size > 0) { + const WTSINFOEXW *info = reinterpret_cast<WTSINFOEXW *>(buffer); + result = info->Level == 1 && info->Data.WTSInfoExLevel1.SessionFlags == WTS_SESSIONSTATE_LOCK; + WTSFreeMemory(buffer); + } +#else // MinGW as of 7.3 does not have WTSINFOEXW in wtsapi32.h + // Retrieve the flags which are at offset 16 due to padding for 32/64bit alike. + if (WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, sessionId, + WTS_INFO_CLASS(25), &buffer, &size) == TRUE + && size >= 20) { + const DWORD *p = reinterpret_cast<DWORD *>(buffer); + const DWORD level = *p; + const DWORD sessionFlags = *(p + 4); + result = level == 1 && sessionFlags == 1; + WTSFreeMemory(buffer); + } +#endif // Q_CC_MINGW + } + return result; +} + QWindowsMimeConverter &QWindowsContext::mimeConverter() const { return d->m_mimeConverter; @@ -826,6 +917,45 @@ QByteArray QWindowsContext::comErrorString(HRESULT hr) return result; } +bool QWindowsContext::systemParametersInfo(unsigned action, unsigned param, void *out, + unsigned dpi) +{ + const BOOL result = QWindowsContext::user32dll.systemParametersInfoForDpi != nullptr && dpi != 0 + ? QWindowsContext::user32dll.systemParametersInfoForDpi(action, param, out, 0, dpi) + : SystemParametersInfo(action, param, out, 0); + return result == TRUE; +} + +bool QWindowsContext::systemParametersInfoForScreen(unsigned action, unsigned param, void *out, + const QPlatformScreen *screen) +{ + return systemParametersInfo(action, param, out, screen ? screen->logicalDpi().first : 0); +} + +bool QWindowsContext::systemParametersInfoForWindow(unsigned action, unsigned param, void *out, + const QPlatformWindow *win) +{ + return systemParametersInfoForScreen(action, param, out, win ? win->screen() : nullptr); +} + +bool QWindowsContext::nonClientMetrics(NONCLIENTMETRICS *ncm, unsigned dpi) +{ + memset(ncm, 0, sizeof(NONCLIENTMETRICS)); + ncm->cbSize = sizeof(NONCLIENTMETRICS); + return systemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm->cbSize, ncm, dpi); +} + +bool QWindowsContext::nonClientMetricsForScreen(NONCLIENTMETRICS *ncm, + const QPlatformScreen *screen) +{ + return nonClientMetrics(ncm, screen ? screen->logicalDpi().first : 0); +} + +bool QWindowsContext::nonClientMetricsForWindow(NONCLIENTMETRICS *ncm, const QPlatformWindow *win) +{ + return nonClientMetricsForScreen(ncm, win ? win->screen() : nullptr); +} + static inline QWindowsInputContext *windowsInputContext() { return qobject_cast<QWindowsInputContext *>(QWindowsIntegration::instance()->inputContext()); @@ -870,6 +1000,7 @@ static inline bool isInputMessage(UINT m) case WM_IME_STARTCOMPOSITION: case WM_IME_ENDCOMPOSITION: case WM_IME_COMPOSITION: + case WM_INPUT: case WM_TOUCH: case WM_MOUSEHOVER: case WM_MOUSELEAVE: @@ -957,7 +1088,9 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, switch (et) { case QtWindows::GestureEvent: - return sessionManagerInteractionBlocked() || d->m_mouseHandler.translateGestureEvent(platformWindow->window(), hwnd, et, msg, result); + if (!(d->m_systemInfo & QWindowsContext::SI_SupportsPointer)) + return sessionManagerInteractionBlocked() || d->m_mouseHandler.translateGestureEvent(platformWindow->window(), hwnd, et, msg, result); + break; case QtWindows::InputMethodOpenCandidateWindowEvent: case QtWindows::InputMethodCloseCandidateWindowEvent: // TODO: Release/regrab mouse if a popup has mouse grab. @@ -974,7 +1107,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, case QtWindows::UnknownEvent: return false; case QtWindows::AccessibleObjectFromWindowRequest: -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) return QWindowsUiaAccessibility::handleWmGetObject(hwnd, wParam, lParam, result); #else return false; @@ -1083,18 +1216,25 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, case QtWindows::ExposeEvent: return platformWindow->handleWmPaint(hwnd, message, wParam, lParam); case QtWindows::NonClientMouseEvent: - if (platformWindow->frameStrutEventsEnabled()) + if (!(d->m_systemInfo & QWindowsContext::SI_SupportsPointer) && platformWindow->frameStrutEventsEnabled()) return sessionManagerInteractionBlocked() || d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result); break; + case QtWindows::NonClientPointerEvent: + if ((d->m_systemInfo & QWindowsContext::SI_SupportsPointer) && platformWindow->frameStrutEventsEnabled()) + return sessionManagerInteractionBlocked() || d->m_pointerHandler.translatePointerEvent(platformWindow->window(), hwnd, et, msg, result); + break; case QtWindows::EnterSizeMoveEvent: platformWindow->setFlag(QWindowsWindow::ResizeMoveActive); return true; case QtWindows::ExitSizeMoveEvent: platformWindow->clearFlag(QWindowsWindow::ResizeMoveActive); platformWindow->checkForScreenChanged(); + handleExitSizeMove(platformWindow->window()); return true; case QtWindows::ScrollEvent: - return sessionManagerInteractionBlocked() || d->m_mouseHandler.translateScrollEvent(platformWindow->window(), hwnd, msg, result); + if (!(d->m_systemInfo & QWindowsContext::SI_SupportsPointer)) + return sessionManagerInteractionBlocked() || d->m_mouseHandler.translateScrollEvent(platformWindow->window(), hwnd, msg, result); + break; case QtWindows::MouseWheelEvent: case QtWindows::MouseEvent: case QtWindows::LeaveEvent: @@ -1104,10 +1244,20 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, window = window->parent(); if (!window) return false; - return sessionManagerInteractionBlocked() || d->m_mouseHandler.translateMouseEvent(window, hwnd, et, msg, result); + if (!(d->m_systemInfo & QWindowsContext::SI_SupportsPointer)) + return sessionManagerInteractionBlocked() || d->m_mouseHandler.translateMouseEvent(window, hwnd, et, msg, result); + else + return sessionManagerInteractionBlocked() || d->m_pointerHandler.translateMouseEvent(window, hwnd, et, msg, result); } + break; case QtWindows::TouchEvent: - return sessionManagerInteractionBlocked() || d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result); + if (!(d->m_systemInfo & QWindowsContext::SI_SupportsPointer)) + return sessionManagerInteractionBlocked() || d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result); + break; + case QtWindows::PointerEvent: + if (d->m_systemInfo & QWindowsContext::SI_SupportsPointer) + return sessionManagerInteractionBlocked() || d->m_pointerHandler.translatePointerEvent(platformWindow->window(), hwnd, et, msg, result); + break; case QtWindows::FocusInEvent: // see QWindowsWindow::requestActivateWindow(). case QtWindows::FocusOutEvent: handleFocusEvent(et, platformWindow); @@ -1150,6 +1300,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, } break; case QtWindows::MouseActivateWindowEvent: + case QtWindows::PointerActivateWindowEvent: if (platformWindow->window()->flags() & Qt::WindowDoesNotAcceptFocus) { *result = LRESULT(MA_NOACTIVATE); return true; @@ -1294,6 +1445,37 @@ bool QWindowsContext::handleContextMenuEvent(QWindow *window, const MSG &msg) } #endif +void QWindowsContext::handleExitSizeMove(QWindow *window) +{ + // Windows can be moved/resized by: + // 1) User moving a window by dragging the title bar: Causes a sequence + // of WM_NCLBUTTONDOWN, WM_NCMOUSEMOVE but no WM_NCLBUTTONUP, + // leaving the left mouse button 'pressed' + // 2) User choosing Resize/Move from System menu and using mouse/cursor keys: + // No mouse events are received + // 3) Programmatically via QSizeGrip calling QPlatformWindow::startSystemResize/Move(): + // Mouse is left in pressed state after press on size grip (inside window), + // no further mouse events are received + // For cases 1,3, intercept WM_EXITSIZEMOVE to sync the buttons. + const Qt::MouseButtons currentButtons = QWindowsMouseHandler::queryMouseButtons(); + const Qt::MouseButtons appButtons = QGuiApplication::mouseButtons(); + if (currentButtons == appButtons) + return; + const Qt::KeyboardModifiers keyboardModifiers = QWindowsKeyMapper::queryKeyboardModifiers(); + const QPoint globalPos = QWindowsCursor::mousePosition(); + const QPlatformWindow *platWin = window->handle(); + const QPoint localPos = platWin->mapFromGlobal(globalPos); + const QEvent::Type type = platWin->geometry().contains(globalPos) + ? QEvent::MouseButtonRelease : QEvent::NonClientAreaMouseButtonRelease; + for (Qt::MouseButton button : {Qt::LeftButton, Qt::RightButton, Qt::MiddleButton}) { + if (appButtons.testFlag(button) && !currentButtons.testFlag(button)) { + QWindowSystemInterface::handleMouseEvent(window, localPos, globalPos, + currentButtons, button, type, + keyboardModifiers); + } + } +} + bool QWindowsContext::asyncExpose() const { return d->m_asyncExpose; @@ -1306,7 +1488,8 @@ void QWindowsContext::setAsyncExpose(bool value) QTouchDevice *QWindowsContext::touchDevice() const { - return d->m_mouseHandler.touchDevice(); + return (d->m_systemInfo & QWindowsContext::SI_SupportsPointer) ? + d->m_pointerHandler.touchDevice() : d->m_mouseHandler.touchDevice(); } static DWORD readDwordRegistrySetting(const wchar_t *regKey, const wchar_t *subKey, DWORD defaultValue) @@ -1399,7 +1582,7 @@ extern "C" LRESULT QT_WIN_CALLBACK qWindowsWndProc(HWND hwnd, UINT message, WPAR marginsFromRects(ncCalcSizeFrame, rectFromNcCalcSize(message, wParam, lParam, 0)); if (margins.left() >= 0) { if (platformWindow) { - platformWindow->setFrameMargins(margins); + platformWindow->setFullFrameMargins(margins); } else { const QSharedPointer<QWindowCreationContext> ctx = QWindowsContext::instance()->windowCreationContext(); if (!ctx.isNull()) diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h index 0a7f20ca83..fd6c72668c 100644 --- a/src/plugins/platforms/windows/qwindowscontext.h +++ b/src/plugins/platforms/windows/qwindowscontext.h @@ -43,9 +43,9 @@ #include "qtwindowsglobal.h" #include <QtCore/qt_windows.h> -#include <QtCore/QScopedPointer> -#include <QtCore/QSharedPointer> -#include <QtCore/QLoggingCategory> +#include <QtCore/qscopedpointer.h> +#include <QtCore/qsharedpointer.h> +#include <QtCore/qloggingcategory.h> #define STRICT_TYPED_ITEMIDS #include <shlobj.h> @@ -57,7 +57,6 @@ struct _SHSTOCKICONINFO; QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcQpaWindows) -Q_DECLARE_LOGGING_CATEGORY(lcQpaBackingStore) Q_DECLARE_LOGGING_CATEGORY(lcQpaEvents) Q_DECLARE_LOGGING_CATEGORY(lcQpaGl) Q_DECLARE_LOGGING_CATEGORY(lcQpaMime) @@ -71,6 +70,7 @@ Q_DECLARE_LOGGING_CATEGORY(lcQpaTrayIcon) class QWindow; class QPlatformScreen; +class QPlatformWindow; class QWindowsMenuBar; class QWindowsScreenManager; class QWindowsTabletSupport; @@ -85,7 +85,18 @@ class QTouchDevice; struct QWindowsUser32DLL { inline void init(); - + inline bool supportsPointerApi(); + + typedef BOOL (WINAPI *EnableMouseInPointer)(BOOL); + typedef BOOL (WINAPI *GetPointerType)(UINT32, PVOID); + typedef BOOL (WINAPI *GetPointerInfo)(UINT32, PVOID); + typedef BOOL (WINAPI *GetPointerDeviceRects)(HANDLE, RECT *, RECT *); + typedef BOOL (WINAPI *GetPointerTouchInfo)(UINT32, PVOID); + typedef BOOL (WINAPI *GetPointerFrameTouchInfo)(UINT32, UINT32 *, PVOID); + typedef BOOL (WINAPI *GetPointerFrameTouchInfoHistory)(UINT32, UINT32 *, UINT32 *, PVOID); + typedef BOOL (WINAPI *GetPointerPenInfo)(UINT32, PVOID); + typedef BOOL (WINAPI *GetPointerPenInfoHistory)(UINT32, UINT32 *, PVOID); + typedef BOOL (WINAPI *SkipPointerFrameMessages)(UINT32); typedef BOOL (WINAPI *SetProcessDPIAware)(); typedef BOOL (WINAPI *AddClipboardFormatListener)(HWND); typedef BOOL (WINAPI *RemoveClipboardFormatListener)(HWND); @@ -94,6 +105,19 @@ struct QWindowsUser32DLL typedef BOOL (WINAPI *EnableNonClientDpiScaling)(HWND); typedef int (WINAPI *GetWindowDpiAwarenessContext)(HWND); typedef int (WINAPI *GetAwarenessFromDpiAwarenessContext)(int); + typedef BOOL (WINAPI *SystemParametersInfoForDpi)(UINT, UINT, PVOID, UINT, UINT); + + // Windows pointer functions (Windows 8 or later). + EnableMouseInPointer enableMouseInPointer = nullptr; + GetPointerType getPointerType = nullptr; + GetPointerInfo getPointerInfo = nullptr; + GetPointerDeviceRects getPointerDeviceRects = nullptr; + GetPointerTouchInfo getPointerTouchInfo = nullptr; + GetPointerFrameTouchInfo getPointerFrameTouchInfo = nullptr; + GetPointerFrameTouchInfoHistory getPointerFrameTouchInfoHistory = nullptr; + GetPointerPenInfo getPointerPenInfo = nullptr; + GetPointerPenInfoHistory getPointerPenInfoHistory = nullptr; + SkipPointerFrameMessages skipPointerFrameMessages = nullptr; // Windows Vista onwards SetProcessDPIAware setProcessDPIAware = nullptr; @@ -110,6 +134,7 @@ struct QWindowsUser32DLL EnableNonClientDpiScaling enableNonClientDpiScaling = nullptr; GetWindowDpiAwarenessContext getWindowDpiAwarenessContext = nullptr; GetAwarenessFromDpiAwarenessContext getAwarenessFromDpiAwarenessContext = nullptr; + SystemParametersInfoForDpi systemParametersInfoForDpi = nullptr; }; // Shell scaling library (Windows 8.1 onwards) @@ -134,7 +159,8 @@ public: enum SystemInfoFlags { SI_RTL_Extensions = 0x1, - SI_SupportsTouch = 0x2 + SI_SupportsTouch = 0x2, + SI_SupportsPointer = 0x4, }; // Verbose flag set by environment variable QT_QPA_VERBOSE @@ -145,6 +171,8 @@ public: bool initTouch(); bool initTouch(unsigned integrationOptions); // For calls from QWindowsIntegration::QWindowsIntegration() only. + bool initTablet(unsigned integrationOptions); + bool initPointer(unsigned integrationOptions); int defaultDPI() const; @@ -191,12 +219,16 @@ public: void setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiAwareness); static int processDpiAwareness(); + void setDetectAltGrModifier(bool a); + // Returns a combination of SystemInfoFlags unsigned systemInfo() const; bool useRTLExtensions() const; QList<int> possibleKeys(const QKeyEvent *e) const; + static bool isSessionLocked(); + QWindowsMimeConverter &mimeConverter() const; QWindowsScreenManager &screenManager(); QWindowsTabletSupport *tabletSupport() const; @@ -208,6 +240,17 @@ public: bool asyncExpose() const; void setAsyncExpose(bool value); + static bool systemParametersInfo(unsigned action, unsigned param, void *out, unsigned dpi = 0); + static bool systemParametersInfoForScreen(unsigned action, unsigned param, void *out, + const QPlatformScreen *screen = nullptr); + static bool systemParametersInfoForWindow(unsigned action, unsigned param, void *out, + const QPlatformWindow *win = nullptr); + static bool nonClientMetrics(NONCLIENTMETRICS *ncm, unsigned dpi = 0); + static bool nonClientMetricsForScreen(NONCLIENTMETRICS *ncm, + const QPlatformScreen *screen = nullptr); + static bool nonClientMetricsForWindow(NONCLIENTMETRICS *ncm, + const QPlatformWindow *win = nullptr); + static DWORD readAdvancedExplorerSettings(const wchar_t *subKey, DWORD defaultValue); QTouchDevice *touchDevice() const; @@ -220,6 +263,7 @@ private: #ifndef QT_NO_CONTEXTMENU bool handleContextMenuEvent(QWindow *window, const MSG &msg); #endif + void handleExitSizeMove(QWindow *window); void unregisterWindowClasses(); QScopedPointer<QWindowsContextPrivate> d; diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index 72155a1d1b..4f669a5509 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -43,16 +43,16 @@ #include "qwindowswindow.h" #include "qwindowsscreen.h" -#include <QtGui/QBitmap> -#include <QtGui/QImage> -#include <QtGui/QBitmap> -#include <QtGui/QGuiApplication> -#include <QtGui/QScreen> +#include <QtGui/qbitmap.h> +#include <QtGui/qimage.h> +#include <QtGui/qbitmap.h> +#include <QtGui/qguiapplication.h> +#include <QtGui/qscreen.h> #include <QtGui/private/qguiapplication_p.h> // getPixmapCursor() #include <QtGui/private/qhighdpiscaling_p.h> -#include <QtCore/QDebug> -#include <QtCore/QScopedArrayPointer> +#include <QtCore/qdebug.h> +#include <QtCore/qscopedpointer.h> static bool initResources() { @@ -524,10 +524,11 @@ HCURSOR QWindowsCursor::createCursorFromShape(Qt::CursorShape cursorShape, const } // Load available standard cursors from resources - const QWindowsStandardCursorMapping *sEnd = standardCursors + sizeof(standardCursors) / sizeof(standardCursors[0]); - for (const QWindowsStandardCursorMapping *s = standardCursors; s < sEnd; ++s) { - if (s->shape == cursorShape) - return static_cast<HCURSOR>(LoadImage(0, s->resource, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED)); + for (const QWindowsStandardCursorMapping &s : standardCursors) { + if (s.shape == cursorShape) { + return static_cast<HCURSOR>(LoadImage(nullptr, s.resource, IMAGE_CURSOR, + 0, 0, LR_DEFAULTSIZE | LR_SHARED)); + } } qWarning("%s: Invalid cursor shape %d", __FUNCTION__, cursorShape); @@ -659,18 +660,18 @@ QPoint QWindowsCursor::mousePosition() return QPoint(p.x, p.y); } -QWindowsCursor::CursorState QWindowsCursor::cursorState() +QWindowsCursor::State QWindowsCursor::cursorState() { enum { cursorShowing = 0x1, cursorSuppressed = 0x2 }; // Windows 8: CURSOR_SUPPRESSED CURSORINFO cursorInfo; cursorInfo.cbSize = sizeof(CURSORINFO); if (GetCursorInfo(&cursorInfo)) { - if (cursorInfo.flags & CursorShowing) - return CursorShowing; + if (cursorInfo.flags & cursorShowing) + return State::Showing; if (cursorInfo.flags & cursorSuppressed) - return CursorSuppressed; + return State::Suppressed; } - return CursorHidden; + return State::Hidden; } QPoint QWindowsCursor::pos() const diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h index 345f47597e..8495b51a5a 100644 --- a/src/plugins/platforms/windows/qwindowscursor.h +++ b/src/plugins/platforms/windows/qwindowscursor.h @@ -43,8 +43,8 @@ #include <QtCore/qt_windows.h> #include <qpa/qplatformcursor.h> -#include <QtCore/QSharedPointer> -#include <QtCore/QHash> +#include <QtCore/qsharedpointer.h> +#include <QtCore/qhash.h> QT_BEGIN_NAMESPACE @@ -89,10 +89,10 @@ typedef QSharedPointer<CursorHandle> CursorHandlePtr; class QWindowsCursor : public QPlatformCursor { public: - enum CursorState { - CursorShowing, - CursorHidden, - CursorSuppressed // Cursor suppressed by touch interaction (Windows 8). + enum class State { + Showing, + Hidden, + Suppressed // Cursor suppressed by touch interaction (Windows 8). }; struct PixmapCursor { @@ -119,7 +119,7 @@ public: static HCURSOR createCursorFromShape(Qt::CursorShape cursorShape, const QPlatformScreen *screen = nullptr); static QPoint mousePosition(); - static CursorState cursorState(); + static State cursorState(); CursorHandlePtr standardWindowCursor(Qt::CursorShape s = Qt::ArrowCursor); CursorHandlePtr pixmapWindowCursor(const QCursor &c); diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 80ee7b2287..681b35eb7c 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -51,24 +51,23 @@ #include "qwindowsintegration.h" #include "qwindowstheme.h" // Color conversion helpers -#include <QtGui/QGuiApplication> -#include <QtGui/QColor> - -#include <QtCore/QDebug> -#include <QtCore/QRegularExpression> -#include <QtCore/QTimer> -#include <QtCore/QDir> -#include <QtCore/QScopedArrayPointer> -#include <QtCore/QSharedPointer> -#include <QtCore/QObject> -#include <QtCore/QThread> -#include <QtCore/QSysInfo> -#include <QtCore/QSharedData> -#include <QtCore/QExplicitlySharedDataPointer> -#include <QtCore/QMutex> -#include <QtCore/QMutexLocker> -#include <QtCore/QUuid> -#include <QtCore/QTemporaryFile> +#include <QtGui/qguiapplication.h> +#include <QtGui/qcolor.h> + +#include <QtCore/qdebug.h> +#include <QtCore/qregularexpression.h> +#include <QtCore/qtimer.h> +#include <QtCore/qdir.h> +#include <QtCore/qscopedpointer.h> +#include <QtCore/qsharedpointer.h> +#include <QtCore/qobject.h> +#include <QtCore/qthread.h> +#include <QtCore/qsysinfo.h> +#include <QtCore/qshareddata.h> +#include <QtCore/qshareddata.h> +#include <QtCore/qmutex.h> +#include <QtCore/quuid.h> +#include <QtCore/qtemporaryfile.h> #include <QtCore/private/qsystemlibrary_p.h> #include <algorithm> @@ -365,7 +364,7 @@ static BOOL QT_WIN_CALLBACK findDialogEnumWindowsProc(HWND hwnd, LPARAM lParam) wchar_t buf[256]; if (!RealGetWindowClass(hwnd, buf, sizeof(buf)/sizeof(wchar_t)) || buf[0] != L'#') return TRUE; - if (!GetWindowTextW(hwnd, buf, sizeof(buf)/sizeof(wchar_t)) || wcscmp(buf, context->title.data())) + if (!GetWindowTextW(hwnd, buf, sizeof(buf)/sizeof(wchar_t)) || wcscmp(buf, context->title.data()) != 0) return TRUE; context->hwnd = hwnd; return FALSE; @@ -508,6 +507,7 @@ class QWindowsNativeFileDialogBase; class QWindowsNativeFileDialogEventHandler : public QWindowsComBase<IFileDialogEvents> { + Q_DISABLE_COPY(QWindowsNativeFileDialogEventHandler) public: static IFileDialogEvents *create(QWindowsNativeFileDialogBase *nativeFileDialog); @@ -523,7 +523,6 @@ public: QWindowsNativeFileDialogEventHandler(QWindowsNativeFileDialogBase *nativeFileDialog) : m_nativeFileDialog(nativeFileDialog) {} - virtual ~QWindowsNativeFileDialogEventHandler() {} private: QWindowsNativeFileDialogBase *m_nativeFileDialog; @@ -787,7 +786,7 @@ class QWindowsNativeFileDialogBase : public QWindowsNativeDialogBase Q_OBJECT Q_PROPERTY(bool hideFiltersDetails READ hideFiltersDetails WRITE setHideFiltersDetails) public: - ~QWindowsNativeFileDialogBase(); + ~QWindowsNativeFileDialogBase() override; inline static QWindowsNativeFileDialogBase *create(QFileDialogOptions::AcceptMode am, const QWindowsFileDialogSharedData &data); @@ -1027,7 +1026,7 @@ static QList<FilterSpec> filterSpecs(const QStringList &filters, Q_ASSERT(filterSeparatorRE.isValid()); // Split filter specification as 'Texts (*.txt[;] *.doc)', '*.txt[;] *.doc' // into description and filters specification as '*.txt;*.doc' - foreach (const QString &filterString, filters) { + for (const QString &filterString : filters) { const int openingParenPos = filterString.lastIndexOf(QLatin1Char('(')); const int closingParenPos = openingParenPos != -1 ? filterString.indexOf(QLatin1Char(')'), openingParenPos + 1) : -1; @@ -1322,7 +1321,7 @@ void QWindowsNativeSaveFileDialog::setNameFilters(const QStringList &f) // filter only if a default suffix is set (see docs). Set the first available // suffix unless we have a defaultSuffix. if (!hasDefaultSuffix()) { - foreach (const QString &filter, f) { + for (const QString &filter : f) { const QString suffix = suffixFromFilter(filter); if (!suffix.isEmpty()) { setDefaultSuffixSys(suffix); @@ -1546,8 +1545,8 @@ QWindowsNativeDialogBase *QWindowsFileDialogHelper::createNativeDialog() result->updateDirectory(); result->updateSelectedNameFilter(); const QList<QUrl> initialSelection = opts->initiallySelectedFiles(); - if (initialSelection.size() > 0) { - const QUrl url = initialSelection.front(); + if (!initialSelection.empty()) { + const QUrl &url = initialSelection.constFirst(); if (url.isLocalFile()) { QFileInfo info(url.toLocalFile()); if (!info.isDir()) @@ -1699,7 +1698,7 @@ void QWindowsXpNativeFileDialog::doExec(HWND owner) const QStringList nameFilters = m_options->nameFilters(); if (selectedFilterIndex >= 0 && selectedFilterIndex < nameFilters.size()) m_data.setSelectedNameFilter(nameFilters.at(selectedFilterIndex)); - QUrl firstFile = selectedFiles.front(); + const QUrl &firstFile = selectedFiles.constFirst(); m_data.setDirectory(firstFile.adjusted(QUrl::RemoveFilename)); m_result = QPlatformDialogHelper::Accepted; emit accepted(); @@ -1728,7 +1727,7 @@ int QWindowsXpNativeFileDialog::existingDirCallback(HWND hwnd, UINT uMsg, LPARAM switch (uMsg) { case BFFM_INITIALIZED: { if (!m_title.isEmpty()) - SetWindowText(hwnd, (wchar_t *)m_title.utf16()); + SetWindowText(hwnd, reinterpret_cast<const wchar_t *>(m_title.utf16())); const QString initialFile = QDir::toNativeSeparators(m_data.directory().toLocalFile()); if (!initialFile.isEmpty()) SendMessage(hwnd, BFFM_SETSELECTION, TRUE, LPARAM(initialFile.utf16())); @@ -1781,12 +1780,12 @@ void QWindowsXpNativeFileDialog::populateOpenFileName(OPENFILENAME *ofn, HWND ow // Create a buffer with the filter strings. int totalStringLength = 0; - QList<FilterSpec> specs = + const QList<FilterSpec> specs = filterSpecs(m_options->nameFilters(), m_options->options() & QFileDialogOptions::HideNameFilterDetails, &totalStringLength); const int size = specs.size(); wchar_t *ptr = new wchar_t[totalStringLength + 2 * size + 1]; ofn->lpstrFilter = ptr; - foreach (const FilterSpec &spec, specs) { + for (const FilterSpec &spec : specs) { ptr += spec.description.toWCharArray(ptr); *ptr++ = 0; ptr += spec.filter.toWCharArray(ptr); @@ -1874,7 +1873,7 @@ QList<QUrl> QWindowsXpNativeFileDialog::execFileNames(HWND owner, int *selectedF class QWindowsXpFileDialogHelper : public QWindowsDialogHelperBase<QPlatformFileDialogHelper> { public: - QWindowsXpFileDialogHelper() {} + QWindowsXpFileDialogHelper() = default; bool supportsNonModalDialog(const QWindow * /* parent */ = 0) const override { return false; } bool defaultNameFilterDisables() const override { return true; } diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.h b/src/plugins/platforms/windows/qwindowsdialoghelpers.h index 55f112c57a..6099ea9ac6 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.h +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.h @@ -43,8 +43,8 @@ #include <QtCore/qt_windows.h> #include <qpa/qplatformdialoghelper.h> #include <qpa/qplatformtheme.h> -#include <QtCore/QStringList> -#include <QtCore/QSharedPointer> +#include <QtCore/qstringlist.h> +#include <QtCore/qsharedpointer.h> QT_BEGIN_NAMESPACE @@ -78,7 +78,7 @@ public: virtual bool supportsNonModalDialog(const QWindow * /* parent */ = 0) const { return true; } protected: - QWindowsDialogHelperBase() {} + QWindowsDialogHelperBase() = default; QWindowsNativeDialogBase *nativeDialog() const; inline bool hasNativeDialog() const { return m_nativeDialog; } void timerEvent(QTimerEvent *) override; diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index e427ee162a..ee82b2f022 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -50,19 +50,19 @@ #include "qwindowsmousehandler.h" #include "qwindowscursor.h" -#include <QtGui/QMouseEvent> -#include <QtGui/QPixmap> -#include <QtGui/QPainter> -#include <QtGui/QRasterWindow> -#include <QtGui/QGuiApplication> +#include <QtGui/qevent.h> +#include <QtGui/qpixmap.h> +#include <QtGui/qpainter.h> +#include <QtGui/qrasterwindow.h> +#include <QtGui/qguiapplication.h> #include <qpa/qwindowsysteminterface_p.h> #include <QtGui/private/qdnd_p.h> #include <QtGui/private/qguiapplication_p.h> #include <QtGui/private/qhighdpiscaling_p.h> -#include <QtCore/QDebug> -#include <QtCore/QBuffer> -#include <QtCore/QPoint> +#include <QtCore/qdebug.h> +#include <QtCore/qbuffer.h> +#include <QtCore/qpoint.h> #include <shlobj.h> @@ -225,7 +225,7 @@ public: }; explicit QWindowsOleDropSource(QWindowsDrag *drag); - virtual ~QWindowsOleDropSource(); + ~QWindowsOleDropSource() override; void createCursors(); @@ -260,7 +260,7 @@ private: }; QWindowsOleDropSource::QWindowsOleDropSource(QWindowsDrag *drag) - : m_mode(QWindowsCursor::cursorState() != QWindowsCursor::CursorSuppressed ? MouseDrag : TouchDrag) + : m_mode(QWindowsCursor::cursorState() != QWindowsCursor::State::Suppressed ? MouseDrag : TouchDrag) , m_drag(drag) , m_windowUnderMouse(QWindowsContext::instance()->windowUnderMouse()) , m_currentButtons(Qt::NoButton) @@ -402,20 +402,16 @@ QWindowsOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) switch (result) { case DRAGDROP_S_DROP: case DRAGDROP_S_CANCEL: - QGuiApplicationPrivate::modifier_buttons = toQtKeyboardModifiers(grfKeyState); - if (buttons != QGuiApplicationPrivate::mouse_buttons) { - if (m_windowUnderMouse.isNull() || m_mode == TouchDrag || fEscapePressed == TRUE) { - QGuiApplicationPrivate::mouse_buttons = buttons; - } else { - // QTBUG 66447: Synthesize a mouse release to the window under mouse at - // start of the DnD operation as Windows does not send any. - const QPoint globalPos = QWindowsCursor::mousePosition(); - const QPoint localPos = m_windowUnderMouse->handle()->mapFromGlobal(globalPos); - QWindowSystemInterface::handleMouseEvent(m_windowUnderMouse.data(), - QPointF(localPos), QPointF(globalPos), - QWindowsMouseHandler::queryMouseButtons(), - Qt::LeftButton, QEvent::MouseButtonRelease); - } + if (!m_windowUnderMouse.isNull() && m_mode != TouchDrag && fEscapePressed == FALSE + && buttons != QGuiApplicationPrivate::mouse_buttons) { + // QTBUG 66447: Synthesize a mouse release to the window under mouse at + // start of the DnD operation as Windows does not send any. + const QPoint globalPos = QWindowsCursor::mousePosition(); + const QPoint localPos = m_windowUnderMouse->handle()->mapFromGlobal(globalPos); + QWindowSystemInterface::handleMouseEvent(m_windowUnderMouse.data(), + QPointF(localPos), QPointF(globalPos), + QWindowsMouseHandler::queryMouseButtons(), + Qt::LeftButton, QEvent::MouseButtonRelease); } m_currentButtons = Qt::NoButton; break; @@ -459,7 +455,7 @@ QWindowsOleDropSource::GiveFeedback(DWORD dwEffect) break; case TouchDrag: // "Touch drag" with an unsuppressed cursor may happen with RDP (see createCursors()) - if (QWindowsCursor::cursorState() != QWindowsCursor::CursorSuppressed) + if (QWindowsCursor::cursorState() != QWindowsCursor::State::Suppressed) SetCursor(nullptr); if (!m_touchDragWindow) m_touchDragWindow = new QWindowsDragCursorWindow; @@ -507,11 +503,13 @@ void QWindowsOleDropTarget::handleDrag(QWindow *window, DWORD grfKeyState, QWindowsDrag *windowsDrag = QWindowsDrag::instance(); const Qt::DropActions actions = translateToQDragDropActions(*pdwEffect); - QGuiApplicationPrivate::modifier_buttons = toQtKeyboardModifiers(grfKeyState); - QGuiApplicationPrivate::mouse_buttons = toQtMouseButtons(grfKeyState); + const Qt::KeyboardModifiers keyboardModifiers = toQtKeyboardModifiers(grfKeyState); + const Qt::MouseButtons mouseButtons = toQtMouseButtons(grfKeyState); const QPlatformDragQtResponse response = - QWindowSystemInterface::handleDrag(window, windowsDrag->dropData(), m_lastPoint, actions); + QWindowSystemInterface::handleDrag(window, windowsDrag->dropData(), + m_lastPoint, actions, + mouseButtons, keyboardModifiers); m_answerRect = response.answerRect(); const Qt::DropAction action = response.acceptedAction(); @@ -523,8 +521,7 @@ void QWindowsOleDropTarget::handleDrag(QWindow *window, DWORD grfKeyState, *pdwEffect = m_chosenEffect; qCDebug(lcQpaMime) << __FUNCTION__ << m_window << windowsDrag->dropData() << " supported actions=" << actions - << " mods=" << QGuiApplicationPrivate::modifier_buttons - << " mouse=" << QGuiApplicationPrivate::mouse_buttons + << " mods=" << keyboardModifiers << " mouse=" << mouseButtons << " accepted: " << response.isAccepted() << action << m_answerRect << " effect" << *pdwEffect; } @@ -575,13 +572,11 @@ QWindowsOleDropTarget::DragLeave() qCDebug(lcQpaMime) << __FUNCTION__ << ' ' << m_window; - QWindowSystemInterface::handleDrag(m_window, 0, QPoint(), Qt::IgnoreAction); + QWindowSystemInterface::handleDrag(m_window, 0, QPoint(), Qt::IgnoreAction, + Qt::NoButton, Qt::NoModifier); - if (!QDragManager::self()->source()) { - QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier; - QGuiApplicationPrivate::mouse_buttons = Qt::NoButton; + if (!QDragManager::self()->source()) m_lastKeyState = 0; - } QWindowsDrag::instance()->releaseDropDataObject(); return NOERROR; @@ -600,18 +595,16 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, << "keys=" << grfKeyState << "pt=" << pt.x << ',' << pt.y; m_lastPoint = QWindowsGeometryHint::mapFromGlobal(m_window, QPoint(pt.x,pt.y)); - // grfKeyState does not all ways contain button state in the drop - QGuiApplicationPrivate::mouse_buttons = toQtMouseButtons(m_lastKeyState); - QGuiApplicationPrivate::modifier_buttons = toQtKeyboardModifiers(grfKeyState); QWindowsDrag *windowsDrag = QWindowsDrag::instance(); const QPlatformDropQtResponse response = QWindowSystemInterface::handleDrop(m_window, windowsDrag->dropData(), m_lastPoint, - translateToQDragDropActions(*pdwEffect)); + translateToQDragDropActions(*pdwEffect), + toQtMouseButtons(grfKeyState), + toQtKeyboardModifiers(grfKeyState)); - QGuiApplicationPrivate::mouse_buttons = toQtMouseButtons(grfKeyState); m_lastKeyState = grfKeyState; if (response.isAccepted()) { @@ -659,6 +652,7 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, */ bool QWindowsDrag::m_canceled = false; +bool QWindowsDrag::m_dragging = false; QWindowsDrag::QWindowsDrag() = default; @@ -706,7 +700,10 @@ Qt::DropAction QWindowsDrag::drag(QDrag *drag) const DWORD allowedEffects = translateToWinDragEffects(possibleActions); qCDebug(lcQpaMime) << '>' << __FUNCTION__ << "possible Actions=0x" << hex << int(possibleActions) << "effects=0x" << allowedEffects << dec; + // Indicate message handlers we are in DoDragDrop() event loop. + QWindowsDrag::m_dragging = true; const HRESULT r = DoDragDrop(dropDataObject, windowDropSource, allowedEffects, &resultEffect); + QWindowsDrag::m_dragging = false; const DWORD reportedPerformedEffect = dropDataObject->reportedPerformedEffect(); if (r == DRAGDROP_S_DROP) { if (reportedPerformedEffect == DROPEFFECT_MOVE && resultEffect != DROPEFFECT_MOVE) { diff --git a/src/plugins/platforms/windows/qwindowsdrag.h b/src/plugins/platforms/windows/qwindowsdrag.h index d934679488..5f30c59882 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.h +++ b/src/plugins/platforms/windows/qwindowsdrag.h @@ -44,8 +44,8 @@ #include "qwindowsinternalmimedata.h" #include <qpa/qplatformdrag.h> +#include <QtGui/qpixmap.h> #include <QtGui/qdrag.h> -#include <QtGui/QPixmap> struct IDropTargetHelper; @@ -55,7 +55,7 @@ class QPlatformScreen; class QWindowsDropMimeData : public QWindowsInternalMimeData { public: - QWindowsDropMimeData() {} + QWindowsDropMimeData() = default; IDataObject *retrieveDataObject() const override; }; @@ -63,7 +63,7 @@ class QWindowsOleDropTarget : public QWindowsComBase<IDropTarget> { public: explicit QWindowsOleDropTarget(QWindow *w); - virtual ~QWindowsOleDropTarget(); + ~QWindowsOleDropTarget() override; // IDropTarget methods STDMETHOD(DragEnter)(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect); @@ -92,6 +92,7 @@ public: static QWindowsDrag *instance(); void cancelDrag() override { QWindowsDrag::m_canceled = true; } static bool isCanceled() { return QWindowsDrag::m_canceled; } + static bool isDragging() { return QWindowsDrag::m_dragging; } IDataObject *dropDataObject() const { return m_dropDataObject; } void setDropDataObject(IDataObject *dataObject) { m_dropDataObject = dataObject; } @@ -102,6 +103,7 @@ public: private: static bool m_canceled; + static bool m_dragging; QWindowsDropMimeData m_dropData; IDataObject *m_dropDataObject = nullptr; diff --git a/src/plugins/platforms/windows/qwindowsdropdataobject.cpp b/src/plugins/platforms/windows/qwindowsdropdataobject.cpp index bd532ab70e..229ff92894 100644 --- a/src/plugins/platforms/windows/qwindowsdropdataobject.cpp +++ b/src/plugins/platforms/windows/qwindowsdropdataobject.cpp @@ -39,8 +39,8 @@ #include "qwindowsdropdataobject.h" -#include <QtCore/QUrl> -#include <QtCore/QMimeData> +#include <QtCore/qurl.h> +#include <QtCore/qmimedata.h> QT_BEGIN_NAMESPACE @@ -60,9 +60,7 @@ QWindowsDropDataObject::QWindowsDropDataObject(QMimeData *mimeData) : { } -QWindowsDropDataObject::~QWindowsDropDataObject() -{ -} +QWindowsDropDataObject::~QWindowsDropDataObject() = default; STDMETHODIMP QWindowsDropDataObject::GetData(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium) diff --git a/src/plugins/platforms/windows/qwindowsdropdataobject.h b/src/plugins/platforms/windows/qwindowsdropdataobject.h index 5ef72c9336..16ba7b036a 100644 --- a/src/plugins/platforms/windows/qwindowsdropdataobject.h +++ b/src/plugins/platforms/windows/qwindowsdropdataobject.h @@ -48,7 +48,7 @@ class QWindowsDropDataObject : public QWindowsOleDataObject { public: explicit QWindowsDropDataObject(QMimeData *mimeData); - virtual ~QWindowsDropDataObject(); + ~QWindowsDropDataObject() override; // overridden IDataObject methods STDMETHOD(GetData)(LPFORMATETC pformatetcIn, LPSTGMEDIUM pmedium); diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index 4632c9c157..52f3c56beb 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -41,8 +41,8 @@ #include "qwindowscontext.h" #include "qwindowswindow.h" -#include <QtCore/QDebug> -#include <QtGui/QOpenGLContext> +#include <QtCore/qdebug.h> +#include <QtGui/qopenglcontext.h> #if defined(QT_OPENGL_ES_2_ANGLE) || defined(QT_OPENGL_DYNAMIC) # include <EGL/eglext.h> @@ -889,19 +889,19 @@ EGLConfig QWindowsEGLContext::chooseConfig(const QSurfaceFormat &format) EGLint green = 0; EGLint blue = 0; EGLint alpha = 0; - for (int i = 0; i < configs.size(); ++i) { + for (const EGLConfig &config : configs) { if (confAttrRed) - QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, configs[i], EGL_RED_SIZE, &red); + QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, config, EGL_RED_SIZE, &red); if (confAttrGreen) - QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, configs[i], EGL_GREEN_SIZE, &green); + QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &green); if (confAttrBlue) - QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, configs[i], EGL_BLUE_SIZE, &blue); + QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blue); if (confAttrAlpha) - QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, configs[i], EGL_ALPHA_SIZE, &alpha); + QWindowsEGLStaticContext::libEGL.eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alpha); if (red == confAttrRed && green == confAttrGreen && blue == confAttrBlue && alpha == confAttrAlpha) - return configs[i]; + return config; } } while (reduceConfigAttributes(&configureAttributes)); diff --git a/src/plugins/platforms/windows/qwindowseglcontext.h b/src/plugins/platforms/windows/qwindowseglcontext.h index 3e5f2c81d5..8a1e1ddae8 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.h +++ b/src/plugins/platforms/windows/qwindowseglcontext.h @@ -113,7 +113,7 @@ class QWindowsEGLStaticContext : public QWindowsStaticOpenGLContext public: static QWindowsEGLStaticContext *create(QWindowsOpenGLTester::Renderers preferredType); - ~QWindowsEGLStaticContext(); + ~QWindowsEGLStaticContext() override; EGLDisplay display() const { return m_display; } @@ -143,7 +143,7 @@ public: QWindowsEGLContext(QWindowsEGLStaticContext *staticContext, const QSurfaceFormat &format, QPlatformOpenGLContext *share); - ~QWindowsEGLContext(); + ~QWindowsEGLContext() override; bool makeCurrent(QPlatformSurface *surface) override; void doneCurrent() override; diff --git a/src/plugins/platforms/windows/qwindowsgdiintegration.cpp b/src/plugins/platforms/windows/qwindowsgdiintegration.cpp index 51f74518f7..c88f669eb5 100644 --- a/src/plugins/platforms/windows/qwindowsgdiintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsgdiintegration.cpp @@ -42,7 +42,7 @@ #include "qwindowsbackingstore.h" #include "qwindowsgdinativeinterface.h" -#include <QtCore/QDebug> +#include <QtCore/qdebug.h> #include <QtGui/private/qpixmap_raster_p.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsgdiintegration.h b/src/plugins/platforms/windows/qwindowsgdiintegration.h index ec67a99bc9..74ce3ffd49 100644 --- a/src/plugins/platforms/windows/qwindowsgdiintegration.h +++ b/src/plugins/platforms/windows/qwindowsgdiintegration.h @@ -49,7 +49,7 @@ class QWindowsGdiIntegration : public QWindowsIntegration { public: explicit QWindowsGdiIntegration(const QStringList ¶mList); - virtual ~QWindowsGdiIntegration(); + ~QWindowsGdiIntegration() override; QPlatformNativeInterface *nativeInterface() const override; QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const override; diff --git a/src/plugins/platforms/windows/qwindowsgdinativeinterface.cpp b/src/plugins/platforms/windows/qwindowsgdinativeinterface.cpp index c7796d959e..4ba7108f45 100644 --- a/src/plugins/platforms/windows/qwindowsgdinativeinterface.cpp +++ b/src/plugins/platforms/windows/qwindowsgdinativeinterface.cpp @@ -40,7 +40,7 @@ #include "qwindowsgdinativeinterface.h" #include "qwindowsbackingstore.h" -#include <QtGui/QBackingStore> +#include <QtGui/qbackingstore.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index cc8174051a..851a6c961e 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -42,11 +42,11 @@ #include "qwindowswindow.h" #include "qwindowsintegration.h" -#include <QtCore/QDebug> -#include <QtCore/QSysInfo> -#include <QtGui/QGuiApplication> +#include <QtCore/qdebug.h> +#include <QtCore/qsysinfo.h> +#include <QtGui/qguiapplication.h> #include <qpa/qplatformnativeinterface.h> -#include <QtPlatformHeaders/QWGLNativeContext> +#include <QtPlatformHeaders/qwglnativecontext.h> #include <algorithm> @@ -206,18 +206,12 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering) BOOL QWindowsOpengl32DLL::swapBuffers(HDC dc) { - if (moduleIsNotOpengl32()) - return wglSwapBuffers(dc); - else - return SwapBuffers(dc); + return moduleIsNotOpengl32() ? wglSwapBuffers(dc) : SwapBuffers(dc); } BOOL QWindowsOpengl32DLL::setPixelFormat(HDC dc, int pf, const PIXELFORMATDESCRIPTOR *pfd) { - if (moduleIsNotOpengl32()) - return wglSetPixelFormat(dc, pf, pfd); - else - return SetPixelFormat(dc, pf, pfd); + return moduleIsNotOpengl32() ? wglSetPixelFormat(dc, pf, pfd) : SetPixelFormat(dc, pf, pfd); } QWindowsOpenGLContext *QOpenGLStaticContext::createContext(QOpenGLContext *context) diff --git a/src/plugins/platforms/windows/qwindowsglcontext.h b/src/plugins/platforms/windows/qwindowsglcontext.h index 87c3723c26..199f8112e3 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.h +++ b/src/plugins/platforms/windows/qwindowsglcontext.h @@ -43,7 +43,7 @@ #include <QtCore/qt_windows.h> #include "qwindowsopenglcontext.h" -#include <QtGui/QOpenGLContext> +#include <QtGui/qopenglcontext.h> #include <vector> @@ -170,13 +170,15 @@ public: static QOpenGLStaticContext *create(bool softwareRendering = false); static QByteArray getGlString(unsigned int which); - QWindowsOpenGLContext *createContext(QOpenGLContext *context); - void *moduleHandle() const { return opengl32.moduleHandle(); } - QOpenGLContext::OpenGLModuleType moduleType() const { return QOpenGLContext::LibGL; } + QWindowsOpenGLContext *createContext(QOpenGLContext *context) override; + void *moduleHandle() const override { return opengl32.moduleHandle(); } + QOpenGLContext::OpenGLModuleType moduleType() const override + { return QOpenGLContext::LibGL; } // For a regular opengl32.dll report the ThreadedOpenGL capability. // For others, which are likely to be software-only, don't. - bool supportsThreadedOpenGL() const { return !opengl32.moduleIsNotOpengl32(); } + bool supportsThreadedOpenGL() const override + { return !opengl32.moduleIsNotOpengl32(); } const QByteArray vendor; const QByteArray renderer; @@ -198,7 +200,7 @@ class QWindowsGLContext : public QWindowsOpenGLContext { public: explicit QWindowsGLContext(QOpenGLStaticContext *staticContext, QOpenGLContext *context); - ~QWindowsGLContext(); + ~QWindowsGLContext() override; bool isSharing() const override { return m_context->shareHandle(); } bool isValid() const override { return m_renderingContext && !m_lost; } QSurfaceFormat format() const override { return m_obtainedFormat; } diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index 261c931f2b..30da0da1de 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -43,16 +43,15 @@ #include "qwindowsintegration.h" #include "qwindowsmousehandler.h" -#include <QtCore/QDebug> -#include <QtCore/QObject> -#include <QtCore/QRect> -#include <QtCore/QRectF> -#include <QtCore/QTextBoundaryFinder> - -#include <QtGui/QInputMethodEvent> -#include <QtGui/QTextCharFormat> -#include <QtGui/QPalette> -#include <QtGui/QGuiApplication> +#include <QtCore/qdebug.h> +#include <QtCore/qobject.h> +#include <QtCore/qrect.h> +#include <QtCore/qtextboundaryfinder.h> + +#include <QtGui/qevent.h> +#include <QtGui/qtextformat.h> +#include <QtGui/qpalette.h> +#include <QtGui/qguiapplication.h> #include <private/qhighdpiscaling_p.h> diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.h b/src/plugins/platforms/windows/qwindowsinputcontext.h index d647628ff1..a47585c29e 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.h +++ b/src/plugins/platforms/windows/qwindowsinputcontext.h @@ -42,8 +42,8 @@ #include <QtCore/qt_windows.h> -#include <QtCore/QLocale> -#include <QtCore/QPointer> +#include <QtCore/qlocale.h> +#include <QtCore/qpointer.h> #include <qpa/qplatforminputcontext.h> QT_BEGIN_NAMESPACE @@ -53,6 +53,7 @@ class QWindowsWindow; class QWindowsInputContext : public QPlatformInputContext { + Q_DISABLE_COPY(QWindowsInputContext) Q_OBJECT struct CompositionContext @@ -65,7 +66,7 @@ class QWindowsInputContext : public QPlatformInputContext }; public: explicit QWindowsInputContext(); - ~QWindowsInputContext(); + ~QWindowsInputContext() override; static void setWindowsImeEnabled(QWindowsWindow *platformWindow, bool enabled); diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 0a9e8b9d91..9e03d09607 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -59,7 +59,7 @@ #endif #include "qwindowsinputcontext.h" #include "qwindowskeymapper.h" -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) # include "uiautomation/qwindowsuiaaccessibility.h" #endif @@ -76,8 +76,8 @@ #include <QtEventDispatcherSupport/private/qwindowsguieventdispatcher_p.h> -#include <QtCore/QDebug> -#include <QtCore/QVariant> +#include <QtCore/qdebug.h> +#include <QtCore/qvariant.h> #include <limits.h> @@ -133,6 +133,7 @@ QT_BEGIN_NAMESPACE struct QWindowsIntegrationPrivate { + Q_DISABLE_COPY(QWindowsIntegrationPrivate) explicit QWindowsIntegrationPrivate(const QStringList ¶mList); ~QWindowsIntegrationPrivate(); @@ -150,7 +151,7 @@ struct QWindowsIntegrationPrivate QScopedPointer<QWindowsStaticOpenGLContext> m_staticOpenGLContext; #endif // QT_NO_OPENGL QScopedPointer<QPlatformInputContext> m_inputContext; -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QWindowsUiaAccessibility m_accessibility; #endif QWindowsServices m_services; @@ -184,7 +185,7 @@ static inline unsigned parseOptions(const QStringList ¶mList, QtWindows::ProcessDpiAwareness *dpiAwareness) { unsigned options = 0; - foreach (const QString ¶m, paramList) { + for (const QString ¶m : paramList) { if (param.startsWith(QLatin1String("fontengine="))) { if (param.endsWith(QLatin1String("freetype"))) { options |= QWindowsIntegration::FontDatabaseFreeType; @@ -197,6 +198,8 @@ static inline unsigned parseOptions(const QStringList ¶mList, } else if (param.endsWith(QLatin1String("none"))) { options |= QWindowsIntegration::NoNativeDialogs; } + } else if (param == QLatin1String("altgr")) { + options |= QWindowsIntegration::DetectAltGrModifier; } else if (param == QLatin1String("gl=gdi")) { options |= QWindowsIntegration::DisableArb; } else if (param == QLatin1String("nodirectwrite")) { @@ -212,6 +215,8 @@ static inline unsigned parseOptions(const QStringList ¶mList, options |= QWindowsIntegration::AlwaysUseNativeMenus; } else if (param == QLatin1String("menus=none")) { options |= QWindowsIntegration::NoNativeMenus; + } else if (param == QLatin1String("nowmpointer")) { + options |= QWindowsIntegration::DontUseWMPointer; } else { qWarning() << "Unknown option" << param; } @@ -230,8 +235,15 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mL QtWindows::ProcessDpiAwareness dpiAwareness = QtWindows::ProcessPerMonitorDpiAware; m_options = parseOptions(paramList, &tabletAbsoluteRange, &dpiAwareness); QWindowsFontDatabase::setFontOptions(m_options); - if (tabletAbsoluteRange >= 0) - m_context.setTabletAbsoluteRange(tabletAbsoluteRange); + + if (m_context.initPointer(m_options)) { + QCoreApplication::setAttribute(Qt::AA_CompressHighFrequencyEvents); + } else { + m_context.initTablet(m_options); + if (tabletAbsoluteRange >= 0) + m_context.setTabletAbsoluteRange(tabletAbsoluteRange); + } + if (!dpiAwarenessSet) { // Set only once in case of repeated instantiations of QGuiApplication. if (!QCoreApplication::testAttribute(Qt::AA_PluginApplication)) { m_context.setProcessDpiAwareness(dpiAwareness); @@ -248,8 +260,7 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mL QWindowsIntegrationPrivate::~QWindowsIntegrationPrivate() { - if (m_fontDatabase) - delete m_fontDatabase; + delete m_fontDatabase; } QWindowsIntegration *QWindowsIntegration::m_instance = nullptr; @@ -262,6 +273,7 @@ QWindowsIntegration::QWindowsIntegration(const QStringList ¶mList) : d->m_clipboard.registerViewer(); #endif d->m_context.screenManager().handleScreenChanges(); + d->m_context.setDetectAltGrModifier((d->m_options & DetectAltGrModifier) != 0); } QWindowsIntegration::~QWindowsIntegration() @@ -332,7 +344,7 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons << "\n Requested: " << requested.geometry << " frame incl.=" << QWindowsGeometryHint::positionIncludesFrame(window) << ' ' << requested.flags - << "\n Obtained : " << obtained.geometry << " margins=" << obtained.frame + << "\n Obtained : " << obtained.geometry << " margins=" << obtained.fullFrameMargins << " handle=" << obtained.hwnd << ' ' << obtained.flags << '\n'; if (Q_UNLIKELY(!obtained.hwnd)) @@ -381,7 +393,7 @@ QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate() switch (requestedRenderer) { case QWindowsOpenGLTester::DesktopGl: if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create()) { - if ((QWindowsOpenGLTester::supportedRenderers() & QWindowsOpenGLTester::DisableRotationFlag) + if ((QWindowsOpenGLTester::supportedRenderers(requestedRenderer) & QWindowsOpenGLTester::DisableRotationFlag) && !QWindowsScreen::setOrientationPreference(Qt::LandscapeOrientation)) { qCWarning(lcQpaGl, "Unable to disable rotation."); } @@ -395,19 +407,23 @@ QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate() case QWindowsOpenGLTester::AngleRendererD3d11Warp: return QWindowsEGLStaticContext::create(requestedRenderer); case QWindowsOpenGLTester::Gles: - return QWindowsEGLStaticContext::create(QWindowsOpenGLTester::supportedGlesRenderers()); + return QWindowsEGLStaticContext::create(requestedRenderer); case QWindowsOpenGLTester::SoftwareRasterizer: if (QWindowsStaticOpenGLContext *swCtx = QOpenGLStaticContext::create(true)) return swCtx; qCWarning(lcQpaGl, "Software OpenGL failed. Falling back to system OpenGL."); - if (QWindowsOpenGLTester::supportedRenderers() & QWindowsOpenGLTester::DesktopGl) + if (QWindowsOpenGLTester::supportedRenderers(requestedRenderer) & QWindowsOpenGLTester::DesktopGl) return QOpenGLStaticContext::create(); return nullptr; default: break; } - const QWindowsOpenGLTester::Renderers supportedRenderers = QWindowsOpenGLTester::supportedRenderers(); + const QWindowsOpenGLTester::Renderers supportedRenderers = QWindowsOpenGLTester::supportedRenderers(requestedRenderer); + if (supportedRenderers.testFlag(QWindowsOpenGLTester::DisableProgramCacheFlag) + && !QCoreApplication::testAttribute(Qt::AA_DisableShaderDiskCache)) { + QCoreApplication::setAttribute(Qt::AA_DisableShaderDiskCache); + } if (supportedRenderers & QWindowsOpenGLTester::DesktopGl) { if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create()) { if ((supportedRenderers & QWindowsOpenGLTester::DisableRotationFlag) @@ -425,7 +441,7 @@ QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate() #elif defined(QT_OPENGL_ES_2) QWindowsOpenGLTester::Renderers glesRenderers = QWindowsOpenGLTester::requestedGlesRenderer(); if (glesRenderers == QWindowsOpenGLTester::InvalidRenderer) - glesRenderers = QWindowsOpenGLTester::supportedGlesRenderers(); + glesRenderers = QWindowsOpenGLTester::supportedRenderers(QWindowsOpenGLTester::AngleRendererD3d11); return QWindowsEGLStaticContext::create(glesRenderers); #elif !defined(QT_NO_OPENGL) return QOpenGLStaticContext::create(); @@ -560,7 +576,7 @@ QPlatformInputContext * QWindowsIntegration::inputContext() const return d->m_inputContext.data(); } -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QPlatformAccessibility *QWindowsIntegration::accessibility() const { return &d->m_accessibility; diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h index 23f3d9ef4e..da86852766 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.h +++ b/src/plugins/platforms/windows/qwindowsintegration.h @@ -42,7 +42,7 @@ #define QWINDOWSINTEGRATION_H #include <qpa/qplatformintegration.h> -#include <QtCore/QScopedPointer> +#include <QtCore/qscopedpointer.h> #include <QtFontDatabaseSupport/private/qwindowsfontdatabase_p.h> QT_BEGIN_NAMESPACE @@ -54,6 +54,7 @@ class QWindowsStaticOpenGLContext; class QWindowsIntegration : public QPlatformIntegration { + Q_DISABLE_COPY(QWindowsIntegration) public: enum Options { // Options to be passed on command line. FontDatabaseFreeType = 0x1, @@ -66,11 +67,13 @@ public: DontUseDirectWriteFonts = QWindowsFontDatabase::DontUseDirectWriteFonts, DontUseColorFonts = QWindowsFontDatabase::DontUseColorFonts, AlwaysUseNativeMenus = 0x100, - NoNativeMenus = 0x200 + NoNativeMenus = 0x200, + DontUseWMPointer = 0x400, + DetectAltGrModifier = 0x800 }; explicit QWindowsIntegration(const QStringList ¶mList); - virtual ~QWindowsIntegration(); + ~QWindowsIntegration() override; bool hasCapability(QPlatformIntegration::Capability cap) const override; @@ -90,7 +93,7 @@ public: # endif #endif // !QT_NO_CLIPBOARD QPlatformInputContext *inputContext() const override; -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QPlatformAccessibility *accessibility() const override; #endif QPlatformFontDatabase *fontDatabase() const override; diff --git a/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp b/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp index 21ebee6262..8f1d8f73d9 100644 --- a/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp +++ b/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp @@ -40,7 +40,7 @@ #include "qwindowsinternalmimedata.h" #include "qwindowscontext.h" #include "qwindowsmime.h" -#include <QDebug> +#include <QtCore/qdebug.h> /*! \class QWindowsInternalMimeDataBase \brief Base for implementations of QInternalMimeData using a IDataObject COM object. diff --git a/src/plugins/platforms/windows/qwindowsinternalmimedata.h b/src/plugins/platforms/windows/qwindowsinternalmimedata.h index a44f5b509c..dbc1ea3922 100644 --- a/src/plugins/platforms/windows/qwindowsinternalmimedata.h +++ b/src/plugins/platforms/windows/qwindowsinternalmimedata.h @@ -43,7 +43,7 @@ #include <QtCore/qt_windows.h> #include <QtGui/private/qinternalmimedata_p.h> -#include <QtCore/QVariant> +#include <QtCore/qvariant.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 950d8ecd36..9e6101b758 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -43,13 +43,14 @@ #include "qwindowswindow.h" #include "qwindowsinputcontext.h" -#include <QtGui/QGuiApplication> -#include <QtGui/QWindow> +#include <QtGui/qguiapplication.h> +#include <QtGui/qwindow.h> #include <qpa/qwindowsysteminterface.h> #include <private/qguiapplication_p.h> #include <private/qhighdpiscaling_p.h> -#include <QtGui/QKeyEvent> +#include <QtGui/qevent.h> #include <QtEventDispatcherSupport/private/qwindowsguieventdispatcher_p.h> +#include <QtCore/private/qdebug_p.h> #if defined(WM_APPCOMMAND) # ifndef FAPPCOMMAND_MOUSE @@ -105,9 +106,7 @@ QWindowsKeyMapper::QWindowsKeyMapper() changeKeyboard(); } -QWindowsKeyMapper::~QWindowsKeyMapper() -{ -} +QWindowsKeyMapper::~QWindowsKeyMapper()= default; #ifndef LANG_PASHTO #define LANG_PASHTO 0x63 @@ -544,6 +543,59 @@ static const Qt::KeyboardModifiers ModsTbl[] = { static const size_t NumMods = sizeof ModsTbl / sizeof *ModsTbl; Q_STATIC_ASSERT((NumMods == KeyboardLayoutItem::NumQtKeys)); +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug d, const KeyboardLayoutItem &k) +{ + QDebugStateSaver saver(d); + d.nospace(); + d << "KeyboardLayoutItem("; + if (k.exists) { + for (size_t i = 0; i < NumMods; ++i) { + if (const quint32 qtKey = k.qtKey[i]) { + d << '[' << i << ' '; + QtDebugUtils::formatQFlags(d, ModsTbl[i]); + d << ' ' << hex << showbase << qtKey << dec << noshowbase << ' '; + QtDebugUtils::formatQEnum(d, Qt::Key(qtKey)); + if (qtKey >= 32 && qtKey < 128) + d << " '" << char(qtKey) << '\''; + if (k.deadkeys & (1<<i)) + d << " deadkey"; + d << "] "; + } + } + } + d << ')'; + return d; +} + +// Helpers to format a list of int as Qt key sequence +class formatKeys +{ +public: + explicit formatKeys(const QList<int> &keys) : m_keys(keys) {} + +private: + friend QDebug operator<<(QDebug d, const formatKeys &keys); + const QList<int> &m_keys; +}; + +QDebug operator<<(QDebug d, const formatKeys &k) +{ + QDebugStateSaver saver(d); + d.nospace(); + d << '('; + for (int i =0, size = k.m_keys.size(); i < size; ++i) { + if (i) + d << ", "; + d << QKeySequence(k.m_keys.at(i)); + } + d << ')'; + return d; +} +#else // !QT_NO_DEBUG_STREAM +static int formatKeys(const QList<int> &) { return 0; } +#endif // QT_NO_DEBUG_STREAM + /** Remap return or action key to select key for windows mobile. */ @@ -599,8 +651,8 @@ static inline int asciiToKeycode(char a, int state) void QWindowsKeyMapper::deleteLayouts() { - for (size_t i = 0; i < NumKeyboardLayoutItems; ++i) - keyLayout[i].exists = false; + for (KeyboardLayoutItem &k : keyLayout) + k.exists = false; } void QWindowsKeyMapper::changeKeyboard() @@ -620,6 +672,7 @@ void QWindowsKeyMapper::changeKeyboard() bidi = true; keyboardInputDirection = bidi ? Qt::RightToLeft : Qt::LeftToRight; + m_seenAltGr = false; } // Helper function that is used when obtaining the list of characters that can be produced by one key and @@ -722,21 +775,8 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 ::ToAscii(VK_SPACE, 0, emptyBuffer, reinterpret_cast<LPWORD>(&buffer), 0); ::ToAscii(vk_key, scancode, kbdBuffer, reinterpret_cast<LPWORD>(&buffer), 0); } - if (QWindowsContext::verbose > 1 && lcQpaEvents().isDebugEnabled()) { - QString message; - QDebug debug(&message); - debug <<__FUNCTION__ << " for virtual key = 0x" << hex << vk_key << dec<< '\n'; - for (size_t i = 0; i < NumMods; ++i) { - const quint32 qtKey = keyLayout[vk_key].qtKey[i]; - debug << " [" << i << "] (" << qtKey << ',' - << hex << showbase << qtKey << noshowbase << dec - << ",'" << char(qtKey ? qtKey : 0x03) << "')"; - if (keyLayout[vk_key].deadkeys & (1<<i)) - debug << " deadkey"; - debug << '\n'; - } - qCDebug(lcQpaEvents) << message; - } + qCDebug(lcQpaEvents) << __FUNCTION__ << "for virtual key=" + << hex << showbase << vk_key << dec << noshowbase << keyLayout[vk_key]; } static inline QString messageKeyText(const MSG &msg) @@ -837,10 +877,26 @@ bool QWindowsKeyMapper::translateKeyEvent(QWindow *widget, HWND hwnd, bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, const MSG &msg) { #if defined(WM_APPCOMMAND) + const int cmd = GET_APPCOMMAND_LPARAM(msg.lParam); // QTBUG-57198, do not send mouse-synthesized commands as key events in addition - if (GET_DEVICE_LPARAM(msg.lParam) == FAPPCOMMAND_MOUSE) + switch (GET_DEVICE_LPARAM(msg.lParam)) { + case FAPPCOMMAND_MOUSE: return false; - const int cmd = GET_APPCOMMAND_LPARAM(msg.lParam); + case FAPPCOMMAND_KEY: + // QTBUG-62838, swallow WM_KEYDOWN, WM_KEYUP for commands that are + // reflected in VK(s) like VK_MEDIA_NEXT_TRACK. Don't do that for + // APPCOMMAND_BROWSER_HOME as that one does not trigger two events + if (cmd != APPCOMMAND_BROWSER_HOME) { + MSG peekedMsg; + if (PeekMessage(&peekedMsg, msg.hwnd, 0, 0, PM_NOREMOVE) + && peekedMsg.message == WM_KEYDOWN) { + PeekMessage(&peekedMsg, msg.hwnd, 0, 0, PM_REMOVE); + PeekMessage(&peekedMsg, msg.hwnd, 0, 0, PM_REMOVE); + } + } + break; + } + const int dwKeys = GET_KEYSTATE_LPARAM(msg.lParam); int state = 0; state |= (dwKeys & MK_SHIFT ? int(Qt::ShiftModifier) : 0); @@ -867,8 +923,34 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con #endif } -bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &msg, bool /* grab */, LRESULT *lResult) +// QTBUG-69317: Check for AltGr found on some keyboards +// which is a sequence of left Ctrl (SYSKEY) + right Menu (Alt). +static bool isAltGr(MSG *msg) +{ + enum : LONG_PTR { RightFlag = 0x1000000 }; + if (msg->wParam != VK_CONTROL || (msg->lParam & RightFlag) != 0 + || (msg->message != WM_KEYDOWN && msg->message != WM_SYSKEYUP)) { + return false; + } + const UINT expectedMessage = msg->message == WM_SYSKEYUP + ? WM_KEYUP : msg->message; + MSG peekedMsg; + if (PeekMessage(&peekedMsg, msg->hwnd, 0, 0, PM_NOREMOVE) == FALSE + || peekedMsg.message != expectedMessage || peekedMsg.wParam != VK_MENU + || (peekedMsg.lParam & RightFlag) == 0) { + return false; + } + *msg = peekedMsg; + PeekMessage(&peekedMsg, msg->hwnd, 0, 0, PM_REMOVE); + return true; +} + +bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, MSG msg, + bool /* grab */, LRESULT *lResult) { + const bool altGr = m_detectAltGrModifier && isAltGr(&msg); + if (altGr) + m_seenAltGr = true; const UINT msgType = msg.message; const quint32 scancode = (msg.lParam >> 16) & scancodeBitmask; @@ -897,10 +979,12 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms // Get the modifier states (may be altered later, depending on key code) int state = 0; state |= (nModifiers & ShiftAny ? int(Qt::ShiftModifier) : 0); - state |= (nModifiers & ControlAny ? int(Qt::ControlModifier) : 0); - state |= (nModifiers & AltAny ? int(Qt::AltModifier) : 0); + state |= (nModifiers & AltLeft ? int(Qt::AltModifier) : 0); + if ((nModifiers & AltRight) != 0) + state |= m_seenAltGr ? Qt::GroupSwitchModifier : Qt::AltModifier; + if ((nModifiers & ControlAny) != 0 && (state & Qt::GroupSwitchModifier) == 0) + state |= Qt::ControlModifier; state |= (nModifiers & MetaAny ? int(Qt::MetaModifier) : 0); - // A multi-character key or a Input method character // not found by our look-ahead if (msgType == WM_CHAR || msgType == WM_IME_CHAR) { @@ -971,8 +1055,17 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms modifiersIndex |= (nModifiers & ControlAny ? 0x2 : 0); modifiersIndex |= (nModifiers & AltAny ? 0x4 : 0); + // Note: For the resulting key, AltGr is equivalent to Alt + Ctrl (as + // opposed to Linux); hence no entry in KeyboardLayoutItem is required int code = keyLayout[vk_key].qtKey[modifiersIndex]; + // If the bit 24 of lParm is set you received a enter, + // otherwise a Return. (This is the extended key bit) + if ((code == Qt::Key_Return) && (msg.lParam & 0x1000000)) + code = Qt::Key_Enter; + else if (altGr) + code = Qt::Key_AltGr; + // Invert state logic: // If the key actually pressed is a modifier key, then we remove its modifier key from the // state, since a modifier-key can't have itself as a modifier @@ -982,11 +1075,8 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms state = state ^ Qt::ShiftModifier; else if (code == Qt::Key_Alt) state = state ^ Qt::AltModifier; - - // If the bit 24 of lParm is set you received a enter, - // otherwise a Return. (This is the extended key bit) - if ((code == Qt::Key_Return) && (msg.lParam & 0x1000000)) - code = Qt::Key_Enter; + else if (code == Qt::Key_AltGr) + state = state ^ Qt::GroupSwitchModifier; // All cursor keys without extended bit if (!(msg.lParam & 0x1000000)) { @@ -1070,7 +1160,8 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms if (uch.isHighSurrogate()) { m_lastHighSurrogate = uch; return true; - } else if (uch.isLowSurrogate() && !m_lastHighSurrogate.isNull()) { + } + if (uch.isLowSurrogate() && !m_lastHighSurrogate.isNull()) { if (QObject *focusObject = QGuiApplication::focusObject()) { const QChar chars[2] = {m_lastHighSurrogate, uch}; QInputMethodEvent event; @@ -1287,7 +1378,9 @@ QList<int> QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const *it = matchedKey; } } - + qCDebug(lcQpaEvents) << __FUNCTION__ << e << "nativeVirtualKey=" + << showbase << hex << e->nativeVirtualKey() << dec << noshowbase + << e->modifiers() << kbItem << "\n returns" << formatKeys(result); return result; } diff --git a/src/plugins/platforms/windows/qwindowskeymapper.h b/src/plugins/platforms/windows/qwindowskeymapper.h index c6b46b0c30..a454f0f973 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.h +++ b/src/plugins/platforms/windows/qwindowskeymapper.h @@ -42,7 +42,7 @@ #include <QtCore/qt_windows.h> -#include <QtCore/QLocale> +#include <QtCore/qlocale.h> QT_BEGIN_NAMESPACE @@ -81,6 +81,9 @@ public: void setUseRTLExtensions(bool e) { m_useRTLExtensions = e; } bool useRTLExtensions() const { return m_useRTLExtensions; } + void setDetectAltGrModifier(bool a) { m_detectAltGrModifier = a; } + bool detectAltGrModifier() const { return m_detectAltGrModifier; } + bool translateKeyEvent(QWindow *widget, HWND hwnd, const MSG &msg, LRESULT *result); QWindow *keyGrabber() const { return m_keyGrabber; } @@ -90,7 +93,7 @@ public: QList<int> possibleKeys(const QKeyEvent *e) const; private: - bool translateKeyEventInternal(QWindow *receiver, const MSG &msg, bool grab, LRESULT *lResult); + bool translateKeyEventInternal(QWindow *receiver, MSG msg, bool grab, LRESULT *lResult); bool translateMultimediaKeyEventInternal(QWindow *receiver, const MSG &msg); void updateKeyMap(const MSG &msg); @@ -106,6 +109,9 @@ private: QChar m_lastHighSurrogate; static const size_t NumKeyboardLayoutItems = 256; KeyboardLayoutItem keyLayout[NumKeyboardLayoutItems]; + bool m_detectAltGrModifier = false; + bool m_seenAltGr = false; + }; enum WindowsNativeModifiers { diff --git a/src/plugins/platforms/windows/qwindowsmenu.h b/src/plugins/platforms/windows/qwindowsmenu.h index d51a29676e..6de1553f35 100644 --- a/src/plugins/platforms/windows/qwindowsmenu.h +++ b/src/plugins/platforms/windows/qwindowsmenu.h @@ -44,8 +44,8 @@ #include <qpa/qplatformmenu.h> -#include <QtCore/QVector> -#include <QtCore/QPair> +#include <QtCore/qvector.h> +#include <QtCore/qpair.h> QT_BEGIN_NAMESPACE @@ -60,7 +60,7 @@ class QWindowsMenuItem : public QPlatformMenuItem Q_OBJECT public: explicit QWindowsMenuItem(QWindowsMenu *parentMenu = nullptr); - ~QWindowsMenuItem(); + ~QWindowsMenuItem() override; void setText(const QString &text) override; void setIcon(const QIcon &icon) override; @@ -199,7 +199,7 @@ public: typedef QVector<QWindowsMenu *> Menus; QWindowsMenuBar(); - ~QWindowsMenuBar(); + ~QWindowsMenuBar() override; void insertMenu(QPlatformMenu *menu, QPlatformMenu *before) override; void removeMenu(QPlatformMenu *menu) override; diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index 0439797a7d..ff0dccb0d9 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -41,15 +41,15 @@ #include "qwindowscontext.h" #include <QtGui/private/qinternalmimedata_p.h> -#include <QtCore/QByteArrayMatcher> -#include <QtCore/QTextCodec> -#include <QtCore/QMap> -#include <QtCore/QUrl> -#include <QtCore/QDir> -#include <QtCore/QDebug> -#include <QtCore/QBuffer> -#include <QtGui/QImageReader> -#include <QtGui/QImageWriter> +#include <QtCore/qbytearraymatcher.h> +#include <QtCore/qtextcodec.h> +#include <QtCore/qmap.h> +#include <QtCore/qurl.h> +#include <QtCore/qdir.h> +#include <QtCore/qdebug.h> +#include <QtCore/qbuffer.h> +#include <QtGui/qimagereader.h> +#include <QtGui/qimagewriter.h> #include <shlobj.h> #include <algorithm> @@ -107,7 +107,8 @@ 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: "; - foreach (const QByteArray &af, QImageReader::supportedImageFormats()) { + const QList<QByteArray> &formats = QImageReader::supportedImageFormats(); + for (const QByteArray &af : formats) { msg += af; msg += ' '; } @@ -487,17 +488,13 @@ QDebug operator<<(QDebug d, IDataObject *dataObj) Constructs a new conversion object, adding it to the globally accessed list of available converters. */ -QWindowsMime::QWindowsMime() -{ -} +QWindowsMime::QWindowsMime() = default; /*! Destroys a conversion object, removing it from the global list of available converters. */ -QWindowsMime::~QWindowsMime() -{ -} +QWindowsMime::~QWindowsMime() = default; /*! Registers the MIME type \a mime, and returns an ID number @@ -573,12 +570,12 @@ int QWindowsMime::registerMimeType(const QString &mime) class QWindowsMimeText : public QWindowsMime { public: - bool canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const; - QVariant convertToMime(const QString &mime, LPDATAOBJECT pDataObj, QVariant::Type preferredType) const; - QString mimeForFormat(const FORMATETC &formatetc) const; - bool canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const; - bool convertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData, STGMEDIUM *pmedium) const; - QVector<FORMATETC> formatsForMime(const QString &mimeType, const QMimeData *mimeData) const; + bool canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const override; + QVariant convertToMime(const QString &mime, LPDATAOBJECT pDataObj, QVariant::Type preferredType) const override; + QString mimeForFormat(const FORMATETC &formatetc) const override; + bool canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const override; + bool convertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData, STGMEDIUM *pmedium) const override; + QVector<FORMATETC> formatsForMime(const QString &mimeType, const QMimeData *mimeData) const override; }; bool QWindowsMimeText::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const @@ -627,7 +624,8 @@ bool QWindowsMimeText::convertFromMime(const FORMATETC &formatetc, const QMimeDa } o[j]=0; return setData(r, pmedium); - } else if (cf == CF_UNICODETEXT) { + } + if (cf == CF_UNICODETEXT) { QString str = mimeData->text(); const QChar *u = str.unicode(); QString res; @@ -729,12 +727,12 @@ class QWindowsMimeURI : public QWindowsMime { public: QWindowsMimeURI(); - bool canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const; - QVariant convertToMime(const QString &mime, LPDATAOBJECT pDataObj, QVariant::Type preferredType) const; - QString mimeForFormat(const FORMATETC &formatetc) const; - bool canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const; - bool convertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData, STGMEDIUM *pmedium) const; - QVector<FORMATETC> formatsForMime(const QString &mimeType, const QMimeData *mimeData) const; + bool canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const override; + QVariant convertToMime(const QString &mime, LPDATAOBJECT pDataObj, QVariant::Type preferredType) const override; + QString mimeForFormat(const FORMATETC &formatetc) const override; + bool canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const override; + bool convertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData, STGMEDIUM *pmedium) const override; + QVector<FORMATETC> formatsForMime(const QString &mimeType, const QMimeData *mimeData) const override; private: int CF_INETURL_W; // wide char version int CF_INETURL; @@ -749,9 +747,9 @@ QWindowsMimeURI::QWindowsMimeURI() bool QWindowsMimeURI::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const { if (mimeData->hasUrls() && getCf(formatetc) == CF_HDROP) { - QList<QUrl> urls = mimeData->urls(); - for (int i=0; i<urls.size(); i++) { - if (!urls.at(i).toLocalFile().isEmpty()) + const QList<QUrl> urls = mimeData->urls(); + for (const QUrl &url : urls) { + if (url.isLocalFile()) return true; } } @@ -762,11 +760,11 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat { if (canConvertFromMime(formatetc, mimeData)) { if (getCf(formatetc) == CF_HDROP) { - QList<QUrl> urls = mimeData->urls(); + const QList<QUrl> &urls = mimeData->urls(); QStringList fileNames; int size = sizeof(DROPFILES)+2; - for (int i=0; i<urls.size(); i++) { - QString fn = QDir::toNativeSeparators(urls.at(i).toLocalFile()); + for (const QUrl &url : urls) { + const QString fn = QDir::toNativeSeparators(url.toLocalFile()); if (!fn.isEmpty()) { size += sizeof(ushort) * size_t(fn.length() + 1); fileNames.append(fn); @@ -791,7 +789,8 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat *f = 0; return setData(result, pmedium); - } else if (getCf(formatetc) == CF_INETURL_W) { + } + if (getCf(formatetc) == CF_INETURL_W) { QList<QUrl> urls = mimeData->urls(); QByteArray result; if (!urls.isEmpty()) { @@ -802,7 +801,8 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat result.append('\0'); result.append('\0'); return setData(result, pmedium); - } else if (getCf(formatetc) == CF_INETURL) { + } + if (getCf(formatetc) == CF_INETURL) { QList<QUrl> urls = mimeData->urls(); QByteArray result; if (!urls.isEmpty()) @@ -872,7 +872,7 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD if (preferredType == QVariant::Url && urls.size() == 1) return urls.at(0); - else if (!urls.isEmpty()) + if (!urls.isEmpty()) return urls; } else if (canGetData(CF_INETURL_W, pDataObj)) { QByteArray data = getData(CF_INETURL_W, pDataObj); @@ -1075,10 +1075,8 @@ QString QWindowsMimeImage::mimeForFormat(const FORMATETC &formatetc) const bool QWindowsMimeImage::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const { - if (mimeType == QLatin1String("application/x-qt-image") && - (canGetData(CF_DIB, pDataObj) || canGetData(CF_PNG, pDataObj))) - return true; - return false; + return mimeType == QLatin1String("application/x-qt-image") + && (canGetData(CF_DIB, pDataObj) || canGetData(CF_PNG, pDataObj)); } bool QWindowsMimeImage::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const @@ -1134,7 +1132,7 @@ bool QWindowsMimeImage::hasOriginalDIBV5(IDataObject *pDataObj) const CoTaskMemFree(fc.ptd); if (fc.cfFormat == CF_DIB) break; - else if (fc.cfFormat == CF_DIBV5) { + if (fc.cfFormat == CF_DIBV5) { isSynthesized = false; break; } @@ -1328,7 +1326,7 @@ QStringList QLastResortMimes::excludeList; QLastResortMimes::QLastResortMimes() { //MIME Media-Types - if (!ianaTypes.size()) { + if (ianaTypes.isEmpty()) { ianaTypes.append(QStringLiteral("application/")); ianaTypes.append(QStringLiteral("audio/")); ianaTypes.append(QStringLiteral("example/")); @@ -1340,7 +1338,7 @@ QLastResortMimes::QLastResortMimes() ianaTypes.append(QStringLiteral("video/")); } //Types handled by other classes - if (!excludeList.size()) { + if (excludeList.isEmpty()) { excludeList.append(QStringLiteral("HTML Format")); excludeList.append(QStringLiteral("UniformResourceLocator")); excludeList.append(QStringLiteral("text/html")); @@ -1598,7 +1596,7 @@ QVariant QWindowsMimeConverter::convertToMime(const QStringList &mimeTypes, QVariant::Type preferredType, QString *formatIn /* = 0 */) const { - foreach (const QString &format, mimeTypes) { + for (const QString &format : mimeTypes) { if (const QWindowsMime *converter = converterToMime(format, pDataObj)) { if (converter->canConvertToMime(format, pDataObj)) { const QVariant dataV = converter->convertToMime(format, pDataObj, preferredType); diff --git a/src/plugins/platforms/windows/qwindowsmime.h b/src/plugins/platforms/windows/qwindowsmime.h index 1ed2aa933f..6bbbae1a0e 100644 --- a/src/plugins/platforms/windows/qwindowsmime.h +++ b/src/plugins/platforms/windows/qwindowsmime.h @@ -42,9 +42,9 @@ #include <QtCore/qt_windows.h> -#include <QtCore/QVector> -#include <QtCore/QList> -#include <QtCore/QVariant> +#include <QtCore/qvector.h> +#include <QtCore/qlist.h> +#include <QtCore/qvariant.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 17851618b4..fcdd179a31 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -45,14 +45,14 @@ #include "qwindowsscreen.h" #include <qpa/qwindowsysteminterface.h> -#include <QtGui/QGuiApplication> -#include <QtGui/QScreen> -#include <QtGui/QTouchDevice> -#include <QtGui/QWindow> -#include <QtGui/QCursor> +#include <QtGui/qguiapplication.h> +#include <QtGui/qscreen.h> +#include <QtGui/qtouchdevice.h> +#include <QtGui/qwindow.h> +#include <QtGui/qcursor.h> -#include <QtCore/QDebug> -#include <QtCore/QScopedArrayPointer> +#include <QtCore/qdebug.h> +#include <QtCore/qscopedpointer.h> #include <windowsx.h> @@ -119,20 +119,16 @@ static inline void compressMouseMove(MSG *msg) static inline QTouchDevice *createTouchDevice() { - enum { QT_SM_TABLETPC = 86, QT_SM_DIGITIZER = 94, QT_SM_MAXIMUMTOUCHES = 95, - QT_NID_INTEGRATED_TOUCH = 0x1, QT_NID_EXTERNAL_TOUCH = 0x02, - QT_NID_MULTI_INPUT = 0x40, QT_NID_READY = 0x80 }; - - const int digitizers = GetSystemMetrics(QT_SM_DIGITIZER); - if (!(digitizers & (QT_NID_INTEGRATED_TOUCH | QT_NID_EXTERNAL_TOUCH))) + const int digitizers = GetSystemMetrics(SM_DIGITIZER); + if (!(digitizers & (NID_INTEGRATED_TOUCH | NID_EXTERNAL_TOUCH))) return 0; - const int tabletPc = GetSystemMetrics(QT_SM_TABLETPC); - const int maxTouchPoints = GetSystemMetrics(QT_SM_MAXIMUMTOUCHES); - qCDebug(lcQpaEvents) << "Digitizers:" << hex << showbase << (digitizers & ~QT_NID_READY) - << "Ready:" << (digitizers & QT_NID_READY) << dec << noshowbase + const int tabletPc = GetSystemMetrics(SM_TABLETPC); + const int maxTouchPoints = GetSystemMetrics(SM_MAXIMUMTOUCHES); + qCDebug(lcQpaEvents) << "Digitizers:" << hex << showbase << (digitizers & ~NID_READY) + << "Ready:" << (digitizers & NID_READY) << dec << noshowbase << "Tablet PC:" << tabletPc << "Max touch points:" << maxTouchPoints; QTouchDevice *result = new QTouchDevice; - result->setType(digitizers & QT_NID_INTEGRATED_TOUCH + result->setType(digitizers & NID_INTEGRATED_TOUCH ? QTouchDevice::TouchScreen : QTouchDevice::TouchPad); QTouchDevice::Capabilities capabilities = QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition; if (result->type() == QTouchDevice::TouchPad) @@ -178,22 +174,121 @@ Qt::MouseButtons QWindowsMouseHandler::queryMouseButtons() return result; } +static QPoint lastMouseMovePos; + +namespace { +struct MouseEvent { + QEvent::Type type; + Qt::MouseButton button; +}; + +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug d, const MouseEvent &e) +{ + QDebugStateSaver saver(d); + d.nospace(); + d << "MouseEvent(" << e.type << ", " << e.button << ')'; + return d; +} +#endif // QT_NO_DEBUG_STREAM +} // namespace + +static inline Qt::MouseButton extraButton(WPARAM wParam) // for WM_XBUTTON... +{ + return GET_XBUTTON_WPARAM(wParam) == XBUTTON1 ? Qt::BackButton : Qt::ForwardButton; +} + +static inline MouseEvent eventFromMsg(const MSG &msg) +{ + switch (msg.message) { + case WM_MOUSEMOVE: + return {QEvent::MouseMove, Qt::NoButton}; + case WM_LBUTTONDOWN: + return {QEvent::MouseButtonPress, Qt::LeftButton}; + case WM_LBUTTONUP: + return {QEvent::MouseButtonRelease, Qt::LeftButton}; + case WM_LBUTTONDBLCLK: // Qt QPA does not handle double clicks, send as press + return {QEvent::MouseButtonPress, Qt::LeftButton}; + case WM_MBUTTONDOWN: + return {QEvent::MouseButtonPress, Qt::MidButton}; + case WM_MBUTTONUP: + return {QEvent::MouseButtonRelease, Qt::MidButton}; + case WM_MBUTTONDBLCLK: + return {QEvent::MouseButtonPress, Qt::MidButton}; + case WM_RBUTTONDOWN: + return {QEvent::MouseButtonPress, Qt::RightButton}; + case WM_RBUTTONUP: + return {QEvent::MouseButtonRelease, Qt::RightButton}; + case WM_RBUTTONDBLCLK: + return {QEvent::MouseButtonPress, Qt::RightButton}; + case WM_XBUTTONDOWN: + return {QEvent::MouseButtonPress, extraButton(msg.wParam)}; + case WM_XBUTTONUP: + return {QEvent::MouseButtonRelease, extraButton(msg.wParam)}; + case WM_XBUTTONDBLCLK: + return {QEvent::MouseButtonPress, extraButton(msg.wParam)}; + case WM_NCMOUSEMOVE: + return {QEvent::NonClientAreaMouseMove, Qt::NoButton}; + case WM_NCLBUTTONDOWN: + return {QEvent::NonClientAreaMouseButtonPress, Qt::LeftButton}; + case WM_NCLBUTTONUP: + return {QEvent::NonClientAreaMouseButtonRelease, Qt::LeftButton}; + case WM_NCLBUTTONDBLCLK: + return {QEvent::NonClientAreaMouseButtonPress, Qt::LeftButton}; + case WM_NCMBUTTONDOWN: + return {QEvent::NonClientAreaMouseButtonPress, Qt::MidButton}; + case WM_NCMBUTTONUP: + return {QEvent::NonClientAreaMouseButtonRelease, Qt::MidButton}; + case WM_NCMBUTTONDBLCLK: + return {QEvent::NonClientAreaMouseButtonPress, Qt::MidButton}; + case WM_NCRBUTTONDOWN: + return {QEvent::NonClientAreaMouseButtonPress, Qt::RightButton}; + case WM_NCRBUTTONUP: + return {QEvent::NonClientAreaMouseButtonRelease, Qt::RightButton}; + case WM_NCRBUTTONDBLCLK: + return {QEvent::NonClientAreaMouseButtonPress, Qt::RightButton}; + default: // WM_MOUSELEAVE + break; + } + return {QEvent::None, Qt::NoButton}; +} + bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, MSG msg, LRESULT *result) { -#ifdef Q_COMPILER_CLASS_ENUM enum : quint64 { signatureMask = 0xffffff00, miWpSignature = 0xff515700 }; -#else - static const quint64 signatureMask = 0xffffff00; - static const quint64 miWpSignature = 0xff515700; -#endif // !Q_COMPILER_CLASS_ENUM if (et == QtWindows::MouseWheelEvent) return translateMouseWheelEvent(window, hwnd, msg, result); + const QPoint winEventPosition(GET_X_LPARAM(msg.lParam), GET_Y_LPARAM(msg.lParam)); + QPoint clientPosition; + QPoint globalPosition; + if (et & QtWindows::NonClientEventFlag) { + globalPosition = winEventPosition; + clientPosition = QWindowsGeometryHint::mapFromGlobal(hwnd, globalPosition); + } else { + clientPosition = winEventPosition; + globalPosition = QWindowsGeometryHint::mapToGlobal(hwnd, winEventPosition); + } + + // Windows sends a mouse move with no buttons pressed to signal "Enter" + // when a window is shown over the cursor. Discard the event and only use + // it for generating QEvent::Enter to be consistent with other platforms - + // X11 and macOS. + bool discardEvent = false; + if (msg.message == WM_MOUSEMOVE) { + const bool samePosition = globalPosition == lastMouseMovePos; + lastMouseMovePos = globalPosition; + if (msg.wParam == 0 && (m_windowUnderMouse.isNull() || samePosition)) + discardEvent = true; + } + Qt::MouseEventSource source = Qt::MouseEventNotSynthesized; + const MouseEvent mouseEvent = eventFromMsg(msg); + // Check for events synthesized from touch. Lower byte is touch index, 0 means pen. static const bool passSynthesizedMouseEvents = !(QWindowsIntegration::instance()->options() & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch); @@ -210,13 +305,11 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, } } - const QPoint winEventPosition(GET_X_LPARAM(msg.lParam), GET_Y_LPARAM(msg.lParam)); - if (et & QtWindows::NonClientEventFlag) { - const QPoint globalPosition = winEventPosition; - const QPoint clientPosition = QWindowsGeometryHint::mapFromGlobal(hwnd, globalPosition); + if (mouseEvent.type >= QEvent::NonClientAreaMouseMove && mouseEvent.type <= QEvent::NonClientAreaMouseButtonDblClick) { const Qt::MouseButtons buttons = QWindowsMouseHandler::queryMouseButtons(); QWindowSystemInterface::handleFrameStrutMouseEvent(window, clientPosition, globalPosition, buttons, + mouseEvent.button, mouseEvent.type, QWindowsKeyMapper::queryKeyboardModifiers(), source); return false; // Allow further event processing (dragging of windows). @@ -224,7 +317,8 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, *result = 0; if (msg.message == WM_MOUSELEAVE) { - qCDebug(lcQpaEvents) << "WM_MOUSELEAVE for " << window << " previous window under mouse = " << m_windowUnderMouse << " tracked window =" << m_trackedWindow; + qCDebug(lcQpaEvents) << mouseEvent << "for" << window << "previous window under mouse=" + << m_windowUnderMouse << "tracked window=" << m_trackedWindow; // When moving out of a window, WM_MOUSEMOVE within the moved-to window is received first, // so if m_trackedWindow is not the window here, it means the cursor has left the @@ -264,12 +358,11 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, } m_previousCaptureWindow = window; return true; - } else if (m_leftButtonDown && !actualLeftDown) { - m_leftButtonDown = false; } + if (m_leftButtonDown && !actualLeftDown) + m_leftButtonDown = false; } - const QPoint globalPosition = QWindowsGeometryHint::mapToGlobal(hwnd, winEventPosition); // In this context, neither an invisible nor a transparent window (transparent regarding mouse // events, "click-through") can be considered as the window under mouse. QWindow *currentWindowUnderMouse = platformWindow->hasMouseCapture() ? @@ -290,10 +383,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, // Qt expects the platform plugin to capture the mouse on // any button press until release. if (!platformWindow->hasMouseCapture() - && (msg.message == WM_LBUTTONDOWN || msg.message == WM_MBUTTONDOWN - || msg.message == WM_RBUTTONDOWN || msg.message == WM_XBUTTONDOWN - || msg.message == WM_LBUTTONDBLCLK || msg.message == WM_MBUTTONDBLCLK - || msg.message == WM_RBUTTONDBLCLK || msg.message == WM_XBUTTONDBLCLK)) { + && (mouseEvent.type == QEvent::MouseButtonPress || mouseEvent.type == QEvent::MouseButtonDblClick)) { platformWindow->setMouseGrabEnabled(true); platformWindow->setFlag(QWindowsWindow::AutoMouseCapture); qCDebug(lcQpaEvents) << "Automatic mouse capture " << window; @@ -302,8 +392,7 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, window->requestActivate(); } else if (platformWindow->hasMouseCapture() && platformWindow->testFlag(QWindowsWindow::AutoMouseCapture) - && (msg.message == WM_LBUTTONUP || msg.message == WM_MBUTTONUP - || msg.message == WM_RBUTTONUP || msg.message == WM_XBUTTONUP) + && mouseEvent.type == QEvent::MouseButtonRelease && !buttons) { platformWindow->setMouseGrabEnabled(false); qCDebug(lcQpaEvents) << "Releasing automatic mouse capture " << window; @@ -369,9 +458,12 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, m_windowUnderMouse = currentWindowUnderMouse; } - QWindowSystemInterface::handleMouseEvent(window, winEventPosition, globalPosition, buttons, - QWindowsKeyMapper::queryKeyboardModifiers(), - source); + if (!discardEvent && mouseEvent.type != QEvent::None) { + QWindowSystemInterface::handleMouseEvent(window, winEventPosition, globalPosition, buttons, + mouseEvent.button, mouseEvent.type, + QWindowsKeyMapper::queryKeyboardModifiers(), + source); + } m_previousCaptureWindow = hasCapture ? window : 0; // QTBUG-48117, force synchronous handling for the extra buttons so that WM_APPCOMMAND // is sent for unhandled WM_XBUTTONDOWN. @@ -411,9 +503,10 @@ static void redirectWheelEvent(QWindow *window, const QPoint &globalPos, int del } if (handleEvent) { + const QPoint point = (orientation == Qt::Vertical) ? QPoint(0, delta) : QPoint(delta, 0); QWindowSystemInterface::handleWheelEvent(receiver, QWindowsGeometryHint::mapFromGlobal(receiver, globalPos), - globalPos, delta, orientation, mods); + globalPos, QPoint(), point, mods); } } diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.h b/src/plugins/platforms/windows/qwindowsmousehandler.h index 86f18a0482..480662c9bf 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.h +++ b/src/plugins/platforms/windows/qwindowsmousehandler.h @@ -43,8 +43,8 @@ #include "qtwindowsglobal.h" #include <QtCore/qt_windows.h> -#include <QtCore/QPointer> -#include <QtCore/QHash> +#include <QtCore/qpointer.h> +#include <QtCore/qhash.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp index ffa100f824..de11356fd4 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp @@ -48,9 +48,9 @@ #include "qwindowsmime.h" #include "qwin10helpers.h" -#include <QtGui/QWindow> -#include <QtGui/QOpenGLContext> -#include <QtGui/QScreen> +#include <QtGui/qwindow.h> +#include <QtGui/qopenglcontext.h> +#include <QtGui/qscreen.h> #include <qpa/qplatformscreen.h> #include <QtFontDatabaseSupport/private/qwindowsfontdatabase_p.h> @@ -111,15 +111,14 @@ void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resourc return 0; } break; - case QWindow::OpenGLSurface: - case QWindow::OpenVGSurface: - break; case QWindow::VulkanSurface: #if QT_CONFIG(vulkan) if (type == VkSurface) return bw->surface(nullptr, nullptr); // returns the address of the VkSurfaceKHR, not the value, as expected #endif break; + default: + break; } qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData()); return 0; @@ -276,11 +275,11 @@ QFunctionPointer QWindowsNativeInterface::platformFunction(const QByteArray &fun { if (function == QWindowsWindowFunctions::setTouchWindowTouchTypeIdentifier()) return QFunctionPointer(QWindowsWindow::setTouchWindowTouchTypeStatic); - else if (function == QWindowsWindowFunctions::setHasBorderInFullScreenIdentifier()) + if (function == QWindowsWindowFunctions::setHasBorderInFullScreenIdentifier()) return QFunctionPointer(QWindowsWindow::setHasBorderInFullScreenStatic); - else if (function == QWindowsWindowFunctions::setWindowActivationBehaviorIdentifier()) + if (function == QWindowsWindowFunctions::setWindowActivationBehaviorIdentifier()) return QFunctionPointer(QWindowsNativeInterface::setWindowActivationBehavior); - else if (function == QWindowsWindowFunctions::isTabletModeIdentifier()) + if (function == QWindowsWindowFunctions::isTabletModeIdentifier()) return QFunctionPointer(QWindowsNativeInterface::isTabletMode); return nullptr; } diff --git a/src/plugins/platforms/windows/qwindowsole.cpp b/src/plugins/platforms/windows/qwindowsole.cpp index 0ceb0d82fa..ad0442c8bd 100644 --- a/src/plugins/platforms/windows/qwindowsole.cpp +++ b/src/plugins/platforms/windows/qwindowsole.cpp @@ -41,14 +41,14 @@ #include "qwindowsmime.h" #include "qwindowscontext.h" \ -#include <QtGui/QMouseEvent> -#include <QtGui/QWindow> -#include <QtGui/QPainter> -#include <QtGui/QCursor> -#include <QtGui/QGuiApplication> +#include <QtGui/qevent.h> +#include <QtGui/qwindow.h> +#include <QtGui/qpainter.h> +#include <QtGui/qcursor.h> +#include <QtGui/qguiapplication.h> -#include <QtCore/QMimeData> -#include <QtCore/QDebug> +#include <QtCore/qmimedata.h> +#include <QtCore/qdebug.h> #include <shlobj.h> @@ -80,9 +80,7 @@ QWindowsOleDataObject::QWindowsOleDataObject(QMimeData *mimeData) : qCDebug(lcQpaMime) << __FUNCTION__ << mimeData->formats(); } -QWindowsOleDataObject::~QWindowsOleDataObject() -{ -} +QWindowsOleDataObject::~QWindowsOleDataObject() = default; void QWindowsOleDataObject::releaseQt() { @@ -365,10 +363,9 @@ QWindowsOleEnumFmtEtc::Clone(LPENUMFORMATETC FAR* newEnum) if (result->isNull()) { delete result; return ResultFromScode(E_OUTOFMEMORY); - } else { - *newEnum = result; } + *newEnum = result; return NOERROR; } diff --git a/src/plugins/platforms/windows/qwindowsole.h b/src/plugins/platforms/windows/qwindowsole.h index fc58858f2c..6940657e88 100644 --- a/src/plugins/platforms/windows/qwindowsole.h +++ b/src/plugins/platforms/windows/qwindowsole.h @@ -43,9 +43,9 @@ #include "qwindowscombase.h" #include <QtCore/qt_windows.h> -#include <QtCore/QMap> -#include <QtCore/QPointer> -#include <QtCore/QVector> +#include <QtCore/qmap.h> +#include <QtCore/qpointer.h> +#include <QtCore/qvector.h> #include <objidl.h> @@ -58,7 +58,7 @@ class QWindowsOleDataObject : public QWindowsComBase<IDataObject> { public: explicit QWindowsOleDataObject(QMimeData *mimeData); - virtual ~QWindowsOleDataObject(); + ~QWindowsOleDataObject() override; void releaseQt(); QMimeData *mimeData() const; @@ -88,7 +88,7 @@ class QWindowsOleEnumFmtEtc : public QWindowsComBase<IEnumFORMATETC> public: explicit QWindowsOleEnumFmtEtc(const QVector<FORMATETC> &fmtetcs); explicit QWindowsOleEnumFmtEtc(const QVector<LPFORMATETC> &lpfmtetcs); - virtual ~QWindowsOleEnumFmtEtc(); + ~QWindowsOleEnumFmtEtc() override; bool isNull() const; diff --git a/src/plugins/platforms/windows/qwindowsopenglcontext.h b/src/plugins/platforms/windows/qwindowsopenglcontext.h index 85f4f717f5..cc6d93d35e 100644 --- a/src/plugins/platforms/windows/qwindowsopenglcontext.h +++ b/src/plugins/platforms/windows/qwindowsopenglcontext.h @@ -40,7 +40,7 @@ #ifndef QWINDOWSOPENGLCONTEXT_H #define QWINDOWSOPENGLCONTEXT_H -#include <QtGui/QOpenGLContext> +#include <QtGui/qopenglcontext.h> #include <qpa/qplatformopenglcontext.h> QT_BEGIN_NAMESPACE @@ -51,9 +51,10 @@ class QWindowsOpenGLContext; class QWindowsStaticOpenGLContext { + Q_DISABLE_COPY(QWindowsStaticOpenGLContext) public: static QWindowsStaticOpenGLContext *create(); - virtual ~QWindowsStaticOpenGLContext() { } + virtual ~QWindowsStaticOpenGLContext() = default; virtual QWindowsOpenGLContext *createContext(QOpenGLContext *context) = 0; virtual void *moduleHandle() const = 0; @@ -65,15 +66,17 @@ public: virtual void *createWindowSurface(void * /*nativeWindow*/, void * /*nativeConfig*/, int * /*err*/) { return 0; } virtual void destroyWindowSurface(void * /*nativeSurface*/) { } +protected: + QWindowsStaticOpenGLContext() = default; + private: static QWindowsStaticOpenGLContext *doCreate(); }; class QWindowsOpenGLContext : public QPlatformOpenGLContext { + Q_DISABLE_COPY(QWindowsOpenGLContext) public: - virtual ~QWindowsOpenGLContext() { } - // Returns the native context handle (e.g. HGLRC for WGL, EGLContext for EGL). virtual void *nativeContext() const = 0; @@ -81,6 +84,9 @@ public: // For others, like WGL, they are not relevant. virtual void *nativeDisplay() const { return 0; } virtual void *nativeConfig() const { return 0; } + +protected: + QWindowsOpenGLContext() = default; }; #endif // QT_NO_OPENGL diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index c52e4e612e..3efccf0f32 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -40,15 +40,15 @@ #include "qwindowsopengltester.h" #include "qwindowscontext.h" -#include <QtCore/QVariantMap> -#include <QtCore/QDebug> -#include <QtCore/QTextStream> -#include <QtCore/QCoreApplication> -#include <QtCore/QFile> -#include <QtCore/QFileInfo> -#include <QtCore/QStandardPaths> -#include <QtCore/QLibraryInfo> -#include <QtCore/QHash> +#include <QtCore/qvariant.h> +#include <QtCore/qdebug.h> +#include <QtCore/qtextstream.h> +#include <QtCore/qcoreapplication.h> +#include <QtCore/qfile.h> +#include <QtCore/qfileinfo.h> +#include <QtCore/qstandardpaths.h> +#include <QtCore/qlibraryinfo.h> +#include <QtCore/qhash.h> #ifndef QT_NO_OPENGL #include <private/qopengl_p.h> @@ -60,6 +60,8 @@ QT_BEGIN_NAMESPACE +static const DWORD VENDOR_ID_AMD = 0x1002; + GpuDescription GpuDescription::detect() { typedef IDirect3D9 * (WINAPI *PtrDirect3DCreate9)(UINT); @@ -74,9 +76,16 @@ GpuDescription GpuDescription::detect() IDirect3D9 *direct3D9 = direct3DCreate9(D3D_SDK_VERSION); if (!direct3D9) return result; + D3DADAPTER_IDENTIFIER9 adapterIdentifier; - const HRESULT hr = direct3D9->GetAdapterIdentifier(0, 0, &adapterIdentifier); - direct3D9->Release(); + bool isAMD = false; + // Adapter "0" is D3DADAPTER_DEFAULT which returns the default adapter. In + // multi-GPU, multi-screen setups this is the GPU that is associated with + // the "main display" in the Display Settings, and this is the GPU OpenGL + // and D3D uses by default. Therefore querying any additional adapters is + // futile and not useful for our purposes in general, except for + // identifying a few special cases later on. + HRESULT hr = direct3D9->GetAdapterIdentifier(0, 0, &adapterIdentifier); if (SUCCEEDED(hr)) { result.vendorId = adapterIdentifier.VendorId; result.deviceId = adapterIdentifier.DeviceId; @@ -90,7 +99,37 @@ GpuDescription GpuDescription::detect() result.driverVersion = QVersionNumber(version); result.driverName = adapterIdentifier.Driver; result.description = adapterIdentifier.Description; + isAMD = result.vendorId == VENDOR_ID_AMD; + } + + // Detect QTBUG-50371 (having AMD as the default adapter results in a crash + // when starting apps on a screen connected to the Intel card) by looking + // for a default AMD adapter and an additional non-AMD one. + if (isAMD) { + const UINT adapterCount = direct3D9->GetAdapterCount(); + for (UINT adp = 1; adp < adapterCount; ++adp) { + hr = direct3D9->GetAdapterIdentifier(adp, 0, &adapterIdentifier); + if (SUCCEEDED(hr)) { + if (adapterIdentifier.VendorId != VENDOR_ID_AMD) { + // Bingo. Now figure out the display for the AMD card. + DISPLAY_DEVICE dd; + memset(&dd, 0, sizeof(dd)); + dd.cb = sizeof(dd); + for (int dev = 0; EnumDisplayDevices(nullptr, dev, &dd, 0); ++dev) { + if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { + // DeviceName is something like \\.\DISPLAY1 which can be used to + // match with the MONITORINFOEX::szDevice queried by QWindowsScreen. + result.gpuSuitableScreen = QString::fromWCharArray(dd.DeviceName); + break; + } + } + break; + } + } + } } + + direct3D9->Release(); return result; } @@ -103,7 +142,8 @@ QDebug operator<<(QDebug d, const GpuDescription &gd) << ", deviceId=" << gd.deviceId << ", subSysId=" << gd.subSysId << dec << noshowbase << ", revision=" << gd.revision << ", driver: " << gd.driverName - << ", version=" << gd.driverVersion << ", " << gd.description << ')'; + << ", version=" << gd.driverVersion << ", " << gd.description + << gd.gpuSuitableScreen << ')'; return d; } #endif // !QT_NO_DEBUG_STREAM @@ -113,15 +153,17 @@ QString GpuDescription::toString() const { QString result; QTextStream str(&result); - str << " Card name: " << description - << "\n Driver Name: " << driverName - << "\n Driver Version: " << driverVersion.toString() - << "\n Vendor ID: 0x" << qSetPadChar(QLatin1Char('0')) + str << " Card name : " << description + << "\n Driver Name : " << driverName + << "\n Driver Version : " << driverVersion.toString() + << "\n Vendor ID : 0x" << qSetPadChar(QLatin1Char('0')) << uppercasedigits << hex << qSetFieldWidth(4) << vendorId - << "\n Device ID: 0x" << qSetFieldWidth(4) << deviceId - << "\n SubSys ID: 0x" << qSetFieldWidth(8) << subSysId - << "\n Revision ID: 0x" << qSetFieldWidth(4) << revision + << "\n Device ID : 0x" << qSetFieldWidth(4) << deviceId + << "\n SubSys ID : 0x" << qSetFieldWidth(8) << subSysId + << "\n Revision ID : 0x" << qSetFieldWidth(4) << revision << dec; + if (!gpuSuitableScreen.isEmpty()) + str << "\nGL windows forced to screen: " << gpuSuitableScreen; return result; } @@ -205,11 +247,12 @@ typedef QHash<QOpenGLConfig::Gpu, QWindowsOpenGLTester::Renderers> SupportedRend Q_GLOBAL_STATIC(SupportedRenderersCache, supportedRenderersCache) #endif -QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(const GpuDescription &gpu, bool glesOnly) +QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(const GpuDescription &gpu, + Renderer requested) { - Q_UNUSED(gpu) - Q_UNUSED(glesOnly) #if defined(QT_NO_OPENGL) + Q_UNUSED(gpu) + Q_UNUSED(requested) return 0; #else QOpenGLConfig::Gpu qgpu = QOpenGLConfig::Gpu::fromDevice(gpu.vendorId, gpu.deviceId, gpu.driverVersion, gpu.description); @@ -223,8 +266,11 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(c | QWindowsOpenGLTester::AngleRendererD3d11Warp | QWindowsOpenGLTester::SoftwareRasterizer); - if (!glesOnly && testDesktopGL()) - result |= QWindowsOpenGLTester::DesktopGl; + // Don't test for GL if explicitly requested or GLES only is requested + if (requested == DesktopGl + || ((requested & GlesMask) == 0 && testDesktopGL())) { + result |= QWindowsOpenGLTester::DesktopGl; + } const char bugListFileVar[] = "QT_OPENGL_BUGLIST"; QString buglistFileName = QStringLiteral(":/qt-project.org/windows/openglblacklists/default.json"); @@ -259,24 +305,20 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(c qCDebug(lcQpaGl) << "Disabling rotation: " << gpu; result |= DisableRotationFlag; } + if (features.contains(QStringLiteral("disable_program_cache"))) { + qCDebug(lcQpaGl) << "Disabling program cache: " << gpu; + result |= DisableProgramCacheFlag; + } srCache->insert(qgpu, result); return result; #endif // !QT_NO_OPENGL } -QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedGlesRenderers() -{ - const GpuDescription gpu = GpuDescription::detect(); - const QWindowsOpenGLTester::Renderers result = detectSupportedRenderers(gpu, true); - qCDebug(lcQpaGl) << __FUNCTION__ << gpu << "renderer: " << result; - return result; -} - -QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedRenderers() +QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedRenderers(Renderer requested) { const GpuDescription gpu = GpuDescription::detect(); - const QWindowsOpenGLTester::Renderers result = detectSupportedRenderers(gpu, false); - qCDebug(lcQpaGl) << __FUNCTION__ << gpu << "renderer: " << result; + const QWindowsOpenGLTester::Renderers result = detectSupportedRenderers(gpu, requested); + qCDebug(lcQpaGl) << __FUNCTION__ << gpu << requested << "renderer: " << result; return result; } diff --git a/src/plugins/platforms/windows/qwindowsopengltester.h b/src/plugins/platforms/windows/qwindowsopengltester.h index e3fec59dd5..08628c2586 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.h +++ b/src/plugins/platforms/windows/qwindowsopengltester.h @@ -40,8 +40,8 @@ #ifndef QWINDOWSOPENGLTESTER_H #define QWINDOWSOPENGLTESTER_H -#include <QtCore/QByteArray> -#include <QtCore/QFlags> +#include <QtCore/qbytearray.h> +#include <QtCore/qflags.h> #include <QtCore/qversionnumber.h> QT_BEGIN_NAMESPACE @@ -62,6 +62,7 @@ struct GpuDescription QVersionNumber driverVersion; QByteArray driverName; QByteArray description; + QString gpuSuitableScreen; }; #ifndef QT_NO_DEBUG_STREAM @@ -82,18 +83,18 @@ public: GlesMask = Gles | AngleBackendMask, SoftwareRasterizer = 0x0020, RendererMask = 0x00FF, - DisableRotationFlag = 0x0100 + DisableRotationFlag = 0x0100, + DisableProgramCacheFlag = 0x0200 }; Q_DECLARE_FLAGS(Renderers, Renderer) static Renderer requestedGlesRenderer(); static Renderer requestedRenderer(); - static Renderers supportedGlesRenderers(); - static Renderers supportedRenderers(); + static QWindowsOpenGLTester::Renderers supportedRenderers(Renderer requested); private: - static QWindowsOpenGLTester::Renderers detectSupportedRenderers(const GpuDescription &gpu, bool glesOnly); + static Renderers detectSupportedRenderers(const GpuDescription &gpu, Renderer requested); static bool testDesktopGL(); }; diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp new file mode 100644 index 0000000000..2b6c696979 --- /dev/null +++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp @@ -0,0 +1,799 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#if defined(WINVER) && WINVER < 0x0603 +# undef WINVER +#endif +#if !defined(WINVER) +# define WINVER 0x0603 // Enable pointer functions for MinGW +#endif + +#include "qwindowspointerhandler.h" +#include "qwindowskeymapper.h" +#include "qwindowscontext.h" +#include "qwindowswindow.h" +#include "qwindowsintegration.h" +#include "qwindowsscreen.h" +#if QT_CONFIG(draganddrop) +# include "qwindowsdrag.h" +#endif + +#include <qpa/qwindowsysteminterface.h> +#include <QtGui/qguiapplication.h> +#include <QtGui/qscreen.h> +#include <QtGui/qtouchdevice.h> +#include <QtGui/qwindow.h> +#include <QtGui/private/qguiapplication_p.h> +#include <QtCore/qvarlengtharray.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qoperatingsystemversion.h> +#include <QtCore/qqueue.h> + +#include <algorithm> + +#include <windowsx.h> + +QT_BEGIN_NAMESPACE + +enum { + QT_PT_POINTER = 1, + QT_PT_TOUCH = 2, + QT_PT_PEN = 3, + QT_PT_MOUSE = 4, + QT_PT_TOUCHPAD = 5, // MinGW is missing PT_TOUCHPAD +}; + +struct PointerTouchEventInfo { + QPointer<QWindow> window; + QList<QWindowSystemInterface::TouchPoint> points; + Qt::KeyboardModifiers modifiers; +}; + +struct PointerTabletEventInfo { + QPointer<QWindow> window; + QPointF local; + QPointF global; + int device; + int pointerType; + Qt::MouseButtons buttons; + qreal pressure; + int xTilt; + int yTilt; + qreal tangentialPressure; + qreal rotation; + int z; + qint64 uid; + Qt::KeyboardModifiers modifiers; +}; + +static QQueue<PointerTouchEventInfo> touchEventQueue; +static QQueue<PointerTabletEventInfo> tabletEventQueue; + +static void enqueueTouchEvent(QWindow *window, + const QList<QWindowSystemInterface::TouchPoint> &points, + Qt::KeyboardModifiers modifiers) +{ + PointerTouchEventInfo eventInfo; + eventInfo.window = window; + eventInfo.points = points; + eventInfo.modifiers = modifiers; + touchEventQueue.enqueue(eventInfo); +} + +static void enqueueTabletEvent(QWindow *window, const QPointF &local, const QPointF &global, + int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, + int xTilt, int yTilt, qreal tangentialPressure, qreal rotation, + int z, qint64 uid, Qt::KeyboardModifiers modifiers) +{ + PointerTabletEventInfo eventInfo; + eventInfo.window = window; + eventInfo.local = local; + eventInfo.global = global; + eventInfo.device = device; + eventInfo.pointerType = pointerType; + eventInfo.buttons = buttons; + eventInfo.pressure = pressure; + eventInfo.xTilt = xTilt; + eventInfo.yTilt = yTilt; + eventInfo.tangentialPressure = tangentialPressure; + eventInfo.rotation = rotation; + eventInfo.z = z; + eventInfo.uid = uid; + eventInfo.modifiers = modifiers; + tabletEventQueue.enqueue(eventInfo); +} + +static void flushTouchEvents(QTouchDevice *touchDevice) +{ + while (!touchEventQueue.isEmpty()) { + PointerTouchEventInfo eventInfo = touchEventQueue.dequeue(); + if (eventInfo.window) { + QWindowSystemInterface::handleTouchEvent(eventInfo.window, + touchDevice, + eventInfo.points, + eventInfo.modifiers); + } + } +} + +static void flushTabletEvents() +{ + while (!tabletEventQueue.isEmpty()) { + PointerTabletEventInfo eventInfo = tabletEventQueue.dequeue(); + if (eventInfo.window) { + QWindowSystemInterface::handleTabletEvent(eventInfo.window, + eventInfo.local, + eventInfo.global, + eventInfo.device, + eventInfo.pointerType, + eventInfo.buttons, + eventInfo.pressure, + eventInfo.xTilt, + eventInfo.yTilt, + eventInfo.tangentialPressure, + eventInfo.rotation, + eventInfo.z, + eventInfo.uid, + eventInfo.modifiers); + } + } +} + +static bool draggingActive() +{ +#if QT_CONFIG(draganddrop) + return QWindowsDrag::isDragging(); +#else + return false; +#endif +} + +bool QWindowsPointerHandler::translatePointerEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, MSG msg, LRESULT *result) +{ + *result = 0; + const quint32 pointerId = GET_POINTERID_WPARAM(msg.wParam); + + POINTER_INPUT_TYPE pointerType; + if (!QWindowsContext::user32dll.getPointerType(pointerId, &pointerType)) { + qWarning() << "GetPointerType() failed:" << qt_error_string(); + return false; + } + + switch (pointerType) { + case QT_PT_POINTER: + case QT_PT_MOUSE: + case QT_PT_TOUCHPAD: { + POINTER_INFO pointerInfo; + if (!QWindowsContext::user32dll.getPointerInfo(pointerId, &pointerInfo)) { + qWarning() << "GetPointerInfo() failed:" << qt_error_string(); + return false; + } + return translateMouseTouchPadEvent(window, hwnd, et, msg, &pointerInfo); + } + case QT_PT_TOUCH: { + quint32 pointerCount = 0; + if (!QWindowsContext::user32dll.getPointerFrameTouchInfo(pointerId, &pointerCount, nullptr)) { + qWarning() << "GetPointerFrameTouchInfo() failed:" << qt_error_string(); + return false; + } + QVarLengthArray<POINTER_TOUCH_INFO, 10> touchInfo(pointerCount); + if (!QWindowsContext::user32dll.getPointerFrameTouchInfo(pointerId, &pointerCount, touchInfo.data())) { + qWarning() << "GetPointerFrameTouchInfo() failed:" << qt_error_string(); + return false; + } + + if (!pointerCount) + return false; + + // The history count is the same for all the touchpoints in touchInfo + quint32 historyCount = touchInfo[0].pointerInfo.historyCount; + // dispatch any skipped frames if event compression is disabled by the app + if (historyCount > 1 && !QCoreApplication::testAttribute(Qt::AA_CompressHighFrequencyEvents)) { + touchInfo.resize(pointerCount * historyCount); + if (!QWindowsContext::user32dll.getPointerFrameTouchInfoHistory(pointerId, + &historyCount, + &pointerCount, + touchInfo.data())) { + qWarning() << "GetPointerFrameTouchInfoHistory() failed:" << qt_error_string(); + return false; + } + + // history frames are returned with the most recent frame first so we iterate backwards + bool result = true; + for (auto it = touchInfo.rbegin(), end = touchInfo.rend(); it != end; it += pointerCount) { + result &= translateTouchEvent(window, hwnd, et, msg, + &(*(it + (pointerCount - 1))), pointerCount); + } + return result; + } + + return translateTouchEvent(window, hwnd, et, msg, touchInfo.data(), pointerCount); + } + case QT_PT_PEN: { + POINTER_PEN_INFO penInfo; + if (!QWindowsContext::user32dll.getPointerPenInfo(pointerId, &penInfo)) { + qWarning() << "GetPointerPenInfo() failed:" << qt_error_string(); + return false; + } + + quint32 historyCount = penInfo.pointerInfo.historyCount; + // dispatch any skipped frames if generic or tablet event compression is disabled by the app + if (historyCount > 1 + && (!QCoreApplication::testAttribute(Qt::AA_CompressHighFrequencyEvents) + || !QCoreApplication::testAttribute(Qt::AA_CompressTabletEvents))) { + QVarLengthArray<POINTER_PEN_INFO, 10> penInfoHistory(historyCount); + + if (!QWindowsContext::user32dll.getPointerPenInfoHistory(pointerId, + &historyCount, + penInfoHistory.data())) { + qWarning() << "GetPointerPenInfoHistory() failed:" << qt_error_string(); + return false; + } + + // history frames are returned with the most recent frame first so we iterate backwards + bool result = true; + for (auto it = penInfoHistory.rbegin(), end = penInfoHistory.rend(); it != end; ++it) { + result &= translatePenEvent(window, hwnd, et, msg, &(*(it))); + } + return result; + } + + return translatePenEvent(window, hwnd, et, msg, &penInfo); + } + } + return false; +} + +static void getMouseEventInfo(UINT message, POINTER_BUTTON_CHANGE_TYPE changeType, QEvent::Type *eventType, Qt::MouseButton *mouseButton) +{ + static const QHash<POINTER_BUTTON_CHANGE_TYPE, Qt::MouseButton> buttonMapping { + {POINTER_CHANGE_FIRSTBUTTON_DOWN, Qt::LeftButton}, + {POINTER_CHANGE_FIRSTBUTTON_UP, Qt::LeftButton}, + {POINTER_CHANGE_SECONDBUTTON_DOWN, Qt::RightButton}, + {POINTER_CHANGE_SECONDBUTTON_UP, Qt::RightButton}, + {POINTER_CHANGE_THIRDBUTTON_DOWN, Qt::MiddleButton}, + {POINTER_CHANGE_THIRDBUTTON_UP, Qt::MiddleButton}, + {POINTER_CHANGE_FOURTHBUTTON_DOWN, Qt::XButton1}, + {POINTER_CHANGE_FOURTHBUTTON_UP, Qt::XButton1}, + {POINTER_CHANGE_FIFTHBUTTON_DOWN, Qt::XButton2}, + {POINTER_CHANGE_FIFTHBUTTON_UP, Qt::XButton2}, + }; + + static const POINTER_BUTTON_CHANGE_TYPE downChanges[] = { + POINTER_CHANGE_FIRSTBUTTON_DOWN, + POINTER_CHANGE_SECONDBUTTON_DOWN, + POINTER_CHANGE_THIRDBUTTON_DOWN, + POINTER_CHANGE_FOURTHBUTTON_DOWN, + POINTER_CHANGE_FIFTHBUTTON_DOWN, + }; + + static const POINTER_BUTTON_CHANGE_TYPE upChanges[] = { + POINTER_CHANGE_FIRSTBUTTON_UP, + POINTER_CHANGE_SECONDBUTTON_UP, + POINTER_CHANGE_THIRDBUTTON_UP, + POINTER_CHANGE_FOURTHBUTTON_UP, + POINTER_CHANGE_FIFTHBUTTON_UP, + }; + + if (!eventType || !mouseButton) + return; + + const bool nonClient = message == WM_NCPOINTERUPDATE || + message == WM_NCPOINTERDOWN || + message == WM_NCPOINTERUP; + + if (std::find(std::begin(downChanges), + std::end(downChanges), changeType) < std::end(downChanges)) { + *eventType = nonClient ? QEvent::NonClientAreaMouseButtonPress : + QEvent::MouseButtonPress; + } else if (std::find(std::begin(upChanges), + std::end(upChanges), changeType) < std::end(upChanges)) { + *eventType = nonClient ? QEvent::NonClientAreaMouseButtonRelease : + QEvent::MouseButtonRelease; + } else if (message == WM_POINTERWHEEL || message == WM_POINTERHWHEEL) { + *eventType = QEvent::Wheel; + } else { + *eventType = nonClient ? QEvent::NonClientAreaMouseMove : + QEvent::MouseMove; + } + + *mouseButton = buttonMapping.value(changeType, Qt::NoButton); +} + +static QWindow *getWindowUnderPointer(QWindow *window, QPoint globalPos) +{ + QWindow *currentWindowUnderPointer = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT); + + while (currentWindowUnderPointer && currentWindowUnderPointer->flags() & Qt::WindowTransparentForInput) + currentWindowUnderPointer = currentWindowUnderPointer->parent(); + + // QTBUG-44332: When Qt is running at low integrity level and + // a Qt Window is parented on a Window of a higher integrity process + // using QWindow::fromWinId() (for example, Qt running in a browser plugin) + // ChildWindowFromPointEx() may not find the Qt window (failing with ERROR_ACCESS_DENIED) + if (!currentWindowUnderPointer) { + const QRect clientRect(QPoint(0, 0), window->size()); + if (clientRect.contains(globalPos)) + currentWindowUnderPointer = window; + } + return currentWindowUnderPointer; +} + +static bool trackLeave(HWND hwnd) +{ + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = hwnd; + tme.dwHoverTime = HOVER_DEFAULT; + return TrackMouseEvent(&tme); +} + +static bool isValidWheelReceiver(QWindow *candidate) +{ + if (candidate) { + const QWindow *toplevel = QWindowsWindow::topLevelOf(candidate); + if (toplevel->handle() && toplevel->handle()->isForeignWindow()) + return true; + if (const QWindowsWindow *ww = QWindowsWindow::windowsWindowOf(toplevel)) + return !ww->testFlag(QWindowsWindow::BlockedByModal); + } + return false; +} + +static QTouchDevice *createTouchDevice() +{ + const int digitizers = GetSystemMetrics(SM_DIGITIZER); + if (!(digitizers & (NID_INTEGRATED_TOUCH | NID_EXTERNAL_TOUCH))) + return nullptr; + const int tabletPc = GetSystemMetrics(SM_TABLETPC); + const int maxTouchPoints = GetSystemMetrics(SM_MAXIMUMTOUCHES); + qCDebug(lcQpaEvents) << "Digitizers:" << hex << showbase << (digitizers & ~NID_READY) + << "Ready:" << (digitizers & NID_READY) << dec << noshowbase + << "Tablet PC:" << tabletPc << "Max touch points:" << maxTouchPoints; + QTouchDevice *result = new QTouchDevice; + result->setType(digitizers & NID_INTEGRATED_TOUCH + ? QTouchDevice::TouchScreen : QTouchDevice::TouchPad); + QTouchDevice::Capabilities capabilities = QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition; + if (result->type() == QTouchDevice::TouchPad) + capabilities |= QTouchDevice::MouseEmulation; + result->setCapabilities(capabilities); + result->setMaximumTouchPoints(maxTouchPoints); + return result; +} + +QTouchDevice *QWindowsPointerHandler::ensureTouchDevice() +{ + if (!m_touchDevice) + m_touchDevice = createTouchDevice(); + return m_touchDevice; +} + +Qt::MouseButtons QWindowsPointerHandler::queryMouseButtons() +{ + Qt::MouseButtons result = 0; + const bool mouseSwapped = GetSystemMetrics(SM_SWAPBUTTON); + if (GetAsyncKeyState(VK_LBUTTON) < 0) + result |= mouseSwapped ? Qt::RightButton: Qt::LeftButton; + if (GetAsyncKeyState(VK_RBUTTON) < 0) + result |= mouseSwapped ? Qt::LeftButton : Qt::RightButton; + if (GetAsyncKeyState(VK_MBUTTON) < 0) + result |= Qt::MidButton; + if (GetAsyncKeyState(VK_XBUTTON1) < 0) + result |= Qt::XButton1; + if (GetAsyncKeyState(VK_XBUTTON2) < 0) + result |= Qt::XButton2; + return result; +} + +bool QWindowsPointerHandler::translateMouseTouchPadEvent(QWindow *window, HWND hwnd, + QtWindows::WindowsEventType et, + MSG msg, PVOID vPointerInfo) +{ + POINTER_INFO *pointerInfo = static_cast<POINTER_INFO *>(vPointerInfo); + const QPoint globalPos = QPoint(pointerInfo->ptPixelLocation.x, pointerInfo->ptPixelLocation.y); + const QPoint localPos = QWindowsGeometryHint::mapFromGlobal(hwnd, globalPos); + const Qt::KeyboardModifiers keyModifiers = QWindowsKeyMapper::queryKeyboardModifiers(); + const Qt::MouseButtons mouseButtons = queryMouseButtons(); + + QWindow *currentWindowUnderPointer = getWindowUnderPointer(window, globalPos); + QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window->handle()); + + switch (msg.message) { + case WM_NCPOINTERDOWN: + case WM_NCPOINTERUP: + case WM_NCPOINTERUPDATE: + case WM_POINTERDOWN: + case WM_POINTERUP: + case WM_POINTERUPDATE: { + + QEvent::Type eventType; + Qt::MouseButton button; + getMouseEventInfo(msg.message, pointerInfo->ButtonChangeType, &eventType, &button); + + if (et & QtWindows::NonClientEventFlag) { + QWindowSystemInterface::handleFrameStrutMouseEvent(window, localPos, globalPos, mouseButtons, button, eventType, + keyModifiers, Qt::MouseEventNotSynthesized); + return false; // To allow window dragging, etc. + } else { + if (currentWindowUnderPointer != m_windowUnderPointer) { + if (m_windowUnderPointer && m_windowUnderPointer == m_currentWindow) { + QWindowSystemInterface::handleLeaveEvent(m_windowUnderPointer); + m_currentWindow = nullptr; + } + + if (currentWindowUnderPointer) { + if (currentWindowUnderPointer != m_currentWindow) { + QWindowSystemInterface::handleEnterEvent(currentWindowUnderPointer, localPos, globalPos); + m_currentWindow = currentWindowUnderPointer; + if (QWindowsWindow *wumPlatformWindow = QWindowsWindow::windowsWindowOf(currentWindowUnderPointer)) + wumPlatformWindow->applyCursor(); + trackLeave(hwnd); + } + } else { + platformWindow->applyCursor(); + } + m_windowUnderPointer = currentWindowUnderPointer; + } + + QWindowSystemInterface::handleMouseEvent(window, localPos, globalPos, mouseButtons, button, eventType, + keyModifiers, Qt::MouseEventNotSynthesized); + + // The initial down click over the QSizeGrip area, which posts a resize WM_SYSCOMMAND + // has go to through DefWindowProc() for resizing to work, so we return false here, + // unless the mouse is captured, as it would mess with menu processing. + return msg.message != WM_POINTERDOWN || GetCapture(); + } + } + case WM_POINTERHWHEEL: + case WM_POINTERWHEEL: { + + if (!isValidWheelReceiver(window)) + return true; + + int delta = GET_WHEEL_DELTA_WPARAM(msg.wParam); + + // Qt horizontal wheel rotation orientation is opposite to the one in WM_POINTERHWHEEL + if (msg.message == WM_POINTERHWHEEL) + delta = -delta; + + const QPoint angleDelta = (msg.message == WM_POINTERHWHEEL || (keyModifiers & Qt::AltModifier)) ? + QPoint(delta, 0) : QPoint(0, delta); + + QWindowSystemInterface::handleWheelEvent(window, localPos, globalPos, QPoint(), angleDelta, keyModifiers); + return true; + } + case WM_POINTERLEAVE: + return true; + } + return false; +} + +bool QWindowsPointerHandler::translateTouchEvent(QWindow *window, HWND hwnd, + QtWindows::WindowsEventType et, + MSG msg, PVOID vTouchInfo, quint32 count) +{ + Q_UNUSED(hwnd); + + if (et & QtWindows::NonClientEventFlag) + return false; // Let DefWindowProc() handle Non Client messages. + + if (draggingActive()) + return false; // Let DoDragDrop() loop handle it. + + if (count < 1) + return false; + + if (msg.message == WM_POINTERCAPTURECHANGED) { + QWindowSystemInterface::handleTouchCancelEvent(window, m_touchDevice, + QWindowsKeyMapper::queryKeyboardModifiers()); + m_lastTouchPositions.clear(); + return true; + } + + // Only handle down/up/update, ignore others like WM_POINTERENTER, WM_POINTERLEAVE, etc. + if (msg.message > WM_POINTERUP) + return false; + + const QScreen *screen = window->screen(); + if (!screen) + screen = QGuiApplication::primaryScreen(); + if (!screen) + return false; + + POINTER_TOUCH_INFO *touchInfo = static_cast<POINTER_TOUCH_INFO *>(vTouchInfo); + + const QRect screenGeometry = screen->geometry(); + + QList<QWindowSystemInterface::TouchPoint> touchPoints; + + bool primaryPointer = false; + + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaEvents).noquote().nospace() << showbase + << __FUNCTION__ + << " message=" << hex << msg.message + << " count=" << dec << count; + + for (quint32 i = 0; i < count; ++i) { + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaEvents).noquote().nospace() << showbase + << " TouchPoint id=" << touchInfo[i].pointerInfo.pointerId + << " frame=" << touchInfo[i].pointerInfo.frameId + << " flags=" << hex << touchInfo[i].pointerInfo.pointerFlags; + + QWindowSystemInterface::TouchPoint touchPoint; + touchPoint.id = touchInfo[i].pointerInfo.pointerId; + touchPoint.pressure = (touchInfo[i].touchMask & TOUCH_MASK_PRESSURE) ? + touchInfo[i].pressure / 1024.0 : 1.0; + if (m_lastTouchPositions.contains(touchPoint.id)) + touchPoint.normalPosition = m_lastTouchPositions.value(touchPoint.id); + + const QPointF screenPos = QPointF(touchInfo[i].pointerInfo.ptPixelLocation.x, + touchInfo[i].pointerInfo.ptPixelLocation.y); + + if (touchInfo[i].touchMask & TOUCH_MASK_CONTACTAREA) + touchPoint.area.setSize(QSizeF(touchInfo[i].rcContact.right - touchInfo[i].rcContact.left, + touchInfo[i].rcContact.bottom - touchInfo[i].rcContact.top)); + touchPoint.area.moveCenter(screenPos); + QPointF normalPosition = QPointF(screenPos.x() / screenGeometry.width(), + screenPos.y() / screenGeometry.height()); + const bool stationaryTouchPoint = (normalPosition == touchPoint.normalPosition); + touchPoint.normalPosition = normalPosition; + + if (touchInfo[i].pointerInfo.pointerFlags & POINTER_FLAG_DOWN) { + touchPoint.state = Qt::TouchPointPressed; + m_lastTouchPositions.insert(touchPoint.id, touchPoint.normalPosition); + } else if (touchInfo[i].pointerInfo.pointerFlags & POINTER_FLAG_UP) { + touchPoint.state = Qt::TouchPointReleased; + m_lastTouchPositions.remove(touchPoint.id); + } else { + touchPoint.state = stationaryTouchPoint ? Qt::TouchPointStationary : Qt::TouchPointMoved; + m_lastTouchPositions.insert(touchPoint.id, touchPoint.normalPosition); + } + if (touchInfo[i].pointerInfo.pointerFlags & POINTER_FLAG_PRIMARY) + primaryPointer = true; + + touchPoints.append(touchPoint); + + // Avoid getting repeated messages for this frame if there are multiple pointerIds + QWindowsContext::user32dll.skipPointerFrameMessages(touchInfo[i].pointerInfo.pointerId); + } + if (primaryPointer) { + // Postpone event delivery to avoid hanging inside DoDragDrop(). + // Only the primary pointer will generate mouse messages. + enqueueTouchEvent(window, touchPoints, QWindowsKeyMapper::queryKeyboardModifiers()); + } else { + QWindowSystemInterface::handleTouchEvent(window, m_touchDevice, touchPoints, + QWindowsKeyMapper::queryKeyboardModifiers()); + } + return false; // Allow mouse messages to be generated. +} + +bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, + MSG msg, PVOID vPenInfo) +{ + if (et & QtWindows::NonClientEventFlag) + return false; // Let DefWindowProc() handle Non Client messages. + + if (draggingActive()) + return false; // Let DoDragDrop() loop handle it. + + POINTER_PEN_INFO *penInfo = static_cast<POINTER_PEN_INFO *>(vPenInfo); + + RECT pRect, dRect; + if (!QWindowsContext::user32dll.getPointerDeviceRects(penInfo->pointerInfo.sourceDevice, &pRect, &dRect)) + return false; + + const quint32 pointerId = penInfo->pointerInfo.pointerId; + const QPoint globalPos = QPoint(penInfo->pointerInfo.ptPixelLocation.x, penInfo->pointerInfo.ptPixelLocation.y); + const QPoint localPos = QWindowsGeometryHint::mapFromGlobal(hwnd, globalPos); + const QPointF hiResGlobalPos = QPointF(dRect.left + qreal(penInfo->pointerInfo.ptHimetricLocation.x - pRect.left) + / (pRect.right - pRect.left) * (dRect.right - dRect.left), + dRect.top + qreal(penInfo->pointerInfo.ptHimetricLocation.y - pRect.top) + / (pRect.bottom - pRect.top) * (dRect.bottom - dRect.top)); + const qreal pressure = (penInfo->penMask & PEN_MASK_PRESSURE) ? qreal(penInfo->pressure) / 1024.0 : 0.5; + const qreal rotation = (penInfo->penMask & PEN_MASK_ROTATION) ? qreal(penInfo->rotation) : 0.0; + const qreal tangentialPressure = 0.0; + const int xTilt = (penInfo->penMask & PEN_MASK_TILT_X) ? penInfo->tiltX : 0; + const int yTilt = (penInfo->penMask & PEN_MASK_TILT_Y) ? penInfo->tiltY : 0; + const int z = 0; + + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaEvents).noquote().nospace() << showbase + << __FUNCTION__ << " pointerId=" << pointerId + << " globalPos=" << globalPos << " localPos=" << localPos << " hiResGlobalPos=" << hiResGlobalPos + << " message=" << hex << msg.message + << " flags=" << hex << penInfo->pointerInfo.pointerFlags; + + const QTabletEvent::TabletDevice device = QTabletEvent::Stylus; + QTabletEvent::PointerType type; + Qt::MouseButtons mouseButtons; + + const bool pointerInContact = IS_POINTER_INCONTACT_WPARAM(msg.wParam); + if (pointerInContact) + mouseButtons = Qt::LeftButton; + + if (penInfo->penFlags & (PEN_FLAG_ERASER | PEN_FLAG_INVERTED)) { + type = QTabletEvent::Eraser; + } else { + type = QTabletEvent::Pen; + if (pointerInContact && penInfo->penFlags & PEN_FLAG_BARREL) + mouseButtons = Qt::RightButton; // Either left or right, not both + } + + switch (msg.message) { + case WM_POINTERENTER: { + QWindowSystemInterface::handleTabletEnterProximityEvent(device, type, pointerId); + m_windowUnderPointer = window; + // The local coordinates may fall outside the window. + // Wait until the next update to send the enter event. + m_needsEnterOnPointerUpdate = true; + break; + } + case WM_POINTERLEAVE: + if (m_windowUnderPointer && m_windowUnderPointer == m_currentWindow) { + QWindowSystemInterface::handleLeaveEvent(m_windowUnderPointer); + m_windowUnderPointer = nullptr; + m_currentWindow = nullptr; + } + QWindowSystemInterface::handleTabletLeaveProximityEvent(device, type, pointerId); + break; + case WM_POINTERDOWN: + case WM_POINTERUP: + case WM_POINTERUPDATE: { + QWindow *target = QGuiApplicationPrivate::tabletDevicePoint(pointerId).target; // Pass to window that grabbed it. + if (!target && m_windowUnderPointer) + target = m_windowUnderPointer; + if (!target) + target = window; + + if (m_needsEnterOnPointerUpdate) { + m_needsEnterOnPointerUpdate = false; + if (window != m_currentWindow) { + QWindowSystemInterface::handleEnterEvent(window, localPos, globalPos); + m_currentWindow = window; + if (QWindowsWindow *wumPlatformWindow = QWindowsWindow::windowsWindowOf(target)) + wumPlatformWindow->applyCursor(); + } + } + const Qt::KeyboardModifiers keyModifiers = QWindowsKeyMapper::queryKeyboardModifiers(); + + // Postpone event delivery to avoid hanging inside DoDragDrop(). + enqueueTabletEvent(target, localPos, hiResGlobalPos, device, type, mouseButtons, + pressure, xTilt, yTilt, tangentialPressure, rotation, z, + pointerId, keyModifiers); + return false; // Allow mouse messages to be generated. + } + } + return true; +} + +// Process old-style mouse messages here. +bool QWindowsPointerHandler::translateMouseEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, MSG msg, LRESULT *result) +{ + // Generate enqueued events. + flushTouchEvents(m_touchDevice); + flushTabletEvents(); + + *result = 0; + if (et != QtWindows::MouseWheelEvent && msg.message != WM_MOUSELEAVE && msg.message != WM_MOUSEMOVE) + return false; + + const QPoint eventPos(GET_X_LPARAM(msg.lParam), GET_Y_LPARAM(msg.lParam)); + QPoint localPos; + QPoint globalPos; + if ((et == QtWindows::MouseWheelEvent) || (et & QtWindows::NonClientEventFlag)) { + globalPos = eventPos; + localPos = QWindowsGeometryHint::mapFromGlobal(hwnd, eventPos); + } else { + localPos = eventPos; + globalPos = QWindowsGeometryHint::mapToGlobal(hwnd, eventPos); + } + + const Qt::KeyboardModifiers keyModifiers = QWindowsKeyMapper::queryKeyboardModifiers(); + QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window->handle()); + + if (et == QtWindows::MouseWheelEvent) { + + if (!isValidWheelReceiver(window)) + return true; + + int delta = GET_WHEEL_DELTA_WPARAM(msg.wParam); + + // Qt horizontal wheel rotation orientation is opposite to the one in WM_MOUSEHWHEEL + if (msg.message == WM_MOUSEHWHEEL) + delta = -delta; + + const QPoint angleDelta = (msg.message == WM_MOUSEHWHEEL || (keyModifiers & Qt::AltModifier)) ? + QPoint(delta, 0) : QPoint(0, delta); + + QWindowSystemInterface::handleWheelEvent(window, localPos, globalPos, QPoint(), angleDelta, keyModifiers); + return true; + } + + if (msg.message == WM_MOUSELEAVE) { + if (window == m_currentWindow) { + QWindowSystemInterface::handleLeaveEvent(window); + m_windowUnderPointer = nullptr; + m_currentWindow = nullptr; + platformWindow->applyCursor(); + } + return false; + } + + // Windows sends a mouse move with no buttons pressed to signal "Enter" + // when a window is shown over the cursor. Discard the event and only use + // it for generating QEvent::Enter to be consistent with other platforms - + // X11 and macOS. + static QPoint lastMouseMovePos; + const bool discardEvent = msg.wParam == 0 && (m_windowUnderPointer.isNull() || globalPos == lastMouseMovePos); + lastMouseMovePos = globalPos; + + QWindow *currentWindowUnderPointer = getWindowUnderPointer(window, globalPos); + + if (currentWindowUnderPointer != m_windowUnderPointer) { + if (m_windowUnderPointer && m_windowUnderPointer == m_currentWindow) { + QWindowSystemInterface::handleLeaveEvent(m_windowUnderPointer); + m_currentWindow = nullptr; + } + + if (currentWindowUnderPointer) { + if (currentWindowUnderPointer != m_currentWindow) { + QWindowSystemInterface::handleEnterEvent(currentWindowUnderPointer, localPos, globalPos); + m_currentWindow = currentWindowUnderPointer; + if (QWindowsWindow *wumPlatformWindow = QWindowsWindow::windowsWindowOf(currentWindowUnderPointer)) + wumPlatformWindow->applyCursor(); + trackLeave(hwnd); + } + } else { + platformWindow->applyCursor(); + } + m_windowUnderPointer = currentWindowUnderPointer; + } + + const Qt::MouseButtons mouseButtons = queryMouseButtons(); + + if (!discardEvent) + QWindowSystemInterface::handleMouseEvent(window, localPos, globalPos, mouseButtons, Qt::NoButton, QEvent::MouseMove, + keyModifiers, Qt::MouseEventNotSynthesized); + return false; +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.h b/src/plugins/platforms/windows/qwindowspointerhandler.h new file mode 100644 index 0000000000..c4d0e0ce4a --- /dev/null +++ b/src/plugins/platforms/windows/qwindowspointerhandler.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSPOINTERHANDLER_H +#define QWINDOWSPOINTERHANDLER_H + +#include "qtwindowsglobal.h" +#include <QtCore/qt_windows.h> + +#include <QtCore/qpointer.h> +#include <QtCore/qscopedpointer.h> +#include <QtCore/qhash.h> + +QT_BEGIN_NAMESPACE + +class QWindow; +class QTouchDevice; + +class QWindowsPointerHandler +{ + Q_DISABLE_COPY(QWindowsPointerHandler) +public: + QWindowsPointerHandler() = default; + bool translatePointerEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, MSG msg, LRESULT *result); + bool translateMouseEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, MSG msg, LRESULT *result); + QTouchDevice *touchDevice() const { return m_touchDevice; } + QTouchDevice *ensureTouchDevice(); + Qt::MouseButtons queryMouseButtons(); + QWindow *windowUnderMouse() const { return m_windowUnderPointer.data(); } + void clearWindowUnderMouse() { m_windowUnderPointer = nullptr; } + +private: + bool translateMouseTouchPadEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, MSG msg, PVOID vPointerInfo); + bool translateTouchEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, MSG msg, PVOID vTouchInfo, unsigned int count); + bool translatePenEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, MSG msg, PVOID vPenInfo); + + QTouchDevice *m_touchDevice = nullptr; + QHash<int, QPointF> m_lastTouchPositions; + QPointer<QWindow> m_windowUnderPointer; + QPointer<QWindow> m_currentWindow; + bool m_needsEnterOnPointerUpdate = false; +}; + +QT_END_NAMESPACE + +#endif // QWINDOWSPOINTERHANDLER_H diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index d56dc870ea..2eaf386d42 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -45,14 +45,14 @@ #include <QtCore/qt_windows.h> -#include <QtCore/QSettings> -#include <QtGui/QPixmap> -#include <QtGui/QGuiApplication> +#include <QtCore/qsettings.h> +#include <QtGui/qpixmap.h> +#include <QtGui/qguiapplication.h> #include <qpa/qwindowsysteminterface.h> #include <private/qhighdpiscaling_p.h> -#include <QtGui/QScreen> +#include <QtGui/qscreen.h> -#include <QtCore/QDebug> +#include <QtCore/qdebug.h> QT_BEGIN_NAMESPACE @@ -69,7 +69,7 @@ static inline QDpi monitorDPI(HMONITOR hMonitor) if (SUCCEEDED(QWindowsContext::shcoredll.getDpiForMonitor(hMonitor, 0, &dpiX, &dpiY))) return QDpi(dpiX, dpiY); } - return QDpi(0, 0); + return {0, 0}; } typedef QList<QWindowsScreenData> WindowsScreenDataList; @@ -274,9 +274,12 @@ QList<QPlatformScreen *> QWindowsScreen::virtualSiblings() const { QList<QPlatformScreen *> result; if (m_data.flags & QWindowsScreenData::VirtualDesktop) { - foreach (QWindowsScreen *screen, QWindowsContext::instance()->screenManager().screens()) + const QWindowsScreenManager::WindowsScreenList screens + = QWindowsContext::instance()->screenManager().screens(); + for (QWindowsScreen *screen : screens) { if (screen->data().flags & QWindowsScreenData::VirtualDesktop) result.push_back(screen); + } } else { result.push_back(const_cast<QWindowsScreen *>(this)); } @@ -327,10 +330,7 @@ QRect QWindowsScreen::virtualGeometry(const QPlatformScreen *screen) // cf QScre return result; } -enum OrientationPreference // matching Win32 API ORIENTATION_PREFERENCE -#if defined(Q_COMPILER_CLASS_ENUM) || defined(Q_CC_MSVC) - : DWORD -#endif +enum OrientationPreference : DWORD // matching Win32 API ORIENTATION_PREFERENCE { orientationPreferenceNone = 0, orientationPreferenceLandscape = 0x1, @@ -398,7 +398,8 @@ QPlatformScreen::SubpixelAntialiasingType QWindowsScreen::subpixelAntialiasingTy { QPlatformScreen::SubpixelAntialiasingType type = QPlatformScreen::subpixelAntialiasingTypeHint(); if (type == QPlatformScreen::Subpixel_None) { - QSettings settings(QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Avalon.Graphics\\DISPLAY1"), QSettings::NativeFormat); + QSettings settings(QLatin1String(R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Avalon.Graphics\DISPLAY1)"), + QSettings::NativeFormat); int registryValue = settings.value(QLatin1String("PixelStructure"), -1).toInt(); switch (registryValue) { case 0: @@ -505,7 +506,8 @@ void QWindowsScreenManager::removeScreen(int index) // move those manually. if (screen != primaryScreen) { unsigned movedWindowCount = 0; - foreach (QWindow *w, QGuiApplication::topLevelWindows()) { + const QWindowList tlws = QGuiApplication::topLevelWindows(); + for (QWindow *w : tlws) { if (w->screen() == screen && w->handle() && w->type() != Qt::Desktop) { if (w->isVisible() && w->windowState() != Qt::WindowMinimized && (QWindowsWindow::baseWindowOf(w)->exStyle() & WS_EX_TOOLWINDOW)) { @@ -530,9 +532,9 @@ void QWindowsScreenManager::removeScreen(int index) bool QWindowsScreenManager::handleScreenChanges() { // Look for changed monitors, add new ones - WindowsScreenDataList newDataList = monitorData(); + const WindowsScreenDataList newDataList = monitorData(); const bool lockScreen = newDataList.size() == 1 && (newDataList.front().flags & QWindowsScreenData::LockScreen); - foreach (const QWindowsScreenData &newData, newDataList) { + for (const QWindowsScreenData &newData : newDataList) { const int existingIndex = indexOfMonitor(m_screens, newData.name); if (existingIndex != -1) { m_screens.at(existingIndex)->handleChanges(newData); @@ -564,7 +566,7 @@ void QWindowsScreenManager::clearScreens() const QWindowsScreen *QWindowsScreenManager::screenAtDp(const QPoint &p) const { - foreach (QWindowsScreen *scr, m_screens) { + for (QWindowsScreen *scr : m_screens) { if (scr->geometry().contains(p)) return scr; } diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h index 5753e605da..824bcb1ad6 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.h +++ b/src/plugins/platforms/windows/qwindowsscreen.h @@ -42,10 +42,10 @@ #include "qtwindowsglobal.h" -#include <QtCore/QList> -#include <QtCore/QVector> -#include <QtCore/QPair> -#include <QtCore/QScopedPointer> +#include <QtCore/qlist.h> +#include <QtCore/qvector.h> +#include <QtCore/qpair.h> +#include <QtCore/qscopedpointer.h> #include <qpa/qplatformscreen.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp index 48332b35f8..b6ed27464e 100644 --- a/src/plugins/platforms/windows/qwindowsservices.cpp +++ b/src/plugins/platforms/windows/qwindowsservices.cpp @@ -41,9 +41,9 @@ #include "qwindowsservices.h" #include <QtCore/qt_windows.h> -#include <QtCore/QUrl> -#include <QtCore/QDebug> -#include <QtCore/QDir> +#include <QtCore/qurl.h> +#include <QtCore/qdebug.h> +#include <QtCore/qdir.h> #include <shlobj.h> #include <intshcut.h> diff --git a/src/plugins/platforms/windows/qwindowsservices.h b/src/plugins/platforms/windows/qwindowsservices.h index 7518a52755..5feb7c8490 100644 --- a/src/plugins/platforms/windows/qwindowsservices.h +++ b/src/plugins/platforms/windows/qwindowsservices.h @@ -47,8 +47,8 @@ QT_BEGIN_NAMESPACE class QWindowsServices : public QPlatformServices { public: - bool openUrl(const QUrl &url); - bool openDocument(const QUrl &url); + bool openUrl(const QUrl &url) override; + bool openDocument(const QUrl &url) override; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.h b/src/plugins/platforms/windows/qwindowssystemtrayicon.h index 1f696180cd..a8adb9641f 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.h +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.h @@ -57,7 +57,7 @@ class QWindowsSystemTrayIcon : public QPlatformSystemTrayIcon { public: QWindowsSystemTrayIcon(); - ~QWindowsSystemTrayIcon(); + ~QWindowsSystemTrayIcon() override; void init() override; void cleanup() override; diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp index 6acb62ad8f..fa209f09c4 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp @@ -46,13 +46,13 @@ #include <qpa/qwindowsysteminterface.h> -#include <QtGui/QTabletEvent> -#include <QtGui/QScreen> -#include <QtGui/QGuiApplication> -#include <QtGui/QWindow> -#include <QtCore/QDebug> -#include <QtCore/QVarLengthArray> -#include <QtCore/QtMath> +#include <QtGui/qevent.h> +#include <QtGui/qscreen.h> +#include <QtGui/qguiapplication.h> +#include <QtGui/qwindow.h> +#include <QtCore/qdebug.h> +#include <QtCore/qvarlengtharray.h> +#include <QtCore/qmath.h> #include <private/qguiapplication_p.h> #include <QtCore/private/qsystemlibrary_p.h> @@ -108,7 +108,7 @@ inline QPointF QWindowsTabletDeviceData::scaleCoordinates(int coordX, int coordY ((coordY - minY) * qAbs(targetHeight) / qAbs(qreal(maxY - minY))) + targetY : ((qAbs(maxY) - (coordY - minY)) * qAbs(targetHeight) / qAbs(qreal(maxY - minY))) + targetY; - return QPointF(x, y); + return {x, y}; } template <class Stream> @@ -135,9 +135,9 @@ QDebug operator<<(QDebug d, const QWindowsTabletDeviceData &t) d.nospace(); d << "TabletDevice id:" << t.uniqueId << " pressure: " << t.minPressure << ".." << t.maxPressure << " tan pressure: " << t.minTanPressure << ".." - << t.maxTanPressure << " area:" << t.minX << t.minY <<t.minZ - << ".." << t.maxX << t.maxY << t.maxZ << " device " << t.currentDevice - << " pointer " << t.currentPointerType; + << t.maxTanPressure << " area: (" << t.minX << ',' << t.minY << ',' << t.minZ + << ")..(" << t.maxX << ',' << t.maxY << ',' << t.maxZ << ") device " + << t.currentDevice << " pointer " << t.currentPointerType; return d; } @@ -211,9 +211,6 @@ bool QWindowsWinTab32DLL::init() QWindowsTabletSupport::QWindowsTabletSupport(HWND window, HCTX context) : m_window(window) , m_context(context) - , m_absoluteRange(20) - , m_tiltSupport(false) - , m_currentDevice(-1) { AXIS orientation[3]; // Some tablets don't support tilt, check if it is possible, @@ -230,13 +227,13 @@ QWindowsTabletSupport::~QWindowsTabletSupport() QWindowsTabletSupport *QWindowsTabletSupport::create() { if (!m_winTab32DLL.init()) - return 0; + return nullptr; const HWND window = QWindowsContext::instance()->createDummyWindow(QStringLiteral("TabletDummyWindow"), L"TabletDummyWindow", qWindowsTabletSupportWndProc); if (!window) { qCWarning(lcQpaTablet) << __FUNCTION__ << "Unable to create window for tablet."; - return 0; + return nullptr; } LOGCONTEXT lcMine; // build our context from the default context @@ -255,7 +252,7 @@ QWindowsTabletSupport *QWindowsTabletSupport::create() if (!context) { qCDebug(lcQpaTablet) << __FUNCTION__ << "Unable to open tablet."; DestroyWindow(window); - return 0; + return nullptr; } // Set the size of the Packet Queue to the correct size @@ -266,7 +263,7 @@ QWindowsTabletSupport *QWindowsTabletSupport::create() qWarning("Unable to set queue size on tablet. The tablet will not work."); QWindowsTabletSupport::m_winTab32DLL.wTClose(context); DestroyWindow(window); - return 0; + return nullptr; } // cannot restore old size } // cannot set } // mismatch @@ -285,7 +282,7 @@ unsigned QWindowsTabletSupport::options() const QString QWindowsTabletSupport::description() const { - const unsigned size = m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_WINTABID, 0); + const unsigned size = m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_WINTABID, nullptr); if (!size) return QString(); QVarLengthArray<TCHAR> winTabId(size + 1); diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.h b/src/plugins/platforms/windows/qwindowstabletsupport.h index 9379dd72d6..d91701d6a5 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.h +++ b/src/plugins/platforms/windows/qwindowstabletsupport.h @@ -43,8 +43,8 @@ #include "qtwindowsglobal.h" #include <QtGui/qtguiglobal.h> -#include <QtCore/QVector> -#include <QtCore/QPointF> +#include <QtCore/qvector.h> +#include <QtCore/qpoint.h> #include <wintab.h> @@ -83,22 +83,23 @@ struct QWindowsWinTab32DLL struct QWindowsTabletDeviceData { - QWindowsTabletDeviceData() : minPressure(0), maxPressure(0), minTanPressure(0), - maxTanPressure(0), minX(0), maxX(0), minY(0), maxY(0), minZ(0), maxZ(0), - uniqueId(0), currentDevice(0), currentPointerType(0) {} - QPointF scaleCoordinates(int coordX, int coordY,const QRect &targetArea) const; qreal scalePressure(qreal p) const { return p / qreal(maxPressure - minPressure); } qreal scaleTangentialPressure(qreal p) const { return p / qreal(maxTanPressure - minTanPressure); } - int minPressure; - int maxPressure; - int minTanPressure; - int maxTanPressure; - int minX, maxX, minY, maxY, minZ, maxZ; - qint64 uniqueId; - int currentDevice; - int currentPointerType; + int minPressure = 0; + int maxPressure = 0; + int minTanPressure = 0; + int maxTanPressure = 0; + int minX = 0; + int maxX = 0; + int minY = 0; + int maxY = 0; + int minZ = 0; + int maxZ = 0; + qint64 uniqueId = 0; + int currentDevice = 0; + int currentPointerType = 0; }; #ifndef QT_NO_DEBUG_STREAM @@ -145,10 +146,10 @@ private: static QWindowsWinTab32DLL m_winTab32DLL; const HWND m_window; const HCTX m_context; - int m_absoluteRange; - bool m_tiltSupport; + int m_absoluteRange = 20; + bool m_tiltSupport = false; QVector<QWindowsTabletDeviceData> m_devices; - int m_currentDevice; + int m_currentDevice = -1; Mode m_mode = PenMode; State m_state = PenUp; }; diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 651c661d6b..4b70e915a8 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -59,20 +59,20 @@ #endif #include <shellapi.h> -#include <QtCore/QVariant> -#include <QtCore/QCoreApplication> -#include <QtCore/QDebug> -#include <QtCore/QTextStream> -#include <QtCore/QSysInfo> -#include <QtCore/QCache> -#include <QtCore/QThread> -#include <QtCore/QMutex> -#include <QtCore/QWaitCondition> -#include <QtGui/QColor> -#include <QtGui/QPalette> -#include <QtGui/QGuiApplication> -#include <QtGui/QPainter> -#include <QtGui/QPixmapCache> +#include <QtCore/qvariant.h> +#include <QtCore/qcoreapplication.h> +#include <QtCore/qdebug.h> +#include <QtCore/qtextstream.h> +#include <QtCore/qsysinfo.h> +#include <QtCore/qcache.h> +#include <QtCore/qthread.h> +#include <QtCore/qmutex.h> +#include <QtCore/qwaitcondition.h> +#include <QtGui/qcolor.h> +#include <QtGui/qpalette.h> +#include <QtGui/qguiapplication.h> +#include <QtGui/qpainter.h> +#include <QtGui/qpixmapcache.h> #include <qpa/qwindowsysteminterface.h> #include <QtThemeSupport/private/qabstractfileiconengine_p.h> #include <QtFontDatabaseSupport/private/qwindowsfontdatabase_p.h> @@ -107,7 +107,7 @@ static inline bool booleanSystemParametersInfo(UINT what, bool defaultValue) { BOOL result; if (SystemParametersInfo(what, 0, &result, 0)) - return result ? true : false; + return result != FALSE; return defaultValue; } @@ -121,9 +121,9 @@ static inline DWORD dWordSystemParametersInfo(UINT what, DWORD defaultValue) static inline QColor mixColors(const QColor &c1, const QColor &c2) { - return QColor ((c1.red() + c2.red()) / 2, - (c1.green() + c2.green()) / 2, - (c1.blue() + c2.blue()) / 2); + return {(c1.red() + c2.red()) / 2, + (c1.green() + c2.green()) / 2, + (c1.blue() + c2.blue()) / 2}; } static inline QColor getSysColor(int index) @@ -507,9 +507,7 @@ void QWindowsTheme::refreshFonts() if (!QGuiApplication::desktopSettingsAware()) return; NONCLIENTMETRICS ncm; - ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, lfMessageFont) + sizeof(LOGFONT); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize , &ncm, 0); - + QWindowsContext::nonClientMetrics(&ncm); const QFont menuFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfMenuFont); const QFont messageBoxFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfMessageFont); const QFont statusFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfStatusFont); diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h index 237e8158fa..c132f20167 100644 --- a/src/plugins/platforms/windows/qwindowstheme.h +++ b/src/plugins/platforms/windows/qwindowstheme.h @@ -42,8 +42,8 @@ #include <qpa/qplatformtheme.h> -#include <QtCore/QSharedPointer> -#include <QtCore/QVariant> +#include <QtCore/qsharedpointer.h> +#include <QtCore/qvariant.h> QT_BEGIN_NAMESPACE @@ -51,9 +51,10 @@ class QWindow; class QWindowsTheme : public QPlatformTheme { + Q_DISABLE_COPY(QWindowsTheme) public: QWindowsTheme(); - ~QWindowsTheme(); + ~QWindowsTheme() override; static QWindowsTheme *instance() { return m_instance; } diff --git a/src/plugins/platforms/windows/qwindowsthreadpoolrunner.h b/src/plugins/platforms/windows/qwindowsthreadpoolrunner.h index 5601cc9305..731e4b5432 100644 --- a/src/plugins/platforms/windows/qwindowsthreadpoolrunner.h +++ b/src/plugins/platforms/windows/qwindowsthreadpoolrunner.h @@ -40,10 +40,10 @@ #ifndef QWINDOWSTHREADPOOLRUNNER_H #define QWINDOWSTHREADPOOLRUNNER_H -#include <QtCore/QMutex> -#include <QtCore/QRunnable> -#include <QtCore/QThreadPool> -#include <QtCore/QWaitCondition> +#include <QtCore/qmutex.h> +#include <QtCore/qrunnable.h> +#include <QtCore/qthreadpool.h> +#include <QtCore/qwaitcondition.h> QT_BEGIN_NAMESPACE @@ -61,7 +61,7 @@ class QWindowsThreadPoolRunner { Q_DISABLE_COPY(QWindowsThreadPoolRunner) -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) template <class RunnableFunction> // nested class implementing QRunnable to execute a function. class Runnable : public QRunnable { @@ -104,7 +104,7 @@ public: private: QMutex m_mutex; QWaitCondition m_condition; -#else // !QT_NO_THREAD +#else // QT_CONFIG(thread) public: QWindowsThreadPoolRunner() {} @@ -114,7 +114,7 @@ public: f(); return true; } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsvulkaninstance.cpp b/src/plugins/platforms/windows/qwindowsvulkaninstance.cpp index d81ee8ba29..7a01483abd 100644 --- a/src/plugins/platforms/windows/qwindowsvulkaninstance.cpp +++ b/src/plugins/platforms/windows/qwindowsvulkaninstance.cpp @@ -44,20 +44,9 @@ QT_BEGIN_NAMESPACE QWindowsVulkanInstance::QWindowsVulkanInstance(QVulkanInstance *instance) : m_instance(instance), m_getPhysDevPresSupport(nullptr), - m_createSurface(nullptr), - m_destroySurface(nullptr) + m_createSurface(nullptr) { - if (qEnvironmentVariableIsSet("QT_VULKAN_LIB")) - m_lib.setFileName(QString::fromUtf8(qgetenv("QT_VULKAN_LIB"))); - else - m_lib.setFileName(QStringLiteral("vulkan-1")); - - if (!m_lib.load()) { - qWarning("Failed to load %s: %s", qPrintable(m_lib.fileName()), qPrintable(m_lib.errorString())); - return; - } - - init(&m_lib); + loadVulkanLibrary(QStringLiteral("vulkan-1")); } void QWindowsVulkanInstance::createOrAdoptInstance() @@ -73,10 +62,6 @@ void QWindowsVulkanInstance::createOrAdoptInstance() qWarning("Failed to find vkGetPhysicalDeviceWin32PresentationSupportKHR"); } -QWindowsVulkanInstance::~QWindowsVulkanInstance() -{ -} - bool QWindowsVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) @@ -106,14 +91,6 @@ VkSurfaceKHR QWindowsVulkanInstance::createSurface(HWND win) qWarning("Failed to find vkCreateWin32SurfaceKHR"); return surface; } - if (!m_destroySurface) { - m_destroySurface = reinterpret_cast<PFN_vkDestroySurfaceKHR>( - m_vkGetInstanceProcAddr(m_vkInst, "vkDestroySurfaceKHR")); - } - if (!m_destroySurface) { - qWarning("Failed to find vkDestroySurfaceKHR"); - return surface; - } VkWin32SurfaceCreateInfoKHR surfaceInfo; memset(&surfaceInfo, 0, sizeof(surfaceInfo)); @@ -127,10 +104,4 @@ VkSurfaceKHR QWindowsVulkanInstance::createSurface(HWND win) return surface; } -void QWindowsVulkanInstance::destroySurface(VkSurfaceKHR surface) -{ - if (m_destroySurface && surface) - m_destroySurface(m_vkInst, surface, nullptr); -} - QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsvulkaninstance.h b/src/plugins/platforms/windows/qwindowsvulkaninstance.h index ca60ab7627..3292137c39 100644 --- a/src/plugins/platforms/windows/qwindowsvulkaninstance.h +++ b/src/plugins/platforms/windows/qwindowsvulkaninstance.h @@ -47,28 +47,25 @@ #define VK_USE_PLATFORM_WIN32_KHR #include <QtVulkanSupport/private/qbasicvulkanplatforminstance_p.h> -#include <QLibrary> +#include <QtCore/qlibrary.h> QT_BEGIN_NAMESPACE class QWindowsVulkanInstance : public QBasicPlatformVulkanInstance { + Q_DISABLE_COPY(QWindowsVulkanInstance) public: QWindowsVulkanInstance(QVulkanInstance *instance); - ~QWindowsVulkanInstance(); void createOrAdoptInstance() override; bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) override; VkSurfaceKHR createSurface(HWND win); - void destroySurface(VkSurfaceKHR surface); private: QVulkanInstance *m_instance; - QLibrary m_lib; PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR m_getPhysDevPresSupport; PFN_vkCreateWin32SurfaceKHR m_createSurface; - PFN_vkDestroySurfaceKHR m_destroySurface; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index ca87f1b6a4..f340f16679 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -58,23 +58,25 @@ #else # include "qwindowsopenglcontext.h" #endif +#include "qwindowsopengltester.h" #ifdef QT_NO_CURSOR # include "qwindowscursor.h" #endif -#include <QtGui/QGuiApplication> -#include <QtGui/QScreen> -#include <QtGui/QWindow> -#include <QtGui/QRegion> -#include <QtGui/QOpenGLContext> +#include <QtGui/qguiapplication.h> +#include <QtGui/qscreen.h> +#include <QtGui/qwindow.h> +#include <QtGui/qregion.h> +#include <QtGui/qopenglcontext.h> #include <private/qsystemlibrary_p.h> #include <private/qwindow_p.h> // QWINDOWSIZE_MAX #include <private/qguiapplication_p.h> #include <private/qhighdpiscaling_p.h> #include <qpa/qwindowsysteminterface.h> -#include <QtCore/QDebug> -#include <QtCore/QLibraryInfo> +#include <QtCore/qdebug.h> +#include <QtCore/qlibraryinfo.h> +#include <QtCore/qoperatingsystemversion.h> #include <dwmapi.h> @@ -422,6 +424,31 @@ static inline void updateGLWindowSettings(const QWindow *w, HWND hwnd, Qt::Windo } /*! + Calculates the dimensions of the invisible borders within the + window frames in Windows 10, using an empirical expression that + reproduces the measured values for standard DPI settings. +*/ + +static QMargins invisibleMargins(QPoint screenPoint) +{ + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10) { + POINT pt = {screenPoint.x(), screenPoint.y()}; + if (HMONITOR hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONULL)) { + if (QWindowsContext::shcoredll.isValid()) { + UINT dpiX; + UINT dpiY; + if (SUCCEEDED(QWindowsContext::shcoredll.getDpiForMonitor(hMonitor, 0, &dpiX, &dpiY))) { + const qreal sc = (dpiX - 96) / 96.0; + const int gap = 7 + qRound(5*sc) - int(sc); + return QMargins(gap, 0, gap, gap); + } + } + } + } + return QMargins(); +} + +/*! \class WindowCreationData \brief Window creation code. @@ -515,6 +542,84 @@ static inline void fixTopLevelWindowFlags(Qt::WindowFlags &flags) flags |= Qt::FramelessWindowHint; } +static QScreen *screenForName(const QWindow *w, const QString &name) +{ + QScreen *winScreen = w ? w->screen() : QGuiApplication::primaryScreen(); + if (winScreen && winScreen->name() != name) { + const auto screens = winScreen->virtualSiblings(); + for (QScreen *screen : screens) { + if (screen->name() == name) + return screen; + } + } + return winScreen; +} + +static QScreen *forcedScreenForGLWindow(const QWindow *w) +{ + const QString forceToScreen = GpuDescription::detect().gpuSuitableScreen; + return forceToScreen.isEmpty() ? nullptr : screenForName(w, forceToScreen); +} + +static QPoint calcPosition(const QWindow *w, const QWindowCreationContextPtr &context, const QMargins &invMargins) +{ + const QPoint orgPos(context->frameX - invMargins.left(), context->frameY - invMargins.top()); + + if (!w || (!w->isTopLevel() && w->surfaceType() != QWindow::OpenGLSurface)) + return orgPos; + + // Workaround for QTBUG-50371 + const QScreen *screenForGL = forcedScreenForGLWindow(w); + if (!screenForGL) + return orgPos; + + const QPoint posFrame(context->frameX, context->frameY); + const QMargins margins = context->margins; + const QRect scrGeo = screenForGL->handle()->availableGeometry(); + + // Point is already in the required screen. + if (scrGeo.contains(orgPos)) + return orgPos; + + // If the visible part of the window is already in the + // required screen, just ignore the invisible offset. + if (scrGeo.contains(posFrame)) + return posFrame; + + // Find the original screen containing the coordinates. + const QList<QScreen *> screens = screenForGL->virtualSiblings(); + const QScreen *orgScreen = nullptr; + for (QScreen *screen : screens) { + if (screen->handle()->availableGeometry().contains(posFrame)) { + orgScreen = screen; + break; + } + } + const QPoint ctPos = QPoint(qMax(scrGeo.left(), scrGeo.center().x() + + (margins.right() - margins.left() - context->frameWidth)/2), + qMax(scrGeo.top(), scrGeo.center().y() + + (margins.bottom() - margins.top() - context->frameHeight)/2)); + + // If initial coordinates were outside all screens, center the window on the required screen. + if (!orgScreen) + return ctPos; + + const QRect orgGeo = orgScreen->handle()->availableGeometry(); + const QRect orgFrame(QPoint(context->frameX, context->frameY), + QSize(context->frameWidth, context->frameHeight)); + + // Window would be centered on orgScreen. Center it on the required screen. + if (orgGeo.center() == (orgFrame - margins).center()) + return ctPos; + + // Transform the coordinates to map them into the required screen. + const QPoint newPos(scrGeo.left() + ((posFrame.x() - orgGeo.left()) * scrGeo.width()) / orgGeo.width(), + scrGeo.top() + ((posFrame.y() - orgGeo.top()) * scrGeo.height()) / orgGeo.height()); + const QPoint newPosNoMargin(newPos.x() - invMargins.left(), newPos.y() - invMargins.top()); + + return scrGeo.contains(newPosNoMargin) ? newPosNoMargin : newPos; +} + void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flagsIn, unsigned creationFlags) { @@ -634,7 +739,7 @@ QWindowsWindowData WindowData result; result.flags = flags; - const HINSTANCE appinst = (HINSTANCE)GetModuleHandle(0); + const auto appinst = reinterpret_cast<HINSTANCE>(GetModuleHandle(nullptr)); const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w); @@ -651,16 +756,23 @@ QWindowsWindowData const QWindowCreationContextPtr context(new QWindowCreationContext(w, data.geometry, rect, data.customMargins, style, exStyle)); QWindowsContext::instance()->setWindowCreationContext(context); + QMargins invMargins = topLevel && !(result.flags & Qt::FramelessWindowHint) && QWindowsGeometryHint::positionIncludesFrame(w) + ? invisibleMargins(QPoint(context->frameX, context->frameY)) : QMargins(); + qCDebug(lcQpaWindows).nospace() << "CreateWindowEx: " << w << " class=" << windowClassName << " title=" << title << '\n' << *this << "\nrequested: " << rect << ": " << context->frameWidth << 'x' << context->frameHeight << '+' << context->frameX << '+' << context->frameY - << " custom margins: " << context->customMargins; + << " custom margins: " << context->customMargins + << " invisible margins: " << invMargins; + + + QPoint pos = calcPosition(w, context, invMargins); result.hwnd = CreateWindowEx(exStyle, classNameUtf16, titleUtf16, style, - context->frameX, context->frameY, + pos.x(), pos.y(), context->frameWidth, context->frameHeight, parentHandle, NULL, appinst, NULL); qCDebug(lcQpaWindows).nospace() @@ -673,7 +785,7 @@ QWindowsWindowData } result.geometry = context->obtainedGeometry; - result.frame = context->margins; + result.fullFrameMargins = context->margins; result.embedded = embedded; result.customMargins = context->customMargins; @@ -887,7 +999,7 @@ QRect QWindowsBaseWindow::frameGeometry_sys() const QRect QWindowsBaseWindow::geometry_sys() const { - return frameGeometry_sys().marginsRemoved(frameMargins()); + return frameGeometry_sys().marginsRemoved(fullFrameMargins()); } QMargins QWindowsBaseWindow::frameMargins_sys() const @@ -1344,28 +1456,12 @@ bool QWindowsWindow::isEmbedded() const QPoint QWindowsWindow::mapToGlobal(const QPoint &pos) const { - if (m_data.hwnd) - return QWindowsGeometryHint::mapToGlobal(m_data.hwnd, pos); - else - return pos; + return m_data.hwnd ? QWindowsGeometryHint::mapToGlobal(m_data.hwnd, pos) : pos; } QPoint QWindowsWindow::mapFromGlobal(const QPoint &pos) const { - if (m_data.hwnd) - return QWindowsGeometryHint::mapFromGlobal(m_data.hwnd, pos); - else - return pos; -} - -static inline HWND transientParentHwnd(HWND hwnd) -{ - if (GetAncestor(hwnd, GA_PARENT) == GetDesktopWindow()) { - const HWND rootOwnerHwnd = GetAncestor(hwnd, GA_ROOTOWNER); - if (rootOwnerHwnd != hwnd) // May return itself for toplevels. - return rootOwnerHwnd; - } - return 0; + return m_data.hwnd ? QWindowsGeometryHint::mapFromGlobal(m_data.hwnd, pos) : pos; } // Update the transient parent for a toplevel window. The concept does not @@ -1382,7 +1478,7 @@ void QWindowsWindow::updateTransientParent() const if (window()->type() == Qt::Popup) return; // QTBUG-34503, // a popup stays on top, no parent, see also WindowCreationData::fromWindow(). // Update transient parent. - const HWND oldTransientParent = transientParentHwnd(m_data.hwnd); + const HWND oldTransientParent = GetWindow(m_data.hwnd, GW_OWNER); HWND newTransientParent = 0; if (const QWindow *tp = window()->transientParent()) if (const QWindowsWindow *tw = QWindowsWindow::windowsWindowOf(tp)) @@ -1560,7 +1656,7 @@ QRect QWindowsWindow::normalGeometry() const const bool fakeFullScreen = m_savedFrameGeometry.isValid() && (window()->windowStates() & Qt::WindowFullScreen); const QRect frame = fakeFullScreen ? m_savedFrameGeometry : normalFrameGeometry(m_data.hwnd); - const QMargins margins = fakeFullScreen ? QWindowsGeometryHint::frame(m_savedStyle, 0) : frameMargins(); + const QMargins margins = fakeFullScreen ? QWindowsGeometryHint::frame(m_savedStyle, 0) : fullFrameMargins(); return frame.isValid() ? frame.marginsRemoved(margins) : frame; } @@ -1592,8 +1688,8 @@ void QWindowsWindow::setGeometry(const QRect &rectIn) window()->metaObject()->className(), qPrintable(window()->objectName()), m_data.geometry.width(), m_data.geometry.height(), m_data.geometry.x(), m_data.geometry.y(), - m_data.frame.left(), m_data.frame.top(), - m_data.frame.right(), m_data.frame.bottom(), + m_data.fullFrameMargins.left(), m_data.fullFrameMargins.top(), + m_data.fullFrameMargins.right(), m_data.fullFrameMargins.bottom(), m_data.customMargins.left(), m_data.customMargins.top(), m_data.customMargins.right(), m_data.customMargins.bottom(), window()->minimumWidth(), window()->minimumHeight(), @@ -1685,7 +1781,7 @@ void QWindowsWindow::handleGeometryChange() void QWindowsBaseWindow::setGeometry_sys(const QRect &rect) const { - const QMargins margins = frameMargins(); + const QMargins margins = fullFrameMargins(); const QRect frameGeometry = rect + margins; qCDebug(lcQpaWindows) << '>' << __FUNCTION__ << window() @@ -1856,7 +1952,8 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowStates state) fireExpose(QRegion(0, 0, w->width(), w->height())); exposeEventsSent = true; } - foreach (QWindow *child, QGuiApplication::allWindows()) { + const QWindowList allWindows = QGuiApplication::allWindows(); + for (QWindow *child : allWindows) { if (child != w && child->isVisible() && child->transientParent() == w) { QWindowsWindow *platformWindow = QWindowsWindow::windowsWindowOf(child); if (platformWindow && platformWindow->isLayered()) { @@ -2048,7 +2145,7 @@ void QWindowsWindow::setExStyle(unsigned s) const SetWindowLongPtr(m_data.hwnd, GWL_EXSTYLE, s); } -void QWindowsWindow::windowEvent(QEvent *event) +bool QWindowsWindow::windowEvent(QEvent *event) { switch (event->type()) { case QEvent::WindowBlocked: // Blocked by another modal window. @@ -2064,6 +2161,8 @@ void QWindowsWindow::windowEvent(QEvent *event) default: break; } + + return QPlatformWindow::windowEvent(event); } void QWindowsWindow::propagateSizeHints() @@ -2106,21 +2205,29 @@ bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow * bool QWindowsWindow::handleGeometryChanging(MSG *message) const { - const QMargins margins = window()->isTopLevel() ? frameMargins() : QMargins(); + const QMargins margins = window()->isTopLevel() ? fullFrameMargins() : QMargins(); return QWindowsWindow::handleGeometryChangingMessage(message, window(), margins); } -void QWindowsWindow::setFrameMargins(const QMargins &newMargins) +void QWindowsWindow::setFullFrameMargins(const QMargins &newMargins) { - if (m_data.frame != newMargins) { - qCDebug(lcQpaWindows) << __FUNCTION__ << window() << m_data.frame << "->" << newMargins; - m_data.frame = newMargins; + if (m_data.fullFrameMargins != newMargins) { + qCDebug(lcQpaWindows) << __FUNCTION__ << window() << m_data.fullFrameMargins << "->" << newMargins; + m_data.fullFrameMargins = newMargins; } } QMargins QWindowsWindow::frameMargins() const { - return m_data.frame; + QMargins result = fullFrameMargins(); + if (isTopLevel() && !(m_data.flags & Qt::FramelessWindowHint)) + result -= invisibleMargins(geometry().topLeft()); + return result; +} + +QMargins QWindowsWindow::fullFrameMargins() const +{ + return m_data.fullFrameMargins; } void QWindowsWindow::setOpacity(qreal level) @@ -2174,7 +2281,7 @@ void QWindowsWindow::setMask(const QRegion ®ion) // Mask is in client area coordinates, so offset it in case we have a frame if (window()->isTopLevel()) { - const QMargins margins = frameMargins(); + const QMargins margins = fullFrameMargins(); OffsetRgn(winRegion, margins.left(), margins.top()); } @@ -2309,6 +2416,13 @@ void QWindowsWindow::setFrameStrutEventsEnabled(bool enabled) } } +static int getBorderWidth(const QPlatformScreen *screen) +{ + NONCLIENTMETRICS ncm; + QWindowsContext::nonClientMetricsForScreen(&ncm, screen); + return ncm.iBorderWidth + ncm.iPaddedBorderWidth + 2; +} + void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const { // We don't apply the min/max size hint as we change the dpi, because we did not adjust the @@ -2318,10 +2432,11 @@ void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const hint.applyToMinMaxInfo(m_data.hwnd, mmi); } - if ((testFlag(WithinMaximize) || (window()->windowStates() & Qt::WindowMinimized)) - && (m_data.flags & Qt::FramelessWindowHint)) { - // This block fixes QTBUG-8361: Frameless windows shouldn't cover the - // taskbar when maximized + // This block fixes QTBUG-8361, QTBUG-4362: Frameless/title-less windows shouldn't cover the + // taskbar when maximized + if ((testFlag(WithinMaximize) || window()->windowStates().testFlag(Qt::WindowMinimized)) + && (m_data.flags.testFlag(Qt::FramelessWindowHint) + || (m_data.flags.testFlag(Qt::CustomizeWindowHint) && !m_data.flags.testFlag(Qt::WindowTitleHint)))) { const QScreen *screen = window()->screen(); // Documentation of MINMAXINFO states that it will only work for the primary screen @@ -2335,6 +2450,14 @@ void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const // If you have the taskbar on top, or on the left you don't want it at (0,0): mmi->ptMaxPosition.x = availableGeometry.x(); mmi->ptMaxPosition.y = availableGeometry.y(); + if (!m_data.flags.testFlag(Qt::FramelessWindowHint)) { + const int borderWidth = getBorderWidth(screen->handle()); + mmi->ptMaxSize.x += borderWidth * 2; + mmi->ptMaxSize.y += borderWidth * 2; + mmi->ptMaxTrackSize = mmi->ptMaxSize; + mmi->ptMaxPosition.x -= borderWidth; + mmi->ptMaxPosition.y -= borderWidth; + } } else if (!screen){ qWarning("window()->screen() returned a null screen"); } diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 6d439bce1a..e8c30bd44b 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -41,7 +41,7 @@ #define QWINDOWSWINDOW_H #include <QtCore/qt_windows.h> -#include <QtCore/QPointer> +#include <QtCore/qpointer.h> #include "qwindowscursor.h" #include <qpa/qplatformwindow.h> @@ -59,7 +59,7 @@ class QDebug; struct QWindowsGeometryHint { - QWindowsGeometryHint() {} + QWindowsGeometryHint() = default; explicit QWindowsGeometryHint(const QWindow *w, const QMargins &customMargins); static QMargins frame(DWORD style, DWORD exStyle); static bool handleCalculateSize(const QMargins &customMargins, const MSG &msg, LRESULT *result); @@ -108,8 +108,8 @@ struct QWindowsWindowData { Qt::WindowFlags flags; QRect geometry; - QMargins frame; // Do not use directly for windows, see FrameDirty. - QMargins customMargins; // User-defined, additional frame for NCCALCSIZE + QMargins fullFrameMargins; // Do not use directly for windows, see FrameDirty. + QMargins customMargins; // User-defined, additional frame for NCCALCSIZE HWND hwnd = 0; bool embedded = false; @@ -120,14 +120,16 @@ struct QWindowsWindowData class QWindowsBaseWindow : public QPlatformWindow { + Q_DISABLE_COPY(QWindowsBaseWindow) public: explicit QWindowsBaseWindow(QWindow *window) : QPlatformWindow(window) {} WId winId() const override { return WId(handle()); } QRect geometry() const override { return geometry_sys(); } - QMargins frameMargins() const override { return frameMargins_sys(); } + QMargins frameMargins() const override { return fullFrameMargins(); } QPoint mapToGlobal(const QPoint &pos) const override; QPoint mapFromGlobal(const QPoint &pos) const override; + virtual QMargins fullFrameMargins() const { return frameMargins_sys(); } using QPlatformWindow::screenForGeometry; @@ -222,7 +224,7 @@ public: }; QWindowsWindow(QWindow *window, const QWindowsWindowData &data); - ~QWindowsWindow(); + ~QWindowsWindow() override; void initialize() override; @@ -251,13 +253,14 @@ public: void raise() override { raise_sys(); } void lower() override { lower_sys(); } - void windowEvent(QEvent *event) override; + bool windowEvent(QEvent *event) override; void propagateSizeHints() override; static bool handleGeometryChangingMessage(MSG *message, const QWindow *qWindow, const QMargins &marginsDp); bool handleGeometryChanging(MSG *message) const; QMargins frameMargins() const override; - void setFrameMargins(const QMargins &newMargins); + QMargins fullFrameMargins() const override; + void setFullFrameMargins(const QMargins &newMargins); void setOpacity(qreal level) override; void setMask(const QRegion ®ion) override; @@ -428,7 +431,7 @@ inline QWindowsWindow *QWindowsWindow::windowsWindowOf(const QWindow *w) void *QWindowsWindow::userDataOf(HWND hwnd) { - return (void *)GetWindowLongPtr(hwnd, GWLP_USERDATA); + return reinterpret_cast<void *>(GetWindowLongPtr(hwnd, GWLP_USERDATA)); } void QWindowsWindow::setUserDataOf(HWND hwnd, void *ud) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp index 0f0f42fafe..85a931e015 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp @@ -37,16 +37,16 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiaaccessibility.h" #include "qwindowsuiamainprovider.h" #include "qwindowsuiautils.h" -#include <QtGui/QAccessible> -#include <QtGui/QWindow> -#include <QtGui/QGuiApplication> +#include <QtGui/qaccessible.h> +#include <QtGui/qwindow.h> +#include <QtGui/qguiapplication.h> #include <QtGui/private/qguiapplication_p.h> #include <QtCore/qt_windows.h> #include <qpa/qplatformintegration.h> @@ -104,19 +104,15 @@ void QWindowsUiaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event return; switch (event->type()) { - case QAccessible::Focus: QWindowsUiaMainProvider::notifyFocusChange(event); break; - case QAccessible::StateChanged: QWindowsUiaMainProvider::notifyStateChange(static_cast<QAccessibleStateChangeEvent *>(event)); break; - case QAccessible::ValueChanged: QWindowsUiaMainProvider::notifyValueChange(static_cast<QAccessibleValueChangeEvent *>(event)); break; - case QAccessible::TextAttributeChanged: case QAccessible::TextColumnChanged: case QAccessible::TextInserted: @@ -126,7 +122,6 @@ void QWindowsUiaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event case QAccessible::TextCaretMoved: QWindowsUiaMainProvider::notifyTextChange(event); break; - default: break; } @@ -134,4 +129,4 @@ void QWindowsUiaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.h index bbb81d596b..48b4f9fa6a 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.h @@ -40,15 +40,15 @@ #ifndef QWINDOWSUIAACCESSIBILITY_H #define QWINDOWSUIAACCESSIBILITY_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowscontext.h" #include <qpa/qplatformaccessibility.h> QT_BEGIN_NAMESPACE -// Windows plataform accessibility implemented over UI Automation. +// Windows platform accessibility implemented over UI Automation. class QWindowsUiaAccessibility : public QPlatformAccessibility { public: @@ -60,6 +60,6 @@ public: QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIAACCESSIBILITY_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiabaseprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiabaseprovider.cpp index 1e1fc49c0f..53c647512a 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiabaseprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiabaseprovider.cpp @@ -37,17 +37,15 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiabaseprovider.h" #include "qwindowsuiautils.h" #include "qwindowscontext.h" -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> -#include <QtCore/QDebug> -#include <QtCore/QString> +#include <QtGui/qaccessible.h> +#include <QtCore/qstring.h> QT_BEGIN_NAMESPACE @@ -78,4 +76,4 @@ QAccessible::Id QWindowsUiaBaseProvider::id() const QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiabaseprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiabaseprovider.h index 3ae403e8c5..9caa7d6898 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiabaseprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiabaseprovider.h @@ -40,12 +40,11 @@ #ifndef QWINDOWSUIABASEPROVIDER_H #define QWINDOWSUIABASEPROVIDER_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> -#include <QtCore/QPointer> +#include <QtGui/qaccessible.h> +#include <QtCore/qpointer.h> #include <qwindowscombase.h> #include <QtWindowsUIAutomationSupport/private/qwindowsuiawrapper_p.h> @@ -53,7 +52,6 @@ QT_BEGIN_NAMESPACE class QAccessibleInterface; -class QDebug; // Base class for UI Automation providers. class QWindowsUiaBaseProvider : public QObject @@ -73,6 +71,6 @@ private: QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIABASEPROVIDER_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiagriditemprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiagriditemprovider.cpp index e0502c00f3..93d360c40b 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiagriditemprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiagriditemprovider.cpp @@ -37,18 +37,17 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiagriditemprovider.h" #include "qwindowsuiamainprovider.h" #include "qwindowsuiautils.h" #include "qwindowscontext.h" -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> -#include <QtCore/QDebug> -#include <QtCore/QString> +#include <QtGui/qaccessible.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qstring.h> QT_BEGIN_NAMESPACE @@ -148,7 +147,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaGridItemProvider::get_ColumnSpan(int *pRetV return S_OK; } -// Returns the provider for the cointaining table/tree. +// Returns the provider for the containing table/tree. HRESULT STDMETHODCALLTYPE QWindowsUiaGridItemProvider::get_ContainingGrid(IRawElementProviderSimple **pRetVal) { qCDebug(lcQpaUiAutomation) << __FUNCTION__; @@ -173,4 +172,4 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaGridItemProvider::get_ContainingGrid(IRawEl QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiagriditemprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiagriditemprovider.h index a93b50ef97..3d17056d38 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiagriditemprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiagriditemprovider.h @@ -40,8 +40,8 @@ #ifndef QWINDOWSUIAGRIDITEMPROVIDER_H #define QWINDOWSUIAGRIDITEMPROVIDER_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiabaseprovider.h" @@ -57,15 +57,15 @@ public: virtual ~QWindowsUiaGridItemProvider(); // IGridItemProvider - HRESULT STDMETHODCALLTYPE get_Row(int *pRetVal); - HRESULT STDMETHODCALLTYPE get_Column(int *pRetVal); - HRESULT STDMETHODCALLTYPE get_RowSpan(int *pRetVal); - HRESULT STDMETHODCALLTYPE get_ColumnSpan(int *pRetVal); - HRESULT STDMETHODCALLTYPE get_ContainingGrid(IRawElementProviderSimple **pRetVal); + HRESULT STDMETHODCALLTYPE get_Row(int *pRetVal) override; + HRESULT STDMETHODCALLTYPE get_Column(int *pRetVal) override; + HRESULT STDMETHODCALLTYPE get_RowSpan(int *pRetVal) override; + HRESULT STDMETHODCALLTYPE get_ColumnSpan(int *pRetVal) override; + HRESULT STDMETHODCALLTYPE get_ContainingGrid(IRawElementProviderSimple **pRetVal) override; }; QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIAGRIDITEMPROVIDER_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiagridprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiagridprovider.cpp index 65c2df703b..cce9d8143c 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiagridprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiagridprovider.cpp @@ -37,18 +37,17 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiagridprovider.h" #include "qwindowsuiamainprovider.h" #include "qwindowsuiautils.h" #include "qwindowscontext.h" -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> -#include <QtCore/QDebug> -#include <QtCore/QString> +#include <QtGui/qaccessible.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qstring.h> QT_BEGIN_NAMESPACE @@ -133,4 +132,4 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaGridProvider::get_ColumnCount(int *pRetVal) QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiagridprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiagridprovider.h index 15521f98b3..b96fc1a93c 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiagridprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiagridprovider.h @@ -40,8 +40,8 @@ #ifndef QWINDOWSUIAGRIDPROVIDER_H #define QWINDOWSUIAGRIDPROVIDER_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiabaseprovider.h" @@ -57,13 +57,13 @@ public: virtual ~QWindowsUiaGridProvider(); // IGridProvider - HRESULT STDMETHODCALLTYPE GetItem(int row, int column, IRawElementProviderSimple **pRetVal); - HRESULT STDMETHODCALLTYPE get_RowCount(int *pRetVal); - HRESULT STDMETHODCALLTYPE get_ColumnCount(int *pRetVal); + HRESULT STDMETHODCALLTYPE GetItem(int row, int column, IRawElementProviderSimple **pRetVal) override; + HRESULT STDMETHODCALLTYPE get_RowCount(int *pRetVal) override; + HRESULT STDMETHODCALLTYPE get_ColumnCount(int *pRetVal) override; }; QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIAGRIDPROVIDER_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiainvokeprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiainvokeprovider.cpp index 2af883c4f6..d09770bc81 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiainvokeprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiainvokeprovider.cpp @@ -37,17 +37,16 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiainvokeprovider.h" #include "qwindowsuiautils.h" #include "qwindowscontext.h" -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> -#include <QtCore/QDebug> -#include <QtCore/QString> +#include <QtGui/qaccessible.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qstring.h> QT_BEGIN_NAMESPACE @@ -81,4 +80,4 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaInvokeProvider::Invoke() QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiainvokeprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiainvokeprovider.h index 2b8a646983..5fb509c5f3 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiainvokeprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiainvokeprovider.h @@ -40,8 +40,8 @@ #ifndef QWINDOWSUIAINVOKEPROVIDER_H #define QWINDOWSUIAINVOKEPROVIDER_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiabaseprovider.h" @@ -57,11 +57,11 @@ public: virtual ~QWindowsUiaInvokeProvider(); // IInvokeProvider - HRESULT STDMETHODCALLTYPE Invoke(); + HRESULT STDMETHODCALLTYPE Invoke() override; }; QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIAINVOKEPROVIDER_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index e36006c103..fad83fb165 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -37,8 +37,8 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiamainprovider.h" #include "qwindowsuiavalueprovider.h" @@ -57,10 +57,10 @@ #include "qwindowsuiautils.h" #include "qwindowsuiaprovidercache.h" -#include <QtCore/QDebug> -#include <QtGui/QAccessible> -#include <QtGui/QGuiApplication> -#include <QtGui/QWindow> +#include <QtCore/qloggingcategory.h> +#include <QtGui/qaccessible.h> +#include <QtGui/qguiapplication.h> +#include <QtGui/qwindow.h> #if !defined(Q_CC_BOR) && !defined (Q_CC_GNU) #include <comdef.h> @@ -391,9 +391,8 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR break; case UIA_NamePropertyId: { QString name = accessible->text(QAccessible::Name); - if (name.isEmpty() && clientTopLevel) { + if (name.isEmpty() && clientTopLevel) name = QCoreApplication::applicationName(); - } setVariantString(name, pRetVal); break; } @@ -658,4 +657,4 @@ HRESULT QWindowsUiaMainProvider::GetFocus(IRawElementProviderFragment **pRetVal) QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.h index 893cbf7f8a..325d5b3de4 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.h @@ -40,15 +40,15 @@ #ifndef QWINDOWSUIAMAINPROVIDER_H #define QWINDOWSUIAMAINPROVIDER_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiabaseprovider.h" -#include <QtCore/QPointer> -#include <QtCore/QSharedPointer> +#include <QtCore/qpointer.h> +#include <QtCore/qsharedpointer.h> #include <QtCore/qt_windows.h> -#include <QtGui/QAccessible> +#include <QtGui/qaccessible.h> QT_BEGIN_NAMESPACE @@ -71,27 +71,27 @@ public: static void notifyTextChange(QAccessibleEvent *event); // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, LPVOID *iface); - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, LPVOID *iface) override; + ULONG STDMETHODCALLTYPE AddRef() override; + ULONG STDMETHODCALLTYPE Release() override; // IRawElementProviderSimple methods - HRESULT STDMETHODCALLTYPE get_ProviderOptions(ProviderOptions *pRetVal); - HRESULT STDMETHODCALLTYPE GetPatternProvider(PATTERNID idPattern, IUnknown **pRetVal); - HRESULT STDMETHODCALLTYPE GetPropertyValue(PROPERTYID idProp, VARIANT *pRetVal); - HRESULT STDMETHODCALLTYPE get_HostRawElementProvider(IRawElementProviderSimple **pRetVal); + HRESULT STDMETHODCALLTYPE get_ProviderOptions(ProviderOptions *pRetVal) override; + HRESULT STDMETHODCALLTYPE GetPatternProvider(PATTERNID idPattern, IUnknown **pRetVal) override; + HRESULT STDMETHODCALLTYPE GetPropertyValue(PROPERTYID idProp, VARIANT *pRetVal) override; + HRESULT STDMETHODCALLTYPE get_HostRawElementProvider(IRawElementProviderSimple **pRetVal) override; // IRawElementProviderFragment methods - HRESULT STDMETHODCALLTYPE Navigate(NavigateDirection direction, IRawElementProviderFragment **pRetVal); - HRESULT STDMETHODCALLTYPE GetRuntimeId(SAFEARRAY **pRetVal); - HRESULT STDMETHODCALLTYPE get_BoundingRectangle(UiaRect *pRetVal); - HRESULT STDMETHODCALLTYPE GetEmbeddedFragmentRoots(SAFEARRAY **pRetVal); - HRESULT STDMETHODCALLTYPE SetFocus(); - HRESULT STDMETHODCALLTYPE get_FragmentRoot(IRawElementProviderFragmentRoot **pRetVal); + HRESULT STDMETHODCALLTYPE Navigate(NavigateDirection direction, IRawElementProviderFragment **pRetVal) override; + HRESULT STDMETHODCALLTYPE GetRuntimeId(SAFEARRAY **pRetVal) override; + HRESULT STDMETHODCALLTYPE get_BoundingRectangle(UiaRect *pRetVal) override; + HRESULT STDMETHODCALLTYPE GetEmbeddedFragmentRoots(SAFEARRAY **pRetVal) override; + HRESULT STDMETHODCALLTYPE SetFocus() override; + HRESULT STDMETHODCALLTYPE get_FragmentRoot(IRawElementProviderFragmentRoot **pRetVal) override; // IRawElementProviderFragmentRoot methods - HRESULT STDMETHODCALLTYPE ElementProviderFromPoint(double x, double y, IRawElementProviderFragment **pRetVal); - HRESULT STDMETHODCALLTYPE GetFocus(IRawElementProviderFragment **pRetVal); + HRESULT STDMETHODCALLTYPE ElementProviderFromPoint(double x, double y, IRawElementProviderFragment **pRetVal) override; + HRESULT STDMETHODCALLTYPE GetFocus(IRawElementProviderFragment **pRetVal) override; private: QString automationIdForAccessible(const QAccessibleInterface *accessible); @@ -100,6 +100,6 @@ private: QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIAMAINPROVIDER_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaprovidercache.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaprovidercache.cpp index 9f0a1e126f..c55e827a46 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaprovidercache.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaprovidercache.cpp @@ -37,15 +37,13 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiaprovidercache.h" #include "qwindowsuiautils.h" #include "qwindowscontext.h" -#include <QtCore/QDebug> - QT_BEGIN_NAMESPACE using namespace QWindowsUiAutomation; @@ -66,7 +64,7 @@ QWindowsUiaProviderCache *QWindowsUiaProviderCache::instance() // Returns the provider instance associated with the ID, or nullptr. QWindowsUiaBaseProvider *QWindowsUiaProviderCache::providerForId(QAccessible::Id id) const { - return providerTable.value(id); + return m_providerTable.value(id); } // Inserts a provider in the cache and associates it with an accessibility ID. @@ -74,8 +72,8 @@ void QWindowsUiaProviderCache::insert(QAccessible::Id id, QWindowsUiaBaseProvide { remove(id); if (provider) { - providerTable[id] = provider; - inverseTable[provider] = id; + m_providerTable[id] = provider; + m_inverseTable[provider] = id; // Connects the destroyed signal to our slot, to remove deleted objects from the cache. QObject::connect(provider, &QObject::destroyed, this, &QWindowsUiaProviderCache::objectDestroyed); } @@ -87,20 +85,20 @@ void QWindowsUiaProviderCache::objectDestroyed(QObject *obj) // We have to use the inverse table to map the object address back to its ID, // since at this point (called from QObject destructor), it has already been // partially destroyed and we cannot treat it as a provider. - auto it = inverseTable.find(obj); - if (it != inverseTable.end()) { - providerTable.remove(*it); - inverseTable.remove(obj); + auto it = m_inverseTable.find(obj); + if (it != m_inverseTable.end()) { + m_providerTable.remove(*it); + m_inverseTable.remove(obj); } } // Removes a provider with a given id from the cache. void QWindowsUiaProviderCache::remove(QAccessible::Id id) { - inverseTable.remove(providerTable.value(id)); - providerTable.remove(id); + m_inverseTable.remove(m_providerTable.value(id)); + m_providerTable.remove(id); } QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaprovidercache.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiaprovidercache.h index 7ad30ac39c..f66dc2c170 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaprovidercache.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaprovidercache.h @@ -40,14 +40,13 @@ #ifndef QWINDOWSUIAPROVIDERCACHE_H #define QWINDOWSUIAPROVIDERCACHE_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiabaseprovider.h" -#include <QtCore/QHash> -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> +#include <QtCore/qhash.h> +#include <QtGui/qaccessible.h> QT_BEGIN_NAMESPACE @@ -66,12 +65,12 @@ private Q_SLOTS: void objectDestroyed(QObject *obj); private: - QHash<QAccessible::Id, QWindowsUiaBaseProvider *> providerTable; - QHash<QObject *, QAccessible::Id> inverseTable; + QHash<QAccessible::Id, QWindowsUiaBaseProvider *> m_providerTable; + QHash<QObject *, QAccessible::Id> m_inverseTable; }; QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIAPROVIDERCACHE_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiarangevalueprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiarangevalueprovider.cpp index 0cd09c3f0a..7c1827387a 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiarangevalueprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiarangevalueprovider.cpp @@ -37,17 +37,16 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiarangevalueprovider.h" #include "qwindowsuiautils.h" #include "qwindowscontext.h" -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> -#include <QtCore/QDebug> -#include <QtCore/QString> +#include <QtGui/qaccessible.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qstring.h> QT_BEGIN_NAMESPACE @@ -187,4 +186,4 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaRangeValueProvider::get_SmallChange(double QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiarangevalueprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiarangevalueprovider.h index f742ef99c2..c5e0a03ee5 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiarangevalueprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiarangevalueprovider.h @@ -40,8 +40,8 @@ #ifndef QWINDOWSUIARANGEVALUEPROVIDER_H #define QWINDOWSUIARANGEVALUEPROVIDER_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiabaseprovider.h" @@ -57,17 +57,17 @@ public: virtual ~QWindowsUiaRangeValueProvider(); // IRangeValueProvider - HRESULT STDMETHODCALLTYPE SetValue(double val); - HRESULT STDMETHODCALLTYPE get_Value(double *pRetVal); - HRESULT STDMETHODCALLTYPE get_IsReadOnly(BOOL *pRetVal); - HRESULT STDMETHODCALLTYPE get_Maximum(double *pRetVal); - HRESULT STDMETHODCALLTYPE get_Minimum(double *pRetVal); - HRESULT STDMETHODCALLTYPE get_LargeChange(double *pRetVal); - HRESULT STDMETHODCALLTYPE get_SmallChange(double *pRetVal); + HRESULT STDMETHODCALLTYPE SetValue(double val) override; + HRESULT STDMETHODCALLTYPE get_Value(double *pRetVal) override; + HRESULT STDMETHODCALLTYPE get_IsReadOnly(BOOL *pRetVal) override; + HRESULT STDMETHODCALLTYPE get_Maximum(double *pRetVal) override; + HRESULT STDMETHODCALLTYPE get_Minimum(double *pRetVal) override; + HRESULT STDMETHODCALLTYPE get_LargeChange(double *pRetVal) override; + HRESULT STDMETHODCALLTYPE get_SmallChange(double *pRetVal) override; }; QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIARANGEVALUEPROVIDER_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionitemprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionitemprovider.cpp index 45216a6d1c..a93a05c7bc 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionitemprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionitemprovider.cpp @@ -37,18 +37,17 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiaselectionitemprovider.h" #include "qwindowsuiamainprovider.h" #include "qwindowsuiautils.h" #include "qwindowscontext.h" -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> -#include <QtCore/QDebug> -#include <QtCore/QString> +#include <QtGui/qaccessible.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qstring.h> QT_BEGIN_NAMESPACE @@ -198,4 +197,4 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaSelectionItemProvider::get_SelectionContain QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionitemprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionitemprovider.h index 6a9b5b1e4b..1f2605188b 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionitemprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionitemprovider.h @@ -40,8 +40,8 @@ #ifndef QWINDOWSUIASELECTIONITEMPROVIDER_H #define QWINDOWSUIASELECTIONITEMPROVIDER_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiabaseprovider.h" @@ -57,15 +57,15 @@ public: virtual ~QWindowsUiaSelectionItemProvider(); // ISelectionItemProvider - HRESULT STDMETHODCALLTYPE Select(); - HRESULT STDMETHODCALLTYPE AddToSelection(); - HRESULT STDMETHODCALLTYPE RemoveFromSelection(); - HRESULT STDMETHODCALLTYPE get_IsSelected(BOOL *pRetVal); - HRESULT STDMETHODCALLTYPE get_SelectionContainer(IRawElementProviderSimple **pRetVal); + HRESULT STDMETHODCALLTYPE Select() override; + HRESULT STDMETHODCALLTYPE AddToSelection() override; + HRESULT STDMETHODCALLTYPE RemoveFromSelection() override; + HRESULT STDMETHODCALLTYPE get_IsSelected(BOOL *pRetVal) override; + HRESULT STDMETHODCALLTYPE get_SelectionContainer(IRawElementProviderSimple **pRetVal) override; }; QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIASELECTIONITEMPROVIDER_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp index 1c06503bfc..3305e9c5c4 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp @@ -37,19 +37,18 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiaselectionprovider.h" #include "qwindowsuiamainprovider.h" #include "qwindowsuiautils.h" #include "qwindowscontext.h" -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> -#include <QtCore/QDebug> -#include <QtCore/QString> -#include <QList> +#include <QtGui/qaccessible.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qstring.h> +#include <QtCore/qlist.h> QT_BEGIN_NAMESPACE @@ -144,4 +143,4 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaSelectionProvider::get_IsSelectionRequired( QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.h index 5a07a82ac8..0376d25804 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.h @@ -40,8 +40,8 @@ #ifndef QWINDOWSUIASELECTIONPROVIDER_H #define QWINDOWSUIASELECTIONPROVIDER_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiabaseprovider.h" @@ -57,13 +57,13 @@ public: virtual ~QWindowsUiaSelectionProvider(); // ISelectionProvider - HRESULT STDMETHODCALLTYPE GetSelection(SAFEARRAY **pRetVal); - HRESULT STDMETHODCALLTYPE get_CanSelectMultiple(BOOL *pRetVal); - HRESULT STDMETHODCALLTYPE get_IsSelectionRequired(BOOL *pRetVal); + HRESULT STDMETHODCALLTYPE GetSelection(SAFEARRAY **pRetVal) override; + HRESULT STDMETHODCALLTYPE get_CanSelectMultiple(BOOL *pRetVal) override; + HRESULT STDMETHODCALLTYPE get_IsSelectionRequired(BOOL *pRetVal) override; }; QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIASELECTIONPROVIDER_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp index 3ea29fc86c..2a94012590 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp @@ -37,18 +37,17 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiatableitemprovider.h" #include "qwindowsuiamainprovider.h" #include "qwindowsuiautils.h" #include "qwindowscontext.h" -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> -#include <QtCore/QDebug> -#include <QtCore/QString> +#include <QtGui/qaccessible.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qstring.h> QT_BEGIN_NAMESPACE @@ -126,4 +125,4 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetColumnHeaderItems(SAF QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.h index 277884c980..bf4b52ee0b 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.h @@ -40,8 +40,8 @@ #ifndef QWINDOWSUIATABLEITEMPROVIDER_H #define QWINDOWSUIATABLEITEMPROVIDER_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiabaseprovider.h" @@ -57,12 +57,12 @@ public: virtual ~QWindowsUiaTableItemProvider(); // ITableItemProvider - HRESULT STDMETHODCALLTYPE GetRowHeaderItems(SAFEARRAY **pRetVal); - HRESULT STDMETHODCALLTYPE GetColumnHeaderItems(SAFEARRAY **pRetVal); + HRESULT STDMETHODCALLTYPE GetRowHeaderItems(SAFEARRAY **pRetVal) override; + HRESULT STDMETHODCALLTYPE GetColumnHeaderItems(SAFEARRAY **pRetVal) override; }; QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIATABLEITEMPROVIDER_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableprovider.cpp index f79a24536b..80086f1d4f 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableprovider.cpp @@ -37,18 +37,17 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiatableprovider.h" #include "qwindowsuiamainprovider.h" #include "qwindowsuiautils.h" #include "qwindowscontext.h" -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> -#include <QtCore/QDebug> -#include <QtCore/QString> +#include <QtGui/qaccessible.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qstring.h> QT_BEGIN_NAMESPACE @@ -151,4 +150,4 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaTableProvider::get_RowOrColumnMajor(enum Ro QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableprovider.h index 8cd0acda03..94c8ab93a7 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableprovider.h @@ -40,8 +40,8 @@ #ifndef QWINDOWSUIATABLEPROVIDER_H #define QWINDOWSUIATABLEPROVIDER_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiabaseprovider.h" @@ -57,13 +57,13 @@ public: virtual ~QWindowsUiaTableProvider(); // ITableProvider - HRESULT STDMETHODCALLTYPE GetRowHeaders(SAFEARRAY **pRetVal); - HRESULT STDMETHODCALLTYPE GetColumnHeaders(SAFEARRAY **pRetVal); - HRESULT STDMETHODCALLTYPE get_RowOrColumnMajor(enum RowOrColumnMajor *pRetVal); + HRESULT STDMETHODCALLTYPE GetRowHeaders(SAFEARRAY **pRetVal) override; + HRESULT STDMETHODCALLTYPE GetColumnHeaders(SAFEARRAY **pRetVal) override; + HRESULT STDMETHODCALLTYPE get_RowOrColumnMajor(enum RowOrColumnMajor *pRetVal) override; }; QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIATABLEPROVIDER_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiatextprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiatextprovider.cpp index e1622933af..9d1e72fb78 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiatextprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiatextprovider.cpp @@ -37,17 +37,16 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiatextprovider.h" #include "qwindowsuiautils.h" #include "qwindowscontext.h" -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> -#include <QtCore/QDebug> -#include <QtCore/QString> +#include <QtGui/qaccessible.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qstring.h> QT_BEGIN_NAMESPACE @@ -258,4 +257,4 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaTextProvider::GetCaretRange(BOOL *isActive, QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiatextprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiatextprovider.h index a6d10027fa..a9be70fa16 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiatextprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiatextprovider.h @@ -40,8 +40,8 @@ #ifndef QWINDOWSUIATEXTPROVIDER_H #define QWINDOWSUIATEXTPROVIDER_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiabaseprovider.h" #include "qwindowsuiatextrangeprovider.h" @@ -58,23 +58,23 @@ public: ~QWindowsUiaTextProvider(); // IUnknown overrides - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, LPVOID *iface); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, LPVOID *iface) override; // ITextProvider - HRESULT STDMETHODCALLTYPE GetSelection(SAFEARRAY **pRetVal); - HRESULT STDMETHODCALLTYPE GetVisibleRanges(SAFEARRAY **pRetVal); - HRESULT STDMETHODCALLTYPE RangeFromChild(IRawElementProviderSimple *childElement, ITextRangeProvider **pRetVal); - HRESULT STDMETHODCALLTYPE RangeFromPoint(UiaPoint point, ITextRangeProvider **pRetVal); - HRESULT STDMETHODCALLTYPE get_DocumentRange(ITextRangeProvider **pRetVal); - HRESULT STDMETHODCALLTYPE get_SupportedTextSelection(SupportedTextSelection *pRetVal); + HRESULT STDMETHODCALLTYPE GetSelection(SAFEARRAY **pRetVal) override; + HRESULT STDMETHODCALLTYPE GetVisibleRanges(SAFEARRAY **pRetVal) override; + HRESULT STDMETHODCALLTYPE RangeFromChild(IRawElementProviderSimple *childElement, ITextRangeProvider **pRetVal) override; + HRESULT STDMETHODCALLTYPE RangeFromPoint(UiaPoint point, ITextRangeProvider **pRetVal) override; + HRESULT STDMETHODCALLTYPE get_DocumentRange(ITextRangeProvider **pRetVal) override; + HRESULT STDMETHODCALLTYPE get_SupportedTextSelection(SupportedTextSelection *pRetVal) override; // ITextProvider2 - HRESULT STDMETHODCALLTYPE RangeFromAnnotation(IRawElementProviderSimple *annotationElement, ITextRangeProvider **pRetVal); - HRESULT STDMETHODCALLTYPE GetCaretRange(BOOL *isActive, ITextRangeProvider **pRetVal); + HRESULT STDMETHODCALLTYPE RangeFromAnnotation(IRawElementProviderSimple *annotationElement, ITextRangeProvider **pRetVal) override; + HRESULT STDMETHODCALLTYPE GetCaretRange(BOOL *isActive, ITextRangeProvider **pRetVal) override; }; QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIATEXTPROVIDER_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiatextrangeprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiatextrangeprovider.cpp index dae7cbdd5f..1be186f6b3 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiatextrangeprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiatextrangeprovider.cpp @@ -37,18 +37,17 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiatextrangeprovider.h" #include "qwindowsuiamainprovider.h" #include "qwindowsuiautils.h" #include "qwindowscontext.h" -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> -#include <QtCore/QDebug> -#include <QtCore/QString> +#include <QtGui/qaccessible.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qstring.h> QT_BEGIN_NAMESPACE @@ -238,12 +237,12 @@ HRESULT QWindowsUiaTextRangeProvider::GetBoundingRectangles(SAFEARRAY **pRetVal) int endRange = qMin(end, m_endOffset); if (startRange < endRange) { // Calculates a bounding rectangle for the line and adds it to the list. - QRect startRect = textInterface->characterRect(startRange); - QRect endRect = textInterface->characterRect(endRange - 1); - QRect lineRect(qMin(startRect.x(), endRect.x()), - qMin(startRect.y(), endRect.y()), - qMax(startRect.x() + startRect.width(), endRect.x() + endRect.width()) - qMin(startRect.x(), endRect.x()), - qMax(startRect.y() + startRect.height(), endRect.y() + endRect.height()) - qMin(startRect.y(), endRect.y())); + const QRect startRect = textInterface->characterRect(startRange); + const QRect endRect = textInterface->characterRect(endRange - 1); + const QRect lineRect(qMin(startRect.x(), endRect.x()), + qMin(startRect.y(), endRect.y()), + qMax(startRect.x() + startRect.width(), endRect.x() + endRect.width()) - qMin(startRect.x(), endRect.x()), + qMax(startRect.y() + startRect.height(), endRect.y() + endRect.height()) - qMin(startRect.y(), endRect.y())); rectList.append(lineRect); } if (end >= len) break; @@ -519,9 +518,9 @@ HRESULT QWindowsUiaTextRangeProvider::Select() } // Not supported. -HRESULT QWindowsUiaTextRangeProvider::FindTextW(BSTR /* text */, BOOL /* backward */, - BOOL /* ignoreCase */, - ITextRangeProvider **pRetVal) +HRESULT QWindowsUiaTextRangeProvider::FindText(BSTR /* text */, BOOL /* backward */, + BOOL /* ignoreCase */, + ITextRangeProvider **pRetVal) { if (!pRetVal) return E_INVALIDARG; @@ -551,4 +550,4 @@ HRESULT QWindowsUiaTextRangeProvider::unselect() QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiatextrangeprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiatextrangeprovider.h index 6fe6502c41..39b9069fc0 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiatextrangeprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiatextrangeprovider.h @@ -40,8 +40,8 @@ #ifndef QWINDOWSUIATEXTRANGEPROVIDER_H #define QWINDOWSUIATEXTRANGEPROVIDER_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiabaseprovider.h" @@ -56,24 +56,25 @@ public: explicit QWindowsUiaTextRangeProvider(QAccessible::Id id, int startOffset, int endOffset); virtual ~QWindowsUiaTextRangeProvider(); - HRESULT STDMETHODCALLTYPE AddToSelection(); - HRESULT STDMETHODCALLTYPE Clone(ITextRangeProvider **pRetVal); - HRESULT STDMETHODCALLTYPE Compare(ITextRangeProvider *range, BOOL *pRetVal); - HRESULT STDMETHODCALLTYPE CompareEndpoints(TextPatternRangeEndpoint endpoint, ITextRangeProvider *targetRange, TextPatternRangeEndpoint targetEndpoint, int *pRetVal); - HRESULT STDMETHODCALLTYPE ExpandToEnclosingUnit(TextUnit unit); - HRESULT STDMETHODCALLTYPE FindAttribute(TEXTATTRIBUTEID attributeId, VARIANT val, BOOL backward, ITextRangeProvider **pRetVal); - HRESULT STDMETHODCALLTYPE FindText(BSTR text, BOOL backward, BOOL ignoreCase, ITextRangeProvider **pRetVal); - HRESULT STDMETHODCALLTYPE GetAttributeValue(TEXTATTRIBUTEID attributeId, VARIANT *pRetVal); - HRESULT STDMETHODCALLTYPE GetBoundingRectangles(SAFEARRAY **pRetVal); - HRESULT STDMETHODCALLTYPE GetChildren(SAFEARRAY **pRetVal); - HRESULT STDMETHODCALLTYPE GetEnclosingElement(IRawElementProviderSimple **pRetVal); - HRESULT STDMETHODCALLTYPE GetText(int maxLength, BSTR *pRetVal); - HRESULT STDMETHODCALLTYPE Move(TextUnit unit, int count, int *pRetVal); - HRESULT STDMETHODCALLTYPE MoveEndpointByRange(TextPatternRangeEndpoint endpoint, ITextRangeProvider *targetRange, TextPatternRangeEndpoint targetEndpoint); - HRESULT STDMETHODCALLTYPE MoveEndpointByUnit(TextPatternRangeEndpoint endpoint, TextUnit unit, int count, int *pRetVal); - HRESULT STDMETHODCALLTYPE RemoveFromSelection(); - HRESULT STDMETHODCALLTYPE ScrollIntoView(BOOL alignToTop); - HRESULT STDMETHODCALLTYPE Select(); + // ITextRangeProvider + HRESULT STDMETHODCALLTYPE AddToSelection() override; + HRESULT STDMETHODCALLTYPE Clone(ITextRangeProvider **pRetVal) override; + HRESULT STDMETHODCALLTYPE Compare(ITextRangeProvider *range, BOOL *pRetVal) override; + HRESULT STDMETHODCALLTYPE CompareEndpoints(TextPatternRangeEndpoint endpoint, ITextRangeProvider *targetRange, TextPatternRangeEndpoint targetEndpoint, int *pRetVal) override; + HRESULT STDMETHODCALLTYPE ExpandToEnclosingUnit(TextUnit unit) override; + HRESULT STDMETHODCALLTYPE FindAttribute(TEXTATTRIBUTEID attributeId, VARIANT val, BOOL backward, ITextRangeProvider **pRetVal) override; + HRESULT STDMETHODCALLTYPE FindText(BSTR text, BOOL backward, BOOL ignoreCase, ITextRangeProvider **pRetVal) override; + HRESULT STDMETHODCALLTYPE GetAttributeValue(TEXTATTRIBUTEID attributeId, VARIANT *pRetVal) override; + HRESULT STDMETHODCALLTYPE GetBoundingRectangles(SAFEARRAY **pRetVal) override; + HRESULT STDMETHODCALLTYPE GetChildren(SAFEARRAY **pRetVal) override; + HRESULT STDMETHODCALLTYPE GetEnclosingElement(IRawElementProviderSimple **pRetVal) override; + HRESULT STDMETHODCALLTYPE GetText(int maxLength, BSTR *pRetVal) override; + HRESULT STDMETHODCALLTYPE Move(TextUnit unit, int count, int *pRetVal) override; + HRESULT STDMETHODCALLTYPE MoveEndpointByRange(TextPatternRangeEndpoint endpoint, ITextRangeProvider *targetRange, TextPatternRangeEndpoint targetEndpoint) override; + HRESULT STDMETHODCALLTYPE MoveEndpointByUnit(TextPatternRangeEndpoint endpoint, TextUnit unit, int count, int *pRetVal) override; + HRESULT STDMETHODCALLTYPE RemoveFromSelection() override; + HRESULT STDMETHODCALLTYPE ScrollIntoView(BOOL alignToTop) override; + HRESULT STDMETHODCALLTYPE Select() override; private: HRESULT unselect(); @@ -83,6 +84,6 @@ private: QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIATEXTRANGEPROVIDER_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiatoggleprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiatoggleprovider.cpp index 01cdfd7e91..32445e4ffb 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiatoggleprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiatoggleprovider.cpp @@ -37,17 +37,16 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiatoggleprovider.h" #include "qwindowsuiautils.h" #include "qwindowscontext.h" -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> -#include <QtCore/QDebug> -#include <QtCore/QString> +#include <QtGui/qaccessible.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qstring.h> QT_BEGIN_NAMESPACE @@ -102,4 +101,4 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaToggleProvider::get_ToggleState(ToggleState QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiatoggleprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiatoggleprovider.h index a0df983e40..2bed6f7e36 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiatoggleprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiatoggleprovider.h @@ -40,8 +40,8 @@ #ifndef QWINDOWSUIATOGGLEPROVIDER_H #define QWINDOWSUIATOGGLEPROVIDER_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiabaseprovider.h" @@ -57,12 +57,12 @@ public: virtual ~QWindowsUiaToggleProvider(); // IToggleProvider - HRESULT STDMETHODCALLTYPE Toggle(); - HRESULT STDMETHODCALLTYPE get_ToggleState(ToggleState *pRetVal); + HRESULT STDMETHODCALLTYPE Toggle() override; + HRESULT STDMETHODCALLTYPE get_ToggleState(ToggleState *pRetVal) override; }; QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIATOGGLEPROVIDER_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp index 89e5aad6a6..fbb5c3b9ec 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp @@ -37,14 +37,14 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiautils.h" #include "qwindowscontext.h" #include "qwindowswindow.h" -#include <QtGui/QWindow> +#include <QtGui/qwindow.h> #include <QtGui/private/qhighdpiscaling_p.h> #include <cmath> @@ -232,4 +232,4 @@ bool isTextUnitSeparator(TextUnit unit, const QChar &ch) QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.h index 15f4d6e8ba..6a482f6c1c 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.h @@ -40,16 +40,14 @@ #ifndef QWINDOWSUIAUTILS_H #define QWINDOWSUIAUTILS_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) -#include <QtCore/QString> +#include <QtCore/qstring.h> #include <QtCore/qt_windows.h> -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> -#include <QtGui/QWindow> -#include <QtCore/QDebug> -#include <QtCore/QRect> +#include <QtGui/qaccessible.h> +#include <QtGui/qwindow.h> +#include <QtCore/qrect.h> #include <QtWindowsUIAutomationSupport/private/qwindowsuiawrapper_p.h> QT_BEGIN_NAMESPACE @@ -84,6 +82,6 @@ void setVariantString(const QString &value, VARIANT *variant); QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIAUTILS_H diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiavalueprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiavalueprovider.cpp index ef7d564e22..8651bcff60 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiavalueprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiavalueprovider.cpp @@ -37,17 +37,16 @@ ** ****************************************************************************/ -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiavalueprovider.h" #include "qwindowsuiautils.h" #include "qwindowscontext.h" -#include <QtGui/QAccessible> -#include <QtGui/QAccessibleInterface> -#include <QtCore/QDebug> -#include <QtCore/QString> +#include <QtGui/qaccessible.h> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qstring.h> QT_BEGIN_NAMESPACE @@ -129,4 +128,4 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaValueProvider::get_Value(BSTR *pRetVal) QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiavalueprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiavalueprovider.h index db54fc0a46..334a17e51d 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiavalueprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiavalueprovider.h @@ -40,8 +40,8 @@ #ifndef QWINDOWSUIAVALUEPROVIDER_H #define QWINDOWSUIAVALUEPROVIDER_H -#include <QtCore/QtConfig> -#ifndef QT_NO_ACCESSIBILITY +#include <QtGui/qtguiglobal.h> +#if QT_CONFIG(accessibility) #include "qwindowsuiabaseprovider.h" @@ -58,13 +58,13 @@ public: virtual ~QWindowsUiaValueProvider(); // IValueProvider - HRESULT STDMETHODCALLTYPE SetValue(LPCWSTR val); - HRESULT STDMETHODCALLTYPE get_IsReadOnly(BOOL *pRetVal); - HRESULT STDMETHODCALLTYPE get_Value(BSTR *pRetVal); + HRESULT STDMETHODCALLTYPE SetValue(LPCWSTR val) override; + HRESULT STDMETHODCALLTYPE get_IsReadOnly(BOOL *pRetVal) override; + HRESULT STDMETHODCALLTYPE get_Value(BSTR *pRetVal) override; }; QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #endif // QWINDOWSUIAVALUEPROVIDER_H diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri index f4c396f7c5..db06a6a2a3 100644 --- a/src/plugins/platforms/windows/windows.pri +++ b/src/plugins/platforms/windows/windows.pri @@ -7,9 +7,9 @@ qtConfig(opengl):!qtConfig(opengles2):!qtConfig(dynamicgl): LIBS *= -lopengl32 mingw: LIBS *= -luuid # For the dialog helpers: -LIBS += -lshlwapi -lshell32 -ladvapi32 +LIBS += -lshlwapi -lshell32 -ladvapi32 -lwtsapi32 -DEFINES *= QT_NO_CAST_FROM_ASCII +DEFINES *= QT_NO_CAST_FROM_ASCII QT_NO_FOREACH SOURCES += \ $$PWD/qwindowswindow.cpp \ @@ -18,6 +18,7 @@ SOURCES += \ $$PWD/qwindowsscreen.cpp \ $$PWD/qwindowskeymapper.cpp \ $$PWD/qwindowsmousehandler.cpp \ + $$PWD/qwindowspointerhandler.cpp \ $$PWD/qwindowsole.cpp \ $$PWD/qwindowsdropdataobject.cpp \ $$PWD/qwindowsmime.cpp \ @@ -40,6 +41,7 @@ HEADERS += \ $$PWD/qwindowsscreen.h \ $$PWD/qwindowskeymapper.h \ $$PWD/qwindowsmousehandler.h \ + $$PWD/qwindowspointerhandler.h \ $$PWD/qtwindowsglobal.h \ $$PWD/qwindowsole.h \ $$PWD/qwindowsdropdataobject.h \ |