From 29f1d6cd424f8665c958d35e0877f4ea25100321 Mon Sep 17 00:00:00 2001 From: Yvan da Silva Date: Sat, 28 Jul 2018 22:37:48 +0200 Subject: [PATCH] [client] Adds back support for wayland * Since LG is now using SDL2, the SDL_VIDEODRIVER must be set. * This fixes SDL error 'Couldn't find matching GLX visual' when creating the window. --- client/main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/client/main.c b/client/main.c index a28f204e..f2649781 100644 --- a/client/main.c +++ b/client/main.c @@ -732,6 +732,17 @@ int run() state.scaleY = 1.0f; state.fpsSleep = 1000000 / params.fpsLimit; + char* XDG_SESSION_TYPE = getenv("XDG_SESSION_TYPE"); + if (strcmp(XDG_SESSION_TYPE, "wayland") == 0) { + DEBUG_INFO("Wayland detected"); + int err = setenv("SDL_VIDEODRIVER", "wayland", 1); + if (err < 0) { + DEBUG_ERROR("Unable to set the env variable SDL_VIDEODRIVER: %d", errno); + return -1; + } + DEBUG_INFO("SDL_VIDEODRIVER has been set to wayland"); + } + if (SDL_Init(SDL_INIT_VIDEO) < 0) { DEBUG_ERROR("SDL_Init Failed"); @@ -838,6 +849,11 @@ int run() ) ); + if (state.window == NULL) { + DEBUG_ERROR("Could not create an SDL window: %s\n", SDL_GetError()); + return 1; + } + if (params.fullscreen) SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); @@ -868,6 +884,9 @@ int run() 1 ); } + } else { + DEBUG_ERROR("Could not get SDL window information %s", SDL_GetError()); + return -1; } if (!state.window)