From 8ace192f97075982fcb19aad60ebc2c6a7c6d160 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Mon, 9 Oct 2023 10:18:07 +0100 Subject: [PATCH] main: Default back to SDL_VIDEODRIVER x11 if not exposing wayland Fixes launching native SDL2 apps since the layer work --- src/main.cpp | 9 ++++----- src/main.hpp | 2 ++ src/steamcompmgr.cpp | 6 ++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d30da5b6c8..881299c41e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -528,14 +528,13 @@ static bool CheckWaylandPresentationTime() int g_nPreferredOutputWidth = 0; int g_nPreferredOutputHeight = 0; +bool g_bExposeWayland = false; int main(int argc, char **argv) { // Force disable this horrible broken layer. setenv("DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1", "1", 1); - bool bExposeWayland = false; - static std::string optstring = build_optstring(gamescope_options); gamescope_optstring = optstring.c_str(); @@ -627,7 +626,7 @@ int main(int argc, char **argv) } else if (strcmp(opt_name, "adaptive-sync") == 0) { s_bInitialWantsVRREnabled = true; } else if (strcmp(opt_name, "expose-wayland") == 0) { - bExposeWayland = true; + g_bExposeWayland = true; } else if (strcmp(opt_name, "headless") == 0) { g_bHeadless = true; g_bIsNested = true; @@ -843,7 +842,7 @@ int main(int argc, char **argv) gamescope_xwayland_server_t *base_server = wlserver_get_xwayland_server(0); setenv("DISPLAY", base_server->get_nested_display_name(), 1); - if ( bExposeWayland ) + if ( g_bExposeWayland ) setenv("XDG_SESSION_TYPE", "wayland", 1); else setenv("XDG_SESSION_TYPE", "x11", 1); @@ -863,7 +862,7 @@ int main(int argc, char **argv) setenv("STEAM_GAME_DISPLAY_0", base_server->get_nested_display_name(), 1); } setenv("GAMESCOPE_WAYLAND_DISPLAY", wlserver_get_wl_display_name(), 1); - if ( bExposeWayland ) + if ( g_bExposeWayland ) setenv("WAYLAND_DISPLAY", wlserver_get_wl_display_name(), 1); #if HAVE_PIPEWIRE diff --git a/src/main.hpp b/src/main.hpp index ada921276c..7d8e9f1bee 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -55,6 +55,8 @@ extern bool g_bNiceCap; extern int g_nOldNice; extern int g_nNewNice; +extern bool g_bExposeWayland; + extern bool g_bRt; extern int g_nOldPolicy; extern struct sched_param g_schedOldParam; diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index 1f416e7c8f..c054686289 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp @@ -6482,6 +6482,12 @@ spawn_client( char **argv ) // Enable Gamescope WSI by default for nested. setenv( "ENABLE_GAMESCOPE_WSI", "1", 0 ); + if ( !g_bExposeWayland ) + { + // If we are not running with --expose-wayland + // set SDL_VIDEODRIVER back to x11. + setenv("SDL_VIDEODRIVER", "x11", 0); + } execvp( argv[ 0 ], argv ); xwm_log.errorf_errno( "execvp failed" );