Fix forcing X11 SDL video driver on XWayland when not built with Wayland

This commit is contained in:
Cameron Gutman
2026-01-27 21:10:52 -06:00
parent c33c49e6fa
commit 402ac59390

View File

@@ -693,14 +693,6 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv); QGuiApplication app(argc, argv);
#ifndef STEAM_LINK
// Force use of the KMSDRM backend for SDL when using Qt platform plugins
// that directly draw to the display without a windowing system.
if (QGuiApplication::platformName() == "eglfs" || QGuiApplication::platformName() == "linuxfb") {
qputenv("SDL_VIDEODRIVER", "kmsdrm");
}
#endif
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
// Register signal handlers to arbitrate between SDL and Qt. // Register signal handlers to arbitrate between SDL and Qt.
// NB: This has to be done after the QGuiApplication is constructed to // NB: This has to be done after the QGuiApplication is constructed to
@@ -774,15 +766,24 @@ int main(int argc, char *argv[])
// After the QGuiApplication is created, the platform stuff will be initialized // After the QGuiApplication is created, the platform stuff will be initialized
// and we can set the SDL video driver to match Qt. // and we can set the SDL video driver to match Qt.
if (WMUtils::isRunningWayland() && QGuiApplication::platformName() == "xcb") { if (QGuiApplication::platformName() == "xcb") {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, if (WMUtils::isRunningWayland()) {
"Detected XWayland. This will probably break hardware decoding! Try running with QT_QPA_PLATFORM=wayland or switch to X11."); SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"Detected XWayland. This will probably break hardware decoding! Try running with QT_QPA_PLATFORM=wayland or switch to X11.");
}
qputenv("SDL_VIDEODRIVER", "x11"); qputenv("SDL_VIDEODRIVER", "x11");
} }
else if (QGuiApplication::platformName().startsWith("wayland")) { else if (QGuiApplication::platformName().startsWith("wayland")) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Detected Wayland"); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Detected Wayland");
qputenv("SDL_VIDEODRIVER", "wayland"); qputenv("SDL_VIDEODRIVER", "wayland");
} }
#ifndef STEAM_LINK
// Force use of the KMSDRM backend for SDL when using Qt platform plugins
// that directly draw to the display without a windowing system.
else if (QGuiApplication::platformName() == "eglfs" || QGuiApplication::platformName() == "linuxfb") {
qputenv("SDL_VIDEODRIVER", "kmsdrm");
}
#endif
#ifdef STEAM_LINK #ifdef STEAM_LINK
// Qt 5.9 from the Steam Link SDK is not able to load any fonts // Qt 5.9 from the Steam Link SDK is not able to load any fonts