From 346e268a3d7866575571741c25d022de9b158858 Mon Sep 17 00:00:00 2001 From: Kurt Kartaltepe Date: Mon, 15 Mar 2021 22:47:51 -0700 Subject: [PATCH] UI: Remove x11info dependency This moves X11 platform to the qt private functions, as x11info was removed from Qt6 so this is required for a clean Qt5/6 transition. This is the implementation of x11info::getdisplay so it should still work on older platforms. This "API" doesnt really guarantee anything though. Also clean up wayland only bits as we use them for all windowing systems now, and the name of the native pointer we want is the same on both platforms for now. --- UI/CMakeLists.txt | 20 +++++++------------- UI/obs-app.cpp | 25 ++++++++----------------- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/UI/CMakeLists.txt b/UI/CMakeLists.txt index 4478e2b5c..a734b9e5a 100644 --- a/UI/CMakeLists.txt +++ b/UI/CMakeLists.txt @@ -123,13 +123,17 @@ elseif(APPLE) endif() elseif(UNIX) - find_package(Qt5X11Extras REQUIRED) + find_package(Qt5Gui REQUIRED) + + include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) set(obs_PLATFORM_SOURCES platform-x11.cpp) - set(obs_PLATFORM_LIBRARIES - Qt5::X11Extras) + set(obs_PLATFORM_LIBRARIES + ${obs_PLATFORM_LIBRARIES} + Qt5::Gui + Qt5::GuiPrivate) if("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD") list(APPEND obs_PLATFORM_LIBRARIES @@ -396,16 +400,6 @@ if(WIN32) OUTPUT_NAME "obs${_output_suffix}") endif() -if (ENABLE_WAYLAND) - find_package(Qt5Gui REQUIRED) - include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) - - set(obs_PLATFORM_LIBRARIES - ${obs_PLATFORM_LIBRARIES} - Qt5::Gui - Qt5::GuiPrivate) -endif() - target_link_libraries(obs libobs Qt5::Widgets diff --git a/UI/obs-app.cpp b/UI/obs-app.cpp index 0d8814894..4369c9737 100644 --- a/UI/obs-app.cpp +++ b/UI/obs-app.cpp @@ -61,14 +61,9 @@ #if !defined(_WIN32) && !defined(__APPLE__) #include -#include - -#ifdef ENABLE_WAYLAND #include #endif -#endif - #include #include "ui-config.h" @@ -1398,27 +1393,23 @@ bool OBSApp::OBSInit() #if !defined(_WIN32) && !defined(__APPLE__) obs_set_nix_platform(OBS_NIX_PLATFORM_X11_GLX); - if (QApplication::platformName() == "xcb") { - if (getenv("OBS_USE_EGL")) { - blog(LOG_INFO, "Using EGL/X11"); - obs_set_nix_platform(OBS_NIX_PLATFORM_X11_EGL); - } - obs_set_nix_platform_display(QX11Info::display()); + if (QApplication::platformName() == "xcb" && getenv("OBS_USE_EGL")) { + obs_set_nix_platform(OBS_NIX_PLATFORM_X11_EGL); + blog(LOG_INFO, "Using EGL/X11"); } #ifdef ENABLE_WAYLAND if (QApplication::platformName().contains("wayland")) { obs_set_nix_platform(OBS_NIX_PLATFORM_WAYLAND); - QPlatformNativeInterface *native = - QGuiApplication::platformNativeInterface(); - obs_set_nix_platform_display( - native->nativeResourceForIntegration("display")); - setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); - blog(LOG_INFO, "Platform: Wayland"); } #endif + + QPlatformNativeInterface *native = + QGuiApplication::platformNativeInterface(); + obs_set_nix_platform_display( + native->nativeResourceForIntegration("display")); #endif if (!StartupOBS(locale.c_str(), GetProfilerNameStore()))