Take our own copy of the X connection that we are passed

* We need to copy the X display (by fetching its connection string and
  calling XOpenDisplay), so that if the Display* we had gets closed then
  nothing will crash.
This commit is contained in:
baldurk
2015-02-25 22:26:45 +00:00
parent fae5aabcce
commit 446d7d6da5
2 changed files with 10 additions and 3 deletions
+3 -3
View File
@@ -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;
+7
View File
@@ -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