vdisp/sdl2: if [WAYLAND_]DISPLAY undef, use KMSDRM

If neither DISPLAY nor WAYLAND_DISPLAY environment variable is defined,
set driver=KMSDRM by default in Linux.
This commit is contained in:
Martin Pulec
2024-09-17 14:37:51 +02:00
parent 0b261533c8
commit 78fa125ff8

View File

@@ -5,7 +5,7 @@
* @author Martin Pulec <pulec@cesnet.cz>
*/
/*
* Copyright (c) 2018-2023 CESNET, z. s. p. o.
* Copyright (c) 2018-2024 CESNET
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -718,6 +718,15 @@ static void *display_sdl2_init(struct module *parent, const char *fmt, unsigned
return NULL;
}
#ifdef __linux__
if (driver == NULL && getenv("DISPLAY") == NULL &&
getenv("WAYLAND_DISPLAY") == NULL) {
MSG(NOTICE, "X11/Wayland doesn't seem to be running (according "
"to env vars). Setting driver=KMSDRM.\n");
driver = "KMSDRM";
}
#endif // defined __linux__
if (SDL_VideoInit(driver) < 0) {
MSG(ERROR, "Unable to initialize SDL2 video: %s\n",
SDL_GetError());