Skip to content

Commit 8ace192

Browse files
committed
main: Default back to SDL_VIDEODRIVER x11 if not exposing wayland
Fixes launching native SDL2 apps since the layer work
1 parent 7ee7002 commit 8ace192

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/main.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,14 +528,13 @@ static bool CheckWaylandPresentationTime()
528528

529529
int g_nPreferredOutputWidth = 0;
530530
int g_nPreferredOutputHeight = 0;
531+
bool g_bExposeWayland = false;
531532

532533
int main(int argc, char **argv)
533534
{
534535
// Force disable this horrible broken layer.
535536
setenv("DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1", "1", 1);
536537

537-
bool bExposeWayland = false;
538-
539538
static std::string optstring = build_optstring(gamescope_options);
540539
gamescope_optstring = optstring.c_str();
541540

@@ -627,7 +626,7 @@ int main(int argc, char **argv)
627626
} else if (strcmp(opt_name, "adaptive-sync") == 0) {
628627
s_bInitialWantsVRREnabled = true;
629628
} else if (strcmp(opt_name, "expose-wayland") == 0) {
630-
bExposeWayland = true;
629+
g_bExposeWayland = true;
631630
} else if (strcmp(opt_name, "headless") == 0) {
632631
g_bHeadless = true;
633632
g_bIsNested = true;
@@ -843,7 +842,7 @@ int main(int argc, char **argv)
843842
gamescope_xwayland_server_t *base_server = wlserver_get_xwayland_server(0);
844843

845844
setenv("DISPLAY", base_server->get_nested_display_name(), 1);
846-
if ( bExposeWayland )
845+
if ( g_bExposeWayland )
847846
setenv("XDG_SESSION_TYPE", "wayland", 1);
848847
else
849848
setenv("XDG_SESSION_TYPE", "x11", 1);
@@ -863,7 +862,7 @@ int main(int argc, char **argv)
863862
setenv("STEAM_GAME_DISPLAY_0", base_server->get_nested_display_name(), 1);
864863
}
865864
setenv("GAMESCOPE_WAYLAND_DISPLAY", wlserver_get_wl_display_name(), 1);
866-
if ( bExposeWayland )
865+
if ( g_bExposeWayland )
867866
setenv("WAYLAND_DISPLAY", wlserver_get_wl_display_name(), 1);
868867

869868
#if HAVE_PIPEWIRE

src/main.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ extern bool g_bNiceCap;
5555
extern int g_nOldNice;
5656
extern int g_nNewNice;
5757

58+
extern bool g_bExposeWayland;
59+
5860
extern bool g_bRt;
5961
extern int g_nOldPolicy;
6062
extern struct sched_param g_schedOldParam;

src/steamcompmgr.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6482,6 +6482,12 @@ spawn_client( char **argv )
64826482

64836483
// Enable Gamescope WSI by default for nested.
64846484
setenv( "ENABLE_GAMESCOPE_WSI", "1", 0 );
6485+
if ( !g_bExposeWayland )
6486+
{
6487+
// If we are not running with --expose-wayland
6488+
// set SDL_VIDEODRIVER back to x11.
6489+
setenv("SDL_VIDEODRIVER", "x11", 0);
6490+
}
64856491
execvp( argv[ 0 ], argv );
64866492

64876493
xwm_log.errorf_errno( "execvp failed" );

0 commit comments

Comments
 (0)