glxext: Send the Drawable's ID in the GLX_BufferSwapComplete event
authorJasper St. Pierre <jstpierre@mecheye.net>
Tue, 24 Jun 2014 17:43:53 +0000 (13:43 -0400)
committerDave Airlie <airlied@redhat.com>
Thu, 26 Jun 2014 23:44:56 +0000 (09:44 +1000)
While the official INTEL_swap_event specification says that the drawable
field should contain the GLXDrawable, not the Drawable, the existing
DRI2 code in dri2.c that translates from DRI2_BufferSwapComplete sends out
GLX_BufferSwapComplete with the Drawable's ID, so existing codebases
like Clutter/Cogl rely on getting the Drawable.

Match DRI2's error here and stuff the event with the X Drawable, not
the GLX drawable.

This fixes apps seeing wrong drawables through an indirect GLX context
or with DRI3, which uses the GLX_BufferSwapComplete event directly on
the wire instead of translates Present in mesa.

At the same time, also modify the structure for the event to make sure
that clients don't make the same mistake. This is not an API or ABI
break, as GLXDrawable and Drawable are both typedefs for XID.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
Cc: "10.1 10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
include/GL/glx.h
src/glx/glxext.c

index 234abc05025c460b08337158e53e79c639748608..78f5052b23a020dfb3c7ccb3ac0bead71f4e5ce1 100644 (file)
@@ -518,7 +518,7 @@ typedef struct {
     unsigned long serial;      /* # of last request processed by server */
     Bool send_event;           /* true if this came from a SendEvent request */
     Display *display;          /* Display the event was read from */
-    GLXDrawable drawable;      /* drawable on which event was requested in event mask */
+    Drawable drawable; /* drawable on which event was requested in event mask */
     int event_type;
     int64_t ust;
     int64_t msc;
index 94582f6b2e8632dc9ac9148f40762cc00378b64f..68c359e6e2c78d7fedc089610b89682fb5acd788 100644 (file)
@@ -134,14 +134,15 @@ __glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire)
       GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
       xGLXBufferSwapComplete2 *awire = (xGLXBufferSwapComplete2 *)wire;
       struct glx_drawable *glxDraw = GetGLXDrawable(dpy, awire->drawable);
-      aevent->event_type = awire->event_type;
-      aevent->drawable = awire->drawable;
-      aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo;
-      aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
 
       if (!glxDraw)
         return False;
 
+      aevent->event_type = awire->event_type;
+      aevent->drawable = glxDraw->xDrawable;
+      aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo;
+      aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
+
       if (awire->sbc < glxDraw->lastEventSbc)
         glxDraw->eventSbcWrap += 0x100000000;
       glxDraw->lastEventSbc = awire->sbc;