#ifdef GLX_DIRECT_RENDERING
-#define NEED_REPLIES
#include <stdio.h>
#include <X11/Xlibint.h>
#include <X11/extensions/Xext.h>
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 */
DRI2CloseDisplay, /* close_display */
DRI2WireToEvent, /* wire_to_event */
DRI2EventToWire, /* event_to_wire */
- NULL, /* error */
+ DRI2Error, /* error */
NULL, /* error_string */
};
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);
{
GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
xDRI2BufferSwapComplete *awire = (xDRI2BufferSwapComplete *)wire;
+ __GLXDRIdrawable *pdraw;
+ __GLXdisplayPrivate *glx_dpy = __glXInitialize(dpy);
+
+ /* Ignore swap events if we're not looking for them */
+ pdraw = dri2GetGlxDrawableFromXDrawableId(dpy, awire->drawable);
+ if (!(pdraw->eventMask & GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK))
+ return False;
+
aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire);
- aevent->type =
- (glx_info->codes->first_event + GLX_BufferSwapComplete) & 0x75;
+ aevent->type = glx_dpy->codes->first_event + GLX_BufferSwapComplete;
aevent->send_event = (awire->type & 0x80) != 0;
aevent->display = dpy;
aevent->drawable = awire->drawable;
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;
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)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2QueryVersionReply rep;
xDRI2QueryVersionReq *req;
+ int i, nevents;
XextCheckExtension(dpy, info, dri2ExtensionName, False);
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;
}