Skip to content

Commit

Permalink
Use the X11 driver if the application uses X11-based graphics frameworks
Browse files Browse the repository at this point in the history
Fixes #8812
  • Loading branch information
slouken committed Jan 9, 2024
1 parent 2afd04d commit bd2f1e9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/video/SDL_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dlfcn.h>
#endif

/* Available video drivers */
Expand Down Expand Up @@ -468,6 +469,28 @@ int SDL_VideoInit(const char *driver_name)
if (!driver_name) {
driver_name = SDL_GetHint(SDL_HINT_VIDEODRIVER);
}
#ifdef __LINUX__
if (!driver_name) {
/* See if it looks like we need X11 */
SDL_bool force_x11 = SDL_FALSE;
void *global_symbols = dlopen(NULL, RTLD_LOCAL|RTLD_NOW);

/* Use linked libraries to detect what quirks we are likely to need */
if (global_symbols != NULL) {
if (dlsym(global_symbols, "glxewInit") != NULL) { /* GLEW (e.g. Frogatto, SLUDGE) */
force_x11 = SDL_TRUE;
} else if (dlsym(global_symbols, "cgGLEnableProgramProfiles") != NULL) { /* NVIDIA Cg (e.g. Awesomenauts, Braid) */
force_x11 = SDL_TRUE;
} else if (dlsym(global_symbols, "_Z7ssgInitv") != NULL) { /* ::ssgInit(void) in plib (e.g. crrcsim) */
force_x11 = SDL_TRUE;
}
dlclose(global_symbols);
}
if (force_x11) {
driver_name = "x11";

This comment has been minimized.

Copy link
@sezero

sezero Jan 9, 2024

Contributor

This assumes X11 is configured-in already: it need not be.

This comment has been minimized.

Copy link
@slouken

slouken Jan 9, 2024

Author Collaborator

True, fixed in 970ed36

}
}
#endif
if (driver_name && *driver_name != 0) {
const char *driver_attempt = driver_name;
while (driver_attempt && *driver_attempt != 0 && !video) {
Expand Down

0 comments on commit bd2f1e9

Please sign in to comment.