frontend: Use public QNativeInterface in Qt 6.5+

Using QNativeInterface allows us to move away from most of
QPlatformNativeInterface usage.
This commit is contained in:
Ryan Foster 2024-06-01 15:50:26 -04:00
commit 840ca8e0d9

View file

@ -26,6 +26,9 @@
#if !defined(_WIN32) && !defined(__APPLE__)
#include <obs-nix-platform.h>
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
#include <qpa/qplatformnativeinterface.h>
#endif
#endif
#include <qt-wrappers.hpp>
@ -38,9 +41,6 @@
#else
#include <QSocketNotifier>
#endif
#if !defined(_WIN32) && !defined(__APPLE__)
#include <qpa/qplatformnativeinterface.h>
#endif
#ifdef _WIN32
#include <sstream>
@ -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<QNativeInterface::QX11Application>();
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<QNativeInterface::QWaylandApplication>();
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);