Skip to content

Commit

Permalink
Set the right Ozone platform on Linux
Browse files Browse the repository at this point in the history
Forcing CEF to use the right Ozone platform allows to avoid having a
dependency on XWayland (a X11 socket) under Wayland.
  • Loading branch information
tytan652 authored and WizardCM committed Aug 25, 2024
1 parent 98d94a4 commit 8e2b31f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions browser-app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
10 changes: 10 additions & 0 deletions browser-app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
}

Expand Down
10 changes: 10 additions & 0 deletions obs-browser-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
#include "signal-restore.hpp"
#endif

#ifdef ENABLE_WAYLAND
#include <obs-nix-platform.h>
#endif

#ifdef ENABLE_BROWSER_QT_LOOP
#include <QApplication>
#include <QThread>
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 8e2b31f

Please sign in to comment.