From 840ca8e0d9ec235c3088d52caa57a1c058b41907 Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Sat, 1 Jun 2024 15:50:26 -0400 Subject: [PATCH] frontend: Use public QNativeInterface in Qt 6.5+ Using QNativeInterface allows us to move away from most of QPlatformNativeInterface usage. --- frontend/OBSApp.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/frontend/OBSApp.cpp b/frontend/OBSApp.cpp index ac378a17f..8ff91b781 100644 --- a/frontend/OBSApp.cpp +++ b/frontend/OBSApp.cpp @@ -26,6 +26,9 @@ #if !defined(_WIN32) && !defined(__APPLE__) #include +#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) +#include +#endif #endif #include @@ -38,9 +41,6 @@ #else #include #endif -#if !defined(_WIN32) && !defined(__APPLE__) -#include -#endif #ifdef _WIN32 #include @@ -1048,21 +1048,37 @@ bool OBSApp::OBSInit() #if !defined(_WIN32) && !defined(__APPLE__) if (QApplication::platformName() == "xcb") { +#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) + auto native = qGuiApp->nativeInterface(); + + obs_set_nix_platform_display(native->display()); +#endif + obs_set_nix_platform(OBS_NIX_PLATFORM_X11_EGL); + blog(LOG_INFO, "Using EGL/X11"); } #ifdef ENABLE_WAYLAND if (QApplication::platformName().contains("wayland")) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) + auto native = qGuiApp->nativeInterface(); + + obs_set_nix_platform_display(native->display()); +#endif + obs_set_nix_platform(OBS_NIX_PLATFORM_WAYLAND); setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); + blog(LOG_INFO, "Platform: Wayland"); } #endif +#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface(); obs_set_nix_platform_display(native->nativeResourceForIntegration("display")); #endif +#endif #ifdef __APPLE__ setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);