summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-06-10 07:15:49 -0700
committerKeith Packard <keithp@keithp.com>2010-06-10 07:20:03 -0700
commit4172aa137c1b9b6f2a25c320d847af1f5ac56fba (patch)
tree212e36708e36d6471e6cc3792202c3a8821105a4
parent353e32d3712f3a883a796ba562ec9fb5a8354837 (diff)
dri2: Only deal with output windows and pixmaps.
This reverts commit fdb081b430ddffb495aa5b05bcc4cf10882ff4b2 "dri2: Deal with input-only windows by using WindowDrawable()" and replaces it as follows: Reject the creation of a DRI2 drawable for UNDRAWABLE_WINDOW (input-only windows) and DRAWABLE_BUFFER (whatever those are) drawables and only look up privates for the supported drawable types. The rest of the the code can continue pretending there's only output windows and pixmaps, which are the only kinds of drawables relevant for DRI2. Fixes server crash with GLX compositing managers such as compiz or kwin, due to looking up a window private for a pixmap and getting a bogus pointer. Signed-off-by: Michel Dänzer <daenzer@vmware.com> Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--hw/xfree86/dri2/dri2.c15
-rw-r--r--hw/xfree86/dri2/dri2ext.c4
2 files changed, 12 insertions, 7 deletions
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 0687202a9..27d8e2537 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -118,12 +118,15 @@ DRI2GetDrawable(DrawablePtr pDraw)
WindowPtr pWin;
PixmapPtr pPixmap;
- if (WindowDrawable(pDraw->type)) {
+ switch (pDraw->type) {
+ case DRAWABLE_WINDOW:
pWin = (WindowPtr) pDraw;
return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey);
- } else {
+ case DRAWABLE_PIXMAP:
pPixmap = (PixmapPtr) pDraw;
return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey);
+ default:
+ return NULL;
}
}
@@ -161,7 +164,7 @@ DRI2AllocateDrawable(DrawablePtr pDraw)
pPriv->last_swap_ust = 0;
list_init(&pPriv->reference_list);
- if (WindowDrawable(pDraw->type)) {
+ if (pDraw->type == DRAWABLE_WINDOW) {
pWin = (WindowPtr) pDraw;
dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv);
} else {
@@ -272,7 +275,7 @@ static int DRI2DrawableGone(pointer p, XID id)
return Success;
pDraw = pPriv->drawable;
- if (WindowDrawable(pDraw->type)) {
+ if (pDraw->type == DRAWABLE_WINDOW) {
pWin = (WindowPtr) pDraw;
dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL);
} else {
@@ -411,12 +414,12 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
need_real_front--;
front_format = format;
- if (WindowDrawable(pDraw->type)) {
+ if (pDraw->type == DRAWABLE_WINDOW) {
need_fake_front++;
}
}
- if (WindowDrawable(pDraw->type)) {
+ if (pDraw->type == DRAWABLE_WINDOW) {
if (attachment == DRI2BufferFakeFrontLeft) {
need_fake_front--;
have_fake_front = 1;
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index 8016edb3f..4e48e65b2 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -55,7 +55,9 @@ static Bool
validDrawable(ClientPtr client, XID drawable, Mask access_mode,
DrawablePtr *pDrawable, int *status)
{
- *status = dixLookupDrawable(pDrawable, drawable, client, 0, access_mode);
+ *status = dixLookupDrawable(pDrawable, drawable, client,
+ M_DRAWABLE_WINDOW | M_DRAWABLE_PIXMAP,
+ access_mode);
if (*status != Success) {
client->errorValue = drawable;
return FALSE;