From e647a91566e63835f9805cf62b7bfa5b7bcbd957 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Wed, 28 Nov 2012 10:21:01 -0600
Subject: xorg-server and server-utils  1.13

---
 abs/core/xorg-server-utils/LICENSE.iceauth         |   25 -
 abs/core/xorg-server-utils/LICENSE.xcmsdb          |   18 -
 abs/core/xorg-server-utils/PKGBUILD                |   78 +-
 ...rlier_and_more_thoroughly_from_exaGlyphsV2.diff |  116 -
 abs/core/xorg-server/PKGBUILD                      |   53 +-
 abs/core/xorg-server/git-fixes.patch               | 2252 +++++---------------
 abs/core/xorg-server/use-pixman-glyph-cache.patch  |  270 +++
 abs/core/xorg-xinit/PKGBUILD                       |    6 +-
 abs/core/xorg-xinit/xserverrc                      |    7 +-
 9 files changed, 907 insertions(+), 1918 deletions(-)
 delete mode 100644 abs/core/xorg-server-utils/LICENSE.iceauth
 delete mode 100644 abs/core/xorg-server-utils/LICENSE.xcmsdb
 delete mode 100644 abs/core/xorg-server/EXA_Fall_back_earlier_and_more_thoroughly_from_exaGlyphsV2.diff
 create mode 100644 abs/core/xorg-server/use-pixman-glyph-cache.patch

diff --git a/abs/core/xorg-server-utils/LICENSE.iceauth b/abs/core/xorg-server-utils/LICENSE.iceauth
deleted file mode 100644
index 06941b3..0000000
--- a/abs/core/xorg-server-utils/LICENSE.iceauth
+++ /dev/null
@@ -1,25 +0,0 @@
-  Copyright 1989, 1998  The Open Group
-  
-  Permission to use, copy, modify, distribute, and sell this software and its
-  documentation for any purpose is hereby granted without fee, provided that
-  the above copyright notice appear in all copies and that both that
-  copyright notice and this permission notice appear in supporting
-  documentation.
-  
-  The above copyright notice and this permission notice shall be included in
-  all copies or substantial portions of the Software.
-  
-  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-  OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-  AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-  
-  Except as contained in this notice, the name of The Open Group shall not be
-  used in advertising or otherwise to promote the sale, use or other dealings
-  in this Software without prior written authorization from The Open Group.
-   * *
-   * Original Author of "xauth" : Jim Fulton, MIT X Consortium
-   * Modified into "iceauth"    : Ralph Mor, X Consortium
-   */
diff --git a/abs/core/xorg-server-utils/LICENSE.xcmsdb b/abs/core/xorg-server-utils/LICENSE.xcmsdb
deleted file mode 100644
index 132ace6..0000000
--- a/abs/core/xorg-server-utils/LICENSE.xcmsdb
+++ /dev/null
@@ -1,18 +0,0 @@
-   (c) Copyright 1990 Tektronix Inc.
-   	All Rights Reserved
-   
-   Permission to use, copy, modify, and distribute this software and its
-   documentation for any purpose and without fee is hereby granted,
-   provided that the above copyright notice appear in all copies and that
-   both that copyright notice and this permission notice appear in
-   supporting documentation, and that the name of Tektronix not be used
-   in advertising or publicity pertaining to distribution of the software
-   without specific, written prior permission.
-   
-   Tektronix disclaims all warranties with regard to this software, including
-   all implied warranties of merchantability and fitness, in no event shall
-   Tektronix be liable for any special, indirect or consequential damages or
-   any damages whatsoever resulting from loss of use, data or profits,
-   whether in an action of contract, negligence or other tortious action,
-   arising out of or in connection with the use or performance of this
-   software.
diff --git a/abs/core/xorg-server-utils/PKGBUILD b/abs/core/xorg-server-utils/PKGBUILD
index 0bae947..1c77a49 100644
--- a/abs/core/xorg-server-utils/PKGBUILD
+++ b/abs/core/xorg-server-utils/PKGBUILD
@@ -1,73 +1,13 @@
-# $Id: PKGBUILD 88717 2010-08-24 14:40:21Z jgc $
+# $Id: PKGBUILD 150987 2012-02-24 12:44:03Z allan $
 # Maintainer: Jan de Groot <jgc@archlinux.org>
 
 pkgname=xorg-server-utils
-pkgver=7.5
-pkgrel=7
-pkgdesc="X.Org utilities required by xorg-server"
-arch=('i686' 'x86_64')
+pkgver=7.6
+pkgrel=3
+pkgdesc="Transition package depending on xorg server utilities"
+arch=('any')
 url="http://xorg.freedesktop.org/"
-license=('custom')
-depends=('libxfontcache>=1.0.5' 'libxi>=1.3' 'libxaw>=1.0.6' 'libxrandr>=1.3.0' 'libxxf86vm>=1.1.0' 'mcpp>=2.7.2')
-makedepends=('pkgconfig' 'xbitmaps' 'bigreqsproto' 'xtrans')
-groups=('xorg')
-source=(${url}/releases/individual/app/iceauth-1.0.3.tar.bz2
-        ${url}/releases/individual/app/rgb-1.0.3.tar.bz2
-        ${url}/releases/individual/app/sessreg-1.0.6.tar.bz2
-        ${url}/releases/individual/app/xcmsdb-1.0.2.tar.bz2
-        ${url}/releases/individual/app/xbacklight-1.1.1.tar.bz2
-        ${url}/releases/individual/app/xgamma-1.0.3.tar.bz2
-        ${url}/releases/individual/app/xhost-1.0.3.tar.bz2
-        ${url}/releases/individual/app/xinput-1.5.2.tar.bz2
-        ${url}/releases/individual/app/xmodmap-1.0.4.tar.bz2
-        ${url}/releases/individual/app/xrandr-1.3.3.tar.bz2
-        ${url}/releases/individual/app/xrdb-1.0.6.tar.bz2
-        ${url}/releases/individual/app/xrefresh-1.0.3.tar.bz2
-        ${url}/releases/individual/app/xset-1.2.0.tar.bz2
-        ${url}/releases/individual/app/xsetmode-1.0.0.tar.bz2
-        ${url}/releases/individual/app/xsetroot-1.0.3.tar.bz2
-        ${url}/releases/individual/app/xvidtune-1.0.2.tar.bz2
-        LICENSE.iceauth
-        LICENSE.xcmsdb)
-md5sums=('975ade3f238c1eb10705da0a91e6e8e7'
-         '44ea16cc3104de6401bc74035f642357'
-         '8c8fcda19f4cffe573d43ec9b8255f8e'
-         '7f2bed9f4dd3301d18d83eb296c3be0d'
-         '3e39eec6d0fd5c587ca6d55aa7bb8fe1'
-         'e8a88bf1a18f35b724619849dca97f4f'
-         'c7f91b4a750d297f269c2a0a3206a1b2'
-         '8cec6023f90180cb8e4be31d98c43fda'
-         'bbe021f812e0014a8ee3692317788119'
-         '5b2dcfb0d9b736afaf78f6ce7651259c'
-         '8dd881cd5a7dcb6e456549817f0fb475'
-         '8f4fafcfb77b3c6972cc44bb3f1c899c'
-         '88ff2d390695366fa53e5d746fe86ad5'
-         'd074e79d380b031d2f60e4cd56538c93'
-         'cbda9b9b8da5af4614110883d5a276b8'
-         'e40eeb4454f2a7cdde3a14f5dfd3aadd'
-         '65695dc24c24958190724a23655ffda7'
-         'b6235416dca2205f0ba83c0c4b3ddeb8')
-
-build() {
-  cd "${srcdir}"
-  install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
-  for i in *; do
-    if [ -d "${i}" ]; then
-      pushd "${i}"
-      case "${i}" in
-        xrdb*)
-          ./configure --prefix=/usr --mandir=/usr/share/man --with-cpp=/usr/bin/mcpp
-          ;;
-        *)
-          ./configure --prefix=/usr --mandir=/usr/share/man
-          ;;
-      esac
-      make
-      make DESTDIR="${pkgdir}" install
-      install -m644 COPYING "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE.${i%-*}
-      popd
-    fi
-  done
-# Replacing stub license files
-  install -m644 "${srcdir}"/LICENSE.* "${pkgdir}/usr/share/licenses/${pkgname}/"
-}
+license=('GPL')
+depends=('xorg-iceauth' 'xorg-sessreg' 'xorg-xcmsdb' 'xorg-xbacklight' 'xorg-xgamma' 'xorg-xhost' 'xorg-xinput' 'xorg-xmodmap' 'xorg-xrandr' 'xorg-xrdb' 'xorg-xrefresh' 'xorg-xset' 'xorg-xsetroot')
+#removed: rgb, xsetmode, xvidtune
+md5sums=()
diff --git a/abs/core/xorg-server/EXA_Fall_back_earlier_and_more_thoroughly_from_exaGlyphsV2.diff b/abs/core/xorg-server/EXA_Fall_back_earlier_and_more_thoroughly_from_exaGlyphsV2.diff
deleted file mode 100644
index 12c1101..0000000
--- a/abs/core/xorg-server/EXA_Fall_back_earlier_and_more_thoroughly_from_exaGlyphsV2.diff
+++ /dev/null
@@ -1,116 +0,0 @@
---- xorg-server-1.12.1/exa/exa_glyphs.c	2012-03-30 04:57:25.000000000 +0200
-+++ xorg-server-1.12.1/exa_glyphs.c.new	2012-04-15 11:48:51.683214230 +0200
-@@ -686,6 +686,7 @@
-     PixmapPtr pMaskPixmap = 0;
-     PicturePtr pMask = NULL;
-     ScreenPtr pScreen = pDst->pDrawable->pScreen;
-+    ExaScreenPriv(pScreen);
-     int width = 0, height = 0;
-     int x, y;
-     int first_xOff = list->xOff, first_yOff = list->yOff;
-@@ -697,7 +698,6 @@
-     ExaGlyphBuffer buffer;
- 
-     if (maskFormat) {
--        ExaScreenPriv(pScreen);
-         GCPtr pGC;
-         xRectangle rect;
- 
-@@ -719,22 +719,20 @@
-                                                 maskFormat->depth,
-                                                 CREATE_PIXMAP_USAGE_SCRATCH);
-         if (!pMaskPixmap)
--            return;
-+	    goto fallback;
-         component_alpha = NeedsComponent(maskFormat->format);
-         pMask = CreatePicture(0, &pMaskPixmap->drawable,
-                               maskFormat, CPComponentAlpha, &component_alpha,
-                               serverClient, &error);
--        if (!pMask ||
--            (!component_alpha && pExaScr->info->CheckComposite &&
--             !(*pExaScr->info->CheckComposite) (PictOpAdd, pSrc, NULL, pMask)))
-+        (*pScreen->DestroyPixmap) (pMaskPixmap);
-+	if (!pMask)
-+	    goto fallback;
-+
-+	if (!component_alpha && pExaScr->info->CheckComposite &&
-+	    !(*pExaScr->info->CheckComposite) (PictOpAdd, pSrc, NULL, pMask))
-         {
-             PictFormatPtr argbFormat;
- 
--            (*pScreen->DestroyPixmap) (pMaskPixmap);
--
--            if (!pMask)
--                return;
--
-             /* The driver can't seem to composite to a8, let's try argb (but
-              * without component-alpha) */
-             FreePicture((pointer) pMask, (XID) 0);
-@@ -748,15 +746,25 @@
-                                                     maskFormat->depth,
-                                                     CREATE_PIXMAP_USAGE_SCRATCH);
-             if (!pMaskPixmap)
--                return;
-+	    goto fallback;
- 
-             pMask = CreatePicture(0, &pMaskPixmap->drawable, maskFormat, 0, 0,
-                                   serverClient, &error);
--            if (!pMask) {
--                (*pScreen->DestroyPixmap) (pMaskPixmap);
--                return;
--            }
-+            (*pScreen->DestroyPixmap) (pMaskPixmap);
-+	    if (!pMask)
-+	    goto fallback;
-         }
-+	  
-+	if (pExaScr->info->CheckComposite &&
-+	    (!(*pExaScr->info->CheckComposite) (PictOpAdd, pSrc, NULL, pMask) ||
-+	     (!(*pExaScr->info->CheckComposite) (op, pSrc, pMask, pDst) &&
-+	      (op != PictOpOver ||
-+	       !(*pExaScr->info->CheckComposite) (PictOpOutReverse, pSrc, pMask, pDst) ||
-+	       !(*pExaScr->info->CheckComposite) (PictOpOver, pSrc, pMask, pDst))))) {
-+	    FreePicture ((pointer) pMask, (XID) 0);
-+	    goto fallback;
-+	}
-+
-         pGC = GetScratchGC(pMaskPixmap->drawable.depth, pScreen);
-         ValidateGC(&pMaskPixmap->drawable, pGC);
-         rect.x = 0;
-@@ -769,6 +777,13 @@
-         y = -extents.y1;
-     }
-     else {
-+    	if (pExaScr->info->CheckComposite &&
-+	    !(*pExaScr->info->CheckComposite) (op, pSrc, NULL, pDst) &&
-+	    (op != PictOpOver ||
-+	     !(*pExaScr->info->CheckComposite) (PictOpOutReverse, pSrc, NULL, pDst) ||
-+	     !(*pExaScr->info->CheckComposite) (PictOpOver, pSrc, NULL, pDst)))
-+	    goto fallback;
-+
-         x = 0;
-         y = 0;
-     }
-@@ -834,6 +849,10 @@
-                          xSrc + x - first_xOff,
-                          ySrc + y - first_yOff, 0, 0, x, y, width, height);
-         FreePicture((pointer) pMask, (XID) 0);
--        (*pScreen->DestroyPixmap) (pMaskPixmap);
-     }
-+    
-+    return;
-+
-+fallback:
-+    ExaCheckGlyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
- }
---- xorg-server-1.12.1/exa/exa_render.c	2012-03-30 04:57:25.000000000 +0200
-+++ xorg-server-1.12.1/exa_render.c.new	2012-04-15 11:50:35.272482047 +0200
-@@ -878,7 +878,7 @@
-     Bool saveMaskRepeat = pMask ? pMask->repeat : 0;
-     RegionRec region;
- 
--    if (pExaScr->swappedOut)
-+    if (pExaScr->fallback_counter || pExaScr->swappedOut)
-         goto fallback;
- 
-     /* Remove repeat in source if useless */
diff --git a/abs/core/xorg-server/PKGBUILD b/abs/core/xorg-server/PKGBUILD
index 747eeca..c42748b 100644
--- a/abs/core/xorg-server/PKGBUILD
+++ b/abs/core/xorg-server/PKGBUILD
@@ -1,9 +1,9 @@
-# $Id: PKGBUILD 163203 2012-07-09 16:05:50Z andyrtr $
+# $Id: PKGBUILD 171979 2012-11-25 17:50:59Z andyrtr $
 # Maintainer: Jan de Groot <jgc@archlinux.org>
 
 pkgbase=xorg-server
 pkgname=('xorg-server' 'xorg-server-xephyr' 'xorg-server-xdmx' 'xorg-server-xvfb' 'xorg-server-xnest' 'xorg-server-common' 'xorg-server-devel')
-pkgver=1.12.3
+pkgver=1.13.0.901
 pkgrel=1
 arch=('i686' 'x86_64')
 license=('custom')
@@ -11,40 +11,39 @@ url="http://xorg.freedesktop.org"
 makedepends=('pixman' 'libx11' 'mesa' 'libgl' 'xf86driproto' 'xcmiscproto' 'xtrans' 'bigreqsproto' 'randrproto' 'inputproto' 'fontsproto' 'videoproto'
              'compositeproto' 'recordproto' 'scrnsaverproto' 'resourceproto' 'xineramaproto' 'libxkbfile' 'libxfont' 'renderproto' 'libpciaccess'
              'libxv' 'xf86dgaproto' 'libxmu' 'libxrender' 'libxi' 'dmxproto' 'libxaw' 'libdmx' 'libxtst' 'libxres' 'xorg-xkbcomp' 'xorg-util-macros'
-             'xorg-font-util' 'glproto' 'dri2proto' 'udev>=183' 'libgcrypt')
+             'xorg-font-util' 'glproto' 'dri2proto' 'libgcrypt')
 options=('!libtool')
 source=(${url}/releases/individual/xserver/${pkgbase}-${pkgver}.tar.bz2
         autoconfig-nvidia.patch
         autoconfig-sis.patch
-        #EXA_Fall_back_earlier_and_more_thoroughly_from_exaGlyphsV2.diff
-        #git-fixes.patch
         xvfb-run
         xvfb-run.1
-        10-quirks.conf)
-sha256sums=('3654b613393734ce0c7c23e81ca4ceb6e8afefb5f0649233ffd105c1220544fe'
+        10-quirks.conf
+        #git-fixes.patch
+        use-pixman-glyph-cache.patch)
+sha256sums=('64a50d6ca8264d8e32db4ebeeaf4df3b37ef447c7eef37e9a377c983733596f5'
             '66e25f76a7496c429e0aff4b0670f168719bb0ceaeb88c6f2272f2bf3ed21162'
             'd027776fac1f7675b0a9ee817502290b1c45f9c09b0f0a6bb058c35f92361e84'
             'ff0156309470fc1d378fd2e104338020a884295e285972cc88e250e031cc35b9'
             '2460adccd3362fefd4cdc5f1c70f332d7b578091fb9167bf88b5f91265bbd776'
-            '94612f5c0d34a3b7152915c2e285c7b462e9d8e38d3539bd551a339498eac166')
+            '94612f5c0d34a3b7152915c2e285c7b462e9d8e38d3539bd551a339498eac166'
+            '7c1dacd30c46b01424c7c75974285cd348dafd0327eb3f211cbe446ad90dd308')
 
 build() {
   cd "${srcdir}/${pkgbase}-${pkgver}"
 
+  # Apply upstream fixes from server-1.13 branch
+#  patch -Np1 -i "${srcdir}/git-fixes.patch"
+
+  # Use pixman 0.28.0 glyph cache - backported from git master
+  patch -Np1 -i "${srcdir}/use-pixman-glyph-cache.patch"
+
   # Use nouveau/nv/nvidia drivers for nvidia devices
   patch -Np1 -i "${srcdir}/autoconfig-nvidia.patch"
 
   # Use unofficial imedia SiS driver for supported SiS devices
   patch -Np0 -i "${srcdir}/autoconfig-sis.patch"
 
-  # fix glitches and crashes with EXA and cairo 1.12
-  # taken from https://bugs.freedesktop.org/show_bug.cgi?id=47266
-  # and reworked for 1.12.1 changes
-#  patch -Np1 -i ${srcdir}/EXA_Fall_back_earlier_and_more_thoroughly_from_exaGlyphsV2.diff
-
-  # Add post-release patches from 1.12 branch
-#  patch -Np1 -i ${srcdir}/git-fixes.patch
-
   autoreconf -fi
   ./configure --prefix=/usr \
       --enable-ipv6 \
@@ -102,9 +101,10 @@ package_xorg-server-common() {
 
 package_xorg-server() {
   pkgdesc="Xorg X server"
-  depends=(libxdmcp libxfont udev libpciaccess libdrm pixman libgcrypt libxau xorg-server-common xf86-input-evdev)
+  depends=(libxdmcp libxfont libpciaccess libdrm 'pixman>=0.28.0' libgcrypt libxau xorg-server-common xf86-input-evdev)
   backup=('etc/X11/xorg.conf.d/10-evdev.conf' 'etc/X11/xorg.conf.d/10-quirks.conf')
-  provides=('x-server')
+  # see xorg-server-1.13.0/hw/xfree86/common/xf86Module.h for ABI versions - we provide major numbers that drivers can depend on
+  provides=('X-ABI-VIDEODRV_VERSION=13' 'X-ABI-XINPUT_VERSION=18' 'X-ABI-EXTENSION_VERSION=7.0' 'x-server')
   groups=('xorg')
   conflicts=('nvidia-utils<=290.10')
 
@@ -136,7 +136,7 @@ package_xorg-server() {
 
 package_xorg-server-xephyr() {
   pkgdesc="A nested X server that runs as an X application"
-  depends=(libxfont libgl libgcrypt libxv pixman xorg-server-common)
+  depends=(libxfont libgl libgcrypt libxv 'pixman>=0.28.0' xorg-server-common)
 
   cd "${srcdir}/${pkgbase}-${pkgver}/hw/kdrive"
   make DESTDIR="${pkgdir}" install
@@ -147,7 +147,7 @@ package_xorg-server-xephyr() {
 
 package_xorg-server-xvfb() {
   pkgdesc="Virtual framebuffer X server"
-  depends=(libxfont libxdmcp libxau libgcrypt pixman xorg-server-common)
+  depends=(libxfont libxdmcp libxau libgcrypt 'pixman>=0.28.0' xorg-server-common)
 
   cd "${srcdir}/${pkgbase}-${pkgver}/hw/vfb"
   make DESTDIR="${pkgdir}" install
@@ -161,7 +161,7 @@ package_xorg-server-xvfb() {
 
 package_xorg-server-xnest() {
   pkgdesc="A nested X server that runs as an X application"
-  depends=(libxfont libxext libgcrypt pixman xorg-server-common)
+  depends=(libxfont libxext libgcrypt 'pixman>=0.28.0' xorg-server-common)
 
   cd "${srcdir}/${pkgbase}-${pkgver}/hw/xnest"
   make DESTDIR="${pkgdir}" install
@@ -172,7 +172,7 @@ package_xorg-server-xnest() {
 
 package_xorg-server-xdmx() {
   pkgdesc="Distributed Multihead X Server and utilities"
-  depends=(libxfont libxi libgcrypt libxaw libxrender libdmx libxfixes pixman xorg-server-common)
+  depends=(libxfont libxi libgcrypt libxaw libxrender libdmx libxfixes 'pixman>=0.28.0' xorg-server-common)
 
   cd "${srcdir}/${pkgbase}-${pkgver}/hw/dmx"
   make DESTDIR="${pkgdir}" install
@@ -183,7 +183,14 @@ package_xorg-server-xdmx() {
 
 package_xorg-server-devel() {
   pkgdesc="Development files for the X.Org X server"
-  depends=(xproto randrproto renderproto xextproto inputproto kbproto fontsproto videoproto dri2proto xineramaproto xorg-util-macros pixman libpciaccess)
+  depends=(# see pkgdir/usr/lib/pkgconfig/xorg-server.pc
+           xproto randrproto renderproto xextproto inputproto kbproto 
+           fontsproto pixman videoproto xf86driproto glproto 
+           mesa dri2proto xineramaproto libpciaccess
+           # see FS#32146
+           resourceproto scrnsaverproto
+           # not technically required but almost every Xorg pkg needs it to build
+           xorg-util-macros)
 
   cd "${srcdir}/${pkgbase}-${pkgver}"
   make DESTDIR="${pkgdir}" install
diff --git a/abs/core/xorg-server/git-fixes.patch b/abs/core/xorg-server/git-fixes.patch
index f6ca242..d1817c0 100644
--- a/abs/core/xorg-server/git-fixes.patch
+++ b/abs/core/xorg-server/git-fixes.patch
@@ -1,1717 +1,643 @@
-From b5bf0ac5405eab77f26bb2f8726644232af17178 Mon Sep 17 00:00:00 2001
-From: Keith Packard <keithp@keithp.com>
-Date: Wed, 11 Apr 2012 16:28:21 +0000
-Subject: hw/xfree86: Spurious ');' in xf86vmode.c messed up indentation badly
-
-Inside the unfinished XF86VIDMODE_EVENTS #ifdef block the
-function definition for xf86VidModeNotifyEvent had an extra ');'
-before the prototype argument declarations. This was harmless for the
-compiler as the code never gets used, but completely messed up the
-file re-indentation. This patch removes the spurious characters in
-preparation for re-indenting the file.
-
-Signed-off-by: Keith Packard <keithp@keithp.com>
-(cherry picked from commit 592bd0ae2b60cd6f6afd3efc40f5f659b12900b4)
----
-diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c
-index 6e2a8e9..9f64f8e 100644
---- a/hw/xfree86/dixmods/extmod/xf86vmode.c
-+++ b/hw/xfree86/dixmods/extmod/xf86vmode.c
-@@ -75,7 +75,7 @@ static unsigned char XF86VidModeReqCode = 0;
- #ifdef XF86VIDMODE_EVENTS
- static int XF86VidModeEventBase = 0;
- 
--static void SXF86VidModeNotifyEvent();
-+static void SXF86VidModeNotifyEvent(
- xXF86VidModeNotifyEvent * /* from */ , xXF86VidModeNotifyEvent *        /* to */
-     );
- 
---
-cgit v0.9.0.2-2-gbebe
-From 3ad72a80088fe3236f38bd0696b04f399e24fe3d Mon Sep 17 00:00:00 2001
-From: Keith Packard <keithp@keithp.com>
-Date: Wed, 11 Apr 2012 16:33:54 +0000
-Subject: hw/xfree86: Re-indent xf86vmode.c
-
-This is the result of re-running the 'x-indent.sh' script over
-xf86vmode.c to clean up the disaster caused by broken syntax in the
-file.
-
-Signed-off-by: Keith Packard <keithp@keithp.com>
-(cherry picked from commit 9779b904c7c0b49c74054c22c420012c40595cdc)
----
-diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c
-index 9f64f8e..68c4b58 100644
---- a/hw/xfree86/dixmods/extmod/xf86vmode.c
-+++ b/hw/xfree86/dixmods/extmod/xf86vmode.c
-@@ -75,8 +75,7 @@ static unsigned char XF86VidModeReqCode = 0;
- #ifdef XF86VIDMODE_EVENTS
- static int XF86VidModeEventBase = 0;
- 
--static void SXF86VidModeNotifyEvent(
--xXF86VidModeNotifyEvent * /* from */ , xXF86VidModeNotifyEvent *        /* to */
-+static void SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent * /* from */ , xXF86VidModeNotifyEvent *    /* to */
-     );
- 
- static RESTYPE EventType;       /* resource type for event masks */
-@@ -117,20 +116,22 @@ static DevPrivateKeyRec ScreenPrivateKeyRec;
- #define DEBUG_P(x) /**/
- #endif
-     static int
-- ClientMajorVersion(ClientPtr client) {
-+ClientMajorVersion(ClientPtr client)
-+{
-     VidModePrivPtr pPriv;
- 
--     pPriv = VM_GETPRIV(client);
-+    pPriv = VM_GETPRIV(client);
-     if (!pPriv)
--         return 0;
-+        return 0;
+diff --git a/Xi/exevents.c b/Xi/exevents.c
+index 494d07e..106da3a 100644
+--- a/Xi/exevents.c
++++ b/Xi/exevents.c
+@@ -949,8 +949,6 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent *event)
+ 
+         if (!(event->flags & TOUCH_POINTER_EMULATED))
+             return DONT_PROCESS;
+-        if (!(event->flags & TOUCH_END))
+-            return DONT_PROCESS;
+ 
+         DecreaseButtonCount(device, key, &t->buttonsDown, &t->motionMask,
+                             &t->state);
+@@ -1561,6 +1559,7 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev)
+     uint32_t touchid;
+     int type = ev->any.type;
+     int emulate_pointer = ! !(ev->device_event.flags & TOUCH_POINTER_EMULATED);
++    DeviceIntPtr kbd;
+ 
+     if (!t)
+         return;
+@@ -1570,9 +1569,6 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev)
      else
--         return pPriv->major;
-+        return pPriv->major;
- }
-+
- #ifdef XF86VIDMODE_EVENTS
- static void
-- CheckScreenPrivate(pScreen)
-+CheckScreenPrivate(pScreen)
- ScreenPtr
--    pScreen;
-+ pScreen;
- {
-     SetupScreen(pScreen);
+         touchid = ev->device_event.touchid;
  
-@@ -142,9 +143,10 @@ ScreenPtr
+-    if (emulate_pointer)
+-        UpdateDeviceState(dev, &ev->device_event);
+-
+     if (type == ET_TouchBegin) {
+         ti = TouchBeginTouch(dev, ev->device_event.sourceid, touchid,
+                              emulate_pointer);
+@@ -1619,9 +1615,14 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev)
+      * events which _only_ emulate motion just work normally */
+     if (emulate_pointer && ev->any.type != ET_TouchUpdate)
+         DeliverEmulatedMotionEvent(dev, ti, ev);
++
+     if (emulate_pointer && IsMaster(dev))
+         CheckMotion(&ev->device_event, dev);
+ 
++    kbd = GetMaster(dev, KEYBOARD_OR_FLOAT);
++    event_set_state(NULL, kbd, &ev->device_event);
++    ev->device_event.corestate = event_get_corestate(NULL, kbd);
++
+     /* Make sure we have a valid window trace for event delivery; must be
+      * called after event type mutation. Touch end events are always processed
+      * in order to end touch records. */
+@@ -1643,6 +1644,9 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev)
+         if (ev->any.type == ET_TouchEnd)
+             TouchEndTouch(dev, ti);
      }
- }
- 
--static XF86VidModeScreenPrivatePtr MakeScreenPrivate(pScreen)
-+static XF86VidModeScreenPrivatePtr
-+MakeScreenPrivate(pScreen)
- ScreenPtr
--    pScreen;
-+ pScreen;
- {
-     SetupScreen(pScreen);
- 
-@@ -160,18 +162,22 @@ ScreenPtr
- }
- 
- static unsigned long
-- getEventMask(ScreenPtr pScreen, ClientPtr client) {
-+getEventMask(ScreenPtr pScreen, ClientPtr client)
-+{
-     SetupScreen(pScreen);
-     XF86VidModeEventPtr pEv;
- 
-     if (!pPriv)
--         return 0;
-+        return 0;
-     for (pEv = pPriv->events; pEv; pEv = pEv->next)
-         if (pEv->client == client)
-             return pEv->mask;
--     return 0;
--} static Bool
-- setEventMask(ScreenPtr pScreen, ClientPtr client, unsigned long mask) {
-+    return 0;
-+}
 +
-+static Bool
-+setEventMask(ScreenPtr pScreen, ClientPtr client, unsigned long mask)
-+{
-     SetupScreen(pScreen);
-     XF86VidModeEventPtr pEv, *pPrev;
- 
-@@ -181,7 +187,8 @@ static unsigned long
-         pPriv = MakeScreenPrivate(pScreen);
-         if (!pPriv)
-             return FALSE;
--    } for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next)
-+    }
-+    for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next)
-         if (pEv->client == client)
-             break;
-     if (mask == 0) {
-@@ -208,38 +215,43 @@ static unsigned long
- }
- 
- static int
-- XF86VidModeFreeEvents(pointer value, XID id) {
-+XF86VidModeFreeEvents(pointer value, XID id)
-+{
-     XF86VidModeEventPtr pOld = (XF86VidModeEventPtr) value;
-     ScreenPtr pScreen = pOld->screen;
--     SetupScreen(pScreen);
-+
-+    SetupScreen(pScreen);
-     XF86VidModeEventPtr pEv, *pPrev;
- 
-     if (!pPriv)
--         return TRUE;
-+        return TRUE;
-     for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next)
-         if (pEv == pOld)
-             break;
-     if (!pEv)
--         return TRUE;
-+        return TRUE;
-     *pPrev = pEv->next;
--     free(pEv);
--     CheckScreenPrivate(pScreen);
--     return TRUE;
--} static void
-- SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced) {
-+    free(pEv);
-+    CheckScreenPrivate(pScreen);
-+    return TRUE;
-+}
-+
-+static void
-+SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced)
-+{
-     XF86VidModeScreenPrivatePtr pPriv;
-     XF86VidModeEventPtr pEv;
-     unsigned long mask;
-     xXF86VidModeNotifyEvent ev;
-     int kind;
- 
--     UpdateCurrentTimeIf();
--     mask = XF86VidModeNotifyMask;
--     pScreen = screenInfo.screens[pScreen->myNum];
--     pPriv = GetScreenPrivate(pScreen);
-+    UpdateCurrentTimeIf();
-+    mask = XF86VidModeNotifyMask;
-+    pScreen = screenInfo.screens[pScreen->myNum];
-+    pPriv = GetScreenPrivate(pScreen);
-     if (!pPriv)
--         return;
--     kind = XF86VidModeModeChange;
-+        return;
-+    kind = XF86VidModeModeChange;
-     for (pEv = pPriv->events; pEv; pEv = pEv->next) {
-         if (!(pEv->mask & mask))
-             continue;
-@@ -251,8 +263,10 @@ static int
-         ev.forced = forced;
-         WriteEventsToClient(pEv->client, 1, (xEvent *) &ev);
- }} static void
-- SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent * from,
--                         xXF86VidModeNotifyEvent * to) {
-+
-+SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent * from,
-+                        xXF86VidModeNotifyEvent * to)
-+{
-     to->type = from->type;
-     to->state = from->state;
-     cpswaps(from->sequenceNumber, to->sequenceNumber);
-@@ -264,29 +278,31 @@ static int
- #endif
- 
- static int
-- ProcXF86VidModeQueryVersion(ClientPtr client) {
-+ProcXF86VidModeQueryVersion(ClientPtr client)
-+{
-     xXF86VidModeQueryVersionReply rep;
- 
--     DEBUG_P("XF86VidModeQueryVersion");
-+    DEBUG_P("XF86VidModeQueryVersion");
- 
--     REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq);
--     rep.type = X_Reply;
--     rep.length = 0;
--     rep.sequenceNumber = client->sequence;
--     rep.majorVersion = SERVER_XF86VIDMODE_MAJOR_VERSION;
--     rep.minorVersion = SERVER_XF86VIDMODE_MINOR_VERSION;
-+    REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq);
-+    rep.type = X_Reply;
-+    rep.length = 0;
-+    rep.sequenceNumber = client->sequence;
-+    rep.majorVersion = SERVER_XF86VIDMODE_MAJOR_VERSION;
-+    rep.minorVersion = SERVER_XF86VIDMODE_MINOR_VERSION;
-     if (client->swapped) {
-         swaps(&rep.sequenceNumber);
-         swapl(&rep.length);
-         swaps(&rep.majorVersion);
-         swaps(&rep.minorVersion);
--    } WriteToClient(client, sizeof(xXF86VidModeQueryVersionReply),
--                    (char *) &rep);
-+    }
-+    WriteToClient(client, sizeof(xXF86VidModeQueryVersionReply), (char *) &rep);
-     return Success;
++    if (emulate_pointer)
++        UpdateDeviceState(dev, &ev->device_event);
  }
  
- static int
-- ProcXF86VidModeGetModeLine(ClientPtr client) {
-+ProcXF86VidModeGetModeLine(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeGetModeLineReq);
-     xXF86VidModeGetModeLineReply rep;
-     xXF86OldVidModeGetModeLineReply oldrep;
-@@ -294,11 +310,11 @@ static int
-     int dotClock;
-     int ver;
- 
--     DEBUG_P("XF86VidModeGetModeline");
-+    DEBUG_P("XF86VidModeGetModeline");
- 
--     ver = ClientMajorVersion(client);
--     REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
--     rep.type = X_Reply;
-+    ver = ClientMajorVersion(client);
-+    REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
-+    rep.type = X_Reply;
-     if (ver < 2) {
-         rep.length = bytes_to_int32(SIZEOF(xXF86OldVidModeGetModeLineReply) -
-                                     SIZEOF(xGenericReply));
-@@ -386,7 +402,8 @@ static int
- }
- 
- static int
-- ProcXF86VidModeGetAllModeLines(ClientPtr client) {
-+ProcXF86VidModeGetAllModeLines(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeGetAllModeLinesReq);
-     xXF86VidModeGetAllModeLinesReply rep;
-     xXF86VidModeModeInfo mdinf;
-@@ -395,38 +412,39 @@ static int
-     int modecount, dotClock;
-     int ver;
- 
--     DEBUG_P("XF86VidModeGetAllModelines");
-+    DEBUG_P("XF86VidModeGetAllModelines");
- 
--     REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
-+    REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
- 
-     if (stuff->screen >= screenInfo.numScreens)
--         return BadValue;
-+        return BadValue;
- 
--     ver = ClientMajorVersion(client);
-+    ver = ClientMajorVersion(client);
- 
--     modecount = VidModeGetNumOfModes(stuff->screen);
-+    modecount = VidModeGetNumOfModes(stuff->screen);
-     if (modecount < 1)
--         return VidModeErrorBase + XF86VidModeExtensionDisabled;
-+        return VidModeErrorBase + XF86VidModeExtensionDisabled;
- 
-     if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
--         return BadValue;
-+        return BadValue;
- 
--     rep.type = X_Reply;
--     rep.length = SIZEOF(xXF86VidModeGetAllModeLinesReply) -
-+    rep.type = X_Reply;
-+    rep.length = SIZEOF(xXF86VidModeGetAllModeLinesReply) -
-         SIZEOF(xGenericReply);
-     if (ver < 2)
--         rep.length += modecount * sizeof(xXF86OldVidModeModeInfo);
-+        rep.length += modecount * sizeof(xXF86OldVidModeModeInfo);
-     else
--         rep.length += modecount * sizeof(xXF86VidModeModeInfo);
--     rep.length >>= 2;
--     rep.sequenceNumber = client->sequence;
--     rep.modecount = modecount;
-+        rep.length += modecount * sizeof(xXF86VidModeModeInfo);
-+    rep.length >>= 2;
-+    rep.sequenceNumber = client->sequence;
-+    rep.modecount = modecount;
-     if (client->swapped) {
-         swaps(&rep.sequenceNumber);
-         swapl(&rep.length);
-         swapl(&rep.modecount);
--    } WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply),
--                    (char *) &rep);
-+    }
-+    WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply),
-+                  (char *) &rep);
- 
-     do {
-         mdinf.dotclock = dotClock;
-@@ -492,7 +510,8 @@ static int
-      && VidModeGetModeValue(mode, VIDMODE_FLAGS)  == stuff->flags )
- 
- static int
-- ProcXF86VidModeAddModeLine(ClientPtr client) {
-+ProcXF86VidModeAddModeLine(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeAddModeLineReq);
-     xXF86OldVidModeAddModeLineReq *oldstuff =
-         (xXF86OldVidModeAddModeLineReq *) client->requestBuffer;
-@@ -502,9 +521,9 @@ static int
-     int dotClock;
-     int ver;
- 
--     DEBUG_P("XF86VidModeAddModeline");
-+    DEBUG_P("XF86VidModeAddModeline");
- 
--     ver = ClientMajorVersion(client);
-+    ver = ClientMajorVersion(client);
-     if (ver < 2) {
-         /* convert from old format */
-         stuff = &newstuff;
-@@ -533,7 +552,8 @@ static int
-         stuff->after_vsyncend = oldstuff->after_vsyncend;
-         stuff->after_vtotal = oldstuff->after_vtotal;
-         stuff->after_flags = oldstuff->after_flags;
--    } if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
-+    }
-+    if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
-         ErrorF("AddModeLine - scrn: %d clock: %ld\n",
-                (int) stuff->screen, (unsigned long) stuff->dotclock);
-         ErrorF("AddModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
-@@ -654,7 +674,8 @@ static int
- }
- 
- static int
-- ProcXF86VidModeDeleteModeLine(ClientPtr client) {
-+ProcXF86VidModeDeleteModeLine(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeDeleteModeLineReq);
-     xXF86OldVidModeDeleteModeLineReq *oldstuff =
-         (xXF86OldVidModeDeleteModeLineReq *) client->requestBuffer;
-@@ -663,9 +684,9 @@ static int
-     int len, dotClock;
-     int ver;
- 
--     DEBUG_P("XF86VidModeDeleteModeline");
-+    DEBUG_P("XF86VidModeDeleteModeline");
- 
--     ver = ClientMajorVersion(client);
-+    ver = ClientMajorVersion(client);
-     if (ver < 2) {
-         /* convert from old format */
-         stuff = &newstuff;
-@@ -683,7 +704,8 @@ static int
-         stuff->vtotal = oldstuff->vtotal;
-         stuff->flags = oldstuff->flags;
-         stuff->privsize = oldstuff->privsize;
--    } if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
-+    }
-+    if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
-         ErrorF("DeleteModeLine - scrn: %d clock: %ld\n",
-                (int) stuff->screen, (unsigned long) stuff->dotclock);
-         ErrorF("                 hdsp: %d hbeg: %d hend: %d httl: %d\n",
-@@ -777,7 +799,8 @@ static int
- }
- 
- static int
-- ProcXF86VidModeModModeLine(ClientPtr client) {
-+ProcXF86VidModeModModeLine(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeModModeLineReq);
-     xXF86OldVidModeModModeLineReq *oldstuff =
-         (xXF86OldVidModeModModeLineReq *) client->requestBuffer;
-@@ -786,9 +809,9 @@ static int
-     int len, dotClock;
-     int ver;
- 
--     DEBUG_P("XF86VidModeModModeline");
-+    DEBUG_P("XF86VidModeModModeline");
- 
--     ver = ClientMajorVersion(client);
-+    ver = ClientMajorVersion(client);
-     if (ver < 2) {
-         /* convert from old format */
-         stuff = &newstuff;
-@@ -805,7 +828,8 @@ static int
-         stuff->vtotal = oldstuff->vtotal;
-         stuff->flags = oldstuff->flags;
-         stuff->privsize = oldstuff->privsize;
--    } if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
-+    }
-+    if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
-         ErrorF("ModModeLine - scrn: %d hdsp: %d hbeg: %d hend: %d httl: %d\n",
-                (int) stuff->screen, stuff->hdisplay, stuff->hsyncstart,
-                stuff->hsyncend, stuff->htotal);
-@@ -903,7 +927,8 @@ static int
- }
- 
- static int
-- ProcXF86VidModeValidateModeLine(ClientPtr client) {
-+ProcXF86VidModeValidateModeLine(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeValidateModeLineReq);
-     xXF86OldVidModeValidateModeLineReq *oldstuff =
-         (xXF86OldVidModeValidateModeLineReq *) client->requestBuffer;
-@@ -913,9 +938,9 @@ static int
-     int len, status, dotClock;
-     int ver;
- 
--     DEBUG_P("XF86VidModeValidateModeline");
-+    DEBUG_P("XF86VidModeValidateModeline");
- 
--     ver = ClientMajorVersion(client);
-+    ver = ClientMajorVersion(client);
-     if (ver < 2) {
-         /* convert from old format */
-         stuff = &newstuff;
-@@ -933,7 +958,8 @@ static int
-         stuff->vtotal = oldstuff->vtotal;
-         stuff->flags = oldstuff->flags;
-         stuff->privsize = oldstuff->privsize;
--    } if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
-+    }
-+    if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
-         ErrorF("ValidateModeLine - scrn: %d clock: %ld\n",
-                (int) stuff->screen, (unsigned long) stuff->dotclock);
-         ErrorF("                   hdsp: %d hbeg: %d hend: %d httl: %d\n",
-@@ -1022,7 +1048,8 @@ static int
- }
- 
- static int
-- ProcXF86VidModeSwitchMode(ClientPtr client) {
-+ProcXF86VidModeSwitchMode(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeSwitchModeReq);
- 
-     DEBUG_P("XF86VidModeSwitchMode");
-@@ -1035,8 +1062,11 @@ static int
-     VidModeZoomViewport(stuff->screen, (short) stuff->zoom);
- 
-     return Success;
--} static int
-- ProcXF86VidModeSwitchToMode(ClientPtr client) {
-+}
-+
-+static int
-+ProcXF86VidModeSwitchToMode(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeSwitchToModeReq);
-     xXF86OldVidModeSwitchToModeReq *oldstuff =
-         (xXF86OldVidModeSwitchToModeReq *) client->requestBuffer;
-@@ -1045,9 +1075,9 @@ static int
-     int len, dotClock;
-     int ver;
- 
--     DEBUG_P("XF86VidModeSwitchToMode");
-+    DEBUG_P("XF86VidModeSwitchToMode");
+ /**
+@@ -1864,6 +1868,11 @@ DeliverTouchEndEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev,
+         goto out;
+     }
  
--     ver = ClientMajorVersion(client);
-+    ver = ClientMajorVersion(client);
-     if (ver < 2) {
-         /* convert from old format */
-         stuff = &newstuff;
-@@ -1065,7 +1095,8 @@ static int
-         stuff->vtotal = oldstuff->vtotal;
-         stuff->flags = oldstuff->flags;
-         stuff->privsize = oldstuff->privsize;
--    } if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
++    if (listener->state == LISTENER_AWAITING_BEGIN) {
++        listener->state = LISTENER_HAS_END;
++        goto out;
 +    }
-+    if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
-         ErrorF("SwitchToMode - scrn: %d clock: %ld\n",
-                (int) stuff->screen, (unsigned long) stuff->dotclock);
-         ErrorF("               hdsp: %d hbeg: %d hend: %d httl: %d\n",
-@@ -1138,7 +1169,8 @@ static int
- }
- 
- static int
-- ProcXF86VidModeLockModeSwitch(ClientPtr client) {
-+ProcXF86VidModeLockModeSwitch(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeLockModeSwitchReq);
- 
-     REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
-@@ -1152,53 +1184,57 @@ static int
-         return VidModeErrorBase + XF86VidModeZoomLocked;
- 
-     return Success;
--} static int
-- ProcXF86VidModeGetMonitor(ClientPtr client) {
-+}
 +
-+static int
-+ProcXF86VidModeGetMonitor(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeGetMonitorReq);
-     xXF86VidModeGetMonitorReply rep;
-     CARD32 *hsyncdata, *vsyncdata;
-     int i, nHsync, nVrefresh;
-     pointer monitor;
- 
--     DEBUG_P("XF86VidModeGetMonitor");
-+    DEBUG_P("XF86VidModeGetMonitor");
- 
--     REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
-+    REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
- 
-     if (stuff->screen >= screenInfo.numScreens)
--         return BadValue;
-+        return BadValue;
- 
-     if (!VidModeGetMonitor(stuff->screen, &monitor))
--         return BadValue;
-+        return BadValue;
- 
--     nHsync = VidModeGetMonitorValue(monitor, VIDMODE_MON_NHSYNC, 0).i;
--     nVrefresh = VidModeGetMonitorValue(monitor, VIDMODE_MON_NVREFRESH, 0).i;
-+    nHsync = VidModeGetMonitorValue(monitor, VIDMODE_MON_NHSYNC, 0).i;
-+    nVrefresh = VidModeGetMonitorValue(monitor, VIDMODE_MON_NVREFRESH, 0).i;
+     /* Event in response to reject */
+     if (ev->device_event.flags & TOUCH_REJECT) {
+         if (listener->state != LISTENER_HAS_END)
+diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c
+index 0e45cb8..ab1b624 100644
+--- a/Xi/xiselectev.c
++++ b/Xi/xiselectev.c
+@@ -180,8 +180,13 @@ ProcXISelectEvents(ClientPtr client)
+                     if (CLIENT_ID(iclient->resource) == client->index)
+                         continue;
+ 
+-                    dixLookupDevice(&tmp, evmask->deviceid, serverClient,
+-                                    DixReadAccess);
++                    if (evmask->deviceid == XIAllDevices)
++                        tmp = inputInfo.all_devices;
++                    else if (evmask->deviceid == XIAllMasterDevices)
++                        tmp = inputInfo.all_master_devices;
++                    else
++                        dixLookupDevice(&tmp, evmask->deviceid, serverClient,
++                                        DixReadAccess);
+                     if (!tmp)
+                         return BadImplementation;       /* this shouldn't happen */
+ 
+diff --git a/config/udev.c b/config/udev.c
+index c2d00bb..454838f 100644
+--- a/config/udev.c
++++ b/config/udev.c
+@@ -300,9 +300,15 @@ wakeup_handler(pointer data, int err, pointer read_mask)
+             return;
+         action = udev_device_get_action(udev_device);
+         if (action) {
+-            if (!strcmp(action, "add") || !strcmp(action, "change")) {
++            if (!strcmp(action, "add")) {
+                 device_removed(udev_device);
+                 device_added(udev_device);
++            } else if (!strcmp(action, "change")) {
++                /* ignore change for the drm devices */
++                if (strcmp(udev_device_get_subsystem(udev_device), "drm")) {
++                    device_removed(udev_device);
++                    device_added(udev_device);
++                }
+             }
+             else if (!strcmp(action, "remove"))
+                 device_removed(udev_device);
+diff --git a/dix/devices.c b/dix/devices.c
+index 9cf04ed..fd4916a 100644
+--- a/dix/devices.c
++++ b/dix/devices.c
+@@ -306,6 +306,9 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
+     /* unity matrix */
+     memset(transform, 0, sizeof(transform));
+     transform[0] = transform[4] = transform[8] = 1.0f;
++    dev->transform.m[0][0] = 1.0;
++    dev->transform.m[1][1] = 1.0;
++    dev->transform.m[2][2] = 1.0;
+ 
+     XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_TRANSFORM),
+                            XIGetKnownProperty(XATOM_FLOAT), 32,
+@@ -440,6 +443,7 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
+     if (*prev != dev)
+         return FALSE;
  
--     rep.type = X_Reply;
-+    rep.type = X_Reply;
-     if ((char *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr)
--         rep.vendorLength = strlen((char *) (VidModeGetMonitorValue(monitor,
--                                                                    VIDMODE_MON_VENDOR,
--                                                                    0)).ptr);
-+        rep.vendorLength = strlen((char *) (VidModeGetMonitorValue(monitor,
-+                                                                   VIDMODE_MON_VENDOR,
-+                                                                   0)).ptr);
++    TouchEndPhysicallyActiveTouches(dev);
+     ReleaseButtonsAndKeys(dev);
+     SyncRemoveDeviceIdleTime(dev->idle_counter);
+     dev->idle_counter = NULL;
+diff --git a/dix/events.c b/dix/events.c
+index 3b40446..ddb5b34 100644
+--- a/dix/events.c
++++ b/dix/events.c
+@@ -1555,11 +1555,13 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time,
+     WindowPtr oldWin;
+ 
+     /* slave devices need to float for the duration of the grab. */
+-    if (grab->grabtype == XI2 &&
++    if (grab->grabtype == XI2 && keybd->enabled &&
+         !(passive & ImplicitGrabMask) && !IsMaster(keybd))
+         DetachFromMaster(keybd);
+ 
+-    if (grabinfo->grab)
++    if (!keybd->enabled)
++        oldWin = NULL;
++    else if (grabinfo->grab)
+         oldWin = grabinfo->grab->window;
+     else if (keybd->focus)
+         oldWin = keybd->focus->win;
+@@ -1569,7 +1571,8 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time,
+         oldWin = keybd->focus->win;
+     if (keybd->valuator)
+         keybd->valuator->motionHintWindow = NullWindow;
+-    DoFocusEvents(keybd, oldWin, grab->window, NotifyGrab);
++    if (oldWin)
++        DoFocusEvents(keybd, oldWin, grab->window, NotifyGrab);
+     if (syncEvents.playingEvents)
+         grabinfo->grabTime = syncEvents.time;
      else
--         rep.vendorLength = 0;
-+        rep.vendorLength = 0;
-     if ((char *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr)
--         rep.modelLength = strlen((char *) (VidModeGetMonitorValue(monitor,
--                                                                   VIDMODE_MON_MODEL,
--                                                                   0)).ptr);
-+        rep.modelLength = strlen((char *) (VidModeGetMonitorValue(monitor,
-+                                                                  VIDMODE_MON_MODEL,
-+                                                                  0)).ptr);
-     else
--         rep.modelLength = 0;
--     rep.length =
-+        rep.modelLength = 0;
-+    rep.length =
-         bytes_to_int32(SIZEOF(xXF86VidModeGetMonitorReply) -
-                        SIZEOF(xGenericReply) + (nHsync +
-                                                 nVrefresh) * sizeof(CARD32) +
-                        pad_to_int32(rep.vendorLength) +
-                        pad_to_int32(rep.modelLength));
--     rep.sequenceNumber = client->sequence;
--     rep.nhsync = nHsync;
--     rep.nvsync = nVrefresh;
--     hsyncdata = malloc(nHsync * sizeof(CARD32));
-+    rep.sequenceNumber = client->sequence;
-+    rep.nhsync = nHsync;
-+    rep.nvsync = nVrefresh;
-+    hsyncdata = malloc(nHsync * sizeof(CARD32));
-     if (!hsyncdata) {
-         return BadAlloc;
--    } vsyncdata = malloc(nVrefresh * sizeof(CARD32));
-+    }
-+    vsyncdata = malloc(nVrefresh * sizeof(CARD32));
- 
-     if (!vsyncdata) {
-         free(hsyncdata);
-@@ -1208,19 +1244,18 @@ static int
-     for (i = 0; i < nHsync; i++) {
-         hsyncdata[i] = (unsigned short) (VidModeGetMonitorValue(monitor,
-                                                                 VIDMODE_MON_HSYNC_LO,
--                                                                i)).
--            f | (unsigned
--                 short) (VidModeGetMonitorValue(monitor, VIDMODE_MON_HSYNC_HI,
--                                                i)).f << 16;
-+                                                                i)).f |
-+            (unsigned
-+             short) (VidModeGetMonitorValue(monitor, VIDMODE_MON_HSYNC_HI,
-+                                            i)).f << 16;
-     }
-     for (i = 0; i < nVrefresh; i++) {
-         vsyncdata[i] = (unsigned short) (VidModeGetMonitorValue(monitor,
-                                                                 VIDMODE_MON_VREFRESH_LO,
--                                                                i)).
--            f | (unsigned
--                 short) (VidModeGetMonitorValue(monitor,
--                                                VIDMODE_MON_VREFRESH_HI,
--                                                i)).f << 16;
-+                                                                i)).f |
-+            (unsigned
-+             short) (VidModeGetMonitorValue(monitor, VIDMODE_MON_VREFRESH_HI,
-+                                            i)).f << 16;
+@@ -1590,13 +1593,10 @@ DeactivateKeyboardGrab(DeviceIntPtr keybd)
+ {
+     GrabPtr grab = keybd->deviceGrab.grab;
+     DeviceIntPtr dev;
+-    WindowPtr focusWin = keybd->focus ? keybd->focus->win
+-        : keybd->spriteInfo->sprite->win;
++    WindowPtr focusWin;
+     Bool wasImplicit = (keybd->deviceGrab.fromPassiveGrab &&
+                         keybd->deviceGrab.implicitGrab);
+ 
+-    if (focusWin == FollowKeyboardWin)
+-        focusWin = inputInfo.keyboard->focus->win;
+     if (keybd->valuator)
+         keybd->valuator->motionHintWindow = NullWindow;
+     keybd->deviceGrab.grab = NullGrab;
+@@ -1607,6 +1607,17 @@ DeactivateKeyboardGrab(DeviceIntPtr keybd)
+         if (dev->deviceGrab.sync.other == grab)
+             dev->deviceGrab.sync.other = NullGrab;
      }
- 
-     if (client->swapped) {
-@@ -1249,38 +1284,40 @@ static int
- }
- 
- static int
-- ProcXF86VidModeGetViewPort(ClientPtr client) {
-+ProcXF86VidModeGetViewPort(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeGetViewPortReq);
-     xXF86VidModeGetViewPortReply rep;
-     int x, y;
- 
--     DEBUG_P("XF86VidModeGetViewPort");
-+    DEBUG_P("XF86VidModeGetViewPort");
- 
--     REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
-+    REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
- 
-     if (stuff->screen >= screenInfo.numScreens)
--         return BadValue;
-+        return BadValue;
- 
--     rep.type = X_Reply;
--     rep.length = 0;
--     rep.sequenceNumber = client->sequence;
-+    rep.type = X_Reply;
-+    rep.length = 0;
-+    rep.sequenceNumber = client->sequence;
- 
--     VidModeGetViewPort(stuff->screen, &x, &y);
--     rep.x = x;
--     rep.y = y;
-+    VidModeGetViewPort(stuff->screen, &x, &y);
-+    rep.x = x;
-+    rep.y = y;
- 
-     if (client->swapped) {
-         swaps(&rep.sequenceNumber);
-         swapl(&rep.length);
-         swapl(&rep.x);
-         swapl(&rep.y);
--    } WriteToClient(client, SIZEOF(xXF86VidModeGetViewPortReply),
--                    (char *) &rep);
-+    }
-+    WriteToClient(client, SIZEOF(xXF86VidModeGetViewPortReply), (char *) &rep);
-     return Success;
- }
- 
- static int
-- ProcXF86VidModeSetViewPort(ClientPtr client) {
-+ProcXF86VidModeSetViewPort(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeSetViewPortReq);
- 
-     DEBUG_P("XF86VidModeSetViewPort");
-@@ -1294,8 +1331,11 @@ static int
-         return BadValue;
- 
-     return Success;
--} static int
-- ProcXF86VidModeGetDotClocks(ClientPtr client) {
-+}
 +
-+static int
-+ProcXF86VidModeGetDotClocks(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeGetDotClocksReq);
-     xXF86VidModeGetDotClocksReply rep;
-     int n;
-@@ -1304,31 +1344,33 @@ static int
-     int *Clocks = NULL;
-     Bool ClockProg;
- 
--     DEBUG_P("XF86VidModeGetDotClocks");
-+    DEBUG_P("XF86VidModeGetDotClocks");
- 
--     REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
-+    REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
- 
-     if (stuff->screen >= screenInfo.numScreens)
--         return BadValue;
-+        return BadValue;
- 
--     numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg);
-+    numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg);
- 
--     rep.type = X_Reply;
--     rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetDotClocksReply)
--                                 - SIZEOF(xGenericReply) + numClocks);
--     rep.sequenceNumber = client->sequence;
--     rep.clocks = numClocks;
--     rep.maxclocks = MAXCLOCKS;
--     rep.flags = 0;
-+    rep.type = X_Reply;
-+    rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetDotClocksReply)
-+                                - SIZEOF(xGenericReply) + numClocks);
-+    rep.sequenceNumber = client->sequence;
-+    rep.clocks = numClocks;
-+    rep.maxclocks = MAXCLOCKS;
-+    rep.flags = 0;
- 
-     if (!ClockProg) {
-         Clocks = malloc(numClocks * sizeof(int));
-         if (!Clocks)
--             return BadValue;
-+            return BadValue;
-         if (!VidModeGetClocks(stuff->screen, Clocks)) {
-             free(Clocks);
-             return BadValue;
--    }} if (ClockProg) {
-+        }
-+    }
-+    if (ClockProg) {
-         rep.flags |= CLKFLAG_PROGRAMABLE;
-     }
-     if (client->swapped) {
-@@ -1356,7 +1398,8 @@ static int
- }
- 
- static int
-- ProcXF86VidModeSetGamma(ClientPtr client) {
-+ProcXF86VidModeSetGamma(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeSetGammaReq);
- 
-     DEBUG_P("XF86VidModeSetGamma");
-@@ -1372,79 +1415,89 @@ static int
-         return BadValue;
- 
-     return Success;
--} static int
-- ProcXF86VidModeGetGamma(ClientPtr client) {
-+}
++    if (keybd->focus)
++        focusWin = keybd->focus->win;
++    else if (keybd->spriteInfo->sprite)
++        focusWin = keybd->spriteInfo->sprite->win;
++    else
++        focusWin = NullWindow;
 +
-+static int
-+ProcXF86VidModeGetGamma(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeGetGammaReq);
-     xXF86VidModeGetGammaReply rep;
-     float red, green, blue;
- 
--     DEBUG_P("XF86VidModeGetGamma");
-+    DEBUG_P("XF86VidModeGetGamma");
++    if (focusWin == FollowKeyboardWin)
++        focusWin = inputInfo.keyboard->focus->win;
++
+     DoFocusEvents(keybd, grab->window, focusWin, NotifyUngrab);
  
--     REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
-+    REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
+     if (!wasImplicit && grab->grabtype == XI2)
+diff --git a/dix/getevents.c b/dix/getevents.c
+index 4e62507..8b4379d 100644
+--- a/dix/getevents.c
++++ b/dix/getevents.c
+@@ -896,9 +896,9 @@ scale_to_desktop(DeviceIntPtr dev, ValuatorMask *mask,
+ 
+     /* scale x&y to desktop coordinates */
+     *screenx = rescaleValuatorAxis(x, dev->valuator->axes + 0, NULL,
+-                                   screenInfo.x, screenInfo.width);
++                                   screenInfo.x, screenInfo.width - 1);
+     *screeny = rescaleValuatorAxis(y, dev->valuator->axes + 1, NULL,
+-                                   screenInfo.y, screenInfo.height);
++                                   screenInfo.y, screenInfo.height - 1);
+ 
+     *devx = x;
+     *devy = y;
+@@ -1400,8 +1400,9 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
+        coordinates were.
+      */
+     if (flags & POINTER_SCREEN) {
+-        screenx = sx;
+-        screeny = sy;
++        scr = miPointerGetScreen(pDev);
++        screenx = sx + scr->x;
++        screeny = sy + scr->y;
+     }
  
-     if (stuff->screen >= screenInfo.numScreens)
--         return BadValue;
-+        return BadValue;
+     scr = positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative,
+diff --git a/dix/touch.c b/dix/touch.c
+index 497ad7d..5f77be5 100644
+--- a/dix/touch.c
++++ b/dix/touch.c
+@@ -572,8 +572,8 @@ TouchBuildSprite(DeviceIntPtr sourcedev, TouchPointInfoPtr ti,
+         return FALSE;
  
--     rep.type = X_Reply;
--     rep.length = 0;
--     rep.sequenceNumber = client->sequence;
-+    rep.type = X_Reply;
-+    rep.length = 0;
-+    rep.sequenceNumber = client->sequence;
-     if (!VidModeGetGamma(stuff->screen, &red, &green, &blue))
--         return BadValue;
--     rep.red = (CARD32) (red * 10000.);
--     rep.green = (CARD32) (green * 10000.);
--     rep.blue = (CARD32) (blue * 10000.);
-+        return BadValue;
-+    rep.red = (CARD32) (red * 10000.);
-+    rep.green = (CARD32) (green * 10000.);
-+    rep.blue = (CARD32) (blue * 10000.);
-     if (client->swapped) {
-         swaps(&rep.sequenceNumber);
-         swapl(&rep.length);
-         swapl(&rep.red);
-         swapl(&rep.green);
-         swapl(&rep.blue);
--    } WriteToClient(client, sizeof(xXF86VidModeGetGammaReply), (char *) &rep);
-+    }
-+    WriteToClient(client, sizeof(xXF86VidModeGetGammaReply), (char *) &rep);
+     /* Mark which grabs/event selections we're delivering to: max one grab per
+-     * window plus the bottom-most event selection. */
+-    ti->listeners = calloc(sprite->spriteTraceGood + 1, sizeof(*ti->listeners));
++     * window plus the bottom-most event selection, plus any active grab. */
++    ti->listeners = calloc(sprite->spriteTraceGood + 2, sizeof(*ti->listeners));
+     if (!ti->listeners) {
+         sprite->spriteTraceGood = 0;
+         return FALSE;
+@@ -1029,3 +1029,31 @@ TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
  
-     return Success;
+     return TouchListenerAcceptReject(dev, ti, i, mode);
  }
- 
- static int
-- ProcXF86VidModeSetGammaRamp(ClientPtr client) {
-+ProcXF86VidModeSetGammaRamp(ClientPtr client)
++
++/**
++ * End physically active touches for a device.
++ */
++void
++TouchEndPhysicallyActiveTouches(DeviceIntPtr dev)
 +{
-     CARD16 *r, *g, *b;
-     int length;
--     REQUEST(xXF86VidModeSetGammaRampReq);
++    InternalEvent *eventlist = InitEventList(GetMaximumEventsNum());
++    int i;
 +
-+    REQUEST(xXF86VidModeSetGammaRampReq);
- 
-     if (stuff->screen >= screenInfo.numScreens)
--         return BadValue;
-+        return BadValue;
- 
-     if (stuff->size != VidModeGetGammaRampSize(stuff->screen))
--         return BadValue;
-+        return BadValue;
- 
--     length = (stuff->size + 1) & ~1;
-+    length = (stuff->size + 1) & ~1;
- 
--     REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length * 6);
-+    REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length * 6);
- 
--     r = (CARD16 *) &stuff[1];
--     g = r + length;
--     b = g + length;
-+    r = (CARD16 *) &stuff[1];
-+    g = r + length;
-+    b = g + length;
- 
-     if (!VidModeSetGammaRamp(stuff->screen, stuff->size, r, g, b))
--         return BadValue;
-+        return BadValue;
- 
--     return Success;
--} static int
-- ProcXF86VidModeGetGammaRamp(ClientPtr client) {
-+    return Success;
-+}
++    OsBlockSignals();
++    mieqProcessInputEvents();
++    for (i = 0; i < dev->last.num_touches; i++) {
++        DDXTouchPointInfoPtr ddxti = dev->last.touches + i;
 +
-+static int
-+ProcXF86VidModeGetGammaRamp(ClientPtr client)
-+{
-     CARD16 *ramp = NULL;
-     int length;
-     size_t ramplen = 0;
-     xXF86VidModeGetGammaRampReply rep;
--     REQUEST(xXF86VidModeGetGammaRampReq);
++        if (ddxti->active) {
++            int j;
++            int nevents = GetTouchEvents(eventlist, dev, ddxti->ddx_id,
++                                         XI_TouchEnd, 0, NULL);
 +
-+    REQUEST(xXF86VidModeGetGammaRampReq);
- 
-     if (stuff->screen >= screenInfo.numScreens)
--         return BadValue;
-+        return BadValue;
- 
-     if (stuff->size != VidModeGetGammaRampSize(stuff->screen))
--         return BadValue;
-+        return BadValue;
- 
--     REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
-+    REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
- 
--     length = (stuff->size + 1) & ~1;
-+    length = (stuff->size + 1) & ~1;
- 
-     if (stuff->size) {
-         ramplen = length * 3 * sizeof(CARD16);
-@@ -1455,7 +1508,9 @@ static int
-                                  ramp, ramp + length, ramp + (length * 2))) {
-             free(ramp);
-             return BadValue;
--    }} rep.type = X_Reply;
++            for (j = 0; j < nevents; j++)
++                mieqProcessDeviceEvent(dev, eventlist + j, NULL);
 +        }
 +    }
-+    rep.type = X_Reply;
-     rep.length = (length >> 1) * 3;
-     rep.sequenceNumber = client->sequence;
-     rep.size = stuff->size;
-@@ -1476,47 +1531,53 @@ static int
- }
- 
- static int
-- ProcXF86VidModeGetGammaRampSize(ClientPtr client) {
-+ProcXF86VidModeGetGammaRampSize(ClientPtr client)
-+{
-     xXF86VidModeGetGammaRampSizeReply rep;
--     REQUEST(xXF86VidModeGetGammaRampSizeReq);
++    OsReleaseSignals();
 +
-+    REQUEST(xXF86VidModeGetGammaRampSizeReq);
- 
-     if (stuff->screen >= screenInfo.numScreens)
--         return BadValue;
-+        return BadValue;
- 
--     REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
-+    REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
- 
--     rep.type = X_Reply;
--     rep.length = 0;
--     rep.sequenceNumber = client->sequence;
--     rep.size = VidModeGetGammaRampSize(stuff->screen);
-+    rep.type = X_Reply;
-+    rep.length = 0;
-+    rep.sequenceNumber = client->sequence;
-+    rep.size = VidModeGetGammaRampSize(stuff->screen);
-     if (client->swapped) {
-         swaps(&rep.sequenceNumber);
-         swapl(&rep.length);
-         swaps(&rep.size);
--    } WriteToClient(client, sizeof(xXF86VidModeGetGammaRampSizeReply),
--                    (char *) &rep);
-+    }
-+    WriteToClient(client, sizeof(xXF86VidModeGetGammaRampSizeReply),
-+                  (char *) &rep);
- 
-     return Success;
- }
- 
- static int
-- ProcXF86VidModeGetPermissions(ClientPtr client) {
-+ProcXF86VidModeGetPermissions(ClientPtr client)
-+{
-     xXF86VidModeGetPermissionsReply rep;
--     REQUEST(xXF86VidModeGetPermissionsReq);
++    FreeEventList(eventlist, GetMaximumEventsNum());
++}
+diff --git a/exa/exa_priv.h b/exa/exa_priv.h
+index ea7e7fa..2e4759d 100644
+--- a/exa/exa_priv.h
++++ b/exa/exa_priv.h
+@@ -209,6 +209,7 @@ typedef struct {
+     RegionRec srcReg;
+     RegionRec maskReg;
+     PixmapPtr srcPix;
++    PixmapPtr maskPix;
+ 
+     DevPrivateKeyRec pixmapPrivateKeyRec;
+     DevPrivateKeyRec gcPrivateKeyRec;
+diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
+index 5716138..b0a0011 100644
+--- a/exa/exa_unaccel.c
++++ b/exa/exa_unaccel.c
+@@ -442,6 +442,13 @@ ExaSrcValidate(DrawablePtr pDrawable,
+     RegionPtr dst;
+     int xoff, yoff;
+ 
++    if (pExaScr->srcPix == pPix)
++        dst = &pExaScr->srcReg;
++    else if (pExaScr->maskPix == pPix)
++        dst = &pExaScr->maskReg;
++    else
++        return;
 +
-+    REQUEST(xXF86VidModeGetPermissionsReq);
+     exaGetDrawableDeltas(pDrawable, pPix, &xoff, &yoff);
  
-     if (stuff->screen >= screenInfo.numScreens)
--         return BadValue;
-+        return BadValue;
+     box.x1 = x + xoff;
+@@ -449,8 +456,6 @@ ExaSrcValidate(DrawablePtr pDrawable,
+     box.x2 = box.x1 + width;
+     box.y2 = box.y1 + height;
  
--     REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
-+    REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
- 
--     rep.type = X_Reply;
--     rep.length = 0;
--     rep.sequenceNumber = client->sequence;
--     rep.permissions = XF86VM_READ_PERMISSION;
-+    rep.type = X_Reply;
-+    rep.length = 0;
-+    rep.sequenceNumber = client->sequence;
-+    rep.permissions = XF86VM_READ_PERMISSION;
-     if (xf86GetVidModeEnabled() &&
-         (xf86GetVidModeAllowNonLocal() || LocalClient(client))) {
-         rep.permissions |= XF86VM_WRITE_PERMISSION;
--    } if (client->swapped) {
-+    }
-+    if (client->swapped) {
-         swaps(&rep.sequenceNumber);
-         swapl(&rep.length);
-         swapl(&rep.permissions);
-@@ -1528,21 +1589,23 @@ static int
- }
- 
- static int
-- ProcXF86VidModeSetClientVersion(ClientPtr client) {
-+ProcXF86VidModeSetClientVersion(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeSetClientVersionReq);
- 
-     VidModePrivPtr pPriv;
- 
--     DEBUG_P("XF86VidModeSetClientVersion");
-+    DEBUG_P("XF86VidModeSetClientVersion");
- 
--     REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
-+    REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
- 
-     if ((pPriv = VM_GETPRIV(client)) == NULL) {
-         pPriv = malloc(sizeof(VidModePrivRec));
-         if (!pPriv)
-             return BadAlloc;
-         VM_SETPRIV(client, pPriv);
--    } pPriv->major = stuff->major;
-+    }
-+    pPriv->major = stuff->major;
- 
-     pPriv->minor = stuff->minor;
- 
-@@ -1550,85 +1613,103 @@ static int
- }
+-    dst = (pExaScr->srcPix == pPix) ? &pExaScr->srcReg : &pExaScr->maskReg;
+-
+     RegionInit(&reg, &box, 1);
+     RegionUnion(dst, dst, &reg);
+     RegionUninit(&reg);
+@@ -495,16 +500,19 @@ ExaPrepareCompositeReg(ScreenPtr pScreen,
+         if (pSrc != pDst)
+             RegionTranslate(pSrc->pCompositeClip,
+                             -pSrc->pDrawable->x, -pSrc->pDrawable->y);
+-    }
++    } else
++        pExaScr->srcPix = NULL;
+ 
+     if (pMask && pMask->pDrawable) {
+         pMaskPix = exaGetDrawablePixmap(pMask->pDrawable);
+         RegionNull(&pExaScr->maskReg);
+         maskReg = &pExaScr->maskReg;
++        pExaScr->maskPix = pMaskPix;
+         if (pMask != pDst && pMask != pSrc)
+             RegionTranslate(pMask->pCompositeClip,
+                             -pMask->pDrawable->x, -pMask->pDrawable->y);
+-    }
++    } else
++        pExaScr->maskPix = NULL;
+ 
+     RegionTranslate(pDst->pCompositeClip,
+                     -pDst->pDrawable->x, -pDst->pDrawable->y);
+diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
+index f8fcde9..532d87b 100644
+--- a/hw/xfree86/common/Makefile.am
++++ b/hw/xfree86/common/Makefile.am
+@@ -15,6 +15,7 @@ XVSDKINCS = xf86xv.h xf86xvmc.h xf86xvpriv.h
+ endif
+ 
+ if XF86VIDMODE
++XF86VMODESOURCES = xf86vmode.c
+ XF86VMODE_SDK = vidmodeproc.h
+ endif
+ 
+@@ -47,7 +48,7 @@ libcommon_la_SOURCES = xf86Configure.c xf86Bus.c xf86Config.c \
+                       xf86VidMode.c xf86fbman.c xf86cmap.c \
+                       xf86Helper.c xf86PM.c xf86Xinput.c xisb.c \
+                       xf86Mode.c xorgHelper.c xf86Extensions.h \
+-		      xf86Extensions.c xf86vmode.c \
++		      xf86Extensions.c $(XF86VMODESOURCES) \
+                       $(XVSOURCES) $(BUSSOURCES) $(RANDRSOURCES)
+ nodist_libcommon_la_SOURCES = xf86DefModeSet.c xf86Build.h
+ libcommon_la_LIBADD = $(top_builddir)/config/libconfig.la
+diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
+index bb2903d..74da438 100644
+--- a/hw/xfree86/common/xf86.h
++++ b/hw/xfree86/common/xf86.h
+@@ -468,4 +468,8 @@ extern _X_EXPORT ScreenPtr xf86ScrnToScreen(ScrnInfoPtr pScrn);
+ /* flags passed to xf86 allocate screen */
+ #define XF86_ALLOCATE_GPU_SCREEN 1
+ 
++/* Update the internal total dimensions of all ScreenRecs together */
++extern _X_EXPORT void
++xf86UpdateDesktopDimensions(void);
++
+ #endif                          /* _XF86_H */
+diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
+index 6de8409..4ffbf7e 100644
+--- a/hw/xfree86/common/xf86Bus.c
++++ b/hw/xfree86/common/xf86Bus.c
+@@ -81,6 +81,8 @@ xf86CallDriverProbe(DriverPtr drv, Bool detect_only)
+     if (drv->platformProbe != NULL) {
+         foundScreen = xf86platformProbeDev(drv);
+     }
++    if (ServerIsNotSeat0())
++        return foundScreen;
+ #endif
  
- static int
-- ProcXF86VidModeDispatch(ClientPtr client) {
-+ProcXF86VidModeDispatch(ClientPtr client)
-+{
-     REQUEST(xReq);
-     switch (stuff->data) {
-     case X_XF86VidModeQueryVersion:
-         return ProcXF86VidModeQueryVersion(client);
--        case X_XF86VidModeGetModeLine:return ProcXF86VidModeGetModeLine(client);
--        case X_XF86VidModeGetMonitor:return ProcXF86VidModeGetMonitor(client);
--        case X_XF86VidModeGetAllModeLines:return
--            ProcXF86VidModeGetAllModeLines(client);
--        case X_XF86VidModeValidateModeLine:return
--            ProcXF86VidModeValidateModeLine(client);
--        case X_XF86VidModeGetViewPort:return ProcXF86VidModeGetViewPort(client);
--        case X_XF86VidModeGetDotClocks:return
--            ProcXF86VidModeGetDotClocks(client);
--        case X_XF86VidModeSetClientVersion:return
--            ProcXF86VidModeSetClientVersion(client);
--        case X_XF86VidModeGetGamma:return ProcXF86VidModeGetGamma(client);
--        case X_XF86VidModeGetGammaRamp:return
--            ProcXF86VidModeGetGammaRamp(client);
--        case X_XF86VidModeGetGammaRampSize:return
--            ProcXF86VidModeGetGammaRampSize(client);
--        case X_XF86VidModeGetPermissions:return
--            ProcXF86VidModeGetPermissions(client);
--        default:if (!xf86GetVidModeEnabled())
-+    case X_XF86VidModeGetModeLine:
-+        return ProcXF86VidModeGetModeLine(client);
-+    case X_XF86VidModeGetMonitor:
-+        return ProcXF86VidModeGetMonitor(client);
-+    case X_XF86VidModeGetAllModeLines:
-+        return ProcXF86VidModeGetAllModeLines(client);
-+    case X_XF86VidModeValidateModeLine:
-+        return ProcXF86VidModeValidateModeLine(client);
-+    case X_XF86VidModeGetViewPort:
-+        return ProcXF86VidModeGetViewPort(client);
-+    case X_XF86VidModeGetDotClocks:
-+        return ProcXF86VidModeGetDotClocks(client);
-+    case X_XF86VidModeSetClientVersion:
-+        return ProcXF86VidModeSetClientVersion(client);
-+    case X_XF86VidModeGetGamma:
-+        return ProcXF86VidModeGetGamma(client);
-+    case X_XF86VidModeGetGammaRamp:
-+        return ProcXF86VidModeGetGammaRamp(client);
-+    case X_XF86VidModeGetGammaRampSize:
-+        return ProcXF86VidModeGetGammaRampSize(client);
-+    case X_XF86VidModeGetPermissions:
-+        return ProcXF86VidModeGetPermissions(client);
-+    default:
-+        if (!xf86GetVidModeEnabled())
-             return VidModeErrorBase + XF86VidModeExtensionDisabled;
-         if (xf86GetVidModeAllowNonLocal() || LocalClient(client)) {
-             switch (stuff->data) {
-             case X_XF86VidModeAddModeLine:
-                 return ProcXF86VidModeAddModeLine(client);
--                case X_XF86VidModeDeleteModeLine:return
--                    ProcXF86VidModeDeleteModeLine(client);
--                case X_XF86VidModeModModeLine:return
--                    ProcXF86VidModeModModeLine(client);
--                case X_XF86VidModeSwitchMode:return
--                    ProcXF86VidModeSwitchMode(client);
--                case X_XF86VidModeSwitchToMode:return
--                    ProcXF86VidModeSwitchToMode(client);
--                case X_XF86VidModeLockModeSwitch:return
--                    ProcXF86VidModeLockModeSwitch(client);
--                case X_XF86VidModeSetViewPort:return
--                    ProcXF86VidModeSetViewPort(client);
--                case X_XF86VidModeSetGamma:return
--                    ProcXF86VidModeSetGamma(client);
--                case X_XF86VidModeSetGammaRamp:return
--                    ProcXF86VidModeSetGammaRamp(client);
--                default:return BadRequest;
--        }}
-+            case X_XF86VidModeDeleteModeLine:
-+                return ProcXF86VidModeDeleteModeLine(client);
-+            case X_XF86VidModeModModeLine:
-+                return ProcXF86VidModeModModeLine(client);
-+            case X_XF86VidModeSwitchMode:
-+                return ProcXF86VidModeSwitchMode(client);
-+            case X_XF86VidModeSwitchToMode:
-+                return ProcXF86VidModeSwitchToMode(client);
-+            case X_XF86VidModeLockModeSwitch:
-+                return ProcXF86VidModeLockModeSwitch(client);
-+            case X_XF86VidModeSetViewPort:
-+                return ProcXF86VidModeSetViewPort(client);
-+            case X_XF86VidModeSetGamma:
-+                return ProcXF86VidModeSetGamma(client);
-+            case X_XF86VidModeSetGammaRamp:
-+                return ProcXF86VidModeSetGammaRamp(client);
-+            default:
-+                return BadRequest;
-+            }
-+        }
-         else
--             return VidModeErrorBase + XF86VidModeClientNotLocal;
-+            return VidModeErrorBase + XF86VidModeClientNotLocal;
+ #ifdef XSERVER_LIBPCIACCESS
+@@ -214,6 +216,8 @@ xf86BusProbe(void)
+ {
+ #ifdef XSERVER_PLATFORM_BUS
+     xf86platformProbe();
++    if (ServerIsNotSeat0())
++        return;
+ #endif
+ #ifdef XSERVER_LIBPCIACCESS
+     xf86PciProbe();
+diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
+index f681a85..721159d 100644
+--- a/hw/xfree86/common/xf86Helper.c
++++ b/hw/xfree86/common/xf86Helper.c
+@@ -1898,3 +1898,9 @@ xf86ScrnToScreen(ScrnInfoPtr pScrn)
+         return screenInfo.screens[pScrn->scrnIndex];
      }
  }
- 
- static int
-- SProcXF86VidModeQueryVersion(ClientPtr client) {
-+SProcXF86VidModeQueryVersion(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeQueryVersionReq);
-     swaps(&stuff->length);
-     return ProcXF86VidModeQueryVersion(client);
--} static int
-- SProcXF86VidModeGetModeLine(ClientPtr client) {
-+}
 +
-+static int
-+SProcXF86VidModeGetModeLine(ClientPtr client)
++void
++xf86UpdateDesktopDimensions(void)
 +{
-     REQUEST(xXF86VidModeGetModeLineReq);
-     swaps(&stuff->length);
-     REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
-     swaps(&stuff->screen);
-     return ProcXF86VidModeGetModeLine(client);
--} static int
-- SProcXF86VidModeGetAllModeLines(ClientPtr client) {
++    update_desktop_dimensions();
 +}
-+
-+static int
-+SProcXF86VidModeGetAllModeLines(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeGetAllModeLinesReq);
-     swaps(&stuff->length);
-     REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
-     swaps(&stuff->screen);
-     return ProcXF86VidModeGetAllModeLines(client);
--} static int
-- SProcXF86VidModeAddModeLine(ClientPtr client) {
-+}
-+
-+static int
-+SProcXF86VidModeAddModeLine(ClientPtr client)
-+{
-     xXF86OldVidModeAddModeLineReq *oldstuff =
-         (xXF86OldVidModeAddModeLineReq *) client->requestBuffer;
-     int ver;
- 
--     REQUEST(xXF86VidModeAddModeLineReq);
--     ver = ClientMajorVersion(client);
-+    REQUEST(xXF86VidModeAddModeLineReq);
-+    ver = ClientMajorVersion(client);
-     if (ver < 2) {
-         swaps(&oldstuff->length);
-         REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
-@@ -1666,13 +1747,14 @@ static int
- }
- 
- static int
-- SProcXF86VidModeDeleteModeLine(ClientPtr client) {
-+SProcXF86VidModeDeleteModeLine(ClientPtr client)
-+{
-     xXF86OldVidModeDeleteModeLineReq *oldstuff =
-         (xXF86OldVidModeDeleteModeLineReq *) client->requestBuffer;
-     int ver;
- 
--     REQUEST(xXF86VidModeDeleteModeLineReq);
--     ver = ClientMajorVersion(client);
-+    REQUEST(xXF86VidModeDeleteModeLineReq);
-+    ver = ClientMajorVersion(client);
-     if (ver < 2) {
-         swaps(&oldstuff->length);
-         REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
-@@ -1710,13 +1792,14 @@ static int
- }
- 
- static int
-- SProcXF86VidModeModModeLine(ClientPtr client) {
-+SProcXF86VidModeModModeLine(ClientPtr client)
-+{
-     xXF86OldVidModeModModeLineReq *oldstuff =
-         (xXF86OldVidModeModModeLineReq *) client->requestBuffer;
-     int ver;
- 
--     REQUEST(xXF86VidModeModModeLineReq);
--     ver = ClientMajorVersion(client);
-+    REQUEST(xXF86VidModeModModeLineReq);
-+    ver = ClientMajorVersion(client);
-     if (ver < 2) {
-         swaps(&oldstuff->length);
-         REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
-@@ -1754,13 +1837,14 @@ static int
- }
+diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
+index 83f9790..f58b87e 100644
+--- a/hw/xfree86/common/xf86Module.h
++++ b/hw/xfree86/common/xf86Module.h
+@@ -80,7 +80,7 @@ typedef enum {
+  * mask is 0xFFFF0000.
+  */
+ #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 4)
+-#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(13, 0)
++#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(13, 1)
+ #define ABI_XINPUT_VERSION	SET_ABI_VERSION(18, 0)
+ #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(7, 0)
+ #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 6)
+diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
+index 24b9473..0525e39 100644
+--- a/hw/xfree86/common/xf86platformBus.c
++++ b/hw/xfree86/common/xf86platformBus.c
+@@ -213,11 +213,12 @@ xf86platformProbe(void)
+     int i;
+     Bool pci = TRUE;
  
- static int
-- SProcXF86VidModeValidateModeLine(ClientPtr client) {
-+SProcXF86VidModeValidateModeLine(ClientPtr client)
-+{
-     xXF86OldVidModeValidateModeLineReq *oldstuff =
-         (xXF86OldVidModeValidateModeLineReq *) client->requestBuffer;
-     int ver;
++    config_odev_probe(xf86PlatformDeviceProbe);
++
+     if (!xf86scanpci()) {
+         pci = FALSE;
+     }
  
--     REQUEST(xXF86VidModeValidateModeLineReq);
--     ver = ClientMajorVersion(client);
-+    REQUEST(xXF86VidModeValidateModeLineReq);
-+    ver = ClientMajorVersion(client);
-     if (ver < 2) {
-         swaps(&oldstuff->length);
-         REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
-@@ -1798,44 +1882,60 @@ static int
+-    config_odev_probe(&xf86PlatformDeviceProbe);
+     for (i = 0; i < xf86_num_platform_devices; i++) {
+         char *busid = xf86_get_platform_attrib(i, ODEV_ATTRIB_BUSID);
+ 
+@@ -358,6 +359,9 @@ xf86platformProbeDev(DriverPtr drvp)
+                     break;
+             }
+             else {
++                /* for non-seat0 servers assume first device is the master */
++                if (ServerIsNotSeat0())
++                    break;
+                 if (xf86_platform_devices[j].pdev) {
+                     if (xf86IsPrimaryPlatform(&xf86_platform_devices[j]))
+                         break;
+diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
+index 23f589c..40963c3 100644
+--- a/hw/xfree86/dri2/dri2.c
++++ b/hw/xfree86/dri2/dri2.c
+@@ -766,6 +766,44 @@ static inline PixmapPtr GetDrawablePixmap(DrawablePtr drawable)
+     }
  }
  
- static int
-- SProcXF86VidModeSwitchMode(ClientPtr client) {
-+SProcXF86VidModeSwitchMode(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeSwitchModeReq);
-     swaps(&stuff->length);
-     REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq);
-     swaps(&stuff->screen);
-     swaps(&stuff->zoom);
-     return ProcXF86VidModeSwitchMode(client);
--} static int
-- SProcXF86VidModeSwitchToMode(ClientPtr client) {
-+}
-+
-+static int
-+SProcXF86VidModeSwitchToMode(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeSwitchToModeReq);
-     swaps(&stuff->length);
-     REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq);
-     swapl(&stuff->screen);
-     return ProcXF86VidModeSwitchToMode(client);
--} static int
-- SProcXF86VidModeLockModeSwitch(ClientPtr client) {
-+}
-+
-+static int
-+SProcXF86VidModeLockModeSwitch(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeLockModeSwitchReq);
-     swaps(&stuff->length);
-     REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
-     swaps(&stuff->screen);
-     swaps(&stuff->lock);
-     return ProcXF86VidModeLockModeSwitch(client);
--} static int
-- SProcXF86VidModeGetMonitor(ClientPtr client) {
-+}
-+
-+static int
-+SProcXF86VidModeGetMonitor(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeGetMonitorReq);
-     swaps(&stuff->length);
-     REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
-     swaps(&stuff->screen);
-     return ProcXF86VidModeGetMonitor(client);
--} static int
-- SProcXF86VidModeGetViewPort(ClientPtr client) {
-+}
-+
-+static int
-+SProcXF86VidModeGetViewPort(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeGetViewPortReq);
-     swaps(&stuff->length);
-     REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
-     swaps(&stuff->screen);
-     return ProcXF86VidModeGetViewPort(client);
--} static int
-- SProcXF86VidModeSetViewPort(ClientPtr client) {
-+}
-+
-+static int
-+SProcXF86VidModeSetViewPort(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeSetViewPortReq);
-     swaps(&stuff->length);
-     REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
-@@ -1843,23 +1943,32 @@ static int
-     swapl(&stuff->x);
-     swapl(&stuff->y);
-     return ProcXF86VidModeSetViewPort(client);
--} static int
-- SProcXF86VidModeGetDotClocks(ClientPtr client) {
-+}
-+
-+static int
-+SProcXF86VidModeGetDotClocks(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeGetDotClocksReq);
-     swaps(&stuff->length);
-     REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
-     swaps(&stuff->screen);
-     return ProcXF86VidModeGetDotClocks(client);
--} static int
-- SProcXF86VidModeSetClientVersion(ClientPtr client) {
-+}
-+
++/*
++ * A TraverseTree callback to invalidate all windows using the same
++ * pixmap
++ */
 +static int
-+SProcXF86VidModeSetClientVersion(ClientPtr client)
++DRI2InvalidateWalk(WindowPtr pWin, pointer data)
 +{
-     REQUEST(xXF86VidModeSetClientVersionReq);
-     swaps(&stuff->length);
-     REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
-     swaps(&stuff->major);
-     swaps(&stuff->minor);
-     return ProcXF86VidModeSetClientVersion(client);
--} static int
-- SProcXF86VidModeSetGamma(ClientPtr client) {
++    if (pWin->drawable.pScreen->GetWindowPixmap(pWin) != data)
++        return WT_DONTWALKCHILDREN;
++    DRI2InvalidateDrawable(&pWin->drawable);
++    return WT_WALKCHILDREN;
 +}
 +
-+static int
-+SProcXF86VidModeSetGamma(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeSetGammaReq);
-     swaps(&stuff->length);
-     REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq);
-@@ -1868,120 +1977,145 @@ static int
-     swapl(&stuff->green);
-     swapl(&stuff->blue);
-     return ProcXF86VidModeSetGamma(client);
--} static int
-- SProcXF86VidModeGetGamma(ClientPtr client) {
-+}
-+
-+static int
-+SProcXF86VidModeGetGamma(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeGetGammaReq);
-     swaps(&stuff->length);
-     REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
-     swaps(&stuff->screen);
-     return ProcXF86VidModeGetGamma(client);
--} static int
-- SProcXF86VidModeSetGammaRamp(ClientPtr client) {
-+}
-+
-+static int
-+SProcXF86VidModeSetGammaRamp(ClientPtr client)
-+{
-     int length;
--     REQUEST(xXF86VidModeSetGammaRampReq);
--     swaps(&stuff->length);
--     REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq);
--     swaps(&stuff->size);
--     swaps(&stuff->screen);
--     length = ((stuff->size + 1) & ~1) * 6;
--     REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length);
--     SwapRestS(stuff);
--     return ProcXF86VidModeSetGammaRamp(client);
--} static int
-- SProcXF86VidModeGetGammaRamp(ClientPtr client) {
-+
-+    REQUEST(xXF86VidModeSetGammaRampReq);
-+    swaps(&stuff->length);
-+    REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq);
-+    swaps(&stuff->size);
-+    swaps(&stuff->screen);
-+    length = ((stuff->size + 1) & ~1) * 6;
-+    REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length);
-+    SwapRestS(stuff);
-+    return ProcXF86VidModeSetGammaRamp(client);
-+}
-+
-+static int
-+SProcXF86VidModeGetGammaRamp(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeGetGammaRampReq);
-     swaps(&stuff->length);
-     REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
-     swaps(&stuff->size);
-     swaps(&stuff->screen);
-     return ProcXF86VidModeGetGammaRamp(client);
--} static int
-- SProcXF86VidModeGetGammaRampSize(ClientPtr client) {
-+}
-+
-+static int
-+SProcXF86VidModeGetGammaRampSize(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeGetGammaRampSizeReq);
-     swaps(&stuff->length);
-     REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
-     swaps(&stuff->screen);
-     return ProcXF86VidModeGetGammaRampSize(client);
--} static int
-- SProcXF86VidModeGetPermissions(ClientPtr client) {
++static void
++DRI2InvalidateDrawableAll(DrawablePtr pDraw)
++{
++    if (pDraw->type == DRAWABLE_WINDOW) {
++        WindowPtr pWin = (WindowPtr) pDraw;
++        PixmapPtr pPixmap = pDraw->pScreen->GetWindowPixmap(pWin);
++
++        /*
++         * Find the top-most window using this pixmap
++         */
++        while (pWin->parent &&
++               pDraw->pScreen->GetWindowPixmap(pWin->parent) == pPixmap)
++            pWin = pWin->parent;
++
++        /*
++         * Walk the sub-tree to invalidate all of the
++         * windows using the same pixmap
++         */
++        TraverseTree(pWin, DRI2InvalidateWalk, pPixmap);
++        DRI2InvalidateDrawable(&pPixmap->drawable);
++    }
++    else
++        DRI2InvalidateDrawable(pDraw);
 +}
 +
-+static int
-+SProcXF86VidModeGetPermissions(ClientPtr client)
-+{
-     REQUEST(xXF86VidModeGetPermissionsReq);
-     swaps(&stuff->length);
-     REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
-     swaps(&stuff->screen);
-     return ProcXF86VidModeGetPermissions(client);
--} static int
-- SProcXF86VidModeDispatch(ClientPtr client) {
-+}
+ DrawablePtr DRI2UpdatePrime(DrawablePtr pDraw, DRI2BufferPtr pDest)
+ {
+     DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
+@@ -831,6 +869,8 @@ DrawablePtr DRI2UpdatePrime(DrawablePtr pDraw, DRI2BufferPtr pDest)
+     spix->screen_x = mpix->screen_x;
+     spix->screen_y = mpix->screen_y;
+ #endif
 +
-+static int
-+SProcXF86VidModeDispatch(ClientPtr client)
-+{
-     REQUEST(xReq);
-     switch (stuff->data) {
-     case X_XF86VidModeQueryVersion:
-         return SProcXF86VidModeQueryVersion(client);
--        case X_XF86VidModeGetModeLine:return
--            SProcXF86VidModeGetModeLine(client);
--        case X_XF86VidModeGetMonitor:return SProcXF86VidModeGetMonitor(client);
--        case X_XF86VidModeGetAllModeLines:return
--            SProcXF86VidModeGetAllModeLines(client);
--        case X_XF86VidModeGetViewPort:return
--            SProcXF86VidModeGetViewPort(client);
--        case X_XF86VidModeValidateModeLine:return
--            SProcXF86VidModeValidateModeLine(client);
--        case X_XF86VidModeGetDotClocks:return
--            SProcXF86VidModeGetDotClocks(client);
--        case X_XF86VidModeSetClientVersion:return
--            SProcXF86VidModeSetClientVersion(client);
--        case X_XF86VidModeGetGamma:return SProcXF86VidModeGetGamma(client);
--        case X_XF86VidModeGetGammaRamp:return
--            SProcXF86VidModeGetGammaRamp(client);
--        case X_XF86VidModeGetGammaRampSize:return
--            SProcXF86VidModeGetGammaRampSize(client);
--        case X_XF86VidModeGetPermissions:return
--            SProcXF86VidModeGetPermissions(client);
--        default:if (!xf86GetVidModeEnabled())
-+    case X_XF86VidModeGetModeLine:
-+        return SProcXF86VidModeGetModeLine(client);
-+    case X_XF86VidModeGetMonitor:
-+        return SProcXF86VidModeGetMonitor(client);
-+    case X_XF86VidModeGetAllModeLines:
-+        return SProcXF86VidModeGetAllModeLines(client);
-+    case X_XF86VidModeGetViewPort:
-+        return SProcXF86VidModeGetViewPort(client);
-+    case X_XF86VidModeValidateModeLine:
-+        return SProcXF86VidModeValidateModeLine(client);
-+    case X_XF86VidModeGetDotClocks:
-+        return SProcXF86VidModeGetDotClocks(client);
-+    case X_XF86VidModeSetClientVersion:
-+        return SProcXF86VidModeSetClientVersion(client);
-+    case X_XF86VidModeGetGamma:
-+        return SProcXF86VidModeGetGamma(client);
-+    case X_XF86VidModeGetGammaRamp:
-+        return SProcXF86VidModeGetGammaRamp(client);
-+    case X_XF86VidModeGetGammaRampSize:
-+        return SProcXF86VidModeGetGammaRampSize(client);
-+    case X_XF86VidModeGetPermissions:
-+        return SProcXF86VidModeGetPermissions(client);
-+    default:
-+        if (!xf86GetVidModeEnabled())
-             return VidModeErrorBase + XF86VidModeExtensionDisabled;
-         if (xf86GetVidModeAllowNonLocal() || LocalClient(client)) {
-             switch (stuff->data) {
-             case X_XF86VidModeAddModeLine:
-                 return SProcXF86VidModeAddModeLine(client);
--                case X_XF86VidModeDeleteModeLine:return
--                    SProcXF86VidModeDeleteModeLine(client);
--                case X_XF86VidModeModModeLine:return
--                    SProcXF86VidModeModModeLine(client);
--                case X_XF86VidModeSwitchMode:return
--                    SProcXF86VidModeSwitchMode(client);
--                case X_XF86VidModeSwitchToMode:return
--                    SProcXF86VidModeSwitchToMode(client);
--                case X_XF86VidModeLockModeSwitch:return
--                    SProcXF86VidModeLockModeSwitch(client);
--                case X_XF86VidModeSetViewPort:return
--                    SProcXF86VidModeSetViewPort(client);
--                case X_XF86VidModeSetGamma:return
--                    SProcXF86VidModeSetGamma(client);
--                case X_XF86VidModeSetGammaRamp:return
--                    SProcXF86VidModeSetGammaRamp(client);
--                default:return BadRequest;
--        }}
-+            case X_XF86VidModeDeleteModeLine:
-+                return SProcXF86VidModeDeleteModeLine(client);
-+            case X_XF86VidModeModModeLine:
-+                return SProcXF86VidModeModModeLine(client);
-+            case X_XF86VidModeSwitchMode:
-+                return SProcXF86VidModeSwitchMode(client);
-+            case X_XF86VidModeSwitchToMode:
-+                return SProcXF86VidModeSwitchToMode(client);
-+            case X_XF86VidModeLockModeSwitch:
-+                return SProcXF86VidModeLockModeSwitch(client);
-+            case X_XF86VidModeSetViewPort:
-+                return SProcXF86VidModeSetViewPort(client);
-+            case X_XF86VidModeSetGamma:
-+                return SProcXF86VidModeSetGamma(client);
-+            case X_XF86VidModeSetGammaRamp:
-+                return SProcXF86VidModeSetGammaRamp(client);
-+            default:
-+                return BadRequest;
-+            }
-+        }
-         else
--             return VidModeErrorBase + XF86VidModeClientNotLocal;
-+            return VidModeErrorBase + XF86VidModeClientNotLocal;
-     }
++    DRI2InvalidateDrawableAll(pDraw);
+     return &spix->drawable;
  }
  
- void
-- XFree86VidModeExtensionInit(void) {
-+XFree86VidModeExtensionInit(void)
-+{
-     ExtensionEntry *extEntry;
-     ScreenPtr pScreen;
-     int i;
-     Bool enabled = FALSE;
- 
--     DEBUG_P("XFree86VidModeExtensionInit");
-+    DEBUG_P("XFree86VidModeExtensionInit");
- 
-     if (!dixRegisterPrivateKey(&VidModeClientPrivateKeyRec, PRIVATE_CLIENT, 0))
--         return;
-+        return;
- #ifdef XF86VIDMODE_EVENTS
-     if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
--         return;
-+        return;
- #endif
- 
- #ifdef XF86VIDMODE_EVENTS
--     EventType = CreateNewResourceType(XF86VidModeFreeEvents, "VidModeEvent");
-+    EventType = CreateNewResourceType(XF86VidModeFreeEvents, "VidModeEvent");
- #endif
- 
-     for (i = 0; i < screenInfo.numScreens; i++) {
-@@ -1990,8 +2124,8 @@ void
-             enabled = TRUE;
-     }
-     /* This means that the DDX doesn't want the vidmode extension enabled */
--        if (!enabled)
--         return;
-+    if (!enabled)
-+        return;
- 
-     if (
- #ifdef XF86VIDMODE_EVENTS
---
-cgit v0.9.0.2-2-gbebe
-From 15607cf2dc87405606b20113011f1ebd97637d32 Mon Sep 17 00:00:00 2001
-From: Daniel Kurtz <djkurtz@chromium.org>
-Date: Thu, 12 Apr 2012 00:11:10 +0000
-Subject: dix: don't BUG_WARN for button events from button-only device
-
-Events from button-only devices still need coordinates, and they get them
-from scale_to_desktop().  Therefore, a dev without valuators is not a bug.
-However, a dev with valuators, but less than two of them still is a bug.
-
-This was noticed when unplugging a "Creative Technology SB Arena Headset",
-which has some BTNs and some KEYs, but no REL or ABS valuators.
-It emits [BTN_3] = 0 on unplug, which would trigger the BUG_WARN.
-
-Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
-Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-(cherry picked from commit c5a45b0f7658c77725adce2b64a0fbd62f208328)
----
-diff --git a/dix/getevents.c b/dix/getevents.c
-index 4e0af45..9dc9617 100644
---- a/dix/getevents.c
-+++ b/dix/getevents.c
-@@ -842,7 +842,7 @@ scale_to_desktop(DeviceIntPtr dev, ValuatorMask *mask,
-     ScreenPtr scr = miPointerGetScreen(dev);
-     double x, y;
+@@ -1048,18 +1088,7 @@ DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable)
+     return FALSE;
+ }
  
--    BUG_WARN(!dev->valuator || dev->valuator->numAxes < 2);
-+    BUG_WARN(dev->valuator && dev->valuator->numAxes < 2);
-     if (!dev->valuator || dev->valuator->numAxes < 2) {
-         /* if we have no axes, last.valuators must be in screen coords
-          * anyway */
---
-cgit v0.9.0.2-2-gbebe
-From f8d2ca759ad37d5e99d462f21a2259ce17bb1a00 Mon Sep 17 00:00:00 2001
-From: Peter Hutterer <peter.hutterer@who-t.net>
-Date: Wed, 18 Apr 2012 05:56:37 +0000
-Subject: dix: indentation fix
-
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-(cherry picked from commit ebf214876a4885a98ded4f5525925b69005fae05)
----
-diff --git a/dix/dispatch.c b/dix/dispatch.c
-index 9a2e22f..d971805 100644
---- a/dix/dispatch.c
-+++ b/dix/dispatch.c
-@@ -416,8 +416,8 @@ Dispatch(void)
-                 if (XSERVER_REQUEST_START_ENABLED())
-                     XSERVER_REQUEST_START(LookupMajorName(client->majorOp),
-                                           client->majorOp,
--                                          ((xReq *) client->requestBuffer)->
--                                          length, client->index,
-+                                          ((xReq *) client->requestBuffer)->length,
-+                                          client->index,
-                                           client->requestBuffer);
- #endif
-                 if (result > (maxBigRequestSize << 2))
---
-cgit v0.9.0.2-2-gbebe
-From f012f0c48dedba4df69cc1a1ecdf8ee5d37daca9 Mon Sep 17 00:00:00 2001
-From: Michal Suchanek <hramrach@gmail.com>
-Date: Thu, 26 Apr 2012 13:11:20 +0000
-Subject: dmx: Annotate dmxlog.c with _X_ATTRIBUTE_PRINTF and _X_NORETURN
-
-and fix resulting printf warning in dmxLogVisual
-
-Signed-off-by: Michal Suchanek <hramrach@gmail.com>
-Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-(cherry picked from commit d662fa2450856777b59c4b62b912395a8bfd52fd)
----
-diff --git a/hw/dmx/dmxlog.c b/hw/dmx/dmxlog.c
-index b56bb93..151f672 100644
---- a/hw/dmx/dmxlog.c
-+++ b/hw/dmx/dmxlog.c
-@@ -86,6 +86,8 @@ ErrorF(const char *format, ...)
+-/*
+- * A TraverseTree callback to invalidate all windows using the same
+- * pixmap
+- */
+-static int
+-DRI2InvalidateWalk(WindowPtr pWin, pointer data)
+-{
+-    if (pWin->drawable.pScreen->GetWindowPixmap(pWin) != data)
+-        return WT_DONTWALKCHILDREN;
+-    DRI2InvalidateDrawable(&pWin->drawable);
+-    return WT_WALKCHILDREN;
+-}
++
+ 
+ int
+ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
+@@ -1162,26 +1191,7 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
+      */
+     *swap_target = pPriv->swap_count + pPriv->swapsPending;
+ 
+-    if (pDraw->type == DRAWABLE_WINDOW) {
+-        WindowPtr pWin = (WindowPtr) pDraw;
+-        PixmapPtr pPixmap = pScreen->GetWindowPixmap(pWin);
+-
+-        /*
+-         * Find the top-most window using this pixmap
+-         */
+-        while (pWin->parent &&
+-               pScreen->GetWindowPixmap(pWin->parent) == pPixmap)
+-            pWin = pWin->parent;
+-
+-        /*
+-         * Walk the sub-tree to invalidate all of the
+-         * windows using the same pixmap
+-         */
+-        TraverseTree(pWin, DRI2InvalidateWalk, pPixmap);
+-        DRI2InvalidateDrawable(&pPixmap->drawable);
+-    }
+-    else
+-        DRI2InvalidateDrawable(pDraw);
++    DRI2InvalidateDrawableAll(pDraw);
  
- /** Provide an VFatalError function when used stand-alone. */
- static void
-+VFatalError(const char *format, va_list args) _X_ATTRIBUTE_PRINTF(1, 0) _X_NORETURN;
-+static void
- VFatalError(const char *format, va_list args)
- {
-     vfprintf(stderr, format, args);     /* RATS: We assume the format string
-@@ -104,7 +106,9 @@ VErrorF(const char *format, va_list args)
+     return Success;
  }
- #else
- /** This function was removed between XFree86 4.3.0 and XFree86 4.4.0. */
--extern void AbortServer(void);
-+extern void AbortServer(void) _X_NORETURN;
-+static void
-+VFatalError(const char *format, va_list args) _X_ATTRIBUTE_PRINTF(1, 0) _X_NORETURN;
- static void
- VFatalError(const char *format, va_list args)
- {
-@@ -166,6 +170,8 @@ dmxHeader(dmxLogLevel logLevel, DMXInputInfo * dmxInput,
- /* Prints the error message with the appropriate low-level X output
-  * routine. */
- static void
-+dmxMessage(dmxLogLevel logLevel, const char *format, va_list args) _X_ATTRIBUTE_PRINTF(2, 0);
-+static void
- dmxMessage(dmxLogLevel logLevel, const char *format, va_list args)
- {
-     if (logLevel == dmxFatal || logLevel >= dmxCurrentLogLevel) {
-@@ -303,10 +309,11 @@ dmxLogVisual(DMXScreenInfo * dmxScreen, XVisualInfo * vi, int defaultVisual)
-         class = "DirectColor";
-         break;
-     }
-+#define VisualLogFormat "0x%02lx %s %2db %db/rgb %3d 0x%04lx 0x%04lx 0x%04lx%s\n"
+diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
+index 37cd8b3..1cf0f02 100644
+--- a/hw/xwin/InitOutput.c
++++ b/hw/xwin/InitOutput.c
+@@ -164,7 +164,7 @@ void XwinExtensionInit(void)
+     int i;
  
-     if (dmxScreen) {
-         dmxLogOutput(dmxScreen,
--                     "0x%02x %s %2db %db/rgb %3d 0x%04x 0x%04x 0x%04x%s\n",
-+                     VisualLogFormat,
-                      vi->visualid, class, vi->depth, vi->bits_per_rgb,
-                      vi->colormap_size,
-                      vi->red_mask, vi->green_mask, vi->blue_mask,
-@@ -314,7 +321,7 @@ dmxLogVisual(DMXScreenInfo * dmxScreen, XVisualInfo * vi, int defaultVisual)
+ #ifdef XWIN_GLX_WINDOWS
+-    if ((g_fNativeGl) && (serverGeneration == 1)) {
++    if (g_fNativeGl) {
+         /* install the native GL provider */
+         glxWinPushNativeProvider();
      }
-     else {
-         dmxLog(dmxInfo,
--               "  0x%02x %s %2db %db/rgb %3d 0x%04x 0x%04x 0x%04x%s\n",
-+               "  " VisualLogFormat,
-                vi->visualid, class, vi->depth, vi->bits_per_rgb,
-                vi->colormap_size,
-                vi->red_mask, vi->green_mask, vi->blue_mask,
-diff --git a/hw/dmx/dmxlog.h b/hw/dmx/dmxlog.h
-index 4d4cd26..162484b 100644
---- a/hw/dmx/dmxlog.h
-+++ b/hw/dmx/dmxlog.h
-@@ -55,18 +55,23 @@ typedef enum {
- /* Logging functions used by Xserver/hw/dmx routines. */
- extern dmxLogLevel dmxSetLogLevel(dmxLogLevel newLevel);
- extern dmxLogLevel dmxGetLogLevel(void);
--extern void dmxLog(dmxLogLevel logLevel, const char *format, ...);
--extern void dmxLogCont(dmxLogLevel logLevel, const char *format, ...);
-+extern void dmxLog(dmxLogLevel logLevel, const char *format,
-+                             ...) _X_ATTRIBUTE_PRINTF(2, 3);
-+extern void dmxLogCont(dmxLogLevel logLevel, const char *format,
-+                             ...) _X_ATTRIBUTE_PRINTF(2, 3);
- extern const char *dmxEventName(int type);
- 
- #ifndef DMX_LOG_STANDALONE
--extern void dmxLogOutput(DMXScreenInfo * dmxScreen, const char *format, ...);
-+extern void dmxLogOutput(DMXScreenInfo * dmxScreen, const char *format,
-+                             ...) _X_ATTRIBUTE_PRINTF(2, 3);
- extern void dmxLogOutputCont(DMXScreenInfo * dmxScreen, const char *format,
--                             ...);
-+                             ...) _X_ATTRIBUTE_PRINTF(2, 3);
- extern void dmxLogOutputWarning(DMXScreenInfo * dmxScreen, const char *format,
--                                ...);
--extern void dmxLogInput(DMXInputInfo * dmxInput, const char *format, ...);
--extern void dmxLogInputCont(DMXInputInfo * dmxInput, const char *format, ...);
-+                             ...) _X_ATTRIBUTE_PRINTF(2, 3);
-+extern void dmxLogInput(DMXInputInfo * dmxInput, const char *format,
-+                             ...) _X_ATTRIBUTE_PRINTF(2, 3);
-+extern void dmxLogInputCont(DMXInputInfo * dmxInput, const char *format,
-+                             ...) _X_ATTRIBUTE_PRINTF(2, 3);
- extern void dmxLogArgs(dmxLogLevel logLevel, int argc, char **argv);
- extern void dmxLogVisual(DMXScreenInfo * dmxScreen, XVisualInfo * vi,
-                          int defaultVisual);
---
-cgit v0.9.0.2-2-gbebe
-From 58dfb13953af71021317b9d85230b1163198f031 Mon Sep 17 00:00:00 2001
-From: Jeremy Huddleston <jeremyhu@apple.com>
-Date: Thu, 10 May 2012 07:53:20 +0000
-Subject: Revert "dix: when disabling a device, release all buttons and keys"
-
-This reverts commit 90299556db24543bb7365e8c2897deca3aa219e7.
-
-The commit being reverted triggered a segfault on server shutdown when a
-device posts raw events after the root windows are forced to NULL.
-
-https://lists.debian.org/debian-x/2012/05/msg00240.html
-
-Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
----
-diff --git a/dix/devices.c b/dix/devices.c
-index d0e99bd..0125504 100644
---- a/dix/devices.c
-+++ b/dix/devices.c
-@@ -432,8 +432,6 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
-     if (*prev != dev)
-         return FALSE;
+@@ -901,7 +901,8 @@ InitOutput(ScreenInfo * screenInfo, int argc, char *argv[])
+ {
+     int i;
  
--    ReleaseButtonsAndKeys(dev);
--
-     /* float attached devices */
-     if (IsMaster(dev)) {
-         for (other = inputInfo.devices; other; other = other->next) {
---
-cgit v0.9.0.2-2-gbebe
+-    XwinExtensionInit();
++    if (serverGeneration == 1)
++        XwinExtensionInit();
+ 
+     /* Log the command line */
+     winLogCommandLine(argc, argv);
+diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am
+index 4c2f04e..33729a9 100644
+--- a/hw/xwin/Makefile.am
++++ b/hw/xwin/Makefile.am
+@@ -109,13 +109,16 @@ SRCS =	InitInput.c \
+ 	winclipboard.h \
+ 	winconfig.h \
+ 	win.h \
++	winglobals.h \
+ 	winkeybd.h \
+ 	winkeynames.h \
+ 	winlayouts.h \
+ 	winmessages.h \
++	winmonitors.h \
+ 	winmsg.h \
+ 	winms.h \
+ 	winmultiwindowclass.h \
++	winmultiwindowicons.h \
+ 	winprefs.h \
+ 	winresource.h \
+ 	winwindow.h \
+diff --git a/hw/xwin/glx/Makefile.am b/hw/xwin/glx/Makefile.am
+index 7222a9f..59f6879 100644
+--- a/hw/xwin/glx/Makefile.am
++++ b/hw/xwin/glx/Makefile.am
+@@ -6,7 +6,8 @@ libXwinGLX_la_SOURCES = \
+ 	glwindows.h \
+ 	glwrap.c \
+ 	indirect.c \
+-	wgl_ext_api.c
++	wgl_ext_api.c \
++	wgl_ext_api.h
+ 
+ if XWIN_MULTIWINDOW
+ DEFS_MULTIWINDOW = -DXWIN_MULTIWINDOW
+diff --git a/include/input.h b/include/input.h
+index 5747f3c..f8459b8 100644
+--- a/include/input.h
++++ b/include/input.h
+@@ -579,6 +579,7 @@ extern int TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti,
+                                      int listener, int mode);
+ extern int TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
+                              uint32_t touchid, Window grab_window, XID *error);
++extern void TouchEndPhysicallyActiveTouches(DeviceIntPtr dev);
+ 
+ /* misc event helpers */
+ extern Mask GetEventMask(DeviceIntPtr dev, xEvent *ev, InputClientsPtr clients);
+diff --git a/man/Xserver.man b/man/Xserver.man
+index 8d243d6..b103551 100644
+--- a/man/Xserver.man
++++ b/man/Xserver.man
+@@ -130,7 +130,7 @@ causes the server to generate a core dump on fatal errors.
+ .B \-displayfd \fIfd\fP
+ specifies a file descriptor in the launching process.  Rather than specify
+ a display number, the X server will attempt to listen on successively higher
+-display numbers, and upon finding a free one, will write the port number back
++display numbers, and upon finding a free one, will write the display number back
+ on this file descriptor as a newline-terminated string.  The \-pn option is
+ ignored when using \-displayfd.
+ .TP 8
+diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
+index 082c0db..c1af32e 100644
+--- a/xkb/xkbAccessX.c
++++ b/xkb/xkbAccessX.c
+@@ -709,7 +709,7 @@ ProcessPointerEvent(InternalEvent *ev, DeviceIntPtr mouse)
+     xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse);
+     DeviceEvent *event = &ev->device_event;
+ 
+-    dev = IsFloating(mouse) ? mouse : GetMaster(mouse, MASTER_KEYBOARD);
++    dev = (IsMaster(mouse) || IsFloating(mouse)) ? mouse : GetMaster(mouse, MASTER_KEYBOARD);
+ 
+     if (dev && dev->key) {
+         xkbi = dev->key->xkbInfo;
diff --git a/abs/core/xorg-server/use-pixman-glyph-cache.patch b/abs/core/xorg-server/use-pixman-glyph-cache.patch
new file mode 100644
index 0000000..c1cd90d
--- /dev/null
+++ b/abs/core/xorg-server/use-pixman-glyph-cache.patch
@@ -0,0 +1,270 @@
+From 9cbcb5bd6a5360a128d15b77a02d8d3351f74366 Mon Sep 17 00:00:00 2001
+From: Søren Sandmann Pedersen <ssp@redhat.com>
+Date: Wed, 30 May 2012 09:19:08 +0000
+Subject: Use new pixman_glyph_cache_t API that will be in pixman 0.28.0
+
+This new API allows glyphs to be cached in a data structure in pixman,
+and entire glyph strings to be composited in one go.
+
+Also bump pixman dependency to 0.27.2.
+
+Results from the cairo peformance test suite running against Xvfb with
+a screen size of 1680x1050@32bpp:
+
+Speedups
+========
+ xlib          firefox-talos-gfx  12416.63 -> 3603.93   3.45x speedup
+██▌
+ xlib          xfce4-terminal-a1   1727.57 -> 1048.85:  1.65x speedup
+▋
+ xlib                  evolution   1370.49 -> 869.34:   1.58x speedup
+▋
+ xlib         gnome-terminal-vim   1832.83 -> 1251.94:  1.46x speedup
+▌
+ xlib                    poppler   1519.70 -> 1204.05:  1.26x speedup
+▎
+ xlib       firefox-planet-gnome   6982.55 -> 5598.16:  1.25x speedup
+▎
+ xlib                  ocitysmap   1142.77 -> 1071.53:  1.07x speedup
+▏
+
+No slowdowns were reported.
+
+Results of x11perf -aa10text:
+
+Before:
+
+      8000000 reps @   0.0007 msec (1450000.0/sec)
+      8000000 reps @   0.0007 msec (1460000.0/sec)
+      8000000 reps @   0.0007 msec (1460000.0/sec)
+      8000000 reps @   0.0007 msec (1470000.0/sec)
+      8000000 reps @   0.0007 msec (1480000.0/sec)
+     40000000 trep @   0.0007 msec (1460000.0/sec)
+
+After:
+
+     32000000 reps @   0.0002 msec (4910000.0/sec)
+     32000000 reps @   0.0002 msec (4830000.0/sec)
+     32000000 reps @   0.0002 msec (4890000.0/sec)
+     32000000 reps @   0.0002 msec (4830000.0/sec)
+     32000000 reps @   0.0002 msec (4900000.0/sec)
+    160000000 trep @   0.0002 msec (4870000.0/sec)
+
+Version 2: Destroy the glyph cache at server regen time
+
+Acked-by: Aaron Plattner <aplattner@nvidia.com>
+Reviewed-by: Keith Packard <keithp@keithp.com>
+Signed-off-by: Soren Sandmann <ssp@redhat.com>
+---
+diff --git a/configure.ac b/configure.ac
+index e686614..b6ed92c 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -811,7 +811,7 @@ LIBPCIACCESS="pciaccess >= 0.12.901"
+ LIBUDEV="libudev >= 143"
+ LIBSELINUX="libselinux >= 2.0.86"
+ LIBDBUS="dbus-1 >= 1.0"
+-LIBPIXMAN="pixman-1 >= 0.21.8"
++LIBPIXMAN="pixman-1 >= 0.27.2"
+ 
+ dnl Pixman is always required, but we separate it out so we can link
+ dnl specific modules against it
+diff --git a/fb/fb.h b/fb/fb.h
+index 75596c5..b869d12 100644
+--- a/fb/fb.h
++++ b/fb/fb.h
+@@ -1344,6 +1344,9 @@ extern _X_EXPORT void
+ extern _X_EXPORT Bool
+  fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats);
+ 
++extern _X_EXPORT void
++fbDestroyGlyphCache(void);
++
+ /*
+  * fbpixmap.c
+  */
+diff --git a/fb/fbpict.c b/fb/fbpict.c
+index 097a1a6..2804ff4 100644
+--- a/fb/fbpict.c
++++ b/fb/fbpict.c
+@@ -70,6 +70,156 @@ fbComposite(CARD8 op,
+     free_pixman_pict(pDst, dest);
+ }
+ 
++static pixman_glyph_cache_t *glyphCache;
++
++void
++fbDestroyGlyphCache(void)
++{
++    if (glyphCache)
++    {
++	pixman_glyph_cache_destroy (glyphCache);
++	glyphCache = NULL;
++    }
++}
++
++static void
++fbUnrealizeGlyph(ScreenPtr pScreen,
++		 GlyphPtr pGlyph)
++{
++    if (glyphCache)
++	pixman_glyph_cache_remove (glyphCache, pGlyph, NULL);
++}
++
++static void
++fbGlyphs(CARD8 op,
++	 PicturePtr pSrc,
++	 PicturePtr pDst,
++	 PictFormatPtr maskFormat,
++	 INT16 xSrc,
++	 INT16 ySrc, int nlist,
++	 GlyphListPtr list,
++	 GlyphPtr *glyphs)
++{
++#define N_STACK_GLYPHS 512
++    ScreenPtr pScreen = pDst->pDrawable->pScreen;
++    pixman_glyph_t stack_glyphs[N_STACK_GLYPHS];
++    pixman_glyph_t *pglyphs = stack_glyphs;
++    pixman_image_t *srcImage, *dstImage;
++    int srcXoff, srcYoff, dstXoff, dstYoff;
++    GlyphPtr glyph;
++    int n_glyphs;
++    int x, y;
++    int i, n;
++    int xDst = list->xOff, yDst = list->yOff;
++
++    miCompositeSourceValidate(pSrc);
++    
++    n_glyphs = 0;
++    for (i = 0; i < nlist; ++i)
++	n_glyphs += list[i].len;
++
++    if (!glyphCache)
++	glyphCache = pixman_glyph_cache_create();
++
++    pixman_glyph_cache_freeze (glyphCache);
++    
++    if (n_glyphs > N_STACK_GLYPHS) {
++	if (!(pglyphs = malloc (n_glyphs * sizeof (pixman_glyph_t))))
++	    goto out;
++    }
++    
++    i = 0;
++    x = y = 0;
++    while (nlist--) {
++        x += list->xOff;
++        y += list->yOff;
++        n = list->len;
++        while (n--) {
++	    const void *g;
++
++            glyph = *glyphs++;
++
++	    if (!(g = pixman_glyph_cache_lookup (glyphCache, glyph, NULL))) {
++		pixman_image_t *glyphImage;
++		PicturePtr pPicture;
++		int xoff, yoff;
++
++		pPicture = GetGlyphPicture(glyph, pScreen);
++		if (!pPicture) {
++		    n_glyphs--;
++		    goto next;
++		}
++
++		if (!(glyphImage = image_from_pict(pPicture, FALSE, &xoff, &yoff)))
++		    goto out;
++
++		g = pixman_glyph_cache_insert(glyphCache, glyph, NULL,
++					      glyph->info.x,
++					      glyph->info.y,
++					      glyphImage);
++
++		free_pixman_pict(pPicture, glyphImage);
++
++		if (!g)
++		    goto out;
++	    }
++
++	    pglyphs[i].x = x;
++	    pglyphs[i].y = y;
++	    pglyphs[i].glyph = g;
++	    i++;
++
++	next:
++            x += glyph->info.xOff;
++            y += glyph->info.yOff;
++	}
++	list++;
++    }
++
++    if (!(srcImage = image_from_pict(pSrc, FALSE, &srcXoff, &srcYoff)))
++	goto out;
++
++    if (!(dstImage = image_from_pict(pDst, TRUE, &dstXoff, &dstYoff)))
++	goto out_free_src;
++
++    if (maskFormat) {
++	pixman_format_code_t format;
++	pixman_box32_t extents;
++	int x, y;
++
++	format = maskFormat->format | (maskFormat->depth << 24);
++
++	pixman_glyph_get_extents(glyphCache, n_glyphs, pglyphs, &extents);
++
++	x = extents.x1;
++	y = extents.y1;
++
++	pixman_composite_glyphs(op, srcImage, dstImage, format,
++				xSrc + srcXoff + xDst, ySrc + srcYoff + yDst,
++				x, y,
++				x + dstXoff, y + dstYoff,
++				extents.x2 - extents.x1,
++				extents.y2 - extents.y1,
++				glyphCache, n_glyphs, pglyphs);
++    }
++    else {
++	pixman_composite_glyphs_no_mask(op, srcImage, dstImage,
++					xSrc + srcXoff - xDst, ySrc + srcYoff - yDst,
++					dstXoff, dstYoff,
++					glyphCache, n_glyphs, pglyphs);
++    }
++
++    free_pixman_pict(pDst, dstImage);
++
++out_free_src:
++    free_pixman_pict(pSrc, srcImage);
++
++out:
++    pixman_glyph_cache_thaw(glyphCache);
++    if (pglyphs != stack_glyphs)
++	free(pglyphs);
++}
++
+ static pixman_image_t *
+ create_solid_fill_image(PicturePtr pict)
+ {
+@@ -357,7 +507,8 @@ fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
+         return FALSE;
+     ps = GetPictureScreen(pScreen);
+     ps->Composite = fbComposite;
+-    ps->Glyphs = miGlyphs;
++    ps->Glyphs = fbGlyphs;
++    ps->UnrealizeGlyph = fbUnrealizeGlyph;
+     ps->CompositeRects = miCompositeRects;
+     ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
+     ps->Trapezoids = fbTrapezoids;
+diff --git a/fb/fbscreen.c b/fb/fbscreen.c
+index 7c7d656..f9080a4 100644
+--- a/fb/fbscreen.c
++++ b/fb/fbscreen.c
+@@ -32,6 +32,7 @@ fbCloseScreen(ScreenPtr pScreen)
+     int d;
+     DepthPtr depths = pScreen->allowedDepths;
+ 
++    fbDestroyGlyphCache();
+     for (d = 0; d < pScreen->numDepths; d++)
+         free(depths[d].vids);
+     free(depths);
+--
+cgit v0.9.0.2-2-gbebe
diff --git a/abs/core/xorg-xinit/PKGBUILD b/abs/core/xorg-xinit/PKGBUILD
index f4d5673..f9bb1c6 100644
--- a/abs/core/xorg-xinit/PKGBUILD
+++ b/abs/core/xorg-xinit/PKGBUILD
@@ -1,10 +1,10 @@
-# $Id: PKGBUILD 149821 2012-02-11 08:52:05Z andyrtr $
+# $Id: PKGBUILD 170012 2012-10-31 00:12:04Z thomas $
 # Maintainer: Jan de Groot <jgc@archlinux.org>
 # Contributor: Alexander Baldeck <alexander@archlinux.org>
 
 pkgname=xorg-xinit
 pkgver=1.3.2
-pkgrel=1
+pkgrel=3
 pkgdesc="X.Org initialisation program "
 arch=('i686' 'x86_64')
 license=('custom')
@@ -28,7 +28,7 @@ md5sums=('9c0943cbd83e489ad1b05221b97efd44'
          '73a597d3fb7f5b9487318ac8cfd4bedf'
          'c7b406c3c5c1e8011b3ac7d6b29c1a2c'
          '7873d97db30d6c279ed37e3559e7c59d'
-         'c5baef10fdb7239594daee72a94ddab3')
+         '4deba1b7f2cc7f93b304b956023e65d6')
 
 build() {
   cd "${srcdir}/xinit-${pkgver}"
diff --git a/abs/core/xorg-xinit/xserverrc b/abs/core/xorg-xinit/xserverrc
index 6f746cd..6b57eeb 100644
--- a/abs/core/xorg-xinit/xserverrc
+++ b/abs/core/xorg-xinit/xserverrc
@@ -1 +1,6 @@
-exec /usr/bin/X -nolisten tcp "$@"
+#!/bin/sh
+if [ -z "$XDG_VTNR" ]; then
+  exec /usr/bin/X -nolisten tcp "$@"
+else
+  exec /usr/bin/X -nolisten tcp "$@" vt$XDG_VTNR
+fi
-- 
cgit v0.12

