UI: Force Wayland usage under Wayland session

Qt doesn't use the Wayland platform on GNOME, so we have to
force it using the QT_QPA_PLATFORM env var. It's still possible to
use other QPA platforms using this env var, or the -platform command
line option.

qt5-wayland is now a required dependency for OBS on Linux (or FreeBSD).

Co-authored-by: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
This commit is contained in:
tytan652 2021-08-09 20:44:27 +02:00 committed by Jim
parent fb7a037bc8
commit 47df2467e9

View File

@ -2009,6 +2009,18 @@ static int run_program(fstream &logFile, int argc, char *argv[])
InstallNSApplicationSubclass();
#endif
#if !defined(_WIN32) && !defined(__APPLE__) && defined(USE_XDG) && \
defined(ENABLE_WAYLAND)
/* NOTE: Qt doesn't use the Wayland platform on GNOME, so we have to
* force it using the QT_QPA_PLATFORM env var. It's still possible to
* use other QPA platforms using this env var, or the -platform command
* line option. */
const char *session_type = getenv("XDG_SESSION_TYPE");
if (session_type && strcmp(session_type, "wayland") == 0)
setenv("QT_QPA_PLATFORM", "wayland", false);
#endif
OBSApp program(argc, argv, profilerNameStore.get());
try {
QAccessible::installFactory(accessibleFactory);