From 85d746329bcc864176a1bc3801d12f1909f69336 Mon Sep 17 00:00:00 2001 From: Nicholas Guriev Date: Thu, 26 May 2022 15:44:19 +0300 Subject: [PATCH] Get back pre-Qt6 implementation of GetConnectionFromQt() Add branches still needed for Qt5. --- base/platform/linux/base_linux_xcb_utilities.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/base/platform/linux/base_linux_xcb_utilities.cpp b/base/platform/linux/base_linux_xcb_utilities.cpp index dfd40d8d..0f6f9e19 100644 --- a/base/platform/linux/base_linux_xcb_utilities.cpp +++ b/base/platform/linux/base_linux_xcb_utilities.cpp @@ -11,6 +11,10 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#include +#endif // Qt < 6.0.0 + namespace base::Platform::XCB { namespace { @@ -104,6 +108,7 @@ class TimestampGetter : public QAbstractNativeEventFilter { } // namespace xcb_connection_t *GetConnectionFromQt() { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) using namespace QNativeInterface; const auto native = qApp->nativeInterface(); if (!native) { @@ -111,6 +116,13 @@ xcb_connection_t *GetConnectionFromQt() { } return native->connection(); +#else // Qt >= 6.0.0 + const auto native = QGuiApplication::platformNativeInterface(); + if (!native) return nullptr; + + return reinterpret_cast( + native->nativeResourceForIntegration(QByteArray("connection"))); +#endif // Qt >= 6.0.0 } std::optional GetTimestamp() {