Skip to content

Commit

Permalink
main: Default back to SDL_VIDEODRIVER x11 if not exposing wayland
Browse files Browse the repository at this point in the history
Fixes launching native SDL2 apps since the layer work
  • Loading branch information
misyltoad committed Oct 9, 2023
1 parent 7ee7002 commit 8ace192
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down

0 comments on commit 8ace192

Please sign in to comment.