Skip to content

Commit

Permalink
x11: add a hint to force the VisualID used when creating a window.
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Sep 4, 2019
1 parent f49c07b commit e5580e1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Empty file modified Android.mk 100644 → 100755
Empty file.
6 changes: 6 additions & 0 deletions include/SDL_hints.h
Expand Up @@ -197,6 +197,12 @@ extern "C" {
*/
#define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR"

/**
* \brief A variable forcing the visual ID chosen for new X11 windows
*
*/
#define SDL_HINT_VIDEO_X11_WINDOW_VISUALID "SDL_VIDEO_X11_WINDOW_VISUALID"

/**
* \brief A variable controlling whether the X11 _NET_WM_PING protocol should be supported.
*
Expand Down
22 changes: 21 additions & 1 deletion src/video/x11/SDL_x11window.c
Expand Up @@ -393,7 +393,27 @@ X11_CreateWindow(_THIS, SDL_Window * window)
long fevent = 0;

#if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_EGL
if ((window->flags & SDL_WINDOW_OPENGL) &&
const char *forced_visual_id = SDL_GetHint(SDL_HINT_VIDEO_X11_WINDOW_VISUALID);

if (forced_visual_id != NULL && forced_visual_id[0] != '\0')
{
XVisualInfo *vi, template;
int nvis;

SDL_zero(template);
template.visualid = SDL_strtol(forced_visual_id, NULL, 0);
vi = X11_XGetVisualInfo(display, VisualIDMask, &template, &nvis);
if (vi) {
visual = vi->visual;
depth = vi->depth;
X11_XFree(vi);
}
else
{
return -1;
}
}
else if ((window->flags & SDL_WINDOW_OPENGL) &&
!SDL_getenv("SDL_VIDEO_X11_VISUALID")) {
XVisualInfo *vinfo = NULL;

Expand Down

0 comments on commit e5580e1

Please sign in to comment.