[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xorg-server: Changes to 'debian-experimental'



 Xi/exevents.c             |    4 
 composite/compalloc.c     |    1 
 configure.ac              |    4 
 dbe/midbe.c               |   20 ++-
 debian/changelog          |    7 -
 dix/devices.c             |    6 -
 dix/resource.c            |   10 +
 exa/exa_classic.c         |    3 
 glx/glxcmds.c             |   23 ++--
 glx/glxdri.c              |    8 -
 glx/glxdri2.c             |   21 +---
 glx/glxdriswrast.c        |    8 -
 glx/glxscreens.h          |    6 -
 hw/xfree86/dri2/dri2.c    |  239 ++++++++++++++++++++++++++++------------------
 hw/xfree86/dri2/dri2.h    |    6 -
 hw/xfree86/dri2/dri2ext.c |   40 -------
 hw/xnest/Cursor.c         |    3 
 include/list.h            |    6 +
 mi/midispcur.c            |   13 +-
 xkb/xkbUtils.c            |    4 
 20 files changed, 243 insertions(+), 189 deletions(-)

New commits:
commit 6b4fcb844d3d76e6982fcb347bedb15596239083
Author: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
Date:   Tue Jun 22 11:47:07 2010 +1000

    Merge in new 1.8.2 RC for the selfish purpose of fixing glXSwapBuffers hang with dual-head

diff --git a/debian/changelog b/debian/changelog
index 62666cd..e8c6058 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,15 +1,18 @@
-xorg-server (2:1.8.1.901-2) UNRELEASED; urgency=low
+xorg-server (2:1.8.1.902-1) UNRELEASED; urgency=low
 
   [ Julien Cristau ]
   * Install the upstream changelog in xserver-common, instead of duplicating
     its 1MB in all other packages.
 
   [ Christopher James Halse Rogers ]
+  * New upstream RC
+    - A number of DRI2 fixes.
+    - Fix for hanging OpenGL clients with multiple heads.
   * 17-fix-DRI2-segfault-when-clientGone.diff:
     - Pick up fix from https://bugs.freedesktop.org/show_bug.cgi?id=27497 to
       fix server crash in DRI2SwapEvent handling (LP: #595182).
 
- -- Christopher James Halse Rogers <raof@ubuntu.com>  Fri, 18 Jun 2010 13:32:45 +1000
+ -- Christopher James Halse Rogers <raof@ubuntu.com>  Tue, 22 Jun 2010 11:45:01 +1000
 
 xorg-server (2:1.8.1.901-1) experimental; urgency=low
 

commit 2ae159bad4178bd0d0b4664b895e085835396ffc
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Jun 21 11:41:22 2010 +1000

    xserver 1.8.1.902
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/configure.ac b/configure.ac
index 73a7b62..01d3d17 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,8 +26,8 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-AC_INIT([xorg-server], 1.8.1.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2010-05-11"
+AC_INIT([xorg-server], 1.8.1.902, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2010-06-21"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE

commit cc9f6806ac0d45e122c24c0e99c1db70a6d5ca12
Author: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
Date:   Sun Jun 13 18:05:26 2010 +0200

    DRI2/xserver: Don't hang in glXSwapBuffers if drawable moves between crtc's (bug 28383)
    
    Detect if a drawable has been moved from an original crtc to a new crtc
    with a lower current vblank count than the original crtc inbetween
    glXSwapBuffers() calls. Reinitialize drawable's last_swap_target
    before scheduling next swap if such a move has taken place.
    
    last_swap_target defines the baseline for scheduling the next swap.
    If a movement between crtc's is not taken into account, the swap may
    schedule for a vblank count on the new crtc far in the future, resulting
    in a apparent "hang" of the drawable for a long time.
    
    Fixes Bugzilla bug #28383.
    
    Signed-off-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
    Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
    Signed-off-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit 75beadd766fed7b12a76e59e57c244e297c2d2cb)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 7d670ff..62734d1 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -614,6 +614,7 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
     DRI2DrawablePtr pPriv;
     DRI2BufferPtr   pDestBuffer = NULL, pSrcBuffer = NULL;
     int             ret, i;
+    CARD64          ust, current_msc;
 
     pPriv = DRI2GetDrawable(pDraw);
     if (pPriv == NULL) {
@@ -658,12 +659,26 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
      * need to schedule a swap for the last swap target + the swap interval.
      */
     if (target_msc == 0 && divisor == 0 && remainder == 0) {
+	/* If the current vblank count of the drawable's crtc is lower
+	 * than the count stored in last_swap_target from a previous swap
+	 * then reinitialize last_swap_target to the current crtc's msc,
+	 * otherwise the swap will hang. This will happen if the drawable
+	 * is moved to a crtc with a lower refresh rate, or a crtc that just
+	 * got enabled.
+	 */
+	if (!(*ds->GetMSC)(pDraw, &ust, &current_msc))
+	    pPriv->last_swap_target = 0;
+
+	if (current_msc < pPriv->last_swap_target)
+	    pPriv->last_swap_target = current_msc;
+
 	/*
 	 * Swap target for this swap is last swap target + swap interval since
 	 * we have to account for the current swap count, interval, and the
 	 * number of pending swaps.
 	 */
 	*swap_target = pPriv->last_swap_target + pPriv->swap_interval;
+
     } else {
 	/* glXSwapBuffersMscOML could have a 0 target_msc, honor it */
 	*swap_target = target_msc;

commit 557301d5c7631e84ad769e6f40a3172a3fdd2369
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Jun 15 13:22:20 2010 +1000

    dix: the default axis mode is Relative, not "0".
    
    Yay for readability.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/dix/devices.c b/dix/devices.c
index 91dd4fd..2226ff2 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1484,7 +1484,7 @@ InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons, Atom* btn_
 
     return(InitButtonClassDeviceStruct(dev, numButtons, btn_labels, map) &&
 	   InitValuatorClassDeviceStruct(dev, numAxes, axes_labels,
-					 numMotionEvents, 0) &&
+					 numMotionEvents, Relative) &&
 	   InitPtrFeedbackClassDeviceStruct(dev, controlProc));
 }
 

commit e50f84d69811baea04ef559d846e4588c4bc4c8e
Author: Éric Piel <E.A.B.Piel@tudelft.nl>
Date:   Fri Jun 11 09:16:32 2010 -0700

    exa: fix ExaCheckCopyNtoN for exa_classic when source = dest
    
    In case you want to copy a region with source = dest, you have the same pixmap
    as source and dest.
    
    At the end of exaPixmapIsOffscreen_classic() the devPrivate.ptr is reset to
    NULL (look at the sources).
    
    Now this is what happens in ExaCheckCopyNtoN:
    
    exaPrepareAccess( pDst );
       Calls IsOffscreen()
          sets devPrivate.ptr to NULL
       sets up devPrivate.ptr to real pointer
       Everything OK
    exaPrepareAccess( pSrc );
       Calls IsOffscreen()
          sets devPrivate.ptr to NULL
       BAILS OUT CAUSE OF NESTED OPERATION SINCE DST EQUALS SRC
    
    We end up with devPrivate.ptr as NULL, and that is clearly wrong.
    
    In particular this fixes a segfault when using the psb driver (bug 28077)
    
    Signed-off-by: Éric Piel <eric.piel@tremplin-utc.net>
    Reviewed-by: Michel Dänzer <michel@daenzer.net>
    Signed-off-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit 7e8f1001217326cc451974bacf25275420c4bb4e)

diff --git a/exa/exa_classic.c b/exa/exa_classic.c
index c31e2d4..9bc369e 100644
--- a/exa/exa_classic.c
+++ b/exa/exa_classic.c
@@ -256,9 +256,10 @@ exaPixmapHasGpuCopy_classic(PixmapPtr pPixmap)
     Bool ret;
 
     if (pExaScr->info->PixmapIsOffscreen) {
+	void* old_ptr = pPixmap->devPrivate.ptr;
 	pPixmap->devPrivate.ptr = ExaGetPixmapAddress(pPixmap);
 	ret = pExaScr->info->PixmapIsOffscreen(pPixmap);
-	pPixmap->devPrivate.ptr = NULL;
+	pPixmap->devPrivate.ptr = old_ptr;
     } else
 	ret = (pExaPixmap->use_gpu_copy && pExaPixmap->fb_ptr);
 

commit 75c1ba8b4fd0cbf5a6eb41fefc4ec728790589df
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Jun 10 12:21:36 2010 +1000

    Xi: don't copy the modifier key count when copying device classes (#25480)
    
    The modifier key count is maintained by the XKB layer and
    increased/decreased for all modifiers that set state.
    
    Test case, MD/SD modifier key count in comment:
    1. keyboard 1: press and hold Shift_L    # SD:1     MD:1
    2. keyboard 2: press and release Shift_L # SD:1,0   MD:1,0
    <class copy happens>                     # SD:1     MD:1
    3. keyboard 1: release Shift_L           # SD:0     MD:1
    4. keyboard 1: press and release Shift_L # SD:1,0   MD:2,1
    
    The modifier is now logically down on the MD but not on keyboard 1 or
    keyboard 2.
    
    XKB is layered in before the DIX, it increases/decreases the modifier key
    count accordingly. In the above example, during (2), the MD gets the key
    release and thus clears the modifier bit. (3) doesn't forward the release to
    the MD because it is already cleared. The copy of modifierKeysDown when the
    lastSlave changes however increases the counter for the held key. On (4),
    the press and release are both forwarded to the MD, causing a offset by 1
    and thus do not clear the logical modifier state.
    
    X.Org Bug 25480 <http://bugs.freedesktop.org/show_bug.cgi?id=25480>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Acked-by: Daniel Stone <daniel@fooishbar.org>
    (cherry picked from commit dc614484f93b67e8b62dbb1bb2fd247fe5a4c850)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index e680f6f..566b0ef 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -196,16 +196,12 @@ void
 CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master)
 {
     KeyClassPtr mk = master->key;
-    KeyClassPtr dk = device->key;
-    int i;
 
     if (device == master)
         return;
 
     mk->sourceid = device->id;
 
-    for (i = 0; i < 8; i++)
-        mk->modifierKeyCount[i] = dk->modifierKeyCount[i];
 
     if (!XkbCopyDeviceKeymap(master, device))
         FatalError("Couldn't pivot keymap from device to core!\n");

commit 421f5dfdd8b566dc07b4606f0edec487b3ead3d9
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Jun 11 11:08:31 2010 +1000

    DRI2: Don't return junk reply instead of blocking in glXWaitForSbcOML()
    
    DRI2WaitSBC() didn't block if requested targetSBC wasn't yet reached.
    
    Instead it returned a xreply with uninitialized junk return values, then
    blocked the connection until targetSBC was reached.
    
    Therefore the client didn't block, but continued with bogus return
    values from glXWaitForSbcOML.
    
    This patch fixes the problem by implementing DRI2WaitSBC similar
    to the clean and proven DRI2WaitMSC implementation.
    
    Signed-off-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
    Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
    Signed-off-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit b3548612c7943011f79a910f9a59bb975984d8a6)
    
    Conflicts:
    
    	hw/xfree86/dri2/dri2ext.c

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 2bdb733..7d670ff 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -768,8 +768,7 @@ DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
 }
 
 int
-DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc,
-	    CARD64 *ust, CARD64 *msc, CARD64 *sbc)
+DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc)
 {
     DRI2DrawablePtr pPriv;
 
@@ -783,14 +782,13 @@ DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc,
     if (target_sbc == 0)
         target_sbc = pPriv->swap_count + pPriv->swapsPending;
 
-    /* If current swap count already >= target_sbc,
+    /* If current swap count already >= target_sbc, reply and
      * return immediately with (ust, msc, sbc) triplet of
      * most recent completed swap.
      */
     if (pPriv->swap_count >= target_sbc) {
-        *sbc = pPriv->swap_count;
-        *msc = pPriv->last_swap_msc;
-        *ust = pPriv->last_swap_ust;
+        ProcDRI2WaitMSCReply(client, pPriv->last_swap_ust,
+                             pPriv->last_swap_msc, pPriv->swap_count);
         return Success;
     }
 
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index ce8a5df..de94c0b 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -251,8 +251,7 @@ extern _X_EXPORT int DRI2WaitMSC(ClientPtr client, DrawablePtr pDrawable,
 extern _X_EXPORT int ProcDRI2WaitMSCReply(ClientPtr client, CARD64 ust,
 					  CARD64 msc, CARD64 sbc);
 extern _X_EXPORT int DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw,
-				 CARD64 target_sbc, CARD64 *ust, CARD64 *msc,
-				 CARD64 *sbc);
+				 CARD64 target_sbc);
 extern _X_EXPORT Bool DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw);
 
 extern _X_EXPORT Bool DRI2CanFlip(DrawablePtr pDraw);
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index 094d54d..627dfc0 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -516,9 +516,8 @@ static int
 ProcDRI2WaitSBC(ClientPtr client)
 {
     REQUEST(xDRI2WaitSBCReq);
-    xDRI2MSCReply rep;
     DrawablePtr pDrawable;
-    CARD64 target, ust, msc, sbc;
+    CARD64 target;
     int status;
 
     REQUEST_SIZE_MATCH(xDRI2WaitSBCReq);
@@ -528,18 +527,9 @@ ProcDRI2WaitSBC(ClientPtr client)
 	return status;
 
     target = vals_to_card64(stuff->target_sbc_lo, stuff->target_sbc_hi);
-    status = DRI2WaitSBC(client, pDrawable, target, &ust, &msc, &sbc);
-    if (status != Success)
-	return status;
+    status = DRI2WaitSBC(client, pDrawable, target);
 
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    load_msc_reply(&rep, ust, msc, sbc);
-
-    WriteToClient(client, sizeof(xDRI2MSCReply), &rep);
-
-    return client->noClientException;
+    return status;
 }
 
 static int

commit f85552aa452d5f575fee9f6031a33ca79bdc3cc8
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Jun 11 10:12:52 2010 +1000

    xkb: fix invalid memory writes in _XkbCopyGeom.
    
    Classic strlen/strcpy mistake of
       foo = malloc(strlen(bar));
       strcpy(foo, bar);
    
    Testcase: valgrind Xephyr :1
    
    ==8591== Invalid write of size 1
    ==8591==    at 0x4A0638F: strcpy (mc_replace_strmem.c:311)
    ==8591==    by 0x605593: _XkbCopyGeom (xkbUtils.c:1994)
    ==8591==    by 0x605973: XkbCopyKeymap (xkbUtils.c:2118)
    ==8591==    by 0x6122B3: InitKeyboardDeviceStruct (xkbInit.c:560)
    ==8591==    by 0x4472E2: CoreKeyboardProc (devices.c:577)
    ==8591==    by 0x447162: ActivateDevice (devices.c:530)
    ==8591==    by 0x4475D6: InitCoreDevices (devices.c:672)
    ==8591==    by 0x4449EE: main (main.c:254)
    ==8591==  Address 0x6f96505 is 0 bytes after a block of size 53 alloc'd
    ==8591==    at 0x4A0515D: malloc (vg_replace_malloc.c:195)
    ==8591==    by 0x6054B7: _XkbCopyGeom (xkbUtils.c:1980)
    ==8591==    by 0x605973: XkbCopyKeymap (xkbUtils.c:2118)
    ==8591==    by 0x6122B3: InitKeyboardDeviceStruct (xkbInit.c:560)
    ==8591==    by 0x4472E2: CoreKeyboardProc (devices.c:577)
    ==8591==    by 0x447162: ActivateDevice (devices.c:530)
    ==8591==    by 0x4475D6: InitCoreDevices (devices.c:672)
    ==8591==    by 0x4449EE: main (main.c:254)
    
    Reported-by: Dave Airlie <airlied@redhat.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by-and-apologised-for: Daniel Stone <daniel@fooishbar.org>
    Signed-off-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit 7f19a7a6e90a4fd7b7ec0256974f62e575218541)
    
    Conflicts:
    
    	xkb/xkbUtils.c

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 6d0901a..b1e0e55 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1977,7 +1977,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
         /* font */
         if (src->geom->label_font) {
             if (!dst->geom->label_font) {
-                tmp = xalloc(strlen(src->geom->label_font));
+                tmp = xalloc(strlen(src->geom->label_font) + 1);
                 if (!tmp)
                     return FALSE;
                 dst->geom->label_font = tmp;
@@ -1985,7 +1985,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
             else if (strlen(src->geom->label_font) !=
                 strlen(dst->geom->label_font)) {
                 tmp = xrealloc(dst->geom->label_font,
-                               strlen(src->geom->label_font));
+                               strlen(src->geom->label_font) + 1);
                 if (!tmp)
                     return FALSE;
                 dst->geom->label_font = tmp;

commit 83460a94985faafcf7cd09456e833f381f0e13bc
Author: Aaron Plattner <aplattner@nvidia.com>
Date:   Fri May 28 09:35:54 2010 -0700

    Fix pixmap validation in miDbePositionWindow.
    
    miDbePositionWindow allocates two pixmaps: a front buffer, and a back buffer.
    If the buffers are supposed to be initialized, it validates a GC against the
    front buffer, then uses it to fill and/or copy both the front buffer *and* the
    back buffer, without revalidating.  If the acceleration architecture needs
    different GC funcs for the two pixmaps -- for example if allocation of the front
    buffer exhausted video memory -- then this can cause crashes because the GC is
    not validated for the back buffer pixmap.
    
    Fix this by performing the rendering for the front buffer first, then
    revalidating against the back buffer before performing the back buffer
    rendering.
    
    Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Jamey Sharp <jamey@minilop.net>
    Signed-off-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit 1304b8b27cb12c803c4f51f04cb6f9d508b82c69)

diff --git a/dbe/midbe.c b/dbe/midbe.c
index 4426c9d..bdea358 100644
--- a/dbe/midbe.c
+++ b/dbe/midbe.c
@@ -695,25 +695,33 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
 
 
         pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
-        ValidateGC((DrawablePtr)pFrontBuffer, pGC);
 
 	/* I suppose this could avoid quite a bit of work if
 	 * it computed the minimal area required.
 	 */
+	ValidateGC(&pFrontBuffer->drawable, pGC);
 	if (clear)
         {
 	    (*pGC->ops->PolyFillRect)((DrawablePtr)pFrontBuffer, pGC, 1,
 				      &clearRect);
-	    (*pGC->ops->PolyFillRect)((DrawablePtr)pBackBuffer , pGC, 1,
-				      &clearRect);
-        }
-
-        /* Copy the contents of the old DBE pixmaps to the new pixmaps. */
+	}
+	/* Copy the contents of the old front pixmap to the new one. */
 	if (pWin->bitGravity != ForgetGravity)
 	{
 	    (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer,
                                   (DrawablePtr)pFrontBuffer, pGC, sourcex,
                                   sourcey, savewidth, saveheight, destx, desty);
+        }
+
+	ValidateGC(&pBackBuffer->drawable, pGC);
+	if (clear)
+	{
+	    (*pGC->ops->PolyFillRect)((DrawablePtr)pBackBuffer , pGC, 1,
+				      &clearRect);
+	}
+	/* Copy the contents of the old back pixmap to the new one. */
+	if (pWin->bitGravity != ForgetGravity)
+	{
 	    (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer,
                                   (DrawablePtr)pBackBuffer, pGC, sourcex,
                                   sourcey, savewidth, saveheight, destx, desty);

commit 14dc68c2655ea033d102ebfc2cb6a368fc0c330f
Author: Dave Airlie <airlied@redhat.com>
Date:   Thu Jun 3 12:16:40 2010 +1000

    composite: initialise pOldPixmap to NullPixmap at alloc time.
    
    We just never initialised the malloced value.
    
    Signed-off-by: Dave Airlie <airlied@redhat.com>
    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit 91a6359caf24d94343ff76f43ea7b7fc3223203d)

diff --git a/composite/compalloc.c b/composite/compalloc.c
index 73adc72..8a6beb9 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -143,6 +143,7 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
 	cw->oldy = COMP_ORIGIN_INVALID;
 	cw->damageRegistered = FALSE;
 	cw->damaged = FALSE;
+	cw->pOldPixmap = NullPixmap;
 	dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, cw);
     }
     ccw->next = cw->clients;

commit 1f6de991d0b44bf1412dc58067fae551f6aac5d1
Author: Nicolas George <nicolas.george@normalesup.org>
Date:   Wed Jun 2 13:40:51 2010 +0200

    Change keyboard controls on slave keyboards (#27926)
    
    Makes the use of IsMaster in ProcChangeKeyboardControl consistent with other
    similar loops.
    
    Signed-off-by: Nicolas George <nicolas.george@normalesup.org>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 968a79dcf5e17ac3963953ef56b8f94dbd75323b)

diff --git a/dix/devices.c b/dix/devices.c
index b55df16..91dd4fd 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1956,7 +1956,7 @@ ProcChangeKeyboardControl (ClientPtr client)
     keyboard = PickKeyboard(client);
 
     for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
-        if ((pDev == keyboard || (!IsMaster(keyboard) && pDev->u.master == keyboard)) &&
+        if ((pDev == keyboard || (!IsMaster(pDev) && pDev->u.master == keyboard)) &&
             pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
             ret = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess);
 	    if (ret != Success)
@@ -1965,7 +1965,7 @@ ProcChangeKeyboardControl (ClientPtr client)
     }
 
     for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
-        if ((pDev == keyboard || (!IsMaster(keyboard) && pDev->u.master == keyboard)) &&
+        if ((pDev == keyboard || (!IsMaster(pDev) && pDev->u.master == keyboard)) &&
             pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
             ret = DoChangeKeyboardControl(client, pDev, vlist, vmask);
             if (ret != Success)

commit b1e338df929bc7ef68524e66d5ff8d85af84b0e6
Author: Jamey Sharp <jamey@minilop.net>
Date:   Mon May 24 09:15:32 2010 -0700

    midispcur: Construct Picture objects lazily in case Render is disabled.
    
    Reverts part of the effects of 518f3b189b6c8aa28b62837d14309fd06163ccbb,
    "mi: don't thrash resources when displaying the software cursor across
    screens". The per-screen cache is preserved, and the GCs are still
    allocated eagerly, but now it doesn't construct pRootPicture until
    somebody attempts to draw an ARGB cursor.
    
    I noticed crashes in Xnest, which doesn't support the RENDER extension,
    but I suspect other DDXes that support disabling that extension would
    have had issues as well.
    
    Signed-off-by: Jamey Sharp <jamey@minilop.net>
    Reviewed-by: Pierre-Loup A. Griffais <pgriffais@nvidia.com>
    (cherry picked from commit bf78e11839f8278020b604672ff7c3d194232be9)

diff --git a/mi/midispcur.c b/mi/midispcur.c
index 54a6787..1d24919 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -179,6 +179,7 @@ miDCRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
 }
 
 #ifdef ARGB_CURSOR
+#define EnsurePicture(picture,draw,win) (picture || miDCMakePicture(&picture,draw,win))
 
 static VisualPtr
 miDCGetWindowVisual (WindowPtr pWin)
@@ -451,6 +452,8 @@ miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
 #ifdef ARGB_CURSOR
     if (pPriv->pPicture)
     {
+	if (!EnsurePicture(pBuffer->pRootPicture, &pWin->drawable, pWin))
+	    return FALSE;
 	CompositePicture (PictOpOver,
 			  pPriv->pPicture,
 			  NULL,
@@ -733,9 +736,8 @@ miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
 #ifdef ARGB_CURSOR
     if (pPriv->pPicture)
     {
-	if (!pBuffer->pTempPicture)
-            miDCMakePicture(&pBuffer->pTempPicture, &pTemp->drawable, pWin);
-
+	if (!EnsurePicture(pBuffer->pTempPicture, &pTemp->drawable, pWin))
+	    return FALSE;
 	CompositePicture (PictOpOver,
 			  pPriv->pPicture,
 			  NULL,
@@ -819,10 +821,7 @@ miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
             goto failure;
 
 #ifdef ARGB_CURSOR
-        miDCMakePicture(&pBuffer->pRootPicture, &pWin->drawable, pWin);
-        if (!pBuffer->pRootPicture)
-            goto failure;
-
+        pBuffer->pRootPicture = NULL;
         pBuffer->pTempPicture = NULL;
 #endif
 

commit 3ad3592820a8beeb724575fb7ae7f3e2f3560030
Author: Jamey Sharp <jamey@minilop.net>
Date:   Mon May 24 09:14:27 2010 -0700

    xnest: Don't ignore errors from DeviceCursorInitialize.
    
    Signed-off-by: Jamey Sharp <jamey@minilop.net>
    Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
    (cherry picked from commit bf9b64eefbadbf299d3b841c1890bfcaef5aab1b)

diff --git a/hw/xnest/Cursor.c b/hw/xnest/Cursor.c
index 12f47e7..d9f5dd6 100644
--- a/hw/xnest/Cursor.c
+++ b/hw/xnest/Cursor.c
@@ -167,8 +167,7 @@ xnestDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
     pScreenPriv = (xnestCursorFuncPtr)
             dixLookupPrivate(&pScreen->devPrivates, xnestCursorScreenKey);
 
-    pScreenPriv->spriteFuncs->DeviceCursorInitialize(pDev, pScreen);
-    return TRUE;
+    return pScreenPriv->spriteFuncs->DeviceCursorInitialize(pDev, pScreen);
 }
 
 void

commit 598603021f6c4fa64161366177e93de67511bc2e
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Jun 2 11:13:17 2010 +1000

    dri2: Take an XID for tracking the DRI2 drawable
    
    Some pixmaps (window pixmaps and scratch pixmaps) don't have the
    drawable->id set and thus DRI2 gets confused when using that field
    for looking up the DRI2 drawable.  Go back to using privates for getting
    at the DRI2 drawable from a DrawablePtr.  We need to keep the resource
    tracking in place so we can remove the DRI2 drawable when the X resource
    it was created for goes away.  Additionally, we also now track the DRI2
    drawable using a client XID so we can reclaim the DRI2 drawable even if
    the client goes before the drawable and doesn't destroy the DRI2 drawable.
    
    Tested-by: Owen W. Taylor <otaylor@fishsoup.net>
    Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
    (cherry picked from commit 9de0e31746d5f0d9d39d11c94ec3cbc04a9935fc)
    
    Conflicts:
    
    	hw/xfree86/dri2/dri2.c

diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index 087d52e..ec3bbe6 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -512,8 +512,9 @@ __glXGetDrawable(__GLXcontext *glxc, GLXDrawable drawId, ClientPtr client,
     if (!validGlxFBConfigForWindow(client, glxc->config, pDraw, error))
 	return NULL;
 
-    pGlxDraw = glxc->pGlxScreen->createDrawable(glxc->pGlxScreen,
-						pDraw, GLX_DRAWABLE_WINDOW,
+    pGlxDraw = glxc->pGlxScreen->createDrawable(client, glxc->pGlxScreen,
+						pDraw, drawId,
+						GLX_DRAWABLE_WINDOW,
 						drawId, glxc->config);
 
     /* since we are creating the drawablePrivate, drawId should be new */
@@ -1104,15 +1105,17 @@ __glXDrawableRelease(__GLXdrawable *drawable)
 }
 
 static int 
-DoCreateGLXDrawable(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *config,
-		    DrawablePtr pDraw, XID glxDrawableId, int type)
+DoCreateGLXDrawable(ClientPtr client, __GLXscreen *pGlxScreen,
+		    __GLXconfig *config, DrawablePtr pDraw, XID drawableId,
+		    XID glxDrawableId, int type)
 {
     __GLXdrawable *pGlxDraw;
 
     if (pGlxScreen->pScreen != pDraw->pScreen)
 	return BadMatch;
 
-    pGlxDraw = pGlxScreen->createDrawable(pGlxScreen, pDraw, type,
+    pGlxDraw = pGlxScreen->createDrawable(client, pGlxScreen, pDraw,
+					  drawableId, type,
 					  glxDrawableId, config);
     if (pGlxDraw == NULL)
 	return BadAlloc;
@@ -1125,7 +1128,7 @@ DoCreateGLXDrawable(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *conf
     /* Add the glx drawable under the XID of the underlying X drawable
      * too.  That way we'll get a callback in DrawableGone and can
      * clean up properly when the drawable is destroyed. */
-    if (pDraw->id != glxDrawableId &&
+    if (drawableId != glxDrawableId &&
 	!AddResource(pDraw->id, __glXDrawableRes, pGlxDraw)) {
 	pGlxDraw->destroy (pGlxDraw);
 	return BadAlloc;
@@ -1153,7 +1156,7 @@ DoCreateGLXPixmap(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *config
 	return BadPixmap;
     }
 
-    err = DoCreateGLXDrawable(client, pGlxScreen, config, pDraw,
+    err = DoCreateGLXDrawable(client, pGlxScreen, config, pDraw, drawableId,
 			      glxDrawableId, GLX_DRAWABLE_PIXMAP);
 
     return err;
@@ -1316,7 +1319,8 @@ DoCreatePbuffer(ClientPtr client, int screenNum, XID fbconfigId,
 	return BadAlloc;
 
     return DoCreateGLXDrawable(client, pGlxScreen, config, &pPixmap->drawable,
-			       glxDrawableId, GLX_DRAWABLE_PBUFFER);
+			       glxDrawableId, glxDrawableId,
+			       GLX_DRAWABLE_PBUFFER);
 }
 
 int __glXDisp_CreatePbuffer(__GLXclientState *cl, GLbyte *pc)
@@ -1439,7 +1443,8 @@ int __glXDisp_CreateWindow(__GLXclientState *cl, GLbyte *pc)
 	return err;
 
     return DoCreateGLXDrawable(client, pGlxScreen, config,
-			       pDraw, req->glxwindow, GLX_DRAWABLE_WINDOW);
+			       pDraw, req->window,
+			       req->glxwindow, GLX_DRAWABLE_WINDOW);
 }
 
 int __glXDisp_DestroyWindow(__GLXclientState *cl, GLbyte *pc)
diff --git a/glx/glxdri.c b/glx/glxdri.c
index 21e44d1..e4870c3 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -682,10 +682,12 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
 }
 
 static __GLXdrawable *
-__glXDRIscreenCreateDrawable(__GLXscreen *screen,
+__glXDRIscreenCreateDrawable(ClientPtr client,
+			     __GLXscreen *screen,
 			     DrawablePtr pDraw,
-			     int type,
 			     XID drawId,
+			     int type,
+			     XID glxDrawId,
 			     __GLXconfig *glxConfig)
 {
     __GLXDRIscreen *driScreen = (__GLXDRIscreen *) screen;
@@ -699,7 +701,7 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen,
 	return NULL;
 
     if (!__glXDrawableInit(&private->base, screen,
-			   pDraw, type, drawId, glxConfig)) {
+			   pDraw, type, glxDrawId, glxConfig)) {
         xfree(private);
 	return NULL;
     }
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 2975bb3..a580df3 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -430,10 +430,12 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
 }
 
 static __GLXdrawable *
-__glXDRIscreenCreateDrawable(__GLXscreen *screen,
+__glXDRIscreenCreateDrawable(ClientPtr client,
+			     __GLXscreen *screen,
 			     DrawablePtr pDraw,
-			     int type,
 			     XID drawId,
+			     int type,
+			     XID glxDrawId,
 			     __GLXconfig *glxConfig)
 {
     __GLXDRIscreen *driScreen = (__GLXDRIscreen *) screen;
@@ -446,7 +448,7 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen,
 
     private->screen = driScreen;
     if (!__glXDrawableInit(&private->base, screen,
-			   pDraw, type, drawId, glxConfig)) {
+			   pDraw, type, glxDrawId, glxConfig)) {
         xfree(private);
 	return NULL;
     }
@@ -457,7 +459,7 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen,
     private->base.waitGL	= __glXDRIdrawableWaitGL;
     private->base.waitX		= __glXDRIdrawableWaitX;
 
-    if (DRI2CreateDrawable(pDraw)) {
+    if (DRI2CreateDrawable(client, pDraw, drawId)) {
 	    xfree(private);
 	    return NULL;
     }
diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c
index c647d83..6a34393 100644
--- a/glx/glxdriswrast.c
+++ b/glx/glxdriswrast.c
@@ -301,10 +301,12 @@ glxChangeGC(GCPtr gc, BITS32 mask, CARD32 val)
 }
 
 static __GLXdrawable *
-__glXDRIscreenCreateDrawable(__GLXscreen *screen,
+__glXDRIscreenCreateDrawable(ClientPtr client,
+			     __GLXscreen *screen,
 			     DrawablePtr pDraw,
-			     int type,
 			     XID drawId,
+			     int type,
+			     XID glxDrawId,
 			     __GLXconfig *glxConfig)
 {
     __GLXDRIscreen *driScreen = (__GLXDRIscreen *) screen;
@@ -319,7 +321,7 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen,
 
     private->screen = driScreen;
     if (!__glXDrawableInit(&private->base, screen,
-			   pDraw, type, drawId, glxConfig)) {
+			   pDraw, type, glxDrawId, glxConfig)) {
         xfree(private);
 	return NULL;
     }
diff --git a/glx/glxscreens.h b/glx/glxscreens.h
index d52099f..861e03c 100644
--- a/glx/glxscreens.h
+++ b/glx/glxscreens.h
@@ -134,10 +134,12 @@ struct __GLXscreen {
 				    __GLXconfig *modes,
 				    __GLXcontext *shareContext);
 
-    __GLXdrawable *(*createDrawable)(__GLXscreen *context,
+    __GLXdrawable *(*createDrawable)(ClientPtr client,
+				     __GLXscreen *context,
 				     DrawablePtr pDraw,
-				     int type,
 				     XID drawId,
+				     int type,
+				     XID glxDrawId,
 				     __GLXconfig *modes);
     int            (*swapInterval)  (__GLXdrawable *drawable,
 				     int interval);
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index e8985b0..dd9bb41 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -37,6 +37,7 @@
 #include <errno.h>
 #include <xf86drm.h>
 #include "xf86Module.h"
+#include "list.h"
 #include "scrnintstr.h"
 #include "windowstr.h"
 #include "dixstruct.h"
@@ -50,12 +51,18 @@ CARD8 dri2_minor;
 
 static int           dri2ScreenPrivateKeyIndex;
 static DevPrivateKey dri2ScreenPrivateKey = &dri2ScreenPrivateKeyIndex;
+static int dri2WindowPrivateKeyIndex;
+static DevPrivateKey dri2WindowPrivateKey = &dri2WindowPrivateKeyIndex;
+static int dri2PixmapPrivateKeyIndex;
+static DevPrivateKey dri2PixmapPrivateKey = &dri2PixmapPrivateKeyIndex;
 static RESTYPE       dri2DrawableRes;
 
 typedef struct _DRI2Screen *DRI2ScreenPtr;
 
 typedef struct _DRI2Drawable {
     DRI2ScreenPtr        dri2_screen;
+    DrawablePtr		 drawable;
+    struct list		 reference_list;
     int			 width;
     int			 height;
     DRI2BufferPtr	*buffers;
@@ -74,6 +81,7 @@ typedef struct _DRI2Drawable {
 
 typedef struct _DRI2Screen {
     ScreenPtr			 screen;
+    int				 refcnt;
     unsigned int		 numDrivers;
     const char			**driverNames;
     const char			*deviceName;
@@ -99,35 +107,33 @@ DRI2GetScreen(ScreenPtr pScreen)
 static DRI2DrawablePtr
 DRI2GetDrawable(DrawablePtr pDraw)
 {
-    DRI2DrawablePtr pPriv;
-    int rc;
-
-    rc = dixLookupResourceByType((pointer *) &pPriv, pDraw->id,
-				 dri2DrawableRes, NULL, DixReadAccess);
-    if (rc != Success)
-	return NULL;
+    WindowPtr pWin;
+    PixmapPtr pPixmap;
 
-    return pPriv;
+    if (pDraw->type == DRAWABLE_WINDOW) {
+	pWin = (WindowPtr) pDraw;
+	return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey);
+    } else {
+	pPixmap = (PixmapPtr) pDraw;
+	return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey);
+    }
 }
 
-int
-DRI2CreateDrawable(DrawablePtr pDraw)
+static DRI2DrawablePtr
+DRI2AllocateDrawable(DrawablePtr pDraw)
 {
     DRI2ScreenPtr   ds = DRI2GetScreen(pDraw->pScreen);
     DRI2DrawablePtr pPriv;
     CARD64          ust;
-    int rc;
-
-    rc = dixLookupResourceByType((pointer *) &pPriv, pDraw->id,
-				 dri2DrawableRes, NULL, DixReadAccess);
-    if (rc == Success || rc != BadValue)
-	return rc;
+    WindowPtr pWin;
+    PixmapPtr pPixmap;
 
     pPriv = xalloc(sizeof *pPriv);
     if (pPriv == NULL)
-	return BadAlloc;
+	return NULL;
 
-    pPriv->dri2_screen = DRI2GetScreen(pDraw->pScreen);
+    pPriv->dri2_screen = ds;
+    pPriv->drawable = pDraw;
     pPriv->width = pDraw->width;
     pPriv->height = pDraw->height;
     pPriv->buffers = NULL;
@@ -145,9 +151,77 @@ DRI2CreateDrawable(DrawablePtr pDraw)
     pPriv->swap_limit = 1; /* default to double buffering */
     pPriv->last_swap_msc = 0;
     pPriv->last_swap_ust = 0;
+    list_init(&pPriv->reference_list);
 
-    if (!AddResource(pDraw->id, dri2DrawableRes, pPriv))
+    if (pDraw->type == DRAWABLE_WINDOW) {
+	pWin = (WindowPtr) pDraw;
+	dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv);
+    } else {
+	pPixmap = (PixmapPtr) pDraw;
+	dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, pPriv);
+    }
+
+    return pPriv;
+}
+
+typedef struct DRI2DrawableRefRec {
+    XID id;
+    XID dri2_id;
+    struct list link;
+} DRI2DrawableRefRec, *DRI2DrawableRefPtr;
+
+static DRI2DrawableRefPtr
+DRI2LookupDrawableRef(DRI2DrawablePtr pPriv, XID id)
+{
+    DRI2DrawableRefPtr ref;
+
+    list_for_each_entry(ref, &pPriv->reference_list, link) {
+	if (ref->id == id)
+	    return ref;
+    }


Reply to: