main: Default back to SDL_VIDEODRIVER x11 if not exposing wayland

Fixes launching native SDL2 apps since the layer work
This commit is contained in:
Joshua Ashton 2023-10-09 10:18:07 +01:00
parent 7ee7002466
commit 8ace192f97
3 changed files with 12 additions and 5 deletions

View file

@ -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

View file

@ -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;

View file

@ -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" );