glXGetCurrentDisplay() has been broken for years and nobody noticed until
recently. This change adds a new XMesaGetCurrentDisplay() that the GLX
emulation API can call, just as we did for glXGetCurrentContext().
Tested by hacking glxgears to call glXGetCurrentContext() before and
after glXMakeCurrent() to verify the return value is NULL beforehand and
the same as the opened display afterward.
Also tested by Tom Hudson with his tests programs.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100988
Cc: mesa-stable@lists.freedesktop.org
Tested-by: Tom Hudson <tom.hudson.phd@gmail.com>
Signed-off-by: Brian Paul <brianp@vmware.com>
/*** GLX_VERSION_1_2 ***/
+/* declare here to avoid including xmesa.h */
+extern Display *XMesaGetCurrentDisplay(void);
+
Display PUBLIC *
glXGetCurrentDisplay(void)
{
- /* Same code as in libGL's glxext.c */
- __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
- if (NULL == gc) return NULL;
- return gc->currentDpy;
+ return XMesaGetCurrentDisplay();
}
* work properly.
*/
typedef struct __GLXcontextRec {
- Display *currentDpy;
GLboolean isDirect;
GLXDrawable currentDrawable;
GLXDrawable currentReadable;
}
+Display *XMesaGetCurrentDisplay(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ XMesaContext xmctx = XMESA_CONTEXT(ctx);
+ return xmctx ? xmctx->display : NULL;
+}
+
+
GLboolean XMesaSetFXmode( GLint mode )
{
extern XMesaBuffer XMesaGetCurrentReadBuffer( void );
+/*
+ * Return display of current context.
+ */
+extern Display *XMesaGetCurrentDisplay( void );
+
+
/*
* Swap the front and back buffers for the given buffer. No action is
* taken if the buffer is not double buffered.