Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions base/platform/linux/base_linux_xcb_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include <QtCore/QAbstractNativeEventFilter>
#include <QtGui/QGuiApplication>

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <qpa/qplatformnativeinterface.h>
#endif // Qt < 6.0.0

namespace base::Platform::XCB {
namespace {

Expand Down Expand Up @@ -104,13 +108,21 @@ 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<QX11Application>();
if (!native) {
return nullptr;
}

return native->connection();
#else // Qt >= 6.0.0
const auto native = QGuiApplication::platformNativeInterface();
if (!native) return nullptr;

return reinterpret_cast<xcb_connection_t*>(
native->nativeResourceForIntegration(QByteArray("connection")));
#endif // Qt >= 6.0.0
}

std::optional<xcb_timestamp_t> GetTimestamp() {
Expand Down