From bb0b563a87c23f045b085321b98c3a2aea68b099 Mon Sep 17 00:00:00 2001 From: nerix Date: Mon, 13 Feb 2023 21:45:58 +0100 Subject: [PATCH] Use `qintptr` in `QWidget::nativeEvent` on Qt 6 (#4376) --- CHANGELOG.md | 1 + src/widgets/BaseWindow.cpp | 13 +++++++++++++ src/widgets/BaseWindow.hpp | 16 +++++++++++++--- src/widgets/FramelessEmbedWindow.cpp | 5 +++++ src/widgets/FramelessEmbedWindow.hpp | 7 +++++++ 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62def8459..14e408c9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ - Dev: Disabled ImageExpirationPool in tests. (#4363) - Dev: Don't rely on undocumented registry keys to find the default browser on Windows. (#4362) - Dev: Use `QEnterEvent` for `QWidget::enterEvent` on Qt 6. (#4365) +- Dev: Use `qintptr` in `QWidget::nativeEvent` on Qt 6. (#4376) ## 2.4.0 diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index 2c7da463b..60365081e 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -631,8 +631,13 @@ void BaseWindow::moveIntoDesktopRect(QPoint point) this->move(point); } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, + qintptr *result) +#else bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) +#endif { #ifdef USEWINSDK MSG *msg = reinterpret_cast(message); @@ -830,7 +835,11 @@ bool BaseWindow::handleSHOWWINDOW(MSG *msg) #endif } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool BaseWindow::handleNCCALCSIZE(MSG *msg, qintptr *result) +#else bool BaseWindow::handleNCCALCSIZE(MSG *msg, long *result) +#endif { #ifdef USEWINSDK if (this->hasCustomWindowFrame()) @@ -914,7 +923,11 @@ bool BaseWindow::handleMOVE(MSG *msg) return false; } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool BaseWindow::handleNCHITTEST(MSG *msg, qintptr *result) +#else bool BaseWindow::handleNCHITTEST(MSG *msg, long *result) +#endif { #ifdef USEWINSDK const LONG border_width = 8; // in pixels diff --git a/src/widgets/BaseWindow.hpp b/src/widgets/BaseWindow.hpp index 3f99bc398..106cc1a3e 100644 --- a/src/widgets/BaseWindow.hpp +++ b/src/widgets/BaseWindow.hpp @@ -67,8 +67,13 @@ public: static bool supportsCustomWindowFrame(); protected: - virtual bool nativeEvent(const QByteArray &eventType, void *message, - long *result) override; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool nativeEvent(const QByteArray &eventType, void *message, + qintptr *result) override; +#else + bool nativeEvent(const QByteArray &eventType, void *message, + long *result) override; +#endif virtual void scaleChangedEvent(float) override; virtual void paintEvent(QPaintEvent *) override; @@ -103,10 +108,15 @@ private: bool handleDPICHANGED(MSG *msg); bool handleSHOWWINDOW(MSG *msg); - bool handleNCCALCSIZE(MSG *msg, long *result); bool handleSIZE(MSG *msg); bool handleMOVE(MSG *msg); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool handleNCCALCSIZE(MSG *msg, qintptr *result); + bool handleNCHITTEST(MSG *msg, qintptr *result); +#else + bool handleNCCALCSIZE(MSG *msg, long *result); bool handleNCHITTEST(MSG *msg, long *result); +#endif bool enableCustomFrame_; ActionOnFocusLoss actionOnFocusLoss_ = Nothing; diff --git a/src/widgets/FramelessEmbedWindow.cpp b/src/widgets/FramelessEmbedWindow.cpp index 9633e241d..c710e6e34 100644 --- a/src/widgets/FramelessEmbedWindow.cpp +++ b/src/widgets/FramelessEmbedWindow.cpp @@ -27,8 +27,13 @@ FramelessEmbedWindow::FramelessEmbedWindow() } #ifdef USEWINSDK +# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool FramelessEmbedWindow::nativeEvent(const QByteArray &eventType, + void *message, qintptr *result) +# else bool FramelessEmbedWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) +# endif { MSG *msg = reinterpret_cast(message); diff --git a/src/widgets/FramelessEmbedWindow.hpp b/src/widgets/FramelessEmbedWindow.hpp index 9d371afc6..3c37f07ae 100644 --- a/src/widgets/FramelessEmbedWindow.hpp +++ b/src/widgets/FramelessEmbedWindow.hpp @@ -13,8 +13,15 @@ public: protected: #ifdef USEWINSDK + +# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool nativeEvent(const QByteArray &eventType, void *message, + qintptr *result) override; +# else bool nativeEvent(const QByteArray &eventType, void *message, long *result) override; +# endif + void showEvent(QShowEvent *event) override; #endif