From 8e2b31f53b8a43cd816e37b4abae6d43de941207 Mon Sep 17 00:00:00 2001 From: tytan652 Date: Thu, 1 Aug 2024 15:13:32 +0200 Subject: [PATCH] Set the right Ozone platform on Linux Forcing CEF to use the right Ozone platform allows to avoid having a dependency on XWayland (a X11 socket) under Wayland. --- browser-app.cpp | 3 +++ browser-app.hpp | 10 ++++++++++ obs-browser-plugin.cpp | 10 ++++++++++ 3 files changed, 23 insertions(+) diff --git a/browser-app.cpp b/browser-app.cpp index fb1c3a8a6..af8a3442d 100644 --- a/browser-app.cpp +++ b/browser-app.cpp @@ -96,6 +96,9 @@ void BrowserApp::OnBeforeCommandLineProcessing( "no-user-gesture-required"); #ifdef __APPLE__ command_line->AppendSwitch("use-mock-keychain"); +#elif !defined(_WIN32) + command_line->AppendSwitchWithValue("ozone-platform", + wayland ? "wayland" : "x11"); #endif } diff --git a/browser-app.hpp b/browser-app.hpp index 035f13857..241e233c9 100644 --- a/browser-app.hpp +++ b/browser-app.hpp @@ -77,10 +77,20 @@ class BrowserApp : public CefApp, bool shared_texture_available; CallbackMap callbackMap; int callbackId; +#if !defined(__APPLE__) && !defined(_WIN32) + bool wayland; +#endif public: +#if defined(__APPLE__) || defined(_WIN32) inline BrowserApp(bool shared_texture_available_ = false) : shared_texture_available(shared_texture_available_) +#else + inline BrowserApp(bool shared_texture_available_ = false, + bool wayland_ = false) + : shared_texture_available(shared_texture_available_), + wayland(wayland_) +#endif { } diff --git a/obs-browser-plugin.cpp b/obs-browser-plugin.cpp index 09ff8a37e..0278089b5 100644 --- a/obs-browser-plugin.cpp +++ b/obs-browser-plugin.cpp @@ -46,6 +46,10 @@ #include "signal-restore.hpp" #endif +#ifdef ENABLE_WAYLAND +#include +#endif + #ifdef ENABLE_BROWSER_QT_LOOP #include #include @@ -386,7 +390,13 @@ static void BrowserInit(void) } #endif +#if defined(__APPLE__) || defined(_WIN32) || !defined(ENABLE_WAYLAND) app = new BrowserApp(tex_sharing_avail); +#else + app = new BrowserApp(tex_sharing_avail, + obs_get_nix_platform() == + OBS_NIX_PLATFORM_WAYLAND); +#endif #ifdef _WIN32 CefExecuteProcess(args, app, nullptr);