glx: fix GLXChangeDrawableAttributesSGIX request
[mesa.git] / src / glx / dri2.c
index 9ca9b3eb06559c2ab3f16d5a3c4376a5e08d1d7d..adfd3d1f7c8869023fdde46db26fd9a1b45f866e 100644 (file)
@@ -33,7 +33,6 @@
 
 #ifdef GLX_DIRECT_RENDERING
 
-#define NEED_REPLIES
 #include <stdio.h>
 #include <X11/Xlibint.h>
 #include <X11/extensions/Xext.h>
@@ -89,7 +88,6 @@ static Bool
 DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
 {
    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
-   XExtDisplayInfo *glx_info = __glXFindDisplay(dpy);
 
    XextCheckExtension(dpy, info, dri2ExtensionName, False);
 
@@ -100,9 +98,13 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
    {
       GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
       xDRI2BufferSwapComplete *awire = (xDRI2BufferSwapComplete *)wire;
+
+      /* Ignore swap events if we're not looking for them */
+      aevent->type = dri2GetSwapEventType(dpy, awire->drawable);
+      if(!aevent->type)
+         return False;
+
       aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire);
-      aevent->type =
-         (glx_info->codes->first_event + GLX_BufferSwapComplete) & 0x75;
       aevent->send_event = (awire->type & 0x80) != 0;
       aevent->display = dpy;
       aevent->drawable = awire->drawable;
@@ -111,7 +113,7 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
         aevent->event_type = GLX_EXCHANGE_COMPLETE_INTEL;
         break;
       case DRI2_BLIT_COMPLETE:
-        aevent->event_type = GLX_BLIT_COMPLETE_INTEL;
+        aevent->event_type = GLX_COPY_COMPLETE_INTEL;
         break;
       case DRI2_FLIP_COMPLETE:
         aevent->event_type = GLX_FLIP_COMPLETE_INTEL;
@@ -170,6 +172,14 @@ DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code)
        err->minorCode == X_DRI2CopyRegion)
        return True;
 
+    /* If the X drawable was destroyed before the GLX drawable, the
+     * DRI2 drawble will be gone by the time we call
+     * DRI2DestroyDrawable.  So just ignore BadDrawable here. */
+    if (err->majorCode == codes->major_opcode &&
+       err->errorCode == BadDrawable &&
+       err->minorCode == X_DRI2DestroyDrawable)
+       return True;
+
     return False;
 }