From 938e535b385ad6f52afb2e1842d20a5878e80c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Wed, 23 Mar 2011 12:21:45 +0100 Subject: [PATCH] dri2: Invalidate DRI2 buffers for all windows with the same pixmap on swap. Without this, when a compositing manager unredirects a fullscreen window which uses DRI2 and page flipping, the DRI2 buffer information for the compositing manager's output window (typically the Composite Overlay Window or root window) may become stale, resulting in all kinds of hilarity. Also re-generate the real front buffer information every time the client asks for it, or we might return stale cached information. --- hw/xfree86/dri2/dri2.c | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c index d8851f2..c229959 100644 --- a/hw/xfree86/dri2/dri2.c +++ b/hw/xfree86/dri2/dri2.c @@ -339,6 +339,7 @@ allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds, int old_buf = find_attachment(pPriv, attachment); if ((old_buf < 0) + || attachment == DRI2BufferFrontLeft || !dimensions_match || (pPriv->buffers[old_buf]->format != format)) { *buffer = (*ds->CreateBuffer)(pDraw, attachment, format); @@ -814,6 +815,15 @@ DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable) return FALSE; } +static int +DRI2SwapWalk(WindowPtr pWin, pointer data) +{ + if (pWin->drawable.pScreen->GetWindowPixmap(pWin) == data) + DRI2InvalidateDrawable(&pWin->drawable); + + return WT_WALKCHILDREN; +} + int DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc, CARD64 divisor, CARD64 remainder, CARD64 *swap_target, @@ -914,7 +924,14 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc, */ *swap_target = pPriv->swap_count + pPriv->swapsPending; - DRI2InvalidateDrawable(pDraw); + if (pDraw->type == DRAWABLE_WINDOW) { + /* Invalidate DRI2 buffers for all windows with the same window pixmap + * as this one. + */ + WalkTree(pScreen, DRI2SwapWalk, + pScreen->GetWindowPixmap((WindowPtr)pDraw)); + } else + DRI2InvalidateDrawable(pDraw); return Success; } -- 1.7.4.1