From e8c915dacc2a84889d7433081cb8a56af81d096e Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Mon, 9 Oct 2023 11:44:32 -0400 Subject: [PATCH] wayland: Try to skip the Wayland driver if not connecting to or in a Wayland session When initializing the Wayland driver, check if the application is being started in, or trying to connect to, a Wayland session and skip to another driver if not. If neither WAYLAND_DISPLAY nor XDG_SESSION_TYPE are set, try to start anyway, and if the Wayland library is missing or no Wayland sessions are started, initialization will fail later in the process as it previously did. This fixes the case where a Wayland session is running on a different VT, but an application wishes to run via KMSDRM on the current VT. (cherry picked from commit 836927edf8da93ca2d3c8dddf7653113da65ce65) --- src/video/wayland/SDL_waylandvideo.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index 8fd65813a..6f0747ac9 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -173,6 +173,14 @@ static SDL_VideoDevice *Wayland_CreateDevice(void) SDL_VideoData *data; struct wl_display *display; + /* Are we trying to connect to or are currently in a Wayland session? */ + if (!getenv("WAYLAND_DISPLAY")) { + const char *session = getenv("XDG_SESSION_TYPE"); + if (session && SDL_strcasecmp(session, "wayland")) { + return NULL; + } + } + if (!SDL_WAYLAND_LoadSymbols()) { return NULL; }