diff --git a/renderdoc/hooks/gl_linux_hooks.cpp b/renderdoc/hooks/gl_linux_hooks.cpp index e77b2275d..04ab1e334 100644 --- a/renderdoc/hooks/gl_linux_hooks.cpp +++ b/renderdoc/hooks/gl_linux_hooks.cpp @@ -39,7 +39,7 @@ namespace glEmulate { void EmulateUnsupportedFunctions(GLHookSet *hooks); } // bit of a hack -namespace Keyboard { extern Display *CurrentXDisplay; } +namespace Keyboard { void CloneDisplay(Display *dpy); } typedef GLXContext (*PFNGLXCREATECONTEXTPROC)(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct); typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display *dpy, GLXContext ctx); @@ -578,7 +578,7 @@ GLXContext glXCreateContext(Display *dpy, XVisualInfo *vis, GLXContext shareList int value = 0; - if(Keyboard::CurrentXDisplay == NULL) Keyboard::CurrentXDisplay = dpy; + Keyboard::CloneDisplay(dpy); OpenGLHook::glhooks.glXGetConfig_real(dpy, vis, GLX_BUFFER_SIZE, &value); init.colorBits = value; OpenGLHook::glhooks.glXGetConfig_real(dpy, vis, GLX_DEPTH_SIZE, &value); init.depthBits = value; @@ -674,7 +674,7 @@ GLXContext glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, GLXConte int value = 0; - if(Keyboard::CurrentXDisplay == NULL) Keyboard::CurrentXDisplay = dpy; + Keyboard::CloneDisplay(dpy); OpenGLHook::glhooks.glXGetConfig_real(dpy, vis, GLX_BUFFER_SIZE, &value); init.colorBits = value; OpenGLHook::glhooks.glXGetConfig_real(dpy, vis, GLX_DEPTH_SIZE, &value); init.depthBits = value; diff --git a/renderdoc/os/linux/linux_stringio.cpp b/renderdoc/os/linux/linux_stringio.cpp index 5ec7c1998..66471a41c 100644 --- a/renderdoc/os/linux/linux_stringio.cpp +++ b/renderdoc/os/linux/linux_stringio.cpp @@ -51,6 +51,13 @@ namespace Keyboard Display *CurrentXDisplay = NULL; + void CloneDisplay(Display *dpy) + { + if(CurrentXDisplay || dpy == NULL) return; + + CurrentXDisplay = XOpenDisplay(XDisplayString(dpy)); + } + void AddInputWindow(void *wnd) { // TODO check against this drawable & parent window being focused in GetKeyState