[Xquartz-changes] xserver: Branch 'master' - 66 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Fri Jun 4 21:59:17 PDT 2010


 Xext/Makefile.am                      |    1 
 Xext/panoramiX.c                      |  103 +-
 Xext/panoramiX.h                      |    7 
 Xext/panoramiXprocs.c                 |  192 ++---
 Xext/panoramiXsrv.h                   |    3 
 Xext/saver.c                          |   18 
 Xext/shape.c                          |    4 
 Xext/shm.c                            |   12 
 Xext/xf86bigfont.c                    |    4 
 Xext/xvdisp.c                         |   16 
 Xi/closedev.c                         |    2 
 Xi/exevents.c                         |    6 
 Xi/xichangecursor.c                   |    2 
 Xi/xiproperty.c                       |    4 
 Xi/xiquerypointer.c                   |    9 
 composite/compalloc.c                 |    1 
 composite/compinit.c                  |   16 
 composite/compint.h                   |   22 
 composite/compoverlay.c               |    2 
 composite/compwindow.c                |  173 +---
 configure.ac                          |   10 
 dbe/midbe.c                           |   20 
 dix/devices.c                         |   84 ++
 dix/dispatch.c                        |   13 
 dix/enterleave.c                      |   12 
 dix/events.c                          |  179 ++--
 dix/getevents.c                       |   23 
 dix/globals.c                         |    4 
 dix/inpututils.c                      |   79 ++
 dix/main.c                            |    5 
 dix/window.c                          |  111 +--
 fb/fb.h                               |    2 
 hw/dmx/dmxcursor.c                    |   62 -
 hw/dmx/dmxextension.c                 |   26 
 hw/dmx/dmxwindow.c                    |    4 
 hw/dmx/dmxwindow.h                    |    2 
 hw/dmx/doc/dmx.xml                    |   15 
 hw/dmx/glxProxy/g_renderswap.c        |   39 -
 hw/dmx/glxProxy/glxcmds.c             |    9 
 hw/dmx/glxProxy/glxscreens.c          |    5 
 hw/dmx/glxProxy/glxsingle.c           |   13 
 hw/dmx/glxProxy/glxvendor.c           |    6 
 hw/dmx/glxProxy/render2swap.c         |    6 
 hw/dmx/glxProxy/renderpixswap.c       |    2 
 hw/dmx/input/dmxcommon.c              |    9 
 hw/dmx/input/dmxconsole.c             |   25 
 hw/dmx/input/dmxinputinit.c           |    7 
 hw/dmx/input/dmxinputinit.h           |    4 
 hw/dmx/input/dmxxinput.c              |   57 -
 hw/kdrive/ephyr/XF86dri.c             |   10 
 hw/kdrive/ephyr/ephyrhostvideo.c      |    6 
 hw/kdrive/src/kdrive.c                |    7 
 hw/xfree86/common/xf86.h              |   57 -
 hw/xfree86/common/xf86AutoConfig.c    |  248 ------
 hw/xfree86/common/xf86Bus.c           |   39 -
 hw/xfree86/common/xf86Bus.h           |    1 
 hw/xfree86/common/xf86Config.c        |    1 
 hw/xfree86/common/xf86Configure.c     |    2 
 hw/xfree86/common/xf86Cursor.c        |   94 +-
 hw/xfree86/common/xf86Helper.c        |  509 -------------
 hw/xfree86/common/xf86Module.h        |    2 
 hw/xfree86/common/xf86Option.c        |    4 
 hw/xfree86/common/xf86Priv.h          |    4 
 hw/xfree86/common/xf86RandR.c         |    2 
 hw/xfree86/common/xf86Xinput.c        |    9 
 hw/xfree86/common/xf86Xinput.h        |    1 
 hw/xfree86/common/xf86pciBus.c        |  752 ++++++++++++++++++++
 hw/xfree86/common/xf86pciBus.h        |    1 
 hw/xfree86/common/xf86str.h           |    3 
 hw/xfree86/common/xf86xv.c            |    2 
 hw/xfree86/dixmods/extmod/xf86vmode.c |    2 
 hw/xfree86/doc/Makefile.am            |    3 
 hw/xfree86/doc/README.DRI             | 1256 ----------------------------------
 hw/xfree86/doc/README.rapidaccess     |   48 -
 hw/xfree86/doc/man/xorg.conf.man.pre  |    3 
 hw/xfree86/doc/sgml/DESIGN.xml        |    5 
 hw/xfree86/dri/dri.c                  |    2 
 hw/xfree86/dri2/dri2.c                |   54 +
 hw/xfree86/dri2/dri2.h                |   10 
 hw/xfree86/dri2/dri2ext.c             |    1 
 hw/xfree86/fbdevhw/Makefile.am        |    3 
 hw/xfree86/int10/helper_mem.c         |    5 
 hw/xfree86/modes/xf86Crtc.c           |   61 +
 hw/xfree86/modes/xf86RandR12.c        |    6 
 hw/xfree86/modes/xf86Rotate.c         |    4 
 hw/xfree86/os-support/bus/Pci.c       |    1 
 hw/xfree86/os-support/bus/Pci.h       |    8 
 hw/xfree86/parser/scan.c              |   29 
 hw/xfree86/vbe/vbe.c                  |    1 
 hw/xfree86/xaa/xaaCpyWin.c            |    2 
 hw/xfree86/xaa/xaaOverlay.c           |    2 
 hw/xfree86/xaa/xaaOverlayDF.c         |    2 
 hw/xnest/Cursor.c                     |    3 
 hw/xnest/Window.c                     |    4 
 hw/xnest/XNWindow.h                   |    2 
 hw/xquartz/applewm.c                  |    6 
 hw/xquartz/darwin.c                   |   24 
 hw/xquartz/darwinEvents.c             |    4 
 hw/xquartz/pseudoramiX.c              |    4 
 hw/xquartz/quartz.c                   |   14 
 hw/xquartz/xpr/xprCursor.c            |    4 
 hw/xquartz/xpr/xprFrame.c             |    2 
 hw/xquartz/xpr/xprScreen.c            |    4 
 hw/xwin/win.h                         |    4 
 hw/xwin/winkeybd.c                    |    2 
 hw/xwin/winmultiwindowshape.c         |    6 
 hw/xwin/winscrinit.c                  |    6 
 hw/xwin/winwin32rootlesswindow.c      |    2 
 hw/xwin/winwindow.c                   |    8 
 include/globals.h                     |    3 
 include/input.h                       |    2 
 include/inputstr.h                    |    4 
 include/scrnintstr.h                  |   19 
 include/windowstr.h                   |   13 
 include/xorg-config.h.in              |    3 
 include/xserver-properties.h          |    7 
 mi/mi.h                               |    3 
 mi/midispcur.c                        |  287 -------
 mi/miexpose.c                         |    6 
 mi/mioverlay.c                        |   87 +-
 mi/misprite.c                         |   70 -
 mi/misprite.h                         |    7 
 mi/miwindow.c                         |   94 +-
 miext/rootless/rootlessCommon.c       |    4 
 miext/rootless/rootlessCommon.h       |    2 
 miext/rootless/rootlessScreen.c       |    2 
 miext/rootless/rootlessWindow.c       |   30 
 miext/rootless/rootlessWindow.h       |    2 
 randr/rrscreen.c                      |   10 
 randr/rrxinerama.c                    |    2 
 record/record.c                       |    9 
 render/render.c                       |   46 -
 test/.gitignore                       |   13 
 test/input.c                          |  109 ++
 xfixes/cursor.c                       |   41 -
 xfixes/region.c                       |    2 
 xkb/xkbInit.c                         |    3 
 xkb/xkbUtils.c                        |    4 
 138 files changed, 2044 insertions(+), 3631 deletions(-)

New commits:
commit 9f85a36c3ecb77f776296f6abe345b201652be12
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Jun 4 21:56:39 2010 -0700

    rootless: Fix SetShape regression
    
    This fixes a regression in miext/rootless from 643cb6e87c10ab554c03ada81930001a8ebcc909
    
    Found-by: tinderbox
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index ce088c7..4d541f4 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -288,12 +288,12 @@ static void RootlessReshapeFrame(WindowPtr pWin)
  *  shaped when the window is framed.
  */
 void
-RootlessSetShape(WindowPtr pWin)
+RootlessSetShape(WindowPtr pWin, int kind)
 {
     ScreenPtr pScreen = pWin->drawable.pScreen;
 
     SCREEN_UNWRAP(pScreen, SetShape);
-    pScreen->SetShape(pWin);
+    pScreen->SetShape(pWin, kind);
     SCREEN_WRAP(pScreen, SetShape);
 
     RootlessReshapeFrame(pWin);
diff --git a/miext/rootless/rootlessWindow.h b/miext/rootless/rootlessWindow.h
index ca104a4..2b018e0 100644
--- a/miext/rootless/rootlessWindow.h
+++ b/miext/rootless/rootlessWindow.h
@@ -39,7 +39,7 @@
 Bool RootlessCreateWindow(WindowPtr pWin);
 Bool RootlessDestroyWindow(WindowPtr pWin);
 
-void RootlessSetShape(WindowPtr pWin);
+void RootlessSetShape(WindowPtr pWin, int kind);
 
 Bool RootlessChangeWindowAttributes(WindowPtr pWin, unsigned long vmask);
 Bool RootlessPositionWindow(WindowPtr pWin, int x, int y);
commit 6b4af3b7925978cd79f717761f1b6f33bd8dfbaf
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Fri Jun 4 16:27:28 2010 +0300

    configure: Check for libsha1.pc
    
    xserver fails to detect libsha1. Problem is that configure checks for
    sha1.pc when libsha1 provides libsha1.pc.
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index 9e7d700..c8b49de 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1382,7 +1382,7 @@ if test "x$with_sha1" = xlibmd; then
 	          [Use libmd SHA1 functions])
 	SHA1_LIBS=-lmd
 fi
-PKG_CHECK_MODULES([LIBSHA1], [sha1], [HAVE_LIBSHA1=yes], [HAVE_LIBSHA1=no])
+PKG_CHECK_MODULES([LIBSHA1], [libsha1], [HAVE_LIBSHA1=yes], [HAVE_LIBSHA1=no])
 if test "x$with_sha1" = x && test "x$HAVE_LIBSHA1" = xyes; then
    with_sha1=libsha1
 fi
commit d163266692235261e1e0cfa6b900f54e6ec63de5
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Thu Jun 3 18:59:04 2010 -0700

    Stop searching for XF86Config files
    
    xorg.conf has been used since the X11R6.7 release in April 2004.
    6 years has been a generous transition period for users to
    "mv XF86Config xorg.conf" and for distros to update their
    configuration tools and packages.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: James Cloos <cloos at jhcloos.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index 9771913..52e80a9 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -626,7 +626,6 @@ xf86pathIsSafe(const char *path)
 #ifndef XCONFENV
 #define XCONFENV	"XORGCONFIG"
 #endif
-#define XFREE86CFGFILE "XF86Config"
 /* xorg.conf is based on XF86Config version 4.   If we ever break
    compatibility of the xorg.conf syntax, we'll bump this version number. */
 #ifndef CONFIG_FILE_VERSION
@@ -988,11 +987,8 @@ xf86openConfigFile(const char *path, const char *cmdline, const char *projroot)
 	if (!projroot || !projroot[0])
 		projroot = PROJECTROOT;
 
-	/* Search for a config file or a fallback */
+	/* Search for a config file */
 	configPath = OpenConfigFile(path, cmdline, projroot, XCONFIGFILE);
-	if (!configPath)
-		configPath = OpenConfigFile(path, cmdline, projroot,
-					    XFREE86CFGFILE);
 	return configPath;
 }
 
commit 01c75522b6ed15e979347acd38e234e2cb9006c3
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Thu Jun 3 18:59:03 2010 -0700

    Stop searching for XF86Config files
    
    xorg.conf has been used since the X11R6.7 release in April 2004.
    6 years has been a generous transition period for users to
    "mv XF86Config xorg.conf" and for distros to update their
    configuration tools and packages.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: James Cloos <cloos at jhcloos.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/doc/sgml/DESIGN.xml b/hw/xfree86/doc/sgml/DESIGN.xml
index 826a970..6c90a40 100644
--- a/hw/xfree86/doc/sgml/DESIGN.xml
+++ b/hw/xfree86/doc/sgml/DESIGN.xml
@@ -118,8 +118,9 @@ routines common to all the X servers in the sample implementation.
     <title>The xorg.conf File</title>
 
     <para>
-The xorg.conf file format is similar to the old format, with the following
-changes:
+The xorg.conf file format is based on the XF86Config format from XFree86 4.4,
+which is in turn similar to the old XFree86 3.x XF86Config format, with the
+following changes:
     </para>
 
     <sect2>
diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index 06710d5..9771913 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -601,7 +601,7 @@ xf86pathIsSafe(const char *path)
  *    %P    projroot
  *    %C    sysconfdir
  *    %D    datadir
- *    %M    major version number
+ *    %M    config file format version number
  *    %%    %
  */
 
@@ -627,16 +627,10 @@ xf86pathIsSafe(const char *path)
 #define XCONFENV	"XORGCONFIG"
 #endif
 #define XFREE86CFGFILE "XF86Config"
-#ifndef XF86_VERSION_MAJOR
-#ifdef XVERSION
-#if XVERSION > 40000000
-#define XF86_VERSION_MAJOR	(XVERSION / 10000000)
-#else
-#define XF86_VERSION_MAJOR	(XVERSION / 1000)
-#endif
-#else
-#define XF86_VERSION_MAJOR	4
-#endif
+/* xorg.conf is based on XF86Config version 4.   If we ever break
+   compatibility of the xorg.conf syntax, we'll bump this version number. */
+#ifndef CONFIG_FILE_VERSION
+#define CONFIG_FILE_VERSION	4
 #endif
 
 #define BAIL_OUT		do {									\
@@ -771,11 +765,8 @@ DoSubstitution(const char *template, const char *cmdline, const char *projroot,
 				break;
 			case 'M':
 				if (!majorvers[0]) {
-					if (XF86_VERSION_MAJOR < 0 || XF86_VERSION_MAJOR > 99) {
-						fprintf(stderr, "XF86_VERSION_MAJOR is out of range\n");
-						BAIL_OUT;
-					} else
-						sprintf(majorvers, "%d", XF86_VERSION_MAJOR);
+					snprintf(majorvers, sizeof(majorvers),
+						 "%d", CONFIG_FILE_VERSION);
 				}
 				APPEND_STR(majorvers);
 				break;
commit 7f19a7a6e90a4fd7b7ec0256974f62e575218541
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Jun 4 14:15:04 2010 +1000

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

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index e3fb9dc..0766922 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1977,7 +1977,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
         /* font */
         if (src->geom->label_font) {
             if (!dst->geom->label_font) {
-                tmp = malloc(strlen(src->geom->label_font));
+                tmp = malloc(strlen(src->geom->label_font) + 1);
                 if (!tmp)
                     return FALSE;
                 dst->geom->label_font = tmp;
@@ -1985,7 +1985,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
             else if (strlen(src->geom->label_font) !=
                 strlen(dst->geom->label_font)) {
                 tmp = realloc(dst->geom->label_font,
-                               strlen(src->geom->label_font));
+                               strlen(src->geom->label_font) + 1);
                 if (!tmp)
                     return FALSE;
                 dst->geom->label_font = tmp;
commit 959a1eaf1c15a691141f1b0dc53757fe9b6e9b13
Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Jun 4 11:09:46 2010 +1000

    composite: use config notify hook to do pixmap resize.
    
    Since reallocating the backing pixmap can fail, we need to try and do
    it before any other side effects of reconfiguring the window happen.
    
    This changes the ConfigNotify hook to return status, and moves the
    composite window reconfiguration wrappers to ConfigNotify. They all
    basically did the same thing, so we can drop the MoveWindow,
    ResizeWindow, ChangeBorderWidth wrappers, and allow ConfigNotify to do
    all the work. If reallocation fails we fail before we send any
    confiureNotify events, or enter the area we can't recover from.
    
    The only place we now enforce 32k limits are in EXA/UXA/fb, so drivers
    that don't use this should probably deal with it in their pixmap
    allocate if they don't already.
    
    This also breaks ABI, so we need an alternate fix for older servers,
    working on the X server makes me realise why I'm a kernel hacker.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/composite/compinit.c b/composite/compinit.c
index e4b68c8..b4deaf5 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -69,9 +69,7 @@ compCloseScreen (int index, ScreenPtr pScreen)
     pScreen->InstallColormap = cs->InstallColormap;
     pScreen->ChangeWindowAttributes = cs->ChangeWindowAttributes;
     pScreen->ReparentWindow = cs->ReparentWindow;
-    pScreen->MoveWindow = cs->MoveWindow;
-    pScreen->ResizeWindow = cs->ResizeWindow;
-    pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
+    pScreen->ConfigNotify = cs->ConfigNotify;
     
     pScreen->ClipNotify = cs->ClipNotify;
     pScreen->UnrealizeWindow = cs->UnrealizeWindow;
@@ -362,14 +360,8 @@ compScreenInit (ScreenPtr pScreen)
     cs->ClipNotify = pScreen->ClipNotify;
     pScreen->ClipNotify = compClipNotify;
 
-    cs->MoveWindow = pScreen->MoveWindow;
-    pScreen->MoveWindow = compMoveWindow;
-
-    cs->ResizeWindow = pScreen->ResizeWindow;
-    pScreen->ResizeWindow = compResizeWindow;
-
-    cs->ChangeBorderWidth = pScreen->ChangeBorderWidth;
-    pScreen->ChangeBorderWidth = compChangeBorderWidth;
+    cs->ConfigNotify = pScreen->ConfigNotify;
+    pScreen->ConfigNotify = compConfigNotify;
 
     cs->ReparentWindow = pScreen->ReparentWindow;
     pScreen->ReparentWindow = compReparentWindow;
diff --git a/composite/compint.h b/composite/compint.h
index 845a196..93da4df 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -127,13 +127,9 @@ typedef struct _CompScreen {
     UnrealizeWindowProcPtr	UnrealizeWindow;
     ClipNotifyProcPtr		ClipNotify;
     /*
-     * Called from ConfigureWindow, these
-     * three track changes to the offscreen storage
-     * geometry
+     * Called from ConfigureWindow.
      */
-    MoveWindowProcPtr		MoveWindow;
-    ResizeWindowProcPtr		ResizeWindow;
-    ChangeBorderWidthProcPtr	ChangeBorderWidth;
+    ConfigNotifyProcPtr         ConfigNotify;
     /*
      * Reparenting has an effect on Subwindows redirect
      */
@@ -280,16 +276,6 @@ void
 compClipNotify (WindowPtr pWin, int dx, int dy);
 
 void
-compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind);
-
-void
-compResizeWindow (WindowPtr pWin, int x, int y,
-		  unsigned int w, unsigned int h, WindowPtr pSib);
-
-void
-compChangeBorderWidth (WindowPtr pWin, unsigned int border_width);
-
-void
 compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent);
 
 Bool
@@ -316,4 +302,8 @@ CompositeRealChildHead (WindowPtr pWin);
 int
 DeleteWindowNoInputDevices(pointer value, XID wid);
 
+int
+compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
+		 int bw, WindowPtr pSib);
+
 #endif /* _COMPINT_H_ */
diff --git a/composite/compwindow.c b/composite/compwindow.c
index 3b16bf9..0f3898c 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -335,132 +335,6 @@ compImplicitRedirect (WindowPtr pWin, WindowPtr pParent)
 }
 
 void
-compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
-{
-    ScreenPtr		pScreen = pWin->drawable.pScreen;
-    CompScreenPtr	cs = GetCompScreen (pScreen);
-
-    compCheckTree (pScreen);
-    if (pWin->redirectDraw != RedirectDrawNone)
-    {
-	WindowPtr		pParent;
-	int			draw_x, draw_y;
-	unsigned int		w, h, bw;
-
-	/* if this is a root window, can't be moved */
-	if (!(pParent = pWin->parent))
-	   return;
-
-	bw = wBorderWidth (pWin);
-	draw_x = pParent->drawable.x + x + (int)bw;
-	draw_y = pParent->drawable.y + y + (int)bw;
-	w = pWin->drawable.width;
-	h = pWin->drawable.height;
-	compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
-    }
-    compCheckTree (pScreen);
-
-    pScreen->MoveWindow = cs->MoveWindow;
-    (*pScreen->MoveWindow) (pWin, x, y, pSib, kind);
-    cs->MoveWindow = pScreen->MoveWindow;
-    pScreen->MoveWindow = compMoveWindow;
-
-    if (pWin->redirectDraw != RedirectDrawNone)
-    {
-	CompWindowPtr	cw = GetCompWindow (pWin);
-	if (cw->pOldPixmap)
-	{
-	    (*pScreen->DestroyPixmap) (cw->pOldPixmap);
-	    cw->pOldPixmap = NullPixmap;
-	}
-    }
-
-    compCheckTree (pScreen);
-}
-
-void
-compResizeWindow (WindowPtr pWin, int x, int y,
-		  unsigned int w, unsigned int h, WindowPtr pSib)
-{
-    ScreenPtr		pScreen = pWin->drawable.pScreen;
-    CompScreenPtr	cs = GetCompScreen (pScreen);
-
-    compCheckTree (pScreen);
-    if (pWin->redirectDraw != RedirectDrawNone)
-    {
-	WindowPtr		pParent;
-	int			draw_x, draw_y;
-	unsigned int		bw;
-
-	/* if this is a root window, can't be moved */
-	if (!(pParent = pWin->parent))
-	   return;
-
-	bw = wBorderWidth (pWin);
-	draw_x = pParent->drawable.x + x + (int)bw;
-	draw_y = pParent->drawable.y + y + (int)bw;
-	compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
-    }
-    compCheckTree (pScreen);
-
-    pScreen->ResizeWindow = cs->ResizeWindow;
-    (*pScreen->ResizeWindow) (pWin, x, y, w, h, pSib);
-    cs->ResizeWindow = pScreen->ResizeWindow;
-    pScreen->ResizeWindow = compResizeWindow;
-    if (pWin->redirectDraw != RedirectDrawNone)
-    {
-	CompWindowPtr	cw = GetCompWindow (pWin);
-	if (cw->pOldPixmap)
-	{
-	    (*pScreen->DestroyPixmap) (cw->pOldPixmap);
-	    cw->pOldPixmap = NullPixmap;
-	}
-    }
-    compCheckTree (pWin->drawable.pScreen);
-}
-
-void
-compChangeBorderWidth (WindowPtr pWin, unsigned int bw)
-{
-    ScreenPtr		pScreen = pWin->drawable.pScreen;
-    CompScreenPtr	cs = GetCompScreen (pScreen);
-
-    compCheckTree (pScreen);
-    if (pWin->redirectDraw != RedirectDrawNone)
-    {
-	WindowPtr		pParent;
-	int			draw_x, draw_y;
-	unsigned int		w, h;
-
-	/* if this is a root window, can't be moved */
-	if (!(pParent = pWin->parent))
-	   return;
-
-	draw_x = pWin->drawable.x;
-	draw_y = pWin->drawable.y;
-	w = pWin->drawable.width;
-	h = pWin->drawable.height;
-	compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
-    }
-    compCheckTree (pScreen);
-
-    pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
-    (*pScreen->ChangeBorderWidth) (pWin, bw);
-    cs->ChangeBorderWidth = pScreen->ChangeBorderWidth;
-    pScreen->ChangeBorderWidth = compChangeBorderWidth;
-    if (pWin->redirectDraw != RedirectDrawNone)
-    {
-	CompWindowPtr	cw = GetCompWindow (pWin);
-	if (cw->pOldPixmap)
-	{
-	    (*pScreen->DestroyPixmap) (cw->pOldPixmap);
-	    cw->pOldPixmap = NullPixmap;
-	}
-    }
-    compCheckTree (pWin->drawable.pScreen);
-}
-
-void
 compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent)
 {
     ScreenPtr		pScreen = pWin->drawable.pScreen;
@@ -822,3 +696,48 @@ CompositeRealChildHead (WindowPtr pWin)
 	return pChildBefore;
     }
 }
+
+int
+compConfigNotify(WindowPtr pWin, int x, int y, int w, int h,
+		 int bw, WindowPtr pSib)
+{
+    ScreenPtr		pScreen = pWin->drawable.pScreen;
+    CompScreenPtr	cs = GetCompScreen (pScreen);
+    Bool                ret = 0;
+    WindowPtr		pParent = pWin->parent;
+    CompWindowPtr       cw;
+    int			draw_x, draw_y;
+    Bool alloc_ret;
+
+    if (cs->ConfigNotify)
+    {
+	pScreen->ConfigNotify = cs->ConfigNotify;
+	ret = (*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
+	cs->ConfigNotify = pScreen->ConfigNotify;
+	pScreen->ConfigNotify = compConfigNotify;
+
+	if (ret)
+	    return ret;
+    }
+
+    if (pWin->redirectDraw == RedirectDrawNone)
+	return Success;
+
+    compCheckTree (pScreen);
+
+    draw_x = pParent->drawable.x + x + bw;
+    draw_y = pParent->drawable.y + y + bw;
+    alloc_ret = compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
+    
+    cw = GetCompWindow (pWin);
+    if (cw->pOldPixmap)
+    {
+	(*pScreen->DestroyPixmap) (cw->pOldPixmap);
+	cw->pOldPixmap = NullPixmap;
+    }
+    compCheckTree (pScreen);
+
+    if (alloc_ret == FALSE)
+	return BadAlloc;
+    return Success;
+}
diff --git a/dix/window.c b/dix/window.c
index 9e1f491..ea729db 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -2302,7 +2302,14 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
 
 ActuallyDoSomething:
     if (pWin->drawable.pScreen->ConfigNotify)
-	(*pWin->drawable.pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
+    {
+	int ret;
+	ret = (*pWin->drawable.pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
+	if (ret) {
+	    client->errorValue = 0;
+	    return ret;
+	}
+    }
 
     if (SubStrSend(pWin, pParent))
     {
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 9ec4caa..45a8271 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -977,7 +977,7 @@ DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
     return TRUE;
 }
 
-static void
+static int
 DRI2ConfigNotify(WindowPtr pWin, int x, int y, int w, int h, int bw,
 		 WindowPtr pSib)
 {
@@ -985,20 +985,24 @@ DRI2ConfigNotify(WindowPtr pWin, int x, int y, int w, int h, int bw,
     ScreenPtr pScreen = pDraw->pScreen;
     DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
     DRI2DrawablePtr dd = DRI2GetDrawable(pDraw);
+    int ret;
 
     if (ds->ConfigNotify) {
 	pScreen->ConfigNotify = ds->ConfigNotify;
 
-	(*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
+	ret = (*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
 
 	ds->ConfigNotify = pScreen->ConfigNotify;
 	pScreen->ConfigNotify = DRI2ConfigNotify;
+	if (ret)
+	    return ret;
     }
 
     if (!dd || (dd->width == w && dd->height == h))
-	return;
+	return Success;
 
     DRI2InvalidateDrawable(pDraw);
+    return Success;
 }
 
 Bool
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index d67b264..361c484 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -396,7 +396,7 @@ typedef    void (* PostChangeSaveUnderProcPtr)(
 	WindowPtr /*pLayerWin*/,
 	WindowPtr /*firstChild*/);
 
-typedef    void (* ConfigNotifyProcPtr)(
+typedef    int (* ConfigNotifyProcPtr)(
 	WindowPtr /*pWin*/,
 	int /*x*/,
 	int /*y*/,
commit 0f12e86e600522768f5f64eafc1230526e700ab7
Merge: aa7c09f... f114f54...
Author: Keith Packard <keithp at keithp.com>
Date:   Thu Jun 3 15:09:32 2010 -0700

    Merge remote branch 'jamey/for-keith'

commit f114f54986aca1add4c8808a05d9692e289547e7
Author: Jamey Sharp <jamey at minilop.net>
Date:   Fri Apr 23 19:33:49 2010 -0700

    Accumulate graphics exposures incrementally in PanoramiXCopyArea/Plane.
    
    This fuses two loops in each function, eliminating an intermediate
    MAXSCREENS-sized array from each.
    
    Aside from being more efficient, I believe this is equivalent to the
    previous implementation, since
    - each per-screen GC has the graphicsExposures flag set the same way,
      and
    - the REGION_* macros ignore their screen argument.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Tested-by: Tiago Vignatti <tiago.vignatti at nokia.com> (i686 GNU/Linux)

diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index a7f8a0c..5ccbe27 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -1084,10 +1084,12 @@ int PanoramiXCopyArea(ClientPtr client)
     } else {
 	DrawablePtr pDst = NULL, pSrc = NULL;
 	GCPtr pGC = NULL;
-	RegionPtr pRgn[MAXSCREENS];
+	RegionRec totalReg;
 	int rc;
 
+	REGION_NULL(unusedScreen, &totalReg);
 	FOR_NSCREENS_BACKWARD(j) {
+	    RegionPtr pRgn;
 	    stuff->dstDrawable = dst->info[j].id;
 	    stuff->srcDrawable = src->info[j].id;
 	    stuff->gc          = gc->info[j].id;
@@ -1116,37 +1118,30 @@ int PanoramiXCopyArea(ClientPtr client)
  	    } else
 		pSrc = pDst;
 
-	    pRgn[j] = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, 
+	    pRgn = (*pGC->ops->CopyArea)(pSrc, pDst, pGC,
 				stuff->srcX, stuff->srcY,
 				stuff->width, stuff->height, 
 				stuff->dstX, stuff->dstY);
+	    if(pGC->graphicsExposures && pRgn) {
+	       if(srcIsRoot) {
+		   REGION_TRANSLATE(unusedScreen, pRgn,
+			    screenInfo.screens[j]->x, screenInfo.screens[j]->y);
+	       }
+	       REGION_APPEND(unusedScreen, &totalReg, pRgn);
+	       REGION_DESTROY(unusedScreen, pRgn);
+	    }
 
-	    if(dstShared) {
-		while(j--) pRgn[j] = NULL;
+	    if(dstShared)
 		break;
-	    }
 	}
 
 	if(pGC->graphicsExposures) {
 	    ScreenPtr pScreen = pDst->pScreen;
-	    RegionRec totalReg;
 	    Bool overlap;
-
-	    REGION_NULL(pScreen, &totalReg);
-	    FOR_NSCREENS_BACKWARD(j) {
-		if(pRgn[j]) {
-		   if(srcIsRoot) {
-		       REGION_TRANSLATE(pScreen, pRgn[j], 
-				screenInfo.screens[j]->x, screenInfo.screens[j]->y);
-		   }
-		   REGION_APPEND(pScreen, &totalReg, pRgn[j]);
-		   REGION_DESTROY(pScreen, pRgn[j]);
-		}
-	    }
-	    REGION_VALIDATE(pScreen, &totalReg, &overlap);
+	    REGION_VALIDATE(unusedScreen, &totalReg, &overlap);
 	    (*pScreen->SendGraphicsExpose)(
 		client, &totalReg, stuff->dstDrawable, X_CopyArea, 0);
-	    REGION_UNINIT(pScreen, &totalReg);
+	    REGION_UNINIT(unusedScreen, &totalReg);
 	}
     }
 
@@ -1163,7 +1158,7 @@ int PanoramiXCopyPlane(ClientPtr client)
     Bool		srcShared, dstShared;
     DrawablePtr 	psrcDraw, pdstDraw = NULL;
     GCPtr 		pGC = NULL;
-    RegionPtr 		pRgn[MAXSCREENS];
+    RegionRec		totalReg;
     REQUEST(xCopyPlaneReq);
 
     REQUEST_SIZE_MATCH(xCopyPlaneReq);
@@ -1198,7 +1193,9 @@ int PanoramiXCopyPlane(ClientPtr client)
     srcx = stuff->srcX; srcy = stuff->srcY;
     dstx = stuff->dstX; dsty = stuff->dstY;
  
+    REGION_NULL(unusedScreen, &totalReg);
     FOR_NSCREENS_BACKWARD(j) {
+	RegionPtr pRgn;
 	stuff->dstDrawable = dst->info[j].id;
 	stuff->srcDrawable = src->info[j].id;
 	stuff->gc          = gc->info[j].id;
@@ -1231,33 +1228,26 @@ int PanoramiXCopyPlane(ClientPtr client)
 	    return(BadValue);
 	}
 
-	pRgn[j] = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC, 
+	pRgn = (*pGC->ops->CopyPlane)(psrcDraw, pdstDraw, pGC,
 				stuff->srcX, stuff->srcY,
 				stuff->width, stuff->height, 
 				stuff->dstX, stuff->dstY, stuff->bitPlane);
+	if(pGC->graphicsExposures && pRgn) {
+	    REGION_APPEND(unusedScreen, &totalReg, pRgn);
+	    REGION_DESTROY(unusedScreen, pRgn);
+	}
 
-	if(dstShared) {
-	    while(j--) pRgn[j] = NULL;
+	if(dstShared)
 	    break;
-	}
     }
 
     if(pGC->graphicsExposures) {
 	ScreenPtr pScreen = pdstDraw->pScreen;
-	RegionRec totalReg;
 	Bool overlap;
-
-	REGION_NULL(pScreen, &totalReg);
-	FOR_NSCREENS_BACKWARD(j) {
-	    if(pRgn[j]) {
-		REGION_APPEND(pScreen, &totalReg, pRgn[j]);
-		REGION_DESTROY(pScreen, pRgn[j]);
-	    }
-	}
-	REGION_VALIDATE(pScreen, &totalReg, &overlap);
+	REGION_VALIDATE(unusedScreen, &totalReg, &overlap);
 	(*pScreen->SendGraphicsExpose)(
 		client, &totalReg, stuff->dstDrawable, X_CopyPlane, 0);
-	REGION_UNINIT(pScreen, &totalReg);
+	REGION_UNINIT(unusedScreen, &totalReg);
     }
 
     return Success;
commit a7c7ebe4b3a0df1a4d1ffe3c690cfb21470f103d
Author: Jamey Sharp <jamey at minilop.net>
Date:   Sat May 22 21:13:48 2010 -0700

    Delete XineramaScreenRegions cache.
    
    Every screen region consists of a single rectangle, so initializing a
    stack-allocated region for each screen on-demand does no heap allocation
    and is fast.
    
    This eliminates a MAXSCREENS-sized array.
    
    The REGION_UNINIT calls are no-ops since no boxes are actually allocated
    for a single-rectangle region, but it seemed wiser to include them.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Tested-by: Tiago Vignatti <tiago.vignatti at nokia.com> (i686 GNU/Linux)

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 78728a9..14e06e1 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -119,8 +119,6 @@ typedef struct {
   CloseScreenProcPtr	CloseScreen;
 } PanoramiXScreenRec, *PanoramiXScreenPtr;
 
-static RegionRec XineramaScreenRegions[MAXSCREENS];
-
 static void XineramaValidateGC(GCPtr, unsigned long, DrawablePtr);
 static void XineramaChangeGC(GCPtr, unsigned long);
 static void XineramaCopyGC(GCPtr, unsigned long, GCPtr);
@@ -153,7 +151,6 @@ XineramaCloseScreen (int i, ScreenPtr pScreen)
     pScreen->CloseScreen = pScreenPriv->CloseScreen;
     pScreen->CreateGC = pScreenPriv->CreateGC;
 
-    REGION_UNINIT(pScreen, &XineramaScreenRegions[pScreen->myNum]);
     if (pScreen->myNum == 0)
 	REGION_UNINIT(pScreen, &PanoramiXScreenRegion);
 
@@ -392,6 +389,7 @@ static void XineramaInitData(ScreenPtr pScreen)
     REGION_NULL(pScreen, &PanoramiXScreenRegion)
     for (i = 0; i < PanoramiXNumScreens; i++) {
 	BoxRec TheBox;
+	RegionRec ScreenRegion;
 
         pScreen = screenInfo.screens[i];
 
@@ -400,9 +398,10 @@ static void XineramaInitData(ScreenPtr pScreen)
 	TheBox.y1 = pScreen->y;
 	TheBox.y2 = TheBox.y1 + pScreen->height;
 
-	REGION_INIT(pScreen, &XineramaScreenRegions[i], &TheBox, 1);
+	REGION_INIT(pScreen, &ScreenRegion, &TheBox, 1);
 	REGION_UNION(pScreen, &PanoramiXScreenRegion, &PanoramiXScreenRegion,
-		     &XineramaScreenRegions[i]);
+		     &ScreenRegion);
+	REGION_UNINIT(pScreen, &ScreenRegion);
     }
 
     PanoramiXPixWidth = screenInfo.screens[0]->x + screenInfo.screens[0]->width;
@@ -422,12 +421,7 @@ static void XineramaInitData(ScreenPtr pScreen)
 
 void XineramaReinitData(ScreenPtr pScreen)
 {
-    int i;
-
     REGION_UNINIT(pScreen, &PanoramiXScreenRegion);
-    for (i = 0; i < PanoramiXNumScreens; i++)
-	REGION_UNINIT(pScreen, &XineramaScreenRegions[i]);
-
     XineramaInitData(pScreen);
 }
 
@@ -1141,7 +1135,7 @@ XineramaGetImageData(
     int pitch,
     Bool isRoot
 ){
-    RegionRec SrcRegion, GrabRegion;
+    RegionRec SrcRegion, ScreenRegion, GrabRegion;
     BoxRec SrcBox, *pbox;
     int x, y, w, h, i, j, nbox, size, sizeNeeded, ScratchPitch, inOut, depth;
     DrawablePtr pDraw = pDrawables[0];
@@ -1165,12 +1159,24 @@ XineramaGetImageData(
     depth = (format == XYPixmap) ? 1 : pDraw->depth;
 
     for(i = 0; i < PanoramiXNumScreens; i++) {
+	BoxRec TheBox;
+	ScreenPtr pScreen;
 	pDraw = pDrawables[i];
+	pScreen = pDraw->pScreen;
 
-	inOut = RECT_IN_REGION(pScreen,&XineramaScreenRegions[i],&SrcBox);
+	TheBox.x1 = pScreen->x;
+	TheBox.x2 = TheBox.x1 + pScreen->width;
+	TheBox.y1 = pScreen->y;
+	TheBox.y2 = TheBox.y1 + pScreen->height;
+
+	REGION_INIT(pScreen, &ScreenRegion, &TheBox, 1);
+	inOut = RECT_IN_REGION(pScreen, &ScreenRegion, &SrcBox);
+	if(inOut == rgnPART)
+	    REGION_INTERSECT(pScreen, &GrabRegion, &SrcRegion, &ScreenRegion);
+	REGION_UNINIT(pScreen, &ScreenRegion);
 
 	if(inOut == rgnIN) {	   
-	    (*pDraw->pScreen->GetImage)(pDraw, 
+	    (*pScreen->GetImage)(pDraw,
 			SrcBox.x1 - pDraw->x - screenInfo.screens[i]->x,
 			SrcBox.y1 - pDraw->y - screenInfo.screens[i]->y,
 			width, height, format, planemask, data);
@@ -1178,9 +1184,6 @@ XineramaGetImageData(
 	} else if (inOut == rgnOUT)
 	    continue;
 
-	REGION_INTERSECT(pScreen, &GrabRegion, &SrcRegion, 
-					&XineramaScreenRegions[i]);
-
 	nbox = REGION_NUM_RECTS(&GrabRegion);
 
 	if(nbox) {
@@ -1206,7 +1209,7 @@ XineramaGetImageData(
 		x = pbox->x1 - pDraw->x - screenInfo.screens[i]->x;
 		y = pbox->y1 - pDraw->y - screenInfo.screens[i]->y;
 
-		(*pDraw->pScreen->GetImage)(pDraw, x, y, w, h, 
+		(*pScreen->GetImage)(pDraw, x, y, w, h,
 					format, planemask, ScratchMem);
 		
 		/* copy the memory over */
diff --git a/hw/dmx/doc/dmx.xml b/hw/dmx/doc/dmx.xml
index d0c83bb..c6dc0cc 100644
--- a/hw/dmx/doc/dmx.xml
+++ b/hw/dmx/doc/dmx.xml
@@ -1507,8 +1507,7 @@ PanoramiX prefix.
     Xinerama windows, pixmaps and colormaps.
     </para>
 
-    <para>A region (XineramaScreenRegions&lsqb;i&rsqb;) is initialized for each
-    physical screen, and single region (PanoramiXScreenRegion) is
+    <para>A region (PanoramiXScreenRegion) is
     initialized to be the union of the screen regions.
     The relative positioning information for the
     physical screens is taken from the ScreenRec x and y members, which
commit a0456da339fa9b3c3e6fead060338ee7348d6460
Author: Jamey Sharp <jamey at minilop.net>
Date:   Sun May 23 12:57:52 2010 -0700

    XineramaSetCursorPosition: use screen bounds directly, not POINT_IN_REGION.
    
    This hides a MAXSCREENS-sized array as an implementation detail of
    panoramiX.c rather than an exported global.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Tested-by: Tiago Vignatti <tiago.vignatti at nokia.com> (i686 GNU/Linux)

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index b87da24..78728a9 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -119,7 +119,7 @@ typedef struct {
   CloseScreenProcPtr	CloseScreen;
 } PanoramiXScreenRec, *PanoramiXScreenPtr;
 
-RegionRec XineramaScreenRegions[MAXSCREENS];
+static RegionRec XineramaScreenRegions[MAXSCREENS];
 
 static void XineramaValidateGC(GCPtr, unsigned long, DrawablePtr);
 static void XineramaChangeGC(GCPtr, unsigned long);
diff --git a/Xext/panoramiXsrv.h b/Xext/panoramiXsrv.h
index af0017d..5b1a3a9 100644
--- a/Xext/panoramiXsrv.h
+++ b/Xext/panoramiXsrv.h
@@ -21,8 +21,6 @@ extern _X_EXPORT int XineramaDeleteResource(pointer, XID);
 
 extern _X_EXPORT void XineramaReinitData(ScreenPtr);
 
-extern _X_EXPORT RegionRec XineramaScreenRegions[MAXSCREENS];
-
 extern _X_EXPORT unsigned long XRC_DRAWABLE;
 extern _X_EXPORT unsigned long XRT_WINDOW;
 extern _X_EXPORT unsigned long XRT_PIXMAP;
diff --git a/dix/events.c b/dix/events.c
index e8e65e2..502eebd 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -486,6 +486,13 @@ SyntheticMotion(DeviceIntPtr dev, int x, int y) {
 static void PostNewCursor(DeviceIntPtr pDev);
 
 static Bool
+pointOnScreen(ScreenPtr pScreen, int x, int y)
+{
+    return x >= pScreen->x && x < pScreen->x + pScreen->width &&
+           y >= pScreen->y && y < pScreen->y + pScreen->height;
+}
+
+static Bool
 XineramaSetCursorPosition(
     DeviceIntPtr pDev,
     int x,
@@ -493,7 +500,6 @@ XineramaSetCursorPosition(
     Bool generateEvent
 ){
     ScreenPtr pScreen;
-    BoxRec box;
     int i;
     SpritePtr pSprite = pDev->spriteInfo->sprite;
 
@@ -505,14 +511,13 @@ XineramaSetCursorPosition(
     x += screenInfo.screens[0]->x;
     y += screenInfo.screens[0]->y;
 
-    if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
-								x, y, &box))
+    if(!pointOnScreen(pScreen, x, y))
     {
 	FOR_NSCREENS(i)
 	{
 	    if(i == pScreen->myNum)
 		continue;
-	    if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i], x, y, &box))
+	    if(pointOnScreen(screenInfo.screens[i], x, y))
 	    {
 		pScreen = screenInfo.screens[i];
 		break;
commit a83cff9f4d622b069c96a68b4e87a669bf1f6446
Author: Jamey Sharp <jamey at minilop.net>
Date:   Sun May 23 10:11:47 2010 -0700

    Move each screen's x/y origin into ScreenRec.
    
    Many references to the dixScreenOrigins array already had the
    corresponding screen pointer handy, which meant they usually looked like
    "dixScreenOrigins[pScreen->myNum]". Adding a field to ScreenRec instead
    of keeping this information in a parallel array simplifies those
    expressions, and eliminates a MAXSCREENS-sized array.
    
    Since dix declared the dixScreenOrigins array, I figure allocating a
    screen private for these values is overkill.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Tested-by: Tiago Vignatti <tiago.vignatti at nokia.com> (i686 GNU/Linux)

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 5f0e97e..b87da24 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -198,8 +198,8 @@ XineramaValidateGC(
 
     if((pDraw->type == DRAWABLE_WINDOW) && !(((WindowPtr)pDraw)->parent)) {
 	/* the root window */
-	int x_off = dixScreenOrigins[pGC->pScreen->myNum].x;
-	int y_off = dixScreenOrigins[pGC->pScreen->myNum].y;
+	int x_off = pGC->pScreen->x;
+	int y_off = pGC->pScreen->y;
 	int new_val;
 
 	new_val = pGCPriv->clipOrg.x - x_off;
@@ -395,9 +395,9 @@ static void XineramaInitData(ScreenPtr pScreen)
 
         pScreen = screenInfo.screens[i];
 
-	TheBox.x1 = dixScreenOrigins[i].x;
+	TheBox.x1 = pScreen->x;
 	TheBox.x2 = TheBox.x1 + pScreen->width;
-	TheBox.y1 = dixScreenOrigins[i].y;
+	TheBox.y1 = pScreen->y;
 	TheBox.y2 = TheBox.y1 + pScreen->height;
 
 	REGION_INIT(pScreen, &XineramaScreenRegions[i], &TheBox, 1);
@@ -405,13 +405,13 @@ static void XineramaInitData(ScreenPtr pScreen)
 		     &XineramaScreenRegions[i]);
     }
 
-    PanoramiXPixWidth = dixScreenOrigins[0].x + screenInfo.screens[0]->width;
-    PanoramiXPixHeight = dixScreenOrigins[0].y + screenInfo.screens[0]->height;
+    PanoramiXPixWidth = screenInfo.screens[0]->x + screenInfo.screens[0]->width;
+    PanoramiXPixHeight = screenInfo.screens[0]->y + screenInfo.screens[0]->height;
 
     for (i = 1; i < PanoramiXNumScreens; i++) {
 	pScreen = screenInfo.screens[i];
-	w = dixScreenOrigins[i].x + pScreen->width;
-	h = dixScreenOrigins[i].y + pScreen->height;
+	w = pScreen->x + pScreen->width;
+	h = pScreen->y + pScreen->height;
 
 	if (PanoramiXPixWidth < w)
 	    PanoramiXPixWidth = w;
@@ -1060,8 +1060,8 @@ ProcXineramaQueryScreens(ClientPtr client)
 	int i;
 
 	for(i = 0; i < PanoramiXNumScreens; i++) {
-	    scratch.x_org  = dixScreenOrigins[i].x;
-	    scratch.y_org  = dixScreenOrigins[i].y;
+	    scratch.x_org  = screenInfo.screens[i]->x;
+	    scratch.y_org  = screenInfo.screens[i]->y;
 	    scratch.width  = screenInfo.screens[i]->width;
 	    scratch.height = screenInfo.screens[i]->height;
 	
@@ -1153,8 +1153,8 @@ XineramaGetImageData(
     SrcBox.x1 = left;
     SrcBox.y1 = top;
     if(!isRoot) {
-	SrcBox.x1 += pDraw->x + dixScreenOrigins[0].x;
-	SrcBox.y1 += pDraw->y + dixScreenOrigins[0].y;
+	SrcBox.x1 += pDraw->x + screenInfo.screens[0]->x;
+	SrcBox.y1 += pDraw->y + screenInfo.screens[0]->y;
     }
     SrcBox.x2 = SrcBox.x1 + width;
     SrcBox.y2 = SrcBox.y1 + height;
@@ -1171,8 +1171,8 @@ XineramaGetImageData(
 
 	if(inOut == rgnIN) {	   
 	    (*pDraw->pScreen->GetImage)(pDraw, 
-			SrcBox.x1 - pDraw->x - dixScreenOrigins[i].x,
-			SrcBox.y1 - pDraw->y - dixScreenOrigins[i].y,
+			SrcBox.x1 - pDraw->x - screenInfo.screens[i]->x,
+			SrcBox.y1 - pDraw->y - screenInfo.screens[i]->y,
 			width, height, format, planemask, data);
 	    break;
 	} else if (inOut == rgnOUT)
@@ -1203,8 +1203,8 @@ XineramaGetImageData(
 		    }	
 		}
 
-		x = pbox->x1 - pDraw->x - dixScreenOrigins[i].x;
-		y = pbox->y1 - pDraw->y - dixScreenOrigins[i].y;
+		x = pbox->x1 - pDraw->x - screenInfo.screens[i]->x;
+		y = pbox->y1 - pDraw->y - screenInfo.screens[i]->y;
 
 		(*pDraw->pScreen->GetImage)(pDraw, x, y, w, h, 
 					format, planemask, ScratchMem);
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index ccd7216..a7f8a0c 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -135,8 +135,8 @@ int PanoramiXCreateWindow(ClientPtr client)
         stuff->wid = newWin->info[j].id;
         stuff->parent = parent->info[j].id;
 	if (parentIsRoot) {
-	    stuff->x = orig_x - dixScreenOrigins[j].x;
-	    stuff->y = orig_y - dixScreenOrigins[j].y;
+	    stuff->x = orig_x - screenInfo.screens[j]->x;
+	    stuff->y = orig_y - screenInfo.screens[j]->y;
 	}
 	if (backPix)
 	    *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id;
@@ -334,8 +334,8 @@ int PanoramiXReparentWindow(ClientPtr client)
 	stuff->window = win->info[j].id;
 	stuff->parent = parent->info[j].id;
 	if(parentIsRoot) {
-	    stuff->x = x - dixScreenOrigins[j].x;
-	    stuff->y = y - dixScreenOrigins[j].y;
+	    stuff->x = x - screenInfo.screens[j]->x;
+	    stuff->y = y - screenInfo.screens[j]->y;
 	}
 	result = (*SavedProcVector[X_ReparentWindow])(client);
         if(result != Success) break;
@@ -495,9 +495,9 @@ int PanoramiXConfigureWindow(ClientPtr client)
 	if(sib)
 	    *((CARD32 *) &stuff[1] + sib_offset) = sib->info[j].id;
 	if(x_offset >= 0)
-	    *((CARD32 *) &stuff[1] + x_offset) = x - dixScreenOrigins[j].x;
+	    *((CARD32 *) &stuff[1] + x_offset) = x - screenInfo.screens[j]->x;
 	if(y_offset >= 0)
-	    *((CARD32 *) &stuff[1] + y_offset) = y - dixScreenOrigins[j].y;
+	    *((CARD32 *) &stuff[1] + y_offset) = y - screenInfo.screens[j]->y;
 	result = (*SavedProcVector[X_ConfigureWindow])(client);
         if(result != Success) break;
     }
@@ -565,8 +565,8 @@ int PanoramiXGetGeometry(ClientPtr client)
 	if((pWin->parent == screenInfo.screens[0]->root) ||
            (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid))
         {
-	   rep.x += dixScreenOrigins[0].x;
-	   rep.y += dixScreenOrigins[0].y;
+	   rep.x += screenInfo.screens[0]->x;
+	   rep.y += screenInfo.screens[0]->y;
 	}
 	rep.borderWidth = pWin->borderWidth;
     }
@@ -599,8 +599,8 @@ int PanoramiXTranslateCoords(ClientPtr client)
     if((pWin == screenInfo.screens[0]->root) ||
        (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid))
     { 
-	x = stuff->srcX - dixScreenOrigins[0].x;
-	y = stuff->srcY - dixScreenOrigins[0].y;
+	x = stuff->srcX - screenInfo.screens[0]->x;
+	y = stuff->srcY - screenInfo.screens[0]->y;
     } else {
 	x = pWin->drawable.x + stuff->srcX;
 	y = pWin->drawable.y + stuff->srcY;
@@ -637,8 +637,8 @@ int PanoramiXTranslateCoords(ClientPtr client)
     if((pDst == screenInfo.screens[0]->root) ||
        (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid))
     {
-	rep.dstX += dixScreenOrigins[0].x;
-	rep.dstY += dixScreenOrigins[0].y;
+	rep.dstX += screenInfo.screens[0]->x;
+	rep.dstY += screenInfo.screens[0]->y;
     }
 
     WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep);
@@ -981,8 +981,8 @@ int PanoramiXClearToBackground(ClientPtr client)
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->window = win->info[j].id;
 	if(isRoot) {
-	    stuff->x = x - dixScreenOrigins[j].x;
-	    stuff->y = y - dixScreenOrigins[j].y;
+	    stuff->x = x - screenInfo.screens[j]->x;
+	    stuff->y = y - screenInfo.screens[j]->y;
 	}
 	result = (*SavedProcVector[X_ClearArea])(client);
 	if(result != Success) break;
@@ -1092,12 +1092,12 @@ int PanoramiXCopyArea(ClientPtr client)
 	    stuff->srcDrawable = src->info[j].id;
 	    stuff->gc          = gc->info[j].id;
  	    if (srcIsRoot) {	
-		stuff->srcX = srcx - dixScreenOrigins[j].x;
-		stuff->srcY = srcy - dixScreenOrigins[j].y;
+		stuff->srcX = srcx - screenInfo.screens[j]->x;
+		stuff->srcY = srcy - screenInfo.screens[j]->y;
 	    }
  	    if (dstIsRoot) {	
-		stuff->dstX = dstx - dixScreenOrigins[j].x;
-		stuff->dstY = dsty - dixScreenOrigins[j].y;
+		stuff->dstX = dstx - screenInfo.screens[j]->x;
+		stuff->dstY = dsty - screenInfo.screens[j]->y;
 	    }
 
 	    VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess);
@@ -1137,7 +1137,7 @@ int PanoramiXCopyArea(ClientPtr client)
 		if(pRgn[j]) {
 		   if(srcIsRoot) {
 		       REGION_TRANSLATE(pScreen, pRgn[j], 
-				dixScreenOrigins[j].x, dixScreenOrigins[j].y);
+				screenInfo.screens[j]->x, screenInfo.screens[j]->y);
 		   }
 		   REGION_APPEND(pScreen, &totalReg, pRgn[j]);
 		   REGION_DESTROY(pScreen, pRgn[j]);
@@ -1203,12 +1203,12 @@ int PanoramiXCopyPlane(ClientPtr client)
 	stuff->srcDrawable = src->info[j].id;
 	stuff->gc          = gc->info[j].id;
 	if (srcIsRoot) {	
-	    stuff->srcX = srcx - dixScreenOrigins[j].x;
-	    stuff->srcY = srcy - dixScreenOrigins[j].y;
+	    stuff->srcX = srcx - screenInfo.screens[j]->x;
+	    stuff->srcY = srcy - screenInfo.screens[j]->y;
 	}
 	if (dstIsRoot) {	
-	    stuff->dstX = dstx - dixScreenOrigins[j].x;
-	    stuff->dstY = dsty - dixScreenOrigins[j].y;
+	    stuff->dstX = dstx - screenInfo.screens[j]->x;
+	    stuff->dstY = dsty - screenInfo.screens[j]->y;
 	}
 
 	VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, DixWriteAccess);
@@ -1297,8 +1297,8 @@ int PanoramiXPolyPoint(ClientPtr client)
             if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint));
 
             if (isRoot) {
-                int x_off = dixScreenOrigins[j].x;
-                int y_off = dixScreenOrigins[j].y;
+                int x_off = screenInfo.screens[j]->x;
+                int y_off = screenInfo.screens[j]->y;
 
 		if(x_off || y_off) {
                     xPoint *pnts = (xPoint*)&stuff[1];
@@ -1357,8 +1357,8 @@ int PanoramiXPolyLine(ClientPtr client)
             if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint));
 
             if (isRoot) {
-                int x_off = dixScreenOrigins[j].x;
-                int y_off = dixScreenOrigins[j].y;
+                int x_off = screenInfo.screens[j]->x;
+                int y_off = screenInfo.screens[j]->y;
 
 		if(x_off || y_off) {
 		    xPoint *pnts = (xPoint*)&stuff[1];
@@ -1420,8 +1420,8 @@ int PanoramiXPolySegment(ClientPtr client)
             if(j) memcpy(&stuff[1], origSegs, nsegs * sizeof(xSegment));
 
             if (isRoot) {
-                int x_off = dixScreenOrigins[j].x;
-                int y_off = dixScreenOrigins[j].y;
+                int x_off = screenInfo.screens[j]->x;
+                int y_off = screenInfo.screens[j]->y;
 
 		if(x_off || y_off) {
 		    xSegment *segs = (xSegment*)&stuff[1];
@@ -1483,8 +1483,8 @@ int PanoramiXPolyRectangle(ClientPtr client)
             if(j) memcpy(&stuff[1], origRecs, nrects * sizeof(xRectangle));
 
 	    if (isRoot) {
-		int x_off = dixScreenOrigins[j].x;
-		int y_off = dixScreenOrigins[j].y;
+		int x_off = screenInfo.screens[j]->x;
+		int y_off = screenInfo.screens[j]->y;
 
 
 		if(x_off || y_off) {
@@ -1545,8 +1545,8 @@ int PanoramiXPolyArc(ClientPtr client)
             if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc));
 
 	    if (isRoot) {
-		int x_off = dixScreenOrigins[j].x;
-		int y_off = dixScreenOrigins[j].y;
+		int x_off = screenInfo.screens[j]->x;
+		int y_off = screenInfo.screens[j]->y;
 	
 		if(x_off || y_off) {
 		    xArc *arcs = (xArc *) &stuff[1];
@@ -1603,8 +1603,8 @@ int PanoramiXFillPoly(ClientPtr client)
 	    if(j) memcpy(&stuff[1], locPts, count * sizeof(DDXPointRec));
 
 	    if (isRoot) {
-		int x_off = dixScreenOrigins[j].x;
-		int y_off = dixScreenOrigins[j].y;
+		int x_off = screenInfo.screens[j]->x;
+		int y_off = screenInfo.screens[j]->y;
 
 		if(x_off || y_off) {
 		    DDXPointPtr pnts = (DDXPointPtr)&stuff[1];
@@ -1666,8 +1666,8 @@ int PanoramiXPolyFillRectangle(ClientPtr client)
 	    if(j) memcpy(&stuff[1], origRects, things * sizeof(xRectangle));
 
 	    if (isRoot) {
-		int x_off = dixScreenOrigins[j].x;
-		int y_off = dixScreenOrigins[j].y;
+		int x_off = screenInfo.screens[j]->x;
+		int y_off = screenInfo.screens[j]->y;
 
 		if(x_off || y_off) {
 		    xRectangle *rects = (xRectangle *) &stuff[1];
@@ -1727,8 +1727,8 @@ int PanoramiXPolyFillArc(ClientPtr client)
 	    if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc));
 
 	    if (isRoot) {
-		int x_off = dixScreenOrigins[j].x;
-		int y_off = dixScreenOrigins[j].y;
+		int x_off = screenInfo.screens[j]->x;
+		int y_off = screenInfo.screens[j]->y;
 
 		if(x_off || y_off) {
 		    xArc *arcs = (xArc *) &stuff[1];
@@ -1780,8 +1780,8 @@ int PanoramiXPutImage(ClientPtr client)
     orig_y = stuff->dstY;
     FOR_NSCREENS_BACKWARD(j){
 	if (isRoot) {
-	  stuff->dstX = orig_x - dixScreenOrigins[j].x;
-	  stuff->dstY = orig_y - dixScreenOrigins[j].y;
+	  stuff->dstX = orig_x - screenInfo.screens[j]->x;
+	  stuff->dstY = orig_y - screenInfo.screens[j]->y;
 	}
 	stuff->drawable = draw->info[j].id;
 	stuff->gc = gc->info[j].id;
@@ -1846,10 +1846,10 @@ int PanoramiXGetImage(ClientPtr client)
 	    return(BadMatch);
     } else {
       if( /* check for being onscreen */
-	dixScreenOrigins[0].x + pDraw->x + x < 0 ||
-	dixScreenOrigins[0].x + pDraw->x + x + w > PanoramiXPixWidth ||
-	dixScreenOrigins[0].y + pDraw->y + y < 0 ||
-	dixScreenOrigins[0].y + pDraw->y + y + h > PanoramiXPixHeight ||
+	screenInfo.screens[0]->x + pDraw->x + x < 0 ||
+	screenInfo.screens[0]->x + pDraw->x + x + w > PanoramiXPixWidth ||
+	screenInfo.screens[0]->y + pDraw->y + y < 0 ||
+	screenInfo.screens[0]->y + pDraw->y + y + h > PanoramiXPixHeight ||
 	 /* check for being inside of border */
        	x < - wBorderWidth((WindowPtr)pDraw) ||
 	x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
@@ -1983,8 +1983,8 @@ PanoramiXPolyText8(ClientPtr client)
 	stuff->drawable = draw->info[j].id;
 	stuff->gc = gc->info[j].id;
 	if (isRoot) {
-	    stuff->x = orig_x - dixScreenOrigins[j].x;
-	    stuff->y = orig_y - dixScreenOrigins[j].y;
+	    stuff->x = orig_x - screenInfo.screens[j]->x;
+	    stuff->y = orig_y - screenInfo.screens[j]->y;
 	}
 	result = (*SavedProcVector[X_PolyText8])(client);
 	if(result != Success) break;
@@ -2024,8 +2024,8 @@ PanoramiXPolyText16(ClientPtr client)
 	stuff->drawable = draw->info[j].id;
 	stuff->gc = gc->info[j].id;
 	if (isRoot) {
-	    stuff->x = orig_x - dixScreenOrigins[j].x;
-	    stuff->y = orig_y - dixScreenOrigins[j].y;
+	    stuff->x = orig_x - screenInfo.screens[j]->x;
+	    stuff->y = orig_y - screenInfo.screens[j]->y;
 	}
 	result = (*SavedProcVector[X_PolyText16])(client);
 	if(result != Success) break;
@@ -2065,8 +2065,8 @@ int PanoramiXImageText8(ClientPtr client)
 	stuff->drawable = draw->info[j].id;
 	stuff->gc = gc->info[j].id;
 	if (isRoot) {
-	    stuff->x = orig_x - dixScreenOrigins[j].x;
-	    stuff->y = orig_y - dixScreenOrigins[j].y;
+	    stuff->x = orig_x - screenInfo.screens[j]->x;
+	    stuff->y = orig_y - screenInfo.screens[j]->y;
 	}
 	result = (*SavedProcVector[X_ImageText8])(client);
 	if(result != Success) break;
@@ -2106,8 +2106,8 @@ int PanoramiXImageText16(ClientPtr client)
 	stuff->drawable = draw->info[j].id;
 	stuff->gc = gc->info[j].id;
 	if (isRoot) {
-	    stuff->x = orig_x - dixScreenOrigins[j].x;
-	    stuff->y = orig_y - dixScreenOrigins[j].y;
+	    stuff->x = orig_x - screenInfo.screens[j]->x;
+	    stuff->y = orig_y - screenInfo.screens[j]->y;
 	}
 	result = (*SavedProcVector[X_ImageText16])(client);
 	if(result != Success) break;
diff --git a/Xext/shm.c b/Xext/shm.c
index 99cd39e..322709c 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -598,8 +598,8 @@ ProcPanoramiXShmPutImage(ClientPtr client)
 	stuff->drawable = draw->info[j].id;
 	stuff->gc = gc->info[j].id;
 	if (isRoot) {
-	    stuff->dstX = orig_x - dixScreenOrigins[j].x;
-	    stuff->dstY = orig_y - dixScreenOrigins[j].y;
+	    stuff->dstX = orig_x - screenInfo.screens[j]->x;
+	    stuff->dstY = orig_y - screenInfo.screens[j]->y;
 	}
 	result = ProcShmPutImage(client);
 	if(result != Success) break;
@@ -660,10 +660,10 @@ ProcPanoramiXShmGetImage(ClientPtr client)
 	    return(BadMatch);
     } else {
       if( /* check for being onscreen */
-	dixScreenOrigins[0].x + pDraw->x + x < 0 ||
-	dixScreenOrigins[0].x + pDraw->x + x + w > PanoramiXPixWidth ||
-	dixScreenOrigins[0].y + pDraw->y + y < 0 ||
-	dixScreenOrigins[0].y + pDraw->y + y + h > PanoramiXPixHeight ||
+	screenInfo.screens[0]->x + pDraw->x + x < 0 ||
+	screenInfo.screens[0]->x + pDraw->x + x + w > PanoramiXPixWidth ||
+	screenInfo.screens[0]->y + pDraw->y + y < 0 ||
+	screenInfo.screens[0]->y + pDraw->y + y + h > PanoramiXPixHeight ||
 	 /* check for being inside of border */
        	x < - wBorderWidth((WindowPtr)pDraw) ||
 	x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
index efbe973..c63706d 100644
--- a/Xext/xvdisp.c
+++ b/Xext/xvdisp.c
@@ -1690,8 +1690,8 @@ XineramaXvShmPutImage(ClientPtr client)
 	   stuff->drw_x = x;
 	   stuff->drw_y = y;
 	   if(isRoot) {
-		stuff->drw_x -= dixScreenOrigins[i].x;
-		stuff->drw_y -= dixScreenOrigins[i].y;
+		stuff->drw_x -= screenInfo.screens[i]->x;
+		stuff->drw_y -= screenInfo.screens[i]->y;
 	   }
 	   stuff->send_event = (send_event && !i) ? 1 : 0;
 
@@ -1742,8 +1742,8 @@ XineramaXvPutImage(ClientPtr client)
 	   stuff->drw_x = x;
 	   stuff->drw_y = y;
 	   if(isRoot) {
-		stuff->drw_x -= dixScreenOrigins[i].x;
-		stuff->drw_y -= dixScreenOrigins[i].y;
+		stuff->drw_x -= screenInfo.screens[i]->x;
+		stuff->drw_y -= screenInfo.screens[i]->y;
 	   }
 
 	   result = ProcXvPutImage(client);
@@ -1790,8 +1790,8 @@ XineramaXvPutVideo(ClientPtr client)
            stuff->drw_x = x;
            stuff->drw_y = y;
            if(isRoot) {
-                stuff->drw_x -= dixScreenOrigins[i].x;
-                stuff->drw_y -= dixScreenOrigins[i].y;
+                stuff->drw_x -= screenInfo.screens[i]->x;
+                stuff->drw_y -= screenInfo.screens[i]->y;
            }
 
            result = ProcXvPutVideo(client);
@@ -1838,8 +1838,8 @@ XineramaXvPutStill(ClientPtr client)
            stuff->drw_x = x;
            stuff->drw_y = y;
            if(isRoot) {
-                stuff->drw_x -= dixScreenOrigins[i].x;
-                stuff->drw_y -= dixScreenOrigins[i].y;
+                stuff->drw_x -= screenInfo.screens[i]->x;
+                stuff->drw_y -= screenInfo.screens[i]->y;
            }
 
            result = ProcXvPutStill(client);
diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
index a0c26ba..b521c48 100644
--- a/Xi/xiquerypointer.c
+++ b/Xi/xiquerypointer.c
@@ -43,6 +43,7 @@
 #include "exevents.h"
 #include "exglobals.h"
 #include "eventconvert.h"
+#include "scrnintstr.h"
 #include "xkbsrv.h"
 
 #ifdef PANORAMIX
@@ -181,12 +182,12 @@ ProcXIQueryPointer(ClientPtr client)
 
 #ifdef PANORAMIX
     if(!noPanoramiXExtension) {
-        rep.root_x += FP1616(dixScreenOrigins[0].x, 0);
-        rep.root_y += FP1616(dixScreenOrigins[0].y, 0);
+        rep.root_x += FP1616(screenInfo.screens[0]->x, 0);
+        rep.root_y += FP1616(screenInfo.screens[0]->y, 0);
         if (stuff->win == rep.root)
         {
-            rep.win_x += FP1616(dixScreenOrigins[0].x, 0);
-            rep.win_y += FP1616(dixScreenOrigins[0].y, 0);
+            rep.win_x += FP1616(screenInfo.screens[0]->x, 0);
+            rep.win_y += FP1616(screenInfo.screens[0]->y, 0);
         }
     }
 #endif
diff --git a/dix/events.c b/dix/events.c
index 21ee85e..e8e65e2 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -502,8 +502,8 @@ XineramaSetCursorPosition(
        that screen are. */
 
     pScreen = pSprite->screen;
-    x += dixScreenOrigins[0].x;
-    y += dixScreenOrigins[0].y;
+    x += screenInfo.screens[0]->x;
+    y += screenInfo.screens[0]->y;
 
     if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
 								x, y, &box))
@@ -521,10 +521,10 @@ XineramaSetCursorPosition(
     }
 
     pSprite->screen = pScreen;
-    pSprite->hotPhys.x = x - dixScreenOrigins[0].x;
-    pSprite->hotPhys.y = y - dixScreenOrigins[0].y;
-    x -= dixScreenOrigins[pScreen->myNum].x;
-    y -= dixScreenOrigins[pScreen->myNum].y;
+    pSprite->hotPhys.x = x - screenInfo.screens[0]->x;
+    pSprite->hotPhys.y = y - screenInfo.screens[0]->y;
+    x -= pScreen->x;
+    y -= pScreen->y;
 
     return (*pScreen->SetCursorPosition)(pDev, pScreen, x, y, generateEvent);
 }
@@ -542,10 +542,10 @@ XineramaConstrainCursor(DeviceIntPtr pDev)
 
     /* Translate the constraining box to the screen
        the sprite is actually on */
-    newBox.x1 += dixScreenOrigins[0].x - dixScreenOrigins[pScreen->myNum].x;
-    newBox.x2 += dixScreenOrigins[0].x - dixScreenOrigins[pScreen->myNum].x;
-    newBox.y1 += dixScreenOrigins[0].y - dixScreenOrigins[pScreen->myNum].y;
-    newBox.y2 += dixScreenOrigins[0].y - dixScreenOrigins[pScreen->myNum].y;
+    newBox.x1 += screenInfo.screens[0]->x - pScreen->x;
+    newBox.x2 += screenInfo.screens[0]->x - pScreen->x;
+    newBox.y1 += screenInfo.screens[0]->y - pScreen->y;
+    newBox.y2 += screenInfo.screens[0]->y - pScreen->y;
 
     (* pScreen->ConstrainCursor)(pDev, pScreen, &newBox);
 }
@@ -595,12 +595,12 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev,
 
     REGION_COPY(pSprite->screen, &pSprite->Reg1,
             &pSprite->windows[i]->borderSize);
-    off_x = dixScreenOrigins[i].x;
-    off_y = dixScreenOrigins[i].y;
+    off_x = screenInfo.screens[i]->x;
+    off_y = screenInfo.screens[i]->y;
 
     while(i--) {
-        x = off_x - dixScreenOrigins[i].x;
-        y = off_y - dixScreenOrigins[i].y;
+        x = off_x - screenInfo.screens[i]->x;
+        y = off_y - screenInfo.screens[i]->y;
 
         if(x || y)
             REGION_TRANSLATE(pSprite->screen, &pSprite->Reg1, x, y);
@@ -608,8 +608,8 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev,
         REGION_UNION(pSprite->screen, &pSprite->Reg1, &pSprite->Reg1,
                 &pSprite->windows[i]->borderSize);
 
-        off_x = dixScreenOrigins[i].x;
-        off_y = dixScreenOrigins[i].y;
+        off_x = screenInfo.screens[i]->x;
+        off_y = screenInfo.screens[i]->y;
     }
 
     pSprite->hotLimits = *REGION_EXTENTS(pSprite->screen, &pSprite->Reg1);
@@ -814,12 +814,12 @@ CheckVirtualMotion(
 
             REGION_COPY(pSprite->screen, &pSprite->Reg2,
                     &pSprite->windows[i]->borderSize);
-            off_x = dixScreenOrigins[i].x;
-            off_y = dixScreenOrigins[i].y;
+            off_x = screenInfo.screens[i]->x;
+            off_y = screenInfo.screens[i]->y;
 
             while(i--) {
-                x = off_x - dixScreenOrigins[i].x;
-                y = off_y - dixScreenOrigins[i].y;
+                x = off_x - screenInfo.screens[i]->x;
+                y = off_y - screenInfo.screens[i]->y;
 
                 if(x || y)
                     REGION_TRANSLATE(pSprite->screen, &pSprite->Reg2, x, y);
@@ -827,8 +827,8 @@ CheckVirtualMotion(
                 REGION_UNION(pSprite->screen, &pSprite->Reg2, &pSprite->Reg2,
                         &pSprite->windows[i]->borderSize);
 
-                off_x = dixScreenOrigins[i].x;
-                off_y = dixScreenOrigins[i].y;
+                off_x = screenInfo.screens[i]->x;
+                off_y = screenInfo.screens[i]->y;
             }
         } else
 #endif
@@ -1135,10 +1135,8 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
     {
 #ifdef PANORAMIX
 	if(!noPanoramiXExtension) {
-	    event->root_x += dixScreenOrigins[pSprite->screen->myNum].x -
-			      dixScreenOrigins[0].x;
-	    event->root_y += dixScreenOrigins[pSprite->screen->myNum].y -
-			      dixScreenOrigins[0].y;
+	    event->root_x += pSprite->screen->x - screenInfo.screens[0]->x;
+	    event->root_y += pSprite->screen->y - screenInfo.screens[0]->y;
 	}
 #endif
 	pSprite->hotPhys.x = event->root_x;
@@ -1218,10 +1216,10 @@ PlayReleasedEvents(void)
                     case ET_KeyRelease:
                     case ET_ProximityIn:
                     case ET_ProximityOut:
-                        ev->root_x += dixScreenOrigins[0].x -
-                            dixScreenOrigins[pDev->spriteInfo->sprite->screen->myNum].x;
-                        ev->root_y += dixScreenOrigins[0].y -
-                            dixScreenOrigins[pDev->spriteInfo->sprite->screen->myNum].y;
+                        ev->root_x += screenInfo.screens[0]->x -
+                            pDev->spriteInfo->sprite->screen->x;
+                        ev->root_y += screenInfo.screens[0]->y -
+                            pDev->spriteInfo->sprite->screen->y;
                         break;
                     default:
                         break;
@@ -2561,8 +2559,8 @@ PointInBorderSize(WindowPtr pWin, int x, int y)
 	for(i = 1; i < PanoramiXNumScreens; i++) {
 	   if(POINT_IN_REGION(pSprite->screen,
 			&pSprite->windows[i]->borderSize,
-			x + dixScreenOrigins[0].x - dixScreenOrigins[i].x,
-			y + dixScreenOrigins[0].y - dixScreenOrigins[i].y,
+			x + screenInfo.screens[0]->x - screenInfo.screens[i]->x,
+			y + screenInfo.screens[0]->y - screenInfo.screens[i]->y,
 			&box))
 		return TRUE;
 	}
@@ -2757,10 +2755,8 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
             /* Motion events entering DIX get translated to Screen 0
                coordinates.  Replayed events have already been
                translated since they've entered DIX before */
-            ev->root_x += dixScreenOrigins[pSprite->screen->myNum].x -
-                                       dixScreenOrigins[0].x;
-            ev->root_y += dixScreenOrigins[pSprite->screen->myNum].y -
-                                       dixScreenOrigins[0].y;
+            ev->root_x += pSprite->screen->x - screenInfo.screens[0]->x;
+            ev->root_y += pSprite->screen->y - screenInfo.screens[0]->y;
         } else
 #endif
         {
@@ -3008,10 +3004,10 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
     }
 #ifdef PANORAMIX
     if(!noPanoramiXExtension) {
-        pSprite->hotLimits.x1 = -dixScreenOrigins[0].x;
-        pSprite->hotLimits.y1 = -dixScreenOrigins[0].y;
-        pSprite->hotLimits.x2 = PanoramiXPixWidth  - dixScreenOrigins[0].x;
-        pSprite->hotLimits.y2 = PanoramiXPixHeight - dixScreenOrigins[0].y;
+        pSprite->hotLimits.x1 = -screenInfo.screens[0]->x;
+        pSprite->hotLimits.y1 = -screenInfo.screens[0]->y;
+        pSprite->hotLimits.x2 = PanoramiXPixWidth  - screenInfo.screens[0]->x;
+        pSprite->hotLimits.y2 = PanoramiXPixHeight - screenInfo.screens[0]->y;
         pSprite->physLimits = pSprite->hotLimits;
         pSprite->confineWin = NullWindow;
         pSprite->hotShape = NullRegion;
@@ -3078,10 +3074,10 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen)
 
 #ifdef PANORAMIX
     if(!noPanoramiXExtension) {
-        pSprite->hotLimits.x1 = -dixScreenOrigins[0].x;
-        pSprite->hotLimits.y1 = -dixScreenOrigins[0].y;
-        pSprite->hotLimits.x2 = PanoramiXPixWidth  - dixScreenOrigins[0].x;
-        pSprite->hotLimits.y2 = PanoramiXPixHeight - dixScreenOrigins[0].y;
+        pSprite->hotLimits.x1 = -screenInfo.screens[0]->x;
+        pSprite->hotLimits.y1 = -screenInfo.screens[0]->y;
+        pSprite->hotLimits.x2 = PanoramiXPixWidth  - screenInfo.screens[0]->x;
+        pSprite->hotLimits.y2 = PanoramiXPixHeight - screenInfo.screens[0]->y;
         pSprite->physLimits = pSprite->hotLimits;
         pSprite->screen = pScreen;
     }
@@ -3114,10 +3110,8 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y)
     pSprite->hotPhys.y = y;
 #ifdef PANORAMIX
     if(!noPanoramiXExtension) {
-	pSprite->hotPhys.x += dixScreenOrigins[newScreen->myNum].x -
-			    dixScreenOrigins[0].x;
-	pSprite->hotPhys.y += dixScreenOrigins[newScreen->myNum].y -
-			    dixScreenOrigins[0].y;
+	pSprite->hotPhys.x += newScreen->x - screenInfo.screens[0]->x;
+	pSprite->hotPhys.y += newScreen->y - screenInfo.screens[0]->y;
 	if (newScreen != pSprite->screen) {
 	    pSprite->screen = newScreen;
 	    /* Make sure we tell the DDX to update its copy of the screen */
@@ -3132,10 +3126,10 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y)
 		(*pSprite->screen->SetCursorPosition)(
                                                       pDev,
                                                       pSprite->screen,
-		    pSprite->hotPhys.x + dixScreenOrigins[0].x -
-			dixScreenOrigins[pSprite->screen->myNum].x,
-		    pSprite->hotPhys.y + dixScreenOrigins[0].y -
-			dixScreenOrigins[pSprite->screen->myNum].y, FALSE);
+		    pSprite->hotPhys.x + screenInfo.screens[0]->x -
+			pSprite->screen->x,
+		    pSprite->hotPhys.y + screenInfo.screens[0]->y -
+			pSprite->screen->y, FALSE);
 	}
     } else
 #endif
@@ -3163,14 +3157,14 @@ XineramaPointInWindowIsVisible(
 
     if(!XineramaSetWindowPntrs(inputInfo.pointer, pWin)) return FALSE;
 
-    xoff = x + dixScreenOrigins[0].x;
-    yoff = y + dixScreenOrigins[0].y;
+    xoff = x + screenInfo.screens[0]->x;
+    yoff = y + screenInfo.screens[0]->y;
 
     for(i = 1; i < PanoramiXNumScreens; i++) {
 	pWin = inputInfo.pointer->spriteInfo->sprite->windows[i];
 	pScreen = pWin->drawable.pScreen;
-	x = xoff - dixScreenOrigins[i].x;
-	y = yoff - dixScreenOrigins[i].y;
+	x = xoff - screenInfo.screens[i]->x;
+	y = yoff - screenInfo.screens[i]->y;
 
 	if(POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box)
 	   && (!wInputShape(pWin) ||
@@ -3216,8 +3210,8 @@ XineramaWarpPointer(ClientPtr client)
 	winX = source->drawable.x;
 	winY = source->drawable.y;
 	if(source == screenInfo.screens[0]->root) {
-	    winX -= dixScreenOrigins[0].x;
-	    winY -= dixScreenOrigins[0].y;
+	    winX -= screenInfo.screens[0]->x;
+	    winY -= screenInfo.screens[0]->y;
 	}
 	if (x < winX + stuff->srcX ||
 	    y < winY + stuff->srcY ||
@@ -3232,8 +3226,8 @@ XineramaWarpPointer(ClientPtr client)
 	x = dest->drawable.x;
 	y = dest->drawable.y;
 	if(dest == screenInfo.screens[0]->root) {
-	    x -= dixScreenOrigins[0].x;
-	    y -= dixScreenOrigins[0].y;
+	    x -= screenInfo.screens[0]->x;
+	    y -= screenInfo.screens[0]->y;
 	}
     }
 
@@ -4997,11 +4991,11 @@ ProcQueryPointer(ClientPtr client)
 
 #ifdef PANORAMIX
     if(!noPanoramiXExtension) {
-	rep.rootX += dixScreenOrigins[0].x;
-	rep.rootY += dixScreenOrigins[0].y;
+	rep.rootX += screenInfo.screens[0]->x;
+	rep.rootY += screenInfo.screens[0]->y;
 	if(stuff->id == rep.root) {
-	    rep.winX += dixScreenOrigins[0].x;
-	    rep.winY += dixScreenOrigins[0].y;
+	    rep.winX += screenInfo.screens[0]->x;
+	    rep.winY += screenInfo.screens[0]->y;
 	}
     }
 #endif
@@ -5670,7 +5664,7 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
 
 #ifdef PANORAMIX
     if(!noPanoramiXExtension &&
-       (dixScreenOrigins[0].x || dixScreenOrigins[0].y))
+       (screenInfo.screens[0]->x || screenInfo.screens[0]->y))
     {
 	switch(events->u.u.type) {
 	case MotionNotify:
@@ -5687,13 +5681,13 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
         */
 	    count = 1;  /* should always be 1 */
 	    memcpy(&eventCopy, events, sizeof(xEvent));
-	    eventCopy.u.keyButtonPointer.rootX += dixScreenOrigins[0].x;
-	    eventCopy.u.keyButtonPointer.rootY += dixScreenOrigins[0].y;
+	    eventCopy.u.keyButtonPointer.rootX += screenInfo.screens[0]->x;
+	    eventCopy.u.keyButtonPointer.rootY += screenInfo.screens[0]->y;
 	    if(eventCopy.u.keyButtonPointer.event ==
 	       eventCopy.u.keyButtonPointer.root)
 	    {
-		eventCopy.u.keyButtonPointer.eventX += dixScreenOrigins[0].x;
-		eventCopy.u.keyButtonPointer.eventY += dixScreenOrigins[0].y;
+		eventCopy.u.keyButtonPointer.eventX += screenInfo.screens[0]->x;
+		eventCopy.u.keyButtonPointer.eventY += screenInfo.screens[0]->y;
 	    }
 	    events = &eventCopy;
 	    break;
diff --git a/dix/getevents.c b/dix/getevents.c
index 3ca5883..3892f6f 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1210,8 +1210,8 @@ PostSyntheticMotion(DeviceIntPtr pDev,
        will translate from sprite screen to screen 0 upon reentry
        to the DIX layer. */
     if (!noPanoramiXExtension) {
-        x += dixScreenOrigins[0].x - dixScreenOrigins[screen].x;
-        y += dixScreenOrigins[0].y - dixScreenOrigins[screen].y;
+        x += screenInfo.screens[0]->x - screenInfo.screens[screen]->x;
+        y += screenInfo.screens[0]->y - screenInfo.screens[screen]->y;
     }
 #endif
 
diff --git a/dix/globals.c b/dix/globals.c
index 28e7d07..82a85c2 100644
--- a/dix/globals.c
+++ b/dix/globals.c
@@ -135,5 +135,3 @@ char *display;
 char *ConnectionInfo;
 
 CARD32 TimeOutValue = DEFAULT_TIMEOUT * MILLI_PER_SECOND;
-
-DDXPointRec dixScreenOrigins[MAXSCREENS];
diff --git a/dix/window.c b/dix/window.c
index 8345523..9e1f491 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -2236,8 +2236,8 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
 	event.u.configureRequest.y = y;
 #ifdef PANORAMIX
 	if(!noPanoramiXExtension && (!pParent || !pParent->parent)) {
-            event.u.configureRequest.x += dixScreenOrigins[0].x;
-            event.u.configureRequest.y += dixScreenOrigins[0].y;
+            event.u.configureRequest.x += screenInfo.screens[0]->x;
+            event.u.configureRequest.y += screenInfo.screens[0]->y;
 	}
 #endif
 	event.u.configureRequest.width = w;
@@ -2317,8 +2317,8 @@ ActuallyDoSomething:
 	event.u.configureNotify.y = y;
 #ifdef PANORAMIX
 	if(!noPanoramiXExtension && (!pParent || !pParent->parent)) {
-	    event.u.configureNotify.x += dixScreenOrigins[0].x;
-	    event.u.configureNotify.y += dixScreenOrigins[0].y;
+	    event.u.configureNotify.x += screenInfo.screens[0]->x;
+	    event.u.configureNotify.y += screenInfo.screens[0]->y;
 	}
 #endif
 	event.u.configureNotify.width = w;
@@ -2471,8 +2471,8 @@ ReparentWindow(WindowPtr pWin, WindowPtr pParent,
     event.u.reparent.y = y;
 #ifdef PANORAMIX
     if(!noPanoramiXExtension && !pParent->parent) {
-	event.u.reparent.x += dixScreenOrigins[0].x;
-	event.u.reparent.y += dixScreenOrigins[0].y;
+	event.u.reparent.x += screenInfo.screens[0]->x;
+	event.u.reparent.y += screenInfo.screens[0]->y;
     }
 #endif
     event.u.reparent.override = pWin->overrideRedirect;
diff --git a/hw/dmx/dmxcursor.c b/hw/dmx/dmxcursor.c
index bf5640d..7e03686 100644
--- a/hw/dmx/dmxcursor.c
+++ b/hw/dmx/dmxcursor.c
@@ -230,7 +230,7 @@ static int dmxSLFindNext(int *list)
 /** Make one pass over all the screens and return the number updated. */
 static int dmxTryComputeScreenOrigins(int *screensLeft)
 {
-    ScreenPtr       pScreen;
+    ScreenPtr       pScreen, refScreen;
     DMXScreenInfo   *screen;
     int             i, ref;
     int             changed = 0;
@@ -239,54 +239,56 @@ static int dmxTryComputeScreenOrigins(int *screensLeft)
         if (!screensLeft[i])
             continue;
         screen  = &dmxScreens[i];
+        pScreen = screenInfo.screens[i];
         switch (screen->where) {
         case PosAbsolute:
-            dixScreenOrigins[i].x = screen->whereX;
-            dixScreenOrigins[i].y = screen->whereY;
+            pScreen->x = screen->whereX;
+            pScreen->y = screen->whereY;
             ++changed, screensLeft[i] = 0;
             break;
         case PosRelative:
             ref = screen->whereRefScreen;
             if (screensLeft[ref])
                 break;
-            dixScreenOrigins[i].x = dixScreenOrigins[ref].x + screen->whereX;
-            dixScreenOrigins[i].y = dixScreenOrigins[ref].y + screen->whereY;
+            refScreen = screenInfo.screens[ref];
+            pScreen->x = refScreen->x + screen->whereX;
+            pScreen->y = refScreen->y + screen->whereY;
             ++changed, screensLeft[i] = 0;
             break;
         case PosRightOf:
             ref = screen->whereRefScreen;
             if (screensLeft[ref])
                 break;
-            pScreen = screenInfo.screens[ref];
-            dixScreenOrigins[i].x = dixScreenOrigins[ref].x + pScreen->width;
-            dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+            refScreen = screenInfo.screens[ref];
+            pScreen->x = refScreen->x + refScreen->width;
+            pScreen->y = refScreen->y;
             ++changed, screensLeft[i] = 0;
             break;
         case PosLeftOf:
             ref = screen->whereRefScreen;
             if (screensLeft[ref])
                 break;
-            pScreen = screenInfo.screens[i];
-            dixScreenOrigins[i].x = dixScreenOrigins[ref].x - pScreen->width;
-            dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+            refScreen = screenInfo.screens[ref];
+            pScreen->x = refScreen->x - pScreen->width;
+            pScreen->y = refScreen->y;
             ++changed, screensLeft[i] = 0;
             break;
         case PosBelow:
             ref = screen->whereRefScreen;
             if (screensLeft[ref])
                 break;
-            pScreen = screenInfo.screens[ref];
-            dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
-            dixScreenOrigins[i].y = dixScreenOrigins[ref].y + pScreen->height;
+            refScreen = screenInfo.screens[ref];
+            pScreen->x = refScreen->x;
+            pScreen->y = refScreen->y + refScreen->height;
             ++changed, screensLeft[i] = 0;
             break;
         case PosAbove:
             ref = screen->whereRefScreen;
             if (screensLeft[ref])
                 break;
-            pScreen = screenInfo.screens[i];
-            dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
-            dixScreenOrigins[i].y = dixScreenOrigins[ref].y - pScreen->height;
+            refScreen = screenInfo.screens[ref];
+            pScreen->x = refScreen->x;
+            pScreen->y = refScreen->y - pScreen->height;
             ++changed, screensLeft[i] = 0;
             break;
         case PosNone:
@@ -298,6 +300,7 @@ static int dmxTryComputeScreenOrigins(int *screensLeft)
 
 static void dmxComputeScreenOrigins(void)
 {
+    ScreenPtr       pScreen;
     int             *screensLeft;
     int             i, ref;
     int             minX, minY;
@@ -313,8 +316,9 @@ static void dmxComputeScreenOrigins(void)
 	     * guarantees that we will eventually terminate.
 	     */
 	    ref                     = dmxScreens[i].whereRefScreen;
-	    dixScreenOrigins[ref].x = dixScreenOrigins[ref].y = 0;
-            screensLeft[ref]        = 0;
+	    pScreen                 = screenInfo.screens[ref];
+	    pScreen->x = pScreen->y = 0;
+	    screensLeft[ref]        = 0;
 	}
     }
     dmxSLFree(screensLeft);
@@ -322,18 +326,18 @@ static void dmxComputeScreenOrigins(void)
 
                                 /* Justify the topmost and leftmost to
                                  * (0,0). */
-    minX = dixScreenOrigins[0].x;
-    minY = dixScreenOrigins[0].y;
+    minX = screenInfo.screens[0]->x;
+    minY = screenInfo.screens[0]->y;
     for (i = 1; i < dmxNumScreens; i++) { /* Compute minX, minY */
-	if (dixScreenOrigins[i].x < minX)
-            minX = dixScreenOrigins[i].x;
-	if (dixScreenOrigins[i].y < minY)
-            minY = dixScreenOrigins[i].y;
+	if (screenInfo.screens[i]->x < minX)
+            minX = screenInfo.screens[i]->x;
+	if (screenInfo.screens[i]->y < minY)
+            minY = screenInfo.screens[i]->y;
     }
     if (minX || minY) {
 	for (i = 0; i < dmxNumScreens; i++) {
-	    dixScreenOrigins[i].x -= minX;
-	    dixScreenOrigins[i].y -= minY;
+	    screenInfo.screens[i]->x -= minX;
+	    screenInfo.screens[i]->y -= minY;
 	}
     }
 }
@@ -398,8 +402,8 @@ void dmxInitOrigins(void)
 
     for (i = 0; i < dmxNumScreens; i++) {
         DMXScreenInfo  *dmxScreen = &dmxScreens[i];
-        dmxScreen->rootXOrigin = dixScreenOrigins[i].x;
-        dmxScreen->rootYOrigin = dixScreenOrigins[i].y;
+        dmxScreen->rootXOrigin = screenInfo.screens[i]->x;
+        dmxScreen->rootYOrigin = screenInfo.screens[i]->y;
     }
 
     dmxReInitOrigins();
diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c
index 678f290..5945a5e 100644
--- a/hw/dmx/dmxextension.c
+++ b/hw/dmx/dmxextension.c
@@ -447,12 +447,12 @@ static void dmxSetRootWindowOrigin(int idx, int x, int y)
     dmxScreen->rootYOrigin = y;
 
     /* Compute offsets here in case <x,y> has been changed above */
-    xoff = x - dixScreenOrigins[idx].x;
-    yoff = y - dixScreenOrigins[idx].y;
+    xoff = x - pScreen->x;
+    yoff = y - pScreen->y;
 
-    /* Adjust the root window's position in dixScreenOrigins */
-    dixScreenOrigins[idx].x = dmxScreen->rootXOrigin;
-    dixScreenOrigins[idx].y = dmxScreen->rootYOrigin;
+    /* Adjust the root window's position */
+    pScreen->x = dmxScreen->rootXOrigin;
+    pScreen->y = dmxScreen->rootYOrigin;
 
     /* Recalculate the Xinerama regions and data structs */
     XineramaReinitData(pScreen);
diff --git a/hw/dmx/doc/dmx.xml b/hw/dmx/doc/dmx.xml
index 251e6ac..d0c83bb 100644
--- a/hw/dmx/doc/dmx.xml
+++ b/hw/dmx/doc/dmx.xml
@@ -1511,8 +1511,7 @@ PanoramiX prefix.
     physical screen, and single region (PanoramiXScreenRegion) is
     initialized to be the union of the screen regions.
     The relative positioning information for the
-    physical screens is taken from the array
-    dixScreenOrigins&lsqb;&rsqb;, which
+    physical screens is taken from the ScreenRec x and y members, which
     the DDX layer must initialize in InitOutput().  The bounds of the
     combined screen is also calculated (PanoramiXPixWidth and
     PanoramiXPixHeight).
diff --git a/hw/dmx/input/dmxcommon.c b/hw/dmx/input/dmxcommon.c
index 2f23d1c..c665dad 100644
--- a/hw/dmx/input/dmxcommon.c
+++ b/hw/dmx/input/dmxcommon.c
@@ -526,10 +526,9 @@ int dmxFindPointerScreen(int x, int y)
     int i;
 
     for (i = 0; i < dmxNumScreens; i++) {
-	if (x >= dixScreenOrigins[i].x
-            && x < dixScreenOrigins[i].x + screenInfo.screens[i]->width
-            && y >= dixScreenOrigins[i].y
-            && y < dixScreenOrigins[i].y + screenInfo.screens[i]->height)
+	ScreenPtr pScreen = screenInfo.screens[i];
+	if (x >= pScreen->x && x < pScreen->x + pScreen->width &&
+	    y >= pScreen->y && y < pScreen->y + pScreen->height)
 	    return i;
     }
     return -1;
diff --git a/hw/dmx/input/dmxconsole.c b/hw/dmx/input/dmxconsole.c
index bf34169..297166e 100644
--- a/hw/dmx/input/dmxconsole.c
+++ b/hw/dmx/input/dmxconsole.c
@@ -204,7 +204,8 @@ static void dmxConsoleDrawWindows(pointer private)
     XUnionRectWithRegion(&rect, whole, whole);
     
     for (i = 0; i < dmxNumScreens; i++) {
-        WindowPtr     pRoot       = screenInfo.screens[i]->root;
+        ScreenPtr     pScreen     = screenInfo.screens[i];
+        WindowPtr     pRoot       = pScreen->root;
         WindowPtr     pChild;
 
 #if DMX_WINDOW_DEBUG
@@ -227,10 +228,8 @@ static void dmxConsoleDrawWindows(pointer private)
                        pChild->overrideRedirect,
                        REGION_NUM_RECTS(&pChild->clipList));
 #endif
-                rect.x      = scalex(priv, pChild->drawable.x
-                                     + dixScreenOrigins[i].x);
-                rect.y      = scaley(priv, pChild->drawable.y
-                                     + dixScreenOrigins[i].y);
+                rect.x      = scalex(priv, pChild->drawable.x + pScreen->x);
+                rect.y      = scaley(priv, pChild->drawable.y + pScreen->y);
                 rect.width  = scalex(priv, pChild->drawable.width);
                 rect.height = scaley(priv, pChild->drawable.height);
                 XDrawRectangle(dpy, priv->pixmap, priv->gc,
@@ -263,15 +262,15 @@ static void dmxConsoleDraw(myPrivate *priv, int updateCursor, int update)
         DMXScreenInfo *dmxScreen = &dmxScreens[i];
 	XFillRectangle(dpy, priv->pixmap,
                        dmxScreen->beDisplay ? priv->gcRev : priv->gcDet,
-                       scalex(priv, dixScreenOrigins[i].x),
-                       scaley(priv, dixScreenOrigins[i].y),
+                       scalex(priv, screenInfo.screens[i]->x),
+                       scaley(priv, screenInfo.screens[i]->y),
                        scalex(priv, screenInfo.screens[i]->width),
                        scaley(priv, screenInfo.screens[i]->height));
     }
     for (i = 0; i < dmxNumScreens; i++) {
         XDrawRectangle(dpy, priv->pixmap, priv->gc,
-                       scalex(priv, dixScreenOrigins[i].x),
-                       scaley(priv, dixScreenOrigins[i].y),
+                       scalex(priv, screenInfo.screens[i]->x),
+                       scaley(priv, screenInfo.screens[i]->y),
                        scalex(priv, screenInfo.screens[i]->width),
                        scaley(priv, screenInfo.screens[i]->height));
     }
@@ -671,11 +670,11 @@ static void dmxConsoleComputeWidthHeight(myPrivate *priv,
                                  * possible by computing the visible
                                  * bounding box. */
     for (i = 0; i < dmxNumScreens; i++) {
-	if (dixScreenOrigins[i].x+screenInfo.screens[i]->width > *width)
-	    *width = dixScreenOrigins[i].x+screenInfo.screens[i]->width;
+	if (screenInfo.screens[i]->x+screenInfo.screens[i]->width > *width)
+	    *width = screenInfo.screens[i]->x+screenInfo.screens[i]->width;
         
-	if (dixScreenOrigins[i].y+screenInfo.screens[i]->height > *height)
-	    *height = dixScreenOrigins[i].y+screenInfo.screens[i]->height;
+	if (screenInfo.screens[i]->y+screenInfo.screens[i]->height > *height)
+	    *height = screenInfo.screens[i]->y+screenInfo.screens[i]->height;
     }
 #endif
 
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 10df02d..7993f9b 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -941,9 +941,8 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
     pScreenPriv->card = card;
     pScreenPriv->bytesPerPixel = screen->fb.bitsPerPixel >> 3;
     pScreenPriv->dpmsState = KD_DPMS_NORMAL;
-#ifdef PANORAMIX
-    dixScreenOrigins[pScreen->myNum] = screen->origin;
-#endif
+    pScreen->x = screen->origin.x;
+    pScreen->y = screen->origin.y;
 
     if (!monitorResolution)
 	monitorResolution = 75;
diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c
index 9cde059..714743a 100644
--- a/hw/xfree86/common/xf86Cursor.c
+++ b/hw/xfree86/common/xf86Cursor.c
@@ -581,7 +581,7 @@ xf86InitOrigins(void)
 {
     unsigned long screensLeft, prevScreensLeft, mask;
     screenLayoutPtr screen;
-    ScreenPtr pScreen;
+    ScreenPtr pScreen, refScreen;
     int x1, x2, y1, y2, left, right, top, bottom;
     int i, j, ref, minX, minY, min, max;
     xf86ScreenLayoutPtr pLayout;
@@ -608,6 +608,7 @@ xf86InitOrigins(void)
 	        continue;
 	    }
 
+	    pScreen = xf86Screens[i]->pScreen;
 	    switch(screen->where) {
 	    case PosObsolete:
 		OldStyleConfig = TRUE;
@@ -620,7 +621,7 @@ xf86InitOrigins(void)
 			break;
 		    }
 		    pLayout->left = AddEdge(pLayout->left, 
-			0, xf86Screens[i]->pScreen->height,
+			0, pScreen->height,
 			xf86Screens[ref]->pScreen->width, 0, ref);
 		}
 		if(screen->right) {
@@ -629,7 +630,6 @@ xf86InitOrigins(void)
 			ErrorF("Referenced uninitialized screen in Layout!\n");
 			break;
 		    }
-		    pScreen = xf86Screens[i]->pScreen;
 		    pLayout->right = AddEdge(pLayout->right, 
 			0, pScreen->height, -pScreen->width, 0, ref);
 		}
@@ -640,7 +640,7 @@ xf86InitOrigins(void)
 			break;
 		    }
 		    pLayout->up = AddEdge(pLayout->up, 
-			0, xf86Screens[i]->pScreen->width,
+			0, pScreen->width,
 			0, xf86Screens[ref]->pScreen->height, ref);
 		}
 		if(screen->bottom) {
@@ -649,7 +649,6 @@ xf86InitOrigins(void)
 			ErrorF("Referenced uninitialized screen in Layout!\n");
 			break;
 		    }
-		    pScreen = xf86Screens[i]->pScreen;
 		    pLayout->down = AddEdge(pLayout->down, 
 			0, pScreen->width, 0, -pScreen->height, ref);
 		}
@@ -658,8 +657,8 @@ xf86InitOrigins(void)
 		screen->x = screen->y = 0;
 		/* FALLTHROUGH */
 	    case PosAbsolute:
-		dixScreenOrigins[i].x = screen->x;
-		dixScreenOrigins[i].y = screen->y;
+		pScreen->x = screen->x;
+		pScreen->y = screen->y;
 		screensLeft &= ~(1 << i);
 		break;
 	    case PosRelative:
@@ -669,8 +668,9 @@ xf86InitOrigins(void)
 		    break;
 		}
 		if(screensLeft & (1 << ref)) break;
-		dixScreenOrigins[i].x = dixScreenOrigins[ref].x + screen->x;
-		dixScreenOrigins[i].y = dixScreenOrigins[ref].y + screen->y;
+		refScreen = xf86Screens[ref]->pScreen;
+		pScreen->x = refScreen->x + screen->x;
+		pScreen->y = refScreen->y + screen->y;
 		screensLeft &= ~(1 << i);
 		break;
 	    case PosRightOf:
@@ -680,10 +680,9 @@ xf86InitOrigins(void)
 		    break;
 		}
 		if(screensLeft & (1 << ref)) break;
-		pScreen = xf86Screens[ref]->pScreen;
-		dixScreenOrigins[i].x = 
-			dixScreenOrigins[ref].x + pScreen->width;
-		dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+		refScreen = xf86Screens[ref]->pScreen;
+		pScreen->x = refScreen->x + refScreen->width;
+		pScreen->y = refScreen->y;
 		screensLeft &= ~(1 << i);
 		break;
 	    case PosLeftOf:
@@ -693,10 +692,9 @@ xf86InitOrigins(void)
 		    break;
 		}
 		if(screensLeft & (1 << ref)) break;
-		pScreen = xf86Screens[i]->pScreen;
-		dixScreenOrigins[i].x = 
-			dixScreenOrigins[ref].x - pScreen->width;
-		dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+		refScreen = xf86Screens[ref]->pScreen;
+		pScreen->x = refScreen->x - pScreen->width;
+		pScreen->y = refScreen->y;
 		screensLeft &= ~(1 << i);
 		break;
 	    case PosBelow:
@@ -706,10 +704,9 @@ xf86InitOrigins(void)
 		    break;
 		}
 		if(screensLeft & (1 << ref)) break;
-		pScreen = xf86Screens[ref]->pScreen;
-		dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
-		dixScreenOrigins[i].y = 
-			dixScreenOrigins[ref].y + pScreen->height;
+		refScreen = xf86Screens[ref]->pScreen;
+		pScreen->x = refScreen->x;
+		pScreen->y = refScreen->y + refScreen->height;
 		screensLeft &= ~(1 << i);
 		break;
 	    case PosAbove:
@@ -719,10 +716,9 @@ xf86InitOrigins(void)
 		    break;
 		}
 		if(screensLeft & (1 << ref)) break;
-		pScreen = xf86Screens[i]->pScreen;
-		dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
-		dixScreenOrigins[i].y = 
-			dixScreenOrigins[ref].y - pScreen->height;
+		refScreen = xf86Screens[ref]->pScreen;
+		pScreen->x = refScreen->x;
+		pScreen->y = refScreen->y - pScreen->height;
 		screensLeft &= ~(1 << i);
 		break;
 	    default:
@@ -741,7 +737,7 @@ xf86InitOrigins(void)
 	    while(!((1 << i) & screensLeft)){ i++; }
 
 	    ref = xf86ConfigLayout.screens[i].refscreen->screennum;
-	    dixScreenOrigins[ref].x = dixScreenOrigins[ref].y = 0;
+	    xf86Screens[ref]->pScreen->x = xf86Screens[ref]->pScreen->y = 0;
 	    screensLeft &= ~(1 << ref);
 	}
 
@@ -749,20 +745,20 @@ xf86InitOrigins(void)
     }
 
     /* justify the topmost and leftmost to (0,0) */
-    minX = dixScreenOrigins[0].x;
-    minY = dixScreenOrigins[0].y;
+    minX = xf86Screens[0]->pScreen->x;
+    minY = xf86Screens[0]->pScreen->y;
 
     for(i = 1; i < xf86NumScreens; i++) {
-	if(dixScreenOrigins[i].x < minX)
-	  minX = dixScreenOrigins[i].x;
-	if(dixScreenOrigins[i].y < minY)
-	  minY = dixScreenOrigins[i].y;
+	if(xf86Screens[i]->pScreen->x < minX)
+	  minX = xf86Screens[i]->pScreen->x;
+	if(xf86Screens[i]->pScreen->y < minY)
+	  minY = xf86Screens[i]->pScreen->y;
     }
 
     if (minX || minY) {
 	for(i = 0; i < xf86NumScreens; i++) {
-	   dixScreenOrigins[i].x -= minX;
-	   dixScreenOrigins[i].y -= minY;
+	   xf86Screens[i]->pScreen->x -= minX;
+	   xf86Screens[i]->pScreen->y -= minY;
 	}
     }
 
@@ -775,18 +771,20 @@ xf86InitOrigins(void)
 
 	pScreen = xf86Screens[i]->pScreen;
 
-	left = dixScreenOrigins[i].x;
+	left = pScreen->x;
 	right = left + pScreen->width;
-	top = dixScreenOrigins[i].y;
+	top = pScreen->y;
 	bottom = top + pScreen->height;
 
 	for(j = 0; j < xf86NumScreens; j++) {
 	    if(i == j) continue;
 
-	    x1 = dixScreenOrigins[j].x;
-	    x2 = x1 + xf86Screens[j]->pScreen->width;
-	    y1 = dixScreenOrigins[j].y;
-	    y2 = y1 + xf86Screens[j]->pScreen->height;
+	    refScreen = xf86Screens[j]->pScreen;
+
+	    x1 = refScreen->x;
+	    x2 = x1 + refScreen->width;
+	    y1 = refScreen->y;
+	    y2 = y1 + refScreen->height;
 
 	    if((bottom > y1) && (top < y2)) {
 		min = y1 - top;
@@ -796,13 +794,13 @@ xf86InitOrigins(void)
 
 		if(((left - 1) >= x1) && ((left - 1) < x2))
 		    pLayout->left = AddEdge(pLayout->left, min, max,
-			dixScreenOrigins[i].x - dixScreenOrigins[j].x,
-			dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+			pScreen->x - refScreen->x,
+			pScreen->y - refScreen->y, j);
 
 		if((right >= x1) && (right < x2))	
 		    pLayout->right = AddEdge(pLayout->right, min, max,
-			dixScreenOrigins[i].x - dixScreenOrigins[j].x,
-			dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+			pScreen->x - refScreen->x,
+			pScreen->y - refScreen->y, j);
 	    }
 
 
@@ -814,13 +812,13 @@ xf86InitOrigins(void)
 
 		if(((top - 1) >= y1) && ((top - 1) < y2))
 		    pLayout->up = AddEdge(pLayout->up, min, max,
-			dixScreenOrigins[i].x - dixScreenOrigins[j].x,
-			dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+			pScreen->x - refScreen->x,
+			pScreen->y - refScreen->y, j);
 
 		if((bottom >= y1) && (bottom < y2))
 		    pLayout->down = AddEdge(pLayout->down, min, max,
-			dixScreenOrigins[i].x - dixScreenOrigins[j].x,
-			dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+			pScreen->x - refScreen->x,
+			pScreen->y - refScreen->y, j);
 	    }
 	}
       }
diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c
index 0845f67..1c77ad9 100644
--- a/hw/xquartz/applewm.c
+++ b/hw/xquartz/applewm.c
@@ -140,10 +140,8 @@ AppleWMSetScreenOrigin(
 {
     int32_t data[2];
 
-    data[0] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].x
-                + darwinMainScreenX);
-    data[1] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].y
-                + darwinMainScreenY);
+    data[0] = pWin->drawable.pScreen->x + darwinMainScreenX;
+    data[1] = pWin->drawable.pScreen->y + darwinMainScreenY;
 
     dixChangeWindowProperty(serverClient, pWin, xa_native_screen_origin(),
 			    XA_INTEGER, 32, PropModeReplace, 2, data, TRUE);
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 825afa0..7453ecc 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -262,8 +262,8 @@ static Bool DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv
         return FALSE;
     }
 
-    dixScreenOrigins[index].x = dfb->x;
-    dixScreenOrigins[index].y = dfb->y;
+    pScreen->x = dfb->x;
+    pScreen->y = dfb->y;
 
     /*    ErrorF("Screen %d added: %dx%d @ (%d,%d)\n",
 	  index, dfb->width, dfb->height, dfb->x, dfb->y); */
@@ -526,16 +526,16 @@ DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo)
 {
     int i, left, top;
 
-    left = dixScreenOrigins[0].x;
-    top  = dixScreenOrigins[0].y;
+    left = pScreenInfo->screens[0]->x;
+    top  = pScreenInfo->screens[0]->y;
 
     /* Find leftmost screen. If there's a tie, take the topmost of the two. */
     for (i = 1; i < pScreenInfo->numScreens; i++) {
-        if (dixScreenOrigins[i].x < left  ||
-            (dixScreenOrigins[i].x == left && dixScreenOrigins[i].y < top))
+        if (pScreenInfo->screens[i]->x < left  ||
+            (pScreenInfo->screens[i]->x == left && pScreenInfo->screens[i]->y < top))
         {
-            left = dixScreenOrigins[i].x;
-            top = dixScreenOrigins[i].y;
+            left = pScreenInfo->screens[i]->x;
+            top = pScreenInfo->screens[i]->y;
         }
     }
 
@@ -551,10 +551,10 @@ DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo)
 
     if (darwinMainScreenX != 0 || darwinMainScreenY != 0) {
         for (i = 0; i < pScreenInfo->numScreens; i++) {
-            dixScreenOrigins[i].x -= darwinMainScreenX;
-            dixScreenOrigins[i].y -= darwinMainScreenY;
+            pScreenInfo->screens[i]->x -= darwinMainScreenX;
+            pScreenInfo->screens[i]->y -= darwinMainScreenY;
             DEBUG_LOG("Screen %d placed at X11 coordinate (%d,%d).\n",
-                      i, dixScreenOrigins[i].x, dixScreenOrigins[i].y);
+                      i, pScreenInfo->screens[i]->x, pScreenInfo->screens[i]->y);
         }
     }
 }
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 421efce..147b32a 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -377,8 +377,8 @@ static void DarwinPrepareValuators(DeviceIntPtr pDev, int *valuators, ScreenPtr
                                    float pointer_x, float pointer_y, 
                                    float pressure, float tilt_x, float tilt_y) {
     /* Fix offset between darwin and X screens */
-    pointer_x -= darwinMainScreenX + dixScreenOrigins[screen->myNum].x;
-    pointer_y -= darwinMainScreenY + dixScreenOrigins[screen->myNum].y;
+    pointer_x -= darwinMainScreenX + screen->x;
+    pointer_y -= darwinMainScreenY + screen->y;
 
     if(pointer_x < 0.0)
         pointer_x = 0.0;
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index ac7fedd..bb37e4a 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -259,8 +259,8 @@ void QuartzUpdateScreens(void) {
     PseudoramiXResetScreens();
     quartzProcs->AddPseudoramiXScreens(&x, &y, &width, &height);
     
-    dixScreenOrigins[pScreen->myNum].x = x;
-    dixScreenOrigins[pScreen->myNum].y = y;
+    pScreen->x = x;
+    pScreen->y = y;
     pScreen->mmWidth = pScreen->mmWidth * ((double) width / pScreen->width);
     pScreen->mmHeight = pScreen->mmHeight * ((double) height / pScreen->height);
     pScreen->width = width;
@@ -269,11 +269,11 @@ void QuartzUpdateScreens(void) {
     DarwinAdjustScreenOrigins(&screenInfo);
     quartzProcs->UpdateScreen(pScreen);
     
-    /* DarwinAdjustScreenOrigins or UpdateScreen may change dixScreenOrigins,
+    /* DarwinAdjustScreenOrigins or UpdateScreen may change pScreen->x/y,
      * so use it rather than x/y
      */
-    sx = dixScreenOrigins[pScreen->myNum].x + darwinMainScreenX;
-    sy = dixScreenOrigins[pScreen->myNum].y + darwinMainScreenY;
+    sx = pScreen->x + darwinMainScreenX;
+    sy = pScreen->y + darwinMainScreenY;
     
     /* Adjust the root window. */
     pRoot = pScreen->root;
@@ -292,7 +292,7 @@ void QuartzUpdateScreens(void) {
     inputInfo.pointer->spriteInfo->sprite->physLimits = bounds;
     inputInfo.pointer->spriteInfo->sprite->hotLimits = bounds;
 
-    DEBUG_LOG("Root Window: %dx%d @ (%d, %d) darwinMainScreen (%d, %d) xy (%d, %d) dixScreenOrigins (%d, %d)\n", width, height, x - sx, y - sy, darwinMainScreenX, darwinMainScreenY, x, y, dixScreenOrigins[pScreen->myNum].x, dixScreenOrigins[pScreen->myNum].y);
+    DEBUG_LOG("Root Window: %dx%d @ (%d, %d) darwinMainScreen (%d, %d) xy (%d, %d) dixScreenOrigins (%d, %d)\n", width, height, x - sx, y - sy, darwinMainScreenX, darwinMainScreenY, x, y, pScreen->x, pScreen->y);
 
     /* Send an event for the root reconfigure */
     e.u.u.type = ConfigureNotify;
diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c
index c1c8b20..fdb8563 100644
--- a/hw/xquartz/xpr/xprCursor.c
+++ b/hw/xquartz/xpr/xprCursor.c
@@ -296,8 +296,8 @@ QuartzWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
     {
         int sx, sy;
 
-        sx = dixScreenOrigins[pScreen->myNum].x + darwinMainScreenX;
-        sy = dixScreenOrigins[pScreen->myNum].y + darwinMainScreenY;
+        sx = pScreen->x + darwinMainScreenX;
+        sy = pScreen->y + darwinMainScreenY;
 
         CGWarpMouseCursorPosition(CGPointMake(sx + x, sy + y));
     }
diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c
index 4fa987c..7add0e3 100644
--- a/hw/xwin/winscrinit.c
+++ b/hw/xwin/winscrinit.c
@@ -243,11 +243,11 @@ winScreenInit (int index,
      Note the screen origin in a normalized coordinate space where (0,0) is at the top left
      of the native virtual desktop area
   */
-  dixScreenOrigins[index].x = pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN);
-  dixScreenOrigins[index].y = pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN);
+  pScreen->x = pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN);
+  pScreen->y = pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN);
 
   ErrorF("Screen %d added at virtual desktop coordinate (%d,%d).\n",
-         index, dixScreenOrigins[index].x, dixScreenOrigins[index].y);
+         index, pScreen->x, pScreen->y);
 
 #if CYGDEBUG || YES
   winDebug ("winScreenInit - returning\n");
diff --git a/include/globals.h b/include/globals.h
index 7de262f..8b80a65 100644
--- a/include/globals.h
+++ b/include/globals.h
@@ -22,8 +22,6 @@ extern _X_EXPORT int defaultColorVisualClass;
 extern _X_EXPORT int GrabInProgress;
 extern _X_EXPORT Bool noTestExtensions;
 
-extern _X_EXPORT DDXPointRec dixScreenOrigins[MAXSCREENS];
-
 extern _X_EXPORT char *ConnectionInfo;
 
 #ifdef DPMSExtension
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index f8171ca..d67b264 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -456,7 +456,7 @@ typedef    void (* DeviceCursorCleanupProcPtr)(
 typedef struct _Screen {
     int			myNum;	/* index of this instance in Screens[] */
     ATOM		id;
-    short		width, height;
+    short		x, y, width, height;
     short		mmWidth, mmHeight;
     short		numDepths;
     unsigned char      	rootDepth;
diff --git a/mi/miexpose.c b/mi/miexpose.c
index ee3ef72..088149b 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -424,8 +424,8 @@ miSendExposures( WindowPtr pWin, RegionPtr pRgn, int dx, int dy)
 	XID realWin = 0;
 
 	if(!pWin->parent) {
-	    x = dixScreenOrigins[scrnum].x;
-	    y = dixScreenOrigins[scrnum].y;
+	    x = screenInfo.screens[scrnum]->x;
+	    y = screenInfo.screens[scrnum]->y;
 	    pWin = screenInfo.screens[0]->root;
 	    realWin = pWin->drawable.id;
 	} else if (scrnum) {
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 5955cd9..ce088c7 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -53,9 +53,9 @@ extern Bool no_configure_window;
 
 #ifdef ROOTLESS_GLOBAL_COORDS
 #define SCREEN_TO_GLOBAL_X \
-    (dixScreenOrigins[pScreen->myNum].x + rootlessGlobalOffsetX)
+    (pScreen->x + rootlessGlobalOffsetX)
 #define SCREEN_TO_GLOBAL_Y \
-    (dixScreenOrigins[pScreen->myNum].y + rootlessGlobalOffsetY)
+    (pScreen->y + rootlessGlobalOffsetY)
 #else
 #define SCREEN_TO_GLOBAL_X 0
 #define SCREEN_TO_GLOBAL_Y 0
@@ -109,8 +109,8 @@ void RootlessNativeWindowMoved (WindowPtr pWin) {
     
     if (xp_get_window_bounds (MAKE_WINDOW_ID(winRec->wid), &bounds) != Success) return;
     
-    sx = dixScreenOrigins[pWin->drawable.pScreen->myNum].x + darwinMainScreenX;
-    sy = dixScreenOrigins[pWin->drawable.pScreen->myNum].y + darwinMainScreenY;
+    sx = pWin->drawable.pScreen->x + darwinMainScreenX;
+    sy = pWin->drawable.pScreen->y + darwinMainScreenY;
     
     /* Fake up a ConfigureWindow packet to resize the window to the current bounds. */
     vlist[0] = (INT16) bounds.x1 - sx;
diff --git a/record/record.c b/record/record.c
index b81b7b2..46231c9 100644
--- a/record/record.c
+++ b/record/record.c
@@ -43,6 +43,7 @@ and Jim Haggerty of Metheus.
 #include "swaprep.h"
 #include "inputstr.h"
 #include "eventconvert.h"
+#include "scrnintstr.h"
 
 
 #include <stdio.h>
@@ -755,11 +756,11 @@ RecordSendProtocolEvents(RecordClientsAndProtocolPtr pRCAP,
 		int scr = XineramaGetCursorScreen(inputInfo.pointer);
 		memcpy(&shiftedEvent, pev, sizeof(xEvent));
 		shiftedEvent.u.keyButtonPointer.rootX +=
-		    dixScreenOrigins[scr].x -
-		    dixScreenOrigins[0].x;
+		    screenInfo.screens[scr]->x -
+		    screenInfo.screens[0]->x;
 		shiftedEvent.u.keyButtonPointer.rootY +=
-		    dixScreenOrigins[scr].y -
-		    dixScreenOrigins[0].y;
+		    screenInfo.screens[scr]->y -
+		    screenInfo.screens[0]->y;
 		pEvToRecord = &shiftedEvent;
 	    }
 #endif /* PANORAMIX */
diff --git a/render/render.c b/render/render.c
index 11c0927..78ecf43 100644
--- a/render/render.c
+++ b/render/render.c
@@ -2832,22 +2832,22 @@ PanoramiXRenderComposite (ClientPtr client)
 	stuff->src = src->info[j].id;
 	if (src->u.pict.root)
 	{
-	    stuff->xSrc = orig.xSrc - dixScreenOrigins[j].x;
-	    stuff->ySrc = orig.ySrc - dixScreenOrigins[j].y;
+	    stuff->xSrc = orig.xSrc - screenInfo.screens[j]->x;
+	    stuff->ySrc = orig.ySrc - screenInfo.screens[j]->y;
 	}
 	stuff->dst = dst->info[j].id;
 	if (dst->u.pict.root)
 	{
-	    stuff->xDst = orig.xDst - dixScreenOrigins[j].x;
-	    stuff->yDst = orig.yDst - dixScreenOrigins[j].y;
+	    stuff->xDst = orig.xDst - screenInfo.screens[j]->x;
+	    stuff->yDst = orig.yDst - screenInfo.screens[j]->y;
 	}
 	if (msk)
 	{
 	    stuff->mask = msk->info[j].id;
 	    if (msk->u.pict.root)
 	    {
-		stuff->xMask = orig.xMask - dixScreenOrigins[j].x;
-		stuff->yMask = orig.yMask - dixScreenOrigins[j].y;
+		stuff->xMask = orig.xMask - screenInfo.screens[j]->x;
+		stuff->yMask = orig.yMask - screenInfo.screens[j]->y;
 	    }
 	}
 	result = (*PanoramiXSaveRenderVector[X_RenderComposite]) (client);
@@ -2881,14 +2881,14 @@ PanoramiXRenderCompositeGlyphs (ClientPtr client)
 	    stuff->src = src->info[j].id;
 	    if (src->u.pict.root)
 	    {
-		stuff->xSrc = xSrc - dixScreenOrigins[j].x;
-		stuff->ySrc = ySrc - dixScreenOrigins[j].y;
+		stuff->xSrc = xSrc - screenInfo.screens[j]->x;
+		stuff->ySrc = ySrc - screenInfo.screens[j]->y;
 	    }
 	    stuff->dst = dst->info[j].id;
 	    if (dst->u.pict.root)
 	    {
-		elt->deltax = origElt.deltax - dixScreenOrigins[j].x;
-		elt->deltay = origElt.deltay - dixScreenOrigins[j].y;
+		elt->deltax = origElt.deltax - screenInfo.screens[j]->x;
+		elt->deltay = origElt.deltay - screenInfo.screens[j]->y;
 	    }
 	    result = (*PanoramiXSaveRenderVector[stuff->renderReqType]) (client);
 	    if(result != Success) break;
@@ -2918,8 +2918,8 @@ PanoramiXRenderFillRectangles (ClientPtr client)
 	    if (j) memcpy (stuff + 1, extra, extra_len);
 	    if (dst->u.pict.root)
 	    {
-		int x_off = dixScreenOrigins[j].x;
-		int y_off = dixScreenOrigins[j].y;
+		int x_off = screenInfo.screens[j]->x;
+		int y_off = screenInfo.screens[j]->y;
 
 		if(x_off || y_off) {
 		    xRectangle	*rects = (xRectangle *) (stuff + 1);
@@ -2966,8 +2966,8 @@ PanoramiXRenderTrapezoids(ClientPtr client)
 	FOR_NSCREENS_FORWARD(j) {
 	    if (j) memcpy (stuff + 1, extra, extra_len);
 	    if (dst->u.pict.root) {
-		int x_off = dixScreenOrigins[j].x;
-		int y_off = dixScreenOrigins[j].y;
+		int x_off = screenInfo.screens[j]->x;
+		int y_off = screenInfo.screens[j]->y;
 
 		if(x_off || y_off) {
                     xTrapezoid  *trap = (xTrapezoid *) (stuff + 1);
@@ -3026,8 +3026,8 @@ PanoramiXRenderTriangles(ClientPtr client)
 	FOR_NSCREENS_FORWARD(j) {
 	    if (j) memcpy (stuff + 1, extra, extra_len);
 	    if (dst->u.pict.root) {
-		int x_off = dixScreenOrigins[j].x;
-		int y_off = dixScreenOrigins[j].y;
+		int x_off = screenInfo.screens[j]->x;
+		int y_off = screenInfo.screens[j]->y;
 
 		if(x_off || y_off) {
                     xTriangle  *tri = (xTriangle *) (stuff + 1);
@@ -3082,8 +3082,8 @@ PanoramiXRenderTriStrip(ClientPtr client)
 	FOR_NSCREENS_FORWARD(j) {
 	    if (j) memcpy (stuff + 1, extra, extra_len);
 	    if (dst->u.pict.root) {
-		int x_off = dixScreenOrigins[j].x;
-		int y_off = dixScreenOrigins[j].y;
+		int x_off = screenInfo.screens[j]->x;
+		int y_off = screenInfo.screens[j]->y;
 
 		if(x_off || y_off) {
                     xPointFixed  *fixed = (xPointFixed *) (stuff + 1);
@@ -3134,8 +3134,8 @@ PanoramiXRenderTriFan(ClientPtr client)
 	FOR_NSCREENS_FORWARD(j) {
 	    if (j) memcpy (stuff + 1, extra, extra_len);
 	    if (dst->u.pict.root) {
-		int x_off = dixScreenOrigins[j].x;
-		int y_off = dixScreenOrigins[j].y;
+		int x_off = screenInfo.screens[j]->x;
+		int y_off = screenInfo.screens[j]->y;
 
 		if(x_off || y_off) {
                     xPointFixed  *fixed = (xPointFixed *) (stuff + 1);
@@ -3188,8 +3188,8 @@ PanoramiXRenderAddTraps (ClientPtr client)
 	    
 	    if (picture->u.pict.root)
 	    {
-		stuff->xOff = x_off + dixScreenOrigins[j].x;
-		stuff->yOff = y_off + dixScreenOrigins[j].y;
+		stuff->xOff = x_off + screenInfo.screens[j]->x;
+		stuff->yOff = y_off + screenInfo.screens[j]->y;
 	    }
 	    result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client);
 	    if(result != Success) break;
commit 217ccaa5a341018457f468a774c035c0df47d918
Author: Jamey Sharp <jamey at minilop.net>
Date:   Sun May 23 11:05:01 2010 -0700

    Delete panoramiXdataPtr: it's redundant.
    
    This eliminates a dynamically-allocated MAXSCREENS-sized array.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Tested-by: Tiago Vignatti <tiago.vignatti at nokia.com> (i686 GNU/Linux)

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index e1cef87..5f0e97e 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -70,7 +70,6 @@ int 		PanoramiXPixWidth = 0;
 int 		PanoramiXPixHeight = 0;
 int 		PanoramiXNumScreens = 0;
 
-PanoramiXData *panoramiXdataPtr = NULL;
 static RegionRec   	PanoramiXScreenRegion = {{0, 0, 0, 0}, NULL};
 
 static int		PanoramiXNumDepths;
@@ -199,8 +198,8 @@ XineramaValidateGC(
 
     if((pDraw->type == DRAWABLE_WINDOW) && !(((WindowPtr)pDraw)->parent)) {
 	/* the root window */
-	int x_off = panoramiXdataPtr[pGC->pScreen->myNum].x;
-	int y_off = panoramiXdataPtr[pGC->pScreen->myNum].y;
+	int x_off = dixScreenOrigins[pGC->pScreen->myNum].x;
+	int y_off = dixScreenOrigins[pGC->pScreen->myNum].y;
 	int new_val;
 
 	new_val = pGCPriv->clipOrg.x - x_off;
@@ -396,27 +395,23 @@ static void XineramaInitData(ScreenPtr pScreen)
 
         pScreen = screenInfo.screens[i];
 
-	panoramiXdataPtr[i].x = dixScreenOrigins[i].x;
-	panoramiXdataPtr[i].y = dixScreenOrigins[i].y;
-	panoramiXdataPtr[i].width = pScreen->width;
-	panoramiXdataPtr[i].height = pScreen->height;
-
-	TheBox.x1 = panoramiXdataPtr[i].x;
-	TheBox.x2 = TheBox.x1 + panoramiXdataPtr[i].width;
-	TheBox.y1 = panoramiXdataPtr[i].y;
-	TheBox.y2 = TheBox.y1 + panoramiXdataPtr[i].height;
+	TheBox.x1 = dixScreenOrigins[i].x;
+	TheBox.x2 = TheBox.x1 + pScreen->width;
+	TheBox.y1 = dixScreenOrigins[i].y;
+	TheBox.y2 = TheBox.y1 + pScreen->height;
 
 	REGION_INIT(pScreen, &XineramaScreenRegions[i], &TheBox, 1);
 	REGION_UNION(pScreen, &PanoramiXScreenRegion, &PanoramiXScreenRegion,
 		     &XineramaScreenRegions[i]);
     }
 
-    PanoramiXPixWidth = panoramiXdataPtr[0].x + panoramiXdataPtr[0].width;
-    PanoramiXPixHeight = panoramiXdataPtr[0].y + panoramiXdataPtr[0].height;
+    PanoramiXPixWidth = dixScreenOrigins[0].x + screenInfo.screens[0]->width;
+    PanoramiXPixHeight = dixScreenOrigins[0].y + screenInfo.screens[0]->height;
 
     for (i = 1; i < PanoramiXNumScreens; i++) {
-	w = panoramiXdataPtr[i].x + panoramiXdataPtr[i].width;
-	h = panoramiXdataPtr[i].y + panoramiXdataPtr[i].height;
+	pScreen = screenInfo.screens[i];
+	w = dixScreenOrigins[i].x + pScreen->width;
+	h = dixScreenOrigins[i].y + pScreen->height;
 
 	if (PanoramiXPixWidth < w)
 	    PanoramiXPixWidth = w;
@@ -473,12 +468,6 @@ void PanoramiXExtensionInit(int argc, char *argv[])
 	 *	run in non-PanoramiXeen mode.
 	 */
 
-	panoramiXdataPtr = (PanoramiXData *) 
-		calloc(PanoramiXNumScreens, sizeof(PanoramiXData));
-
-	if (!panoramiXdataPtr)
-	    break;
-
 	if (!dixRequestPrivate(PanoramiXGCKey, sizeof(PanoramiXGCRec))) {
 		noPanoramiXExtension = TRUE;
 		return;
@@ -897,8 +886,6 @@ static void PanoramiXResetProc(ExtensionEntry* extEntry)
     screenInfo.numScreens = PanoramiXNumScreens;
     for (i = 256; i--; )
 	ProcVector[i] = SavedProcVector[i];
-
-    free(panoramiXdataPtr);
 }
 
 
@@ -1000,8 +987,8 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
 	rep.length = 0;
 	rep.sequenceNumber = client->sequence;
 		/* screen dimensions */
-	rep.width  = panoramiXdataPtr[stuff->screen].width; 
-	rep.height = panoramiXdataPtr[stuff->screen].height; 
+	rep.width  = screenInfo.screens[stuff->screen]->width;
+	rep.height = screenInfo.screens[stuff->screen]->height;
 	rep.window = stuff->window;
 	rep.screen = stuff->screen;
     	if (client->swapped) {
@@ -1073,10 +1060,10 @@ ProcXineramaQueryScreens(ClientPtr client)
 	int i;
 
 	for(i = 0; i < PanoramiXNumScreens; i++) {
-	    scratch.x_org  = panoramiXdataPtr[i].x;
-	    scratch.y_org  = panoramiXdataPtr[i].y;
-	    scratch.width  = panoramiXdataPtr[i].width;
-	    scratch.height = panoramiXdataPtr[i].height;
+	    scratch.x_org  = dixScreenOrigins[i].x;
+	    scratch.y_org  = dixScreenOrigins[i].y;
+	    scratch.width  = screenInfo.screens[i]->width;
+	    scratch.height = screenInfo.screens[i]->height;
 	
 	    if(client->swapped) {
 		int n;
@@ -1166,8 +1153,8 @@ XineramaGetImageData(
     SrcBox.x1 = left;
     SrcBox.y1 = top;
     if(!isRoot) {
-	SrcBox.x1 += pDraw->x + panoramiXdataPtr[0].x;
-	SrcBox.y1 += pDraw->y + panoramiXdataPtr[0].y;
+	SrcBox.x1 += pDraw->x + dixScreenOrigins[0].x;
+	SrcBox.y1 += pDraw->y + dixScreenOrigins[0].y;
     }
     SrcBox.x2 = SrcBox.x1 + width;
     SrcBox.y2 = SrcBox.y1 + height;
@@ -1184,8 +1171,8 @@ XineramaGetImageData(
 
 	if(inOut == rgnIN) {	   
 	    (*pDraw->pScreen->GetImage)(pDraw, 
-			SrcBox.x1 - pDraw->x - panoramiXdataPtr[i].x,
-			SrcBox.y1 - pDraw->y - panoramiXdataPtr[i].y, 
+			SrcBox.x1 - pDraw->x - dixScreenOrigins[i].x,
+			SrcBox.y1 - pDraw->y - dixScreenOrigins[i].y,
 			width, height, format, planemask, data);
 	    break;
 	} else if (inOut == rgnOUT)
@@ -1216,8 +1203,8 @@ XineramaGetImageData(
 		    }	
 		}
 
-		x = pbox->x1 - pDraw->x - panoramiXdataPtr[i].x;
-		y = pbox->y1 - pDraw->y - panoramiXdataPtr[i].y;
+		x = pbox->x1 - pDraw->x - dixScreenOrigins[i].x;
+		y = pbox->y1 - pDraw->y - dixScreenOrigins[i].y;
 
 		(*pDraw->pScreen->GetImage)(pDraw, x, y, w, h, 
 					format, planemask, ScratchMem);
diff --git a/Xext/panoramiX.h b/Xext/panoramiX.h
index 35de179..a8684f0 100644
--- a/Xext/panoramiX.h
+++ b/Xext/panoramiX.h
@@ -46,13 +46,6 @@ Equipment Corporation.
 #include "gcstruct.h"
 
 
-typedef struct _PanoramiXData {
-    int x;
-    int y;
-    int width;
-    int height;
-} PanoramiXData;
-
 typedef struct _PanoramiXInfo {
     XID id ;
 } PanoramiXInfo;
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 6b199cf..ccd7216 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -135,8 +135,8 @@ int PanoramiXCreateWindow(ClientPtr client)
         stuff->wid = newWin->info[j].id;
         stuff->parent = parent->info[j].id;
 	if (parentIsRoot) {
-	    stuff->x = orig_x - panoramiXdataPtr[j].x;
-	    stuff->y = orig_y - panoramiXdataPtr[j].y;
+	    stuff->x = orig_x - dixScreenOrigins[j].x;
+	    stuff->y = orig_y - dixScreenOrigins[j].y;
 	}
 	if (backPix)
 	    *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id;
@@ -334,8 +334,8 @@ int PanoramiXReparentWindow(ClientPtr client)
 	stuff->window = win->info[j].id;
 	stuff->parent = parent->info[j].id;
 	if(parentIsRoot) {
-	    stuff->x = x - panoramiXdataPtr[j].x;
-	    stuff->y = y - panoramiXdataPtr[j].y;
+	    stuff->x = x - dixScreenOrigins[j].x;
+	    stuff->y = y - dixScreenOrigins[j].y;
 	}
 	result = (*SavedProcVector[X_ReparentWindow])(client);
         if(result != Success) break;
@@ -495,9 +495,9 @@ int PanoramiXConfigureWindow(ClientPtr client)
 	if(sib)
 	    *((CARD32 *) &stuff[1] + sib_offset) = sib->info[j].id;
 	if(x_offset >= 0)
-	    *((CARD32 *) &stuff[1] + x_offset) = x - panoramiXdataPtr[j].x;
+	    *((CARD32 *) &stuff[1] + x_offset) = x - dixScreenOrigins[j].x;
 	if(y_offset >= 0)
-	    *((CARD32 *) &stuff[1] + y_offset) = y - panoramiXdataPtr[j].y;
+	    *((CARD32 *) &stuff[1] + y_offset) = y - dixScreenOrigins[j].y;
 	result = (*SavedProcVector[X_ConfigureWindow])(client);
         if(result != Success) break;
     }
@@ -565,8 +565,8 @@ int PanoramiXGetGeometry(ClientPtr client)
 	if((pWin->parent == screenInfo.screens[0]->root) ||
            (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid))
         {
-	   rep.x += panoramiXdataPtr[0].x;
-	   rep.y += panoramiXdataPtr[0].y;
+	   rep.x += dixScreenOrigins[0].x;
+	   rep.y += dixScreenOrigins[0].y;
 	}
 	rep.borderWidth = pWin->borderWidth;
     }
@@ -599,8 +599,8 @@ int PanoramiXTranslateCoords(ClientPtr client)
     if((pWin == screenInfo.screens[0]->root) ||
        (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid))
     { 
-	x = stuff->srcX - panoramiXdataPtr[0].x;
-	y = stuff->srcY - panoramiXdataPtr[0].y;
+	x = stuff->srcX - dixScreenOrigins[0].x;
+	y = stuff->srcY - dixScreenOrigins[0].y;
     } else {
 	x = pWin->drawable.x + stuff->srcX;
 	y = pWin->drawable.y + stuff->srcY;
@@ -637,8 +637,8 @@ int PanoramiXTranslateCoords(ClientPtr client)
     if((pDst == screenInfo.screens[0]->root) ||
        (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid))
     {
-	rep.dstX += panoramiXdataPtr[0].x;
-	rep.dstY += panoramiXdataPtr[0].y;
+	rep.dstX += dixScreenOrigins[0].x;
+	rep.dstY += dixScreenOrigins[0].y;
     }
 
     WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep);
@@ -981,8 +981,8 @@ int PanoramiXClearToBackground(ClientPtr client)
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->window = win->info[j].id;
 	if(isRoot) {
-	    stuff->x = x - panoramiXdataPtr[j].x;
-	    stuff->y = y - panoramiXdataPtr[j].y;
+	    stuff->x = x - dixScreenOrigins[j].x;
+	    stuff->y = y - dixScreenOrigins[j].y;
 	}
 	result = (*SavedProcVector[X_ClearArea])(client);
 	if(result != Success) break;
@@ -1092,12 +1092,12 @@ int PanoramiXCopyArea(ClientPtr client)
 	    stuff->srcDrawable = src->info[j].id;
 	    stuff->gc          = gc->info[j].id;
  	    if (srcIsRoot) {	
-		stuff->srcX = srcx - panoramiXdataPtr[j].x;
-		stuff->srcY = srcy - panoramiXdataPtr[j].y;
+		stuff->srcX = srcx - dixScreenOrigins[j].x;
+		stuff->srcY = srcy - dixScreenOrigins[j].y;
 	    }
  	    if (dstIsRoot) {	
-		stuff->dstX = dstx - panoramiXdataPtr[j].x;
-		stuff->dstY = dsty - panoramiXdataPtr[j].y;
+		stuff->dstX = dstx - dixScreenOrigins[j].x;
+		stuff->dstY = dsty - dixScreenOrigins[j].y;
 	    }
 
 	    VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess);
@@ -1137,7 +1137,7 @@ int PanoramiXCopyArea(ClientPtr client)
 		if(pRgn[j]) {
 		   if(srcIsRoot) {
 		       REGION_TRANSLATE(pScreen, pRgn[j], 
-				panoramiXdataPtr[j].x, panoramiXdataPtr[j].y);
+				dixScreenOrigins[j].x, dixScreenOrigins[j].y);
 		   }
 		   REGION_APPEND(pScreen, &totalReg, pRgn[j]);
 		   REGION_DESTROY(pScreen, pRgn[j]);
@@ -1203,12 +1203,12 @@ int PanoramiXCopyPlane(ClientPtr client)
 	stuff->srcDrawable = src->info[j].id;
 	stuff->gc          = gc->info[j].id;
 	if (srcIsRoot) {	
-	    stuff->srcX = srcx - panoramiXdataPtr[j].x;
-	    stuff->srcY = srcy - panoramiXdataPtr[j].y;
+	    stuff->srcX = srcx - dixScreenOrigins[j].x;
+	    stuff->srcY = srcy - dixScreenOrigins[j].y;
 	}
 	if (dstIsRoot) {	
-	    stuff->dstX = dstx - panoramiXdataPtr[j].x;
-	    stuff->dstY = dsty - panoramiXdataPtr[j].y;
+	    stuff->dstX = dstx - dixScreenOrigins[j].x;
+	    stuff->dstY = dsty - dixScreenOrigins[j].y;
 	}
 
 	VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, DixWriteAccess);
@@ -1297,8 +1297,8 @@ int PanoramiXPolyPoint(ClientPtr client)
             if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint));
 
             if (isRoot) {
-                int x_off = panoramiXdataPtr[j].x;
-                int y_off = panoramiXdataPtr[j].y;
+                int x_off = dixScreenOrigins[j].x;
+                int y_off = dixScreenOrigins[j].y;
 
 		if(x_off || y_off) {
                     xPoint *pnts = (xPoint*)&stuff[1];
@@ -1357,8 +1357,8 @@ int PanoramiXPolyLine(ClientPtr client)
             if(j) memcpy(&stuff[1], origPts, npoint * sizeof(xPoint));
 
             if (isRoot) {
-                int x_off = panoramiXdataPtr[j].x;
-                int y_off = panoramiXdataPtr[j].y;
+                int x_off = dixScreenOrigins[j].x;
+                int y_off = dixScreenOrigins[j].y;
 
 		if(x_off || y_off) {
 		    xPoint *pnts = (xPoint*)&stuff[1];
@@ -1420,8 +1420,8 @@ int PanoramiXPolySegment(ClientPtr client)
             if(j) memcpy(&stuff[1], origSegs, nsegs * sizeof(xSegment));
 
             if (isRoot) {
-                int x_off = panoramiXdataPtr[j].x;
-                int y_off = panoramiXdataPtr[j].y;
+                int x_off = dixScreenOrigins[j].x;
+                int y_off = dixScreenOrigins[j].y;
 
 		if(x_off || y_off) {
 		    xSegment *segs = (xSegment*)&stuff[1];
@@ -1483,8 +1483,8 @@ int PanoramiXPolyRectangle(ClientPtr client)
             if(j) memcpy(&stuff[1], origRecs, nrects * sizeof(xRectangle));
 
 	    if (isRoot) {
-		int x_off = panoramiXdataPtr[j].x;
-		int y_off = panoramiXdataPtr[j].y;
+		int x_off = dixScreenOrigins[j].x;
+		int y_off = dixScreenOrigins[j].y;
 
 
 		if(x_off || y_off) {
@@ -1545,8 +1545,8 @@ int PanoramiXPolyArc(ClientPtr client)
             if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc));
 
 	    if (isRoot) {
-		int x_off = panoramiXdataPtr[j].x;
-		int y_off = panoramiXdataPtr[j].y;
+		int x_off = dixScreenOrigins[j].x;
+		int y_off = dixScreenOrigins[j].y;
 	
 		if(x_off || y_off) {
 		    xArc *arcs = (xArc *) &stuff[1];
@@ -1603,8 +1603,8 @@ int PanoramiXFillPoly(ClientPtr client)
 	    if(j) memcpy(&stuff[1], locPts, count * sizeof(DDXPointRec));
 
 	    if (isRoot) {
-		int x_off = panoramiXdataPtr[j].x;
-		int y_off = panoramiXdataPtr[j].y;
+		int x_off = dixScreenOrigins[j].x;
+		int y_off = dixScreenOrigins[j].y;
 
 		if(x_off || y_off) {
 		    DDXPointPtr pnts = (DDXPointPtr)&stuff[1];
@@ -1666,8 +1666,8 @@ int PanoramiXPolyFillRectangle(ClientPtr client)
 	    if(j) memcpy(&stuff[1], origRects, things * sizeof(xRectangle));
 
 	    if (isRoot) {
-		int x_off = panoramiXdataPtr[j].x;
-		int y_off = panoramiXdataPtr[j].y;
+		int x_off = dixScreenOrigins[j].x;
+		int y_off = dixScreenOrigins[j].y;
 
 		if(x_off || y_off) {
 		    xRectangle *rects = (xRectangle *) &stuff[1];
@@ -1727,8 +1727,8 @@ int PanoramiXPolyFillArc(ClientPtr client)
 	    if(j) memcpy(&stuff[1], origArcs, narcs * sizeof(xArc));
 
 	    if (isRoot) {
-		int x_off = panoramiXdataPtr[j].x;
-		int y_off = panoramiXdataPtr[j].y;
+		int x_off = dixScreenOrigins[j].x;
+		int y_off = dixScreenOrigins[j].y;
 
 		if(x_off || y_off) {
 		    xArc *arcs = (xArc *) &stuff[1];
@@ -1780,8 +1780,8 @@ int PanoramiXPutImage(ClientPtr client)
     orig_y = stuff->dstY;
     FOR_NSCREENS_BACKWARD(j){
 	if (isRoot) {
-    	  stuff->dstX = orig_x - panoramiXdataPtr[j].x;
-	  stuff->dstY = orig_y - panoramiXdataPtr[j].y;
+	  stuff->dstX = orig_x - dixScreenOrigins[j].x;
+	  stuff->dstY = orig_y - dixScreenOrigins[j].y;
 	}
 	stuff->drawable = draw->info[j].id;
 	stuff->gc = gc->info[j].id;
@@ -1846,10 +1846,10 @@ int PanoramiXGetImage(ClientPtr client)
 	    return(BadMatch);
     } else {
       if( /* check for being onscreen */
-	panoramiXdataPtr[0].x + pDraw->x + x < 0 ||
-	panoramiXdataPtr[0].x + pDraw->x + x + w > PanoramiXPixWidth ||
-        panoramiXdataPtr[0].y + pDraw->y + y < 0 ||
-	panoramiXdataPtr[0].y + pDraw->y + y + h > PanoramiXPixHeight ||
+	dixScreenOrigins[0].x + pDraw->x + x < 0 ||
+	dixScreenOrigins[0].x + pDraw->x + x + w > PanoramiXPixWidth ||
+	dixScreenOrigins[0].y + pDraw->y + y < 0 ||
+	dixScreenOrigins[0].y + pDraw->y + y + h > PanoramiXPixHeight ||
 	 /* check for being inside of border */
        	x < - wBorderWidth((WindowPtr)pDraw) ||
 	x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
@@ -1983,8 +1983,8 @@ PanoramiXPolyText8(ClientPtr client)
 	stuff->drawable = draw->info[j].id;
 	stuff->gc = gc->info[j].id;
 	if (isRoot) {
-	    stuff->x = orig_x - panoramiXdataPtr[j].x;
-	    stuff->y = orig_y - panoramiXdataPtr[j].y;
+	    stuff->x = orig_x - dixScreenOrigins[j].x;
+	    stuff->y = orig_y - dixScreenOrigins[j].y;
 	}
 	result = (*SavedProcVector[X_PolyText8])(client);
 	if(result != Success) break;
@@ -2024,8 +2024,8 @@ PanoramiXPolyText16(ClientPtr client)
 	stuff->drawable = draw->info[j].id;
 	stuff->gc = gc->info[j].id;
 	if (isRoot) {
-	    stuff->x = orig_x - panoramiXdataPtr[j].x;
-	    stuff->y = orig_y - panoramiXdataPtr[j].y;
+	    stuff->x = orig_x - dixScreenOrigins[j].x;
+	    stuff->y = orig_y - dixScreenOrigins[j].y;
 	}
 	result = (*SavedProcVector[X_PolyText16])(client);
 	if(result != Success) break;
@@ -2065,8 +2065,8 @@ int PanoramiXImageText8(ClientPtr client)
 	stuff->drawable = draw->info[j].id;
 	stuff->gc = gc->info[j].id;
 	if (isRoot) {
-	    stuff->x = orig_x - panoramiXdataPtr[j].x;
-	    stuff->y = orig_y - panoramiXdataPtr[j].y;
+	    stuff->x = orig_x - dixScreenOrigins[j].x;
+	    stuff->y = orig_y - dixScreenOrigins[j].y;
 	}
 	result = (*SavedProcVector[X_ImageText8])(client);
 	if(result != Success) break;
@@ -2106,8 +2106,8 @@ int PanoramiXImageText16(ClientPtr client)
 	stuff->drawable = draw->info[j].id;
 	stuff->gc = gc->info[j].id;
 	if (isRoot) {
-	    stuff->x = orig_x - panoramiXdataPtr[j].x;
-	    stuff->y = orig_y - panoramiXdataPtr[j].y;
+	    stuff->x = orig_x - dixScreenOrigins[j].x;
+	    stuff->y = orig_y - dixScreenOrigins[j].y;
 	}
 	result = (*SavedProcVector[X_ImageText16])(client);
 	if(result != Success) break;
diff --git a/Xext/panoramiXsrv.h b/Xext/panoramiXsrv.h
index c77b119..af0017d 100644
--- a/Xext/panoramiXsrv.h
+++ b/Xext/panoramiXsrv.h
@@ -9,7 +9,6 @@
 #include "panoramiX.h"
 
 extern _X_EXPORT int PanoramiXNumScreens;
-extern _X_EXPORT PanoramiXData *panoramiXdataPtr;
 extern _X_EXPORT int PanoramiXPixWidth;
 extern _X_EXPORT int PanoramiXPixHeight;
 
diff --git a/Xext/shm.c b/Xext/shm.c
index 3d9c633..99cd39e 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -598,8 +598,8 @@ ProcPanoramiXShmPutImage(ClientPtr client)
 	stuff->drawable = draw->info[j].id;
 	stuff->gc = gc->info[j].id;
 	if (isRoot) {
-	    stuff->dstX = orig_x - panoramiXdataPtr[j].x;
-	    stuff->dstY = orig_y - panoramiXdataPtr[j].y;
+	    stuff->dstX = orig_x - dixScreenOrigins[j].x;
+	    stuff->dstY = orig_y - dixScreenOrigins[j].y;
 	}
 	result = ProcShmPutImage(client);
 	if(result != Success) break;
@@ -660,10 +660,10 @@ ProcPanoramiXShmGetImage(ClientPtr client)
 	    return(BadMatch);
     } else {
       if( /* check for being onscreen */
-	panoramiXdataPtr[0].x + pDraw->x + x < 0 ||
-	panoramiXdataPtr[0].x + pDraw->x + x + w > PanoramiXPixWidth ||
-        panoramiXdataPtr[0].y + pDraw->y + y < 0 ||
-	panoramiXdataPtr[0].y + pDraw->y + y + h > PanoramiXPixHeight ||
+	dixScreenOrigins[0].x + pDraw->x + x < 0 ||
+	dixScreenOrigins[0].x + pDraw->x + x + w > PanoramiXPixWidth ||
+	dixScreenOrigins[0].y + pDraw->y + y < 0 ||
+	dixScreenOrigins[0].y + pDraw->y + y + h > PanoramiXPixHeight ||
 	 /* check for being inside of border */
        	x < - wBorderWidth((WindowPtr)pDraw) ||
 	x + w > wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
index d7338ad..efbe973 100644
--- a/Xext/xvdisp.c
+++ b/Xext/xvdisp.c
@@ -1690,8 +1690,8 @@ XineramaXvShmPutImage(ClientPtr client)
 	   stuff->drw_x = x;
 	   stuff->drw_y = y;
 	   if(isRoot) {
-		stuff->drw_x -= panoramiXdataPtr[i].x;
-		stuff->drw_y -= panoramiXdataPtr[i].y;
+		stuff->drw_x -= dixScreenOrigins[i].x;
+		stuff->drw_y -= dixScreenOrigins[i].y;
 	   }
 	   stuff->send_event = (send_event && !i) ? 1 : 0;
 
@@ -1742,8 +1742,8 @@ XineramaXvPutImage(ClientPtr client)
 	   stuff->drw_x = x;
 	   stuff->drw_y = y;
 	   if(isRoot) {
-		stuff->drw_x -= panoramiXdataPtr[i].x;
-		stuff->drw_y -= panoramiXdataPtr[i].y;
+		stuff->drw_x -= dixScreenOrigins[i].x;
+		stuff->drw_y -= dixScreenOrigins[i].y;
 	   }
 
 	   result = ProcXvPutImage(client);
@@ -1790,8 +1790,8 @@ XineramaXvPutVideo(ClientPtr client)
            stuff->drw_x = x;
            stuff->drw_y = y;
            if(isRoot) {
-                stuff->drw_x -= panoramiXdataPtr[i].x;
-                stuff->drw_y -= panoramiXdataPtr[i].y;
+                stuff->drw_x -= dixScreenOrigins[i].x;
+                stuff->drw_y -= dixScreenOrigins[i].y;
            }
 
            result = ProcXvPutVideo(client);
@@ -1838,8 +1838,8 @@ XineramaXvPutStill(ClientPtr client)
            stuff->drw_x = x;
            stuff->drw_y = y;
            if(isRoot) {
-                stuff->drw_x -= panoramiXdataPtr[i].x;
-                stuff->drw_y -= panoramiXdataPtr[i].y;
+                stuff->drw_x -= dixScreenOrigins[i].x;
+                stuff->drw_y -= dixScreenOrigins[i].y;
            }
 
            result = ProcXvPutStill(client);
diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
index 41253fb..a0c26ba 100644
--- a/Xi/xiquerypointer.c
+++ b/Xi/xiquerypointer.c
@@ -181,12 +181,12 @@ ProcXIQueryPointer(ClientPtr client)
 
 #ifdef PANORAMIX
     if(!noPanoramiXExtension) {
-        rep.root_x += FP1616(panoramiXdataPtr[0].x, 0);
-        rep.root_y += FP1616(panoramiXdataPtr[0].y, 0);
+        rep.root_x += FP1616(dixScreenOrigins[0].x, 0);
+        rep.root_y += FP1616(dixScreenOrigins[0].y, 0);
         if (stuff->win == rep.root)
         {
-            rep.win_x += FP1616(panoramiXdataPtr[0].x, 0);
-            rep.win_y += FP1616(panoramiXdataPtr[0].y, 0);
+            rep.win_x += FP1616(dixScreenOrigins[0].x, 0);
+            rep.win_y += FP1616(dixScreenOrigins[0].y, 0);
         }
     }
 #endif
diff --git a/dix/events.c b/dix/events.c
index 0186596..21ee85e 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -502,8 +502,8 @@ XineramaSetCursorPosition(
        that screen are. */
 
     pScreen = pSprite->screen;
-    x += panoramiXdataPtr[0].x;
-    y += panoramiXdataPtr[0].y;
+    x += dixScreenOrigins[0].x;
+    y += dixScreenOrigins[0].y;
 
     if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
 								x, y, &box))
@@ -521,10 +521,10 @@ XineramaSetCursorPosition(
     }
 
     pSprite->screen = pScreen;
-    pSprite->hotPhys.x = x - panoramiXdataPtr[0].x;
-    pSprite->hotPhys.y = y - panoramiXdataPtr[0].y;
-    x -= panoramiXdataPtr[pScreen->myNum].x;
-    y -= panoramiXdataPtr[pScreen->myNum].y;
+    pSprite->hotPhys.x = x - dixScreenOrigins[0].x;
+    pSprite->hotPhys.y = y - dixScreenOrigins[0].y;
+    x -= dixScreenOrigins[pScreen->myNum].x;
+    y -= dixScreenOrigins[pScreen->myNum].y;
 
     return (*pScreen->SetCursorPosition)(pDev, pScreen, x, y, generateEvent);
 }
@@ -542,10 +542,10 @@ XineramaConstrainCursor(DeviceIntPtr pDev)
 
     /* Translate the constraining box to the screen
        the sprite is actually on */
-    newBox.x1 += panoramiXdataPtr[0].x - panoramiXdataPtr[pScreen->myNum].x;
-    newBox.x2 += panoramiXdataPtr[0].x - panoramiXdataPtr[pScreen->myNum].x;
-    newBox.y1 += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y;
-    newBox.y2 += panoramiXdataPtr[0].y - panoramiXdataPtr[pScreen->myNum].y;
+    newBox.x1 += dixScreenOrigins[0].x - dixScreenOrigins[pScreen->myNum].x;
+    newBox.x2 += dixScreenOrigins[0].x - dixScreenOrigins[pScreen->myNum].x;
+    newBox.y1 += dixScreenOrigins[0].y - dixScreenOrigins[pScreen->myNum].y;
+    newBox.y2 += dixScreenOrigins[0].y - dixScreenOrigins[pScreen->myNum].y;
 
     (* pScreen->ConstrainCursor)(pDev, pScreen, &newBox);
 }
@@ -595,12 +595,12 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev,
 
     REGION_COPY(pSprite->screen, &pSprite->Reg1,
             &pSprite->windows[i]->borderSize);
-    off_x = panoramiXdataPtr[i].x;
-    off_y = panoramiXdataPtr[i].y;
+    off_x = dixScreenOrigins[i].x;
+    off_y = dixScreenOrigins[i].y;
 
     while(i--) {
-        x = off_x - panoramiXdataPtr[i].x;
-        y = off_y - panoramiXdataPtr[i].y;
+        x = off_x - dixScreenOrigins[i].x;
+        y = off_y - dixScreenOrigins[i].y;
 
         if(x || y)
             REGION_TRANSLATE(pSprite->screen, &pSprite->Reg1, x, y);
@@ -608,8 +608,8 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev,
         REGION_UNION(pSprite->screen, &pSprite->Reg1, &pSprite->Reg1,
                 &pSprite->windows[i]->borderSize);
 
-        off_x = panoramiXdataPtr[i].x;
-        off_y = panoramiXdataPtr[i].y;
+        off_x = dixScreenOrigins[i].x;
+        off_y = dixScreenOrigins[i].y;
     }
 
     pSprite->hotLimits = *REGION_EXTENTS(pSprite->screen, &pSprite->Reg1);
@@ -814,12 +814,12 @@ CheckVirtualMotion(
 
             REGION_COPY(pSprite->screen, &pSprite->Reg2,
                     &pSprite->windows[i]->borderSize);
-            off_x = panoramiXdataPtr[i].x;
-            off_y = panoramiXdataPtr[i].y;
+            off_x = dixScreenOrigins[i].x;
+            off_y = dixScreenOrigins[i].y;
 
             while(i--) {
-                x = off_x - panoramiXdataPtr[i].x;
-                y = off_y - panoramiXdataPtr[i].y;
+                x = off_x - dixScreenOrigins[i].x;
+                y = off_y - dixScreenOrigins[i].y;
 
                 if(x || y)
                     REGION_TRANSLATE(pSprite->screen, &pSprite->Reg2, x, y);
@@ -827,8 +827,8 @@ CheckVirtualMotion(
                 REGION_UNION(pSprite->screen, &pSprite->Reg2, &pSprite->Reg2,
                         &pSprite->windows[i]->borderSize);
 
-                off_x = panoramiXdataPtr[i].x;
-                off_y = panoramiXdataPtr[i].y;
+                off_x = dixScreenOrigins[i].x;
+                off_y = dixScreenOrigins[i].y;
             }
         } else
 #endif
@@ -1135,10 +1135,10 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
     {
 #ifdef PANORAMIX
 	if(!noPanoramiXExtension) {
-            event->root_x += panoramiXdataPtr[pSprite->screen->myNum].x -
-			      panoramiXdataPtr[0].x;
-	    event->root_y += panoramiXdataPtr[pSprite->screen->myNum].y -
-			      panoramiXdataPtr[0].y;
+	    event->root_x += dixScreenOrigins[pSprite->screen->myNum].x -
+			      dixScreenOrigins[0].x;
+	    event->root_y += dixScreenOrigins[pSprite->screen->myNum].y -
+			      dixScreenOrigins[0].y;
 	}
 #endif
 	pSprite->hotPhys.x = event->root_x;
@@ -1218,10 +1218,10 @@ PlayReleasedEvents(void)
                     case ET_KeyRelease:
                     case ET_ProximityIn:
                     case ET_ProximityOut:
-                        ev->root_x += panoramiXdataPtr[0].x -
-                            panoramiXdataPtr[pDev->spriteInfo->sprite->screen->myNum].x;
-                        ev->root_y += panoramiXdataPtr[0].y -
-                            panoramiXdataPtr[pDev->spriteInfo->sprite->screen->myNum].y;
+                        ev->root_x += dixScreenOrigins[0].x -
+                            dixScreenOrigins[pDev->spriteInfo->sprite->screen->myNum].x;
+                        ev->root_y += dixScreenOrigins[0].y -
+                            dixScreenOrigins[pDev->spriteInfo->sprite->screen->myNum].y;
                         break;
                     default:
                         break;
@@ -2561,8 +2561,8 @@ PointInBorderSize(WindowPtr pWin, int x, int y)
 	for(i = 1; i < PanoramiXNumScreens; i++) {
 	   if(POINT_IN_REGION(pSprite->screen,
 			&pSprite->windows[i]->borderSize,
-			x + panoramiXdataPtr[0].x - panoramiXdataPtr[i].x,
-			y + panoramiXdataPtr[0].y - panoramiXdataPtr[i].y,
+			x + dixScreenOrigins[0].x - dixScreenOrigins[i].x,
+			y + dixScreenOrigins[0].y - dixScreenOrigins[i].y,
 			&box))
 		return TRUE;
 	}
@@ -2757,10 +2757,10 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
             /* Motion events entering DIX get translated to Screen 0
                coordinates.  Replayed events have already been
                translated since they've entered DIX before */
-            ev->root_x += panoramiXdataPtr[pSprite->screen->myNum].x -
-                                       panoramiXdataPtr[0].x;
-            ev->root_y += panoramiXdataPtr[pSprite->screen->myNum].y -
-                                       panoramiXdataPtr[0].y;
+            ev->root_x += dixScreenOrigins[pSprite->screen->myNum].x -
+                                       dixScreenOrigins[0].x;
+            ev->root_y += dixScreenOrigins[pSprite->screen->myNum].y -
+                                       dixScreenOrigins[0].y;
         } else
 #endif
         {
@@ -3008,10 +3008,10 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
     }
 #ifdef PANORAMIX
     if(!noPanoramiXExtension) {
-        pSprite->hotLimits.x1 = -panoramiXdataPtr[0].x;
-        pSprite->hotLimits.y1 = -panoramiXdataPtr[0].y;
-        pSprite->hotLimits.x2 = PanoramiXPixWidth  - panoramiXdataPtr[0].x;
-        pSprite->hotLimits.y2 = PanoramiXPixHeight - panoramiXdataPtr[0].y;
+        pSprite->hotLimits.x1 = -dixScreenOrigins[0].x;
+        pSprite->hotLimits.y1 = -dixScreenOrigins[0].y;
+        pSprite->hotLimits.x2 = PanoramiXPixWidth  - dixScreenOrigins[0].x;
+        pSprite->hotLimits.y2 = PanoramiXPixHeight - dixScreenOrigins[0].y;
         pSprite->physLimits = pSprite->hotLimits;
         pSprite->confineWin = NullWindow;
         pSprite->hotShape = NullRegion;
@@ -3078,10 +3078,10 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen)
 
 #ifdef PANORAMIX
     if(!noPanoramiXExtension) {
-        pSprite->hotLimits.x1 = -panoramiXdataPtr[0].x;
-        pSprite->hotLimits.y1 = -panoramiXdataPtr[0].y;
-        pSprite->hotLimits.x2 = PanoramiXPixWidth  - panoramiXdataPtr[0].x;
-        pSprite->hotLimits.y2 = PanoramiXPixHeight - panoramiXdataPtr[0].y;
+        pSprite->hotLimits.x1 = -dixScreenOrigins[0].x;
+        pSprite->hotLimits.y1 = -dixScreenOrigins[0].y;
+        pSprite->hotLimits.x2 = PanoramiXPixWidth  - dixScreenOrigins[0].x;
+        pSprite->hotLimits.y2 = PanoramiXPixHeight - dixScreenOrigins[0].y;
         pSprite->physLimits = pSprite->hotLimits;
         pSprite->screen = pScreen;
     }
@@ -3114,10 +3114,10 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y)
     pSprite->hotPhys.y = y;
 #ifdef PANORAMIX
     if(!noPanoramiXExtension) {
-	pSprite->hotPhys.x += panoramiXdataPtr[newScreen->myNum].x -
-			    panoramiXdataPtr[0].x;
-	pSprite->hotPhys.y += panoramiXdataPtr[newScreen->myNum].y -
-			    panoramiXdataPtr[0].y;
+	pSprite->hotPhys.x += dixScreenOrigins[newScreen->myNum].x -
+			    dixScreenOrigins[0].x;
+	pSprite->hotPhys.y += dixScreenOrigins[newScreen->myNum].y -
+			    dixScreenOrigins[0].y;
 	if (newScreen != pSprite->screen) {
 	    pSprite->screen = newScreen;
 	    /* Make sure we tell the DDX to update its copy of the screen */
@@ -3132,10 +3132,10 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y)
 		(*pSprite->screen->SetCursorPosition)(
                                                       pDev,
                                                       pSprite->screen,
-		    pSprite->hotPhys.x + panoramiXdataPtr[0].x -
-			panoramiXdataPtr[pSprite->screen->myNum].x,
-		    pSprite->hotPhys.y + panoramiXdataPtr[0].y -
-			panoramiXdataPtr[pSprite->screen->myNum].y, FALSE);
+		    pSprite->hotPhys.x + dixScreenOrigins[0].x -
+			dixScreenOrigins[pSprite->screen->myNum].x,
+		    pSprite->hotPhys.y + dixScreenOrigins[0].y -
+			dixScreenOrigins[pSprite->screen->myNum].y, FALSE);
 	}
     } else
 #endif
@@ -3163,14 +3163,14 @@ XineramaPointInWindowIsVisible(
 
     if(!XineramaSetWindowPntrs(inputInfo.pointer, pWin)) return FALSE;
 
-    xoff = x + panoramiXdataPtr[0].x;
-    yoff = y + panoramiXdataPtr[0].y;
+    xoff = x + dixScreenOrigins[0].x;
+    yoff = y + dixScreenOrigins[0].y;
 
     for(i = 1; i < PanoramiXNumScreens; i++) {
 	pWin = inputInfo.pointer->spriteInfo->sprite->windows[i];
 	pScreen = pWin->drawable.pScreen;
-	x = xoff - panoramiXdataPtr[i].x;
-	y = yoff - panoramiXdataPtr[i].y;
+	x = xoff - dixScreenOrigins[i].x;
+	y = yoff - dixScreenOrigins[i].y;
 
 	if(POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box)
 	   && (!wInputShape(pWin) ||
@@ -3216,8 +3216,8 @@ XineramaWarpPointer(ClientPtr client)
 	winX = source->drawable.x;
 	winY = source->drawable.y;
 	if(source == screenInfo.screens[0]->root) {
-	    winX -= panoramiXdataPtr[0].x;
-	    winY -= panoramiXdataPtr[0].y;
+	    winX -= dixScreenOrigins[0].x;
+	    winY -= dixScreenOrigins[0].y;
 	}
 	if (x < winX + stuff->srcX ||
 	    y < winY + stuff->srcY ||
@@ -3232,8 +3232,8 @@ XineramaWarpPointer(ClientPtr client)
 	x = dest->drawable.x;
 	y = dest->drawable.y;
 	if(dest == screenInfo.screens[0]->root) {
-	    x -= panoramiXdataPtr[0].x;
-	    y -= panoramiXdataPtr[0].y;
+	    x -= dixScreenOrigins[0].x;
+	    y -= dixScreenOrigins[0].y;
 	}
     }
 
@@ -4997,11 +4997,11 @@ ProcQueryPointer(ClientPtr client)
 
 #ifdef PANORAMIX
     if(!noPanoramiXExtension) {
-	rep.rootX += panoramiXdataPtr[0].x;
-	rep.rootY += panoramiXdataPtr[0].y;
+	rep.rootX += dixScreenOrigins[0].x;
+	rep.rootY += dixScreenOrigins[0].y;
 	if(stuff->id == rep.root) {
-	    rep.winX += panoramiXdataPtr[0].x;
-	    rep.winY += panoramiXdataPtr[0].y;
+	    rep.winX += dixScreenOrigins[0].x;
+	    rep.winY += dixScreenOrigins[0].y;
 	}
     }
 #endif
@@ -5670,7 +5670,7 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
 
 #ifdef PANORAMIX
     if(!noPanoramiXExtension &&
-       (panoramiXdataPtr[0].x || panoramiXdataPtr[0].y))
+       (dixScreenOrigins[0].x || dixScreenOrigins[0].y))
     {
 	switch(events->u.u.type) {
 	case MotionNotify:
@@ -5687,13 +5687,13 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
         */
 	    count = 1;  /* should always be 1 */
 	    memcpy(&eventCopy, events, sizeof(xEvent));
-	    eventCopy.u.keyButtonPointer.rootX += panoramiXdataPtr[0].x;
-	    eventCopy.u.keyButtonPointer.rootY += panoramiXdataPtr[0].y;
+	    eventCopy.u.keyButtonPointer.rootX += dixScreenOrigins[0].x;
+	    eventCopy.u.keyButtonPointer.rootY += dixScreenOrigins[0].y;
 	    if(eventCopy.u.keyButtonPointer.event ==
 	       eventCopy.u.keyButtonPointer.root)
 	    {
-		eventCopy.u.keyButtonPointer.eventX += panoramiXdataPtr[0].x;
-		eventCopy.u.keyButtonPointer.eventY += panoramiXdataPtr[0].y;
+		eventCopy.u.keyButtonPointer.eventX += dixScreenOrigins[0].x;
+		eventCopy.u.keyButtonPointer.eventY += dixScreenOrigins[0].y;
 	    }
 	    events = &eventCopy;
 	    break;
diff --git a/dix/getevents.c b/dix/getevents.c
index eeef414..3ca5883 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1210,8 +1210,8 @@ PostSyntheticMotion(DeviceIntPtr pDev,
        will translate from sprite screen to screen 0 upon reentry
        to the DIX layer. */
     if (!noPanoramiXExtension) {
-        x += panoramiXdataPtr[0].x - panoramiXdataPtr[screen].x;
-        y += panoramiXdataPtr[0].y - panoramiXdataPtr[screen].y;
+        x += dixScreenOrigins[0].x - dixScreenOrigins[screen].x;
+        y += dixScreenOrigins[0].y - dixScreenOrigins[screen].y;
     }
 #endif
 
diff --git a/dix/window.c b/dix/window.c
index 71edd46..8345523 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -2236,8 +2236,8 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
 	event.u.configureRequest.y = y;
 #ifdef PANORAMIX
 	if(!noPanoramiXExtension && (!pParent || !pParent->parent)) {
-            event.u.configureRequest.x += panoramiXdataPtr[0].x;
-            event.u.configureRequest.y += panoramiXdataPtr[0].y;
+            event.u.configureRequest.x += dixScreenOrigins[0].x;
+            event.u.configureRequest.y += dixScreenOrigins[0].y;
 	}
 #endif
 	event.u.configureRequest.width = w;
@@ -2317,8 +2317,8 @@ ActuallyDoSomething:
 	event.u.configureNotify.y = y;
 #ifdef PANORAMIX
 	if(!noPanoramiXExtension && (!pParent || !pParent->parent)) {
-	    event.u.configureNotify.x += panoramiXdataPtr[0].x;
-            event.u.configureNotify.y += panoramiXdataPtr[0].y;
+	    event.u.configureNotify.x += dixScreenOrigins[0].x;
+	    event.u.configureNotify.y += dixScreenOrigins[0].y;
 	}
 #endif
 	event.u.configureNotify.width = w;
@@ -2471,8 +2471,8 @@ ReparentWindow(WindowPtr pWin, WindowPtr pParent,
     event.u.reparent.y = y;
 #ifdef PANORAMIX
     if(!noPanoramiXExtension && !pParent->parent) {
-	event.u.reparent.x += panoramiXdataPtr[0].x;
-	event.u.reparent.y += panoramiXdataPtr[0].y;
+	event.u.reparent.x += dixScreenOrigins[0].x;
+	event.u.reparent.y += dixScreenOrigins[0].y;
     }
 #endif
     event.u.reparent.override = pWin->overrideRedirect;
diff --git a/hw/dmx/doc/dmx.xml b/hw/dmx/doc/dmx.xml
index 12d7067..251e6ac 100644
--- a/hw/dmx/doc/dmx.xml
+++ b/hw/dmx/doc/dmx.xml
@@ -1497,9 +1497,7 @@ PanoramiX prefix.
     <para>The Xinerama extension is registered by calling AddExtension().
     </para>
 
-    <para>A local per-screen array of data structures
-    (panoramiXdataPtr&lsqb;&rsqb;)
-    is allocated for each physical screen, and GC and Screen private
+    <para>GC and Screen private
     indexes are allocated, and both GC and Screen private areas are
     allocated for each physical screen.  These hold Xinerama-specific
     per-GC and per-Screen data.  Each screen's CreateGC and CloseScreen
@@ -1511,9 +1509,8 @@ PanoramiX prefix.
 
     <para>A region (XineramaScreenRegions&lsqb;i&rsqb;) is initialized for each
     physical screen, and single region (PanoramiXScreenRegion) is
-    initialized to be the union of the screen regions.  The
-    panoramiXdataPtr&lsqb;&rsqb; array is also initialized with the size and
-    origin of each screen.  The relative positioning information for the
+    initialized to be the union of the screen regions.
+    The relative positioning information for the
     physical screens is taken from the array
     dixScreenOrigins&lsqb;&rsqb;, which
     the DDX layer must initialize in InitOutput().  The bounds of the
diff --git a/hw/xquartz/pseudoramiX.c b/hw/xquartz/pseudoramiX.c
index 5868ab1..298ec2b 100644
--- a/hw/xquartz/pseudoramiX.c
+++ b/hw/xquartz/pseudoramiX.c
@@ -255,9 +255,9 @@ static int ProcPseudoramiXGetScreenSize(ClientPtr client)
     rep.sequenceNumber = client->sequence;
     /* screen dimensions */
     rep.width  = pseudoramiXScreens[stuff->screen].w;
-    // was panoramiXdataPtr[stuff->screen].width;
+    // was screenInfo.screens[stuff->screen]->width;
     rep.height = pseudoramiXScreens[stuff->screen].h;
-    // was panoramiXdataPtr[stuff->screen].height;
+    // was screenInfo.screens[stuff->screen]->height;
     if (client->swapped) {
         swaps (&rep.sequenceNumber, n);
         swapl (&rep.length, n);
diff --git a/mi/miexpose.c b/mi/miexpose.c
index 9249ca9..ee3ef72 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -424,8 +424,8 @@ miSendExposures( WindowPtr pWin, RegionPtr pRgn, int dx, int dy)
 	XID realWin = 0;
 
 	if(!pWin->parent) {
-	    x = panoramiXdataPtr[scrnum].x;
-	    y = panoramiXdataPtr[scrnum].y;
+	    x = dixScreenOrigins[scrnum].x;
+	    y = dixScreenOrigins[scrnum].y;
 	    pWin = screenInfo.screens[0]->root;
 	    realWin = pWin->drawable.id;
 	} else if (scrnum) {
diff --git a/record/record.c b/record/record.c
index 3724dc7..b81b7b2 100644
--- a/record/record.c
+++ b/record/record.c
@@ -755,11 +755,11 @@ RecordSendProtocolEvents(RecordClientsAndProtocolPtr pRCAP,
 		int scr = XineramaGetCursorScreen(inputInfo.pointer);
 		memcpy(&shiftedEvent, pev, sizeof(xEvent));
 		shiftedEvent.u.keyButtonPointer.rootX +=
-		    panoramiXdataPtr[scr].x -
-		    panoramiXdataPtr[0].x;
+		    dixScreenOrigins[scr].x -
+		    dixScreenOrigins[0].x;
 		shiftedEvent.u.keyButtonPointer.rootY +=
-		    panoramiXdataPtr[scr].y -
-		    panoramiXdataPtr[0].y;
+		    dixScreenOrigins[scr].y -
+		    dixScreenOrigins[0].y;
 		pEvToRecord = &shiftedEvent;
 	    }
 #endif /* PANORAMIX */
diff --git a/render/render.c b/render/render.c
index d342502..11c0927 100644
--- a/render/render.c
+++ b/render/render.c
@@ -2832,22 +2832,22 @@ PanoramiXRenderComposite (ClientPtr client)
 	stuff->src = src->info[j].id;
 	if (src->u.pict.root)
 	{
-	    stuff->xSrc = orig.xSrc - panoramiXdataPtr[j].x;
-	    stuff->ySrc = orig.ySrc - panoramiXdataPtr[j].y;
+	    stuff->xSrc = orig.xSrc - dixScreenOrigins[j].x;
+	    stuff->ySrc = orig.ySrc - dixScreenOrigins[j].y;
 	}
 	stuff->dst = dst->info[j].id;
 	if (dst->u.pict.root)
 	{
-	    stuff->xDst = orig.xDst - panoramiXdataPtr[j].x;
-	    stuff->yDst = orig.yDst - panoramiXdataPtr[j].y;
+	    stuff->xDst = orig.xDst - dixScreenOrigins[j].x;
+	    stuff->yDst = orig.yDst - dixScreenOrigins[j].y;
 	}
 	if (msk)
 	{
 	    stuff->mask = msk->info[j].id;
 	    if (msk->u.pict.root)
 	    {
-		stuff->xMask = orig.xMask - panoramiXdataPtr[j].x;
-		stuff->yMask = orig.yMask - panoramiXdataPtr[j].y;
+		stuff->xMask = orig.xMask - dixScreenOrigins[j].x;
+		stuff->yMask = orig.yMask - dixScreenOrigins[j].y;
 	    }
 	}
 	result = (*PanoramiXSaveRenderVector[X_RenderComposite]) (client);
@@ -2881,14 +2881,14 @@ PanoramiXRenderCompositeGlyphs (ClientPtr client)
 	    stuff->src = src->info[j].id;
 	    if (src->u.pict.root)
 	    {
-		stuff->xSrc = xSrc - panoramiXdataPtr[j].x;
-		stuff->ySrc = ySrc - panoramiXdataPtr[j].y;
+		stuff->xSrc = xSrc - dixScreenOrigins[j].x;
+		stuff->ySrc = ySrc - dixScreenOrigins[j].y;
 	    }
 	    stuff->dst = dst->info[j].id;
 	    if (dst->u.pict.root)
 	    {
-		elt->deltax = origElt.deltax - panoramiXdataPtr[j].x;
-		elt->deltay = origElt.deltay - panoramiXdataPtr[j].y;
+		elt->deltax = origElt.deltax - dixScreenOrigins[j].x;
+		elt->deltay = origElt.deltay - dixScreenOrigins[j].y;
 	    }
 	    result = (*PanoramiXSaveRenderVector[stuff->renderReqType]) (client);
 	    if(result != Success) break;
@@ -2918,8 +2918,8 @@ PanoramiXRenderFillRectangles (ClientPtr client)
 	    if (j) memcpy (stuff + 1, extra, extra_len);
 	    if (dst->u.pict.root)
 	    {
-		int x_off = panoramiXdataPtr[j].x;
-		int y_off = panoramiXdataPtr[j].y;
+		int x_off = dixScreenOrigins[j].x;
+		int y_off = dixScreenOrigins[j].y;
 
 		if(x_off || y_off) {
 		    xRectangle	*rects = (xRectangle *) (stuff + 1);
@@ -2966,8 +2966,8 @@ PanoramiXRenderTrapezoids(ClientPtr client)
 	FOR_NSCREENS_FORWARD(j) {
 	    if (j) memcpy (stuff + 1, extra, extra_len);
 	    if (dst->u.pict.root) {
-                int x_off = panoramiXdataPtr[j].x;
-		int y_off = panoramiXdataPtr[j].y;
+		int x_off = dixScreenOrigins[j].x;
+		int y_off = dixScreenOrigins[j].y;
 
 		if(x_off || y_off) {
                     xTrapezoid  *trap = (xTrapezoid *) (stuff + 1);
@@ -3026,8 +3026,8 @@ PanoramiXRenderTriangles(ClientPtr client)
 	FOR_NSCREENS_FORWARD(j) {
 	    if (j) memcpy (stuff + 1, extra, extra_len);
 	    if (dst->u.pict.root) {
-                int x_off = panoramiXdataPtr[j].x;
-		int y_off = panoramiXdataPtr[j].y;
+		int x_off = dixScreenOrigins[j].x;
+		int y_off = dixScreenOrigins[j].y;
 
 		if(x_off || y_off) {
                     xTriangle  *tri = (xTriangle *) (stuff + 1);
@@ -3082,8 +3082,8 @@ PanoramiXRenderTriStrip(ClientPtr client)
 	FOR_NSCREENS_FORWARD(j) {
 	    if (j) memcpy (stuff + 1, extra, extra_len);
 	    if (dst->u.pict.root) {
-                int x_off = panoramiXdataPtr[j].x;
-		int y_off = panoramiXdataPtr[j].y;
+		int x_off = dixScreenOrigins[j].x;
+		int y_off = dixScreenOrigins[j].y;
 
 		if(x_off || y_off) {
                     xPointFixed  *fixed = (xPointFixed *) (stuff + 1);
@@ -3134,8 +3134,8 @@ PanoramiXRenderTriFan(ClientPtr client)
 	FOR_NSCREENS_FORWARD(j) {
 	    if (j) memcpy (stuff + 1, extra, extra_len);
 	    if (dst->u.pict.root) {
-                int x_off = panoramiXdataPtr[j].x;
-		int y_off = panoramiXdataPtr[j].y;
+		int x_off = dixScreenOrigins[j].x;
+		int y_off = dixScreenOrigins[j].y;
 
 		if(x_off || y_off) {
                     xPointFixed  *fixed = (xPointFixed *) (stuff + 1);
@@ -3188,8 +3188,8 @@ PanoramiXRenderAddTraps (ClientPtr client)
 	    
 	    if (picture->u.pict.root)
 	    {
-		stuff->xOff = x_off + panoramiXdataPtr[j].x;
-		stuff->yOff = y_off + panoramiXdataPtr[j].y;
+		stuff->xOff = x_off + dixScreenOrigins[j].x;
+		stuff->yOff = y_off + dixScreenOrigins[j].y;
 	    }
 	    result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client);
 	    if(result != Success) break;
commit e7fae9ecc42ab5e73b89117722dbf4117d928f9a
Author: Jamey Sharp <jamey at minilop.net>
Date:   Sat May 22 00:26:28 2010 -0700

    Move each screen's root-window pointer into ScreenRec.
    
    Many references to the WindowTable array already had the corresponding
    screen pointer handy, which meant they usually looked like
    "WindowTable[pScreen->myNum]". Adding a field to ScreenRec instead of
    keeping this information in a parallel array simplifies those
    expressions, and eliminates a MAXSCREENS-sized array.
    
    Since dix uses this data, a screen private entry isn't appropriate.
    
    xf86-video-dummy currently uses WindowTable, so it needs to be updated
    to reflect this change.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Tested-by: Tiago Vignatti <tiago.vignatti at nokia.com> (i686 GNU/Linux)

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 594da0e..e1cef87 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -837,7 +837,7 @@ PanoramiXConsolidate(void)
 
     for (i =  0; i < PanoramiXNumScreens; i++) {
 	ScreenPtr pScreen = screenInfo.screens[i];
-	root->info[i].id = WindowTable[i]->drawable.id;
+	root->info[i].id = pScreen->root->drawable.id;
 	root->u.win.class = InputOutput;
         root->u.win.root = TRUE;
         saver->info[i].id = pScreen->screensaver.wid;
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 08ea3ec..6b199cf 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -129,7 +129,7 @@ int PanoramiXCreateWindow(ClientPtr client)
     orig_visual = stuff->visual;
     orig_x = stuff->x;
     orig_y = stuff->y;
-    parentIsRoot = (stuff->parent == WindowTable[0]->drawable.id) ||
+    parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) ||
                    (stuff->parent == screenInfo.screens[0]->screensaver.wid);
     FOR_NSCREENS_BACKWARD(j) {
         stuff->wid = newWin->info[j].id;
@@ -328,7 +328,7 @@ int PanoramiXReparentWindow(ClientPtr client)
 
     x = stuff->x;
     y = stuff->y;
-    parentIsRoot = (stuff->parent == WindowTable[0]->drawable.id) ||
+    parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) ||
                    (stuff->parent == screenInfo.screens[0]->screensaver.wid);
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->window = win->info[j].id;
@@ -475,7 +475,7 @@ int PanoramiXConfigureWindow(ClientPtr client)
 	}
     }
 
-    if(pWin->parent && ((pWin->parent == WindowTable[0]) ||
+    if(pWin->parent && ((pWin->parent == screenInfo.screens[0]->root) ||
                         (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid)))
     {
 	if ((Mask)stuff->mask & CWX) {
@@ -544,7 +544,7 @@ int PanoramiXGetGeometry(ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.root = WindowTable[0]->drawable.id;
+    rep.root = screenInfo.screens[0]->root->drawable.id;
     rep.depth = pDraw->depth;
     rep.width = pDraw->width;
     rep.height = pDraw->height;
@@ -562,7 +562,7 @@ int PanoramiXGetGeometry(ClientPtr client)
         WindowPtr pWin = (WindowPtr)pDraw;
 	rep.x = pWin->origin.x - wBorderWidth (pWin);
 	rep.y = pWin->origin.y - wBorderWidth (pWin);
-	if((pWin->parent == WindowTable[0]) || 
+	if((pWin->parent == screenInfo.screens[0]->root) ||
            (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid))
         {
 	   rep.x += panoramiXdataPtr[0].x;
@@ -596,7 +596,7 @@ int PanoramiXTranslateCoords(ClientPtr client)
     rep.sameScreen = xTrue;
     rep.child = None;
 
-    if((pWin == WindowTable[0]) || 
+    if((pWin == screenInfo.screens[0]->root) ||
        (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid))
     { 
 	x = stuff->srcX - panoramiXdataPtr[0].x;
@@ -634,7 +634,7 @@ int PanoramiXTranslateCoords(ClientPtr client)
     }
     rep.dstX = x - pDst->drawable.x;
     rep.dstY = y - pDst->drawable.y;
-    if((pDst == WindowTable[0]) || 
+    if((pDst == screenInfo.screens[0]->root) ||
        (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid))
     {
 	rep.dstX += panoramiXdataPtr[0].x;
diff --git a/Xext/saver.c b/Xext/saver.c
index da61fbe..696c4aa 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -503,7 +503,7 @@ SendScreenSaverNotify (ScreenPtr pScreen, int state, Bool forced)
 	ev.type = ScreenSaverNotify + ScreenSaverEventBase;
 	ev.state = state;
 	ev.timestamp = currentTime.milliseconds;
-	ev.root = WindowTable[pScreen->myNum]->drawable.id;
+	ev.root = pScreen->root->drawable.id;
 	ev.window = pScreen->screensaver.wid;
 	ev.kind = kind;
 	ev.forced = forced;
@@ -580,7 +580,7 @@ CreateSaverWindow (ScreenPtr pScreen)
     if (GrabInProgress && GrabInProgress != pAttr->client->index)
 	return FALSE;
 
-    pWin = CreateWindow (pSaver->wid, WindowTable[pScreen->myNum],
+    pWin = CreateWindow (pSaver->wid, pScreen->root,
 			 pAttr->x, pAttr->y, pAttr->width, pAttr->height,
 			 pAttr->borderWidth, pAttr->class, 
 			 pAttr->mask, (XID *)pAttr->values, 
@@ -866,7 +866,7 @@ ScreenSaverSetAttributes (ClientPtr client)
     if (ret != Success)
 	return ret;
     pScreen = pDraw->pScreen;
-    pParent = WindowTable[pScreen->myNum];
+    pParent = pScreen->root;
 
     ret = XaceHook(XACE_SCREENSAVER_ACCESS, client, pScreen, DixSetAttrAccess);
     if (ret != Success)
diff --git a/Xi/closedev.c b/Xi/closedev.c
index 159ead5..e319c73 100644
--- a/Xi/closedev.c
+++ b/Xi/closedev.c
@@ -156,7 +156,7 @@ ProcXCloseDevice(ClientPtr client)
      * Delete passive grabs from all windows for this device.      */
 
     for (i = 0; i < screenInfo.numScreens; i++) {
-	pWin = WindowTable[i];
+	pWin = screenInfo.screens[i]->root;
 	DeleteDeviceEvents(d, pWin, client);
 	p1 = pWin->firstChild;
 	DeleteEventsFromChildren(d, p1, client);
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 41b396c..56d9bf7 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -926,7 +926,7 @@ ProcessRawEvent(RawDeviceEvent *ev, DeviceIntPtr device)
         }
 
         for (i = 0; i < screenInfo.numScreens; i++)
-            DeliverEventsToWindow(device, WindowTable[i], xi, 1,
+            DeliverEventsToWindow(device, screenInfo.screens[i]->root, xi, 1,
                                   GetEventFilter(device, xi), NULL);
         free(xi);
     }
@@ -1042,7 +1042,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
 
 	/* see comment in EnqueueEvents regarding the next three lines */
 	if (ev->any.type == ET_Motion)
-	    ev->device_event.root = WindowTable[pSprite->hotPhys.pScreen->myNum]->drawable.id;
+	    ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id;
 
 	eventinfo.device = device;
 	eventinfo.event = ev;
@@ -2120,7 +2120,7 @@ SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count)
     WindowPtr pWin, p1;
 
     for (i = 0; i < screenInfo.numScreens; i++) {
-        pWin = WindowTable[i];
+        pWin = screenInfo.screens[i]->root;
         if (!pWin)
             continue;
         DeliverEventsToWindow(dev, pWin, ev, count, mask, NullGrab);
diff --git a/Xi/xichangecursor.c b/Xi/xichangecursor.c
index e72cfac..2153393 100644
--- a/Xi/xichangecursor.c
+++ b/Xi/xichangecursor.c
@@ -93,7 +93,7 @@ int ProcXIChangeCursor(ClientPtr client)
 
     if (stuff->cursor == None)
     {
-        if (pWin == WindowTable[pWin->drawable.pScreen->myNum])
+        if (pWin == pWin->drawable.pScreen->root)
             pCursor = rootCursor;
         else
             pCursor = (CursorPtr)None;
diff --git a/composite/compinit.c b/composite/compinit.c
index a81cc74..e4b68c8 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -141,7 +141,7 @@ compScreenUpdate (ScreenPtr pScreen)
     compCheckTree (pScreen);
     if (cs->damaged)
     {
-	compWindowUpdate (WindowTable[pScreen->myNum]);
+	compWindowUpdate (pScreen->root);
 	cs->damaged = FALSE;
     }
 }
diff --git a/composite/compoverlay.c b/composite/compoverlay.c
index 2158cdb..67b566c 100644
--- a/composite/compoverlay.c
+++ b/composite/compoverlay.c
@@ -124,7 +124,7 @@ Bool
 compCreateOverlayWindow (ScreenPtr pScreen)
 {
     CompScreenPtr   cs = GetCompScreen(pScreen);
-    WindowPtr	    pRoot = WindowTable[pScreen->myNum];
+    WindowPtr	    pRoot = pScreen->root;
     WindowPtr	    pWin;
     XID		    attrs[] = { None, TRUE }; /* backPixmap, overrideRedirect */
     int		    result;
diff --git a/dix/devices.c b/dix/devices.c
index 250a498..998d22a 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -360,9 +360,9 @@ EnableDevice(DeviceIntPtr dev, BOOL sendevent)
             /* Sprites appear on first root window, so we can hardcode it */
             if (dev->spriteInfo->spriteOwner)
             {
-                InitializeSprite(dev, WindowTable[0]);
+                InitializeSprite(dev, screenInfo.screens[0]->root);
                                                  /* mode doesn't matter */
-                EnterWindow(dev, WindowTable[0], NotifyAncestor);
+                EnterWindow(dev, screenInfo.screens[0]->root, NotifyAncestor);
             }
             else if ((other = NextFreePointerDevice()) == NULL)
             {
@@ -2435,7 +2435,7 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
         if (dev->spriteInfo->sprite)
             currentRoot = dev->spriteInfo->sprite->spriteTrace[0];
         else /* new device auto-set to floating */
-            currentRoot = WindowTable[0];
+            currentRoot = screenInfo.screens[0]->root;
 
         /* we need to init a fake sprite */
         screen = currentRoot->drawable.pScreen;
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 27cb220..c0efce5 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -562,7 +562,7 @@ CreateConnectionBlock(void)
 	VisualPtr	pVisual;
 
 	pScreen = screenInfo.screens[i];
-	root.windowId = WindowTable[i]->drawable.id;
+	root.windowId = pScreen->root->drawable.id;
 	root.defaultColormap = pScreen->defColormap;
 	root.whitePixel = pScreen->whitePixel;
 	root.blackPixel = pScreen->blackPixel;
@@ -912,7 +912,7 @@ GetGeometry(ClientPtr client, xGetGeometryReply *rep)
     rep->type = X_Reply;
     rep->length = 0;
     rep->sequenceNumber = client->sequence;
-    rep->root = WindowTable[pDraw->pScreen->myNum]->drawable.id;
+    rep->root = pDraw->pScreen->root->drawable.id;
     rep->depth = pDraw->depth;
     rep->width = pDraw->width;
     rep->height = pDraw->height;
@@ -972,7 +972,7 @@ ProcQueryTree(ClientPtr client)
         return rc;
     memset(&reply, 0, sizeof(xQueryTreeReply));
     reply.type = X_Reply;
-    reply.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
+    reply.root = pWin->drawable.pScreen->root->drawable.id;
     reply.sequenceNumber = client->sequence;
     if (pWin->parent)
 	reply.parent = pWin->parent->drawable.id;
@@ -2055,7 +2055,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
 	}
 	else
 	{
-	    pBoundingDraw = (DrawablePtr)WindowTable[pDraw->pScreen->myNum];
+	    pBoundingDraw = (DrawablePtr)pDraw->pScreen->root;
 	}
 
 	xgi.visual = wVisual (pWin);
@@ -3666,9 +3666,9 @@ SendConnSetup(ClientPtr client, char *reason)
     {
 	unsigned int j;
 	xDepth *pDepth;
+	WindowPtr pRoot = screenInfo.screens[i]->root;
 
-        root->currentInputMask = WindowTable[i]->eventMask |
-			         wOtherEventMasks (WindowTable[i]);
+        root->currentInputMask = pRoot->eventMask | wOtherEventMasks(pRoot);
 	pDepth = (xDepth *)(root + 1);
 	for (j = 0; j < root->nDepths; j++)
 	{
@@ -3916,7 +3916,6 @@ AddScreen(
        any of the strings pointed to by argv.  They may be passed to
        multiple screens.
     */
-    WindowTable[i] = NullWindow;
     screenInfo.screens[i] = pScreen;
     screenInfo.numScreens++;
     if (!(*pfnInit)(i, pScreen, argc, argv))
diff --git a/dix/enterleave.c b/dix/enterleave.c
index c08cc31..eefa7ab 100644
--- a/dix/enterleave.c
+++ b/dix/enterleave.c
@@ -1077,7 +1077,7 @@ CoreFocusPointerRootNoneSwitch(DeviceIntPtr dev,
 
     for (i = 0; i < nscreens; i++)
     {
-        root = WindowTable[i];
+        root = screenInfo.screens[i]->root;
         if (!HasOtherPointer(root, GetPairedDevice(dev)) && !FirstFocusChild(root))
         {
             /* If pointer was on PointerRootWin and changes to NoneWin, and
@@ -1138,7 +1138,7 @@ CoreFocusToPointerRootOrNone(DeviceIntPtr dev,
 
     for (i = 0; i < nscreens; i++)
     {
-        root = WindowTable[i];
+        root = screenInfo.screens[i]->root;
         if (!HasFocus(root) && !FirstFocusChild(root))
         {
             CoreFocusEvent(dev, FocusIn, mode, B ? NotifyPointerRoot : NotifyDetailNone, root);
@@ -1169,7 +1169,7 @@ CoreFocusFromPointerRootOrNone(DeviceIntPtr dev,
 
     for (i = 0; i < nscreens; i++)
     {
-        root = WindowTable[i];
+        root = screenInfo.screens[i]->root;
         if (!HasFocus(root) && !FirstFocusChild(root))
         {
             /* If pointer was on PointerRootWin and changes to NoneWin, and
@@ -1279,7 +1279,7 @@ DeviceFocusEvents(DeviceIntPtr dev,
                         NotifyPointer);
             /* Notify all the roots */
             for (i = 0; i < nscreens; i++)
-                DeviceFocusEvent(dev, XI_FocusOut, mode, out, WindowTable[i]);
+                DeviceFocusEvent(dev, XI_FocusOut, mode, out, screenInfo.screens[i]->root);
         }
         else
         {
@@ -1293,7 +1293,7 @@ DeviceFocusEvents(DeviceIntPtr dev,
         }
         /* Notify all the roots */
         for (i = 0; i < nscreens; i++)
-            DeviceFocusEvent(dev, XI_FocusIn, mode, in, WindowTable[i]);
+            DeviceFocusEvent(dev, XI_FocusIn, mode, in, screenInfo.screens[i]->root);
         if (to == PointerRootWin)
             DeviceFocusInEvents(dev, RootWindow(dev), sprite->win, mode, NotifyPointer);
     }
@@ -1305,7 +1305,7 @@ DeviceFocusEvents(DeviceIntPtr dev,
                 DeviceFocusOutEvents(dev, sprite->win, RootWindow(dev), mode,
                         NotifyPointer);
             for (i = 0; i < nscreens; i++)
-                DeviceFocusEvent(dev, XI_FocusOut, mode, out, WindowTable[i]);
+                DeviceFocusEvent(dev, XI_FocusOut, mode, out, screenInfo.screens[i]->root);
             if (to->parent != NullWindow)
                 DeviceFocusInEvents(dev, RootWindow(dev), to, mode, NotifyNonlinearVirtual);
             DeviceFocusEvent(dev, XI_FocusIn, mode, NotifyNonlinear, to);
diff --git a/dix/events.c b/dix/events.c
index 9e05dc9..0186596 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -556,9 +556,10 @@ XineramaSetWindowPntrs(DeviceIntPtr pDev, WindowPtr pWin)
 {
     SpritePtr pSprite = pDev->spriteInfo->sprite;
 
-    if(pWin == WindowTable[0]) {
-	    memcpy(pSprite->windows, WindowTable,
-				PanoramiXNumScreens*sizeof(WindowPtr));
+    if(pWin == screenInfo.screens[0]->root) {
+	int i;
+	for (i = 0; i < PanoramiXNumScreens; i++)
+	    pSprite->windows[i] = screenInfo.screens[i]->root;
     } else {
 	PanoramiXRes *win;
 	int rc, i;
@@ -619,7 +620,7 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev,
         pSprite->hotShape = NullRegion;
 
     pSprite->confined = FALSE;
-    pSprite->confineWin = (pWin == WindowTable[0]) ? NullWindow : pWin;
+    pSprite->confineWin = (pWin == screenInfo.screens[0]->root) ? NullWindow : pWin;
 
     CheckPhysLimits(pDev, pSprite->current, generateEvents, FALSE, NULL);
 }
@@ -875,7 +876,7 @@ CheckVirtualMotion(
 #ifdef PANORAMIX
     if (noPanoramiXExtension) /* No typo. Only set the root win if disabled */
 #endif
-        RootWindow(pDev) = WindowTable[pSprite->hot.pScreen->myNum];
+        RootWindow(pDev) = pSprite->hot.pScreen->root;
 }
 
 static void
@@ -1123,7 +1124,7 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
 	 *  updated yet.
 	 */
 	if (ev->any.type == ET_Motion)
-	    ev->device_event.root = WindowTable[pSprite->hotPhys.pScreen->myNum]->drawable.id;
+	    ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id;
 
 	eventinfo.event = ev;
 	eventinfo.device = device;
@@ -1339,7 +1340,7 @@ playmore:
             }
             else
                 ConfineCursorToWindow(dev,
-                        WindowTable[dev->spriteInfo->sprite->hotPhys.pScreen->myNum],
+                        dev->spriteInfo->sprite->hotPhys.pScreen->root,
                         TRUE, FALSE);
             PostNewCursor(dev);
         }
@@ -1369,7 +1370,7 @@ ScreenRestructured (ScreenPtr pScreen)
         }
         else
             ConfineCursorToWindow(pDev,
-                    WindowTable[pDev->spriteInfo->sprite->hotPhys.pScreen->myNum],
+                    pDev->spriteInfo->sprite->hotPhys.pScreen->root,
                     TRUE, FALSE);
     }
 }
@@ -2766,7 +2767,7 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
             if (pSprite->hot.pScreen != pSprite->hotPhys.pScreen)
             {
                 pSprite->hot.pScreen = pSprite->hotPhys.pScreen;
-                RootWindow(pDev) = WindowTable[pSprite->hot.pScreen->myNum];
+                RootWindow(pDev) = pSprite->hot.pScreen->root;
             }
         }
 
@@ -2849,7 +2850,7 @@ WindowsRestructured(void)
 
 #ifdef PANORAMIX
 /* This was added to support reconfiguration under Xdmx.  The problem is
- * that if the 0th screen (i.e., WindowTable[0]) is moved to an origin
+ * that if the 0th screen (i.e., screenInfo.screens[0]) is moved to an origin
  * other than 0,0, the information in the private sprite structure must
  * be updated accordingly, or XYToWindow (and other routines) will not
  * compute correctly. */
@@ -2892,7 +2893,7 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
             } else
                 ConfineCursorToWindow(
                         pDev,
-                        WindowTable[pSprite->hotPhys.pScreen->myNum],
+                        pSprite->hotPhys.pScreen->root,
                         TRUE, FALSE);
 
         }
@@ -3051,7 +3052,7 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen)
 
     pSprite = pDev->spriteInfo->sprite;
 
-    win = WindowTable[pScreen->myNum];
+    win = pScreen->root;
 
     pSprite->hotPhys.pScreen = pScreen;
     pSprite->hot = pSprite->hotPhys;
@@ -3124,7 +3125,7 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y)
 		XineramaConfineCursorToWindow(pDev,
                         pSprite->confineWin, TRUE);
 	    else
-		XineramaConfineCursorToWindow(pDev, WindowTable[0], TRUE);
+		XineramaConfineCursorToWindow(pDev, screenInfo.screens[0]->root, TRUE);
 	    /* if the pointer wasn't confined, the DDX won't get
 	       told of the pointer warp so we reposition it here */
 	    if(!syncEvents.playingEvents)
@@ -3139,8 +3140,7 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y)
     } else
 #endif
     if (newScreen != pSprite->hotPhys.pScreen)
-	ConfineCursorToWindow(pDev, WindowTable[newScreen->myNum],
-                TRUE, FALSE);
+	ConfineCursorToWindow(pDev, newScreen->root, TRUE, FALSE);
 }
 
 #ifdef PANORAMIX
@@ -3215,7 +3215,7 @@ XineramaWarpPointer(ClientPtr client)
 
 	winX = source->drawable.x;
 	winY = source->drawable.y;
-	if(source == WindowTable[0]) {
+	if(source == screenInfo.screens[0]->root) {
 	    winX -= panoramiXdataPtr[0].x;
 	    winY -= panoramiXdataPtr[0].y;
 	}
@@ -3231,7 +3231,7 @@ XineramaWarpPointer(ClientPtr client)
     if (dest) {
 	x = dest->drawable.x;
 	y = dest->drawable.y;
-	if(dest == WindowTable[0]) {
+	if(dest == screenInfo.screens[0]->root) {
 	    x -= panoramiXdataPtr[0].x;
 	    y -= panoramiXdataPtr[0].y;
 	}
diff --git a/dix/globals.c b/dix/globals.c
index c24a94f..28e7d07 100644
--- a/dix/globals.c
+++ b/dix/globals.c
@@ -83,8 +83,6 @@ ClientPtr  serverClient;
 int  currentMaxClients;   /* current size of clients array */
 long maxBigRequestSize = MAX_BIG_REQUEST_SIZE;
 
-WindowPtr WindowTable[MAXSCREENS];
-
 unsigned long globalSerialNumber = 0;
 unsigned long serverGeneration = 0;
 
diff --git a/dix/main.c b/dix/main.c
index 3e500ba..982fedd 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -249,7 +249,7 @@ int main(int argc, char *argv[], char *envp[])
 #endif
 
 	for (i = 0; i < screenInfo.numScreens; i++)
-	    InitRootWindow(WindowTable[i]);
+	    InitRootWindow(screenInfo.screens[i]->root);
 
         InitCoreDevices();
 	InitInput(argc, argv);
@@ -303,7 +303,8 @@ int main(int argc, char *argv[], char *envp[])
 
         CloseInput();
 
-        memset(WindowTable, 0, sizeof(WindowTable));
+	for (i = 0; i < screenInfo.numScreens; i++)
+	    screenInfo.screens[i]->root = NullWindow;
 	CloseDownDevices();
 	CloseDownEvents();
 
diff --git a/dix/window.c b/dix/window.c
index bdad749..71edd46 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -210,7 +210,7 @@ PrintWindowTree(void)
     for (i=0; i<screenInfo.numScreens; i++)
     {
 	ErrorF("[dix] WINDOW %d\n", i);
-	pWin = WindowTable[i];
+	pWin = screenInfo.screens[i]->root;
 	miPrintRegion(&pWin->clipList);
 	p1 = pWin->firstChild;
 	PrintChildren(p1, 4);
@@ -256,7 +256,7 @@ TraverseTree(WindowPtr pWin, VisitWindowProcPtr func, pointer data)
 int
 WalkTree(ScreenPtr pScreen, VisitWindowProcPtr func, pointer data)
 {
-    return(TraverseTree(WindowTable[pScreen->myNum], func, data));
+    return(TraverseTree(pScreen->root, func, data));
 }
 
 /* hack for forcing backing store on all windows */
@@ -366,7 +366,7 @@ CreateRootWindow(ScreenPtr pScreen)
     pScreen->screensaver.ExternalScreenSaver = NULL;
     screenIsSaved = SCREEN_SAVER_OFF;
 
-    WindowTable[pScreen->myNum] = pWin;
+    pScreen->root = pWin;
 
     pWin->drawable.pScreen = pScreen;
     pWin->drawable.type = DRAWABLE_WINDOW;
@@ -1327,7 +1327,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
 	     */
 	    if ( cursorID == None)
 	    {
-		if (pWin == WindowTable[pWin->drawable.pScreen->myNum])
+		if (pWin == pWin->drawable.pScreen->root)
 		    pCursor = rootCursor;
 		else
 		    pCursor = (CursorPtr) None;
@@ -2964,7 +2964,7 @@ HandleSaveSet(ClientPtr client)
 	pWin = SaveSetWindow(client->saveSet[j]);
 #ifdef XFIXES
 	if (SaveSetToRoot(client->saveSet[j]))
-	    pParent = WindowTable[pWin->drawable.pScreen->myNum];
+	    pParent = pWin->drawable.pScreen->root;
 	else
 #endif
 	{
@@ -3250,7 +3250,6 @@ SaveScreens(int on, int mode)
 static Bool
 TileScreenSaver(ScreenPtr pScreen, int kind)
 {
-    int i = pScreen->myNum;
     int j;
     int result;
     XID attributes[3];
@@ -3266,9 +3265,9 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
     attri = 0;
     switch (kind) {
     case SCREEN_IS_TILED:
-	switch (WindowTable[i]->backgroundState) {
+	switch (pScreen->root->backgroundState) {
 	case BackgroundPixel:
-	    attributes[attri++] = WindowTable[i]->background.pixel;
+	    attributes[attri++] = pScreen->root->background.pixel;
 	    mask |= CWBackPixel;
 	    break;
 	case BackgroundPixmap:
@@ -3280,7 +3279,7 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
 	}
 	break;
     case SCREEN_IS_BLACK:
-	attributes[attri++] = WindowTable[i]->drawable.pScreen->blackPixel;
+	attributes[attri++] = pScreen->root->drawable.pScreen->blackPixel;
 	mask |= CWBackPixel;
 	break;
     }
@@ -3329,12 +3328,12 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
 
     pWin = pScreen->screensaver.pWindow =
 	 CreateWindow(pScreen->screensaver.wid,
-	      WindowTable[i],
+	      pScreen->root,
 	      -RANDOM_WIDTH, -RANDOM_WIDTH,
 	      (unsigned short)pScreen->width + RANDOM_WIDTH,
 	      (unsigned short)pScreen->height + RANDOM_WIDTH,
 	      0, InputOutput, mask, attributes, 0, serverClient,
-	      wVisual (WindowTable[i]), &result);
+	      wVisual (pScreen->root), &result);
 
     if (cursor)
 	FreeResource (cursorID, RT_NONE);
diff --git a/fb/fb.h b/fb/fb.h
index 91c91ee..e2222a5 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -740,7 +740,7 @@ typedef struct {
 
 #define fbWindowEnabled(pWin) \
     REGION_NOTEMPTY((pWin)->drawable.pScreen, \
-		    &WindowTable[(pWin)->drawable.pScreen->myNum]->borderClip)
+		    &(pWin)->drawable.pScreen->root->borderClip)
 
 #define fbDrawableEnabled(pDrawable) \
     ((pDrawable)->type == DRAWABLE_PIXMAP ? \
diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c
index c8e8dae..678f290 100644
--- a/hw/dmx/dmxextension.c
+++ b/hw/dmx/dmxextension.c
@@ -297,7 +297,7 @@ void dmxFlushPendingSyncs(void)
 void dmxUpdateScreenResources(ScreenPtr pScreen, int x, int y, int w, int h)
 {
     DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
-    WindowPtr      pRoot     = WindowTable[pScreen->myNum];
+    WindowPtr      pRoot     = pScreen->root;
     WindowPtr      pChild;
     Bool           anyMarked = FALSE;
 
@@ -402,7 +402,7 @@ static void dmxConfigureScreenWindow(int idx,
 static void dmxConfigureRootWindow(int idx, int x, int y, int w, int h)
 {
     DMXScreenInfo *dmxScreen = &dmxScreens[idx];
-    WindowPtr      pRoot     = WindowTable[idx];
+    WindowPtr      pRoot     = screenInfo.screens[idx]->root;
 
     /* NOTE: Either this function or the ones that it calls must handle
      * the case where w == 0 || h == 0.  Currently, the functions that
@@ -437,7 +437,7 @@ static void dmxSetRootWindowOrigin(int idx, int x, int y)
 {
     DMXScreenInfo *dmxScreen = &dmxScreens[idx];
     ScreenPtr      pScreen   = screenInfo.screens[idx];
-    WindowPtr      pRoot     = WindowTable[idx];
+    WindowPtr      pRoot     = pScreen->root;
     WindowPtr      pChild;
     int            xoff;
     int            yoff;
@@ -458,7 +458,7 @@ static void dmxSetRootWindowOrigin(int idx, int x, int y)
     XineramaReinitData(pScreen);
 
     /* Adjust each of the root window's children */
-    if (!idx) ReinitializeRootWindow(WindowTable[0], xoff, yoff);
+    if (!idx) ReinitializeRootWindow(screenInfo.screens[0]->root, xoff, yoff);
     pChild = pRoot->firstChild;
     while (pChild) {
 	/* Adjust child window's position */
@@ -634,7 +634,7 @@ int dmxConfigureDesktop(DMXDesktopAttributesPtr attribs)
 	int   i;
 	for (i = 0; i < dmxNumScreens; i++) {
 	    ScreenPtr  pScreen = screenInfo.screens[i];
-	    WindowPtr  pChild  = WindowTable[i]->firstChild;
+	    WindowPtr  pChild  = pScreen->root->firstChild;
 	    while (pChild) {
 		/* Adjust child window's position */
 		pScreen->MoveWindow(pChild,
@@ -914,7 +914,7 @@ static void dmxBECreateResources(pointer value, XID id, RESTYPE type,
 static void dmxBECreateWindowTree(int idx)
 {
     DMXScreenInfo *dmxScreen = &dmxScreens[idx];
-    WindowPtr      pRoot     = WindowTable[idx];
+    WindowPtr      pRoot     = screenInfo.screens[idx]->root;
     dmxWinPrivPtr  pWinPriv  = DMX_GET_WINDOW_PRIV(pRoot);
     WindowPtr      pWin;
 
@@ -982,7 +982,7 @@ static void dmxBECreateWindowTree(int idx)
 static void dmxForceExposures(int idx)
 {
     ScreenPtr      pScreen   = screenInfo.screens[idx];
-    WindowPtr  pRoot     = WindowTable[idx];
+    WindowPtr  pRoot     = pScreen->root;
     Bool       anyMarked = FALSE;
     WindowPtr  pChild;
 
@@ -1510,7 +1510,7 @@ static void dmxBEDestroyScratchGCs(int scrnNum)
  *  destroy a window as well as all of it's children. */
 static void dmxBEDestroyWindowTree(int idx)
 {
-    WindowPtr  pWin   = WindowTable[idx];
+    WindowPtr  pWin   = screenInfo.screens[idx]->root;
     WindowPtr  pChild = pWin;
 
     while (1) {
diff --git a/hw/dmx/input/dmxconsole.c b/hw/dmx/input/dmxconsole.c
index 9542efa..bf34169 100644
--- a/hw/dmx/input/dmxconsole.c
+++ b/hw/dmx/input/dmxconsole.c
@@ -204,7 +204,7 @@ static void dmxConsoleDrawWindows(pointer private)
     XUnionRectWithRegion(&rect, whole, whole);
     
     for (i = 0; i < dmxNumScreens; i++) {
-        WindowPtr     pRoot       = WindowTable[i];
+        WindowPtr     pRoot       = screenInfo.screens[i]->root;
         WindowPtr     pChild;
 
 #if DMX_WINDOW_DEBUG
diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index 1242be1..814fc1a 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -570,7 +570,7 @@ static void dmxUpdateWindowInformation(DMXInputInfo *dmxInput,
     int i;
 
 #ifdef PANORAMIX
-    if (!noPanoramiXExtension && pWindow && pWindow->parent != WindowTable[0])
+    if (!noPanoramiXExtension && pWindow && pWindow->parent != screenInfo.screens[0]->root)
         return;
 #endif
 #if DMX_WINDOW_DEBUG
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 9d1b383..10df02d 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -95,7 +95,7 @@ KdOsFuncs	*kdOsFuncs;
 void
 KdSetRootClip (ScreenPtr pScreen, BOOL enable)
 {
-    WindowPtr	pWin = WindowTable[pScreen->myNum];
+    WindowPtr	pWin = pScreen->root;
     WindowPtr	pChild;
     Bool	WasViewable;
     Bool	anyMarked = FALSE;
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index d4b9351..1aad2d1 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1062,7 +1062,7 @@ xf86SetBlackWhitePixels(ScreenPtr pScreen)
 static void
 xf86SetRootClip (ScreenPtr pScreen, Bool enable)
 {
-    WindowPtr	pWin = WindowTable[pScreen->myNum];
+    WindowPtr	pWin = pScreen->root;
     WindowPtr	pChild;
     Bool	WasViewable = (Bool)(pWin->viewable);
     Bool	anyMarked = FALSE;
diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c
index 455a02c..77053b8 100644
--- a/hw/xfree86/common/xf86RandR.c
+++ b/hw/xfree86/common/xf86RandR.c
@@ -159,7 +159,7 @@ xf86RandRSetMode (ScreenPtr	    pScreen,
     int			oldmmHeight = pScreen->mmHeight;
     int			oldVirtualX = scrp->virtualX;
     int			oldVirtualY = scrp->virtualY;
-    WindowPtr		pRoot = WindowTable[pScreen->myNum];
+    WindowPtr		pRoot = pScreen->root;
     Bool		ret = TRUE;
 
     if (pRoot && scrp->vtSema)
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 2b33f25..efed677 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -1881,7 +1881,7 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes)
 void
 xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
 {
-   DrawablePtr root = &WindowTable[pScreen->myNum]->drawable;
+   DrawablePtr root = &pScreen->root->drawable;
    ChangeGCVal pval[2];
    BoxPtr pbox = REGION_RECTS(clipboxes);
    int i, nbox = REGION_NUM_RECTS(clipboxes);
diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c
index 754fe37..4487628 100644
--- a/hw/xfree86/dixmods/extmod/xf86vmode.c
+++ b/hw/xfree86/dixmods/extmod/xf86vmode.c
@@ -347,7 +347,7 @@ SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced)
 	ev.type = XF86VidModeNotify + XF86VidModeEventBase;
 	ev.state = state;
 	ev.timestamp = currentTime.milliseconds;
-	ev.root = WindowTable[pScreen->myNum]->drawable.id;
+	ev.root = pScreen->root->drawable.id;
 	ev.kind = kind;
 	ev.forced = forced;
 	WriteEventsToClient (pEv->client, 1, (xEvent *) &ev);
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index 77f7fe2..f7cea5e 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -1187,7 +1187,7 @@ DRIDriverClipNotify(ScreenPtr pScreen)
 
 	if (pDRIPriv->nrWindows > 0) {
 	    pDRIPriv->nrWalked = 0;
-	    TraverseTree(WindowTable[pScreen->myNum], DRIDCNTreeTraversal,
+	    TraverseTree(pScreen->root, DRIDCNTreeTraversal,
 			 (pointer)pDRIWindows);
 	}
 
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 5562853..9ec4caa 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -607,7 +607,7 @@ DRI2CanFlip(DrawablePtr pDraw)
     if (pDraw->type == DRAWABLE_PIXMAP)
 	return TRUE;
 
-    pRoot = WindowTable[pScreen->myNum];
+    pRoot = pScreen->root;
     pRootPixmap = pScreen->GetWindowPixmap(pRoot);
 
     pWin = (WindowPtr) pDraw;
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 9dfce3f..8d598d6 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -517,7 +517,7 @@ xf86RandR12SetMode (ScreenPtr	    pScreen,
     int			oldHeight = pScreen->height;
     int			oldmmWidth = pScreen->mmWidth;
     int			oldmmHeight = pScreen->mmHeight;
-    WindowPtr		pRoot = WindowTable[pScreen->myNum];
+    WindowPtr		pRoot = pScreen->root;
     DisplayModePtr      currentMode = NULL;
     Bool 		ret = TRUE;
     PixmapPtr 		pspix = NULL;
@@ -685,7 +685,7 @@ xf86RandR12ScreenSetSize (ScreenPtr	pScreen,
     XF86RandRInfoPtr	randrp = XF86RANDRINFO(pScreen);
     ScrnInfoPtr		pScrn = XF86SCRNINFO(pScreen);
     xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(pScrn);
-    WindowPtr		pRoot = WindowTable[pScreen->myNum];
+    WindowPtr		pRoot = pScreen->root;
     PixmapPtr		pScrnPix = (*pScreen->GetScreenPixmap)(pScreen);
     Bool		ret = FALSE;
     int                 c;
@@ -739,7 +739,7 @@ finish:
     if (pRoot && pScrn->vtSema)
 	(*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE);
 #if RANDR_12_INTERFACE
-    if (xf86RandR12Key && WindowTable[pScreen->myNum] && ret)
+    if (xf86RandR12Key && pScreen->root && ret)
 	RRScreenSizeNotify (pScreen);
 #endif
     return ret;
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 2714fee..e3683a8 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -76,9 +76,9 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region)
 {
     ScrnInfoPtr		scrn = crtc->scrn;
     ScreenPtr		screen = scrn->pScreen;
-    WindowPtr		root = WindowTable[screen->myNum];
+    WindowPtr		root = screen->root;
     PixmapPtr		dst_pixmap = crtc->rotatedPixmap;
-    PictFormatPtr	format = compWindowFormat (WindowTable[screen->myNum]);
+    PictFormatPtr	format = compWindowFormat (screen->root);
     int			error;
     PicturePtr		src, dst;
     int			n = REGION_NUM_RECTS(region);
diff --git a/hw/xfree86/xaa/xaaCpyWin.c b/hw/xfree86/xaa/xaaCpyWin.c
index d37c8ec..d58db8e 100644
--- a/hw/xfree86/xaa/xaaCpyWin.c
+++ b/hw/xfree86/xaa/xaaCpyWin.c
@@ -47,7 +47,7 @@ XAACopyWindow(
     	return;
     }
 
-    pwinRoot = WindowTable[pScreen->myNum];
+    pwinRoot = pScreen->root;
 
     REGION_NULL(pScreen, &rgnDst);
 
diff --git a/hw/xfree86/xaa/xaaOverlay.c b/hw/xfree86/xaa/xaaOverlay.c
index 2af8083..14de9bd 100644
--- a/hw/xfree86/xaa/xaaOverlay.c
+++ b/hw/xfree86/xaa/xaaOverlay.c
@@ -54,7 +54,7 @@ XAACopyWindow8_32(
     	return;
     }
 
-    pwinRoot = WindowTable[pScreen->myNum];
+    pwinRoot = pScreen->root;
 
     if(doUnderlay)
 	freeReg = miOverlayCollectUnderlayRegions(pWin, &borderClip);
diff --git a/hw/xfree86/xaa/xaaOverlayDF.c b/hw/xfree86/xaa/xaaOverlayDF.c
index 3b848ac..b186cb5 100644
--- a/hw/xfree86/xaa/xaaOverlayDF.c
+++ b/hw/xfree86/xaa/xaaOverlayDF.c
@@ -324,7 +324,7 @@ XAAOverCopyWindow(
     RegionRec rgnDst;
     BoxPtr pbox;
     int i, nbox, dx, dy;
-    WindowPtr pRoot = WindowTable[pScreen->myNum];
+    WindowPtr pRoot = pScreen->root;
 
 
     if (!pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) { 
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 580fe4a..825afa0 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -793,7 +793,7 @@ void AbortDDX( void )
 void
 xf86SetRootClip (ScreenPtr pScreen, int enable)
 {
-    WindowPtr	pWin = WindowTable[pScreen->myNum];
+    WindowPtr	pWin = pScreen->root;
     WindowPtr	pChild;
     Bool	WasViewable = (Bool)(pWin->viewable);
     Bool	anyMarked = TRUE;
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 36d18eb..ac7fedd 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -276,7 +276,7 @@ void QuartzUpdateScreens(void) {
     sy = dixScreenOrigins[pScreen->myNum].y + darwinMainScreenY;
     
     /* Adjust the root window. */
-    pRoot = WindowTable[pScreen->myNum];
+    pRoot = pScreen->root;
     AppleWMSetScreenOrigin(pRoot);
     pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
     miPaintWindow(pRoot, &pRoot->borderClip,  PW_BACKGROUND);
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index 53dde7a..6dc2c87 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -576,7 +576,7 @@ xprHideWindows(Bool hide)
     
     for (screen = 0; screen < screenInfo.numScreens; screen++) {
         RootlessFrameID prevWid = NULL;
-        pRoot = WindowTable[screenInfo.screens[screen]->myNum];
+        pRoot = screenInfo.screens[screen]->root;
 
         for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) {
             RootlessWindowRec *winRec = WINREC(pWin);
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index d574721..87e97d4 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -397,7 +397,7 @@ xprUpdateScreen(ScreenPtr pScreen)
     rootlessGlobalOffsetX = darwinMainScreenX;
     rootlessGlobalOffsetY = darwinMainScreenY;
 
-    AppleWMSetScreenOrigin(WindowTable[pScreen->myNum]);
+    AppleWMSetScreenOrigin(pScreen->root);
 
     RootlessRepositionWindows(pScreen);
     RootlessUpdateScreenPixmap(pScreen);
@@ -416,7 +416,7 @@ xprInitInput(int argc, char **argv)
     rootlessGlobalOffsetY = darwinMainScreenY;
 
     for (i = 0; i < screenInfo.numScreens; i++)
-        AppleWMSetScreenOrigin(WindowTable[i]);
+        AppleWMSetScreenOrigin(screenInfo.screens[i]->root);
 }
 
 /*
diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c
index ad9e66a..6d91ce0 100644
--- a/hw/xwin/winkeybd.c
+++ b/hw/xwin/winkeybd.c
@@ -262,7 +262,7 @@ winRestoreModeKeyStates (void)
 
   /* Only process events if the rootwindow is mapped. The keyboard events
    * will cause segfaults otherwise */
-  if (WindowTable && WindowTable[0] && WindowTable[0]->mapped == FALSE)
+  if (screenInfo.screens[0]->root && screenInfo.screens[0]->root->mapped == FALSE)
     processEvents = FALSE;    
   
   /* Force to process all pending events in the mi event queue */
diff --git a/hw/xwin/winwin32rootlesswindow.c b/hw/xwin/winwin32rootlesswindow.c
index 3a49ead..214e895 100755
--- a/hw/xwin/winwin32rootlesswindow.c
+++ b/hw/xwin/winwin32rootlesswindow.c
@@ -407,7 +407,7 @@ void
 winMWExtWMRestackWindows (ScreenPtr pScreen)
 {
   winScreenPriv(pScreen);
-  WindowPtr pRoot = WindowTable[pScreen->myNum];
+  WindowPtr pRoot = pScreen->root;
   WindowPtr pWin = NULL;
   WindowPtr pWinPrev = NULL;
   win32RootlessWindowPtr pRLWin = NULL;
diff --git a/hw/xwin/winwindow.c b/hw/xwin/winwindow.c
index d0c360f..9348d5c 100644
--- a/hw/xwin/winwindow.c
+++ b/hw/xwin/winwindow.c
@@ -144,7 +144,7 @@ winCopyWindowNativeGDI (WindowPtr pWin,
 #endif
 
   /* Get a pointer to the root window */
-  pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
+  pwinRoot = pWin->drawable.pScreen->root;
 
   /* Create a region for the destination */
   prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
diff --git a/include/globals.h b/include/globals.h
index 6959fc7..7de262f 100644
--- a/include/globals.h
+++ b/include/globals.h
@@ -19,7 +19,6 @@ extern _X_EXPORT char *defaultFontPath;
 extern _X_EXPORT int monitorResolution;
 extern _X_EXPORT int defaultColorVisualClass;
 
-extern _X_EXPORT WindowPtr WindowTable[MAXSCREENS];
 extern _X_EXPORT int GrabInProgress;
 extern _X_EXPORT Bool noTestExtensions;
 
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 1460bc4..f8171ca 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -478,6 +478,7 @@ typedef struct _Screen {
     pointer		devPrivate;
     short       	numVisuals;
     VisualPtr		visuals;
+    WindowPtr		root;
     ScreenSaverStuffRec screensaver;
 
     /* Random screen procedures */
diff --git a/mi/midispcur.c b/mi/midispcur.c
index c279010..87eb27d 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -405,7 +405,7 @@ miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
     }
     pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
 						  miDCScreenKey);
-    pWin = WindowTable[pScreen->myNum];
+    pWin = pScreen->root;
     pBuffer = MIDCBUFFER(pDev, pScreen);
 
 #ifdef ARGB_CURSOR
@@ -448,7 +448,7 @@ miDCSaveUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
     pBuffer = MIDCBUFFER(pDev, pScreen);
 
     pSave = pBuffer->pSave;
-    pWin = WindowTable[pScreen->myNum];
+    pWin = pScreen->root;
     if (!pSave || pSave->drawable.width < w || pSave->drawable.height < h)
     {
 	if (pSave)
@@ -482,7 +482,7 @@ miDCRestoreUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
     pBuffer = MIDCBUFFER(pDev, pScreen);
     pSave = pBuffer->pSave;
 
-    pWin = WindowTable[pScreen->myNum];
+    pWin = pScreen->root;
     if (!pSave)
 	return FALSE;
 
@@ -513,7 +513,7 @@ miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
             goto failure;
 
         dixSetPrivate(&pDev->devPrivates, miDCSpriteKey + pScreen->myNum, pBuffer);
-        pWin = WindowTable[pScreen->myNum];
+        pWin = pScreen->root;
 
         pBuffer->pSourceGC = miDCMakeGC(pWin);
         if (!pBuffer->pSourceGC)
diff --git a/mi/miexpose.c b/mi/miexpose.c
index 57968dd..9249ca9 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -426,7 +426,7 @@ miSendExposures( WindowPtr pWin, RegionPtr pRgn, int dx, int dy)
 	if(!pWin->parent) {
 	    x = panoramiXdataPtr[scrnum].x;
 	    y = panoramiXdataPtr[scrnum].y;
-	    pWin = WindowTable[0];
+	    pWin = screenInfo.screens[0]->root;
 	    realWin = pWin->drawable.id;
 	} else if (scrnum) {
 	    PanoramiXRes *win;
diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index 1a3ac41..da3ff4a 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -306,7 +306,7 @@ miOverlayReparentWindow(WindowPtr pWin, WindowPtr pPriorParent)
 {
     if(IN_UNDERLAY(pWin) || HasUnderlayChildren(pWin)) {
 	/* This could probably be more optimal */
-	RebuildTree(WindowTable[pWin->drawable.pScreen->myNum]->firstChild);
+	RebuildTree(pWin->drawable.pScreen->root->firstChild);
     }	
 }
 
@@ -1610,7 +1610,7 @@ miOverlayChangeBorderWidth(
 void
 miOverlaySetRootClip(ScreenPtr pScreen, Bool enable)
 {
-    WindowPtr pRoot = WindowTable[pScreen->myNum];
+    WindowPtr pRoot = pScreen->root;
     miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pRoot);
 
     MARK_UNDERLAY(pRoot);
diff --git a/miext/rootless/rootlessCommon.c b/miext/rootless/rootlessCommon.c
index 39a3eed..dd3f953 100644
--- a/miext/rootless/rootlessCommon.c
+++ b/miext/rootless/rootlessCommon.c
@@ -447,7 +447,7 @@ RootlessRedisplay(WindowPtr pWindow)
 void
 RootlessRepositionWindows(ScreenPtr pScreen)
 {
-    WindowPtr root = WindowTable[pScreen->myNum];
+    WindowPtr root = pScreen->root;
     WindowPtr win;
 
     if (root != NULL) {
@@ -468,7 +468,7 @@ RootlessRepositionWindows(ScreenPtr pScreen)
 void
 RootlessRedisplayScreen(ScreenPtr pScreen)
 {
-    WindowPtr root = WindowTable[pScreen->myNum];
+    WindowPtr root = pScreen->root;
 
     if (root != NULL) {
         WindowPtr win;
diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index f44c4e8..8a4b813 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -213,7 +213,7 @@ extern RegionRec rootlessHugeRoot;
 
 // Returns TRUE if this window is a root window
 #define IsRoot(pWin) \
-    ((pWin) == WindowTable[(pWin)->drawable.pScreen->myNum])
+    ((pWin) == (pWin)->drawable.pScreen->root)
 
 
 /*
diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index 7a24af8..d24ca04 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -493,7 +493,7 @@ static void expose_1 (WindowPtr pWin) {
 void
 RootlessScreenExpose (ScreenPtr pScreen)
 {
-    expose_1 (WindowTable[pScreen->myNum]);
+    expose_1 (pScreen->root);
 }
 
 
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 22a548a..5955cd9 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -1517,7 +1517,7 @@ RootlessOrderAllWindows (void)
     RL_DEBUG_MSG("RootlessOrderAllWindows() ");
     for (i = 0; i < screenInfo.numScreens; i++) {
       if (screenInfo.screens[i] == NULL) continue;
-      pWin = WindowTable[i];
+      pWin = screenInfo.screens[i]->root;
       if (pWin == NULL) continue;
       
       for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib) {
@@ -1533,7 +1533,7 @@ void
 RootlessEnableRoot (ScreenPtr pScreen)
 {
     WindowPtr pRoot;
-    pRoot = WindowTable[pScreen->myNum];
+    pRoot = pScreen->root;
     
     RootlessEnsureFrame (pRoot);
     (*pScreen->ClearToBackground) (pRoot, 0, 0, 0, 0, TRUE);
@@ -1546,7 +1546,7 @@ RootlessDisableRoot (ScreenPtr pScreen)
     WindowPtr pRoot;
     RootlessWindowRec *winRec;
 
-    pRoot = WindowTable[pScreen->myNum];
+    pRoot = pScreen->root;
     winRec = WINREC (pRoot);
 
     if (NULL == winRec)
@@ -1572,8 +1572,10 @@ RootlessHideAllWindows (void)
     for (i = 0; i < screenInfo.numScreens; i++)
     {
         pScreen = screenInfo.screens[i];
-        pWin = WindowTable[i];
-        if (pScreen == NULL || pWin == NULL)
+	if (pScreen == NULL)
+	    continue;
+	pWin = pScreen->root;
+	if (pWin == NULL)
             continue;
         
         for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib)
@@ -1609,8 +1611,10 @@ RootlessShowAllWindows (void)
     for (i = 0; i < screenInfo.numScreens; i++)
     {
         pScreen = screenInfo.screens[i];
-        pWin = WindowTable[i];
-        if (pScreen == NULL || pWin == NULL)
+	if (pScreen == NULL)
+	    continue;
+	pWin = pScreen->root;
+	if (pWin == NULL)
             continue;
         
         for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib)
diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index a940f8a..a2a0f36 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -73,7 +73,7 @@ RREditConnectionInfo (ScreenPtr pScreen)
 void
 RRSendConfigNotify (ScreenPtr pScreen)
 {
-    WindowPtr	pWin = WindowTable[pScreen->myNum];
+    WindowPtr	pWin = pScreen->root;
     xEvent	event;
 
     event.u.u.type = ConfigureNotify;
@@ -97,7 +97,7 @@ RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen)
     rrScrPriv (pScreen);
     xRRScreenChangeNotifyEvent	se;
     RRCrtcPtr	crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL;
-    WindowPtr	pRoot = WindowTable[pScreen->myNum];
+    WindowPtr	pRoot = pScreen->root;
     
     se.type = RRScreenChangeNotify + RREventBase;
     se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0);
@@ -620,7 +620,7 @@ ProcRRGetScreenInfo (ClientPtr client)
 	rep.setOfRotations = RR_Rotate_0;
 	rep.sequenceNumber = client->sequence;
 	rep.length = 0;
-	rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
+	rep.root = pWin->drawable.pScreen->root->drawable.id;
 	rep.timestamp = currentTime.milliseconds;
 	rep.configTimestamp = currentTime.milliseconds;
 	rep.nSizes = 0;
@@ -649,7 +649,7 @@ ProcRRGetScreenInfo (ClientPtr client)
 	rep.setOfRotations = output->crtc->rotations;
 	rep.sequenceNumber = client->sequence;
 	rep.length = 0;
-	rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
+	rep.root = pWin->drawable.pScreen->root->drawable.id;
 	rep.timestamp = pScrPriv->lastSetTime.milliseconds;
 	rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
 	rep.rotation = output->crtc->rotation;
@@ -961,7 +961,7 @@ sendReply:
 
     rep.newTimestamp = pScrPriv->lastSetTime.milliseconds;
     rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds;
-    rep.root = WindowTable[pDraw->pScreen->myNum]->drawable.id;
+    rep.root = pDraw->pScreen->root->drawable.id;
 
     if (client->swapped) 
     {
diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c
index 457b2b4..c1bd5bb 100644
--- a/randr/rrxinerama.c
+++ b/randr/rrxinerama.c
@@ -216,7 +216,7 @@ ProcRRXineramaGetScreenSize(ClientPtr client)
 	return rc;
 
     pScreen = pWin->drawable.pScreen;
-    pRoot = WindowTable[pScreen->myNum];
+    pRoot = pScreen->root;
     
     rep.type = X_Reply;
     rep.length = 0;
diff --git a/render/render.c b/render/render.c
index b58dd3e..d342502 100644
--- a/render/render.c
+++ b/render/render.c
@@ -2681,7 +2681,7 @@ PanoramiXRenderCreatePicture (ClientPtr client)
     newPict->info[0].id = stuff->pid;
     
     if (refDraw->type == XRT_WINDOW &&
-	stuff->drawable == WindowTable[0]->drawable.id)
+	stuff->drawable == screenInfo.screens[0]->root->drawable.id)
     {
 	newPict->u.pict.root = TRUE;
     }
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index d3a207d..5f08db7 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -690,7 +690,7 @@ ReplaceCursor (CursorPtr pCursor,
 	}
     }
     /* this "knows" that WindowHasNewCursor doesn't depend on it's argument */
-    WindowHasNewCursor (WindowTable[0]);
+    WindowHasNewCursor (screenInfo.screens[0]->root);
 }
 
 static Bool 
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index 93175c5..0f3ffa4 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -43,6 +43,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include "opaque.h"
 #include "property.h"
+#include "scrnintstr.h"
 #define	XKBSRV_NEED_FILE_FUNCS
 #include <xkbsrv.h>
 #include "xkbgeom.h"
@@ -210,7 +211,7 @@ char *			pval;
 	ErrorF("[xkb] Internal Error! bad size (%d!=%d) for _XKB_RULES_NAMES\n",
 								out,len);
     }
-    dixChangeWindowProperty(serverClient, WindowTable[0], name, XA_STRING, 8,
+    dixChangeWindowProperty(serverClient, screenInfo.screens[0]->root, name, XA_STRING, 8,
 			    PropModeReplace, len, pval, TRUE);
     free(pval);
     return TRUE;
commit 80b5d3a3264d2c5167e5ac85a3b04af0f89cece1
Author: Jamey Sharp <jamey at minilop.net>
Date:   Fri May 21 23:13:51 2010 -0700

    Move each screen's screensaver data into ScreenRec.
    
    Most references to the savedScreenInfo array already had the
    corresponding screen pointer handy, which meant they usually looked like
    "savedScreenInfo[pScreen->myNum]". Adding a field to ScreenRec instead
    of keeping this information in a parallel array simplifies those
    expressions, and eliminates a MAXSCREENS-sized array.
    
    Since dix uses this data, a screen private entry isn't appropriate.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Tested-by: Tiago Vignatti <tiago.vignatti at nokia.com> (i686 GNU/Linux)

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index edcbb49..594da0e 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -836,13 +836,14 @@ PanoramiXConsolidate(void)
     saver->type = XRT_WINDOW;
 
     for (i =  0; i < PanoramiXNumScreens; i++) {
+	ScreenPtr pScreen = screenInfo.screens[i];
 	root->info[i].id = WindowTable[i]->drawable.id;
 	root->u.win.class = InputOutput;
         root->u.win.root = TRUE;
-        saver->info[i].id = savedScreenInfo[i].wid;
+        saver->info[i].id = pScreen->screensaver.wid;
         saver->u.win.class = InputOutput;
         saver->u.win.root = TRUE;
-	defmap->info[i].id = (screenInfo.screens[i])->defColormap;
+	defmap->info[i].id = pScreen->defColormap;
     }
 
     AddResource(root->info[0].id, XRT_WINDOW, root);
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 8752ca5..08ea3ec 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -130,7 +130,7 @@ int PanoramiXCreateWindow(ClientPtr client)
     orig_x = stuff->x;
     orig_y = stuff->y;
     parentIsRoot = (stuff->parent == WindowTable[0]->drawable.id) ||
-                   (stuff->parent == savedScreenInfo[0].wid);
+                   (stuff->parent == screenInfo.screens[0]->screensaver.wid);
     FOR_NSCREENS_BACKWARD(j) {
         stuff->wid = newWin->info[j].id;
         stuff->parent = parent->info[j].id;
@@ -329,7 +329,7 @@ int PanoramiXReparentWindow(ClientPtr client)
     x = stuff->x;
     y = stuff->y;
     parentIsRoot = (stuff->parent == WindowTable[0]->drawable.id) ||
-                   (stuff->parent == savedScreenInfo[0].wid);
+                   (stuff->parent == screenInfo.screens[0]->screensaver.wid);
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->window = win->info[j].id;
 	stuff->parent = parent->info[j].id;
@@ -476,7 +476,7 @@ int PanoramiXConfigureWindow(ClientPtr client)
     }
 
     if(pWin->parent && ((pWin->parent == WindowTable[0]) ||
-                        (pWin->parent->drawable.id == savedScreenInfo[0].wid)))
+                        (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid)))
     {
 	if ((Mask)stuff->mask & CWX) {
 	    x_offset = 0;
@@ -563,7 +563,7 @@ int PanoramiXGetGeometry(ClientPtr client)
 	rep.x = pWin->origin.x - wBorderWidth (pWin);
 	rep.y = pWin->origin.y - wBorderWidth (pWin);
 	if((pWin->parent == WindowTable[0]) || 
-           (pWin->parent->drawable.id == savedScreenInfo[0].wid))
+           (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid))
         {
 	   rep.x += panoramiXdataPtr[0].x;
 	   rep.y += panoramiXdataPtr[0].y;
@@ -597,7 +597,7 @@ int PanoramiXTranslateCoords(ClientPtr client)
     rep.child = None;
 
     if((pWin == WindowTable[0]) || 
-       (pWin->drawable.id == savedScreenInfo[0].wid))
+       (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid))
     { 
 	x = stuff->srcX - panoramiXdataPtr[0].x;
 	y = stuff->srcY - panoramiXdataPtr[0].y;
@@ -635,7 +635,7 @@ int PanoramiXTranslateCoords(ClientPtr client)
     rep.dstX = x - pDst->drawable.x;
     rep.dstY = y - pDst->drawable.y;
     if((pDst == WindowTable[0]) || 
-       (pDst->drawable.id == savedScreenInfo[0].wid))
+       (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid))
     {
 	rep.dstX += panoramiXdataPtr[0].x;
 	rep.dstY += panoramiXdataPtr[0].y;
diff --git a/Xext/saver.c b/Xext/saver.c
index fdcbac5..da61fbe 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -285,7 +285,7 @@ CheckScreenPrivate (ScreenPtr pScreen)
     {
 	free(pPriv);
 	SetScreenPrivate (pScreen, NULL);
-	savedScreenInfo[pScreen->myNum].ExternalScreenSaver = NULL;
+	pScreen->screensaver.ExternalScreenSaver = NULL;
     }
 }
 
@@ -304,7 +304,7 @@ MakeScreenPrivate (ScreenPtr pScreen)
     pPriv->hasWindow = FALSE;
     pPriv->installedMap = None;
     SetScreenPrivate (pScreen, pPriv);
-    savedScreenInfo[pScreen->myNum].ExternalScreenSaver = ScreenSaverHandle;
+    pScreen->screensaver.ExternalScreenSaver = ScreenSaverHandle;
     return pPriv;
 }
 
@@ -504,7 +504,7 @@ SendScreenSaverNotify (ScreenPtr pScreen, int state, Bool forced)
 	ev.state = state;
 	ev.timestamp = currentTime.milliseconds;
 	ev.root = WindowTable[pScreen->myNum]->drawable.id;
-	ev.window = savedScreenInfo[pScreen->myNum].wid;
+	ev.window = pScreen->screensaver.wid;
 	ev.kind = kind;
 	ev.forced = forced;
 	WriteEventsToClient (pEv->client, 1, (xEvent *) &ev);
@@ -559,7 +559,7 @@ CreateSaverWindow (ScreenPtr pScreen)
     Colormap			wantMap;
     ColormapPtr			pCmap;
 
-    pSaver = &savedScreenInfo[pScreen->myNum];
+    pSaver = &pScreen->screensaver;
     if (pSaver->pWindow)
     {
 	pSaver->pWindow = NullWindow;
@@ -672,7 +672,7 @@ DestroySaverWindow (ScreenPtr pScreen)
     if (!pPriv || !pPriv->hasWindow)
 	return FALSE;
 
-    pSaver = &savedScreenInfo[pScreen->myNum];
+    pSaver = &pScreen->screensaver;
     if (pSaver->pWindow)
     {
 	pSaver->pWindow = NullWindow;
@@ -756,7 +756,7 @@ ProcScreenSaverQueryInfo (ClientPtr client)
     if (rc != Success)
 	return rc;
 
-    pSaver = &savedScreenInfo[pDraw->pScreen->myNum];
+    pSaver = &pDraw->pScreen->screensaver;
     pPriv = GetScreenPrivate (pDraw->pScreen);
 
     UpdateCurrentTime ();
diff --git a/composite/compwindow.c b/composite/compwindow.c
index f2f6ea3..3b16bf9 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -800,7 +800,7 @@ CompositeRealChildHead (WindowPtr pWin)
 
     if (!pWin->parent &&
 	(screenIsSaved == SCREEN_SAVER_ON) &&
-	(HasSaverWindow (pWin->drawable.pScreen->myNum))) {
+	(HasSaverWindow (pWin->drawable.pScreen))) {
 
 	/* First child is the screen saver; see if next child is the overlay */
 	pChildBefore = pWin->firstChild;
diff --git a/dix/window.c b/dix/window.c
index 00854c6..bdad749 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -151,12 +151,10 @@ WindowSeekDeviceCursor(WindowPtr pWin,
 
 int screenIsSaved = SCREEN_SAVER_OFF;
 
-ScreenSaverStuffRec savedScreenInfo[MAXSCREENS];
-
 static int FocusPrivatesKeyIndex;
 DevPrivateKey FocusPrivatesKey = &FocusPrivatesKeyIndex;
 
-static Bool TileScreenSaver(int i, int kind);
+static Bool TileScreenSaver(ScreenPtr pScreen, int kind);
 
 
 #define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \
@@ -363,9 +361,9 @@ CreateRootWindow(ScreenPtr pScreen)
     if (!pWin)
 	return FALSE;
 
-    savedScreenInfo[pScreen->myNum].pWindow = NULL;
-    savedScreenInfo[pScreen->myNum].wid = FakeClientID(0);
-    savedScreenInfo[pScreen->myNum].ExternalScreenSaver = NULL;
+    pScreen->screensaver.pWindow = NULL;
+    pScreen->screensaver.wid = FakeClientID(0);
+    pScreen->screensaver.ExternalScreenSaver = NULL;
     screenIsSaved = SCREEN_SAVER_OFF;
 
     WindowTable[pScreen->myNum] = pWin;
@@ -539,7 +537,7 @@ RealChildHead(WindowPtr pWin)
 
     if (!pWin->parent &&
 	(screenIsSaved == SCREEN_SAVER_ON) &&
-	(HasSaverWindow (pWin->drawable.pScreen->myNum)))
+	(HasSaverWindow (pWin->drawable.pScreen)))
 	return (pWin->firstChild);
     else
 	return (NullWindow);
@@ -3034,7 +3032,7 @@ NotClippedByChildren(WindowPtr pWin)
     pReg = REGION_CREATE(pScreen, NullBox, 1);
     if (pWin->parent ||
 	screenIsSaved != SCREEN_SAVER_ON ||
-	!HasSaverWindow (pWin->drawable.pScreen->myNum))
+	!HasSaverWindow (pWin->drawable.pScreen))
     {
 	REGION_INTERSECT(pScreen, pReg, &pWin->borderClip, &pWin->winSize);
     }
@@ -3152,33 +3150,33 @@ dixSaveScreens(ClientPtr client, int on, int mode)
     }
     for (i = 0; i < screenInfo.numScreens; i++)
     {
+	ScreenPtr pScreen = screenInfo.screens[i];
 	if (on == SCREEN_SAVER_FORCER)
-	   (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i], on);
-	if (savedScreenInfo[i].ExternalScreenSaver)
+	   (* pScreen->SaveScreen) (pScreen, on);
+	if (pScreen->screensaver.ExternalScreenSaver)
 	{
-	    if ((*savedScreenInfo[i].ExternalScreenSaver)
-		(screenInfo.screens[i], type, on == SCREEN_SAVER_FORCER))
+	    if ((*pScreen->screensaver.ExternalScreenSaver)
+		(pScreen, type, on == SCREEN_SAVER_FORCER))
 		continue;
 	}
 	if (type == screenIsSaved)
 	    continue;
 	switch (type) {
 	case SCREEN_SAVER_OFF:
-	    if (savedScreenInfo[i].blanked == SCREEN_IS_BLANKED)
+	    if (pScreen->screensaver.blanked == SCREEN_IS_BLANKED)
 	    {
-	       (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i],
-						      what);
+	       (* pScreen->SaveScreen) (pScreen, what);
 	    }
-	    else if (HasSaverWindow (i))
+	    else if (HasSaverWindow (pScreen))
 	    {
-		savedScreenInfo[i].pWindow = NullWindow;
-		FreeResource(savedScreenInfo[i].wid, RT_NONE);
+		pScreen->screensaver.pWindow = NullWindow;
+		FreeResource(pScreen->screensaver.wid, RT_NONE);
 	    }
 	    break;
 	case SCREEN_SAVER_CYCLE:
-	    if (savedScreenInfo[i].blanked == SCREEN_IS_TILED)
+	    if (pScreen->screensaver.blanked == SCREEN_IS_TILED)
 	    {
-		WindowPtr pWin = savedScreenInfo[i].pWindow;
+		WindowPtr pWin = pScreen->screensaver.pWindow;
 		/* make it look like screen saver is off, so that
 		 * NotClippedByChildren will compute a clip list
 		 * for the root window, so miPaintWindow works
@@ -3202,35 +3200,33 @@ dixSaveScreens(ClientPtr client, int on, int mode)
 	     * Call the DDX saver in case it wants to do something
 	     * at cycle time
 	     */
-	    else if (savedScreenInfo[i].blanked == SCREEN_IS_BLANKED)
+	    else if (pScreen->screensaver.blanked == SCREEN_IS_BLANKED)
 	    {
-		(* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i],
-						       type);
+		(* pScreen->SaveScreen) (pScreen, type);
 	    }
 	    break;
 	case SCREEN_SAVER_ON:
 	    if (ScreenSaverBlanking != DontPreferBlanking)
 	    {
-		if ((* screenInfo.screens[i]->SaveScreen)
-		   (screenInfo.screens[i], what))
+		if ((* pScreen->SaveScreen) (pScreen, what))
 		{
-		   savedScreenInfo[i].blanked = SCREEN_IS_BLANKED;
+		   pScreen->screensaver.blanked = SCREEN_IS_BLANKED;
 		   continue;
 		}
 		if ((ScreenSaverAllowExposures != DontAllowExposures) &&
-		    TileScreenSaver(i, SCREEN_IS_BLACK))
+		    TileScreenSaver(pScreen, SCREEN_IS_BLACK))
 		{
-		    savedScreenInfo[i].blanked = SCREEN_IS_BLACK;
+		    pScreen->screensaver.blanked = SCREEN_IS_BLACK;
 		    continue;
 		}
 	    }
 	    if ((ScreenSaverAllowExposures != DontAllowExposures) &&
-		TileScreenSaver(i, SCREEN_IS_TILED))
+		TileScreenSaver(pScreen, SCREEN_IS_TILED))
 	    {
-		savedScreenInfo[i].blanked = SCREEN_IS_TILED;
+		pScreen->screensaver.blanked = SCREEN_IS_TILED;
 	    }
 	    else
-		savedScreenInfo[i].blanked = SCREEN_ISNT_SAVED;
+		pScreen->screensaver.blanked = SCREEN_ISNT_SAVED;
 	    break;
 	}
     }
@@ -3252,8 +3248,9 @@ SaveScreens(int on, int mode)
 }
 
 static Bool
-TileScreenSaver(int i, int kind)
+TileScreenSaver(ScreenPtr pScreen, int kind)
 {
+    int i = pScreen->myNum;
     int j;
     int result;
     XID attributes[3];
@@ -3330,12 +3327,12 @@ TileScreenSaver(int i, int kind)
 	}
     }
 
-    pWin = savedScreenInfo[i].pWindow =
-	 CreateWindow(savedScreenInfo[i].wid,
+    pWin = pScreen->screensaver.pWindow =
+	 CreateWindow(pScreen->screensaver.wid,
 	      WindowTable[i],
 	      -RANDOM_WIDTH, -RANDOM_WIDTH,
-	      (unsigned short)screenInfo.screens[i]->width + RANDOM_WIDTH,
-	      (unsigned short)screenInfo.screens[i]->height + RANDOM_WIDTH,
+	      (unsigned short)pScreen->width + RANDOM_WIDTH,
+	      (unsigned short)pScreen->height + RANDOM_WIDTH,
 	      0, InputOutput, mask, attributes, 0, serverClient,
 	      wVisual (WindowTable[i]), &result);
 
@@ -3346,7 +3343,7 @@ TileScreenSaver(int i, int kind)
 	return FALSE;
 
     if (!AddResource(pWin->drawable.id, RT_WINDOW,
-		     (pointer)savedScreenInfo[i].pWindow))
+		     (pointer)pScreen->screensaver.pWindow))
 	return FALSE;
 
     if (mask & CWBackPixmap)
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 21b4a16..1460bc4 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -82,6 +82,16 @@ typedef struct _Depth {
     VisualID		*vids;    /* block of visual ids for this depth */
   } DepthRec;
 
+typedef struct _ScreenSaverStuff {
+    WindowPtr pWindow;
+    XID       wid;
+    char      blanked;
+    Bool      (*ExternalScreenSaver)(
+	ScreenPtr	/*pScreen*/,
+	int		/*xstate*/,
+	Bool		/*force*/);
+} ScreenSaverStuffRec;
+
 
 /*
  *  There is a typedef for each screen function pointer so that code that
@@ -468,6 +478,7 @@ typedef struct _Screen {
     pointer		devPrivate;
     short       	numVisuals;
     VisualPtr		visuals;
+    ScreenSaverStuffRec screensaver;
 
     /* Random screen procedures */
 
diff --git a/include/windowstr.h b/include/windowstr.h
index 96bee9b..29b95fc 100644
--- a/include/windowstr.h
+++ b/include/windowstr.h
@@ -204,24 +204,15 @@ extern _X_EXPORT Mask	DontPropagateMasks[];
 
 #define HasBorder(w)	((w)->borderWidth || wClipShape(w))
 
-typedef struct _ScreenSaverStuff {
-    WindowPtr pWindow;
-    XID       wid;
-    char      blanked;
-    Bool      (*ExternalScreenSaver)(
-	ScreenPtr	/*pScreen*/,
-	int		/*xstate*/,
-	Bool		/*force*/);
-} ScreenSaverStuffRec, *ScreenSaverStuffPtr;
+typedef struct _ScreenSaverStuff *ScreenSaverStuffPtr;
 
 #define SCREEN_IS_BLANKED   0
 #define SCREEN_ISNT_SAVED   1
 #define SCREEN_IS_TILED     2
 #define SCREEN_IS_BLACK	    3
 
-#define HasSaverWindow(i)   (savedScreenInfo[i].pWindow != NullWindow)
+#define HasSaverWindow(pScreen)   (pScreen->screensaver.pWindow != NullWindow)
 
 extern _X_EXPORT int screenIsSaved;
-extern _X_EXPORT ScreenSaverStuffRec savedScreenInfo[MAXSCREENS];
 
 #endif /* WINDOWSTRUCT_H */
diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index df43196..1a3ac41 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -1741,7 +1741,7 @@ miOverlayComputeCompositeClip(GCPtr pGC, WindowPtr pWin)
 	pregWin = REGION_CREATE(pScreen, NullBox, 1);
 	freeTmpClip = TRUE;
 	if (pWin->parent || (screenIsSaved != SCREEN_SAVER_ON) ||
-		!HasSaverWindow (pScreen->myNum))
+		!HasSaverWindow (pScreen))
 	{
             REGION_INTERSECT(pScreen,pregWin,&pTree->borderClip,&pWin->winSize);
 	}
commit 5030540d6cd2aa9bbd4ecb7f4487616f9ef0140a
Author: Jamey Sharp <jamey at minilop.net>
Date:   Thu May 27 11:50:52 2010 -0700

    midispcur: Add comment explaining why pRootPicture must not be freed.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Cc: Peter Hutterer <peter.hutterer at who-t.net>
    Acked-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/mi/midispcur.c b/mi/midispcur.c
index 59923c8..c279010 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -569,6 +569,12 @@ miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
                 if (pBuffer->pSaveGC) FreeGC(pBuffer->pSaveGC, (GContext) 0);
                 if (pBuffer->pRestoreGC) FreeGC(pBuffer->pRestoreGC, (GContext) 0);
 
+#ifdef ARGB_CURSOR
+                /* If a pRootPicture was allocated for a root window, it
+                 * is freed when that root window is destroyed, so don't
+                 * free it again here. */
+#endif
+
                 if (pBuffer->pSave) (*pScreen->DestroyPixmap)(pBuffer->pSave);
 
                 free(pBuffer);
commit f308cbea8c9fa5c5c6705bc301178b167de450d5
Author: Jamey Sharp <jamey at minilop.net>
Date:   Mon May 24 18:41:54 2010 -0700

    mi: Delete unused flicker-free MoveCursor code.
    
    It's been commented-out for three and a half years and nobody seems to
    be missing it enough to resurrect it.
    
    Besides deleting code that is untested and therefore buggy, this saves a
    little memory for each pointer device on each screen.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/mi/midispcur.c b/mi/midispcur.c
index f2b2229..59923c8 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -66,12 +66,9 @@ static DevPrivateKey miDCSpriteKey = miDCSpriteKeyIndex;
 typedef struct {
     GCPtr	    pSourceGC, pMaskGC;
     GCPtr	    pSaveGC, pRestoreGC;
-    GCPtr	    pMoveGC;
-    GCPtr	    pPixSourceGC, pPixMaskGC;
-    PixmapPtr	    pSave, pTemp;
+    PixmapPtr	    pSave;
 #ifdef ARGB_CURSOR
     PicturePtr	    pRootPicture;
-    PicturePtr	    pTempPicture;
 #endif
 } miDCBufferRec, *miDCBufferPtr;
 
@@ -498,243 +495,10 @@ miDCRestoreUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
 }
 
 Bool
-miDCChangeSave (DeviceIntPtr pDev, ScreenPtr pScreen,
-                int x, int y, int w, int h, int dx, int dy)
-{
-    miDCScreenPtr   pScreenPriv;
-    miDCBufferPtr   pBuffer;
-    PixmapPtr	    pSave;
-    WindowPtr	    pWin;
-    GCPtr	    pGC;
-    int		    sourcex, sourcey, destx, desty, copyw, copyh;
-
-    pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
-						  miDCScreenKey);
-    pBuffer = MIDCBUFFER(pDev, pScreen);
-
-    pSave = pBuffer->pSave;
-    pWin = WindowTable[pScreen->myNum];
-    /*
-     * restore the bits which are about to get trashed
-     */
-    if (!pSave)
-	return FALSE;
-
-    pGC = pBuffer->pRestoreGC;
-    if (pWin->drawable.serialNumber != pGC->serialNumber)
-	ValidateGC ((DrawablePtr) pWin, pGC);
-    /*
-     * copy the old bits to the screen.
-     */
-    if (dy > 0)
-    {
-	(*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
-			       0, h - dy, w, dy, x + dx, y + h);
-    }
-    else if (dy < 0)
-    {
-	(*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
-			       0, 0, w, -dy, x + dx, y + dy);
-    }
-    if (dy >= 0)
-    {
-	desty = y + dy;
-	sourcey = 0;
-	copyh = h - dy;
-    }
-    else
-    {
-	desty = y;
-	sourcey = - dy;
-	copyh = h + dy;
-    }
-    if (dx > 0)
-    {
-	(*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
-			       w - dx, sourcey, dx, copyh, x + w, desty);
-    }
-    else if (dx < 0)
-    {
-	(*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
-			       0, sourcey, -dx, copyh, x + dx, desty);
-    }
-
-    pGC = pBuffer->pSaveGC;
-    if (pSave->drawable.serialNumber != pGC->serialNumber)
-	ValidateGC ((DrawablePtr) pSave, pGC);
-    /*
-     * move the bits that are still valid within the pixmap
-     */
-    if (dx >= 0)
-    {
-	sourcex = 0;
-	destx = dx;
-	copyw = w - dx;
-    }
-    else
-    {
-	destx = 0;
-	sourcex = - dx;
-	copyw = w + dx;
-    }
-    if (dy >= 0)
-    {
-	sourcey = 0;
-	desty = dy;
-	copyh = h - dy;
-    }
-    else
-    {
-	desty = 0;
-	sourcey = -dy;
-	copyh = h + dy;
-    }
-    (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pSave, pGC,
-			   sourcex, sourcey, copyw, copyh, destx, desty);
-    /*
-     * copy the new bits from the screen into the remaining areas of the
-     * pixmap
-     */
-    if (dy > 0)
-    {
-	(*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
-			       x, y, w, dy, 0, 0);
-    }
-    else if (dy < 0)
-    {
-	(*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
-			       x, y + h + dy, w, -dy, 0, h + dy);
-    }
-    if (dy >= 0)
-    {
-	desty = dy;
-	sourcey = y + dy;
-	copyh = h - dy;
-    }
-    else
-    {
-	desty = 0;
-	sourcey = y;
-	copyh = h + dy;
-    }
-    if (dx > 0)
-    {
-	(*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
-			       x, sourcey, dx, copyh, 0, desty);
-    }
-    else if (dx < 0)
-    {
-	(*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC,
-			       x + w + dx, sourcey, -dx, copyh, w + dx, desty);
-    }
-    return TRUE;
-}
-
-Bool
-miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
-                int x, int y, int w, int h, int dx, int dy,
-                unsigned long source, unsigned long mask)
-{
-    miDCCursorPtr   pPriv;
-    miDCScreenPtr   pScreenPriv;
-    miDCBufferPtr   pBuffer;
-    int		    status;
-    WindowPtr	    pWin;
-    GCPtr	    pGC;
-    XID		    gcval = FALSE;
-    PixmapPtr	    pTemp;
-
-    pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates,
-					    CursorScreenKey(pScreen));
-    if (!pPriv)
-    {
-	pPriv = miDCRealize(pScreen, pCursor);
-	if (!pPriv)
-	    return FALSE;
-    }
-    pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
-						  miDCScreenKey);
-    pWin = WindowTable[pScreen->myNum];
-    pBuffer = MIDCBUFFER(pDev, pScreen);
-
-    pTemp = pBuffer->pTemp;
-    if (!pTemp ||
-	pTemp->drawable.width != pBuffer->pSave->drawable.width ||
-	pTemp->drawable.height != pBuffer->pSave->drawable.height)
-    {
-	if (pTemp)
-	    (*pScreen->DestroyPixmap) (pTemp);
-#ifdef ARGB_CURSOR
-	if (pBuffer->pTempPicture)
-	{
-	    FreePicture (pBuffer->pTempPicture, 0);
-	    pBuffer->pTempPicture = 0;
-	}
-#endif
-	pBuffer->pTemp = pTemp = (*pScreen->CreatePixmap)
-	    (pScreen, w, h, pBuffer->pSave->drawable.depth, 0);
-	if (!pTemp)
-	    return FALSE;
-    }
-    if (!pBuffer->pMoveGC)
-    {
-	pBuffer->pMoveGC = CreateGC ((DrawablePtr)pTemp,
-	    GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
-	if (!pBuffer->pMoveGC)
-	    return FALSE;
-    }
-    /*
-     * copy the saved area to a temporary pixmap
-     */
-    pGC = pBuffer->pMoveGC;
-    if (pGC->serialNumber != pTemp->drawable.serialNumber)
-	ValidateGC ((DrawablePtr) pTemp, pGC);
-    (*pGC->ops->CopyArea)((DrawablePtr)pBuffer->pSave,
-			  (DrawablePtr)pTemp, pGC, 0, 0, w, h, 0, 0);
-    
-    /*
-     * draw the cursor in the temporary pixmap
-     */
-#ifdef ARGB_CURSOR
-    if (pPriv->pPicture)
-    {
-	if (!EnsurePicture(pBuffer->pTempPicture, &pTemp->drawable, pWin))
-	    return FALSE;
-	CompositePicture (PictOpOver,
-			  pPriv->pPicture,
-			  NULL,
-			  pBuffer->pTempPicture,
-			  0, 0, 0, 0, 
-			  dx, dy, 
-			  pCursor->bits->width,
-			  pCursor->bits->height);
-    }
-    else
-#endif
-    {
-	miDCPutBits ((DrawablePtr)pTemp, pPriv,
-		     pBuffer->pPixSourceGC, pBuffer->pPixMaskGC,
-		     dx, dy, pCursor->bits->width, pCursor->bits->height,
-		     source, mask);
-    }
-
-    pGC = pBuffer->pRestoreGC;
-    if (pWin->drawable.serialNumber != pGC->serialNumber)
-	ValidateGC ((DrawablePtr) pWin, pGC);
-
-    (*pGC->ops->CopyArea) ((DrawablePtr) pTemp, (DrawablePtr) pWin,
-			    pGC,
-			    0, 0, w, h, x, y);
-    return TRUE;
-}
-
-Bool
 miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
 {
     miDCBufferPtr   pBuffer;
     WindowPtr       pWin;
-    XID             gcval = FALSE;
-    int             status;
     int             i;
 
     if (!DevHasCursor(pDev))
@@ -767,28 +531,12 @@ miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
         if (!pBuffer->pRestoreGC)
             goto failure;
 
-        pBuffer->pMoveGC = CreateGC ((DrawablePtr)pWin,
-            GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
-        if (!pBuffer->pMoveGC)
-            goto failure;
-
-        pBuffer->pPixSourceGC = CreateGC ((DrawablePtr)pWin,
-            GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
-        if (!pBuffer->pPixSourceGC)
-            goto failure;
-
-        pBuffer->pPixMaskGC = CreateGC ((DrawablePtr)pWin,
-            GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
-        if (!pBuffer->pPixMaskGC)
-            goto failure;
-
 #ifdef ARGB_CURSOR
         pBuffer->pRootPicture = NULL;
-        pBuffer->pTempPicture = NULL;
 #endif
 
-        // these get (re)allocated lazily depending on the cursor size
-        pBuffer->pSave = pBuffer->pTemp = NULL;
+        /* (re)allocated lazily depending on the cursor size */
+        pBuffer->pSave = NULL;
     }
 
     return TRUE;
@@ -820,12 +568,8 @@ miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
                 if (pBuffer->pMaskGC) FreeGC(pBuffer->pMaskGC, (GContext) 0);
                 if (pBuffer->pSaveGC) FreeGC(pBuffer->pSaveGC, (GContext) 0);
                 if (pBuffer->pRestoreGC) FreeGC(pBuffer->pRestoreGC, (GContext) 0);
-                if (pBuffer->pMoveGC) FreeGC(pBuffer->pMoveGC, (GContext) 0);
-                if (pBuffer->pPixSourceGC) FreeGC(pBuffer->pPixSourceGC, (GContext) 0);
-                if (pBuffer->pPixMaskGC) FreeGC(pBuffer->pPixMaskGC, (GContext) 0);
 
                 if (pBuffer->pSave) (*pScreen->DestroyPixmap)(pBuffer->pSave);
-                if (pBuffer->pTemp) (*pScreen->DestroyPixmap)(pBuffer->pTemp);
 
                 free(pBuffer);
                 dixSetPrivate(&pDev->devPrivates, miDCSpriteKey + pScreen->myNum, NULL);
diff --git a/mi/misprite.c b/mi/misprite.c
index 3d10bc8..2962abf 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -798,73 +798,9 @@ miSpriteSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
 	miSpriteFindColors (pPointer, pScreen);
     }
     if (pPointer->isUp) {
-#if 0
-        /* FIXME: Disabled for MPX, should be rewritten */
-	int	sx, sy;
-	/*
-	 * check to see if the old saved region
-	 * encloses the new sprite, in which case we use
-	 * the flicker-free MoveCursor primitive.
-	 */
-	sx = pointer->x - (int)pCursor->bits->xhot;
-	sy = pointer->y - (int)pCursor->bits->yhot;
-	if (sx + (int) pCursor->bits->width >= pointer->saved.x1 &&
-	    sx < pointer->saved.x2 &&
-	    sy + (int) pCursor->bits->height >= pointer->saved.y1 &&
-	    sy < pointer->saved.y2 &&
-	    (int) pCursor->bits->width + (2 * SPRITE_PAD) ==
-		pointer->saved.x2 - pointer->saved.x1 &&
-	    (int) pCursor->bits->height + (2 * SPRITE_PAD) ==
-		pointer->saved.y2 - pointer->saved.y1
-	    )
-	{
-	    DamageDrawInternal (pScreen, TRUE);
-	    miSpriteIsDown(pCursorInfo);
-	    if (!(sx >= pointer->saved.x1 &&
-                  sx + (int)pCursor->bits->width < pointer->saved.x2
-                  && sy >= pointer->saved.y1 &&
-                  sy + (int)pCursor->bits->height <
-                                pointer->saved.y2))
-            {
-		int oldx1, oldy1, dx, dy;
-
-		oldx1 = pointer->saved.x1;
-		oldy1 = pointer->saved.y1;
-		dx = oldx1 - (sx - SPRITE_PAD);
-		dy = oldy1 - (sy - SPRITE_PAD);
-		pointer->saved.x1 -= dx;
-		pointer->saved.y1 -= dy;
-		pointer->saved.x2 -= dx;
-		pointer->saved.y2 -= dy;
-		(void) miDCChangeSave(pScreen,
-				pointer->saved.x1,
- 				pointer->saved.y1,
-                                pointer->saved.x2 -
-                                pointer->saved.x1,
-                                pointer->saved.y2 -
-                                pointer->saved.y1,
-				dx, dy);
-	    }
-	    (void) miDCMoveCursor(pScreen, pCursor,
-				  pointer->saved.x1,
- 				  pointer->saved.y1,
-                                  pointer->saved.x2 -
-                                  pointer->saved.x1,
-                                  pointer->saved.y2 -
-                                  pointer->saved.y1,
-				  sx - pointer->saved.x1,
-				  sy - pointer->saved.y1,
-				  pointer->colors[SOURCE_COLOR].pixel,
-				  pointer->colors[MASK_COLOR].pixel);
-	    miSpriteIsUp(pCursorInfo);
-	    DamageDrawInternal (pScreen, FALSE);
-	}
-	else
-#endif
-	{
-	    SPRITE_DEBUG (("SetCursor remove %d\n", pDev->id));
-	    miSpriteRemoveCursor (pDev, pScreen);
-	}
+	/* TODO: reimplement flicker-free MoveCursor */
+	SPRITE_DEBUG (("SetCursor remove %d\n", pDev->id));
+	miSpriteRemoveCursor (pDev, pScreen);
     }
 
     if (!pPointer->isUp && pPointer->pCursor)
diff --git a/mi/misprite.h b/mi/misprite.h
index 78bf52c..632d207 100644
--- a/mi/misprite.h
+++ b/mi/misprite.h
@@ -46,12 +46,5 @@ extern Bool miDCSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
                                 int x, int y, int w, int h);
 extern Bool miDCRestoreUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
                                    int x, int y, int w, int h);
-extern Bool miDCMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
-                           CursorPtr pCursor, int x, int y,
-                           int w, int h, int dx, int dy,
-                           unsigned long source, unsigned long mask);
-extern Bool miDCChangeSave(DeviceIntPtr pDev, ScreenPtr pScreen,
-                           int x, int y, int w, int h,
-                           int dx, int dy);
 extern Bool miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen);
 extern void miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen);
commit d1bad1b59f24ab4dcf2d1ce1c5d4f42b5fa40bc1
Author: Jamey Sharp <jamey at minilop.net>
Date:   Tue May 25 14:25:07 2010 -0700

    dmx: Fix XSetExtensionErrorHandler calls to agree on constness.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/dmx/input/dmxcommon.c b/hw/dmx/input/dmxcommon.c
index da5b778..2f23d1c 100644
--- a/hw/dmx/input/dmxcommon.c
+++ b/hw/dmx/input/dmxcommon.c
@@ -370,7 +370,7 @@ void dmxCommonOthGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
     Display              *display = priv->display;
     int                  num;
     int                  i, j, k;
-    int                  (*handler)(Display *, char *, char *);
+    XextErrorHandler     handler;
 
     if (!display && !(display = XOpenDisplay(dmxInput->name)))
         return;
diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index 5943e92..1242be1 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -827,7 +827,7 @@ static void dmxPopulateLocal(DMXInputInfo *dmxInput, dmxArg a)
     }
 }
 
-int dmxInputExtensionErrorHandler(Display *dsp, char *name, char *reason)
+int dmxInputExtensionErrorHandler(Display *dsp, _Xconst char *name, _Xconst char *reason)
 {
     return 0;
 }
@@ -839,7 +839,7 @@ static void dmxInputScanForExtensions(DMXInputInfo *dmxInput, int doXI)
     Display              *display;
     int                  num;
     int                  i, j;
-    int                  (*handler)(Display *, char *, char *);
+    XextErrorHandler     handler;
 
     if (!(display = XOpenDisplay(dmxInput->name))) return;
     
diff --git a/hw/dmx/input/dmxinputinit.h b/hw/dmx/input/dmxinputinit.h
index 2e625cf..5a4a410 100644
--- a/hw/dmx/input/dmxinputinit.h
+++ b/hw/dmx/input/dmxinputinit.h
@@ -276,8 +276,8 @@ extern void dmxKeyboardKbdCtrlProc(DeviceIntPtr pDevice, KeybdCtrl *ctrl);
 extern void dmxKeyboardBellProc(int percent, DeviceIntPtr pDevice,
                                 pointer ctrl, int unknown);
 
-extern int  dmxInputExtensionErrorHandler(Display *dsp, char *name,
-                                          char *reason);
+extern int  dmxInputExtensionErrorHandler(Display *dsp, _Xconst char *name,
+                                          _Xconst char *reason);
 
 extern int          dmxInputDetach(DMXInputInfo *dmxInput);
 extern void         dmxInputDetachAll(DMXScreenInfo *dmxScreen);
commit aa7c09f7d04d59852b850b2b6993f4cbdc7ec940
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Wed Jun 2 14:31:56 2010 -0700

    Install fbdevhw module in normal module directory instead of linux/
    
    Since we no longer support OS-independent custom elfloader modules,
    we don't need to put the OS-dependent modules into os-specific subdirs
    any more.
    
    We do however still need to install the stubs version of this module
    on non-Linux platforms, since a number of drivers link to functions
    in it, even when built on non-Linux platforms.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Michel Dänzer <michel at daenzer.net>
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/fbdevhw/Makefile.am b/hw/xfree86/fbdevhw/Makefile.am
index 0663525..76a69c1 100644
--- a/hw/xfree86/fbdevhw/Makefile.am
+++ b/hw/xfree86/fbdevhw/Makefile.am
@@ -1,5 +1,4 @@
-linuxmoduledir = $(moduledir)/linux
-linuxmodule_LTLIBRARIES = libfbdevhw.la
+module_LTLIBRARIES = libfbdevhw.la
 
 libfbdevhw_la_LDFLAGS = -avoid-version
 
commit b13d7a8e09c8e3eb5003420c3c0484431e5a052b
Merge: f0ab726... dcceb90...
Author: Keith Packard <keithp at keithp.com>
Date:   Thu Jun 3 07:01:26 2010 -0700

    Merge remote branch 'vignatti/for-keith'

commit dcceb90b1dccbbf5793f6ba1ed857013b71dafbc
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Wed May 19 11:45:46 2010 +0200

    xext: delete wrong source reference from fontcache
    
    This should go away in 0b45ba48.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>

diff --git a/Xext/Makefile.am b/Xext/Makefile.am
index fa007aa..e444fd0 100644
--- a/Xext/Makefile.am
+++ b/Xext/Makefile.am
@@ -133,7 +133,6 @@ EXTRA_DIST = \
 	$(XSELINUX_SRCS) \
 	$(XCALIBRATE_SRCS) \
 	$(XINERAMA_SRCS) \
-	$(FONTCACHE_SRCS) \
 	$(BIGFONT_SRCS) \
 	$(DPMS_SRCS) \
         $(GE_SRCS)
commit c043de3261b6e14f2446b2cd9d62dde5860d4720
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Mon May 3 12:37:25 2010 +0200

    configure: sha1: check libsha1 using pkg-config instead
    
    Previously the code was using AC_CHECK_LIB, guaranteeing whether the library
    is correct by tracking sha1_begin function. This paranoic checking is not
    necessary given there's only one libsha1 in the market, which surely contains
    such function.
    
    Moreover, this patch now improves a bit the sha1 implementation checking
    behavior using pkg-config to find the right flags that needs to link against.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>

diff --git a/configure.ac b/configure.ac
index b5b638a..8976319 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1380,7 +1380,7 @@ if test "x$with_sha1" = xlibmd; then
 	          [Use libmd SHA1 functions])
 	SHA1_LIBS=-lmd
 fi
-AC_CHECK_LIB([sha1], [sha1_begin], [HAVE_LIBSHA1=yes])
+PKG_CHECK_MODULES([LIBSHA1], [sha1], [HAVE_LIBSHA1=yes], [HAVE_LIBSHA1=no])
 if test "x$with_sha1" = x && test "x$HAVE_LIBSHA1" = xyes; then
    with_sha1=libsha1
 fi
commit f0ab726d8966cab4e50154c216d577db79328d77
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Wed Apr 21 11:07:47 2010 +0300

    DRI2: Use single error path in initialization
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Kristian Høgsberg <krh at bitplanet.net>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index e1ccdae..5562853 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -1066,18 +1066,14 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 	/* Driver too old: use the old-style driverName field */
 	ds->numDrivers = 1;
 	ds->driverNames = malloc(sizeof(*ds->driverNames));
-	if (!ds->driverNames) {
-	    free(ds);
-	    return FALSE;
-	}
+	if (!ds->driverNames)
+	    goto err_out;
 	ds->driverNames[0] = info->driverName;
     } else {
 	ds->numDrivers = info->numDrivers;
 	ds->driverNames = malloc(info->numDrivers * sizeof(*ds->driverNames));
-	if (!ds->driverNames) {
-	    free(ds);
-	    return FALSE;
-	}
+	if (!ds->driverNames)
+		goto err_out;
 	memcpy(ds->driverNames, info->driverNames,
 	       info->numDrivers * sizeof(*ds->driverNames));
     }
commit 6eef70dc56bcc1e3047e4e488bcd6ae62c8ffac6
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Jan 22 18:34:36 2010 +0200

    DRI2: Allow building without libdrm
    
    Some drivers use DRI protocol but implement their own kernel rendering
    manager. For these drivers, libdrm becomes useless. --disable-libdrm
    configure parameter can be used to disable libdrm support in dri2.
    
    To provide ABI/API compatibility for libdrm based drivers, libdrm call
    is wrapped in ifdef.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Kristian Høgsberg <krh at bitplanet.net>

diff --git a/configure.ac b/configure.ac
index b5b638a..0541bac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -644,6 +644,7 @@ AC_ARG_ENABLE(vgahw,          AS_HELP_STRING([--enable-vgahw], [Build Xorg with
 AC_ARG_ENABLE(vbe,            AS_HELP_STRING([--enable-vbe], [Build Xorg with VBE module (default: enabled)]), [VBE=$enableval], [VBE=yes])
 AC_ARG_ENABLE(int10-module,     AS_HELP_STRING([--enable-int10-module], [Build Xorg with int10 module (default: enabled)]), [INT10MODULE=$enableval], [INT10MODULE=yes])
 AC_ARG_ENABLE(windowswm,      AS_HELP_STRING([--enable-windowswm], [Build XWin with WindowsWM extension (default: no)]), [WINDOWSWM=$enableval], [WINDOWSWM=no])
+AC_ARG_ENABLE(libdrm,         AS_HELP_STRING([--enable-libdrm], [Build Xorg with libdrm support (default: enabled)]), [DRM=$enableval],[DRM=yes])
 
 dnl DDXes.
 AC_ARG_ENABLE(xorg,    	      AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
@@ -1033,9 +1034,10 @@ esac
 AM_CONDITIONAL(DRI2, test "x$DRI2" = xyes)
 
 if test "x$DRI" = xyes || test "x$DRI2" = xyes; then
-	PKG_CHECK_MODULES([LIBDRM], $LIBDRM)
-	AC_SUBST(LIBDRM_CFLAGS)
-	AC_SUBST(LIBDRM_LIBS)
+	if test "x$DRM" = xyes; then
+		AC_DEFINE(WITH_LIBDRM, 1, [Building with libdrm support])
+		PKG_CHECK_MODULES([LIBDRM], $LIBDRM)
+	fi
 fi
 
 if test "x$DRI2" = xyes; then
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 03255a2..e1ccdae 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -35,7 +35,9 @@
 #endif
 
 #include <errno.h>
+#ifdef WITH_LIBDRM
 #include <xf86drm.h>
+#endif
 #include "xf86Module.h"
 #include "list.h"
 #include "scrnintstr.h"
@@ -965,7 +967,7 @@ DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd,
 }
 
 Bool
-DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic)
+DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
 {
     DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
 
@@ -1045,9 +1047,16 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
         ds->AuthMagic = info->AuthMagic;
     }
 
+    /*
+     * if the driver doesn't provide an AuthMagic function or the info struct
+     * version is too low, it relies on the old method (using libdrm) or fail
+     */
     if (!ds->AuthMagic)
+#ifdef WITH_LIBDRM
         ds->AuthMagic = drmAuthMagic;
-
+#else
+        goto err_out;
+#endif
 
     /* Initialize minor if needed and set to minimum provied by DDX */
     if (!dri2_minor || dri2_minor > cur_minor)
@@ -1087,6 +1096,12 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
     }
 
     return TRUE;
+
+err_out:
+    xf86DrvMsg(pScreen->myNum, X_WARNING,
+            "[DRI2] Initialization failed for info version %d.\n", info->version);
+    free(ds);
+    return FALSE;
 }
 
 void
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index 29b1d9b..f08ca29 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -206,7 +206,7 @@ extern _X_EXPORT Bool DRI2Connect(ScreenPtr pScreen,
 		 const char **driverName,
 		 const char **deviceName);
 
-extern _X_EXPORT Bool DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic);
+extern _X_EXPORT Bool DRI2Authenticate(ScreenPtr pScreen, uint32_t magic);
 
 extern _X_EXPORT int DRI2CreateDrawable(ClientPtr client,
 					DrawablePtr pDraw,
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index e6d98f5..db04268 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -42,7 +42,6 @@
 #include "scrnintstr.h"
 #include "pixmapstr.h"
 #include "extnsionst.h"
-#include "xf86drm.h"
 #include "xfixes.h"
 #include "dri2.h"
 #include "protocol-versions.h"
diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in
index 8946a65..56ffda2 100644
--- a/include/xorg-config.h.in
+++ b/include/xorg-config.h.in
@@ -139,4 +139,7 @@
 /* Support PC98 */
 #undef SUPPORT_PC98
 
+/* Build with libdrm support */
+#undef WITH_LIBDRM
+
 #endif /* _XORG_CONFIG_H_ */
commit cdcb575664d3d60b662c542e782de83a047165c9
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Jan 22 17:58:17 2010 +0200

    DRI2: add AuthMagic hook for driver side support
    
    With this new hook, drmAuthMagic becomes useless and should be deprecated.
    You might want to implement AuthMagic on driver side instead.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Kristian Høgsberg <krh at bitplanet.net>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 29c917f..03255a2 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -94,6 +94,7 @@ typedef struct _DRI2Screen {
     DRI2ScheduleSwapProcPtr	 ScheduleSwap;
     DRI2GetMSCProcPtr		 GetMSC;
     DRI2ScheduleWaitMSCProcPtr	 ScheduleWaitMSC;
+    DRI2AuthMagicProcPtr	 AuthMagic;
 
     HandleExposuresProcPtr       HandleExposures;
 
@@ -968,8 +969,8 @@ DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic)
 {
     DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
 
-    if (ds == NULL || drmAuthMagic(ds->fd, magic))
-	return FALSE;
+    if (ds == NULL || (*ds->AuthMagic)(ds->fd, magic))
+        return FALSE;
 
     return TRUE;
 }
@@ -1040,6 +1041,14 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 	cur_minor = 1;
     }
 
+    if (info->version >= 5) {
+        ds->AuthMagic = info->AuthMagic;
+    }
+
+    if (!ds->AuthMagic)
+        ds->AuthMagic = drmAuthMagic;
+
+
     /* Initialize minor if needed and set to minimum provied by DDX */
     if (!dri2_minor || dri2_minor > cur_minor)
 	dri2_minor = cur_minor;
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index be44bdd..29b1d9b 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -66,6 +66,8 @@ typedef void		(*DRI2CopyRegionProcPtr)(DrawablePtr pDraw,
 						 DRI2BufferPtr pSrcBuffer);
 typedef void		(*DRI2WaitProcPtr)(WindowPtr pWin,
 					   unsigned int sequence);
+typedef int		(*DRI2AuthMagicProcPtr)(int fd, uint32_t magic);
+
 /**
  * Schedule a buffer swap
  *
@@ -159,7 +161,7 @@ typedef void		(*DRI2InvalidateProcPtr)(DrawablePtr pDraw,
 /**
  * Version of the DRI2InfoRec structure defined in this header
  */
-#define DRI2INFOREC_VERSION 4
+#define DRI2INFOREC_VERSION 5
 
 typedef struct {
     unsigned int version;	/**< Version of this struct */
@@ -183,6 +185,10 @@ typedef struct {
     /* array of driver names, indexed by DRI2Driver* driver types */
     /* a name of NULL means that driver is not supported */
     const char * const *driverNames;
+
+    /* added in version 5 */
+
+    DRI2AuthMagicProcPtr	AuthMagic;
 }  DRI2InfoRec, *DRI2InfoPtr;
 
 extern _X_EXPORT int DRI2EventBase;
commit 643cb6e87c10ab554c03ada81930001a8ebcc909
Author: Pierre-Loup A. Griffais <pgriffais at nvidia.com>
Date:   Thu May 27 09:11:50 2010 -0700

    Only deal with input code when changing the input shape.
    
    Propagate the shape kind all the way to SetShape to avoid performing non-input
    operations such as revalidating the tree and generating exposures when only
    changing a window's input shape.
    
    Signed-off-by: Pierre-Loup A. Griffais <pgriffais at nvidia.com>
    Acked-by: Aaron Plattner<aplattner at nvidia.com>
    Reviewed-by: Daniel Stone<daniel at fooishbar.org>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/Xext/shape.c b/Xext/shape.c
index 93e4703..86b0bc0 100644
--- a/Xext/shape.c
+++ b/Xext/shape.c
@@ -220,7 +220,7 @@ RegionOperate (
     }
     if (srcRgn)
 	REGION_DESTROY(pScreen, srcRgn);
-    (*pScreen->SetShape) (pWin);
+    (*pScreen->SetShape) (pWin, kind);
     SendShapeNotify (pWin, kind);
     return Success;
 }
@@ -642,7 +642,7 @@ ProcShapeOffset (ClientPtr client)
     if (srcRgn)
     {
         REGION_TRANSLATE(pScreen, srcRgn, stuff->xOff, stuff->yOff);
-        (*pScreen->SetShape) (pWin);
+        (*pScreen->SetShape) (pWin, stuff->destKind);
     }
     SendShapeNotify (pWin, (int)stuff->destKind);
     return Success;
diff --git a/hw/dmx/dmxwindow.c b/hw/dmx/dmxwindow.c
index 39af510..5b0baff 100644
--- a/hw/dmx/dmxwindow.c
+++ b/hw/dmx/dmxwindow.c
@@ -991,7 +991,7 @@ static void dmxDoSetShape(WindowPtr pWindow)
 }
 
 /** Set shape of \a pWindow on the back-end server. */
-void dmxSetShape(WindowPtr pWindow)
+void dmxSetShape(WindowPtr pWindow, int kind)
 {
     ScreenPtr       pScreen = pWindow->drawable.pScreen;
     DMXScreenInfo  *dmxScreen = &dmxScreens[pScreen->myNum];
@@ -1000,7 +1000,7 @@ void dmxSetShape(WindowPtr pWindow)
     DMX_UNWRAP(SetShape, dmxScreen, pScreen);
 #if 1
     if (pScreen->SetShape)
-	pScreen->SetShape(pWindow);
+	pScreen->SetShape(pWindow, kind);
 #endif
 
     if (pWinPriv->window) {
diff --git a/hw/dmx/dmxwindow.h b/hw/dmx/dmxwindow.h
index 740a21f..8bd1f74 100644
--- a/hw/dmx/dmxwindow.h
+++ b/hw/dmx/dmxwindow.h
@@ -94,7 +94,7 @@ extern void dmxResizeRootWindow(WindowPtr pRoot,
 extern Bool dmxBEDestroyWindow(WindowPtr pWindow);
 
 /* Support for shape extension */
-extern void dmxSetShape(WindowPtr pWindow);
+extern void dmxSetShape(WindowPtr pWindow, int kind);
 
 /** Private index.  \see dmxwindow.c \see dmxscrinit.c */
 extern DevPrivateKey dmxWinPrivateKey;
diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c
index 48c870f..11d5369 100644
--- a/hw/xnest/Window.c
+++ b/hw/xnest/Window.c
@@ -423,10 +423,10 @@ xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_exposed)
 }
 
 void
-xnestSetShape(WindowPtr pWin)
+xnestSetShape(WindowPtr pWin, int kind)
 {
   xnestShapeWindow(pWin);
-  miSetShape(pWin);
+  miSetShape(pWin, kind);
 }
 
 static Bool
diff --git a/hw/xnest/XNWindow.h b/hw/xnest/XNWindow.h
index b59d86a..92a1902 100644
--- a/hw/xnest/XNWindow.h
+++ b/hw/xnest/XNWindow.h
@@ -66,7 +66,7 @@ void xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion);
 void xnestClipNotify(WindowPtr pWin, int dx, int dy);
 void xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn,
 			  RegionPtr other_exposed);
-void xnestSetShape(WindowPtr pWin);
+void xnestSetShape(WindowPtr pWin, int kind);
 void xnestShapeWindow(WindowPtr pWin);
 
 #endif /* XNESTWINDOW_H */
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 26bb856..49b73d7 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -1204,7 +1204,7 @@ Bool
 winMapWindowRootless (WindowPtr pWindow);
 
 void
-winSetShapeRootless (WindowPtr pWindow);
+winSetShapeRootless (WindowPtr pWindow, int kind);
 
 
 /*
@@ -1226,7 +1226,7 @@ void
 winReshapeMultiWindow (WindowPtr pWin);
 
 void
-winSetShapeMultiWindow (WindowPtr pWindow);
+winSetShapeMultiWindow (WindowPtr pWindow, int kind);
 
 void
 winUpdateRgnMultiWindow (WindowPtr pWindow);
diff --git a/hw/xwin/winmultiwindowshape.c b/hw/xwin/winmultiwindowshape.c
index 3532357..597eab6 100644
--- a/hw/xwin/winmultiwindowshape.c
+++ b/hw/xwin/winmultiwindowshape.c
@@ -41,17 +41,17 @@
  */
 
 void
-winSetShapeMultiWindow (WindowPtr pWin)
+winSetShapeMultiWindow (WindowPtr pWin, int kind)
 {
   ScreenPtr		pScreen = pWin->drawable.pScreen;
   winScreenPriv(pScreen);
 
 #if CYGMULTIWINDOW_DEBUG
-  ErrorF ("winSetShapeMultiWindow - pWin: %08x\n", pWin);
+  ErrorF ("winSetShapeMultiWindow - pWin: %08x kind: %i\n", pWin, kind);
 #endif
   
   WIN_UNWRAP(SetShape); 
-  (*pScreen->SetShape)(pWin);
+  (*pScreen->SetShape)(pWin, kind);
   WIN_WRAP(SetShape, winSetShapeMultiWindow);
   
   /* Update the Windows window's shape */
diff --git a/hw/xwin/winwindow.c b/hw/xwin/winwindow.c
index 30b6729..d0c360f 100644
--- a/hw/xwin/winwindow.c
+++ b/hw/xwin/winwindow.c
@@ -451,17 +451,17 @@ winMapWindowRootless (WindowPtr pWin)
 
 
 void
-winSetShapeRootless (WindowPtr pWin)
+winSetShapeRootless (WindowPtr pWin, int kind)
 {
   ScreenPtr		pScreen = pWin->drawable.pScreen;
   winScreenPriv(pScreen);
 
 #if CYGDEBUG
-  winTrace ("winSetShapeRootless (%p)\n", pWin);
+  winTrace ("winSetShapeRootless (%p, %i)\n", pWin, kind);
 #endif
 
   WIN_UNWRAP(SetShape); 
-  (*pScreen->SetShape)(pWin);
+  (*pScreen->SetShape)(pWin, kind);
   WIN_WRAP(SetShape, winSetShapeRootless);
   
   winReshapeRootless (pWin);
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 6f1936c..21b4a16 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -423,7 +423,8 @@ typedef    void (* ReparentWindowProcPtr)(
     WindowPtr /*pPriorParent*/);
 
 typedef    void (* SetShapeProcPtr)(
-	WindowPtr /*pWin*/);
+        WindowPtr /*pWin*/,
+        int /* kind */);
 
 typedef    void (* ChangeBorderWidthProcPtr)(
 	WindowPtr /*pWin*/,
diff --git a/mi/mi.h b/mi/mi.h
index 812edce..321523b 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -567,7 +567,8 @@ extern _X_EXPORT WindowPtr miGetLayerWindow(
 );
 
 extern _X_EXPORT void miSetShape(
-    WindowPtr /*pWin*/
+    WindowPtr /*pWin*/,
+    int /*kind*/
 );
 
 extern _X_EXPORT void miChangeBorderWidth(
diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index 2de7682..df43196 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -5,6 +5,7 @@
 
 #include <X11/X.h>
 #include "scrnintstr.h"
+#include <X11/extensions/shapeproto.h>
 #include "validate.h"
 #include "windowstr.h"
 #include "mi.h"
@@ -82,7 +83,7 @@ static void miOverlayResizeWindow(WindowPtr, int, int, unsigned int,
 					unsigned int, WindowPtr);
 static void miOverlayClearToBackground(WindowPtr, int, int, int, int, Bool);
 
-static void miOverlaySetShape(WindowPtr);
+static void miOverlaySetShape(WindowPtr, int);
 static void miOverlayChangeBorderWidth(WindowPtr, unsigned int);
 
 #define MIOVERLAY_GET_SCREEN_PRIVATE(pScreen) ((miOverlayScreenPtr) \
@@ -1497,53 +1498,55 @@ miOverlayResizeWindow(
 
 
 static void
-miOverlaySetShape(WindowPtr pWin)
+miOverlaySetShape(WindowPtr pWin, int kind)
 {
-    Bool	WasViewable = (Bool)(pWin->viewable);
-    ScreenPtr 	pScreen = pWin->drawable.pScreen;
-
-    if (WasViewable) {
-	(*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
-
-	if (HasBorder (pWin)) {
-	    RegionPtr borderVisible;
-
-	    borderVisible = REGION_CREATE(pScreen, NullBox, 1);
-	    REGION_SUBTRACT(pScreen, borderVisible,
-				      &pWin->borderClip, &pWin->winSize);
-	    pWin->valdata->before.borderVisible = borderVisible;
-	    pWin->valdata->before.resized = TRUE;
-	    if(IN_UNDERLAY(pWin)) {
-		miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
-		RegionPtr borderVisible2;
-
-		borderVisible2 = REGION_CREATE(pScreen, NULL, 1);
-		REGION_SUBTRACT(pScreen, borderVisible2,
-				      &pTree->borderClip, &pWin->winSize);
-		pTree->valdata->borderVisible = borderVisible2;
-	    }
-	}
-    }
+    Bool        WasViewable = (Bool)(pWin->viewable);
+    ScreenPtr   pScreen = pWin->drawable.pScreen;
+
+    if (kind != ShapeInput) {
+        if (WasViewable) {
+            (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
+
+            if (HasBorder (pWin)) {
+                RegionPtr borderVisible;
+
+                borderVisible = REGION_CREATE(pScreen, NullBox, 1);
+                REGION_SUBTRACT(pScreen, borderVisible,
+                                        &pWin->borderClip, &pWin->winSize);
+                pWin->valdata->before.borderVisible = borderVisible;
+                pWin->valdata->before.resized = TRUE;
+                if(IN_UNDERLAY(pWin)) {
+                    miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
+                    RegionPtr borderVisible2;
+
+                    borderVisible2 = REGION_CREATE(pScreen, NULL, 1);
+                    REGION_SUBTRACT(pScreen, borderVisible2,
+                                        &pTree->borderClip, &pWin->winSize);
+                    pTree->valdata->borderVisible = borderVisible2;
+                }
+            }
+        }
 
-    SetWinSize (pWin);
-    SetBorderSize (pWin);
+        SetWinSize (pWin);
+        SetBorderSize (pWin);
 
-    ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
+        ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
 
-    if (WasViewable) {
-	(*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
+        if (WasViewable) {
+            (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL);
 
 
-	(*pScreen->ValidateTree)(pWin->parent, NullWindow, VTOther);
-    }
+            (*pScreen->ValidateTree)(pWin->parent, NullWindow, VTOther);
+        }
 
-    if (WasViewable) {
-	(*pScreen->HandleExposures)(pWin->parent);
-	if (pScreen->PostValidateTree)
-	    (*pScreen->PostValidateTree)(pWin->parent, NullWindow, VTOther);
+        if (WasViewable) {
+            (*pScreen->HandleExposures)(pWin->parent);
+            if (pScreen->PostValidateTree)
+                (*pScreen->PostValidateTree)(pWin->parent, NullWindow, VTOther);
+        }
     }
     if (pWin->realized)
-	WindowsRestructured ();
+        WindowsRestructured ();
     CheckCursorConfinement(pWin);
 }
 
diff --git a/mi/miwindow.c b/mi/miwindow.c
index 2550ca2..ce35974 100644
--- a/mi/miwindow.c
+++ b/mi/miwindow.c
@@ -50,6 +50,7 @@ SOFTWARE.
 #endif
 
 #include <X11/X.h>
+#include <X11/extensions/shape.h>
 #include "regionstr.h"
 #include "region.h"
 #include "mi.h"
@@ -696,56 +697,59 @@ miGetLayerWindow(WindowPtr pWin)
  */
 
 void
-miSetShape(WindowPtr pWin)
+miSetShape(WindowPtr pWin, int kind)
 {
-    Bool	WasViewable = (Bool)(pWin->viewable);
-    ScreenPtr 	pScreen = pWin->drawable.pScreen;
-    Bool	anyMarked = FALSE;
+    Bool        WasViewable = (Bool)(pWin->viewable);
+    ScreenPtr   pScreen = pWin->drawable.pScreen;
+    Bool        anyMarked = FALSE;
     WindowPtr   pLayerWin;
 
-    if (WasViewable)
-    {
-	anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
-						      &pLayerWin);
-	if (pWin->valdata)
-	{
-	    if (HasBorder (pWin))
-	    {
-		RegionPtr	borderVisible;
-
-		borderVisible = REGION_CREATE(pScreen, NullBox, 1);
-		REGION_SUBTRACT(pScreen, borderVisible,
-				      &pWin->borderClip, &pWin->winSize);
-		pWin->valdata->before.borderVisible = borderVisible;
-	    }
-	    pWin->valdata->before.resized = TRUE;
-	}
-    }
-
-    SetWinSize (pWin);
-    SetBorderSize (pWin);
-
-    ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
-
-    if (WasViewable)
-    {
-	anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
-						NULL);
-
-
-	if (anyMarked)
-	    (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, VTOther);
-    }
-
-    if (WasViewable)
-    {
-	if (anyMarked)
-	    (*pScreen->HandleExposures)(pLayerWin->parent);
-	if (anyMarked && pScreen->PostValidateTree)
-	    (*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, VTOther);
+    if (kind != ShapeInput) {
+        if (WasViewable)
+        {
+            anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin,
+                                                          &pLayerWin);
+            if (pWin->valdata)
+            {
+                if (HasBorder (pWin))
+                {
+                    RegionPtr borderVisible;
+
+                    borderVisible = REGION_CREATE(pScreen, NullBox, 1);
+                    REGION_SUBTRACT(pScreen, borderVisible,
+                                    &pWin->borderClip, &pWin->winSize);
+                    pWin->valdata->before.borderVisible = borderVisible;
+                }
+                pWin->valdata->before.resized = TRUE;
+            }
+        }
+
+        SetWinSize (pWin);
+        SetBorderSize (pWin);
+
+        ResizeChildrenWinSize(pWin, 0, 0, 0, 0);
+
+        if (WasViewable)
+        {
+            anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin,
+                                                           NULL);
+
+            if (anyMarked)
+                (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow,
+                                         VTOther);
+        }
+
+        if (WasViewable)
+        {
+            if (anyMarked)
+                (*pScreen->HandleExposures)(pLayerWin->parent);
+            if (anyMarked && pScreen->PostValidateTree)
+                (*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow,
+                                             VTOther);
+        }
     }
     if (pWin->realized)
-	WindowsRestructured ();
+        WindowsRestructured ();
     CheckCursorConfinement(pWin);
 }
 
diff --git a/xfixes/region.c b/xfixes/region.c
index 7a71c78..b034ad0 100644
--- a/xfixes/region.c
+++ b/xfixes/region.c
@@ -733,7 +733,7 @@ ProcXFixesSetWindowShapeRegion (ClientPtr client)
     if (*pDestRegion)
 	REGION_DESTROY(pScreen, *pDestRegion);
     *pDestRegion = pRegion;
-    (*pScreen->SetShape) (pWin);
+    (*pScreen->SetShape) (pWin, stuff->destKind);
     SendShapeNotify (pWin, stuff->destKind);
     return Success;
 }
commit d90f2cd98a97e6534792d3867b3fba70d850b706
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu May 27 13:26:23 2010 +0100

    xfree86: Unbreak autoconfig following 0abf065e38c4
    
    The move of the PCI device id probing into a separate file neglected to
    return the number of found devices, and so the PCI devices were being
    overwritten by the default entries for vesa and fbdev.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
    Cc: Tiago Vignatti <tiago.vignatti at nokia.com>
    Cc: Alex Deucher <alexdeucher at gmail.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Reviewed-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index 8947a4f..5b236af 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -257,7 +257,7 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
     }
 #endif
 
-    xf86PciMatchDriver(matches, nmatches);
+    i = xf86PciMatchDriver(matches, nmatches);
 
     /* Fallback to platform default hardware */
     if (i < (nmatches - 1)) {
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index 085be01..184f221 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -1294,7 +1294,11 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip
 }
 #endif /* __linux__ */
 
-void
+/**
+ *  @return The numbers of found devices that match with the current system
+ *  drivers.
+ */
+int
 xf86PciMatchDriver(char* matches[], int nmatches) {
     int i;
     struct pci_device * info = NULL;
@@ -1326,4 +1330,6 @@ xf86PciMatchDriver(char* matches[], int nmatches) {
     if ((info != NULL) && (i < nmatches)) {
 	i += videoPtrToDriverList(info, &(matches[i]), nmatches - i);
     }
+
+    return i;
 }
diff --git a/hw/xfree86/common/xf86pciBus.h b/hw/xfree86/common/xf86pciBus.h
index f84a496..3f02b93 100644
--- a/hw/xfree86/common/xf86pciBus.h
+++ b/hw/xfree86/common/xf86pciBus.h
@@ -37,6 +37,6 @@ void xf86PciProbe(void);
 Bool xf86PciAddMatchingDev(DriverPtr drvp);
 Bool xf86PciProbeDev(DriverPtr drvp);
 void xf86PciIsolateDevice(char *argument);
-void xf86PciMatchDriver(char* matches[], int nmatches);
+int xf86PciMatchDriver(char* matches[], int nmatches);
 
 #endif /* _XF86_PCI_BUS_H */
commit 1304b8b27cb12c803c4f51f04cb6f9d508b82c69
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Fri May 28 09:35:54 2010 -0700

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

diff --git a/dbe/midbe.c b/dbe/midbe.c
index e47a253..49689c5 100644
--- a/dbe/midbe.c
+++ b/dbe/midbe.c
@@ -695,25 +695,33 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
 
 
         pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
-        ValidateGC((DrawablePtr)pFrontBuffer, pGC);
 
 	/* I suppose this could avoid quite a bit of work if
 	 * it computed the minimal area required.
 	 */
+	ValidateGC(&pFrontBuffer->drawable, pGC);
 	if (clear)
         {
 	    (*pGC->ops->PolyFillRect)((DrawablePtr)pFrontBuffer, pGC, 1,
 				      &clearRect);
-	    (*pGC->ops->PolyFillRect)((DrawablePtr)pBackBuffer , pGC, 1,
-				      &clearRect);
-        }
-
-        /* Copy the contents of the old DBE pixmaps to the new pixmaps. */
+	}
+	/* Copy the contents of the old front pixmap to the new one. */
 	if (pWin->bitGravity != ForgetGravity)
 	{
 	    (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer,
                                   (DrawablePtr)pFrontBuffer, pGC, sourcex,
                                   sourcey, savewidth, saveheight, destx, desty);
+        }
+
+	ValidateGC(&pBackBuffer->drawable, pGC);
+	if (clear)
+	{
+	    (*pGC->ops->PolyFillRect)((DrawablePtr)pBackBuffer , pGC, 1,
+				      &clearRect);
+	}
+	/* Copy the contents of the old back pixmap to the new one. */
+	if (pWin->bitGravity != ForgetGravity)
+	{
 	    (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer,
                                   (DrawablePtr)pBackBuffer, pGC, sourcex,
                                   sourcey, savewidth, saveheight, destx, desty);
commit 91a6359caf24d94343ff76f43ea7b7fc3223203d
Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Jun 3 12:16:40 2010 +1000

    composite: initialise pOldPixmap to NullPixmap at alloc time.
    
    We just never initialised the malloced value.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/composite/compalloc.c b/composite/compalloc.c
index 3694ab8..7930ebe 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -143,6 +143,7 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
 	cw->oldy = COMP_ORIGIN_INVALID;
 	cw->damageRegistered = FALSE;
 	cw->damaged = FALSE;
+	cw->pOldPixmap = NullPixmap;
 	dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, cw);
     }
     ccw->next = cw->clients;
commit 968a79dcf5e17ac3963953ef56b8f94dbd75323b
Author: Nicolas George <nicolas.george at normalesup.org>
Date:   Wed Jun 2 13:40:51 2010 +0200

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

diff --git a/dix/devices.c b/dix/devices.c
index b0b4653..250a498 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2021,7 +2021,7 @@ ProcChangeKeyboardControl (ClientPtr client)
     keyboard = PickKeyboard(client);
 
     for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
-        if ((pDev == keyboard || (!IsMaster(keyboard) && pDev->u.master == keyboard)) &&
+        if ((pDev == keyboard || (!IsMaster(pDev) && pDev->u.master == keyboard)) &&
             pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
             ret = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess);
 	    if (ret != Success)
@@ -2030,7 +2030,7 @@ ProcChangeKeyboardControl (ClientPtr client)
     }
 
     for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
-        if ((pDev == keyboard || (!IsMaster(keyboard) && pDev->u.master == keyboard)) &&
+        if ((pDev == keyboard || (!IsMaster(pDev) && pDev->u.master == keyboard)) &&
             pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
             ret = DoChangeKeyboardControl(client, pDev, vlist, vmask);
             if (ret != Success)
commit 108b766c31b57fb1955d34d85673a235c7f743aa
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu May 20 11:04:53 2010 +1000

    xfree86: initialize InputAttributes to NULL in the autoconfig code.
    
    Reported-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index a481368..7acb6af 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -2330,6 +2330,7 @@ configInput(IDevPtr inputp, XF86ConfInputPtr conf_input, MessageType from)
     inputp->driver = conf_input->inp_driver;
     inputp->commonOptions = conf_input->inp_option_lst;
     inputp->extraOptions = NULL;
+    inputp->attrs = NULL;
 
     return TRUE;
 }
commit 151659f9636088fd70bc5586de97bf43ee706180
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon May 24 16:24:03 2010 +1000

    test: fix up InputAttributes helper function test.
    
    Just some extra clarification as pointed out by Dan Nicholson,
    and that memcpy should have been a memcmp.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Dan Nicholson <dbn.lists at gmail.com>

diff --git a/test/input.c b/test/input.c
index 8a54af9..12771c5 100644
--- a/test/input.c
+++ b/test/input.c
@@ -803,12 +803,18 @@ static void cmp_attr_fields(InputAttributes *attr1,
 
     tags1 = attr1->tags;
     tags2 = attr2->tags;
+
+    /* if we don't have any tags, skip the tag checking bits */
     if (!tags1)
     {
         g_assert(!tags2);
         return;
     }
 
+    /* Don't lug around empty arrays */
+    g_assert(*tags1);
+    g_assert(*tags2);
+
     /* check for identical content, but duplicated */
     while (*tags1)
     {
@@ -818,6 +824,7 @@ static void cmp_attr_fields(InputAttributes *attr1,
         tags2++;
     }
 
+    /* ensure tags1 and tags2 have the same no of elements */
     g_assert(!*tags2);
 
     /* check for not sharing memory */
@@ -842,7 +849,7 @@ static void dix_input_attributes(void)
     g_assert(!new);
 
     new = DuplicateInputAttributes(&orig);
-    g_assert(memcpy(&orig, new, sizeof(InputAttributes)));
+    g_assert(memcmp(&orig, new, sizeof(InputAttributes)) == 0);
 
     orig.product = "product name";
     new = DuplicateInputAttributes(&orig);
commit 6cccf0131c8464d8838cae2200730873d7dd9e45
Author: Peter Korsgaard <peter.korsgaard at barco.com>
Date:   Tue May 25 11:03:28 2010 +0200

    dix: add 3x3 transformation matrix xinput property for multi-head handling
    
    For absolute input devices (E.G. touchscreens) in multi-head setups,
    we need a way to bind the device to an randr output. This adds the
    infrastructure to the server to allow us to do so.
    
    positionSprite() scales input coordinates to the dimensions of the shared
    (total) screen frame buffer, so to restrict motion to an output we need to
    scale/rotate/translate device coordinates to a subset of the frame buffer
    before passing them on to positionSprite.
    
    This is done here using a 3x3 transformation matrix, which is applied to
    the device coordinates using homogeneous coordinates, E.G.:
    
    [ c0 c1 c2 ]   [ x ]
    [ c3 c4 c5 ] * [ y ]
    [ c6 c7 c8 ]   [ 1 ]
    
    Notice: As input devices have varying input ranges, the coordinates are
    first scaled to the [0..1] range for generality, and afterwards scaled
    back up.
    
    E.G. for a dual head setup (using same resolution) next to each other, you
    would want to scale the X coordinates of the touchscreen connected to the
    both heads by 50%, and translate (offset) the coordinates of the rightmost
    head by 50%, or in matrix form:
    
       left:            right:
    [ 0.5 0 0 ]     [ 0.5 0 0.5 ]
    [ 0   1 0 ]     [ 0   1 0   ]
    [ 0   0 1 ]     [ 0   0 0   ]
    
    Which can be done using xinput:
    
    xinput set-prop <left> --type=float "Coordinate Transformation Matrix" \
           0.5 0 0 0 1 0 0 0 1
    
    xinput set-prop <right> --type=float "Coordinate Transformation Matrix" \
           0.5 0 0.5 0 1 0 0 0 1
    
    Likewise more complication setups involving more heads, rotation or
    different resolution can be handled.
    
    Signed-off-by: Peter Korsgaard <peter.korsgaard at barco.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index 8bb1962..b4d939f 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -177,7 +177,9 @@ static struct dev_properties
     {0, BTN_LABEL_PROP_BTN_TOOL_TRIPLETAP},
 
     {0, BTN_LABEL_PROP_BTN_GEAR_DOWN},
-    {0, BTN_LABEL_PROP_BTN_GEAR_UP}
+    {0, BTN_LABEL_PROP_BTN_GEAR_UP},
+
+    {0, XI_PROP_TRANSFORM}
 };
 
 static long XIPropHandlerID = 1;
diff --git a/dix/devices.c b/dix/devices.c
index cf23bc6..b0b4653 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -77,6 +77,8 @@ SOFTWARE.
 #include <X11/extensions/XI.h>
 #include <X11/extensions/XI2.h>
 #include <X11/extensions/XIproto.h>
+#include <math.h>
+#include <pixman.h>
 #include "exglobals.h"
 #include "exevents.h"
 #include "xiquerydevice.h" /* for SizeDeviceClasses */
@@ -91,6 +93,48 @@ SOFTWARE.
 
 static void RecalculateMasterButtons(DeviceIntPtr slave);
 
+static void
+DeviceSetTransform(DeviceIntPtr dev, float *transform)
+{
+    struct pixman_f_transform scale;
+    double sx, sy;
+    int x, y;
+
+    /**
+     * calculate combined transformation matrix:
+     *
+     * M = InvScale * Transform * Scale
+     *
+     * So we can later transform points using M * p
+     *
+     * Where:
+     *  Scale scales coordinates into 0..1 range
+     *  Transform is the user supplied (affine) transform
+     *  InvScale scales coordinates back up into their native range
+     */
+    sx = dev->valuator->axes[0].max_value - dev->valuator->axes[0].min_value;
+    sy = dev->valuator->axes[1].max_value - dev->valuator->axes[1].min_value;
+
+    /* invscale */
+    pixman_f_transform_init_scale(&scale, sx, sy);
+    scale.m[0][2] = dev->valuator->axes[0].min_value;
+    scale.m[1][2] = dev->valuator->axes[1].min_value;
+
+    /* transform */
+    for (y=0; y<3; y++)
+        for (x=0; x<3; x++)
+            dev->transform.m[y][x] = *transform++;
+
+    pixman_f_transform_multiply(&dev->transform, &scale, &dev->transform);
+
+    /* scale */
+    pixman_f_transform_init_scale(&scale, 1.0 / sx, 1.0 / sy);
+    scale.m[0][2] = -dev->valuator->axes[0].min_value / sx;
+    scale.m[1][2] = -dev->valuator->axes[1].min_value / sy;
+
+    pixman_f_transform_multiply(&dev->transform, &dev->transform, &scale);
+}
+
 /**
  * DIX property handler.
  */
@@ -115,6 +159,21 @@ DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
             else if (!(*((CARD8*)prop->data)) && dev->enabled)
                 DisableDevice(dev, TRUE);
         }
+    } else if (property == XIGetKnownProperty(XI_PROP_TRANSFORM))
+    {
+        float *f = (float*)prop->data;
+        int i;
+
+        if (prop->format != 32 || prop->size != 9 ||
+            prop->type != XIGetKnownProperty(XATOM_FLOAT))
+            return BadValue;
+
+        for (i=0; i<9; i++)
+            if (!isfinite(f[i]))
+                return BadValue;
+
+        if (!checkonly)
+            DeviceSetTransform(dev, f);
     }
 
     return Success;
@@ -183,6 +242,7 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
     int devid;
     char devind[MAXDEVICES];
     BOOL enabled;
+    float transform[9];
 
     /* Find next available id, 0 and 1 are reserved */
     memset(devind, 0, sizeof(char)*MAXDEVICES);
@@ -234,6 +294,17 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
                            XA_INTEGER, 8, PropModeReplace, 1, &enabled,
                            FALSE);
     XISetDevicePropertyDeletable(dev, XIGetKnownProperty(XI_PROP_ENABLED), FALSE);
+
+    /* unity matrix */
+    memset(transform, 0, sizeof(transform));
+    transform[0] = transform[4] = transform[8] = 1.0f;
+
+    XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_TRANSFORM),
+                           XIGetKnownProperty(XATOM_FLOAT), 32,
+                           PropModeReplace, 9, transform, FALSE);
+    XISetDevicePropertyDeletable(dev, XIGetKnownProperty(XI_PROP_TRANSFORM),
+                                 FALSE);
+
     XIRegisterPropertyHandler(dev, DeviceSetProperty, NULL, NULL);
 
     return dev;
diff --git a/dix/getevents.c b/dix/getevents.c
index 62aaff9..eeef414 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -33,6 +33,7 @@
 #include <X11/X.h>
 #include <X11/keysym.h>
 #include <X11/Xproto.h>
+#include <math.h>
 
 #include "misc.h"
 #include "resource.h"
@@ -56,6 +57,7 @@
 
 #include <X11/extensions/XI.h>
 #include <X11/extensions/XIproto.h>
+#include <pixman.h>
 #include "exglobals.h"
 #include "exevents.h"
 #include "exglobals.h"
@@ -997,6 +999,22 @@ FreeEventList(EventListPtr list, int num_events)
     free(list);
 }
 
+static void
+transformAbsolute(DeviceIntPtr dev, int v[MAX_VALUATORS])
+{
+    struct pixman_f_vector p;
+
+    /* p' = M * p in homogeneous coordinates */
+    p.v[0] = v[0];
+    p.v[1] = v[1];
+    p.v[2] = 1.0;
+
+    pixman_f_transform_point(&dev->transform, &p);
+
+    v[0] = lround(p.v[0]);
+    v[1] = lround(p.v[1]);
+}
+
 /**
  * Generate a series of xEvents (filled into the EventList) representing
  * pointer motion, or button presses.  Xi and XKB-aware.
@@ -1068,6 +1086,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
                         scr->height);
         }
 
+        transformAbsolute(pDev, valuators);
         moveAbsolute(pDev, &x, &y, first_valuator, num_valuators, valuators);
     } else {
         if (flags & POINTER_ACCELERATE) {
diff --git a/include/inputstr.h b/include/inputstr.h
index c5b9ff7..a83e863 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -49,6 +49,7 @@ SOFTWARE.
 #ifndef INPUTSTRUCT_H
 #define INPUTSTRUCT_H
 
+#include <pixman.h>
 #include "input.h"
 #include "window.h"
 #include "dixstruct.h"
@@ -550,6 +551,9 @@ typedef struct _DeviceIntRec {
         XIPropertyPtr   properties;
         XIPropertyHandlerPtr handlers; /* NULL-terminated */
     } properties;
+
+    /* coordinate transformation matrix for absolute input devices */
+    struct pixman_f_transform transform;
 } DeviceIntRec;
 
 typedef struct {
diff --git a/include/xserver-properties.h b/include/xserver-properties.h
index 30e8efb..c6259ae 100644
--- a/include/xserver-properties.h
+++ b/include/xserver-properties.h
@@ -35,6 +35,13 @@
 /* BOOL. If present, device is a virtual XTEST device */
 #define XI_PROP_XTEST_DEVICE  "XTEST Device"
 
+/* Coordinate transformation matrix for absolute input devices
+ * FLOAT, 9 values in row-major order, coordinates in 0..1 range:
+ * [c0 c1 c2]   [x]
+ * [c3 c4 c5] * [y]
+ * [c6 c7 c8]   [1] */
+#define XI_PROP_TRANSFORM "Coordinate Transformation Matrix"
+
 /* Pointer acceleration properties */
 /* INTEGER of any format */
 #define ACCEL_PROP_PROFILE_NUMBER "Device Accel Profile"
commit e4582d9e5c8649347742a13eae68cf27005296fc
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu May 27 10:42:54 2010 -0400

    xfree86: bump ABI_XINPUT_VERSION to 11.
    
    commit c2d0b3b437b7ce6ce975f2ead4d8bb8295ef0ddc
    "xfree86: store the InputAttributes in the input device."
    introduced the new API. Bump the input version so drivers can handle this
    appropriately.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index d61758f..51b9b16 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -83,7 +83,7 @@ typedef enum {
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 4)
 #define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(8, 0)
-#define ABI_XINPUT_VERSION	SET_ABI_VERSION(10, 0)
+#define ABI_XINPUT_VERSION	SET_ABI_VERSION(11, 0)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(4, 0)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 6)
 
commit cd0ef0b6a2f9c6bfeda98684569da922792d3feb
Author: Jamey Sharp <jamey at minilop.net>
Date:   Tue May 25 14:30:22 2010 -0700

    dmx: Delete unused ChangeKeyboardDevice/ChangePointerDevice.
    
    Daniel Stone deleted the API for these in 2006, in commit
    96e32805d12fc36f0fa0926dbfb0dd8a5cadb739.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/dmx/input/dmxxinput.c b/hw/dmx/input/dmxxinput.c
index a2a4156..8b58eeb 100644
--- a/hw/dmx/input/dmxxinput.c
+++ b/hw/dmx/input/dmxxinput.c
@@ -51,63 +51,6 @@
 #include "dmxinputinit.h"
 #include "exevents.h"
 
-/** Change the core keyboard from \a old_dev to \a new_dev.  Currently
- * this is not implemented. */
-int ChangeKeyboardDevice(DeviceIntPtr old_dev, DeviceIntPtr new_dev)
-{
-#if 0
-    DMXLocalInputInfoPtr dmxLocalOld = old_dev->public.devicePrivate;
-    DMXLocalInputInfoPtr dmxLocalNew = new_dev->public.devicePrivate;
-    
-                                /* Switch our notion of core keyboard */
-    dmxLocalOld->isCore         = 0;
-    dmxLocalOld->sendsCore      = dmxLocalOld->savedSendsCore;
-
-    dmxLocalNew->isCore         = 1;
-    dmxLocalNew->savedSendsCore = dmxLocalNew->sendsCore;
-    dmxLocalNew->sendsCore      = 1;
-    dmxLocalCorePointer         = dmxLocalNew;
-
-    RegisterKeyboardDevice(new_dev);
-    RegisterOtherDevice(old_dev);
-    
-    return Success;
-#endif
-    return BadMatch;
-}
-
-/** Change the core pointer from \a old_dev to \a new_dev. */
-int ChangePointerDevice(DeviceIntPtr old_dev,
-                        DeviceIntPtr new_dev,
-                        unsigned char x,
-                        unsigned char y)
-{
-    DMXLocalInputInfoPtr dmxLocalOld = old_dev->public.devicePrivate;
-    DMXLocalInputInfoPtr dmxLocalNew = new_dev->public.devicePrivate;
-    
-    if (x != 0 || y != 1) return BadMatch;
-
-                                /* Make sure the new device can focus */
-    InitFocusClassDeviceStruct(old_dev);
-
-                                /* Switch the motion history buffers */
-    if (dmxLocalOld->savedMotionProc) {
-        old_dev->valuator->numMotionEvents = dmxLocalOld->savedMotionEvents;
-    }
-    dmxLocalNew->savedMotionEvents     = new_dev->valuator->numMotionEvents;
-    new_dev->valuator->numMotionEvents = GetMaximumEventsNum();
-                                /* Switch our notion of core pointer */
-    dmxLocalOld->isCore         = 0;
-    dmxLocalOld->sendsCore      = dmxLocalOld->savedSendsCore;
-
-    dmxLocalNew->isCore         = 1;
-    dmxLocalNew->savedSendsCore = dmxLocalNew->sendsCore;
-    dmxLocalNew->sendsCore      = 1;
-    dmxLocalCorePointer         = dmxLocalNew;
-    
-    return Success;
-}
-
 /** Close the input device.  This is not required by the XINPUT model
  * that DMX uses. */
 void CloseInputDevice (DeviceIntPtr d, ClientPtr client)
commit 70454864917f534483fa049e067b5646df61c88a
Author: Jamey Sharp <jamey at minilop.net>
Date:   Fri May 14 12:31:44 2010 -0700

    Ignore build products in the server's test suite.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Cc: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/test/.gitignore b/test/.gitignore
index ed97e81..db8c5f3 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -1,2 +1,15 @@
 #		Add & Override for this directory and it's subdirectories
 libxservertest.c
+
+input
+xkb
+xtest
+xi2/protocol-eventconvert
+xi2/protocol-xigetclientpointer
+xi2/protocol-xigetselectedevents
+xi2/protocol-xiquerydevice
+xi2/protocol-xiquerypointer
+xi2/protocol-xiqueryversion
+xi2/protocol-xiselectevents
+xi2/protocol-xisetclientpointer
+xi2/protocol-xiwarppointer
commit 8bb88379d95356384e233225bfda6abfd71389b4
Author: Jamey Sharp <jamey at minilop.net>
Date:   Tue May 25 15:52:18 2010 -0700

    dmx: Remove dead __glXDispSwap_DrawArraysEXT definition.
    
    Eric Anholt made the corresponding fix in glx/render2swap.c in commit
    49d38ab2328c409b2a98465b52677af057121513.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Alex Deucher <alexdeucher at gmail.com>

diff --git a/hw/dmx/glxProxy/render2swap.c b/hw/dmx/glxProxy/render2swap.c
index 37e43d8..0daeed1 100644
--- a/hw/dmx/glxProxy/render2swap.c
+++ b/hw/dmx/glxProxy/render2swap.c
@@ -333,9 +333,3 @@ void __glXDispSwap_DrawArrays(GLbyte *pc)
     }
 
 }
-
-void __glXDispSwap_DrawArraysEXT(GLbyte *pc)
-{
-#ifdef XXX_STUB
-#endif /*XXX_STUB*/
-}
commit c97a3ade5a8718b063292c73a31aac2196fe2452
Author: Jamey Sharp <jamey at minilop.net>
Date:   Tue May 25 15:17:30 2010 -0700

    dmx: Delete unused local variables.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/dmx/glxProxy/g_renderswap.c b/hw/dmx/glxProxy/g_renderswap.c
index b92821d..b6bede3 100644
--- a/hw/dmx/glxProxy/g_renderswap.c
+++ b/hw/dmx/glxProxy/g_renderswap.c
@@ -101,7 +101,6 @@ void __glXDispSwap_Color3sv(GLbyte *pc)
 
 void __glXDispSwap_Color3ubv(GLbyte *pc)
 {
-	__GLX_DECLARE_SWAP_VARIABLES;
 }
 
 void __glXDispSwap_Color3uiv(GLbyte *pc)
@@ -120,7 +119,6 @@ void __glXDispSwap_Color3usv(GLbyte *pc)
 
 void __glXDispSwap_Color4bv(GLbyte *pc)
 {
-	__GLX_DECLARE_SWAP_VARIABLES;
 }
 
 void __glXDispSwap_Color4dv(GLbyte *pc)
@@ -163,7 +161,6 @@ void __glXDispSwap_Color4sv(GLbyte *pc)
 
 void __glXDispSwap_Color4ubv(GLbyte *pc)
 {
-	__GLX_DECLARE_SWAP_VARIABLES;
 
 }
 
@@ -185,16 +182,10 @@ void __glXDispSwap_Color4usv(GLbyte *pc)
 
 void __glXDispSwap_EdgeFlagv(GLbyte *pc)
 {
-	__GLX_DECLARE_SWAP_VARIABLES;
-
-
 }
 
 void __glXDispSwap_End(GLbyte *pc)
 {
-	__GLX_DECLARE_SWAP_VARIABLES;
-
-
 }
 
 void __glXDispSwap_Indexdv(GLbyte *pc)
@@ -238,9 +229,6 @@ void __glXDispSwap_Indexsv(GLbyte *pc)
 
 void __glXDispSwap_Normal3bv(GLbyte *pc)
 {
-	__GLX_DECLARE_SWAP_VARIABLES;
-
-
 }
 
 void __glXDispSwap_Normal3dv(GLbyte *pc)
@@ -1203,9 +1191,6 @@ void __glXDispSwap_TexGeniv(GLbyte *pc)
 
 void __glXDispSwap_InitNames(GLbyte *pc)
 {
-	__GLX_DECLARE_SWAP_VARIABLES;
-
-
 }
 
 void __glXDispSwap_LoadName(GLbyte *pc)
@@ -1226,9 +1211,6 @@ void __glXDispSwap_PassThrough(GLbyte *pc)
 
 void __glXDispSwap_PopName(GLbyte *pc)
 {
-	__GLX_DECLARE_SWAP_VARIABLES;
-
-
 }
 
 void __glXDispSwap_PushName(GLbyte *pc)
@@ -1318,16 +1300,10 @@ void __glXDispSwap_StencilMask(GLbyte *pc)
 
 void __glXDispSwap_ColorMask(GLbyte *pc)
 {
-	__GLX_DECLARE_SWAP_VARIABLES;
-
-
 }
 
 void __glXDispSwap_DepthMask(GLbyte *pc)
 {
-	__GLX_DECLARE_SWAP_VARIABLES;
-
-
 }
 
 void __glXDispSwap_IndexMask(GLbyte *pc)
@@ -1365,9 +1341,6 @@ void __glXDispSwap_Enable(GLbyte *pc)
 
 void __glXDispSwap_PopAttrib(GLbyte *pc)
 {
-	__GLX_DECLARE_SWAP_VARIABLES;
-
-
 }
 
 void __glXDispSwap_PushAttrib(GLbyte *pc)
@@ -1698,9 +1671,6 @@ void __glXDispSwap_Frustum(GLbyte *pc)
 
 void __glXDispSwap_LoadIdentity(GLbyte *pc)
 {
-	__GLX_DECLARE_SWAP_VARIABLES;
-
-
 }
 
 void __glXDispSwap_LoadMatrixf(GLbyte *pc)
@@ -1779,16 +1749,10 @@ void __glXDispSwap_Ortho(GLbyte *pc)
 
 void __glXDispSwap_PopMatrix(GLbyte *pc)
 {
-	__GLX_DECLARE_SWAP_VARIABLES;
-
-
 }
 
 void __glXDispSwap_PushMatrix(GLbyte *pc)
 {
-	__GLX_DECLARE_SWAP_VARIABLES;
-
-
 }
 
 void __glXDispSwap_Rotated(GLbyte *pc)
@@ -1974,9 +1938,6 @@ void __glXDispSwap_PrioritizeTextures(GLbyte *pc)
 
 void __glXDispSwap_Indexubv(GLbyte *pc)
 {
-	__GLX_DECLARE_SWAP_VARIABLES;
-
-
 }
 
 void __glXDispSwap_BlendColor(GLbyte *pc)
diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c
index 18df675..389aa3d 100644
--- a/hw/dmx/glxProxy/glxcmds.c
+++ b/hw/dmx/glxProxy/glxcmds.c
@@ -3420,11 +3420,6 @@ int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
    Display *dpy;
    int screen, rc;
    DMXScreenInfo *dmxScreen;
-   char *attrbuf;
-#ifdef PANORAMIX
-    PanoramiXRes *pXinDraw = NULL;
-    PanoramiXRes *pXinReadDraw = NULL;
-#endif
 
    if (drawId != None) {
       rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixSetAttrAccess);
@@ -3491,7 +3486,7 @@ int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
 
 #ifdef PANORAMIX
        if (!noPanoramiXExtension) {
-	  pXinDraw = (PanoramiXRes *)
+	  PanoramiXRes *pXinDraw = (PanoramiXRes *)
 	     SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess);
 	  if (!pXinDraw) {
 	     client->errorValue = drawId;
diff --git a/hw/dmx/glxProxy/glxscreens.c b/hw/dmx/glxProxy/glxscreens.c
index dbd4a92..0298435 100644
--- a/hw/dmx/glxProxy/glxscreens.c
+++ b/hw/dmx/glxProxy/glxscreens.c
@@ -254,7 +254,6 @@ void __glXScreenInit(GLint numscreens)
 	 if (numscreens > 1) {
 	    for (s=1; s<numscreens; s++) {
 	       DMXScreenInfo *dmxScreen = &dmxScreens[s];
-	       __GLXscreenInfo *glxScreen = &__glXActiveScreens[s];
 	  
 	       cfg = FindMatchingFBConfig( &dmxScreen0->fbconfigs[c],
 		                           dmxScreen->fbconfigs, 
diff --git a/hw/dmx/glxProxy/glxsingle.c b/hw/dmx/glxProxy/glxsingle.c
index a41257e..a076134 100644
--- a/hw/dmx/glxProxy/glxsingle.c
+++ b/hw/dmx/glxProxy/glxsingle.c
@@ -750,7 +750,6 @@ int __glXDisp_ReadPixels(__GLXclientState *cl, GLbyte *pc)
     GLboolean swapBytes, lsbFirst;
     ClientPtr client = cl->client;
     DrawablePtr pDraw;
-    int error;
     __GLXcontext *glxc;
     int from_screen = 0;
     int to_screen = 0;
diff --git a/hw/dmx/glxProxy/renderpixswap.c b/hw/dmx/glxProxy/renderpixswap.c
index 462feee..9deb30d 100644
--- a/hw/dmx/glxProxy/renderpixswap.c
+++ b/hw/dmx/glxProxy/renderpixswap.c
@@ -358,7 +358,7 @@ void __glXDispSwap_SeparableFilter2D(GLbyte *pc)
 {
     __GLXdispatchConvolutionFilterHeader *hdr =
 				(__GLXdispatchConvolutionFilterHeader *) pc;
-    GLint hdrlen, image1len;
+    GLint hdrlen;
     __GLX_DECLARE_SWAP_VARIABLES;
 
     hdrlen = __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE);
diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index 9da4aba..5943e92 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -839,7 +839,6 @@ static void dmxInputScanForExtensions(DMXInputInfo *dmxInput, int doXI)
     Display              *display;
     int                  num;
     int                  i, j;
-    DMXLocalInputInfoPtr dmxLocal;
     int                  (*handler)(Display *, char *, char *);
 
     if (!(display = XOpenDisplay(dmxInput->name))) return;
commit 3c3d099fc10c63d746f90c08043d45180d6a7226
Author: Jamey Sharp <jamey at minilop.net>
Date:   Tue May 25 13:44:32 2010 -0700

    dmx: Xfree -> free
    
    Mikhail fixed the corresponding Xallocs, but missed these uses of Xfree
    in commit 3f3ff971ecff9936cebafc813af9193b97bba89c.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c
index d9b884a..18df675 100644
--- a/hw/dmx/glxProxy/glxcmds.c
+++ b/hw/dmx/glxProxy/glxcmds.c
@@ -3404,7 +3404,7 @@ int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
       WriteToClient(client, attribs_size, (char *)attribs);
    }
 
-   Xfree(attribs);
+   free(attribs);
 
    return Success;
 }
diff --git a/hw/dmx/glxProxy/glxscreens.c b/hw/dmx/glxProxy/glxscreens.c
index 7be7ac4..dbd4a92 100644
--- a/hw/dmx/glxProxy/glxscreens.c
+++ b/hw/dmx/glxProxy/glxscreens.c
@@ -204,9 +204,9 @@ static void CalcServerVersionAndExtensions( void )
     * release temporary storage
     */
    for (s=0; s<__glXNumActiveScreens; s++) {
-      if (be_extensions[s]) Xfree(be_extensions[s]); 
+      free(be_extensions[s]);
    }
-   Xfree( be_extensions );
+   free( be_extensions );
 
    if (dmxGLXSwapGroupSupport) {
        if (!denied_extensions ||
diff --git a/hw/dmx/glxProxy/glxsingle.c b/hw/dmx/glxProxy/glxsingle.c
index 8c7fdfc..a41257e 100644
--- a/hw/dmx/glxProxy/glxsingle.c
+++ b/hw/dmx/glxProxy/glxsingle.c
@@ -288,7 +288,7 @@ int __glXForwardPipe0WithReply( __GLXclientState *cl, GLbyte *pc )
 	  WriteToClient(client, be_buf_size, (char *)be_buf);
     }
 
-    if (be_buf_size > 0) Xfree(be_buf);
+    if (be_buf_size > 0) free(be_buf);
 
     return Success;
 }
@@ -364,7 +364,7 @@ int __glXForwardAllWithReply( __GLXclientState *cl, GLbyte *pc )
        SyncHandle();
 
        if (s > from_screen && be_buf_size > 0) {
-	  Xfree(be_buf);
+	  free(be_buf);
        }
     }
 
@@ -388,7 +388,7 @@ int __glXForwardAllWithReply( __GLXclientState *cl, GLbyte *pc )
 	  WriteToClient(client, be_buf_size, (char *)be_buf);
     }
 
-    if (be_buf_size > 0) Xfree(be_buf);
+    if (be_buf_size > 0) free(be_buf);
 
     return Success;
 }
@@ -939,12 +939,12 @@ int __glXDisp_ReadPixels(__GLXclientState *cl, GLbyte *pc)
 
 		   }
 
-		   Xfree( be_buf );
+		   free( be_buf );
 		}
 		else {
 		   /* Throw data on the floor */
 		   _XEatData(dpy, be_buf_size);
-		   Xfree( buf );
+		   free( buf );
 		   return BadAlloc;
 		}
 	     }
@@ -970,7 +970,7 @@ int __glXDisp_ReadPixels(__GLXclientState *cl, GLbyte *pc)
     WriteToClient(client, sizeof(xGLXReadPixelsReply),(char *)&reply);
     if (buf_size > 0) {
        WriteToClient(client, buf_size, (char *)buf);
-       Xfree( buf );
+       free( buf );
     }
 
     return Success;
diff --git a/hw/dmx/glxProxy/glxvendor.c b/hw/dmx/glxProxy/glxvendor.c
index 6af53e2..cf864c2 100644
--- a/hw/dmx/glxProxy/glxvendor.c
+++ b/hw/dmx/glxProxy/glxvendor.c
@@ -272,7 +272,7 @@ int __glXVForwardPipe0WithReply( __GLXclientState *cl, GLbyte *pc )
 	  WriteToClient(client, be_buf_size, (char *)be_buf);
     }
 
-    if (be_buf_size > 0) Xfree(be_buf);
+    if (be_buf_size > 0) free(be_buf);
 
     return Success;
 }
@@ -349,7 +349,7 @@ int __glXVForwardAllWithReply( __GLXclientState *cl, GLbyte *pc )
        SyncHandle();
 
        if (s > from_screen && be_buf_size > 0) {
-	  Xfree(be_buf);
+	  free(be_buf);
        }
     }
 
@@ -369,7 +369,7 @@ int __glXVForwardAllWithReply( __GLXclientState *cl, GLbyte *pc )
 	  WriteToClient(client, be_buf_size, (char *)be_buf);
     }
 
-    if (be_buf_size > 0) Xfree(be_buf);
+    if (be_buf_size > 0) free(be_buf);
 
     return Success;
 }
commit 01ca6400d949a873c0bb5de7e0dbf138e8a7949b
Author: Jamey Sharp <jamey at minilop.net>
Date:   Tue May 25 14:02:34 2010 -0700

    Xephyr: Fix Xcalloc deprecation warnings.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/kdrive/ephyr/XF86dri.c b/hw/kdrive/ephyr/XF86dri.c
index 08123d3..e7c88b3 100644
--- a/hw/kdrive/ephyr/XF86dri.c
+++ b/hw/kdrive/ephyr/XF86dri.c
@@ -221,7 +221,7 @@ XF86DRIOpenConnection (Display *dpy, int screen,
     }
 
     if (rep.length) {
-        if (!(*busIdString = (char *)Xcalloc(rep.busIdStringLength + 1, 1))) {
+        if (!(*busIdString = (char *)calloc(rep.busIdStringLength + 1, 1))) {
             _XEatData(dpy, ((rep.busIdStringLength+3) & ~3));
             UnlockDisplay(dpy);
             SyncHandle();
@@ -316,7 +316,7 @@ Bool XF86DRIGetClientDriverName(Display *dpy, int screen,
     *ddxDriverPatchVersion = rep.ddxDriverPatchVersion;
 
     if (rep.length) {
-        if (!(*clientDriverName = (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) {
+        if (!(*clientDriverName = (char *)calloc(rep.clientDriverNameLength + 1, 1))) {
             _XEatData(dpy, ((rep.clientDriverNameLength+3) & ~3));
             UnlockDisplay(dpy);
             SyncHandle();
@@ -528,7 +528,7 @@ Bool XF86DRIGetDrawableInfo(Display* dpy, int screen, Drawable drawable,
     if (*numClipRects) {
        int len = sizeof(drm_clip_rect_t) * (*numClipRects);
 
-       *pClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
+       *pClipRects = (drm_clip_rect_t *)calloc(len, 1);
        if (*pClipRects)
 	  _XRead(dpy, (char*)*pClipRects, len);
     } else {
@@ -538,7 +538,7 @@ Bool XF86DRIGetDrawableInfo(Display* dpy, int screen, Drawable drawable,
     if (*numBackClipRects) {
        int len = sizeof(drm_clip_rect_t) * (*numBackClipRects);
 
-       *pBackClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
+       *pBackClipRects = (drm_clip_rect_t *)calloc(len, 1);
        if (*pBackClipRects) 
 	  _XRead(dpy, (char*)*pBackClipRects, len);
     } else {
@@ -587,7 +587,7 @@ XF86DRIGetDeviceInfo (Display *dpy, int screen, drm_handle_t *hFrameBuffer,
     *devPrivateSize = rep.devPrivateSize;
 
     if (rep.length) {
-        if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) {
+        if (!(*pDevPrivate = (void *)calloc(rep.devPrivateSize, 1))) {
             _XEatData(dpy, ((rep.devPrivateSize+3) & ~3));
             UnlockDisplay(dpy);
             SyncHandle();
diff --git a/hw/kdrive/ephyr/ephyrhostvideo.c b/hw/kdrive/ephyr/ephyrhostvideo.c
index 53cd12e..38927b0 100644
--- a/hw/kdrive/ephyr/ephyrhostvideo.c
+++ b/hw/kdrive/ephyr/ephyrhostvideo.c
@@ -262,7 +262,7 @@ ephyrHostXVQueryAdaptors (EphyrHostXVAdaptorArray **a_adaptors)
 
     EPHYR_LOG ("enter\n") ;
 
-    result = Xcalloc (1, sizeof (EphyrHostXVAdaptorArray)) ;
+    result = calloc (1, sizeof (EphyrHostXVAdaptorArray)) ;
     if (!result)
         goto out ;
 
@@ -340,7 +340,7 @@ ephyrHostXVAdaptorGetVideoFormats (const EphyrHostXVAdaptor *a_this,
     EPHYR_RETURN_VAL_IF_FAIL (a_this, NULL) ;
 
     nb_formats = ((XvAdaptorInfo*)a_this)->num_formats ;
-    formats = Xcalloc (nb_formats, sizeof (EphyrHostVideoFormat)) ;
+    formats = calloc (nb_formats, sizeof (EphyrHostVideoFormat)) ;
     for (i=0; i < nb_formats; i++) {
         memset (&visual_info_template, 0, sizeof (visual_info_template)) ;
         visual_info_template.visualid =
@@ -454,7 +454,7 @@ ephyrHostXVQueryEncodings (int a_port_id,
                             &num_encodings,
                             &encoding_info) ;
     if (num_encodings && encoding_info) {
-        encodings = Xcalloc (num_encodings, sizeof (EphyrHostEncoding)) ;
+        encodings = calloc (num_encodings, sizeof (EphyrHostEncoding)) ;
         for (i=0; i<num_encodings; i++) {
             encodings[i].id = encoding_info[i].encoding_id ;
             encodings[i].name = strdup (encoding_info[i].name) ;
commit 34df659687ad3936ab03d19ce8fdb21f385c2e8a
Author: Jamey Sharp <jamey at minilop.net>
Date:   Tue May 25 11:51:32 2010 -0700

    xfree86/int10/helper_mem: Fix log message.
    
    Three years ago in commit f62beb6f3609e8b6e61325ac89017590811bbd07 ajax
    deleted the code that could have set this format string to anything
    else, so just use the format string literal. This makes GCC happy since
    it can check the argument types, which, by the way, weren't correct
    since this format string doesn't need any arguments.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Alex Deucher <alexdeucher at gmail.com>
    Reviewed-by: Tiago Vignatti <tiago.vignatti at nokia.com>

diff --git a/hw/xfree86/int10/helper_mem.c b/hw/xfree86/int10/helper_mem.c
index 3f206c2..496c9a5 100644
--- a/hw/xfree86/int10/helper_mem.c
+++ b/hw/xfree86/int10/helper_mem.c
@@ -296,15 +296,12 @@ xf86int10GetBiosSegment(xf86Int10InfoPtr pInt, void *base)
     unsigned i;
     int cs = ~0;
     int segments[4];
-    const char * format;
 
     segments[0] = MEM_RW(pInt, (0x10 << 2) + 2);
     segments[1] = MEM_RW(pInt, (0x42 << 2) + 2);
     segments[2] = V_BIOS >> 4;
     segments[3] = ~0;
 
-    format = "No V_BIOS found\n";
-
     for (i = 0; segments[i] != ~0; i++) {
 	unsigned char * vbiosMem;
 
@@ -318,7 +315,7 @@ xf86int10GetBiosSegment(xf86Int10InfoPtr pInt, void *base)
     }
 
     if (segments[i] == ~0) {
-	xf86DrvMsg(pInt->scrnIndex, X_ERROR, format, (unsigned long)cs << 4);
+	xf86DrvMsg(pInt->scrnIndex, X_ERROR, "No V_BIOS found\n");
 	return FALSE;
     }
 
commit 0a98d9e6cec7c611a3c56f97d4ddc0c546975c55
Author: Jamey Sharp <jamey at minilop.net>
Date:   Tue May 25 10:30:58 2010 -0700

    xf86bigfont: Silence compiler warning by initializing pDesc.
    
    Access to pDesc was always guarded by (nCharInfos > 0), so the code
    wasn't actually buggy, but this makes it clear that it's correct.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Alex Deucher <alexdeucher at gmail.com>

diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c
index 8c4a7eb..8b3913d 100644
--- a/Xext/xf86bigfont.c
+++ b/Xext/xf86bigfont.c
@@ -404,7 +404,7 @@ ProcXF86BigfontQueryFont(
     int nCharInfos;
     int shmid;
 #ifdef HAS_SHM
-    ShmDescPtr pDesc;
+    ShmDescPtr pDesc = NULL;
 #else
 #define pDesc 0
 #endif
@@ -449,8 +449,6 @@ ProcXF86BigfontQueryFont(
 #ifdef HAS_SHM
 	if (!badSysCall)
 	    pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex);
-	else
-	    pDesc = NULL;
 	if (pDesc) {
 	    pCI = (xCharInfo *) pDesc->attach_addr;
 	    if (stuff_flags & XF86Bigfont_FLAGS_Shm)
commit 4e9d3e413245e7c01c2ff3c0f130b8967754131b
Author: Keith Packard <keithp at keithp.com>
Date:   Wed May 26 07:54:35 2010 -0700

    Revert "Add a "flags" field to DeleteInputDeviceRequest."
    
    Peter wants to get a larger patch sequence put together and I didn't
    read past the commit message to see the 'don't take this patch
    please'.
    
    This reverts commit 531ff40301975519af7b20109c17d296312d3f2b.

diff --git a/Xi/stubs.c b/Xi/stubs.c
index 8285549..04ba976 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -241,6 +241,6 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
  *
  */
 void
-DeleteInputDeviceRequest(DeviceIntPtr dev, int flags)
+DeleteInputDeviceRequest(DeviceIntPtr dev)
 {
 }
diff --git a/config/config.c b/config/config.c
index f49420d..65ef679 100644
--- a/config/config.c
+++ b/config/config.c
@@ -81,7 +81,7 @@ remove_device(const char *backend, DeviceIntPtr dev)
      * already been removed. */
     OsBlockSignals();
     ProcessInputEvents();
-    DeleteInputDeviceRequest(dev, 0);
+    DeleteInputDeviceRequest(dev);
     OsReleaseSignals();
 }
 
diff --git a/config/dbus.c b/config/dbus.c
index 511908a..72a0a05 100644
--- a/config/dbus.c
+++ b/config/dbus.c
@@ -226,7 +226,7 @@ remove_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
      * already been removed. */
     OsBlockSignals();
     ProcessInputEvents();
-    DeleteInputDeviceRequest(dev, 0);
+    DeleteInputDeviceRequest(dev);
     OsReleaseSignals();
 
     ret = Success;
diff --git a/dix/devices.c b/dix/devices.c
index 2784024..cf23bc6 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -891,7 +891,7 @@ CloseDeviceList(DeviceIntPtr *listHead)
     while (dev != NULL)
     {
         freedIds[dev->id] = TRUE;
-        DeleteInputDeviceRequest(dev, DEVICE_REMOVE_ALL);
+        DeleteInputDeviceRequest(dev);
 
         dev = *listHead;
         while (dev != NULL && freedIds[dev->id])
diff --git a/hw/dmx/dmxinput.c b/hw/dmx/dmxinput.c
index eceb251..568bb88 100644
--- a/hw/dmx/dmxinput.c
+++ b/hw/dmx/dmxinput.c
@@ -114,6 +114,6 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
 }
 
 void
-DeleteInputDeviceRequest(DeviceIntPtr pDev, int flags)
+DeleteInputDeviceRequest(DeviceIntPtr pDev)
 {
 }
diff --git a/hw/kdrive/linux/evdev.c b/hw/kdrive/linux/evdev.c
index cb16176..3797f09 100644
--- a/hw/kdrive/linux/evdev.c
+++ b/hw/kdrive/linux/evdev.c
@@ -165,7 +165,7 @@ EvdevPtrRead (int evdevPort, void *closure)
     n = read (evdevPort, &events, NUM_EVENTS * sizeof (struct input_event));
     if (n <= 0) {
         if (errno == ENODEV)
-            DeleteInputDeviceRequest(pi->dixdev, 0);
+            DeleteInputDeviceRequest(pi->dixdev);
         return;
     }
 
@@ -375,7 +375,7 @@ EvdevKbdRead (int evdevPort, void *closure)
     n = read (evdevPort, &events, NUM_EVENTS * sizeof (struct input_event));
     if (n <= 0) {
         if (errno == ENODEV)
-            DeleteInputDeviceRequest(ki->dixdev, 0);
+            DeleteInputDeviceRequest(ki->dixdev);
         return;
     }
 
diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index 51b9b16..d61758f 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -83,7 +83,7 @@ typedef enum {
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 4)
 #define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(8, 0)
-#define ABI_XINPUT_VERSION	SET_ABI_VERSION(11, 0)
+#define ABI_XINPUT_VERSION	SET_ABI_VERSION(10, 0)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(4, 0)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 6)
 
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index b30ebbb..356ddab 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -854,7 +854,7 @@ unwind:
 }
 
 void
-DeleteInputDeviceRequest(DeviceIntPtr pDev, int flags)
+DeleteInputDeviceRequest(DeviceIntPtr pDev)
 {
     LocalDevicePtr pInfo = (LocalDevicePtr) pDev->public.devicePrivate;
     InputDriverPtr drv = NULL;
@@ -874,9 +874,9 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev, int flags)
     if (!isMaster && pInfo != NULL)
     {
         if(drv->UnInit)
-            drv->UnInit(drv, pInfo, flags);
+            drv->UnInit(drv, pInfo, 0);
         else
-            xf86DeleteInput(pInfo, flags);
+            xf86DeleteInput(pInfo, 0);
 
         /* devices added through HAL aren't in the config layout */
         it = xf86ConfigLayout.inputs;
@@ -1267,7 +1267,7 @@ xf86DisableDevice(DeviceIntPtr dev, Bool panic)
     } else
     {
         SendDevicePresenceEvent(dev->id, DeviceUnrecoverable);
-        DeleteInputDeviceRequest(dev, 0);
+        DeleteInputDeviceRequest(dev);
     }
 }
 
diff --git a/hw/xquartz/darwinXinput.c b/hw/xquartz/darwinXinput.c
index 59ca627..90e440e 100644
--- a/hw/xquartz/darwinXinput.c
+++ b/hw/xquartz/darwinXinput.c
@@ -245,7 +245,7 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
  *
  */
 void
-DeleteInputDeviceRequest(DeviceIntPtr dev, int flags)
+DeleteInputDeviceRequest(DeviceIntPtr dev)
 {
   DEBUG_LOG("DeleteInputDeviceRequest(%p)\n", dev);
 }
diff --git a/include/input.h b/include/input.h
index 5426c44..c68a284 100644
--- a/include/input.h
+++ b/include/input.h
@@ -62,9 +62,6 @@ SOFTWARE.
 #define DEVICE_OFF	2
 #define DEVICE_CLOSE	3
 
-/* DeleteInputDeviceRequest flags */
-#define DEVICE_REMOVE_ALL    (1 << 0) /* all devices will be removed */
-
 #define POINTER_RELATIVE (1 << 1)
 #define POINTER_ABSOLUTE (1 << 2)
 #define POINTER_ACCELERATE (1 << 3)
@@ -539,8 +536,7 @@ extern _X_EXPORT int NewInputDeviceRequest(
     InputAttributes *attrs,
     DeviceIntPtr *dev);
 extern  _X_EXPORT void DeleteInputDeviceRequest(
-    DeviceIntPtr dev,
-    int flags);
+    DeviceIntPtr dev);
 
 extern _X_EXPORT void DDXRingBell(
     int volume,
commit 531ff40301975519af7b20109c17d296312d3f2b
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu May 20 18:07:12 2010 +1000

    Add a "flags" field to DeleteInputDeviceRequest.
    
    Some input drivers need to implement an internal hotplugging scheme for
    dependent devices to provide multiple X devices off one kernel device file.
    Such dependent devices can be added with NewInputDeviceRequest() but they are
    not removed when the config backend calls DeleteInputDeviceRequest(),
    leaving the original device to clean up.
    
    Example of the wacom driver:
    
    config/udev calls NewInputDeviceRequest("stylus")
    
    wacom PreInit calls
            NewInputDeviceRequest("eraser")
            NewInputDeviceRequest("pad")
            NewInputDeviceRequest("cursor")
            PreInit finishes.
    
    When the device is removed, the config backend only calls
    DeleteInputDeviceRequest for "stylus". The driver needs to call
    DeleteInputDeviceRequest for the dependent devices eraser, pad and cursor to
    clean up properly.
    However, when the server terminates, DeleteInputDeviceRequest is called for
    all devices - the driver must not remove the dependent devices to avoid
    double-frees. There is no method for the driver to detect why a device is
    being removed, leading to elaborate guesswork and some amount of wishful
    thinking.
    
    Though the input driver's UnInit already supports flags, they are unused.
    This patch uses the flags to supply information where the
    DeleteInputDeviceRequest request originates from, allowing a driver to
    selectively call DeleteInputDeviceRequest when necessary.
    
    Also bumps XINPUT ABI.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/Xi/stubs.c b/Xi/stubs.c
index 04ba976..8285549 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -241,6 +241,6 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
  *
  */
 void
-DeleteInputDeviceRequest(DeviceIntPtr dev)
+DeleteInputDeviceRequest(DeviceIntPtr dev, int flags)
 {
 }
diff --git a/config/config.c b/config/config.c
index 65ef679..f49420d 100644
--- a/config/config.c
+++ b/config/config.c
@@ -81,7 +81,7 @@ remove_device(const char *backend, DeviceIntPtr dev)
      * already been removed. */
     OsBlockSignals();
     ProcessInputEvents();
-    DeleteInputDeviceRequest(dev);
+    DeleteInputDeviceRequest(dev, 0);
     OsReleaseSignals();
 }
 
diff --git a/config/dbus.c b/config/dbus.c
index 72a0a05..511908a 100644
--- a/config/dbus.c
+++ b/config/dbus.c
@@ -226,7 +226,7 @@ remove_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
      * already been removed. */
     OsBlockSignals();
     ProcessInputEvents();
-    DeleteInputDeviceRequest(dev);
+    DeleteInputDeviceRequest(dev, 0);
     OsReleaseSignals();
 
     ret = Success;
diff --git a/dix/devices.c b/dix/devices.c
index cf23bc6..2784024 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -891,7 +891,7 @@ CloseDeviceList(DeviceIntPtr *listHead)
     while (dev != NULL)
     {
         freedIds[dev->id] = TRUE;
-        DeleteInputDeviceRequest(dev);
+        DeleteInputDeviceRequest(dev, DEVICE_REMOVE_ALL);
 
         dev = *listHead;
         while (dev != NULL && freedIds[dev->id])
diff --git a/hw/dmx/dmxinput.c b/hw/dmx/dmxinput.c
index 568bb88..eceb251 100644
--- a/hw/dmx/dmxinput.c
+++ b/hw/dmx/dmxinput.c
@@ -114,6 +114,6 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
 }
 
 void
-DeleteInputDeviceRequest(DeviceIntPtr pDev)
+DeleteInputDeviceRequest(DeviceIntPtr pDev, int flags)
 {
 }
diff --git a/hw/kdrive/linux/evdev.c b/hw/kdrive/linux/evdev.c
index 3797f09..cb16176 100644
--- a/hw/kdrive/linux/evdev.c
+++ b/hw/kdrive/linux/evdev.c
@@ -165,7 +165,7 @@ EvdevPtrRead (int evdevPort, void *closure)
     n = read (evdevPort, &events, NUM_EVENTS * sizeof (struct input_event));
     if (n <= 0) {
         if (errno == ENODEV)
-            DeleteInputDeviceRequest(pi->dixdev);
+            DeleteInputDeviceRequest(pi->dixdev, 0);
         return;
     }
 
@@ -375,7 +375,7 @@ EvdevKbdRead (int evdevPort, void *closure)
     n = read (evdevPort, &events, NUM_EVENTS * sizeof (struct input_event));
     if (n <= 0) {
         if (errno == ENODEV)
-            DeleteInputDeviceRequest(ki->dixdev);
+            DeleteInputDeviceRequest(ki->dixdev, 0);
         return;
     }
 
diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index d61758f..51b9b16 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -83,7 +83,7 @@ typedef enum {
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 4)
 #define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(8, 0)
-#define ABI_XINPUT_VERSION	SET_ABI_VERSION(10, 0)
+#define ABI_XINPUT_VERSION	SET_ABI_VERSION(11, 0)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(4, 0)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 6)
 
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 356ddab..b30ebbb 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -854,7 +854,7 @@ unwind:
 }
 
 void
-DeleteInputDeviceRequest(DeviceIntPtr pDev)
+DeleteInputDeviceRequest(DeviceIntPtr pDev, int flags)
 {
     LocalDevicePtr pInfo = (LocalDevicePtr) pDev->public.devicePrivate;
     InputDriverPtr drv = NULL;
@@ -874,9 +874,9 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
     if (!isMaster && pInfo != NULL)
     {
         if(drv->UnInit)
-            drv->UnInit(drv, pInfo, 0);
+            drv->UnInit(drv, pInfo, flags);
         else
-            xf86DeleteInput(pInfo, 0);
+            xf86DeleteInput(pInfo, flags);
 
         /* devices added through HAL aren't in the config layout */
         it = xf86ConfigLayout.inputs;
@@ -1267,7 +1267,7 @@ xf86DisableDevice(DeviceIntPtr dev, Bool panic)
     } else
     {
         SendDevicePresenceEvent(dev->id, DeviceUnrecoverable);
-        DeleteInputDeviceRequest(dev);
+        DeleteInputDeviceRequest(dev, 0);
     }
 }
 
diff --git a/hw/xquartz/darwinXinput.c b/hw/xquartz/darwinXinput.c
index 90e440e..59ca627 100644
--- a/hw/xquartz/darwinXinput.c
+++ b/hw/xquartz/darwinXinput.c
@@ -245,7 +245,7 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
  *
  */
 void
-DeleteInputDeviceRequest(DeviceIntPtr dev)
+DeleteInputDeviceRequest(DeviceIntPtr dev, int flags)
 {
   DEBUG_LOG("DeleteInputDeviceRequest(%p)\n", dev);
 }
diff --git a/include/input.h b/include/input.h
index c68a284..5426c44 100644
--- a/include/input.h
+++ b/include/input.h
@@ -62,6 +62,9 @@ SOFTWARE.
 #define DEVICE_OFF	2
 #define DEVICE_CLOSE	3
 
+/* DeleteInputDeviceRequest flags */
+#define DEVICE_REMOVE_ALL    (1 << 0) /* all devices will be removed */
+
 #define POINTER_RELATIVE (1 << 1)
 #define POINTER_ABSOLUTE (1 << 2)
 #define POINTER_ACCELERATE (1 << 3)
@@ -536,7 +539,8 @@ extern _X_EXPORT int NewInputDeviceRequest(
     InputAttributes *attrs,
     DeviceIntPtr *dev);
 extern  _X_EXPORT void DeleteInputDeviceRequest(
-    DeviceIntPtr dev);
+    DeviceIntPtr dev,
+    int flags);
 
 extern _X_EXPORT void DDXRingBell(
     int volume,
commit c2d0b3b437b7ce6ce975f2ead4d8bb8295ef0ddc
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue May 25 17:15:32 2010 +1000

    xfree86: store the InputAttributes in the input device.
    
    InputAttributes largely decide which configuration values get merged from
    the xorg.conf.d snippets. While they are available in the config backend,
    they are not available for any other callers of NewInputDeviceRequest().
    
    Drivers implementing driver-side hotplugging do not have access to these
    attributes and cannot have xorg.conf.d snippets specific to dependent
    devices. For example, the following case cannot work right now:
    
    Section "InputClass"
            MatchProduct "Wacom"
            Option "PressCurve" "0 0 100 100"
            ...
    EndSection
    
    Section "InputClass"
            MatchProduct "Wacom"
            MatchProduct "eraser"
            Option "PressCurve" "10 10 50 50"
            ...
    EndSection
    
    The second section is not triggered, as the wacom driver cannot supply the
    InputAttributes to NewInputDeviceRequest().
    
    Add the attributes to the IDevRec and merge them into the InputInfoRec to
    make them accessible in the driver. This changes the ABI for input drivers.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index bde80ea..d4b9351 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -330,6 +330,8 @@ xf86DeleteInput(InputInfoPtr pInp, int flags)
     if (pInp->private)
 	free(pInp->private);
 
+    FreeInputAttributes(pInp->attrs);
+
     /* Remove the entry from the list. */
     if (pInp == xf86InputDevs)
 	xf86InputDevs = pInp->next;
diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c
index 8be893c..61d0dcc 100644
--- a/hw/xfree86/common/xf86Option.c
+++ b/hw/xfree86/common/xf86Option.c
@@ -164,6 +164,10 @@ xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts,
 	else
 	    pInfo->options = tmp;
     }
+
+    if (pInfo->conf_idev && pInfo->conf_idev->attrs) {
+        pInfo->attrs = pInfo->conf_idev->attrs;
+    }
 }
 
 /* Created for new XInput stuff -- essentially extensions to the parser	*/
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 2e25482..356ddab 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -622,7 +622,6 @@ MergeInputClasses(IDevPtr idev, InputAttributes *attrs)
         mergedopts = xf86ReplaceStrOption(mergedopts, "driver", idev->driver);
     }
     idev->commonOptions = xf86optionListMerge(idev->commonOptions, mergedopts);
-
     return Success;
 }
 
@@ -822,6 +821,8 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
         rval = MergeInputClasses(idev, attrs);
         if (rval != Success)
             goto unwind;
+
+        idev->attrs = DuplicateInputAttributes(attrs);
     }
 
     if (!idev->driver || !idev->identifier) {
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index aa9e9d5..20a3f1b 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -148,6 +148,7 @@ typedef struct _LocalDeviceRec {
     pointer		    module;
     pointer		    options;
     unsigned int            history_size;
+    InputAttributes         *attrs;
 } LocalDeviceRec, *LocalDevicePtr, InputInfoRec, *InputInfoPtr;
 
 typedef struct _DeviceAssocRec 
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index 22f0261..c9b261d 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -406,6 +406,7 @@ typedef struct {
    char *			driver;
    pointer		 	commonOptions;
    pointer			extraOptions;
+   InputAttributes              *attrs;
 } IDevRec, *IDevPtr;
 
 typedef struct {
commit 86303a338ad563d0b986a3c052104301c310c4ac
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue May 25 17:12:34 2010 +1000

    dix: add helper functions to duplicate and free InputAttributes.
    
    No special memory handling is used to give drivers the maximum flexibility
    with the data. Drivers should be able to call realloc on the product string
    if needed and perform similar operations.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/dix/inpututils.c b/dix/inpututils.c
index 8e75372..df2ace0 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -331,3 +331,82 @@ int generate_modkeymap(ClientPtr client, DeviceIntPtr dev,
 
     return Success;
 }
+
+/**
+ * Duplicate the InputAttributes in the most obvious way.
+ * No special memory handling is used to give drivers the maximum
+ * flexibility with the data. Drivers should be able to call realloc on the
+ * product string if needed and perform similar operations.
+ */
+InputAttributes*
+DuplicateInputAttributes(InputAttributes *attrs)
+{
+    InputAttributes *new_attr;
+    int ntags = 0;
+    char **tags, **new_tags;
+
+    if (!attrs)
+        return NULL;
+
+    if (!(new_attr = calloc(1, sizeof(InputAttributes))))
+        goto unwind;
+
+    if (attrs->product && !(new_attr->product = strdup(attrs->product)))
+        goto unwind;
+    if (attrs->vendor && !(new_attr->vendor = strdup(attrs->vendor)))
+        goto unwind;
+    if (attrs->device && !(new_attr->device = strdup(attrs->device)))
+        goto unwind;
+
+    new_attr->flags = attrs->flags;
+
+    if ((tags = attrs->tags))
+    {
+        while(*tags++)
+            ntags++;
+
+        new_attr->tags = calloc(ntags + 1, sizeof(char*));
+        if (!new_attr->tags)
+            goto unwind;
+
+        tags = attrs->tags;
+        new_tags = new_attr->tags;
+
+        while(*tags)
+        {
+            *new_tags = strdup(*tags);
+            if (!*new_tags)
+                goto unwind;
+
+            tags++;
+            new_tags++;
+        }
+    }
+
+    return new_attr;
+
+unwind:
+    FreeInputAttributes(new_attr);
+    return NULL;
+}
+
+void
+FreeInputAttributes(InputAttributes *attrs)
+{
+    char **tags;
+
+    if (!attrs)
+        return;
+
+    free(attrs->product);
+    free(attrs->vendor);
+    free(attrs->device);
+
+    if ((tags = attrs->tags))
+        while(*tags)
+            free(*tags++);
+
+    free(attrs->tags);
+    free(attrs);
+}
+
diff --git a/include/input.h b/include/input.h
index 63f981e..c68a284 100644
--- a/include/input.h
+++ b/include/input.h
@@ -518,6 +518,8 @@ extern int AllocXTestDevice(ClientPtr client,
 extern BOOL IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master);
 extern DeviceIntPtr GetXTestDevice(DeviceIntPtr master);
 extern void SendDevicePresenceEvent(int deviceid, int type);
+extern _X_EXPORT InputAttributes *DuplicateInputAttributes(InputAttributes *attrs);
+extern _X_EXPORT void FreeInputAttributes(InputAttributes *attrs);
 
 /* misc event helpers */
 extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event);
diff --git a/test/input.c b/test/input.c
index 63d1a18..8a54af9 100644
--- a/test/input.c
+++ b/test/input.c
@@ -771,11 +771,112 @@ static void xi_unregister_handlers(void)
 
 }
 
+static void cmp_attr_fields(InputAttributes *attr1,
+                            InputAttributes *attr2)
+{
+    char **tags1, **tags2;
+
+    g_assert(attr1 && attr2);
+    g_assert(attr1 != attr2);
+    g_assert(attr1->flags == attr2->flags);
+
+    if (attr1->product != NULL)
+    {
+        g_assert(attr1->product != attr2->product);
+        g_assert(strcmp(attr1->product, attr2->product) == 0);
+    } else
+        g_assert(attr2->product == NULL);
+
+    if (attr1->vendor != NULL)
+    {
+        g_assert(attr1->vendor != attr2->vendor);
+        g_assert(strcmp(attr1->vendor, attr2->vendor) == 0);
+    } else
+        g_assert(attr2->vendor == NULL);
+
+    if (attr1->device != NULL)
+    {
+        g_assert(attr1->device != attr2->device);
+        g_assert(strcmp(attr1->device, attr2->device) == 0);
+    } else
+        g_assert(attr2->device == NULL);
+
+    tags1 = attr1->tags;
+    tags2 = attr2->tags;
+    if (!tags1)
+    {
+        g_assert(!tags2);
+        return;
+    }
+
+    /* check for identical content, but duplicated */
+    while (*tags1)
+    {
+        g_assert(*tags1 != *tags2);
+        g_assert(strcmp(*tags1, *tags2) == 0);
+        tags1++;
+        tags2++;
+    }
+
+    g_assert(!*tags2);
+
+    /* check for not sharing memory */
+    tags1 = attr1->tags;
+    while (*tags1)
+    {
+        tags2 = attr2->tags;
+        while (*tags2)
+            g_assert(*tags1 != *tags2++);
+
+        tags1++;
+    }
+}
+
+static void dix_input_attributes(void)
+{
+    InputAttributes orig = {0};
+    InputAttributes *new;
+    char *tags[4] = {"tag1", "tag2", "tag2", NULL};
+
+    new = DuplicateInputAttributes(NULL);
+    g_assert(!new);
+
+    new = DuplicateInputAttributes(&orig);
+    g_assert(memcpy(&orig, new, sizeof(InputAttributes)));
+
+    orig.product = "product name";
+    new = DuplicateInputAttributes(&orig);
+    cmp_attr_fields(&orig, new);
+    FreeInputAttributes(new);
+
+    orig.vendor = "vendor name";
+    new = DuplicateInputAttributes(&orig);
+    cmp_attr_fields(&orig, new);
+    FreeInputAttributes(new);
+
+    orig.device = "device path";
+    new = DuplicateInputAttributes(&orig);
+    cmp_attr_fields(&orig, new);
+    FreeInputAttributes(new);
+
+    orig.flags = 0xF0;
+    new = DuplicateInputAttributes(&orig);
+    cmp_attr_fields(&orig, new);
+    FreeInputAttributes(new);
+
+    orig.tags = tags;
+    new = DuplicateInputAttributes(&orig);
+    cmp_attr_fields(&orig, new);
+    FreeInputAttributes(new);
+}
+
+
 int main(int argc, char** argv)
 {
     g_test_init(&argc, &argv,NULL);
     g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id=");
 
+    g_test_add_func("/dix/input/attributes", dix_input_attributes);
     g_test_add_func("/dix/input/init-valuators", dix_init_valuators);
     g_test_add_func("/dix/input/event-core-conversion", dix_event_to_core_conversion);
     g_test_add_func("/dix/input/check-grab-values", dix_check_grab_values);
@@ -784,5 +885,6 @@ int main(int argc, char** argv)
     g_test_add_func("/include/byte_padding_macros", include_byte_padding_macros);
     g_test_add_func("/Xi/xiproperty/register-unregister", xi_unregister_handlers);
 
+
     return g_test_run();
 }
commit bf78e11839f8278020b604672ff7c3d194232be9
Author: Jamey Sharp <jamey at minilop.net>
Date:   Mon May 24 09:15:32 2010 -0700

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

diff --git a/mi/midispcur.c b/mi/midispcur.c
index 16495e4..f2b2229 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -141,6 +141,7 @@ miDCRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
 }
 
 #ifdef ARGB_CURSOR
+#define EnsurePicture(picture,draw,win) (picture || miDCMakePicture(&picture,draw,win))
 
 static VisualPtr
 miDCGetWindowVisual (WindowPtr pWin)
@@ -413,6 +414,8 @@ miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
 #ifdef ARGB_CURSOR
     if (pPriv->pPicture)
     {
+	if (!EnsurePicture(pBuffer->pRootPicture, &pWin->drawable, pWin))
+	    return FALSE;
 	CompositePicture (PictOpOver,
 			  pPriv->pPicture,
 			  NULL,
@@ -695,9 +698,8 @@ miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
 #ifdef ARGB_CURSOR
     if (pPriv->pPicture)
     {
-	if (!pBuffer->pTempPicture)
-            miDCMakePicture(&pBuffer->pTempPicture, &pTemp->drawable, pWin);
-
+	if (!EnsurePicture(pBuffer->pTempPicture, &pTemp->drawable, pWin))
+	    return FALSE;
 	CompositePicture (PictOpOver,
 			  pPriv->pPicture,
 			  NULL,
@@ -781,10 +783,7 @@ miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
             goto failure;
 
 #ifdef ARGB_CURSOR
-        miDCMakePicture(&pBuffer->pRootPicture, &pWin->drawable, pWin);
-        if (!pBuffer->pRootPicture)
-            goto failure;
-
+        pBuffer->pRootPicture = NULL;
         pBuffer->pTempPicture = NULL;
 #endif
 
commit bf9b64eefbadbf299d3b841c1890bfcaef5aab1b
Author: Jamey Sharp <jamey at minilop.net>
Date:   Mon May 24 09:14:27 2010 -0700

    xnest: Don't ignore errors from DeviceCursorInitialize.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>

diff --git a/hw/xnest/Cursor.c b/hw/xnest/Cursor.c
index 9ae2102..5491ee9 100644
--- a/hw/xnest/Cursor.c
+++ b/hw/xnest/Cursor.c
@@ -167,8 +167,7 @@ xnestDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
     pScreenPriv = (xnestCursorFuncPtr)
             dixLookupPrivate(&pScreen->devPrivates, xnestCursorScreenKey);
 
-    pScreenPriv->spriteFuncs->DeviceCursorInitialize(pDev, pScreen);
-    return TRUE;
+    return pScreenPriv->spriteFuncs->DeviceCursorInitialize(pDev, pScreen);
 }
 
 void
commit b11465a6ecdc2b8373e6fc8af427edc4602bcaa1
Merge: 7c085ae... 0abf065...
Author: Keith Packard <keithp at keithp.com>
Date:   Mon May 24 22:18:31 2010 -0700

    Merge remote branch 'vignatti/bus-cleanup-take2'

commit 7c085aebfedeb621a6fbeb3f09f4fcc640452044
Author: Jamey Sharp <jamey at minilop.net>
Date:   Mon May 24 11:45:42 2010 -0700

    xfixes: Remove the invisible cursor sprite, using NullCursor instead.
    
    Oliver McFadden reports that the invisible cursor sprite caused damage
    events and thus unnecessary redrawing, so removing it improves
    performance when using software cursor sprites, especially on those
    devices where you do not want a visible cursor: touchscreen tablets,
    embedded devices, etc.
    
    For the xfree86 DDX, if hardware cursors are used, the driver is
    required to provide a HideCursor function, which will be called instead
    of trying to set a null cursor. I think software cursors are already
    safe. The other DDXes also look safe.
    
    As far as I can tell, there's no reason to realize a null cursor. I
    think everything that handles null cursors doesn't rely on any setup in
    RealizeCursor, and treats them as empty cursors.
    
    Xnest assumes that if a cursor is created, it will be realized before it
    is freed, which didn't happen if the invisible cursor was never used in
    a server generation. So this fixes a segfault in Xnest as well.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Cc: Oliver McFadden <oliver.mcfadden at nokia.com>
    Signed-off-by: Oliver McFadden <oliver.mcfadden at nokia.com>
    Tested-by: Oliver McFadden <oliver.mcfadden at nokia.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 52bdb27..d3a207d 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -58,7 +58,6 @@ static RESTYPE		CursorClientType;
 static RESTYPE		CursorHideCountType;
 static RESTYPE		CursorWindowType;
 static CursorPtr	CursorCurrent[MAXDEVICES];
-static CursorPtr        pInvisibleCursor = NULL;
 
 static int CursorScreenPrivateKeyIndex;
 static DevPrivateKey CursorScreenPrivateKey = &CursorScreenPrivateKeyIndex;
@@ -148,8 +147,7 @@ CursorDisplayCursor (DeviceIntPtr pDev,
 	CursorVisible = EnableCursor;
 
     if (cs->pCursorHideCounts != NULL || !CursorVisible) {
-        ret = ((*pScreen->RealizeCursor)(pDev, pScreen, pInvisibleCursor) &&
-	       (*pScreen->DisplayCursor) (pDev, pScreen, pInvisibleCursor));
+	ret = (*pScreen->DisplayCursor) (pDev, pScreen, NullCursor);
     } else {
 	ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
     }
@@ -1031,37 +1029,6 @@ CursorFreeWindow (pointer data, XID id)
     return 1;
 }
 
-static CursorPtr
-createInvisibleCursor (void)
-{
-    CursorPtr pCursor;
-    unsigned char *psrcbits, *pmaskbits;
-    CursorMetricRec cm;
-
-    psrcbits = (unsigned char *) calloc(4, 1);
-    pmaskbits = (unsigned char *) calloc(4, 1);
-    if (psrcbits == NULL || pmaskbits == NULL) {
-	return NULL;
-    }
-
-    cm.width = 1;
-    cm.height = 1;
-    cm.xhot = 0;
-    cm.yhot = 0;
-
-    if (AllocARGBCursor(psrcbits, pmaskbits,
-			NULL, &cm,
-			0, 0, 0,
-			0, 0, 0,
-			&pCursor, serverClient, (XID)0) != Success)
-	return NullCursor;
-
-    if (!AddResource(FakeClientID(0), RT_CURSOR, (pointer) pCursor))
-	return NullCursor;
-
-    return pCursor;
-}
-
 Bool
 XFixesCursorInit (void)
 {
@@ -1090,10 +1057,6 @@ XFixesCursorInit (void)
     CursorWindowType = CreateNewResourceType(CursorFreeWindow,
 					     "XFixesCursorWindow");
 
-    pInvisibleCursor = createInvisibleCursor();
-    if (pInvisibleCursor == NULL)
-	return BadAlloc;
-
     return CursorClientType && CursorHideCountType && CursorWindowType;
 }
 
commit 0abf065e38c4c48917054eb3e39e12bd20e6e8ec
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Thu May 20 19:24:47 2010 +0300

    xfree86: move all pci code from auto configurator into a meaningful location
    
    This patch creates the private xf86PciMatchDriver hook, which goes inside pci
    code to match the drivers found in the system.
    
    Now there's no direct references to PCI inside xf86AutoConfig.c anymore.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Alex Deucher <alexdeucher at gmail.com>

diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index 896f695..8947a4f 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -39,10 +39,10 @@
 #include "xf86Config.h"
 #include "xf86Priv.h"
 #include "xf86_OSlib.h"
+#include "xf86pciBus.h"
 #ifdef __sparc__
 # include "xf86sbusBus.h"
 #endif
-#include "dirent.h"
 
 #ifdef sun
 # include <sys/visual_io.h>
@@ -140,102 +140,6 @@ AppendToConfig(const char *s)
     AppendToList(s, &builtinConfig, &builtinLines);
 }
 
-static int
-videoPtrToDriverList(struct pci_device *dev,
-		     char *returnList[], int returnListMax)
-{
-    int i;
-    /* Add more entries here if we ever return more than 4 drivers for
-       any device */
-    char *driverList[5] = { NULL, NULL, NULL, NULL, NULL };
-
-    switch (dev->vendor_id)
-    {
-	/* AMD Geode LX */
-	case 0x1022:
-	    if (dev->device_id == 0x2081)
-		driverList[0] = "geode";
-	    break;
-	/* older Geode products acquired by AMD still carry an NSC vendor_id */
-	case 0x100b:
-	    if (dev->device_id == 0x0030) {
-		/* NSC Geode GX2 specifically */
-		driverList[0] = "geode";
-		/* GX2 support started its life in the NSC tree and was later 
-		   forked by AMD for GEODE so we keep it as a backup */
-		driverList[1] = "nsc";
-	    } else 
-		/* other NSC variant e.g. 0x0104 (SC1400), 0x0504 (SCx200) */
-		driverList[0] = "nsc";
-	    break;
-	/* Cyrix Geode GX1 */
-	case 0x1078:
-	    if (dev->device_id == 0x0104)
-		driverList[0] = "cyrix";
-	    break;
-	case 0x1142:		    driverList[0] = "apm"; break;
-	case 0xedd8:		    driverList[0] = "ark"; break;
-	case 0x1a03:		    driverList[0] = "ast"; break;
-	case 0x1002:		    driverList[0] = "ati"; break;
-	case 0x102c:		    driverList[0] = "chips"; break;
-	case 0x1013:		    driverList[0] = "cirrus"; break;
-	case 0x3d3d:		    driverList[0] = "glint"; break;
-	case 0x105d:		    driverList[0] = "i128"; break;
-	case 0x8086:
-	    if ((dev->device_id == 0x00d1) || (dev->device_id == 0x7800)) {
-		driverList[0] = "i740";
-            } else if (dev->device_id == 0x8108) {
-                break; /* "hooray" for poulsbo */
-	    } else {
-		driverList[0] = "intel";
-	    }
-	    break;
-	case 0x102b:		    driverList[0] = "mga";	break;
-	case 0x10c8:		    driverList[0] = "neomagic"; break;
-	case 0x10de: case 0x12d2:   driverList[0] = "nv";	break;
-	case 0x1106:		    driverList[0] = "openchrome"; break;
-        case 0x1b36:		    driverList[0] = "qxl"; break;
-	case 0x1163:		    driverList[0] = "rendition"; break;
-	case 0x5333:
-	    switch (dev->device_id)
-	    {
-		case 0x88d0: case 0x88d1: case 0x88f0: case 0x8811:
-		case 0x8812: case 0x8814: case 0x8901:
-		    driverList[0] = "s3"; break;
-		case 0x5631: case 0x883d: case 0x8a01: case 0x8a10:
-		case 0x8c01: case 0x8c03: case 0x8904: case 0x8a13:
-		    driverList[0] = "s3virge"; break;
-		default:
-		    driverList[0] = "savage"; break;
-	    }
-	    break;
-	case 0x1039:		    driverList[0] = "sis";	break;
-	case 0x126f:		    driverList[0] = "siliconmotion"; break;
-	case 0x121a:
-	    if (dev->device_id < 0x0003)
-	        driverList[0] = "voodoo";
-	    else
-	        driverList[0] = "tdfx";
-	    break;
-	case 0x1011:		    driverList[0] = "tga"; break;
-	case 0x1023:		    driverList[0] = "trident"; break;
-	case 0x100c:		    driverList[0] = "tseng"; break;
-	case 0x80ee:		    driverList[0] = "vboxvideo"; break;
-	case 0x15ad:		    driverList[0] = "vmware"; break;
-	case 0x18ca:
-	    if (dev->device_id == 0x47)
-		driverList[0] = "xgixp";
-	    else
-		driverList[0] = "xgi";
-	    break;
-	default: break;
-    }
-    for (i = 0; (i < returnListMax) && (driverList[i] != NULL); i++) {
-	returnList[i] = xnfstrdup(driverList[i]);
-    }
-    return i;	/* Number of entries added */
-}
-
 Bool
 xf86AutoConfig(void)
 {
@@ -285,132 +189,9 @@ xf86AutoConfig(void)
     return (ret == CONFIG_OK);
 }
 
-static int
-xchomp(char *line)
-{
-    size_t len = 0;
-
-    if (!line) {
-        return 1;
-    }
-
-    len = strlen(line);
-    if (line[len - 1] == '\n' && len > 0) {
-        line[len - 1] = '\0';
-    }
-    return 0;
-}
-
-#ifdef __linux__
-/* This function is used to provide a workaround for binary drivers that
- * don't export their PCI ID's properly. If distros don't end up using this
- * feature it can and should be removed because the symbol-based resolution
- * scheme should be the primary one */
-static void
-matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip)
-{
-    DIR *idsdir;
-    FILE *fp;
-    struct dirent *direntry;
-    char *line = NULL;
-    size_t len;
-    ssize_t read;
-    char path_name[256], vendor_str[5], chip_str[5];
-    uint16_t vendor, chip;
-    int i, j;
-
-    idsdir = opendir(PCI_TXT_IDS_PATH);
-    if (!idsdir)
-        return;
-
-    xf86Msg(X_INFO, "Scanning %s directory for additional PCI ID's supported by the drivers\n", PCI_TXT_IDS_PATH);
-    direntry = readdir(idsdir);
-    /* Read the directory */
-    while (direntry) {
-        if (direntry->d_name[0] == '.') {
-            direntry = readdir(idsdir);
-            continue;
-        }
-        len = strlen(direntry->d_name);
-        /* A tiny bit of sanity checking. We should probably do better */
-        if (strncmp(&(direntry->d_name[len-4]), ".ids", 4) == 0) {
-            /* We need the full path name to open the file */
-            strncpy(path_name, PCI_TXT_IDS_PATH, 256);
-            strncat(path_name, "/", 1);
-            strncat(path_name, direntry->d_name, (256 - strlen(path_name) - 1));
-            fp = fopen(path_name, "r");
-            if (fp == NULL) {
-                xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n", path_name);
-                goto end;
-            }
-            /* Read the file */
-#ifdef __GLIBC__
-            while ((read = getline(&line, &len, fp)) != -1) {
-#else
-            while ((line = fgetln(fp, &len)) != (char *)NULL) {
-#endif /* __GLIBC __ */
-                xchomp(line);
-                if (isdigit(line[0])) {
-                    strncpy(vendor_str, line, 4);
-                    vendor_str[4] = '\0';
-                    vendor = (int)strtol(vendor_str, NULL, 16);
-                    if ((strlen(&line[4])) == 0) {
-                        chip_str[0] = '\0';
-                        chip = -1;
-                    } else {
-                        /* Handle trailing whitespace */
-                        if (isspace(line[4])) {
-                            chip_str[0] = '\0';
-                            chip = -1;
-                        } else {
-                            /* Ok, it's a real ID */
-                            strncpy(chip_str, &line[4], 4);
-                            chip_str[4] = '\0';
-                            chip = (int)strtol(chip_str, NULL, 16);
-                        }
-                    }
-                    if (vendor == match_vendor && chip == match_chip ) {
-                        i = 0;
-                        while (matches[i]) {
-                            i++;
-                        }
-                        matches[i] = (char*)malloc(sizeof(char) * strlen(direntry->d_name) -  3);
-                        if (!matches[i]) {
-                            xf86Msg(X_ERROR, "Could not allocate space for the module name. Exiting.\n");
-                            goto end;
-                        }
-                        /* hack off the .ids suffix. This should guard
-                         * against other problems, but it will end up
-                         * taking off anything after the first '.' */
-                        for (j = 0; j < (strlen(direntry->d_name) - 3) ; j++) {
-                            if (direntry->d_name[j] == '.') {
-                                matches[i][j] = '\0';
-                                break;
-                            } else {
-                                matches[i][j] = direntry->d_name[j];
-                            }
-                        }
-                        xf86Msg(X_INFO, "Matched %s from file name %s\n", matches[i], direntry->d_name);
-                    }
-                } else {
-                    /* TODO Handle driver overrides here */
-                }
-            }
-            fclose(fp);
-        }
-        direntry = readdir(idsdir);
-    }
- end:
-    free(line);
-    closedir(idsdir);
-}
-#endif /* __linux__ */
-
 static void
 listPossibleVideoDrivers(char *matches[], int nmatches)
 {
-    struct pci_device * info = NULL;
-    struct pci_device_iterator *iter;
     int i;
     
     for (i = 0 ; i < nmatches ; i++) {
@@ -476,32 +257,7 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
     }
 #endif
 
-    /* Find the primary device, and get some information about it. */
-    iter = pci_slot_match_iterator_create(NULL);
-    while ((info = pci_device_next(iter)) != NULL) {
-	if (xf86IsPrimaryPci(info)) {
-	    break;
-	}
-    }
-
-    pci_iterator_destroy(iter);
-
-    if (!info) {
-	ErrorF("Primary device is not PCI\n");
-    }
-#ifdef __linux__
-    else {
-	matchDriverFromFiles(matches, info->vendor_id, info->device_id);
-    }
-#endif /* __linux__ */
-
-    for (i = 0; (i < nmatches) && (matches[i]); i++) {
-	/* find end of matches list */
-    }
-
-    if ((info != NULL) && (i < nmatches)) {
-	i += videoPtrToDriverList(info, &(matches[i]), nmatches - i);
-    }
+    xf86PciMatchDriver(matches, nmatches);
 
     /* Fallback to platform default hardware */
     if (i < (nmatches - 1)) {
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index c20abfa..085be01 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -41,6 +41,7 @@
 #include "Pci.h"
 #include "xf86.h"
 #include "xf86Priv.h"
+#include "dirent.h" /* DIR, FILE type definitions */
 
 /* Bus-specific headers */
 #include "xf86Bus.h"
@@ -1075,3 +1076,254 @@ xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
 
     return TRUE;
 }
+
+static int
+videoPtrToDriverList(struct pci_device *dev,
+		     char *returnList[], int returnListMax)
+{
+    int i;
+    /* Add more entries here if we ever return more than 4 drivers for
+       any device */
+    char *driverList[5] = { NULL, NULL, NULL, NULL, NULL };
+
+    switch (dev->vendor_id)
+    {
+	/* AMD Geode LX */
+	case 0x1022:
+	    if (dev->device_id == 0x2081)
+		driverList[0] = "geode";
+	    break;
+	/* older Geode products acquired by AMD still carry an NSC vendor_id */
+	case 0x100b:
+	    if (dev->device_id == 0x0030) {
+		/* NSC Geode GX2 specifically */
+		driverList[0] = "geode";
+		/* GX2 support started its life in the NSC tree and was later
+		   forked by AMD for GEODE so we keep it as a backup */
+		driverList[1] = "nsc";
+	    } else
+		/* other NSC variant e.g. 0x0104 (SC1400), 0x0504 (SCx200) */
+		driverList[0] = "nsc";
+	    break;
+	/* Cyrix Geode GX1 */
+	case 0x1078:
+	    if (dev->device_id == 0x0104)
+		driverList[0] = "cyrix";
+	    break;
+	case 0x1142:		    driverList[0] = "apm"; break;
+	case 0xedd8:		    driverList[0] = "ark"; break;
+	case 0x1a03:		    driverList[0] = "ast"; break;
+	case 0x1002:		    driverList[0] = "ati"; break;
+	case 0x102c:		    driverList[0] = "chips"; break;
+	case 0x1013:		    driverList[0] = "cirrus"; break;
+	case 0x3d3d:		    driverList[0] = "glint"; break;
+	case 0x105d:		    driverList[0] = "i128"; break;
+	case 0x8086:
+	    if ((dev->device_id == 0x00d1) || (dev->device_id == 0x7800)) {
+		driverList[0] = "i740";
+            } else if (dev->device_id == 0x8108) {
+                break; /* "hooray" for poulsbo */
+	    } else {
+		driverList[0] = "intel";
+	    }
+	    break;
+	case 0x102b:		    driverList[0] = "mga";	break;
+	case 0x10c8:		    driverList[0] = "neomagic"; break;
+	case 0x10de: case 0x12d2:   driverList[0] = "nv";	break;
+	case 0x1106:		    driverList[0] = "openchrome"; break;
+        case 0x1b36:		    driverList[0] = "qxl"; break;
+	case 0x1163:		    driverList[0] = "rendition"; break;
+	case 0x5333:
+	    switch (dev->device_id)
+	    {
+		case 0x88d0: case 0x88d1: case 0x88f0: case 0x8811:
+		case 0x8812: case 0x8814: case 0x8901:
+		    driverList[0] = "s3"; break;
+		case 0x5631: case 0x883d: case 0x8a01: case 0x8a10:
+		case 0x8c01: case 0x8c03: case 0x8904: case 0x8a13:
+		    driverList[0] = "s3virge"; break;
+		default:
+		    driverList[0] = "savage"; break;
+	    }
+	    break;
+	case 0x1039:		    driverList[0] = "sis";	break;
+	case 0x126f:		    driverList[0] = "siliconmotion"; break;
+	case 0x121a:
+	    if (dev->device_id < 0x0003)
+	        driverList[0] = "voodoo";
+	    else
+	        driverList[0] = "tdfx";
+	    break;
+	case 0x1011:		    driverList[0] = "tga"; break;
+	case 0x1023:		    driverList[0] = "trident"; break;
+	case 0x100c:		    driverList[0] = "tseng"; break;
+	case 0x80ee:		    driverList[0] = "vboxvideo"; break;
+	case 0x15ad:		    driverList[0] = "vmware"; break;
+	case 0x18ca:
+	    if (dev->device_id == 0x47)
+		driverList[0] = "xgixp";
+	    else
+		driverList[0] = "xgi";
+	    break;
+	default: break;
+    }
+    for (i = 0; (i < returnListMax) && (driverList[i] != NULL); i++) {
+	returnList[i] = xnfstrdup(driverList[i]);
+    }
+    return i;	/* Number of entries added */
+}
+
+static int
+xchomp(char *line)
+{
+    size_t len = 0;
+
+    if (!line) {
+        return 1;
+    }
+
+    len = strlen(line);
+    if (line[len - 1] == '\n' && len > 0) {
+        line[len - 1] = '\0';
+    }
+    return 0;
+}
+
+#ifdef __linux__
+/* This function is used to provide a workaround for binary drivers that
+ * don't export their PCI ID's properly. If distros don't end up using this
+ * feature it can and should be removed because the symbol-based resolution
+ * scheme should be the primary one */
+static void
+matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip)
+{
+    DIR *idsdir;
+    FILE *fp;
+    struct dirent *direntry;
+    char *line = NULL;
+    size_t len;
+    ssize_t read;
+    char path_name[256], vendor_str[5], chip_str[5];
+    uint16_t vendor, chip;
+    int i, j;
+
+    idsdir = opendir(PCI_TXT_IDS_PATH);
+    if (!idsdir)
+        return;
+
+    xf86Msg(X_INFO, "Scanning %s directory for additional PCI ID's supported by the drivers\n", PCI_TXT_IDS_PATH);
+    direntry = readdir(idsdir);
+    /* Read the directory */
+    while (direntry) {
+        if (direntry->d_name[0] == '.') {
+            direntry = readdir(idsdir);
+            continue;
+        }
+        len = strlen(direntry->d_name);
+        /* A tiny bit of sanity checking. We should probably do better */
+        if (strncmp(&(direntry->d_name[len-4]), ".ids", 4) == 0) {
+            /* We need the full path name to open the file */
+            strncpy(path_name, PCI_TXT_IDS_PATH, 256);
+            strncat(path_name, "/", 1);
+            strncat(path_name, direntry->d_name, (256 - strlen(path_name) - 1));
+            fp = fopen(path_name, "r");
+            if (fp == NULL) {
+                xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n", path_name);
+                goto end;
+            }
+            /* Read the file */
+#ifdef __GLIBC__
+            while ((read = getline(&line, &len, fp)) != -1) {
+#else
+            while ((line = fgetln(fp, &len)) != (char *)NULL) {
+#endif /* __GLIBC __ */
+                xchomp(line);
+                if (isdigit(line[0])) {
+                    strncpy(vendor_str, line, 4);
+                    vendor_str[4] = '\0';
+                    vendor = (int)strtol(vendor_str, NULL, 16);
+                    if ((strlen(&line[4])) == 0) {
+                        chip_str[0] = '\0';
+                        chip = -1;
+                    } else {
+                        /* Handle trailing whitespace */
+                        if (isspace(line[4])) {
+                            chip_str[0] = '\0';
+                            chip = -1;
+                        } else {
+                            /* Ok, it's a real ID */
+                            strncpy(chip_str, &line[4], 4);
+                            chip_str[4] = '\0';
+                            chip = (int)strtol(chip_str, NULL, 16);
+                        }
+                    }
+                    if (vendor == match_vendor && chip == match_chip ) {
+                        i = 0;
+                        while (matches[i]) {
+                            i++;
+                        }
+                        matches[i] = (char*)malloc(sizeof(char) * strlen(direntry->d_name) -  3);
+                        if (!matches[i]) {
+                            xf86Msg(X_ERROR, "Could not allocate space for the module name. Exiting.\n");
+                            goto end;
+                        }
+                        /* hack off the .ids suffix. This should guard
+                         * against other problems, but it will end up
+                         * taking off anything after the first '.' */
+                        for (j = 0; j < (strlen(direntry->d_name) - 3) ; j++) {
+                            if (direntry->d_name[j] == '.') {
+                                matches[i][j] = '\0';
+                                break;
+                            } else {
+                                matches[i][j] = direntry->d_name[j];
+                            }
+                        }
+                        xf86Msg(X_INFO, "Matched %s from file name %s\n", matches[i], direntry->d_name);
+                    }
+                } else {
+                    /* TODO Handle driver overrides here */
+                }
+            }
+            fclose(fp);
+        }
+        direntry = readdir(idsdir);
+    }
+ end:
+    free(line);
+    closedir(idsdir);
+}
+#endif /* __linux__ */
+
+void
+xf86PciMatchDriver(char* matches[], int nmatches) {
+    int i;
+    struct pci_device * info = NULL;
+    struct pci_device_iterator *iter;
+
+    /* Find the primary device, and get some information about it. */
+    iter = pci_slot_match_iterator_create(NULL);
+    while ((info = pci_device_next(iter)) != NULL) {
+	if (xf86IsPrimaryPci(info)) {
+	    break;
+	}
+    }
+
+    pci_iterator_destroy(iter);
+
+    if (!info) {
+	ErrorF("Primary device is not PCI\n");
+    }
+#ifdef __linux__
+    else {
+	matchDriverFromFiles(matches, info->vendor_id, info->device_id);
+    }
+#endif /* __linux__ */
+
+    for (i = 0; (i < nmatches) && (matches[i]); i++) {
+	/* find end of matches list */
+    }
+
+    if ((info != NULL) && (i < nmatches)) {
+	i += videoPtrToDriverList(info, &(matches[i]), nmatches - i);
+    }
+}
diff --git a/hw/xfree86/common/xf86pciBus.h b/hw/xfree86/common/xf86pciBus.h
index 69c005a..f84a496 100644
--- a/hw/xfree86/common/xf86pciBus.h
+++ b/hw/xfree86/common/xf86pciBus.h
@@ -37,5 +37,6 @@ void xf86PciProbe(void);
 Bool xf86PciAddMatchingDev(DriverPtr drvp);
 Bool xf86PciProbeDev(DriverPtr drvp);
 void xf86PciIsolateDevice(char *argument);
+void xf86PciMatchDriver(char* matches[], int nmatches);
 
 #endif /* _XF86_PCI_BUS_H */
commit 0ceac6f64f5ad9bc2ac4b19be2dd245ffba78b05
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Thu May 20 18:23:24 2010 +0300

    xfree86: no need to check for the configuration case when matching devices
    
    xf86MatchDevice will never be called in configuration time.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Alex Deucher <alexdeucher at gmail.com>

diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 134ca7e..bde80ea 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1440,8 +1440,6 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
     if (sectlist)
 	*sectlist = NULL;
 
-    if (xf86DoConfigure && xf86DoConfigurePass1) return 1;
-
     /*
      * This is a very important function that matches the device sections
      * as they show up in the config file with the drivers that the server
commit b0eef1101815b08da2d375af7bec2be3136cf713
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Thu May 20 18:19:14 2010 +0300

    xfree86: organize and group all pci related stuff inside xf86.h
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Alex Deucher <alexdeucher at gmail.com>

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 68c3744..d8629a8 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -41,8 +41,6 @@
 #include <dix-config.h>
 #endif
 
-#include <pciaccess.h>
-
 #include "xf86str.h"
 #include "xf86Opt.h"
 #include <X11/Xfuncproto.h>
@@ -62,7 +60,6 @@ extern _X_EXPORT DevPrivateKey xf86CreateRootWindowKey;
 extern _X_EXPORT DevPrivateKey xf86PixmapKey;
 extern _X_EXPORT ScrnInfoPtr *xf86Screens;	/* List of pointers to ScrnInfoRecs */
 extern _X_EXPORT const unsigned char byte_reversed[256];
-extern _X_EXPORT Bool pciSlotClaimed;
 extern _X_EXPORT Bool fbSlotClaimed;
 #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
 extern _X_EXPORT Bool sbusSlotClaimed;
@@ -91,21 +88,39 @@ extern _X_EXPORT Bool VTSwitchEnabled;	/* kbd driver */
 /* Function Prototypes */
 #ifndef _NO_XF86_PROTOTYPES
 
-/* xf86Bus.c */
+/* PCI related */
+#include <pciaccess.h>
+extern _X_EXPORT Bool pciSlotClaimed;
 
-extern _X_EXPORT Bool xf86CheckPciSlot( const struct pci_device * );
-extern _X_EXPORT int xf86ClaimPciSlot( struct pci_device *, DriverPtr drvp,
-		     int chipset, GDevPtr dev, Bool active);
+extern _X_EXPORT Bool xf86CheckPciSlot(const struct pci_device *);
+extern _X_EXPORT int xf86ClaimPciSlot(struct pci_device *, DriverPtr drvp,
+                                      int chipset, GDevPtr dev, Bool active);
 extern _X_EXPORT void xf86UnclaimPciSlot(struct pci_device *);
-extern _X_EXPORT Bool xf86ParsePciBusString(const char *busID, int *bus, int *device,
-			   int *func);
-extern _X_EXPORT Bool xf86ComparePciBusString(const char *busID, int bus, int device, int func);
+extern _X_EXPORT Bool xf86ParsePciBusString(const char *busID, int *bus,
+                                            int *device, int *func);
+extern _X_EXPORT Bool xf86ComparePciBusString(const char *busID, int bus,
+                                              int device, int func);
 extern _X_EXPORT void xf86FormatPciBusNumber(int busnum, char *buffer);
+extern _X_EXPORT Bool xf86IsPrimaryPci(struct pci_device * pPci);
+extern _X_EXPORT Bool xf86CheckPciMemBase(struct pci_device * pPci,
+                                          memType base);
+extern _X_EXPORT struct pci_device * xf86GetPciInfoForEntity(int entityIndex);
+extern _X_EXPORT int xf86MatchPciInstances(const char *driverName,
+        int vendorID, SymTabPtr chipsets, PciChipsets *PCIchipsets,
+        GDevPtr *devList, int numDevs, DriverPtr drvp, int **foundEntities);
+extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn,
+        int scrnFlag, int entityIndex,PciChipsets *p_chip, void *dummy,
+        EntityProc init, EntityProc enter, EntityProc leave, pointer private);
+/* Obsolete! don't use */
+extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
+        int entityIndex,PciChipsets *p_chip, void *dummy, EntityProc init,
+        EntityProc enter, EntityProc leave, pointer private);
+
+/* xf86Bus.c */
+
 extern _X_EXPORT int  xf86GetFbInfoForScreen(int scrnIndex);
 extern _X_EXPORT int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
 extern _X_EXPORT int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
-extern _X_EXPORT Bool xf86IsPrimaryPci(struct pci_device * pPci);
-/* new RAC */
 extern _X_EXPORT Bool xf86DriverHasEntities(DriverPtr drvp);
 extern _X_EXPORT void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex);
 extern _X_EXPORT void xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex,
@@ -114,10 +129,8 @@ extern _X_EXPORT int xf86GetNumEntityInstances(int entityIndex);
 extern _X_EXPORT GDevPtr xf86GetDevFromEntity(int entityIndex, int instance);
 extern _X_EXPORT void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex);
 extern _X_EXPORT EntityInfoPtr xf86GetEntityInfo(int entityIndex);
-extern _X_EXPORT struct pci_device * xf86GetPciInfoForEntity(int entityIndex);
 extern _X_EXPORT Bool xf86SetEntityFuncs(int entityIndex, EntityProc init,
 			EntityProc enter, EntityProc leave, pointer);
-extern _X_EXPORT Bool xf86CheckPciMemBase(struct pci_device * pPci, memType base);
 extern _X_EXPORT Bool xf86IsEntityPrimary(int entityIndex);
 extern _X_EXPORT void xf86EnterServerState(xf86State state);
 extern _X_EXPORT ScrnInfoPtr xf86FindScreenForEntity(int entityIndex);
@@ -223,10 +236,6 @@ extern _X_EXPORT void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from);
 extern _X_EXPORT void xf86PrintChipsets(const char *drvname, const char *drvmsg,
 		       SymTabPtr chips);
 extern _X_EXPORT int xf86MatchDevice(const char *drivername, GDevPtr **driversectlist);
-extern _X_EXPORT int xf86MatchPciInstances(const char *driverName, int vendorID,
-		      SymTabPtr chipsets, PciChipsets *PCIchipsets,
-		      GDevPtr *devList, int numDevs, DriverPtr drvp,
-		      int **foundEntities);
 extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num,
 		   Bool (*ClockFunc)(ScrnInfoPtr, int),
 		   void (*ProtectRegs)(ScrnInfoPtr, Bool),
@@ -265,23 +274,11 @@ extern _X_EXPORT void xf86SetSilkenMouse(ScreenPtr pScreen);
 extern _X_EXPORT pointer xf86FindXvOptions(int scrnIndex, int adapt_index, char *port_name,
 			  char **adaptor_name, pointer *adaptor_options);
 extern _X_EXPORT void xf86GetOS(const char **name, int *major, int *minor, int *teeny);
-extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag,
-				int entityIndex,PciChipsets *p_chip,
-				void *dummy, EntityProc init,
-				EntityProc enter, EntityProc leave,
-				pointer private);
 extern _X_EXPORT ScrnInfoPtr xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag,
 			       int entityIndex, EntityProc init,
 			       EntityProc enter, EntityProc leave,
 			       pointer private);
 
-/* Obsolete! don't use */
-extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
-                               int entityIndex,PciChipsets *p_chip,
-                               void *dummy, EntityProc init,
-                               EntityProc enter, EntityProc leave,
-                               pointer private);
-
 extern _X_EXPORT Bool xf86IsScreenPrimary(int scrnIndex);
 extern _X_EXPORT int  xf86RegisterRootWindowProperty(int ScrnIndex, Atom	property, Atom type,
 				    int format, unsigned long len,
commit 47df5a489ea69a68e753367423bfbe8830521f4e
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Thu May 20 17:39:59 2010 +0300

    xfree86: remove BUS_ISA type given we don't support anymore
    
    Should go together within commit df14682a.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Alex Deucher <alexdeucher at gmail.com>

diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index de1f1b6..22f0261 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -338,7 +338,6 @@ typedef struct _DriverRec {
 /* Tolerate prior #include <linux/input.h> */
 #if defined(linux) && defined(_INPUT_H)
 #undef BUS_NONE
-#undef BUS_ISA
 #undef BUS_PCI
 #undef BUS_SBUS
 #undef BUS_last
@@ -346,7 +345,6 @@ typedef struct _DriverRec {
 
 typedef enum {
     BUS_NONE,
-    BUS_ISA,
     BUS_PCI,
     BUS_SBUS,
     BUS_last    /* Keep last */
commit 9d000a5509e0a356ee33ad08e4dc967a2ef8cbe0
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Thu May 20 16:52:37 2010 +0300

    xfree86: remove all kind of bus and PCI dependency from the common helper file
    
    Move all PCI procedures from xf86Helper.c to a more meaningful place (namely
    xf86pciBus.c). xf86Helper.c is free of PCI code now.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Alex Deucher <alexdeucher at gmail.com>

diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 9ec5941..134ca7e 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -38,9 +38,6 @@
 #include <xorg-config.h>
 #endif
 
-#include <pciaccess.h>
-#include "Pci.h"
-
 #include <X11/X.h>
 #include "os.h"
 #include "servermd.h"
@@ -57,7 +54,6 @@
 #include "xf86Xinput.h"
 #include "xf86InPriv.h"
 #include "mivalidate.h"
-#include "xf86Bus.h"
 #include "xf86Crtc.h"
 
 /* For xf86GetClocks */
@@ -1506,420 +1502,6 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
     return i;
 }
 
-static Bool
-pciDeviceHasBars(struct pci_device *pci)
-{
-    int i;
-
-    for (i = 0; i < 6; i++)
-	if (pci->regions[i].size)
-	    return TRUE;
-
-    if (pci->rom_size)
-	return TRUE;
-
-    return FALSE;
-}
-
-struct Inst {
-    struct pci_device *	pci;
-    GDevPtr		dev;
-    Bool		foundHW;  /* PCIid in list of supported chipsets */
-    Bool		claimed;  /* BusID matches with a device section */
-    int 		chip;
-    int 		screen;
-};
-
-
-/**
- * Find set of unclaimed devices matching a given vendor ID.
- *
- * Used by drivers to find as yet unclaimed devices matching the specified
- * vendor ID.
- *
- * \param driverName     Name of the driver.  This is used to find Device
- *                       sections in the config file.
- * \param vendorID       PCI vendor ID of associated devices.  If zero, then
- *                       the true vendor ID must be encoded in the \c PCIid
- *                       fields of the \c PCIchipsets entries.
- * \param chipsets       Symbol table used to associate chipset names with
- *                       PCI IDs.
- * \param devList        List of Device sections parsed from the config file.
- * \param numDevs        Number of entries in \c devList.
- * \param drvp           Pointer the driver's control structure.
- * \param foundEntities  Returned list of entity indicies associated with the
- *                       driver.
- *
- * \returns
- * The number of elements in returned in \c foundEntities on success or zero
- * on failure.
- *
- * \todo
- * This function does a bit more than short description says.  Fill in some
- * more of the details of its operation.
- *
- * \todo
- * The \c driverName parameter is redundant.  It is the same as
- * \c DriverRec::driverName.  In a future version of this function, remove
- * that parameter.
- */
-int
-xf86MatchPciInstances(const char *driverName, int vendorID,
-		      SymTabPtr chipsets, PciChipsets *PCIchipsets,
-		      GDevPtr *devList, int numDevs, DriverPtr drvp,
-		      int **foundEntities)
-{
-    int i,j;
-    struct pci_device * pPci;
-    struct pci_device_iterator *iter;
-    struct Inst *instances = NULL;
-    int numClaimedInstances = 0;
-    int allocatedInstances = 0;
-    int numFound = 0;
-    SymTabRec *c;
-    PciChipsets *id;
-    int *retEntities = NULL;
-
-    *foundEntities = NULL;
-
-
-    /* Each PCI device will contribute at least one entry.  Each device
-     * section can contribute at most one entry.  The sum of the two is
-     * guaranteed to be larger than the maximum possible number of entries.
-     * Do this calculation and memory allocation once now to eliminate the
-     * need for realloc calls inside the loop.
-     */
-    if (!(xf86DoConfigure && xf86DoConfigurePass1)) {
-	unsigned max_entries = numDevs;
-
-	iter = pci_slot_match_iterator_create(NULL);
-	while ((pPci = pci_device_next(iter)) != NULL) {
-	    max_entries++;
-	}
-
-	pci_iterator_destroy(iter);
-	instances = xnfalloc(max_entries * sizeof(struct Inst));
-    }
-
-    iter = pci_slot_match_iterator_create(NULL);
-    while ((pPci = pci_device_next(iter)) != NULL) {
-	unsigned device_class = pPci->device_class;
-	Bool foundVendor = FALSE;
-
-
-	/* Convert the pre-PCI 2.0 device class for a VGA adapter to the
-	 * 2.0 version of the same class.
-	 */
-	if ( device_class == 0x00000101 ) {
-	    device_class = 0x00030000;
-	}
-
-
-	/* Find PCI devices that match the given vendor ID.  The vendor ID is
-	 * either specified explicitly as a parameter to the function or
-	 * implicitly encoded in the high bits of id->PCIid.
-	 *
-	 * The first device with a matching vendor is recorded, even if the
-	 * device ID doesn't match.  This is done because the Device section
-	 * in the xorg.conf file can over-ride the device ID.  A matching PCI
-	 * ID might not be found now, but after the device ID over-ride is
-	 * applied there /might/ be a match.
-	 */
-	for (id = PCIchipsets; id->PCIid != -1; id++) {
-	    const unsigned vendor_id = ((id->PCIid & 0xFFFF0000) >> 16)
-		| vendorID;
-	    const unsigned device_id = (id->PCIid & 0x0000FFFF);
-	    const unsigned match_class = 0x00030000 | id->PCIid;
-
-	    if ((vendor_id == pPci->vendor_id)
-		|| ((vendorID == PCI_VENDOR_GENERIC) && (match_class == device_class))) {
-		if (!foundVendor && (instances != NULL)) {
-		    ++allocatedInstances;
-		    instances[allocatedInstances - 1].pci = pPci;
-		    instances[allocatedInstances - 1].dev = NULL;
-		    instances[allocatedInstances - 1].claimed = FALSE;
-		    instances[allocatedInstances - 1].foundHW = FALSE;
-		    instances[allocatedInstances - 1].screen = 0;
-		}
-
-		foundVendor = TRUE;
-
-		if ( (device_id == pPci->device_id)
-		     || ((vendorID == PCI_VENDOR_GENERIC) 
-			 && (match_class == device_class)) ) {
-		    if ( instances != NULL ) {
-			instances[allocatedInstances - 1].foundHW = TRUE;
-			instances[allocatedInstances - 1].chip = id->numChipset;
-		    }
-
-
-		    if ( xf86DoConfigure && xf86DoConfigurePass1 ) {
-			if (xf86CheckPciSlot(pPci)) {
-			    GDevPtr pGDev = 
-			      xf86AddBusDeviceToConfigure(drvp->driverName,
-							  BUS_PCI, pPci, -1);
-			    if (pGDev) {
-				/* After configure pass 1, chipID and chipRev
-				 * are treated as over-rides, so clobber them
-				 * here.
-				 */
-				pGDev->chipID = -1;
-				pGDev->chipRev = -1;
-			    }
-
-			    numFound++;
-			}
-		    }
-		    else {
-			numFound++;
-		    }
-
-		    break;
-		}
-	    }
-	}
-    }
-
-    pci_iterator_destroy(iter);
-
-
-    /* In "probe only" or "configure" mode (signaled by instances being NULL),
-     * our work is done.  Return the number of detected devices.
-     */
-    if ( instances == NULL ) {
-	return numFound;
-    }
-
-
-    /*
-     * This may be debatable, but if no PCI devices with a matching vendor
-     * type is found, return zero now.  It is probably not desirable to
-     * allow the config file to override this.
-     */
-    if (allocatedInstances <= 0) {
-	free(instances);
-	return 0;
-    }
-
-
-    DebugF("%s instances found: %d\n", driverName, allocatedInstances);
-
-   /*
-    * Check for devices that need duplicated instances.  This is required
-    * when there is more than one screen per entity.
-    *
-    * XXX This currently doesn't work for cases where the BusID isn't
-    * specified explicitly in the config file.
-    */
-
-    for (j = 0; j < numDevs; j++) {
-        if (devList[j]->screen > 0 && devList[j]->busID
-	    && *devList[j]->busID) {
-	    for (i = 0; i < allocatedInstances; i++) {
-	        pPci = instances[i].pci;
-	        if (xf86ComparePciBusString(devList[j]->busID, 
-					    PCI_MAKE_BUS( pPci->domain, pPci->bus ),
-					    pPci->dev,
-					    pPci->func)) {
-		    allocatedInstances++;
-		    instances[allocatedInstances - 1] = instances[i];
-		    instances[allocatedInstances - 1].screen =
-		      				devList[j]->screen;
-		    numFound++;
-		    break;
-		}
-	    }
-	}
-    }
-
-    for (i = 0; i < allocatedInstances; i++) {
-	GDevPtr dev = NULL;
-	GDevPtr devBus = NULL;
-
-	pPci = instances[i].pci;
-	for (j = 0; j < numDevs; j++) {
-	    if (devList[j]->busID && *devList[j]->busID) {
-		if (xf86ComparePciBusString(devList[j]->busID, 
-					    PCI_MAKE_BUS( pPci->domain, pPci->bus ),
-					    pPci->dev,
-					    pPci->func) &&
-		    devList[j]->screen == instances[i].screen) {
-
-		    if (devBus)
-                        xf86MsgVerb(X_WARNING,0,
-			    "%s: More than one matching Device section for "
-			    "instances\n\t(BusID: %s) found: %s\n",
-			    driverName, devList[j]->busID,
-			    devList[j]->identifier);
-		    else
-			devBus = devList[j];
-		}
-	    } else {
-		/*
-		 * if device section without BusID is found
-		 * only assign to it to the primary device.
-		 */
-		if (xf86IsPrimaryPci(pPci)) {
-		    xf86Msg(X_PROBED, "Assigning device section with no busID"
-			    " to primary device\n");
-		    if (dev || devBus)
-			xf86MsgVerb(X_WARNING, 0,
-			    "%s: More than one matching Device section "
-			    "found: %s\n", driverName, devList[j]->identifier);
-		    else
-			dev = devList[j];
-		}
-	    }
-	}
-	if (devBus) dev = devBus;  /* busID preferred */
-	if (!dev) {
-	    if (xf86CheckPciSlot(pPci) && pciDeviceHasBars(pPci)) {
-		xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
-			    "for instance (BusID PCI:%u@%u:%u:%u) found\n",
-			    driverName, pPci->domain, pPci->bus, pPci->dev,
-			    pPci->func);
-	    }
-	} else {
-	    numClaimedInstances++;
-	    instances[i].claimed = TRUE;
-	    instances[i].dev = dev;
-	}
-    }
-    DebugF("%s instances found: %d\n", driverName, numClaimedInstances);
-    /*
-     * Now check that a chipset or chipID override in the device section
-     * is valid.  Chipset has precedence over chipID.
-     * If chipset is not valid ignore BusSlot completely.
-     */
-    for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
-	MessageType from = X_PROBED;
-
-	if (!instances[i].claimed) {
-	    continue;
-	}
-	if (instances[i].dev->chipset) {
-	    for (c = chipsets; c->token >= 0; c++) {
-		if (xf86NameCmp(c->name, instances[i].dev->chipset) == 0)
-		    break;
-	    }
-	    if (c->token == -1) {
-		instances[i].claimed = FALSE;
-		numClaimedInstances--;
-		xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
-			    "section \"%s\" isn't valid for this driver\n",
-			    driverName, instances[i].dev->chipset,
-			    instances[i].dev->identifier);
-	    } else {
-		instances[i].chip = c->token;
-
-		for (id = PCIchipsets; id->numChipset >= 0; id++) {
-		    if (id->numChipset == instances[i].chip)
-			break;
-		}
-		if(id->numChipset >=0){
-		    xf86Msg(X_CONFIG,"Chipset override: %s\n",
-			     instances[i].dev->chipset);
-		    from = X_CONFIG;
-		} else {
-		    instances[i].claimed = FALSE;
-		    numClaimedInstances--;
-		    xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
-				"section \"%s\" isn't a valid PCI chipset\n",
-				driverName, instances[i].dev->chipset,
-				instances[i].dev->identifier);
-		}
-	    }
-	} else if (instances[i].dev->chipID > 0) {
-	    for (id = PCIchipsets; id->numChipset >= 0; id++) {
-		if (id->PCIid == instances[i].dev->chipID)
-		    break;
-	    }
-	    if (id->numChipset == -1) {
-		instances[i].claimed = FALSE;
-		numClaimedInstances--;
-		xf86MsgVerb(X_WARNING, 0, "%s: ChipID 0x%04X in Device "
-			    "section \"%s\" isn't valid for this driver\n",
-			    driverName, instances[i].dev->chipID,
-			    instances[i].dev->identifier);
-	    } else {
-		instances[i].chip = id->numChipset;
-
-		xf86Msg( X_CONFIG,"ChipID override: 0x%04X\n",
-			 instances[i].dev->chipID);
-		from = X_CONFIG;
-	    }
-	} else if (!instances[i].foundHW) {
-	    /*
-	     * This means that there was no override and the PCI chipType
-	     * doesn't match one that is supported
-	     */
-	    instances[i].claimed = FALSE;
-	    numClaimedInstances--;
-	}
-	if (instances[i].claimed == TRUE){
-	    for (c = chipsets; c->token >= 0; c++) {
-		if (c->token == instances[i].chip)
-		    break;
-	    }
-	    xf86Msg(from,"Chipset %s found\n",
-		    c->name);
-	}
-    }
-
-    /*
-     * Of the claimed instances, check that another driver hasn't already
-     * claimed its slot.
-     */
-    numFound = 0;
-    for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
-	
-	if (!instances[i].claimed)
-	    continue;
-	pPci = instances[i].pci;
-
-
-        /*
-	 * Allow the same entity to be used more than once for devices with
-	 * multiple screens per entity.  This assumes implicitly that there
-	 * will be a screen == 0 instance.
-	 *
-	 * XXX Need to make sure that two different drivers don't claim
-	 * the same screen > 0 instance.
-	 */
-        if (instances[i].screen == 0 && !xf86CheckPciSlot( pPci ))
-	    continue;
-
-	DebugF("%s: card at %d:%d:%d is claimed by a Device section\n",
-	       driverName, pPci->bus, pPci->dev, pPci->func);
-
-	/* Allocate an entry in the lists to be returned */
-	numFound++;
-	retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
-	retEntities[numFound - 1] = xf86ClaimPciSlot( pPci, drvp,
-						      instances[i].chip,
-						      instances[i].dev,
-						      instances[i].dev->active);
-        if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) {
-	    for (j = 0; j < xf86NumEntities; j++) {
-	        EntityPtr pEnt = xf86Entities[j];
-	        if (pEnt->bus.type != BUS_PCI)
-		    continue;
-	        if (pEnt->bus.id.pci == pPci) {
-		    retEntities[numFound - 1] = j;
-		    xf86AddDevToEntity(j, instances[i].dev);
-		    break;
-		}
-	    }
-	}
-    }
-    free(instances);
-    if (numFound > 0) {
-	*foundEntities = retEntities;
-    }
-	
-    return numFound;
-}
-
 /*
  * xf86GetClocks -- get the dot-clocks via a BIG BAD hack ...
  */
@@ -2349,28 +1931,6 @@ xf86FindXvOptions(int scrnIndex, int adaptor_index, char *port_name,
 #define LoaderGetOS xf86GetOS
 #include "loader/os.c"
 
-/* new RAC */
-/*
- * xf86ConfigPciEntityInactive() -- This function can be used
- * to configure an inactive entity as well as to reconfigure an
- * previously active entity inactive. If the entity has been
- * assigned to a screen before it will be removed. If p_chip is
- * non-NULL all static resources listed there will be registered.
- */
-static void
-xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip,
-			    EntityProc init, EntityProc enter,
-			    EntityProc leave, pointer private)
-{
-    ScrnInfoPtr pScrn;
-
-    if ((pScrn = xf86FindScreenForEntity(pEnt->index)))
-	xf86RemoveEntityFromScreen(pScrn,pEnt->index);
-
-    /* shared resources are only needed when entity is active: remove */
-    xf86SetEntityFuncs(pEnt->index,init,enter,leave,private);
-}
-
 static void
 xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init,
 			   EntityProc enter, EntityProc leave, pointer private)
@@ -2383,42 +1943,6 @@ xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init,
 }
 
 ScrnInfoPtr
-xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
-			  PciChipsets *p_chip, void *dummy, EntityProc init,
-			  EntityProc enter, EntityProc leave, pointer private)
-{
-    EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
-    if (!pEnt) return pScrn;
-
-    if (!(pEnt->location.type == BUS_PCI)
-	|| !xf86GetPciInfoForEntity(entityIndex)) {
-	free(pEnt);
-	return pScrn;
-    }
-    if (!pEnt->active) {
-	xf86ConfigPciEntityInactive(pEnt, p_chip, init,  enter,
-				    leave,  private);
-	free(pEnt);
-	return pScrn;
-    }
-
-    if (!pScrn)
-	pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
-    if (xf86IsEntitySharable(entityIndex)) {
-        xf86SetEntityShared(entityIndex);
-    }
-    xf86AddEntityToScreen(pScrn,entityIndex);
-    if (xf86IsEntityShared(entityIndex)) {
-        return pScrn;
-    }
-    free(pEnt);
-
-    xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
-
-    return pScrn;
-}
-
-ScrnInfoPtr
 xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
 		   EntityProc init, EntityProc enter, EntityProc leave,
 		   pointer private)
@@ -2446,33 +1970,6 @@ xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
     return pScrn;
 }
 
-/*
- *
- *  OBSOLETE ! xf86ConfigActivePciEntity() is an obsolete function.
- *             It is likely to be removed. Don't use!
- */
-
-Bool
-xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
-                          PciChipsets *p_chip, void *dummy, EntityProc init,
-                          EntityProc enter, EntityProc leave, pointer private)
-{
-    EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
-    if (!pEnt) return FALSE;
-
-    if (!pEnt->active || !(pEnt->location.type == BUS_PCI)) {
-        free(pEnt);
-        return FALSE;
-    }
-    xf86AddEntityToScreen(pScrn,entityIndex);
-
-    free(pEnt);
-    if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private))
-        return FALSE;
-
-    return TRUE;
-}
-
 Bool
 xf86IsScreenPrimary(int scrnIndex)
 {
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index 4656f1a..c20abfa 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -581,3 +581,497 @@ xf86PciIsolateDevice(char *argument)
     } else
         FatalError("Invalid isolated device specification\n");
 }
+
+static Bool
+pciDeviceHasBars(struct pci_device *pci)
+{
+    int i;
+
+    for (i = 0; i < 6; i++)
+	if (pci->regions[i].size)
+	    return TRUE;
+
+    if (pci->rom_size)
+	return TRUE;
+
+    return FALSE;
+}
+
+struct Inst {
+    struct pci_device *	pci;
+    GDevPtr		dev;
+    Bool		foundHW;  /* PCIid in list of supported chipsets */
+    Bool		claimed;  /* BusID matches with a device section */
+    int 		chip;
+    int 		screen;
+};
+
+
+/**
+ * Find set of unclaimed devices matching a given vendor ID.
+ *
+ * Used by drivers to find as yet unclaimed devices matching the specified
+ * vendor ID.
+ *
+ * \param driverName     Name of the driver.  This is used to find Device
+ *                       sections in the config file.
+ * \param vendorID       PCI vendor ID of associated devices.  If zero, then
+ *                       the true vendor ID must be encoded in the \c PCIid
+ *                       fields of the \c PCIchipsets entries.
+ * \param chipsets       Symbol table used to associate chipset names with
+ *                       PCI IDs.
+ * \param devList        List of Device sections parsed from the config file.
+ * \param numDevs        Number of entries in \c devList.
+ * \param drvp           Pointer the driver's control structure.
+ * \param foundEntities  Returned list of entity indicies associated with the
+ *                       driver.
+ *
+ * \returns
+ * The number of elements in returned in \c foundEntities on success or zero
+ * on failure.
+ *
+ * \todo
+ * This function does a bit more than short description says.  Fill in some
+ * more of the details of its operation.
+ *
+ * \todo
+ * The \c driverName parameter is redundant.  It is the same as
+ * \c DriverRec::driverName.  In a future version of this function, remove
+ * that parameter.
+ */
+int
+xf86MatchPciInstances(const char *driverName, int vendorID,
+		      SymTabPtr chipsets, PciChipsets *PCIchipsets,
+		      GDevPtr *devList, int numDevs, DriverPtr drvp,
+		      int **foundEntities)
+{
+    int i,j;
+    struct pci_device * pPci;
+    struct pci_device_iterator *iter;
+    struct Inst *instances = NULL;
+    int numClaimedInstances = 0;
+    int allocatedInstances = 0;
+    int numFound = 0;
+    SymTabRec *c;
+    PciChipsets *id;
+    int *retEntities = NULL;
+
+    *foundEntities = NULL;
+
+
+    /* Each PCI device will contribute at least one entry.  Each device
+     * section can contribute at most one entry.  The sum of the two is
+     * guaranteed to be larger than the maximum possible number of entries.
+     * Do this calculation and memory allocation once now to eliminate the
+     * need for realloc calls inside the loop.
+     */
+    if (!(xf86DoConfigure && xf86DoConfigurePass1)) {
+	unsigned max_entries = numDevs;
+
+	iter = pci_slot_match_iterator_create(NULL);
+	while ((pPci = pci_device_next(iter)) != NULL) {
+	    max_entries++;
+	}
+
+	pci_iterator_destroy(iter);
+	instances = xnfalloc(max_entries * sizeof(struct Inst));
+    }
+
+    iter = pci_slot_match_iterator_create(NULL);
+    while ((pPci = pci_device_next(iter)) != NULL) {
+	unsigned device_class = pPci->device_class;
+	Bool foundVendor = FALSE;
+
+
+	/* Convert the pre-PCI 2.0 device class for a VGA adapter to the
+	 * 2.0 version of the same class.
+	 */
+	if ( device_class == 0x00000101 ) {
+	    device_class = 0x00030000;
+	}
+
+
+	/* Find PCI devices that match the given vendor ID.  The vendor ID is
+	 * either specified explicitly as a parameter to the function or
+	 * implicitly encoded in the high bits of id->PCIid.
+	 *
+	 * The first device with a matching vendor is recorded, even if the
+	 * device ID doesn't match.  This is done because the Device section
+	 * in the xorg.conf file can over-ride the device ID.  A matching PCI
+	 * ID might not be found now, but after the device ID over-ride is
+	 * applied there /might/ be a match.
+	 */
+	for (id = PCIchipsets; id->PCIid != -1; id++) {
+	    const unsigned vendor_id = ((id->PCIid & 0xFFFF0000) >> 16)
+		| vendorID;
+	    const unsigned device_id = (id->PCIid & 0x0000FFFF);
+	    const unsigned match_class = 0x00030000 | id->PCIid;
+
+	    if ((vendor_id == pPci->vendor_id)
+		|| ((vendorID == PCI_VENDOR_GENERIC) && (match_class == device_class))) {
+		if (!foundVendor && (instances != NULL)) {
+		    ++allocatedInstances;
+		    instances[allocatedInstances - 1].pci = pPci;
+		    instances[allocatedInstances - 1].dev = NULL;
+		    instances[allocatedInstances - 1].claimed = FALSE;
+		    instances[allocatedInstances - 1].foundHW = FALSE;
+		    instances[allocatedInstances - 1].screen = 0;
+		}
+
+		foundVendor = TRUE;
+
+		if ( (device_id == pPci->device_id)
+		     || ((vendorID == PCI_VENDOR_GENERIC)
+			 && (match_class == device_class)) ) {
+		    if ( instances != NULL ) {
+			instances[allocatedInstances - 1].foundHW = TRUE;
+			instances[allocatedInstances - 1].chip = id->numChipset;
+		    }
+
+
+		    if ( xf86DoConfigure && xf86DoConfigurePass1 ) {
+			if (xf86CheckPciSlot(pPci)) {
+			    GDevPtr pGDev =
+			      xf86AddBusDeviceToConfigure(drvp->driverName,
+							  BUS_PCI, pPci, -1);
+			    if (pGDev) {
+				/* After configure pass 1, chipID and chipRev
+				 * are treated as over-rides, so clobber them
+				 * here.
+				 */
+				pGDev->chipID = -1;
+				pGDev->chipRev = -1;
+			    }
+
+			    numFound++;
+			}
+		    }
+		    else {
+			numFound++;
+		    }
+
+		    break;
+		}
+	    }
+	}
+    }
+
+    pci_iterator_destroy(iter);
+
+
+    /* In "probe only" or "configure" mode (signaled by instances being NULL),
+     * our work is done.  Return the number of detected devices.
+     */
+    if ( instances == NULL ) {
+	return numFound;
+    }
+
+
+    /*
+     * This may be debatable, but if no PCI devices with a matching vendor
+     * type is found, return zero now.  It is probably not desirable to
+     * allow the config file to override this.
+     */
+    if (allocatedInstances <= 0) {
+	free(instances);
+	return 0;
+    }
+
+
+    DebugF("%s instances found: %d\n", driverName, allocatedInstances);
+
+   /*
+    * Check for devices that need duplicated instances.  This is required
+    * when there is more than one screen per entity.
+    *
+    * XXX This currently doesn't work for cases where the BusID isn't
+    * specified explicitly in the config file.
+    */
+
+    for (j = 0; j < numDevs; j++) {
+        if (devList[j]->screen > 0 && devList[j]->busID
+	    && *devList[j]->busID) {
+	    for (i = 0; i < allocatedInstances; i++) {
+	        pPci = instances[i].pci;
+	        if (xf86ComparePciBusString(devList[j]->busID,
+					    PCI_MAKE_BUS( pPci->domain, pPci->bus ),
+					    pPci->dev,
+					    pPci->func)) {
+		    allocatedInstances++;
+		    instances[allocatedInstances - 1] = instances[i];
+		    instances[allocatedInstances - 1].screen = devList[j]->screen;
+		    numFound++;
+		    break;
+		}
+	    }
+	}
+    }
+
+    for (i = 0; i < allocatedInstances; i++) {
+	GDevPtr dev = NULL;
+	GDevPtr devBus = NULL;
+
+	pPci = instances[i].pci;
+	for (j = 0; j < numDevs; j++) {
+	    if (devList[j]->busID && *devList[j]->busID) {
+		if (xf86ComparePciBusString(devList[j]->busID,
+					    PCI_MAKE_BUS( pPci->domain, pPci->bus ),
+					    pPci->dev,
+					    pPci->func) &&
+		    devList[j]->screen == instances[i].screen) {
+
+		    if (devBus)
+                        xf86MsgVerb(X_WARNING,0,
+			    "%s: More than one matching Device section for "
+			    "instances\n\t(BusID: %s) found: %s\n",
+			    driverName, devList[j]->busID,
+			    devList[j]->identifier);
+		    else
+			devBus = devList[j];
+		}
+	    } else {
+		/*
+		 * if device section without BusID is found
+		 * only assign to it to the primary device.
+		 */
+		if (xf86IsPrimaryPci(pPci)) {
+		    xf86Msg(X_PROBED, "Assigning device section with no busID"
+			    " to primary device\n");
+		    if (dev || devBus)
+			xf86MsgVerb(X_WARNING, 0,
+			    "%s: More than one matching Device section "
+			    "found: %s\n", driverName, devList[j]->identifier);
+		    else
+			dev = devList[j];
+		}
+	    }
+	}
+	if (devBus) dev = devBus;  /* busID preferred */
+	if (!dev) {
+	    if (xf86CheckPciSlot(pPci) && pciDeviceHasBars(pPci)) {
+		xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
+			    "for instance (BusID PCI:%u@%u:%u:%u) found\n",
+			    driverName, pPci->domain, pPci->bus, pPci->dev,
+			    pPci->func);
+	    }
+	} else {
+	    numClaimedInstances++;
+	    instances[i].claimed = TRUE;
+	    instances[i].dev = dev;
+	}
+    }
+    DebugF("%s instances found: %d\n", driverName, numClaimedInstances);
+    /*
+     * Now check that a chipset or chipID override in the device section
+     * is valid.  Chipset has precedence over chipID.
+     * If chipset is not valid ignore BusSlot completely.
+     */
+    for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
+	MessageType from = X_PROBED;
+
+	if (!instances[i].claimed) {
+	    continue;
+	}
+	if (instances[i].dev->chipset) {
+	    for (c = chipsets; c->token >= 0; c++) {
+		if (xf86NameCmp(c->name, instances[i].dev->chipset) == 0)
+		    break;
+	    }
+	    if (c->token == -1) {
+		instances[i].claimed = FALSE;
+		numClaimedInstances--;
+		xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
+			    "section \"%s\" isn't valid for this driver\n",
+			    driverName, instances[i].dev->chipset,
+			    instances[i].dev->identifier);
+	    } else {
+		instances[i].chip = c->token;
+
+		for (id = PCIchipsets; id->numChipset >= 0; id++) {
+		    if (id->numChipset == instances[i].chip)
+			break;
+		}
+		if(id->numChipset >=0){
+		    xf86Msg(X_CONFIG,"Chipset override: %s\n",
+			     instances[i].dev->chipset);
+		    from = X_CONFIG;
+		} else {
+		    instances[i].claimed = FALSE;
+		    numClaimedInstances--;
+		    xf86MsgVerb(X_WARNING, 0, "%s: Chipset \"%s\" in Device "
+				"section \"%s\" isn't a valid PCI chipset\n",
+				driverName, instances[i].dev->chipset,
+				instances[i].dev->identifier);
+		}
+	    }
+	} else if (instances[i].dev->chipID > 0) {
+	    for (id = PCIchipsets; id->numChipset >= 0; id++) {
+		if (id->PCIid == instances[i].dev->chipID)
+		    break;
+	    }
+	    if (id->numChipset == -1) {
+		instances[i].claimed = FALSE;
+		numClaimedInstances--;
+		xf86MsgVerb(X_WARNING, 0, "%s: ChipID 0x%04X in Device "
+			    "section \"%s\" isn't valid for this driver\n",
+			    driverName, instances[i].dev->chipID,
+			    instances[i].dev->identifier);
+	    } else {
+		instances[i].chip = id->numChipset;
+
+		xf86Msg( X_CONFIG,"ChipID override: 0x%04X\n",
+			 instances[i].dev->chipID);
+		from = X_CONFIG;
+	    }
+	} else if (!instances[i].foundHW) {
+	    /*
+	     * This means that there was no override and the PCI chipType
+	     * doesn't match one that is supported
+	     */
+	    instances[i].claimed = FALSE;
+	    numClaimedInstances--;
+	}
+	if (instances[i].claimed == TRUE){
+	    for (c = chipsets; c->token >= 0; c++) {
+		if (c->token == instances[i].chip)
+		    break;
+	    }
+	    xf86Msg(from,"Chipset %s found\n",
+		    c->name);
+	}
+    }
+
+    /*
+     * Of the claimed instances, check that another driver hasn't already
+     * claimed its slot.
+     */
+    numFound = 0;
+    for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
+	if (!instances[i].claimed)
+	    continue;
+	pPci = instances[i].pci;
+
+
+        /*
+	 * Allow the same entity to be used more than once for devices with
+	 * multiple screens per entity.  This assumes implicitly that there
+	 * will be a screen == 0 instance.
+	 *
+	 * XXX Need to make sure that two different drivers don't claim
+	 * the same screen > 0 instance.
+	 */
+        if (instances[i].screen == 0 && !xf86CheckPciSlot( pPci ))
+	    continue;
+
+	DebugF("%s: card at %d:%d:%d is claimed by a Device section\n",
+	       driverName, pPci->bus, pPci->dev, pPci->func);
+
+	/* Allocate an entry in the lists to be returned */
+	numFound++;
+	retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
+	retEntities[numFound - 1] = xf86ClaimPciSlot( pPci, drvp,
+						      instances[i].chip,
+						      instances[i].dev,
+						      instances[i].dev->active);
+        if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) {
+	    for (j = 0; j < xf86NumEntities; j++) {
+	        EntityPtr pEnt = xf86Entities[j];
+	        if (pEnt->bus.type != BUS_PCI)
+		    continue;
+	        if (pEnt->bus.id.pci == pPci) {
+		    retEntities[numFound - 1] = j;
+		    xf86AddDevToEntity(j, instances[i].dev);
+		    break;
+		}
+	    }
+	}
+    }
+    free(instances);
+    if (numFound > 0) {
+	*foundEntities = retEntities;
+    }
+
+    return numFound;
+}
+
+/*
+ * xf86ConfigPciEntityInactive() -- This function can be used
+ * to configure an inactive entity as well as to reconfigure an
+ * previously active entity inactive. If the entity has been
+ * assigned to a screen before it will be removed. If p_chip is
+ * non-NULL all static resources listed there will be registered.
+ */
+static void
+xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip,
+			    EntityProc init, EntityProc enter,
+			    EntityProc leave, pointer private)
+{
+    ScrnInfoPtr pScrn;
+
+    if ((pScrn = xf86FindScreenForEntity(pEnt->index)))
+	xf86RemoveEntityFromScreen(pScrn,pEnt->index);
+
+    /* shared resources are only needed when entity is active: remove */
+    xf86SetEntityFuncs(pEnt->index,init,enter,leave,private);
+}
+
+ScrnInfoPtr
+xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
+			  PciChipsets *p_chip, void *dummy, EntityProc init,
+			  EntityProc enter, EntityProc leave, pointer private)
+{
+    EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
+    if (!pEnt) return pScrn;
+
+    if (!(pEnt->location.type == BUS_PCI)
+	|| !xf86GetPciInfoForEntity(entityIndex)) {
+	free(pEnt);
+	return pScrn;
+    }
+    if (!pEnt->active) {
+	xf86ConfigPciEntityInactive(pEnt, p_chip, init,  enter,
+				    leave,  private);
+	free(pEnt);
+	return pScrn;
+    }
+
+    if (!pScrn)
+	pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
+    if (xf86IsEntitySharable(entityIndex)) {
+        xf86SetEntityShared(entityIndex);
+    }
+    xf86AddEntityToScreen(pScrn,entityIndex);
+    if (xf86IsEntityShared(entityIndex)) {
+        return pScrn;
+    }
+    free(pEnt);
+
+    xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
+
+    return pScrn;
+}
+
+/*
+ *  OBSOLETE ! xf86ConfigActivePciEntity() is an obsolete function.
+ *             It is likely to be removed. Don't use!
+ */
+Bool
+xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
+                          PciChipsets *p_chip, void *dummy, EntityProc init,
+                          EntityProc enter, EntityProc leave, pointer private)
+{
+    EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
+    if (!pEnt) return FALSE;
+
+    if (!pEnt->active || !(pEnt->location.type == BUS_PCI)) {
+        free(pEnt);
+        return FALSE;
+    }
+    xf86AddEntityToScreen(pScrn,entityIndex);
+
+    free(pEnt);
+    if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private))
+        return FALSE;
+
+    return TRUE;
+}
commit 610009cf39984f2f5e818a221b626f7af10bd90e
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue May 18 20:54:28 2010 +0300

    xfree86: bus: remove useless field from EntityRec
    
    RAC is the champion of remaining trash for sure!
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Alex Deucher <alexdeucher at gmail.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86Bus.h b/hw/xfree86/common/xf86Bus.h
index b22e2e7..e161c7f 100644
--- a/hw/xfree86/common/xf86Bus.h
+++ b/hw/xfree86/common/xf86Bus.h
@@ -54,7 +54,6 @@ typedef struct {
     Bool                        active;
     Bool                        inUse;
     BusRec                      bus;
-    pointer                     busAcc;
     int                         lastScrnFlag;
     DevUnion *                  entityPrivates;
     int                         numInstances;
commit 95889a569feabd3f803afb92950d067bd76e7397
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue May 18 20:48:35 2010 +0300

    xfree86: bus: delete useless xf86FindPrimaryDevice
    
    This function had a wrong name and was just logging the primary device. No one
    cares about it honestly.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Alex Deucher <alexdeucher at gmail.com>

diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 69fbdff..8276257 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -111,10 +111,6 @@ xf86BusConfig(void)
     if (xorgHWAccess)
         xorgHWAccess = xf86EnableIO();
 
-    /* Locate bus slot that had register IO enabled at server startup */
-    if (xorgHWAccess)
-        xf86FindPrimaryDevice();
-
     /*
      * Now call each of the Probe functions.  Each successful probe will
      * result in an extra entry added to the xf86Screens[] list for each
@@ -557,39 +553,6 @@ xf86PostScreenInit(void)
     xf86EnterServerState(OPERATING);
 }
 
-/*
- * xf86FindPrimaryDevice() - Find the display device which
- * was active when the server was started.
- */
-void
-xf86FindPrimaryDevice(void)
-{
-    if (primaryBus.type != BUS_NONE) {
-	char *bus;
-	char loc[16];
-
-	switch (primaryBus.type) {
-	case BUS_PCI:
-	    bus = "PCI";
-	    snprintf(loc, sizeof(loc), " %2.2x@%2.2x:%2.2x:%1.1x",
-		     primaryBus.id.pci->bus,
-		     primaryBus.id.pci->domain,
-		     primaryBus.id.pci->dev,
-		     primaryBus.id.pci->func);
-	    break;
-	case BUS_SBUS:
-	    bus = "SBUS";
-	    snprintf(loc, sizeof(loc), " %2.2x", primaryBus.id.sbus.fbNum);
-	    break;
-	default:
-	    bus = "";
-	    loc[0] = '\0';
-	}
-
-	xf86MsgVerb(X_INFO, 2, "Primary Device is: %s%s\n",bus,loc);
-    }
-}
-
 int
 xf86GetLastScrnFlag(int entityIndex)
 {
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index 3013321..2f93bb1 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -681,8 +681,6 @@ DoConfigure(void)
 	    xorgHWAccess = FALSE;
     }
 
-    xf86FindPrimaryDevice();
- 
     /* Create XF86Config file structure */
     xf86config = calloc(1, sizeof(XF86ConfigRec));
 
diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index d2073ae..b5e7a45 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -110,14 +110,10 @@ extern _X_EXPORT  RootWinPropPtr *xf86RegisteredPropertiesTable;
 #ifndef _NO_XF86_PROTOTYPES
 
 /* xf86Bus.c */
-
 extern _X_EXPORT Bool xf86BusConfig(void);
 extern _X_EXPORT void xf86BusProbe(void);
 extern _X_EXPORT void xf86AccessEnter(void);
 extern _X_EXPORT void xf86AccessLeave(void);
-
-extern _X_EXPORT void xf86FindPrimaryDevice(void);
-/* new RAC */
 extern _X_EXPORT void xf86PostProbe(void);
 extern _X_EXPORT void xf86ClearEntityListForScreen(int scrnIndex);
 extern _X_EXPORT void xf86AddDevToEntity(int entityIndex, GDevPtr dev);
commit f6865909485d7d282c8131a2ae306143ad51ba2b
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue May 18 19:39:31 2010 +0300

    xfree86: bus: remove unused headers
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Alex Deucher <alexdeucher at gmail.com>

diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 8a73925..69fbdff 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -49,8 +49,6 @@
 #include "xf86_OSproc.h"
 #include "xf86VGAarbiter.h"
 
-#include "Pci.h"
-
 /* Entity data */
 EntityPtr *xf86Entities = NULL;	/* Bus slots claimed by drivers */
 int xf86NumEntities = 0;
diff --git a/hw/xfree86/os-support/bus/Pci.c b/hw/xfree86/os-support/bus/Pci.c
index b7fa25f..a0a597d 100644
--- a/hw/xfree86/os-support/bus/Pci.c
+++ b/hw/xfree86/os-support/bus/Pci.c
@@ -126,7 +126,6 @@
 
 #include <errno.h>
 #include <signal.h>
-#include <X11/Xarch.h>
 #include "compiler.h"
 #include "xf86.h"
 #include "xf86Priv.h"
diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h
index 70c831f..e001c30 100644
--- a/hw/xfree86/os-support/bus/Pci.h
+++ b/hw/xfree86/os-support/bus/Pci.h
@@ -107,8 +107,6 @@
 #ifndef _PCI_H
 #define _PCI_H 1
 
-#include <X11/Xarch.h>
-#include <X11/Xfuncproto.h>
 #include "xf86Pci.h"
 #include "xf86PciInfo.h"
 
diff --git a/hw/xfree86/vbe/vbe.c b/hw/xfree86/vbe/vbe.c
index 9f9b743..3840bfe 100644
--- a/hw/xfree86/vbe/vbe.c
+++ b/hw/xfree86/vbe/vbe.c
@@ -17,7 +17,6 @@
 
 #include "xf86.h"
 #include "vbe.h"
-#include <X11/Xarch.h>
 #include <X11/extensions/dpmsconst.h>
 
 #define VERSION(x) VBE_VERSION_MAJOR(x),VBE_VERSION_MINOR(x)
commit 111b1fff1ca69724a8350c4375089c312329c378
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue May 18 19:35:10 2010 +0300

    xfree86: bus: remove unused pci macros
    
    Should be gone in commits 3c03d9f1 and a9d7d659a respectively.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Alex Deucher <alexdeucher at gmail.com>

diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h
index b52a6cf..70c831f 100644
--- a/hw/xfree86/os-support/bus/Pci.h
+++ b/hw/xfree86/os-support/bus/Pci.h
@@ -121,9 +121,6 @@
 #define PCI_DOM_MASK 0x0ffu
 #endif
 
-#define DEVID(vendor, device) \
-    ((CARD32)((PCI_##device << 16) | PCI_##vendor))
-
 #ifndef PCI_DOM_MASK
 # define PCI_DOM_MASK 0x0ffu
 #endif
@@ -143,9 +140,6 @@
 #define PCI_DEV_FROM_TAG(tag)  (((tag) & 0x0000f800u) >> 11)
 #define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8)
 
-#define PCI_DFN_FROM_TAG(tag)  (((tag) & 0x0000ff00u) >> 8)
-#define PCI_BDEV_FROM_TAG(tag) ((tag) & 0x00fff800u)
-
 #define PCI_DOM_FROM_BUS(bus)  (((bus) >> 8) & (PCI_DOM_MASK))
 #define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
 #define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u)
commit 2ffffb4daf6161e6a22d81442ecf6209acc9e975
Merge: b5e0f6d... d530608...
Author: Keith Packard <keithp at keithp.com>
Date:   Sun May 23 23:22:08 2010 -0700

    Merge remote branch 'alanc/docs'

commit b5e0f6d8f45c5b24eb50b305c66fa80c783ef488
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon May 24 12:25:15 2010 +1000

    xfree86: fix multiple InputAttributes tag matching.
    
    attr->tags is an array of strings (null-terminated). When matching, match
    against each string instead of each [i,end] substring in the first tag.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index ac287aa..2e25482 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -551,9 +551,9 @@ InputClassMatches(XF86ConfInputClassPtr iclass, InputAttributes *attrs)
             return FALSE;
 
         for (cur = iclass->match_tag, match = FALSE; *cur && !match; cur++) {
-            const char *tag;
-            for(tag = *attrs->tags; *tag; tag++) {
-                if (!strcmp(tag, *cur)) {
+            char * const *tag;
+            for(tag = attrs->tags; *tag; tag++) {
+                if (!strcmp(*tag, *cur)) {
                     match = TRUE;
                     break;
                 }
commit d5306084b57583c670c56ce9e7d3c78cca7aa07b
Author: Brice Goglin <bgoglin at debian.org>
Date:   Sat May 22 20:29:02 2010 +0200

    Remove obsolete reference to README.DRI in xorg.conf.man
    
    Signed-off-by: Brice Goglin <Brice.Goglin at ens-lyon.org>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre
index 5ff4ff2..9075db6 100644
--- a/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -2342,8 +2342,7 @@ section for a dual headed configuration with two mice:
 .SH "DRI SECTION"
 This optional section is used to provide some information for the
 Direct Rendering Infrastructure.
-Details about the format of this section
-can be found in the README.DRI document, which is also available on-line at
+Details about the format of this section can be found on-line at
 .IR <http://dri.freedesktop.org/> .
 .SH "VENDOR SECTION"
 The optional
commit 89dd7d2b6fe18f32c2f9336c3d8cd9f35490e5ae
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat May 22 10:33:04 2010 -0700

    Remove ancient documentation of IBM RapidAccess keyboard hack
    
    Keyboard setup belongs in drivers, not in a document no one sees
    because we don't even install it.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Reviewed-by: Alex Deucher <alexdeucher at gmail.com>

diff --git a/hw/xfree86/doc/Makefile.am b/hw/xfree86/doc/Makefile.am
index bfdf86d..33ff18a 100644
--- a/hw/xfree86/doc/Makefile.am
+++ b/hw/xfree86/doc/Makefile.am
@@ -5,5 +5,4 @@ SUBDIRS = man
 endif
 
 EXTRA_DIST = \
-	README.modes \
-	README.rapidaccess
+	README.modes
diff --git a/hw/xfree86/doc/README.rapidaccess b/hw/xfree86/doc/README.rapidaccess
deleted file mode 100644
index 39f515e..0000000
--- a/hw/xfree86/doc/README.rapidaccess
+++ /dev/null
@@ -1,48 +0,0 @@
-The IBM Rapid Access keyboard have some extra buttons
-on it to launch programs, control a cd-player and so on.
-
-These buttons is not functional when the computer is turned
-on but have to be activated by sending the codes 0xea 0x71
-to it.
-
-I've written the following hack to send codes to the keyboard:
-
---------------------------------------------------------------
-/* gcc -O2 -s -Wall -osend_to_keyboard send_to_keyboard.c */
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/io.h>
-
-int main( int argc, char *argv[] )
-{
-  int i;
-
-  ioperm( 0x60, 3, 1 );
-
-  for( i = 1; i < argc; i++ ) {
-    int x = strtol( argv[i], 0, 16 );
-
-    usleep( 300 );
-    outb( x, 0x60 );
-  }
-
-  return 0;
-}
---------------------------------------------------------------
-
-As root you can then call this program (in your boot scripts)
-as "send_to_keyboard ea 71" to turn on the extra buttons.
-
-It's not a good idea to run several instances of this program
-at the same time. It is a hack but it works. If you try to
-send other codes to the keyboard it probably will lock up.
-For other codes see:
-
-http://www.win.tue.nl/~aeb/linux/kbd/scancodes-2.html#ss2.22
-
---
-Dennis Björklund <db at zigo.dhs.org>
-
-
-
-$XFree86$
commit 480fcdf0335abae0ee544b022c7985211eee462f
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat May 22 10:29:47 2010 -0700

    Remove completely out-of-date README.DRI
    
    The license only allows distribution of verbatim copies, so we can't
    update it, even to correct the incorrect address to send updates to.
    
    The Mesa & DRI web pages are much better sources of current information
    anyway.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/hw/xfree86/doc/Makefile.am b/hw/xfree86/doc/Makefile.am
index 72bc5d9..bfdf86d 100644
--- a/hw/xfree86/doc/Makefile.am
+++ b/hw/xfree86/doc/Makefile.am
@@ -5,6 +5,5 @@ SUBDIRS = man
 endif
 
 EXTRA_DIST = \
-	README.DRI \
 	README.modes \
 	README.rapidaccess
diff --git a/hw/xfree86/doc/README.DRI b/hw/xfree86/doc/README.DRI
deleted file mode 100644
index 7fc52eb..0000000
--- a/hw/xfree86/doc/README.DRI
+++ /dev/null
@@ -1,1256 +0,0 @@
-                               DRI User Guide
-
-          VA Linux Systems, Inc. Professional Services - Graphics.
-
-                                15 June 2001
-
-1.  Preamble
-
-1.1  Copyright
-
-Copyright 2000-2001 by VA Linux Systems, Inc.  All Rights Reserved.
-
-Permission is granted to make and distribute verbatim copies of this document
-provided the copyright notice and this permission notice are preserved on all
-copies.
-
-1.2  Trademarks
-
-OpenGL is a registered trademark and SGI is a trademark of Silicon Graphics,
-Inc.  Unix is a registered trademark of The Open Group.  The `X' device and X
-Window System are trademarks of The Open Group.  XFree86 is a trademark of
-The XFree86 Project.  Linux is a registered trademark of Linus Torvalds.
-Intel is a registered trademark of Intel Corporation.  3Dlabs, GLINT, and
-Oxygen are either registered trademarks or trademarks of 3Dlabs Inc. Ltd.
-3dfx, Voodoo3, Voodoo4, and Voodoo5 are registered trademarks of 3dfx Inter-
-active, Incorporated.  Matrox is a registered trademark of Matrox Electronic
-Systems Ltd.  ATI Rage and Radeon are registered trademarks of ATI Technolo-
-gies, Inc.  All other trademarks mentioned are the property of their respec-
-tive owners.
-
-2.  Introduction
-
-With XFree86 4.x and the Direct Rendering Interface (DRI), hardware acceler-
-ated 3D graphics can be considered a standard feature on Linux workstations.
-Support for other operating systems, such as FreeBSD, is underway.
-
-This document describes how to use the DRI system and troubleshoot problems
-which may occur.  Readers should have a basic understanding of Linux, X and
-OpenGL.  See the resources section at the end for more documentation and
-software downloads.
-
-This document does not cover compilation or installation of XFree86 4.x.  It
-is assumed that you've already installed a Linux distribution which includes
-XFree86 4.x or that you're an experienced Linux developer who has compiled
-the DRI for himself.  DRI download, compilation and installation instructions
-can be found at http://dri.sourceforge.net/DRIcompile.html
-
-Edits, corrections and updates to this document may be mailed to <brian at tung-
-stengrahpics.com>.
-
-3.  Supported Architectures & Hardware
-
-3.1  CPU Architectures
-
-The architectures currently supported by the DRI have grown from the initial
-Intel i386 systems to now include the Alpha Processor and the Sun SPARC
-machines.
-
-Intel's SSE (a.k.a. Katmai) instructions are used in optimized vertex trans-
-formation functions in Mesa-based drivers.  This requires a recent Linux ker-
-nel both at compile and runtime.  See the DRI Compile Guide for compile-time
-requirements.  At runtime a check is made to determine if the CPU can execute
-SSE instructions.  They're disabled otherwise.
-
-AMD's 3DNow! instructions are also used in optimized vertex transformation
-functions in the Mesa-based DRI drivers.  3DNow! is supported in most ver-
-sions of Linux.  Like the SSE optimizations, a runtime check is made to
-determine if the CPU can execute 3DNow! instructions.
-
-Alpha-based systems can use Compaq's optimized math library for improved 3D
-performance.  See the DRI Compilation Guide for details.
-
-3.2  Graphics Hardware
-
-XFree86 4.2 (or later versions) includes 3D acceleration for the following
-graphics hardware:
-
-   o 3dfx, supported on Intel x86, AMD and Alpha:
-
-        o Voodoo5 5500
-
-        o Voodoo4 4500
-
-        o Voodoo3 3500 TV
-
-        o Voodoo3 3000 AGP
-
-        o Voodoo3 3000 PCI
-
-        o Voodoo3 2000 AGP
-
-        o Voodoo3 2000 PCI
-
-        o Voodoo Banshee
-
-        o Velocity 100/200
-
-     There are many configurations of 3dfx cards on the market.  Not all have
-     been tested.
-
-   o Matrox, supported on Intel x86 and AMD:
-
-        o Matrox G200
-
-        o Matrox G400
-
-   o Intel i810/i815/i830 (motherboard chipsets)
-
-        o i810
-
-        o i810-dc100
-
-        o i810e
-
-        o i815
-
-        o i830
-
-   o ATI Rage 128, supported on Intel x86, AMD and Alpha:
-
-        o Rage Fury
-
-        o Rage Magnum
-
-        o XPERT 2000
-
-        o XPERT 128
-
-        o XPERT 99
-
-        o All-in-Wonder 128
-
-        o Rage 128 PCI (Alpha-based systems)
-
-     Note that both PCI and AGP versions of Rage 128 based cards are sup-
-     ported at this time.
-
-   o ATI Radeon, supported on Intel x86, AMD and Alpha:
-
-        o Radeon SDR AGP
-
-        o Radeon DDR AGP
-
-        o Radeon 32MB SDR PCI (Alpha-based systems)
-
-        o Radeon 7000, M6 (RV100)
-
-        o Radeon 7200 (R100)
-
-        o Radeon 7500, M7 (RV200)
-
-        o Radeon 8500, 9100 (R200)
-
-        o Radeon 9000, M9 (RV250)
-
-   o 3Dlabs, supported on Intel x86 and AMD:
-
-        o Oxygen GMX 2000 (MX/Gamma based).  Note:  this driver is no longer
-          being actively developed.
-
-Support for other hardware is underway.  Most of the DRI development work is
-funded by contracts with IHVs.  These contracts often prevent us from
-announcing drivers before they're released.  Queries about upcoming drivers
-may not be answerable.
-
-4.  Prerequisite Software
-
-   o The DRI is available in XFree86 4.0 and later.
-
-   o Some hardware drivers require specific versions of the Linux kernel for
-     AGP support, etc.  See section 10 for specifics.
-
-   o You DO NOT need to install Mesa separately.  The parts of Mesa needed
-     for hardware acceleration are already in the XFree86/DRI project.
-
-5.  Kernel Modules
-
-3D hardware acceleration requires a DRI kernel module that's specific to your
-graphics hardware.
-
-The DRI kernel module version must exactly match your running kernel version.
-Since there are so many versions of the kernel, it's difficult to provide
-precompiled kernel modules.
-
-While the Linux source tree includes the DRI kernel module sources, the lat-
-est DRI kernel sources will be found in the DRI source tree.
-
-See the DRI Compilation Guide for information on compiling the DRI kernel
-modules.
-
-XFree86 4.0.1 added automatic kernel module loading to the X server.  On
-Linux, the X server uses modprobe to load kernel modules.  In Linux 2.4.x the
-DRM kernel modules should be kept in /lib/modules/2.4.x/ker-
-nel/drivers/char/drm/ for automatic loading to work.
-
-Optionally, DRM kernel modules can be loaded manually with insmod prior to
-starting the X server.
-
-You can verify that the kernel module was installed with lsmod, checking the
-X server startup log, and checking that /proc/dri/0 exists.
-
-6.  XF86Config file
-
-The XFree86 configuration file is usually found in /etc/X11/XF86Config.  This
-section describes the parts which must be specially set for the DRI.
-
-First, the XF86Config file must load the GLX and DRI modules:
-
-          Section "Module"
-          ...
-          # This loads the GLX module
-              Load       "glx"
-          # This loads the DRI module
-              Load       "dri"
-          EndSection
-
-Next, the DRI section can be used to restrict access to direct rendering.  A
-client can only use direct rendering if it has permission to open the
-/dev/dri/card? file(s).  The permissions on these DRI device files is con-
-trolled by the "DRI" section in the XF86Config file.
-
-If you want all of the users on your system to be able to use direct-render-
-ing, then use a simple DRI section like this:
-
-          Section "DRI"
-               Mode 0666
-          EndSection
-
-This section will allow any user with a current connection to the X server to
-use direct rendering.
-
-If you want to restrict the use of direct-rendering to a certain group of
-users, then create a group for those users by editing the /etc/group file on
-your system.  For example, you may want to create a group called xf86dri and
-place two users (e.g., fred and jane) in that group.  To do that, you might
-add the following line to /etc/group:
-
-             xf86dri:x:8000:fred,jane
-
-You have to be careful that the group id (8000 in this example) is unique.
-
-Then you would use the following DRI section:
-
-             Section "DRI"
-                  Group "xf86dri"
-                  Mode 0660
-             EndSection
-
-This would limit access to direct-rendering to those users in the xf86dri
-group (fred and jane in this example).  When other users tried to use direct
-rendering, they would fall back to unaccelerated indirect rendering.
-
-[Note that there is a known bug in XFree86 4.0 that prevents some changes to
-the DRI section from taking effect.  Until this bug is fixed, if you change
-the DRI section, please also remove the /dev/dri directory with the rm -rf
-/dev/dri command.]
-
-Finally, the XF86Config file needs Device and Screen sections specific to
-your hardware.  Look in section 10: Hardware-Specific Information and Trou-
-bleshooting for details.
-
-7.  Memory usage
-
-Using the 3D features of a graphics card requires more memory than when it's
-just used as a 2D device.  Double buffering, depth buffering, stencil
-buffers, textures, etc. all require extra graphics memory.  These features
-may require four times the memory used for a simple 2D display.
-
-If your graphics card doesn't have a lot of memory (less than 16MB, for exam-
-ple), you may have to reduce your screen size and/or color depth in order to
-use 3D features.  Reducing the screen resolution will also leave more space
-for texture images, possibly improving 3D performance.  If, for example, you
-play Quake3 at 1024x768 but start your display at 1600x1200 you might con-
-sider restarting X at 1024x768 in order to maximize your texture memory
-space.
-
-The documentation included with your card should have information about maxi-
-mum screen size when using 3D.
-
-8.  Using 3D Acceleration
-
-This section describes how to link your application with libGL.so and verify
-that you are in fact using 3D acceleration.
-
-8.1  libGL.so
-
-Your OpenGL program must link with the libGL.so.1.2 library provided by
-XFree86.  The libGL.so.1.2 library contains a GLX protocol encoder for indi-
-rect/remote rendering and DRI code for accessing hardware drivers.  In par-
-ticular, be sure you're not using libGL.so from another source such as Mesa
-or the Utah GLX project.
-
-Unless it was built in a special way, the libGL.so library does not contain
-any 3D hardware driver code.  Instead, libGL.so dynamically loads the appro-
-priate 3D driver during initialization.
-
-Most simple OpenGL programs also use the GLUT and GLU libraries.  A source
-for these libraries is listed in the Resources section below.
-
-8.2  Compiling and linking an OpenGL program
-
-A simple GLUT/OpenGL program may be compiled and linked as follows:
-
-             gcc program.c -I/usr/local/include -L/usr/local/lib -L/usr/X11R6/lib -lglut -lGLU -lGL -o program
-
-The -I option is used to specify where the GL/glut.h (and possibly the
-GL/gl.h and GL/glu.h) header file may be found.
-
-The -L options specify where the libglut.so and the X libraries are located.
-libGL.so and libGLU.so should be in /usr/lib, as specified by the
-Linux/OpenGL ABI standard.
-
-The -lglut -lGLU -lGL arguments specify that the application should link with
-the GLUT, GLU and GL libraries, in that order.
-
-8.3  Running your OpenGL program
-
-Simply typing ./program in your shell should execute the program.
-
-If you get an error message such as
-
-             gears: error in loading shared libraries: libGL.so.1: cannot
-             open shared object file: No such file or directory
-
-if means that the libGL.so.1 file is not the right location.  Proceed to the
-trouble shooting section.
-
-8.4  libOSMesa.so
-
-OSMesa (Off-Screen Mesa) is an interface and driver for rendering 3D images
-into a user-allocated block of memory rather than an on-screen window.  It
-was originally developed for Mesa before Mesa became part of the XFree86/DRI
-project.  It can now be used with the XFree86/DRI libGL.so as well.
-
-libOSMesa.so implements the OSMesa interface and it must be linked with your
-application if you want to use the OSMesa functions.  You must also link with
-libGL.so.  For example:
-
-             gcc osdemo.c -lOSMesa -lGLU -lGL -o osdemo
-
-In stand-alone Mesa this interface was compiled into the monolithic libGL.so
-(formerly libMesaGL.so) library.  In XFree86 4.0.1 and later this interface
-is implemented in a separate library.
-
-8.5  glxinfo
-
-glxinfo is a useful program for checking which version of libGL you're using
-as well as which DRI-based driver.  Simply type glxinfo and examine the
-OpenGL vendor, renderer, and version lines.  Among the output you should see
-something like this:
-
-               OpenGL vendor string: VA Linux Systems, Inc.
-               OpenGL renderer string: Mesa DRI Voodoo3 20000224
-               OpenGL version string: 1.2 Mesa 3.4
-
-or this:
-
-               OpenGL vendor string: VA Linux Systems, Inc.
-               OpenGL renderer string: Mesa GLX Indirect
-               OpenGL version string: 1.2 Mesa 3.4
-
-The first example indicates that the 3dfx driver is using Voodoo3 hardware.
-The second example indicates that no hardware driver was found and indirect,
-unaccelerated rendering is being used.
-
-If you see that indirect rendering is being used when direct rendering was
-expected, proceed to the troubleshooting section.
-
-glxinfo also lists all of the GLX-enhanced visuals available so you can
-determine which visuals are double-bufferd, have depth (Z) buffers, stencil
-buffers, accumulation buffers, etc.
-
-8.6  Environment Variables
-
-The libGL.so library recognizes three environment variables.  Normally, none
-of them need to be defined.  If you're using the csh or tcsh shells, type
-setenv VARNAME value to set the variable.  Otherwise, if you're using sh or
-bash, type export VARNAME=value.
-
-  1.  LIBGL_DEBUG, if defined will cause libGL.so to print error and diagnos-
-      tic messages.  This can help to solve problems.  Setting LIBGL_DEBUG to
-      verbose may provide additional information.
-
-  2.  LIBGL_ALWAYS_INDIRECT, if defined this will force libGL.so to always
-      use indirect rendering instead of hardware acceleration.  This can be
-      useful to isolate rendering errors.
-
-  3.  LIBGL_DRIVERS_PATH can be used to override the default directories
-      which are searched for 3D drivers.  The value is one or more paths sep-
-      arated by colons.  In a typical XFree86 installation, the 3D drivers
-      should be in /usr/X11R6/lib/modules/dri/ and LIBGL_DRIVERS_PATH need
-      not be defined.  Note that this feature is disabled for set-uid pro-
-      grams.  This variable replaces the LIBGL_DRIVERS_DIR env var used in
-      XFree86 4.0.
-
-  4.  MESA_DEBUG, if defined, will cause Mesa-based 3D drivers to print user
-      error messages to stderr.  These are errors that you'd otherwise detect
-      by calling glGetError.
-
-Mesa-based drivers (this includes most of the drivers listed above) also
-observe many of the existing Mesa environment variables.  These include the
-MESA_DEBUG and MESA_INFO variables.
-
-9.  General Trouble Shooting
-
-This section contains information to help you diagnose general problems.  See
-below for additional information for specific hardware.
-
-9.1  Bus Mastering
-
-DMA-based DRI drivers (that's most DRI drivers) cannot function unless bus
-mastering is enabled for your graphics card.  By default, some systems don't
-having bus mastering on.  You should enable it in your BIOS.
-
-Alternately, you can check the status of bus mastering and change the setting
-from within Linux.  There may be similar procedures for other operating sys-
-tems.
-
-Run lspci (as root) and find the information describing your graphics
-adapter.  For example:
-
-         00:00.0 Host bridge: Intel Corporation 440BX/ZX - 82443BX/ZX Host bridge (rev 03)
-         00:01.0 PCI bridge: Intel Corporation 440BX/ZX - 82443BX/ZX AGP bridge (rev 03)
-         00:07.0 ISA bridge: Intel Corporation 82371AB PIIX4 ISA (rev 02)
-         00:07.1 IDE interface: Intel Corporation 82371AB PIIX4 IDE (rev 01)
-         00:07.2 USB Controller: Intel Corporation 82371AB PIIX4 USB (rev 01)
-         00:07.3 Bridge: Intel Corporation 82371AB PIIX4 ACPI (rev 02)
-         00:11.0 Ethernet controller: Intel Corporation 82557 [Ethernet Pro 100] (rev 08)
-         00:12.0 SCSI storage controller: Symbios Logic Inc. (formerly NCR) 53c895 (rev 02)
-         00:14.0 Multimedia audio controller: Ensoniq ES1371 [AudioPCI-97] (rev 08)
-         01:00.0 VGA compatible controller: 3Dfx Interactive, Inc.: Unknown device 0009 (rev 01)
-
-The bus, device, and function number comprise the device id, which is conven-
-tionally written in the form bus:dev.func, or in this case 01:00.0.
-
-Use the setpci command to examine bit two of register 4 for your graphics
-card.  This will indicate whether or not bus mastering is enabled.
-
-             setpci -s 01:00.0 4.w
-
-A hexadecimal value will be printed.  Convert the least significant digit to
-binary.  For example, if you see 3, that's 0011 in binary (bit two is 0).  If
-you see 7, that's 0111 in binary (bit two is 1).  In the first example, bus
-mastering is disabled.  It's enabled in the second example.
-
-The following shell script will enabled bus mastering for your graphics card
-and host bridge.  Run it as root.
-
-         #!/bin/bash
-         dev=01:00.0   # change as appropriate
-         echo Enabling bus mastering on device $dev
-         setpci -s $dev 4.w=$(printf %x $((0x$(setpci -s $dev 4.w)|4)))
-         dev=00:00.0
-         echo Enabling bus mastering on host bridge $dev
-         setpci -s $dev 4.w=$(printf %x $((0x$(setpci -s $dev 4.w)|4)))
-
-You can check if this worked by running the first setpci command again.
-
-9.2  The X Server
-
-  1.  Before you start the X server, verify the appropriate 3D kernel module
-      is installed.  Type lsmod and look for the appropriate kernel module.
-      For 3dfx hardware you should see tdfx, for example.
-
-  2.  Verify you're running XFree86 4.0 (or newer) and not an older version.
-      If you run xdpyinfo and look for the following line near the top:
-
-                       vendor release number:    4000
-
-  3.  Verify that your XF86Config file (usually found at /etc/X11/XF86Config)
-      loads the glx and dri modules and has a DRI section.
-
-      See the Software Resources section below for sample XF86Config files.
-
-  4.  Examine the messages printed during X server startup and check that the
-      DRM module loaded.  Using the Voodoo3 as an example:
-
-                   (==) TDFX(0): Write-combining range (0xf0000000,0x2000000)
-                   (II) TDFX(0): Textures Memory 7.93 MB
-                   (0): [drm] created "tdfx" driver at busid "PCI:1:0:0"
-                   (0): [drm] added 4096 byte SAREA at 0xc65dd000
-                   (0): [drm] mapped SAREA 0xc65dd000 to 0x40013000
-                   (0): [drm] framebuffer handle = 0xf0000000
-                   (0): [drm] added 1 reserved context for kernel
-                   (II) TDFX(0): [drm] Registers = 0xfc000000
-                   (II) TDFX(0): visual configs initialized
-                   (II) TDFX(0): Using XFree86 Acceleration Architecture (XAA)
-                           Screen to screen bit blits
-                           Solid filled rectangles
-                           8x8 mono pattern filled rectangles
-                           Indirect CPU to Screen color expansion
-                           Solid Lines
-                           Dashed Lines
-                           Offscreen Pixmaps
-                           Driver provided NonTEGlyphRenderer replacement
-                           Setting up tile and stipple cache:
-                                   10 128x128 slots
-                   (==) TDFX(0): Backing store disabled
-                   (==) TDFX(0): Silken mouse enabled
-                   (0): X context handle = 0x00000001
-                   (0): [drm] installed DRM signal handler
-                   (0): [DRI] installation complete
-                   (II) TDFX(0): direct rendering enabled
-
-  5.  After the X server has started, verify that the required X server
-      extensions are loaded.  Run xdpyinfo and look for the following entries
-      in the extensions list:
-
-                  GLX
-                  SGI-GLX
-                  XFree86-DRI
-
-9.3  Linking, running and verifying 3D acceleration
-
-After you've verified that the X server and DRI have started correctly it's
-time to verify that the GL library and hardware drivers are working cor-
-rectly.
-
-  1.  Verify that you're using the correct libGL.so library with ldd.  The
-      /usr/lib and /usr/X11R6/lib directories are expected locations for
-      libGL.so.
-
-      Example:
-
-                   % ldd /usr/local/bin/glxinfo
-                           libglut.so.3 => /usr/local/lib/libglut.so.3 (0x40019000)
-                           libGLU.so.1 => /usr/local/lib/libGLU.so.1 (0x40051000)
-                           libGL.so.1 => /usr/lib/libGL.so.1 (0x40076000)
-                           libXmu.so.6 => /usr/X11R6/lib/libXmu.so.6 (0x402ee000)
-                           libXi.so.6 => /usr/X11R6/lib/libXi.so.6 (0x40301000)
-                           libm.so.6 => /lib/libm.so.6 (0x40309000)
-                           libc.so.6 => /lib/libc.so.6 (0x40325000)
-                           libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x40419000)
-                           libXt.so.6 => /usr/X11R6/lib/libXt.so.6 (0x404bd000)
-                           libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0x40509000)
-                           libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0x40512000)
-                           libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x40529000)
-                           libvga.so.1 => /usr/lib/libvga.so.1 (0x40537000)
-                           libpthread.so.0 => /lib/libpthread.so.0 (0x4057d000)
-                           /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
-
-  2.  You may also double check that libGL.so is in fact DRI-capable.  Run
-      strings libGL.so.1.2 | grep DRI and look for symbols prefixed with
-      "XF86DRI", such as "XF86DRIQueryExtension".
-
-  3.  To be safe one should run ldconfig after installing libGL.so to be sure
-      the runtime loader will find the proper library.
-
-  4.  Verify that the appropriate 3D driver is in /usr/X11R6/lib/modules/dri/
-      For example, the 3dfx driver will be named tdfx_dri.so.
-
-  5.  Set the LIBGL_DEBUG environment variable.  This will cause libGL.so to
-      print an error message if it fails to load a DRI driver.  Any error
-      message printed should be self-explanatory.
-
-  6.  Run glxinfo.  Note the line labeled "OpenGL renderer string".  It
-      should have a value which starts with "Mesa DRI" followed by the name
-      of your hardware.
-
-  7.  Older Linux OpenGL applications may have been linked against Mesa's GL
-      library and will not automatically use libGL.so.  In some cases, making
-      symbolic links from the Mesa GL library to libGL.so.1 will solve the
-      problem:
-
-                   ln -s libGL.so.1 libMesaGL.so.3
-
-      In other cases, the application will have to be relinked against the
-      new XFree86 libGL.so.
-
-      It is reported that part of the problem is that running ldconfig will
-      silently rewrite symbolic links based on the SONAME field in libraries.
-
-If you're still having trouble, look in the next section for information spe-
-cific to your graphics card.
-
-10.  Hardware-Specific Information and Troubleshooting
-
-This section presents hardware-specific information for normal use and trou-
-bleshooting.
-
-10.1  3dfx Banshee, Voodoo3, Voodoo4 and Voodoo5 Series
-
-10.1.1  Requirements
-
-The 3dfx DRI driver requires special versions of the 3dfx Glide library.
-Different versions of Glide are needed for Banshee/Voodoo3 than for
-Voodoo4/5.  The Glide libraries can be downloaded from the DRI website.
-
-10.1.2  Configuration
-
-Your XF86Config file's device section must specify the tdfx device.  For
-example:
-
-             Section "Device"
-                 Identifier  "Voodoo3"
-                 VendorName  "3dfx"
-                 Driver      "tdfx"
-             EndSection
-
-Or,
-
-             Section "Device"
-                 Identifier  "Voodoo5"
-                 VendorName  "3dfx"
-                 Driver      "tdfx"
-             EndSection
-
-The Screen section should then reference the Voodoo device:
-
-          Section "Screen"
-              Identifier  "Screen 1"
-              Device      "Voodoo3"
-              Monitor     "High Res Monitor"
-              DefaultDepth 16
-              Subsection "Display"
-               Depth       16
-               Modes       "1280x1024" "1024x768" "800x600" "640x480"
-               ViewPort    0 0
-              EndSubsection
-             EndSection
-
-Or,
-
-          Section "Screen"
-              Identifier  "Screen 1"
-              Device      "Voodoo5"
-              Monitor     "High Res Monitor"
-              DefaultDepth 24
-              Subsection "Display"
-               Depth       16
-               Modes       "1280x1024" "1024x768" "800x600" "640x480"
-               ViewPort    0 0
-              EndSubsection
-              Subsection "Display"
-               Depth       24
-               Modes       "1280x1024" "1024x768" "800x600" "640x480"
-               ViewPort    0 0
-              EndSubsection
-             EndSection
-
-The kernel module for 3dfx hardware is named tdfx.o and should be installed
-in /lib/modules/2.4.x/kernel/drivers/char/drm/.  It will be automatically
-loaded by the Xserver if needed.
-
-The DRI 3D driver for 3dfx hardware should be in /usr/X11R6/lib/mod-
-ules/dri/tdfx_dri.so.  This will be automatically loaded by libGL.so.
-
-The Voodoo5 supports 3D rendering in 16 and 32 bpp modes.  When running in
-32bpp mode an 8-bit stencil buffer and 24-bit Z (depth) buffer are offered.
-When running in 16bpp mode only a 16-bit Z (depth) buffer is offered and
-stencil is implemented in software.
-
-A software-based accumulation buffer is available in both 16 and 32bpp modes.
-
-10.1.3  Troubleshooting
-
-   o If you try to run an OpenGL application and see an error message similar
-     to
-
-                gd error (glide): gd error (glide): grSstSelect:  non-existent SSTgd error (glide): grSstSelect:  non-existent SSTS
-
-     it means that you have the wrong version of the Glide library for your
-     hardware.
-
-   o 3D acceleration for Banshee and Voodoo3 is only supported in the 16
-     bit/pixel screen mode.  Use xdpyinfo to verify that all your visuals are
-     depth 16.  Edit your XF86Config file if needed.
-
-   o The /dev/3dfx device is not used for DRI; it's only for Glide on older
-     3dfx hardware.
-
-   o Different versions of Glide are needed for Voodoo3 and Voodoo5.  See the
-     DRI website's resources page to download the right version of Glide.
-
-   o Voodoo4/5 may be run at 24bpp (instead of 32bpp, the default) but 3D
-     acceleration is not supported in that mode.  32bpp mode is fully 3D
-     accelerated.
-
-10.1.4  Performance and Features
-
-   o Normally, buffer swapping in double-buffered applications is synchro-
-     nized to your monitor's refresh rate.  This may be overridden by setting
-     the FX_GLIDE_SWAPINTERVAL environment variable.  The value of this vari-
-     able indicates the maximum number of swap buffer commands can be
-     buffered.  Zero allows maximum frame rate.
-
-   o On Voodoo4/5, rendering with 16-bits/texel textures is faster than using
-     32-bit per texel textures.  The internalFormat parameter to glTexImage2D
-     can be used to control texel size.  Quake3 and other games let you con-
-     trol this as well.
-
-   o The glTexEnv mode GL_BLEND is not directly supported by the Voodoo3
-     hardware.  It can be accomplished with a multipass algorithm but it's
-     not implemented at this time.  Applications which use that mode, such as
-     the Performer Town demo, may become sluggish when falling back to soft-
-     ware rendering to render in that mode.
-
-   o The Voodoo3/Banshee driver reverts to software rendering under the fol-
-     lowing conditions:
-
-        o Setting GL_LIGHT_MODEL_COLOR_CONTROL to GL_SEPARATE_SPECULAR_COLOR.
-
-        o Enabling line stippling or polygon stippling.
-
-        o Enabling point smoothing or polygon smoothing.
-
-        o Enabling line smoothing when line width is not 1.0.  That is,
-          antialiased lines are done in hardware only when the line width is
-          1.0.
-
-        o Using 1-D or 3-D texture maps.
-
-        o Using the GL_BLEND texture environment.
-
-        o Using stencil operations.
-
-        o Using the accumulation buffer.
-
-        o Using glBlendEquation(GL_LOGIC_OP).
-
-        o Using glDrawBuffer(GL_FRONT_AND_BACK).
-
-        o Using glPolygonMode(face, GL_POINT) or glPolygonMode(face,
-          GL_LINE).
-
-        o Using point size attenuation (i.e. GL_DISTANCE_ATTENUATION_EXT).
-
-        o Using glColorMask(r, g, b, a) when r!=g or g!=b.
-
-   o The Voodoo5 driver reverts to software rendering under the same condi-
-     tions Voodoo3 with three exceptions.  First, stencil operations are
-     implemented in hardware when the screen is configured for 32 bits/pixel.
-     Second, the GL_BLEND texture env mode is fully supported in hardware.
-     Third, glColorMask is fully supported in hardware when the screen is
-     configured for 32 bits/pixel.
-
-   o As of January, 2001 the second VSA-100 chip on the Voodoo5 is not yet
-     operational.  Therefore, the board isn't being used to its full capac-
-     ity.  The second VSA-100 chip will allow Scan-Line Interleave (SLI) mode
-     for full-screen applications and games, potentially doubling the sys-
-     tem's fill rate.  When the second VSA-100 chip is activated glGet-
-     String(GL_RENDERER) will report Voodoo5 instead of Voodoo4.
-
-   o The lowest mipmap level is sometimes miscolored in trilinear- sampled
-     polygons.
-
-   o The GL_EXT_texture_env_combine extension is supported on the Voodoo4 and
-     Voodoo5.
-
-10.1.5  Known Problems
-
-   o The lowest mipmap level is sometimes miscolored in trilinear- sampled
-     polygons (Voodoo3/Banshee).
-
-   o Fog doesn't work with orthographic projections.
-
-   o The accuracy of blending operations on Voodoo4/5 isn't always very good.
-     If you run Glean, you'll find some test failures.
-
-   o The Glide library cannot be used directly; it's only meant to be used
-     via the tdfx DRI driver.
-
-   o SSystem has problems because of poorly set near and far clipping planes.
-     The office.unc Performer model also suffers from this problem.
-
-10.2  Intel i810
-
-10.2.1  Requirements
-
-A kernel with AGP GART support (such as Linux 2.4.x) is needed.
-
-10.2.2  Configuration
-
-Your XF86Config file's device section must specify the i810 device, and spec-
-ify a usable amount of video ram to reserve.
-
-             Section "Device"
-                 Identifier  "i810"
-                 VendorName  "Intel"
-                 Driver      "i810"
-              Option     "AGPMode" "1"
-              VideoRam    10000
-             EndSection
-
-The Screen section should then reference the i810 device:
-
-          Section "Screen"
-              Identifier  "Screen 1"
-              Device      "i810"
-              Monitor     "High Res Monitor"
-              DefaultDepth 16
-              Subsection "Display"
-               Depth       16
-               Modes       "1280x1024" "1024x768" "800x600" "640x480"
-               ViewPort    0 0
-              EndSubsection
-             EndSection
-
-The kernel module for the i810 is named i810.o and should be installed in
-/lib/modules/2.4.x/kernel/drivers/char/drm/.  It will be automatically loaded
-by the Xserver if needed.
-
-The DRI 3D driver for the i810 should be in /usr/X11R6/lib/mod-
-ules/dri/i810_dri.so.  This will be automatically loaded by libGL.so.
-
-10.2.3  Troubleshooting
-
-   o 3D acceleration for the i810 is only available in the 16 bit/pixel
-     screen mode at this time.  32bpp acceleration is not supported by this
-     hardware.  Use xdpyinfo to verify that all your visuals are depth 16.
-     Edit your XF86Config file if needed.
-
-   o The i810 uses system ram for video and 3d graphics.  The X server will
-     ordinarily reserve 4mb of ram for graphics, which is too little for an
-     effective 3d setup.  To tell the driver to use a larger amount, specify
-     a VideoRam option in the Device section of your XF86Config file.  A num-
-     ber between 10000 and 16384 seems adequate for most requirements.  If
-     too little memory is available for DMA buffers, back and depth buffers
-     and textures, direct rendering will be disabled.
-
-10.2.4  Performance and Features
-
-Basically all of the i810 features which can be exposed through OpenGL 1.2
-are implemented.  However, the following OpenGL features are implemented in
-software and will be slow:
-
-   o Stencil buffer and accumulation buffer operations
-
-   o Blend subtract, min/max and logic op blend modes
-
-   o glColorMask when any mask is set to false
-
-   o GL_SEPARATE_SPECULAR_COLOR lighting mode
-
-   o glDrawBuffer(GL_FRONT_AND_BACK)
-
-   o Using 1D or 3D textures
-
-   o Using texture borders
-
-10.3  Matrox G200 and G400
-
-10.3.1  Requirements
-
-A kernel with AGP GART support (such as Linux 2.4.x) is needed.
-
-10.3.2  Configuration
-
-Your XF86Config file's device section must specify the mga device:
-
-             Section "Device"
-                 Identifier  "MGA"
-                 VendorName  "Matrox"
-                 Driver      "mga"
-              Option     "AGPMode" "1"
-              VideoRam    32768
-             EndSection
-
-The Screen section should then reference the MGA device:
-
-          Section "Screen"
-              Identifier  "Screen 1"
-              Device      "MGA"
-              Monitor     "High Res Monitor"
-              DefaultDepth 16
-              Subsection "Display"
-               Depth       16
-               Modes       "1280x1024" "1024x768" "800x600" "640x480"
-               ViewPort    0 0
-              EndSubsection
-             EndSection
-
-To use a 32bpp screen mode, use this Screen section instead:
-
-          Section "Screen"
-              Identifier  "Screen 1"
-              Device      "MGA"
-              Monitor     "High Res Monitor"
-              DefaultDepth 24
-                 DefaultFbBpp 32
-              Subsection "Display"
-               Depth       24
-               Modes       "1280x1024" "1024x768" "800x600" "640x480"
-               ViewPort    0 0
-              EndSubsection
-             EndSection
-
-The kernel module for the G200/G400 is named mga.o and should be installed in
-/lib/modules/2.4.x/kernel/drivers/char/drm/.  It will be automatically loaded
-by the Xserver if needed.
-
-The DRI 3D driver for the G200/G400 should be in /usr/X11R6/lib/mod-
-ules/dri/mga_dri.so.  This will be automatically loaded by libGL.so.
-
-10.3.3  Performance and Features
-
-Software rendering will be used under any of the following conditions:
-
-   o Using glDrawBuffer(GL_FRONT_AND_BACK).
-
-   o Using point, line, or triangle smoothing.
-
-   o Using glLogicOp.
-
-   o Using glPolygonStipple or glLineStipple.
-
-   o Using 1D or 3D textures.
-
-   o Using texture borders.
-
-   o Using glDepthFunc(GL_NEVER).
-
-   o Using the accumulation buffer.
-
-The AGP mode may be set to 1, 2, or 4.  One is used by default.  Higher AGP
-speeds may result in unreliable performance depending on your motherboard.
-
-Compaq has funded the implementation of AGP accelerated ReadPixels and Draw-
-Pixels in this driver.  With this implementation, on a G400 drawing directly
-from AGP memory (exported to the client), throughput of up to 1 GB/sec has
-been measured.
-
-Additionally Compaq's funding has produced several new extensions in Mesa,
-including one (packed_depth_stencil_MESA) which enables Read/DrawPixels func-
-tionality to operate directly on the packed 24/8 depth/stencil buffers of
-this hardware.
-
-In order to access this functionality, the application must ensure that all
-pixel processing operations are disabled.  There are in addition a fairly
-complex set of rules regarding which packing/unpacking modes must be used,
-and which data formats are supported, and alignment constraints.  See the
-files in lib/GL/mesa/src/drv/mga/DOCS for a summary of these.  The extension
-definitions are included in the Mesa 3.4 source distribution.
-
-10.3.4  IRQ Assignment
-
-There have been problems in the past with the MGA driver being very sluggish
-when the DRI is enabled (to the point of being unusable.)  This is caused by
-the graphics card not having an interrupt assigned to it.  The current DRI
-trunk will attempt to detect this condition and bail out gracefully.
-
-The solution to the above problem is to assign an interrupt to your graphics
-card.  This is something you must turn on in your system BIOS configuration.
-Please consult your system BIOS manual for instructions on how to enable an
-interrupt for your graphics card.
-
-10.3.5  MGA HAL lib
-
-MGAHALlib.a is a binary library Matrox has provided for use under Linux to
-expose functionality for which they can not provide documentation.  (For
-example TV-Out requires MacroVision be enabled on the output.)  This binary
-library also sets the pixel/memory clocks to the optimal settings for your
-Matrox card.
-
-Currently the MGAHAL library is required for the G450 to work.  You can down-
-load this from the driver section on Matrox's website: www.matrox.com/mga
-
-Here modifications to the DRI build instructions which make the mga ddx
-driver use the MGAHAL library:
-
-            1.Put the following define in your host.def file
-                 #define UseMatroxHal YES
-            2. Place mgaHALlib.a in the following directory
-                 xc/programs/Xserver/hw/xfree86/drivers/mga/HALlib/
-
-You can use DualHead on the G400/G450 DH cards by creating two device sec-
-tions which both point to the same BusID.  For most AGP devices the BusID
-will be "PCI:1:0:0".  Configure your screen section as you would normally
-configure XFree86 4.x Multihead.  It should be noted that currently the sec-
-ond head does not support direct rendering.
-
-10.3.6  Known Problems
-
-None.
-
-10.4  ATI Rage 128
-
-10.4.1  Requirements
-
-A kernel with AGP GART support (such as Linux 2.4.x) is needed.
-
-10.4.2  Configuration
-
-Your XF86Config file's device section must specify the ati device:
-
-             Section "Device"
-                 Identifier  "Rage128"
-                 VendorName  "ATI"
-                 Driver      "ati"
-              Option     "AGPMode" "1"
-              Option     "UseCCEFor2D" "false"
-             EndSection
-
-The Screen section should then reference the Rage 128 device:
-
-          Section "Screen"
-              Identifier  "Screen 1"
-              Device      "Rage128"
-              Monitor     "High Res Monitor"
-              DefaultDepth 16
-              Subsection "Display"
-               Depth       16
-               Modes       "1280x1024" "1024x768" "800x600" "640x480"
-               ViewPort    0 0
-              EndSubsection
-              Subsection "Display"
-               Depth       32
-               Modes       "1280x1024" "1024x768" "800x600" "640x480"
-               ViewPort    0 0
-              EndSubsection
-             EndSection
-
-The kernel module for the Rage 128 is named r128.o and should be installed in
-/lib/modules/2.4.x/kernel/drivers/char/drm/.  It will be automatically loaded
-by the Xserver if needed.
-
-The DRI 3D driver for the Rage 128 should be in /usr/X11R6/lib/mod-
-ules/dri/r128_dri.so.  This will be automatically loaded by libGL.so.
-
-You may also set your screen depth to 32 for 32bpp mode.
-
-10.4.3  Performance and Features
-
-While PCI Rage 128 based cards are supported, they do not yet support PCI
-GART, so they will not perform as well as their AGP counterparts.
-
-For AGP cards, the AGP mode may be set to 1, 2, or 4.  One is used by
-default.  Higher AGP speeds may result in unreliable performance depending on
-your motherboard.
-
-Note that even at 32bpp there is no alpha channel.
-
-The following OpenGL features are implemented in software and will be slow:
-
-   o accumulation buffer operations
-
-   o stencil, when using a 16bpp screen
-
-   o Blend subtract, min/max and logic op blend modes
-
-   o GL_SEPARATE_SPECULAR_COLOR lighting mode
-
-   o glDrawBuffer(GL_FRONT_AND_BACK)
-
-   o Using 1D or 3D textures
-
-   o Using texture borders
-
-10.4.4  Known Problems
-
-If you experience stability problems you may try setting the UseCCEFor2D
-option to true.  This will effectively disable 2D hardware acceleration.
-Performance will be degraded, of course.
-
-10.5  ATI Radeon
-
-10.5.1  Requirements
-
-A kernel with AGP GART support (such as Linux 2.4.x) is needed.
-
-10.5.2  Configuration
-
-Your XF86Config file's device section must specify the ati device:
-
-             Section "Device"
-                 Identifier  "Radeon"
-                 VendorName  "ATI"
-                 Driver      "ati"
-              Option     "AGPMode" "1"
-             EndSection
-
-The Screen section should then reference the Radeon device:
-
-          Section "Screen"
-              Identifier  "Screen 1"
-              Device      "Radeon"
-              Monitor     "High Res Monitor"
-              DefaultDepth 16
-              Subsection "Display"
-               Depth       16
-               Modes       "1280x1024" "1024x768" "800x600" "640x480"
-               ViewPort    0 0
-              EndSubsection
-              Subsection "Display"
-               Depth       32
-               Modes       "1280x1024" "1024x768" "800x600" "640x480"
-               ViewPort    0 0
-              EndSubsection
-             EndSection
-
-The kernel module for the Radeon is named radeon.o and should be installed in
-/lib/modules/2.4.x/kernel/drivers/char/drm/.  It will be automatically loaded
-by the Xserver if needed.
-
-The DRI 3D driver for the Radeon should be in /usr/X11R6/lib/mod-
-ules/dri/radeon_dri.so.  This will be automatically loaded by libGL.so.
-
-You may also set your screen depth to 32 for 32bpp mode.
-
-10.5.3  Performance and Features
-
-While this driver supports many of the features of ATI Radeon cards, we do
-not yet fully support the card's TCL features.  This work is progressing, but
-is not yet ready.
-
-The AGP mode may be set to 1, 2, or 4.  One is used by default.  Higher AGP
-speeds may result in unreliable performance depending on your motherboard.
-
-The following OpenGL features are implemented in software and will be slow:
-
-   o Blend subtract, blend min/max and blend logicops
-
-   o Stencil and accumulation operations
-
-   o 1D and 3D textures
-
-   o Texture borders
-
-The GL_EXT_texture_env_combine, GL_EXT_texture_env_add and GL_EXT_tex-
-ture_env_dot3 extensions are supported (or will be soon supported in the new
-driver based on Mesa 3.5).
-
-We hope to implement support for the following features in the future:
-
-   o Vertex transformation, clipping and lighting (TCL)
-
-   o Hardware stencil buffer
-
-   o Cube map textures
-
-   o 3D textures
-
-   o Three texture units
-
-10.5.4  Known Problems
-
-Certain (early?) revisions of the AMD Irongate chipset have AGPGART problems
-which effect Radeon, and other graphics cards.  The card may work unreliably,
-or not work at all.  If the DRM kernel module is not loaded, the 2D Xserver
-may work.  There's hope that this can be fixed in the future.
-
-10.6  3DLabs Oxygen GMX 2000
-
-The driver for this hardware was experimental and is no longer being devel-
-oped or supported.
-
-11.  General Limitations and Known Bugs
-
-11.1  OpenGL
-
-The following OpenGL features are not supported at this time: overlays,
-stereo, hardware-accelerated indirect rendering.
-
-OpenGL-like functionality is provided with the Mesa library.  XFree86 4.1.0
-uses Mesa 3.4.2.  Subsequent releases of XFree86 will use newer versions of
-Mesa.  When newer versions of Mesa are available, the 3D drivers can be
-updated without reinstalling XFree86 or libGL.so.
-
-11.2  GLX
-
-The GLX 1.3 API is exported but none of the new 1.3 functions are opera-
-tional.
-
-The new glXGetProcAddressARB function is fully supported.
-
-GLXPixmap rendering is only supported for indirect rendering contexts.  This
-is a common OpenGL limitation.  Attempting to use a direct rendering context
-with a GLXPixmap will result in an X protocol error.
-
-11.3  Debugging
-
-Debugging DRI drivers with gdb can be difficult because of the locking
-involved.  When debugging OpenGL applications, you should avoid stepping
-inside the GL functions.  If you're trying to debug a DRI driver it's recom-
-mended that you do so remotely, from a second system.
-
-11.4  Scheduling
-
-When you run multiple GL applications at once you may notice poor time slic-
-ing.  This is due to an interaction problem with the Linux scheduler which
-will be addressed in the future.
-
-11.5  libGL.so and dlopen()
-
-A number of popular OpenGL applications on Linux (such as Quake3, HereticII,
-Heavy Gear 2, etc) dynamically open the libGL.so library at runtime with
-dlopen(), rather than linking with -lGL at compile/link time.
-
-If dynamic loading of libGL.so is not implemented carefully, there can be a
-number of serious problems.  Here are the things to be careful of in your
-application:
-
-   o Specify the RTLD_GLOBAL flag to dlopen().  If you don't do this then
-     you'll likely see a runtime error message complaining that _glapi_Con-
-     text is undefined when libGL.so tries to open a hardware-specific
-     driver.  Without this flag, nested opening of dynamic libraries does not
-     work.
-
-   o Do not close the library with dlclose() until after XCloseDisplay() has
-     been called.  When libGL.so initializes itself it registers several
-     callbacks functions with Xlib.  When XCloseDisplay() is called those
-     callback functions are called.  If libGL.so has already been unloaded
-     with dlclose() this will cause a segmentation fault.
-
-   o Your application should link with -lpthread.  On Linux, libGL.so uses
-     the pthreads library in order to provide thread safety.  There is appar-
-     ently a bug in the dlopen()/dlclose() code which causes crashes if the
-     library uses pthreads but the parent application doesn't.  The only
-     known work-around is to link the application with -lpthread.
-
-Some applications don't yet incorporate these procedures and may fail.  For
-example, changing the graphics settings in some video games will expose this
-problem.  The DRI developers are working with game vendors to prevent this
-problem in the future.
-
-11.6  Bug Database
-
-The DRI bug database which includes bugs related to specific drivers is at
-the SourceForge DRI Bug Database
-
-Please scan both the open and closed bug lists to determine if your problem
-has already been reported and perhaps fixed.
-
-12.  Resources
-
-12.1  Software
-
-A collection of useful configuration files, libraries, headers, utilities and
-demo programs is available from http://dri.sourceforge.net/res.phtml
-
-12.2  Documentation
-
-   o General OpenGL information is available at the OpenGL Home Page
-
-   o XFree86 information is available at the XFree86 Home Page
-
-   o Information about the design of the DRI is available from Precision
-     Insight, Inc.
-
-   o Visit the DRI project on SourceForge.net for the latest development news
-     about the DRI and 3D drivers.
-
-   o The DRI Compilation Guide explains how to download, compile and install
-     the DRI for yourself.
-
-12.3  Support
-
-   o The DRI-users mailing list at SourceForge is a forum for people to dis-
-     cuss DRI problems.
-
-   o In the future there may be IHV and Linux vendor support resources for
-     the DRI.
-
-     Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.28 dawes Exp $
-
-
commit 1805c74d9b0ed46802481bcd6beea5feeb60212c
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat May 22 10:29:00 2010 -0700

    Add RandR 1.2 README.modes doc to EXTRA_DIST
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/hw/xfree86/doc/Makefile.am b/hw/xfree86/doc/Makefile.am
index 5809fa0..72bc5d9 100644
--- a/hw/xfree86/doc/Makefile.am
+++ b/hw/xfree86/doc/Makefile.am
@@ -6,4 +6,5 @@ endif
 
 EXTRA_DIST = \
 	README.DRI \
+	README.modes \
 	README.rapidaccess
commit 5939e39a641773a36c22104e1184143678dca7a2
Author: Dave Airlie <airlied at redhat.com>
Date:   Mon May 24 09:31:51 2010 +1000

    xf86: allow for no outputs connected at startup operation.
    
    When nothing is connected at startup and we canGrow, allow the server to start with a 1024x768 framebuffer, and when the drivers send hotplug events this will expand to the correct size dynamically.
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 8b9ec41..065ba48 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -46,6 +46,8 @@
 
 #include "xf86xv.h"
 
+#define NO_OUTPUT_DEFAULT_WIDTH 1024
+#define NO_OUTPUT_DEFAULT_HEIGHT 768
 /*
  * Initialize xf86CrtcConfig structure
  */
@@ -1923,7 +1925,7 @@ xf86SetScrnInfoModes (ScrnInfoPtr scrn)
 #endif
 }
 
-static void
+static Bool
 xf86CollectEnabledOutputs(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
 			  Bool *enabled)
 {
@@ -1938,8 +1940,10 @@ xf86CollectEnabledOutputs(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
 		   "No outputs definitely connected, trying again...\n");
 
 	for (o = 0; o < config->num_output; o++)
-	    enabled[o] = xf86OutputEnabled(config->output[o], FALSE);
+	    any_enabled |= enabled[o] = xf86OutputEnabled(config->output[o], FALSE);
     }
+
+    return any_enabled;
 }
 
 static Bool
@@ -2339,6 +2343,8 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
     Bool		*enabled;
     int			width, height;
     int			i = scrn->scrnIndex;
+    Bool have_outputs = TRUE;
+    Bool ret;
 
     /* Set up the device options */
     config->options = xnfalloc (sizeof (xf86DeviceOptions));
@@ -2364,18 +2370,23 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
     modes = xnfcalloc (config->num_output, sizeof (DisplayModePtr));
     enabled = xnfcalloc (config->num_output, sizeof (Bool));
     
-    xf86CollectEnabledOutputs(scrn, config, enabled);
-
-    if (xf86TargetUserpref(scrn, config, modes, enabled, width, height))
-	xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n");
-    else if (xf86TargetPreferred(scrn, config, modes, enabled, width, height))
-	xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n");
-    else if (xf86TargetAspect(scrn, config, modes, enabled, width, height))
-	xf86DrvMsg(i, X_INFO, "Using fuzzy aspect match for initial modes\n");
-    else if (xf86TargetFallback(scrn, config, modes, enabled, width, height))
-	xf86DrvMsg(i, X_INFO, "Using sloppy heuristic for initial modes\n");
-    else
-	xf86DrvMsg(i, X_WARNING, "Unable to find initial modes\n");
+    ret = xf86CollectEnabledOutputs(scrn, config, enabled);
+    if (ret == FALSE && canGrow) {
+	xf86DrvMsg(i, X_WARNING, "Unable to find connected outputs - setting %dx%d initial framebuffer\n",
+		   NO_OUTPUT_DEFAULT_WIDTH, NO_OUTPUT_DEFAULT_HEIGHT);
+	have_outputs = FALSE;
+    } else {
+	if (xf86TargetUserpref(scrn, config, modes, enabled, width, height))
+	    xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n");
+	else if (xf86TargetPreferred(scrn, config, modes, enabled, width, height))
+	    xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n");
+	else if (xf86TargetAspect(scrn, config, modes, enabled, width, height))
+	    xf86DrvMsg(i, X_INFO, "Using fuzzy aspect match for initial modes\n");
+	else if (xf86TargetFallback(scrn, config, modes, enabled, width, height))
+	    xf86DrvMsg(i, X_INFO, "Using sloppy heuristic for initial modes\n");
+	else
+	    xf86DrvMsg(i, X_WARNING, "Unable to find initial modes\n");
+    }
 
     for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
 	if (!modes[o])
@@ -2406,7 +2417,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
     /*
      * Assign CRTCs to fit output configuration
      */
-    if (!xf86PickCrtcs (scrn, crtcs, modes, 0, width, height))
+    if (have_outputs && !xf86PickCrtcs (scrn, crtcs, modes, 0, width, height))
     {
 	free(crtcs);
 	free(modes);
@@ -2468,6 +2479,13 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
 	 */
 	xf86DefaultScreenLimits (scrn, &width, &height, canGrow);
     
+	if (have_outputs == FALSE) {
+	    if (width < NO_OUTPUT_DEFAULT_WIDTH && height < NO_OUTPUT_DEFAULT_HEIGHT) {
+		width = NO_OUTPUT_DEFAULT_WIDTH;
+		height = NO_OUTPUT_DEFAULT_HEIGHT;
+	    }
+	}
+
 	scrn->display->virtualX = width;
 	scrn->display->virtualY = height;
     }
@@ -2493,8 +2511,17 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
 			      width, height);
     }
 
-    /* Mirror output modes to scrn mode list */
-    xf86SetScrnInfoModes (scrn);
+    if (have_outputs) {
+	/* Mirror output modes to scrn mode list */
+	xf86SetScrnInfoModes (scrn);
+    } else {
+	/* Clear any existing modes from scrn->modes */
+	while (scrn->modes != NULL)
+	    xf86DeleteMode(&scrn->modes, scrn->modes);
+	scrn->modes = xf86ModesAdd(scrn->modes,
+				   xf86CVTMode(width, height, 60, 0, 0));
+    }
+
     
     free(crtcs);
     free(modes);
commit b9f48d60bc0c839bd323c582231e8e7e2b810af6
Author: Jamey Sharp <jamey at minilop.net>
Date:   Wed May 19 10:44:33 2010 -0700

    Device init: Don't crash when CreateGC fails.
    
    ActivateDevice was ignoring errors from DeviceCursorInitialize, so
    cursor-related calls failed later. Jeremy Huddleston saw that crash in
    miPointerConstrainCursor, while with Xvfb I saw it in
    miSpriteRealizeCursor.
    
    miDCDeviceCleanup frees any non-NULL GCs. miDCDeviceInitialize calls
    Cleanup on any failure, but if it failed early then some of the pointers
    in the miDCBufferPtr were garbage. Switch from malloc to calloc to
    ensure everything's initialized safely first.
    
    With these two fixes, if CreateGC fails then the server gracefully fails
    in FatalError instead of segfaulting.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Cc: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/dix/devices.c b/dix/devices.c
index ab8c3f9..cf23bc6 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -463,7 +463,8 @@ ActivateDevice(DeviceIntPtr dev, BOOL sendevent)
 
     /* Initialize memory for sprites. */
     if (IsMaster(dev) && dev->spriteInfo->spriteOwner)
-        pScreen->DeviceCursorInitialize(dev, pScreen);
+        if (!pScreen->DeviceCursorInitialize(dev, pScreen))
+            ret = BadAlloc;
 
     SendDevicePresenceEvent(dev->id, DeviceAdded);
     if (sendevent)
diff --git a/mi/midispcur.c b/mi/midispcur.c
index 61e3133..16495e4 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -742,7 +742,7 @@ miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
     {
         pScreen = screenInfo.screens[i];
 
-        pBuffer = malloc(sizeof(miDCBufferRec));
+        pBuffer = calloc(1, sizeof(miDCBufferRec));
         if (!pBuffer)
             goto failure;
 


More information about the Xquartz-changes mailing list