r300g: support some exotic sampler formats
[mesa.git] / src / glx / dri2.c
index a7a8cb50aa3fa6a9f8337be4fb4f25789317e48d..80c125e741852ac0aca5b943bf74c0488705ed52 100644 (file)
@@ -62,6 +62,8 @@ static Bool
 DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire);
 static Status
 DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire);
+static int
+DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code);
 
 static /* const */ XExtensionHooks dri2ExtensionHooks = {
   NULL,                   /* create_gc */
@@ -73,7 +75,7 @@ static /* const */ XExtensionHooks dri2ExtensionHooks = {
   DRI2CloseDisplay,       /* close_display */
   DRI2WireToEvent,        /* wire_to_event */
   DRI2EventToWire,        /* event_to_wire */
-  NULL,                   /* error */
+  DRI2Error,              /* error */
   NULL,                   /* error_string */
 };
 
@@ -81,15 +83,13 @@ static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay,
                                    dri2Info,
                                    dri2ExtensionName,
                                    &dri2ExtensionHooks,
-                                   DRI2NumberEvents, NULL)
+                                   0, NULL)
 
 static Bool
 DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
 {
    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
    XExtDisplayInfo *glx_info = __glXFindDisplay(dpy);
-   static int glx_event_base;
-   static Bool found_glx_info = False;
 
    XextCheckExtension(dpy, info, dri2ExtensionName, False);
 
@@ -111,7 +111,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;
@@ -162,6 +162,17 @@ DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire)
    return Success;
 }
 
+static int
+DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code)
+{
+    if (err->majorCode == codes->major_opcode &&
+       err->errorCode == BadDrawable &&
+       err->minorCode == X_DRI2CopyRegion)
+       return True;
+
+    return False;
+}
+
 Bool
 DRI2QueryExtension(Display * dpy, int *eventBase, int *errorBase)
 {
@@ -182,6 +193,7 @@ DRI2QueryVersion(Display * dpy, int *major, int *minor)
    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
    xDRI2QueryVersionReply rep;
    xDRI2QueryVersionReq *req;
+   int i, nevents;
 
    XextCheckExtension(dpy, info, dri2ExtensionName, False);
 
@@ -201,6 +213,24 @@ DRI2QueryVersion(Display * dpy, int *major, int *minor)
    UnlockDisplay(dpy);
    SyncHandle();
 
+   switch (rep.minorVersion) {
+   case 1:
+          nevents = 0;
+          break;
+   case 2:
+          nevents = 1;
+          break;
+   case 3:
+   default:
+          nevents = 2;
+          break;
+   }
+       
+   for (i = 0; i < nevents; i++) {
+       XESetWireToEvent (dpy, info->codes->first_event + i, DRI2WireToEvent);
+       XESetEventToWire (dpy, info->codes->first_event + i, DRI2EventToWire);
+   }
+
    return True;
 }