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

Jeremy Huddleston jeremyhu at freedesktop.org
Sat Jun 2 01:39:30 PDT 2012


 Xext/hashtable.c                        |    4 
 Xi/exevents.c                           |  270 --------------------------------
 Xi/extinit.c                            |    7 
 Xi/stubs.c                              |    1 
 Xi/xiproperty.c                         |    2 
 Xi/xiselectev.c                         |    8 
 config/config-backends.h                |    1 
 config/config.c                         |    9 +
 config/udev.c                           |   16 +
 configure.ac                            |    2 
 dix/devices.c                           |   12 -
 dix/enterleave.c                        |  239 ++++++++++++++++++++++++++++
 dix/enterleave.h                        |    5 
 dix/getevents.c                         |   25 ++
 dix/ptrveloc.c                          |    3 
 exa/exa_glyphs.c                        |    6 
 glx/glxdri.c                            |    2 
 glx/glxdri2.c                           |    2 
 hw/vfb/InitOutput.c                     |    7 
 hw/xfree86/common/xf86.h                |   15 +
 hw/xfree86/common/xf86AutoConfig.c      |    4 
 hw/xfree86/common/xf86Bus.c             |   20 ++
 hw/xfree86/common/xf86Cursor.c          |    9 -
 hw/xfree86/common/xf86DGA.c             |    2 
 hw/xfree86/common/xf86DPMS.c            |    2 
 hw/xfree86/common/xf86Helper.c          |   18 +-
 hw/xfree86/common/xf86Init.c            |    2 
 hw/xfree86/common/xf86Priv.h            |    1 
 hw/xfree86/common/xf86RandR.c           |   15 -
 hw/xfree86/common/xf86VGAarbiter.c      |    8 
 hw/xfree86/common/xf86VGAarbiterPriv.h  |    2 
 hw/xfree86/common/xf86Xinput.c          |   94 +++++++++--
 hw/xfree86/common/xf86cmap.c            |   22 +-
 hw/xfree86/common/xf86fbman.c           |    4 
 hw/xfree86/common/xf86pciBus.c          |   10 -
 hw/xfree86/common/xf86sbusBus.c         |    8 
 hw/xfree86/common/xf86xv.c              |   10 -
 hw/xfree86/common/xf86xvmc.c            |   12 -
 hw/xfree86/doc/ddxDesign.xml            |   27 ---
 hw/xfree86/dri/dri.c                    |   10 -
 hw/xfree86/dri2/dri2.c                  |   41 ++++
 hw/xfree86/dri2/dri2.h                  |   26 ++-
 hw/xfree86/dri2/dri2ext.c               |   36 ++++
 hw/xfree86/exa/examodule.c              |    5 
 hw/xfree86/fbdevhw/fbdevhw.c            |    2 
 hw/xfree86/modes/xf86Crtc.c             |   16 -
 hw/xfree86/modes/xf86Cursors.c          |   10 -
 hw/xfree86/modes/xf86DiDGA.c            |    6 
 hw/xfree86/modes/xf86RandR12.c          |   36 ++--
 hw/xfree86/modes/xf86Rotate.c           |   14 -
 hw/xfree86/ramdac/xf86Cursor.c          |    4 
 hw/xfree86/ramdac/xf86HWCurs.c          |    2 
 hw/xfree86/ramdac/xf86RamDacCmap.c      |    2 
 hw/xfree86/shadowfb/shadow.c            |    4 
 hw/xfree86/utils/man/cvt.man            |    4 
 hw/xfree86/vgahw/vgaCmap.c              |    5 
 hw/xfree86/vgahw/vgaHW.c                |    4 
 hw/xfree86/xaa/xaaInit.c                |   12 -
 hw/xfree86/xaa/xaaInitAccel.c           |    2 
 hw/xfree86/xaa/xaaOverlayDF.c           |    2 
 hw/xfree86/xaa/xaaPCache.c              |    6 
 hw/xfree86/xaa/xaaStateChange.c         |    2 
 include/exevents.h                      |    7 
 include/hotplug.h                       |    1 
 include/ptrveloc.h                      |   15 -
 include/xkbsrv.h                        |    3 
 render/glyph.c                          |   30 ++-
 render/glyphstr.h                       |    6 
 render/render.c                         |    4 
 test/xi2/protocol-common.h              |    4 
 test/xi2/protocol-xipassivegrabdevice.c |    7 
 test/xi2/protocol-xiquerydevice.c       |   16 -
 test/xi2/protocol-xiquerypointer.c      |    7 
 test/xi2/protocol-xiqueryversion.c      |    8 
 test/xi2/protocol-xiselectevents.c      |    1 
 test/xi2/protocol-xisetclientpointer.c  |    1 
 test/xi2/protocol-xiwarppointer.c       |    1 
 77 files changed, 747 insertions(+), 521 deletions(-)

New commits:
commit 78f0d9cdc441a575e15e5f7200ce74750d2f7ad2
Author: Chad Versace <chad.versace at linux.intel.com>
Date:   Wed May 2 16:18:49 2012 -0700

    dri2: Add DRI2GetParam request (v2)
    
    Bump dri2proto dependency to 2.7.
    Bump DRI2INFOREC_VERSION to 7.
    
    This new protocol request effectively allows clients to perform feature
    detection on the DDX. The request was added in DRI2 protocol 1.4.
    
    If I had DRI2GetParam in June 2011, when I was implementing support in the
    Intel DDX and Mesa for new hardware that required a new DRI2 attachment
    format, then I could have avoided a week of pain caused by the necessity
    to write a horrid feature detection hack [1] in Mesa. In the future, when
    the work begins to add MSAA support to the Intel DDX, having a clean way
    to do feature detection will allow us to avoid revisiting and expanding
    that hack.
    
    [1] mesa, commit aea2236a, function intel_verify_dri2_has_hiz
    
    v2: If driver doesn't define ds->GetParam, dont' crash. Fall back to
        default behavior, per keithp.
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Eric Anholt <eric at anholt.net> (v1)
    Reviewed-by: Ian Romanick <idr at freedesktop.org> (v1)
    Signed-off-by: Chad Versace <chad.versace at linux.intel.com>

diff --git a/configure.ac b/configure.ac
index 97ceab1..9ae77fb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -773,7 +773,7 @@ RECORDPROTO="recordproto >= 1.13.99.1"
 SCRNSAVERPROTO="scrnsaverproto >= 1.1"
 RESOURCEPROTO="resourceproto >= 1.2.0"
 DRIPROTO="xf86driproto >= 2.1.0"
-DRI2PROTO="dri2proto >= 2.6"
+DRI2PROTO="dri2proto >= 2.7"
 XINERAMAPROTO="xineramaproto"
 BIGFONTPROTO="xf86bigfontproto >= 1.2.0"
 DGAPROTO="xf86dgaproto >= 2.0.99.1"
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 591ff3a..babf32f 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -107,6 +107,7 @@ typedef struct _DRI2Screen {
     DRI2AuthMagicProcPtr AuthMagic;
     DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
     DRI2SwapLimitValidateProcPtr SwapLimitValidate;
+    DRI2GetParamProcPtr GetParam;
 
     HandleExposuresProcPtr HandleExposures;
 
@@ -1210,6 +1211,11 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
         ds->SwapLimitValidate = info->SwapLimitValidate;
     }
 
+    if (info->version >= 7) {
+        ds->GetParam = info->GetParam;
+        cur_minor = 4;
+    }
+
     /*
      * 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
@@ -1332,3 +1338,38 @@ DRI2Version(int *major, int *minor)
     if (minor != NULL)
         *minor = DRI2VersRec.minorversion;
 }
+
+int
+DRI2GetParam(ClientPtr client,
+             DrawablePtr drawable,
+             CARD64 param,
+             BOOL *is_param_recognized,
+             CARD64 *value)
+{
+    DRI2ScreenPtr ds = DRI2GetScreen(drawable->pScreen);
+    char high_byte = (param >> 24);
+
+    switch (high_byte) {
+    case 0:
+        /* Parameter names whose high_byte is 0 are reserved for the X
+         * server. The server currently recognizes no parameters.
+         */
+        goto not_recognized;
+    case 1:
+        /* Parameter names whose high byte is 1 are reserved for the DDX. */
+        if (ds->GetParam)
+            return ds->GetParam(client, drawable, param,
+                                is_param_recognized, value);
+        else
+            goto not_recognized;
+    default:
+        /* Other parameter names are reserved for future use. They are never
+         * recognized.
+         */
+        goto not_recognized;
+    }
+
+not_recognized:
+    *is_param_recognized = FALSE;
+    return Success;
+}
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index 00b3668..f849be6 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -176,9 +176,23 @@ typedef Bool (*DRI2SwapLimitValidateProcPtr) (DrawablePtr pDraw,
                                               int swap_limit);
 
 /**
+ * \brief Get the value of a parameter.
+ *
+ * The parameter's \a value is looked up on the screen associated with
+ * \a pDrawable.
+ *
+ * \return \c Success or error code.
+ */
+typedef int (*DRI2GetParamProcPtr) (ClientPtr client,
+                                    DrawablePtr pDrawable,
+                                    CARD64 param,
+                                    BOOL *is_param_recognized,
+                                    CARD64 *value);
+
+/**
  * Version of the DRI2InfoRec structure defined in this header
  */
-#define DRI2INFOREC_VERSION 6
+#define DRI2INFOREC_VERSION 7
 
 typedef struct {
     unsigned int version;       /**< Version of this struct */
@@ -211,6 +225,10 @@ typedef struct {
 
     DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
     DRI2SwapLimitValidateProcPtr SwapLimitValidate;
+
+    /* added in version 7 */
+
+    DRI2GetParamProcPtr GetParam;
 } DRI2InfoRec, *DRI2InfoPtr;
 
 extern _X_EXPORT int DRI2EventBase;
@@ -308,4 +326,10 @@ extern _X_EXPORT void DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw,
                                           int frame, unsigned int tv_sec,
                                           unsigned int tv_usec);
 
+extern _X_EXPORT int DRI2GetParam(ClientPtr client,
+                                  DrawablePtr pDrawable,
+                                  CARD64 param,
+                                  BOOL *is_param_recognized,
+                                  CARD64 *value);
+
 #endif
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index 61578f3..c6f5b4e 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -535,6 +535,37 @@ ProcDRI2WaitSBC(ClientPtr client)
 }
 
 static int
+ProcDRI2GetParam(ClientPtr client)
+{
+    REQUEST(xDRI2GetParamReq);
+    xDRI2GetParamReply rep;
+    DrawablePtr pDrawable;
+    CARD64 value;
+    int status;
+
+    REQUEST_SIZE_MATCH(xDRI2GetParamReq);
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+
+    if (!validDrawable(client, stuff->drawable, DixReadAccess,
+                       &pDrawable, &status))
+        return status;
+
+    status = DRI2GetParam(client, pDrawable, stuff->param,
+                          &rep.is_param_recognized, &value);
+    rep.value_hi = value >> 32;
+    rep.value_lo = value & 0xffffffff;
+
+    if (status != Success)
+        return status;
+
+    WriteToClient(client, sizeof(xDRI2GetParamReply), &rep);
+
+    return status;
+}
+
+static int
 ProcDRI2Dispatch(ClientPtr client)
 {
     REQUEST(xReq);
@@ -572,6 +603,8 @@ ProcDRI2Dispatch(ClientPtr client)
         return ProcDRI2WaitSBC(client);
     case X_DRI2SwapInterval:
         return ProcDRI2SwapInterval(client);
+    case X_DRI2GetParam:
+        return ProcDRI2GetParam(client);
     default:
         return BadRequest;
     }
commit 594b4a4f0601066d09e49a84c5af8c2eb6f07240
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu May 24 13:34:11 2012 +1000

    Xext: include dix-config.h
    
    silences
    In file included from ../include/misc.h:111:0, from hashtable.c:2:
    ./include/os.h:559:1: warning: redundant redeclaration of 'strndup' [-Wredundant-decls]
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/Xext/hashtable.c b/Xext/hashtable.c
index 2adf92e..9d9ef89 100644
--- a/Xext/hashtable.c
+++ b/Xext/hashtable.c
@@ -1,3 +1,7 @@
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
 #include <stdlib.h>
 #include "misc.h"
 #include "hashtable.h"
commit d348ab06aae21c153ecbc3511aeafc8ab66d8303
Author: Julien Cristau <jcristau at debian.org>
Date:   Fri May 11 21:31:50 2012 +0200

    Xvfb: destroy the screen pixmap in CloseScreen
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index e2cd96c..16edf43 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -774,6 +774,13 @@ vfbCloseScreen(int index, ScreenPtr pScreen)
     for (i = 0; i < screenInfo.numScreens; i++)
         SetInstalledColormap(screenInfo.screens[i], NULL);
 
+    /*
+     * fb overwrites miCloseScreen, so do this here
+     */
+    if (pScreen->devPrivate)
+        (*pScreen->DestroyPixmap) (pScreen->devPrivate);
+    pScreen->devPrivate = NULL;
+
     return pScreen->CloseScreen(index, pScreen);
 }
 
commit e4153c1d9138ed40de1c615525066a0f5bb599dc
Author: Julien Cristau <jcristau at debian.org>
Date:   Fri May 11 21:31:49 2012 +0200

    Xi: make stub DeleteInputDeviceRequest call RemoveDevice
    
    DeleteInputDeviceRequest is called from CloseDownDevices on reset, so
    call RemoveDevice to avoid leaking devices in Xvfb/Xnest/Xwin.
    
    Signed-off-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/stubs.c b/Xi/stubs.c
index 8baa5a0..39bee7c 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -141,4 +141,5 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs,
 void
 DeleteInputDeviceRequest(DeviceIntPtr dev)
 {
+    RemoveDevice(dev, TRUE);
 }
commit 2d4fda4b09e67e47d3e6fc4743fc6e81bfe40f28
Author: Marcin Slusarz <marcin.slusarz at gmail.com>
Date:   Mon May 21 21:39:43 2012 +0200

    xfree86: fix mouse wheel support for DGA clients
    
    xf86-input-evdev (since "smooth scrolling" support was added) can send mouse
    motion and wheel events in one batch, so we need to handle it properly.
    Otherwise mouse wheel events which come with motion events are lost
    and separate mouse wheel events are handled through non-DGA path.
    
    Signed-off-by: Marcin Slusarz <marcin.slusarz at gmail.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 77b8000..bee407b 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -1059,26 +1059,24 @@ xf86PostMotionEventP(DeviceIntPtr device,
     xf86PostMotionEventM(device, is_absolute, &mask);
 }
 
-void
-xf86PostMotionEventM(DeviceIntPtr device,
-                     int is_absolute, const ValuatorMask *mask)
+static int
+xf86CheckMotionEvent4DGA(DeviceIntPtr device, int is_absolute,
+                         const ValuatorMask *mask)
 {
-    int flags = 0;
-
-    if (valuator_mask_num_valuators(mask) > 0) {
-        if (is_absolute)
-            flags = POINTER_ABSOLUTE;
-        else
-            flags = POINTER_RELATIVE | POINTER_ACCELERATE;
-    }
+    int stolen = 0;
 
 #if XFreeXDGA
+    ScreenPtr scr = NULL;
+    int idx, i;
+
     /* The evdev driver may not always send all axes across. */
-    if (valuator_mask_isset(mask, 0) || valuator_mask_isset(mask, 1))
-        if (miPointerGetScreen(device)) {
-            int index = miPointerGetScreen(device)->myNum;
+    if (valuator_mask_isset(mask, 0) || valuator_mask_isset(mask, 1)) {
+        scr = miPointerGetScreen(device);
+        if (scr) {
             int dx = 0, dy = 0;
 
+            idx = scr->myNum;
+
             if (valuator_mask_isset(mask, 0)) {
                 dx = valuator_mask_get(mask, 0);
                 if (is_absolute)
@@ -1091,11 +1089,75 @@ xf86PostMotionEventM(DeviceIntPtr device,
                     dy -= device->last.valuators[1];
             }
 
-            if (DGAStealMotionEvent(device, index, dx, dy))
-                return;
+            if (DGAStealMotionEvent(device, idx, dx, dy))
+                stolen = 1;
+        }
+    }
+
+    for (i = 2; i < valuator_mask_size(mask); i++) {
+        AxisInfoPtr ax;
+        double incr;
+        int val, button;
+
+        if (i >= device->valuator->numAxes)
+            break;
+
+        if (!valuator_mask_isset(mask, i))
+            continue;
+
+        ax = &device->valuator->axes[i];
+
+        if (ax->scroll.type == SCROLL_TYPE_NONE)
+            continue;
+
+        if (!scr) {
+            scr = miPointerGetScreen(device);
+            if (!scr)
+                break;
+            idx = scr->myNum;
+        }
+
+        incr = ax->scroll.increment;
+        val = valuator_mask_get(mask, i);
+
+        if (ax->scroll.type == SCROLL_TYPE_VERTICAL) {
+            if (incr * val < 0)
+                button = 4; /* up */
+            else
+                button = 5; /* down */
+        } else { /* SCROLL_TYPE_HORIZONTAL */
+            if (incr * val < 0)
+                button = 6; /* left */
+            else
+                button = 7; /* right */
         }
+
+        if (DGAStealButtonEvent(device, idx, button, 1) &&
+                DGAStealButtonEvent(device, idx, button, 0))
+            stolen = 1;
+    }
+
 #endif
 
+    return stolen;
+}
+
+void
+xf86PostMotionEventM(DeviceIntPtr device,
+                     int is_absolute, const ValuatorMask *mask)
+{
+    int flags = 0;
+
+    if (xf86CheckMotionEvent4DGA(device, is_absolute, mask))
+        return;
+
+    if (valuator_mask_num_valuators(mask) > 0) {
+        if (is_absolute)
+            flags = POINTER_ABSOLUTE;
+        else
+            flags = POINTER_RELATIVE | POINTER_ACCELERATE;
+    }
+
     QueuePointerEvents(device, MotionNotify, 0, flags, mask);
 }
 
commit 9bc53d8cb04af2be3feeebb1b10774c2d599a76b
Author: Michal Srb <msrb at suse.com>
Date:   Tue May 22 21:19:40 2012 -0700

    dri2: SProcDRI2Connect - send the response.
    
    The swapped implementation of DRI2Connect is always responding with empty
    device and driver values. However the response was only prepared and never
    sent (also had undefined .type member), causing e.g. glxinfo get stuck waiting
    for response when started remotely from machine with different endianity.
    
    Signed-off-by: Michal Srb <msrb at suse.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Tested-by: Michel Dänzer <michel at daenzer.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index 2579a5c..61578f3 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -589,12 +589,15 @@ SProcDRI2Connect(ClientPtr client)
     if (sizeof(*stuff) / 4 != client->req_len)
         return BadLength;
 
+    rep.type = X_Reply;
     rep.sequenceNumber = client->sequence;
     swaps(&rep.sequenceNumber);
     rep.length = 0;
     rep.driverNameLength = 0;
     rep.deviceNameLength = 0;
 
+    WriteToClient(client, sizeof(xDRI2ConnectReply), &rep);
+
     return Success;
 }
 
commit 457fc77691b2df66f6dd3ba10ce7c1b61b9b42a3
Merge: 2e237c8 5a3a98f
Author: Keith Packard <keithp at keithp.com>
Date:   Tue May 22 10:32:29 2012 -0700

    Merge remote-tracking branch 'alanc/master'

commit 2e237c838fe1780c2fcbd2306f35fd15b6747831
Author: Dave Airlie <airlied at gmail.com>
Date:   Wed Apr 11 10:02:25 2012 +0100

    xf86: reimplement XF86SCRNINFO macro using new functions.
    
    This macro did lookups via privates but we can just use the ScreenToScrn
    conversion instead.
    
    This patch drops all in-server uses, we should drop the macro later,
    once drivers have been converted to not use it.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index ef99106..0eb000d 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -76,8 +76,8 @@ extern _X_EXPORT Bool xf86DRI2Enabled(void);
 
 extern _X_EXPORT Bool VTSwitchEnabled;  /* kbd driver */
 
-#define XF86SCRNINFO(p) ((ScrnInfoPtr)dixLookupPrivate(&(p)->devPrivates, \
-						       xf86ScreenKey))
+#define XF86SCRNINFO(p) xf86ScreenToScrn(p)
+
 #define XF86FLIP_PIXELS() \
 	do { \
 	    if (xf86GetFlipPixels()) { \
diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c
index 3716434..61cae6a 100644
--- a/hw/xfree86/common/xf86Cursor.c
+++ b/hw/xfree86/common/xf86Cursor.c
@@ -133,7 +133,7 @@ xf86InitViewport(ScrnInfoPtr pScr)
 void
 xf86SetViewport(ScreenPtr pScreen, int x, int y)
 {
-    ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr pScr = xf86ScreenToScrn(pScreen);
 
     (*pScr->PointerMoved) (pScreen->myNum, x, y);
 }
@@ -184,7 +184,8 @@ xf86PointerMoved(int scrnIndex, int x, int y)
 void
 xf86LockZoom(ScreenPtr pScreen, Bool lock)
 {
-    XF86SCRNINFO(pScreen)->zoomLocked = lock;
+    ScrnInfoPtr pScr = xf86ScreenToScrn(pScreen);
+    pScr->zoomLocked = lock;
 }
 
 /*
@@ -196,7 +197,7 @@ xf86LockZoom(ScreenPtr pScreen, Bool lock)
 Bool
 xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
 {
-    ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr pScr = xf86ScreenToScrn(pScreen);
     ScreenPtr pCursorScreen;
     Bool Switched;
     int px, py, was_blocked;
@@ -316,7 +317,7 @@ xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
 void
 xf86ZoomViewport(ScreenPtr pScreen, int zoom)
 {
-    ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr pScr = xf86ScreenToScrn(pScreen);
     DisplayModePtr mode;
 
     if (pScr->zoomLocked || !(mode = pScr->currentMode))
diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c
index abd894d..b17f601 100644
--- a/hw/xfree86/common/xf86RandR.c
+++ b/hw/xfree86/common/xf86RandR.c
@@ -66,7 +66,7 @@ static Bool
 xf86RandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
 {
     RRScreenSizePtr pSize;
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
     DisplayModePtr mode;
     int refresh0 = 60;
@@ -147,7 +147,7 @@ xf86RandRSetMode(ScreenPtr pScreen,
                  DisplayModePtr mode,
                  Bool useVirtual, int mmWidth, int mmHeight)
 {
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
     int oldWidth = pScreen->width;
     int oldHeight = pScreen->height;
@@ -228,7 +228,7 @@ static Bool
 xf86RandRSetConfig(ScreenPtr pScreen,
                    Rotation rotation, int rate, RRScreenSizePtr pSize)
 {
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
     DisplayModePtr mode;
     int pos[MAXDEVICES][2];
@@ -344,7 +344,7 @@ xf86RandRCreateScreenResources(ScreenPtr pScreen)
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
 
 #if 0
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     DisplayModePtr mode;
 #endif
 
@@ -367,7 +367,7 @@ xf86RandRCreateScreenResources(ScreenPtr pScreen)
 static Bool
 xf86RandRCloseScreen(int index, ScreenPtr pScreen)
 {
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
 
     scrp->virtualX = pScreen->width = randrp->virtualX;
@@ -417,8 +417,9 @@ xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
 
     /* This is only for during server start */
     if (resetMode) {
+	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
         return (xf86RandRSetMode(pScreen,
-                                 XF86SCRNINFO(pScreen)->currentMode,
+                                 pScrn->currentMode,
                                  TRUE, pScreen->mmWidth, pScreen->mmHeight));
     }
 
@@ -430,7 +431,7 @@ xf86RandRInit(ScreenPtr pScreen)
 {
     rrScrPrivPtr rp;
     XF86RandRInfoPtr randrp;
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
 
 #ifdef PANORAMIX
     /* XXX disable RandR when using Xinerama */
diff --git a/hw/xfree86/exa/examodule.c b/hw/xfree86/exa/examodule.c
index a422bb2..5092458 100644
--- a/hw/xfree86/exa/examodule.c
+++ b/hw/xfree86/exa/examodule.c
@@ -72,7 +72,7 @@ static const OptionInfoRec EXAOptions[] = {
 static Bool
 exaXorgCloseScreen(int i, ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     ExaXorgScreenPrivPtr pScreenPriv = (ExaXorgScreenPrivPtr)
         dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey);
 
@@ -111,7 +111,6 @@ void
 exaDDXDriverInit(ScreenPtr pScreen)
 {
     ExaScreenPriv(pScreen);
-    /* Do NOT use XF86SCRNINFO macro here!! */
     ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     ExaXorgScreenPrivPtr pScreenPriv;
 
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 49287d9..e6b2052 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -447,7 +447,7 @@ static Bool
 xf86RandR12GetInfo(ScreenPtr pScreen, Rotation * rotations)
 {
     RRScreenSizePtr pSize;
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
     DisplayModePtr mode;
     int refresh0 = 60;
@@ -504,7 +504,7 @@ xf86RandR12SetMode(ScreenPtr pScreen,
                    DisplayModePtr mode,
                    Bool useVirtual, int mmWidth, int mmHeight)
 {
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
     int oldWidth = pScreen->width;
     int oldHeight = pScreen->height;
@@ -576,7 +576,7 @@ Bool
 xf86RandR12SetConfig(ScreenPtr pScreen,
                      Rotation rotation, int rate, RRScreenSizePtr pSize)
 {
-    ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr scrp = xf86ScreenToScrn(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
     DisplayModePtr mode;
     int pos[MAXDEVICES][2];
@@ -671,7 +671,7 @@ xf86RandR12ScreenSetSize(ScreenPtr pScreen,
                          CARD16 height, CARD32 mmWidth, CARD32 mmHeight)
 {
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
-    ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
     WindowPtr pRoot = pScreen->root;
     PixmapPtr pScrnPix;
diff --git a/hw/xfree86/vgahw/vgaCmap.c b/hw/xfree86/vgahw/vgaCmap.c
index 25d406e..a1aa405 100644
--- a/hw/xfree86/vgahw/vgaCmap.c
+++ b/hw/xfree86/vgahw/vgaCmap.c
@@ -81,9 +81,6 @@ xColorItem *pdefs;
     xColorItem directDefs[256];
     Bool new_overscan = FALSE;
     Bool writeColormap;
-
-    /* This can get called before the ScrnInfoRec is installed so we
-       can't rely on getting it with XF86SCRNINFO() */
     int scrnIndex = pmap->pScreen->myNum;
     ScrnInfoPtr scrninfp = xf86ScreenToScrn(pmap->pScreen);
     vgaHWPtr hwp = VGAHWPTR(scrninfp);
commit 8da35202f390cd8a0410814911017d99fa9dddcb
Author: Dave Airlie <airlied at gmail.com>
Date:   Wed Apr 11 09:53:35 2012 +0100

    xf86/modes: drop more pScrn->pScreen usages
    
    Just simple conversion to use the lookup function.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 7fdff91..26eefc8 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -144,7 +144,7 @@ xf86CrtcDamageShadow(xf86CrtcPtr crtc)
     ScrnInfoPtr pScrn = crtc->scrn;
     BoxRec damage_box;
     RegionRec damage_region;
-    ScreenPtr pScreen = pScrn->pScreen;
+    ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
 
     damage_box.x1 = 0;
     damage_box.x2 = crtc->mode.HDisplay;
@@ -270,7 +270,7 @@ void
 xf86RotateDestroy(xf86CrtcPtr crtc)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
-    ScreenPtr pScreen = pScrn->pScreen;
+    ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     int c;
 
commit e7a9e30fd20a7c2a526783726d0a76b8a04b053a
Author: Dave Airlie <airlied at gmail.com>
Date:   Wed Apr 11 09:52:37 2012 +0100

    xaa: convert pScrn->pScreen to use accessor.
    
    This uses a standard conversion function to do the conversion.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
index 9a5d3fb..48d0605 100644
--- a/hw/xfree86/xaa/xaaInit.c
+++ b/hw/xfree86/xaa/xaaInit.c
@@ -92,7 +92,7 @@ XAADestroyInfoRec(XAAInfoRecPtr infoRec)
         return;
 
     if (infoRec->ClosePixmapCache)
-        (*infoRec->ClosePixmapCache) (infoRec->pScrn->pScreen);
+        (*infoRec->ClosePixmapCache) (xf86ScrnToScreen(infoRec->pScrn));
 
     free(infoRec->PreAllocMem);
 
diff --git a/hw/xfree86/xaa/xaaPCache.c b/hw/xfree86/xaa/xaaPCache.c
index a168ceb..53460b3 100644
--- a/hw/xfree86/xaa/xaaPCache.c
+++ b/hw/xfree86/xaa/xaaPCache.c
@@ -2015,7 +2015,7 @@ XAAWriteBitmapToCacheLinear(ScrnInfoPtr pScrn,
                             int x, int y, int w, int h,
                             unsigned char *src, int srcwidth, int fg, int bg)
 {
-    ScreenPtr pScreen = pScrn->pScreen;
+    ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
     PixmapPtr pScreenPix, pDstPix;
     ChangeGCVal gcvals[2];
     GCPtr pGC;
@@ -2061,7 +2061,7 @@ XAAWritePixmapToCacheLinear(ScrnInfoPtr pScrn,
                             unsigned char *src,
                             int srcwidth, int bpp, int depth)
 {
-    ScreenPtr pScreen = pScrn->pScreen;
+    ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
     PixmapPtr pScreenPix, pDstPix;
     GCPtr pGC;
 
commit 738367ac9b6179593a38074d0105de206cbed296
Author: Dave Airlie <airlied at gmail.com>
Date:   Wed Apr 11 09:46:39 2012 +0100

    xf86/modes: drop two uses of screenInfo
    
    Just use new macros to access scrn->screen.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 71467c3..49287d9 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -960,7 +960,7 @@ xf86RandR12SetTransformSupport(ScreenPtr pScreen, Bool transforms)
 void
 xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y)
 {
-    ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
+    ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
 
     if (xf86RandR12Generation != serverGeneration ||
         XF86RANDRINFO(pScreen)->virtualX == -1) {
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 9ac6e2c..7fdff91 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -370,9 +370,7 @@ xf86CrtcRotate(xf86CrtcPtr crtc)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-
-    /* if this is called during ScreenInit() we don't have pScrn->pScreen yet */
-    ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
+    ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
     PictTransform crtc_to_fb;
     struct pict_f_transform f_crtc_to_fb, f_fb_to_crtc;
     xFixed *new_params = NULL;
commit cc4fe613d0b0891ea9502340801b37e64301f573
Author: Dave Airlie <airlied at redhat.com>
Date:   Sat May 5 09:47:24 2012 +0100

    render/exa: use glyph picture accessors
    
    use the glyph picture accessors in the X server, render and EXA code.
    
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/exa/exa_glyphs.c b/exa/exa_glyphs.c
index 2538bce..71f750f 100644
--- a/exa/exa_glyphs.c
+++ b/exa/exa_glyphs.c
@@ -365,7 +365,7 @@ exaGlyphCacheUploadGlyph(ScreenPtr pScreen,
                          ExaGlyphCachePtr cache, int x, int y, GlyphPtr pGlyph)
 {
     ExaScreenPriv(pScreen);
-    PicturePtr pGlyphPicture = GlyphPicture(pGlyph)[pScreen->myNum];
+    PicturePtr pGlyphPicture = GetGlyphPicture(pGlyph, pScreen);
     PixmapPtr pGlyphPixmap = (PixmapPtr) pGlyphPicture->pDrawable;
 
     ExaPixmapPriv(pGlyphPixmap);
@@ -544,7 +544,7 @@ exaBufferGlyph(ScreenPtr pScreen,
                INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, INT16 yDst)
 {
     ExaScreenPriv(pScreen);
-    unsigned int format = (GlyphPicture(pGlyph)[pScreen->myNum])->format;
+    unsigned int format = (GetGlyphPicture(pGlyph, pScreen))->format;
     int width = pGlyph->info.width;
     int height = pGlyph->info.height;
     ExaCompositeRectPtr rect;
@@ -586,7 +586,7 @@ exaBufferGlyph(ScreenPtr pScreen,
 
     /* Couldn't find the glyph in the cache, use the glyph picture directly */
 
-    mask = GlyphPicture(pGlyph)[pScreen->myNum];
+    mask = GetGlyphPicture(pGlyph, pScreen);
     if (buffer->mask && buffer->mask != mask)
         return ExaGlyphNeedFlush;
 
diff --git a/render/glyph.c b/render/glyph.c
index a9dddaf..acb573f 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -90,7 +90,6 @@ GlyphUninit(ScreenPtr pScreen)
     PictureScreenPtr ps = GetPictureScreen(pScreen);
     GlyphPtr glyph;
     int fdepth, i;
-    int scrno = pScreen->myNum;
 
     for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++) {
         if (!globalGlyphs[fdepth].hashSet)
@@ -99,9 +98,9 @@ GlyphUninit(ScreenPtr pScreen)
         for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++) {
             glyph = globalGlyphs[fdepth].table[i].glyph;
             if (glyph && glyph != DeletedGlyph) {
-                if (GlyphPicture(glyph)[scrno]) {
-                    FreePicture((pointer) GlyphPicture(glyph)[scrno], 0);
-                    GlyphPicture(glyph)[scrno] = NULL;
+                if (GetGlyphPicture(glyph, pScreen)) {
+                    FreePicture((pointer) GetGlyphPicture(glyph, pScreen), 0);
+                    SetGlyphPicture(glyph, pScreen, NULL);
                 }
                 (*ps->UnrealizeGlyph) (pScreen, glyph);
             }
@@ -239,8 +238,8 @@ FreeGlyphPicture(GlyphPtr glyph)
     for (i = 0; i < screenInfo.numScreens; i++) {
         ScreenPtr pScreen = screenInfo.screens[i];
 
-        if (GlyphPicture(glyph)[i])
-            FreePicture((pointer) GlyphPicture(glyph)[i], 0);
+        if (GetGlyphPicture(glyph, pScreen))
+            FreePicture((pointer) GetGlyphPicture(glyph, pScreen), 0);
 
         ps = GetPictureScreenIfSet(pScreen);
         if (ps)
@@ -363,11 +362,12 @@ AllocateGlyph(xGlyphInfo * gi, int fdepth)
     dixInitPrivates(glyph, (char *) glyph + head_size, PRIVATE_GLYPH);
 
     for (i = 0; i < screenInfo.numScreens; i++) {
-        GlyphPicture(glyph)[i] = NULL;
-        ps = GetPictureScreenIfSet(screenInfo.screens[i]);
+        ScreenPtr pScreen = screenInfo.screens[i];
+        SetGlyphPicture(glyph, pScreen, NULL);
+        ps = GetPictureScreenIfSet(pScreen);
 
         if (ps) {
-            if (!(*ps->RealizeGlyph) (screenInfo.screens[i], glyph))
+            if (!(*ps->RealizeGlyph) (pScreen, glyph))
                 goto bail;
         }
     }
@@ -638,7 +638,7 @@ miGlyphs(CARD8 op,
         n = list->len;
         while (n--) {
             glyph = *glyphs++;
-            pPicture = GlyphPicture(glyph)[pScreen->myNum];
+            pPicture = GetGlyphPicture(glyph, pScreen);
 
             if (pPicture) {
                 if (maskFormat) {
diff --git a/render/render.c b/render/render.c
index 344ca75..fe7666d 100644
--- a/render/render.c
+++ b/render/render.c
@@ -1136,11 +1136,11 @@ ProcRenderAddGlyphs(ClientPtr client)
                     goto bail;
                 }
 
-                GlyphPicture(glyph)[screen] = pDst =
-                    CreatePicture(0, &pDstPix->drawable,
+                pDst = CreatePicture(0, &pDstPix->drawable,
                                   glyphSet->format,
                                   CPComponentAlpha, &component_alpha,
                                   serverClient, &error);
+                SetGlyphPicture(glyph, pScreen, pDst);
 
                 /* The picture takes a reference to the pixmap, so we
                    drop ours. */
commit a45e1d6cc6f2a5f31ed737294351cfa251caa030
Author: Dave Airlie <airlied at redhat.com>
Date:   Sat May 5 09:38:28 2012 +0100

    render: add GetGlyphPicture accessor.
    
    This is a new API to stop the drivers directly looking up the glyph pictures
    in a global array. It provides a define GLYPH_HAS_GLYPH_PICTURE_ACCESSOR for
    drivers to work in a compat way.
    
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/render/glyph.c b/render/glyph.c
index a143e9e..a9dddaf 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -684,3 +684,13 @@ miGlyphs(CARD8 op,
         (*pScreen->DestroyPixmap) (pMaskPixmap);
     }
 }
+
+PicturePtr GetGlyphPicture(GlyphPtr glyph, ScreenPtr pScreen)
+{
+    return GlyphPicture(glyph)[pScreen->myNum];
+}
+
+void SetGlyphPicture(GlyphPtr glyph, ScreenPtr pScreen, PicturePtr picture)
+{
+    GlyphPicture(glyph)[pScreen->myNum] = picture;
+}
diff --git a/render/glyphstr.h b/render/glyphstr.h
index cbc4751..7d178be 100644
--- a/render/glyphstr.h
+++ b/render/glyphstr.h
@@ -133,4 +133,10 @@ extern _X_EXPORT GlyphSetPtr AllocateGlyphSet(int fdepth, PictFormatPtr format);
 extern _X_EXPORT int
  FreeGlyphSet(pointer value, XID gid);
 
+#define GLYPH_HAS_GLYPH_PICTURE_ACCESSOR 1 /* used for api compat */
+extern _X_EXPORT PicturePtr
+ GetGlyphPicture(GlyphPtr glyph, ScreenPtr pScreen);
+extern _X_EXPORT void
+ SetGlyphPicture(GlyphPtr glyph, ScreenPtr pScreen, PicturePtr picture);
+
 #endif                          /* _GLYPHSTR_H_ */
commit 41151f88a62f01b00c1912822b8b430df1eb307e
Author: Dave Airlie <airlied at gmail.com>
Date:   Tue Apr 10 15:47:33 2012 +0100

    xf86: migrate to using xf86ScreenToScrn wrapper (v2)
    
    migrate to new helper API.
    
    This just wraps all the obvious uses of xf86Screens[pScreen->myNum],
    and should be fairly simple to review.
    
    v2: remove commented out lines.
    
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/glx/glxdri.c b/glx/glxdri.c
index 9b8b66f..b2209c5 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -961,7 +961,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
     __GLXDRIscreen *screen;
     Bool isCapable;
     size_t buffer_size;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     if (!xf86LoaderCheckSymbol("DRIQueryDirectRenderingCapable") ||
         !DRIQueryDirectRenderingCapable(pScreen, &isCapable) || !isCapable) {
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index aa38295..cceb126 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -686,7 +686,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
     const char *driverName, *deviceName;
     __GLXDRIscreen *screen;
     size_t buffer_size;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     screen = calloc(1, sizeof *screen);
     if (screen == NULL)
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 316978c..e0314d8 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -100,7 +100,7 @@ typedef struct {
 Bool
 DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, DGAModePtr modes, int num)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     DGAScreenPtr pScreenPriv;
     int i;
 
diff --git a/hw/xfree86/common/xf86DPMS.c b/hw/xfree86/common/xf86DPMS.c
index 75f0342..54ad842 100644
--- a/hw/xfree86/common/xf86DPMS.c
+++ b/hw/xfree86/common/xf86DPMS.c
@@ -57,7 +57,7 @@ Bool
 xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
 {
 #ifdef DPMSExtension
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     DPMSPtr pDPMS;
     pointer DPMSOpt;
     MessageType enabled_from;
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 6834a0c..fb56a0b 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1577,7 +1577,7 @@ xf86SetBackingStore(ScreenPtr pScreen)
 {
     Bool useBS = FALSE;
     MessageType from = X_DEFAULT;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     OptionInfoPtr options;
 
     options = xnfalloc(sizeof(BSOptions));
@@ -1618,7 +1618,7 @@ xf86SetSilkenMouse(ScreenPtr pScreen)
 {
     Bool useSM = TRUE;
     MessageType from = X_DEFAULT;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     OptionInfoPtr options;
 
     options = xnfalloc(sizeof(SMOptions));
diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c
index 7c9e6ba..b9b46f6 100644
--- a/hw/xfree86/common/xf86VGAarbiter.c
+++ b/hw/xfree86/common/xf86VGAarbiter.c
@@ -106,7 +106,7 @@ xf86VGAarbiterAllowDRI(ScreenPtr pScreen)
 {
     int vga_count;
     int rsrc_decodes;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     if (vga_no_arb)
         return TRUE;
@@ -173,7 +173,7 @@ xf86VGAarbiterWrapFunctions(void)
     for (i = 0; i < xf86NumScreens; i++) {
         pScreen = xf86Screens[i]->pScreen;
         ps = GetPictureScreenIfSet(pScreen);
-        pScrn = xf86Screens[pScreen->myNum];
+        pScrn = xf86ScreenToScrn(pScreen);
         PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
 
         if (!dixRegisterPrivateKey
@@ -224,7 +224,7 @@ static Bool
 VGAarbiterCloseScreen(int i, ScreenPtr pScreen)
 {
     Bool val;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VGAarbiterScreenPtr pScreenPriv =
         (VGAarbiterScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
                                                VGAarbiterScreenKey);
@@ -298,9 +298,7 @@ VGAarbiterGetImage(DrawablePtr pDrawable,
     ScreenPtr pScreen = pDrawable->pScreen;
 
     SCREEN_PROLOG(GetImage);
-//    if (xf86Screens[pScreen->myNum]->vtSema) {
     VGAGet(pScreen);
-//    }
     (*pScreen->GetImage) (pDrawable, sx, sy, w, h, format, planemask, pdstLine);
     VGAPut();
     SCREEN_EPILOG(GetImage, VGAarbiterGetImage);
diff --git a/hw/xfree86/common/xf86VGAarbiterPriv.h b/hw/xfree86/common/xf86VGAarbiterPriv.h
index 2513ce6..ebc8854 100644
--- a/hw/xfree86/common/xf86VGAarbiterPriv.h
+++ b/hw/xfree86/common/xf86VGAarbiterPriv.h
@@ -95,7 +95,7 @@
 static inline void
 VGAGet(ScreenPtr pScreen)
 {
-    pci_device_vgaarb_set_target(xf86Screens[pScreen->myNum]->vgaDev);
+    pci_device_vgaarb_set_target(xf86ScreenToScrn(pScreen)->vgaDev);
     pci_device_vgaarb_lock();
 }
 
diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c
index cdc8459..460fafd 100644
--- a/hw/xfree86/common/xf86cmap.c
+++ b/hw/xfree86/common/xf86cmap.c
@@ -66,7 +66,7 @@
 #define LOAD_PALETTE(pmap) \
     ((pmap == GetInstalledmiColormap(pmap->pScreen)) && \
      ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) || \
-      xf86Screens[pmap->pScreen->myNum]->vtSema || pScreenPriv->isDGAmode))
+      xf86ScreenToScrn(pmap->pScreen)->vtSema || pScreenPriv->isDGAmode))
 
 typedef struct _CMapLink {
     ColormapPtr cmap;
@@ -151,7 +151,7 @@ xf86HandleColormaps(ScreenPtr pScreen,
                     xf86LoadPaletteProc * loadPalette,
                     xf86SetOverscanProc * setOverscan, unsigned int flags)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     ColormapPtr pDefMap = NULL;
     CMapScreenPtr pScreenPriv;
     LOCO *gamma;
@@ -511,7 +511,7 @@ CMapSetDGAMode(int index, int num, DGADevicePtr dev)
     pScreenPriv->isDGAmode = DGAActive(index);
 
     if (!pScreenPriv->isDGAmode && GetInstalledmiColormap(pScreen)
-        && xf86Screens[pScreen->myNum]->vtSema)
+        && xf86ScreenToScrn(pScreen)->vtSema)
         CMapReinstallMap(GetInstalledmiColormap(pScreen));
 
     return ret;
@@ -528,7 +528,7 @@ CMapReinstallMap(ColormapPtr pmap)
                                          CMapScreenKey);
     CMapColormapPtr cmapPriv =
         (CMapColormapPtr) dixLookupPrivate(&pmap->devPrivates, CMapColormapKey);
-    ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pmap->pScreen);
     int i = cmapPriv->numColors;
     int *indices = pScreenPriv->PreAllocIndices;
 
@@ -560,7 +560,7 @@ CMapRefreshColors(ColormapPtr pmap, int defs, int *indices)
     CMapColormapPtr pColPriv =
         (CMapColormapPtr) dixLookupPrivate(&pmap->devPrivates, CMapColormapKey);
     VisualPtr pVisual = pmap->pVisual;
-    ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pmap->pScreen);
     int numColors, i;
     LOCO *gamma, *colors;
     EntryPtr entry;
@@ -692,7 +692,7 @@ CMapSetOverscan(ColormapPtr pmap, int defs, int *indices)
                                          CMapScreenKey);
     CMapColormapPtr pColPriv =
         (CMapColormapPtr) dixLookupPrivate(&pmap->devPrivates, CMapColormapKey);
-    ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pmap->pScreen);
     VisualPtr pVisual = pmap->pVisual;
     int i;
     LOCO *colors;
@@ -833,7 +833,7 @@ CMapUnwrapScreen(ScreenPtr pScreen)
 {
     CMapScreenPtr pScreenPriv =
         (CMapScreenPtr) dixLookupPrivate(&pScreen->devPrivates, CMapScreenKey);
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     pScreen->CloseScreen = pScreenPriv->CloseScreen;
     pScreen->CreateColormap = pScreenPriv->CreateColormap;
@@ -1008,7 +1008,7 @@ xf86ChangeGammaRamp(ScreenPtr pScreen,
                     unsigned short *red,
                     unsigned short *green, unsigned short *blue)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     CMapColormapPtr pColPriv;
     CMapScreenPtr pScreenPriv;
     CMapLinkPtr pLink;
@@ -1085,7 +1085,7 @@ xf86ChangeGammaRamp(ScreenPtr pScreen,
 int
 xf86GetGammaRampSize(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     CMapScreenPtr pScreenPriv;
 
     if (xf86_crtc_supports_gamma(pScrn)) {
@@ -1112,7 +1112,7 @@ xf86GetGammaRamp(ScreenPtr pScreen,
                  unsigned short *red,
                  unsigned short *green, unsigned short *blue)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     CMapScreenPtr pScreenPriv;
     LOCO *entry;
     int shift, sigbits;
@@ -1172,7 +1172,7 @@ xf86GetGammaRamp(ScreenPtr pScreen,
 int
 xf86ChangeGamma(ScreenPtr pScreen, Gamma gamma)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     if (pScrn->ChangeGamma)
         return (*pScrn->ChangeGamma) (pScreen->myNum, gamma);
diff --git a/hw/xfree86/common/xf86fbman.c b/hw/xfree86/common/xf86fbman.c
index 3c29bf5..e2db1c3 100644
--- a/hw/xfree86/common/xf86fbman.c
+++ b/hw/xfree86/common/xf86fbman.c
@@ -1186,7 +1186,7 @@ xf86FBCloseScreen(int i, ScreenPtr pScreen)
 Bool
 xf86InitFBManager(ScreenPtr pScreen, BoxPtr FullBox)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     RegionRec ScreenRegion;
     RegionRec FullRegion;
     BoxRec ScreenBox;
@@ -1223,7 +1223,7 @@ xf86InitFBManager(ScreenPtr pScreen, BoxPtr FullBox)
 Bool
 xf86InitFBManagerArea(ScreenPtr pScreen, int PixelArea, int Verbosity)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xRectangle Rect[3];
     RegionPtr pRegion, pScreenRegion;
     int nRect;
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 0e5b0cf..b100348 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -271,7 +271,7 @@ xf86XVScreenInit(ScreenPtr pScreen, XF86VideoAdaptorPtr * adaptors, int num)
     if (!ScreenPriv)
         return FALSE;
 
-    pScrn = xf86Screens[pScreen->myNum];
+    pScrn = xf86ScreenToScrn(pScreen);
 
     ScreenPriv->DestroyWindow = pScreen->DestroyWindow;
     ScreenPriv->WindowExposures = pScreen->WindowExposures;
@@ -356,7 +356,7 @@ static Bool
 xf86XVInitAdaptors(ScreenPtr pScreen, XF86VideoAdaptorPtr * infoPtr, int number)
 {
     XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XF86VideoAdaptorPtr adaptorPtr;
     XvAdaptorPtr pAdaptor, pa;
     XvAdaptorRecPrivatePtr adaptorPriv;
@@ -1150,7 +1150,7 @@ xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind)
         pScreen = pLayerWin->drawable.pScreen;
 
     ScreenPriv = GET_XF86XV_SCREEN(pScreen);
-    pScrn = xf86Screens[pScreen->myNum];
+    pScrn = xf86ScreenToScrn(pScreen);
 
     xf86XVReputOrStopAllPorts(pScrn, TRUE);
 
@@ -1257,7 +1257,7 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
 static Bool
 xf86XVCloseScreen(int i, ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
     XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
     XvAdaptorPtr pa;
@@ -1899,7 +1899,7 @@ xf86XVFillKeyHelperDrawable(DrawablePtr pDraw, CARD32 key, RegionPtr fillboxes)
     xRectangle *rects;
     GCPtr gc;
 
-    if (!xf86Screens[pScreen->myNum]->vtSema)
+    if (!xf86ScreenToScrn(pScreen)->vtSema)
         return;
 
     gc = GetScratchGC(pDraw->depth, pScreen);
diff --git a/hw/xfree86/common/xf86xvmc.c b/hw/xfree86/common/xf86xvmc.c
index 7321efa..b7da758 100644
--- a/hw/xfree86/common/xf86xvmc.c
+++ b/hw/xfree86/common/xf86xvmc.c
@@ -64,7 +64,7 @@ xf86XvMCCreateContext(XvPortPtr pPort,
                       XvMCContextPtr pContext, int *num_priv, CARD32 **priv)
 {
     xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pContext->pScreen);
 
     pContext->port_priv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
 
@@ -78,7 +78,7 @@ static void
 xf86XvMCDestroyContext(XvMCContextPtr pContext)
 {
     xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pContext->pScreen);
 
     (*pScreenPriv->adaptors[pContext->adapt_num]->DestroyContext) (pScrn,
                                                                    pContext);
@@ -89,7 +89,7 @@ xf86XvMCCreateSurface(XvMCSurfacePtr pSurface, int *num_priv, CARD32 **priv)
 {
     XvMCContextPtr pContext = pSurface->context;
     xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pContext->pScreen);
 
     return (*pScreenPriv->adaptors[pContext->adapt_num]->CreateSurface) (pScrn,
                                                                          pSurface,
@@ -102,7 +102,7 @@ xf86XvMCDestroySurface(XvMCSurfacePtr pSurface)
 {
     XvMCContextPtr pContext = pSurface->context;
     xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pContext->pScreen);
 
     (*pScreenPriv->adaptors[pContext->adapt_num]->DestroySurface) (pScrn,
                                                                    pSurface);
@@ -114,7 +114,7 @@ xf86XvMCCreateSubpicture(XvMCSubpicturePtr pSubpicture,
 {
     XvMCContextPtr pContext = pSubpicture->context;
     xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pContext->pScreen);
 
     return (*pScreenPriv->adaptors[pContext->adapt_num]->
             CreateSubpicture) (pScrn, pSubpicture, num_priv, priv);
@@ -125,7 +125,7 @@ xf86XvMCDestroySubpicture(XvMCSubpicturePtr pSubpicture)
 {
     XvMCContextPtr pContext = pSubpicture->context;
     xf86XvMCScreenPtr pScreenPriv = XF86XVMC_GET_PRIVATE(pContext->pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pContext->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pContext->pScreen);
 
     (*pScreenPriv->adaptors[pContext->adapt_num]->DestroySubpicture) (pScrn,
                                                                       pSubpicture);
diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml
index ca5efc9..1b0dbc4 100644
--- a/hw/xfree86/doc/ddxDesign.xml
+++ b/hw/xfree86/doc/ddxDesign.xml
@@ -9061,7 +9061,7 @@ static Bool
 ZZZScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 {
     /* Get the ScrnInfoRec */
-    pScrn = xf86Screens[pScreen->myNum];
+    pScrn = xf86ScreenToScrn(pScreen);
 
     /*
      * If using the vgahw module, its data structures and related
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index 9530eb4..20eb683 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -315,7 +315,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
     int reserved_count;
     int i;
     DRIEntPrivPtr pDRIEntPriv;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     DRIContextFlags flags = 0;
     DRIContextPrivPtr pDRIContextPriv;
 
@@ -615,7 +615,7 @@ DRIFinishScreenInit(ScreenPtr pScreen)
         pScreen->ClipNotify = pDRIInfo->wrap.ClipNotify;
     }
     if (pDRIInfo->wrap.AdjustFrame) {
-        ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+        ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
         pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
         pScrn->AdjustFrame = pDRIInfo->wrap.AdjustFrame;
@@ -634,7 +634,7 @@ DRICloseScreen(ScreenPtr pScreen)
     DRIInfoPtr pDRIInfo;
     drm_context_t *reserved;
     int reserved_count;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     DRIEntPrivPtr pDRIEntPriv = DRI_ENT_PRIV(pScrn);
     Bool closeMaster;
 
@@ -672,7 +672,7 @@ DRICloseScreen(ScreenPtr pScreen)
                 pDRIPriv->wrap.ClipNotify = NULL;
             }
             if (pDRIInfo->wrap.AdjustFrame) {
-                ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+                ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
                 pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
                 pDRIPriv->wrap.AdjustFrame = NULL;
@@ -2311,7 +2311,7 @@ DRIAdjustFrame(int scrnIndex, int x, int y, int flags)
 {
     ScreenPtr pScreen = screenInfo.screens[scrnIndex];
     DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     int px, py;
 
     if (!pDRIPriv || !pDRIPriv->pSAREA) {
diff --git a/hw/xfree86/exa/examodule.c b/hw/xfree86/exa/examodule.c
index 72cf798..a422bb2 100644
--- a/hw/xfree86/exa/examodule.c
+++ b/hw/xfree86/exa/examodule.c
@@ -112,7 +112,7 @@ exaDDXDriverInit(ScreenPtr pScreen)
 {
     ExaScreenPriv(pScreen);
     /* Do NOT use XF86SCRNINFO macro here!! */
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     ExaXorgScreenPrivPtr pScreenPriv;
 
     if (!dixRegisterPrivateKey(&exaXorgScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c
index 2881d7e..0444d48 100644
--- a/hw/xfree86/fbdevhw/fbdevhw.c
+++ b/hw/xfree86/fbdevhw/fbdevhw.c
@@ -866,7 +866,7 @@ fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags)
 Bool
 fbdevHWSaveScreen(ScreenPtr pScreen, int mode)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
     unsigned long unblank;
 
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index fee1ae7..ab6ed5e 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -182,7 +182,7 @@ xf86CrtcSetScreenSubpixelOrder(ScreenPtr pScreen)
 {
     int subpixel_order = SubPixelUnknown;
     Bool has_none = FALSE;
-    ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     int c, o;
 
@@ -698,7 +698,7 @@ xf86OutputDestroy(xf86OutputPtr output)
 static Bool
 xf86CrtcCreateScreenResources(ScreenPtr screen)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
 
     screen->CreateScreenResources = config->CreateScreenResources;
@@ -718,7 +718,7 @@ xf86CrtcCreateScreenResources(ScreenPtr screen)
 static Bool
 xf86CrtcCloseScreen(int index, ScreenPtr screen)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
     int o, c;
 
@@ -751,7 +751,7 @@ Bool
 #endif
 xf86CrtcScreenInit(ScreenPtr screen)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
     int c;
 
@@ -2823,7 +2823,7 @@ xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags)
 Bool
 xf86SaveScreen(ScreenPtr pScreen, int mode)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     if (xf86IsUnblank(mode))
         xf86DPMSSet(pScrn, DPMSModeOn, 0);
@@ -3151,7 +3151,7 @@ xf86_crtc_notify_proc_ptr
 xf86_wrap_crtc_notify(ScreenPtr screen, xf86_crtc_notify_proc_ptr new)
 {
     if (xf86CrtcConfigPrivateIndex != -1) {
-        ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+        ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
         xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
         xf86_crtc_notify_proc_ptr old;
 
@@ -3166,7 +3166,7 @@ void
 xf86_unwrap_crtc_notify(ScreenPtr screen, xf86_crtc_notify_proc_ptr old)
 {
     if (xf86CrtcConfigPrivateIndex != -1) {
-        ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+        ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
         xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
 
         config->xf86_crtc_notify = old;
@@ -3176,7 +3176,7 @@ xf86_unwrap_crtc_notify(ScreenPtr screen, xf86_crtc_notify_proc_ptr old)
 void
 xf86_crtc_notify(ScreenPtr screen)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
 
     if (config->xf86_crtc_notify)
diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index 95a7892..634ee3f 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -477,7 +477,7 @@ xf86_load_cursor_image(ScrnInfoPtr scrn, unsigned char *src)
 static Bool
 xf86_use_hw_cursor(ScreenPtr screen, CursorPtr cursor)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
 
@@ -496,7 +496,7 @@ xf86_use_hw_cursor(ScreenPtr screen, CursorPtr cursor)
 static Bool
 xf86_use_hw_cursor_argb(ScreenPtr screen, CursorPtr cursor)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
 
@@ -564,7 +564,7 @@ xf86_load_cursor_argb(ScrnInfoPtr scrn, CursorPtr cursor)
 Bool
 xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     xf86CursorInfoPtr cursor_info;
 
@@ -631,7 +631,7 @@ xf86_reload_cursors(ScreenPtr screen)
     if (!cursor_screen_priv || !cursor_screen_priv->isUp)
         return;
 
-    scrn = xf86Screens[screen->myNum];
+    scrn = xf86ScreenToScrn(screen);
     xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
 
     /* make sure the cursor code has been initialized */
@@ -667,7 +667,7 @@ xf86_reload_cursors(ScreenPtr screen)
 void
 xf86_cursors_fini(ScreenPtr screen)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
 
     if (xf86_config->cursor_info) {
diff --git a/hw/xfree86/modes/xf86DiDGA.c b/hw/xfree86/modes/xf86DiDGA.c
index fafd95a..fdec6cb 100644
--- a/hw/xfree86/modes/xf86DiDGA.c
+++ b/hw/xfree86/modes/xf86DiDGA.c
@@ -41,7 +41,7 @@
 static Bool
 xf86_dga_get_modes(ScreenPtr pScreen)
 {
-    ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     DGAModePtr modes, mode;
     DisplayModePtr display_mode;
@@ -175,7 +175,7 @@ xf86DiDGAReInit(ScreenPtr pScreen)
 Bool
 _xf86_di_dga_reinit_internal(ScreenPtr pScreen)
 {
-    ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
 
     if (!DGAAvailable(pScreen->myNum))
@@ -197,7 +197,7 @@ xf86DiDGAInit(ScreenPtr pScreen, unsigned long dga_address)
 Bool
 _xf86_di_dga_init_internal(ScreenPtr pScreen)
 {
-    ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
 
     xf86_config->dga_flags = 0;
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index aca0734..71467c3 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -743,7 +743,7 @@ xf86RandR12GetRotation(ScreenPtr pScreen)
 Bool
 xf86RandR12CreateScreenResources(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config;
     XF86RandRInfoPtr randrp;
     int c;
@@ -902,7 +902,7 @@ xf86RandR12CloseScreen(ScreenPtr pScreen)
 
     randrp = XF86RANDRINFO(pScreen);
 #if RANDR_12_INTERFACE
-    xf86Screens[pScreen->myNum]->EnterVT = randrp->orig_EnterVT;
+    xf86ScreenToScrn(pScreen)->EnterVT = randrp->orig_EnterVT;
 #endif
 
     free(randrp);
@@ -914,7 +914,7 @@ xf86RandR12SetRotations(ScreenPtr pScreen, Rotation rotations)
     XF86RandRInfoPtr randrp;
 
 #if RANDR_12_INTERFACE
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     int c;
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
 #endif
@@ -939,7 +939,7 @@ xf86RandR12SetTransformSupport(ScreenPtr pScreen, Bool transforms)
     XF86RandRInfoPtr randrp;
 
 #if RANDR_13_INTERFACE
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     int c;
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
 #endif
@@ -1041,7 +1041,7 @@ static Bool
 xf86RandR12CrtcNotify(RRCrtcPtr randr_crtc)
 {
     ScreenPtr pScreen = randr_crtc->pScreen;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
     RRModePtr randr_mode = NULL;
     int x;
@@ -1136,7 +1136,7 @@ xf86RandR12CrtcSet(ScreenPtr pScreen,
                    int num_randr_outputs, RROutputPtr * randr_outputs)
 {
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
     xf86CrtcPtr crtc = randr_crtc->devPrivate;
     RRTransformPtr transform;
@@ -1349,7 +1349,7 @@ static Bool
 xf86RandR12OutputValidateMode(ScreenPtr pScreen,
                               RROutputPtr randr_output, RRModePtr randr_mode)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86OutputPtr output = randr_output->devPrivate;
     DisplayModeRec mode;
 
@@ -1434,7 +1434,7 @@ xf86RROutputSetModes(RROutputPtr randr_output, DisplayModePtr modes)
 static Bool
 xf86RandR12SetInfo12(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
     RROutputPtr *clones;
     RRCrtcPtr *crtcs;
@@ -1510,7 +1510,7 @@ xf86RandR12SetInfo12(ScreenPtr pScreen)
 static Bool
 xf86RandR12GetInfo12(ScreenPtr pScreen, Rotation * rotations)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     if (!pScrn->vtSema)
         return TRUE;
@@ -1522,7 +1522,7 @@ xf86RandR12GetInfo12(ScreenPtr pScreen, Rotation * rotations)
 static Bool
 xf86RandR12CreateObjects12(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
     int c;
     int o;
@@ -1559,7 +1559,7 @@ static Bool
 xf86RandR12CreateScreenResources12(ScreenPtr pScreen)
 {
     int c;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
 
     if (xf86RandR12Key == NULL)
@@ -1581,7 +1581,7 @@ xf86RandR12CreateScreenResources12(ScreenPtr pScreen)
 void
 xf86RandR12TellChanged(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
     int c;
 
@@ -1751,7 +1751,7 @@ xf86RandR12EnterVT(int screen_index, int flags)
 static Bool
 xf86RandR12Init12(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     rrScrPrivPtr rp = rrGetScrPriv(pScreen);
     XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
     int i;
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index cbc8687..9ac6e2c 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -174,7 +174,7 @@ xf86CrtcDamageShadow(xf86CrtcPtr crtc)
 static void
 xf86RotatePrepare(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     int c;
 
@@ -204,7 +204,7 @@ xf86RotatePrepare(ScreenPtr pScreen)
 static Bool
 xf86RotateRedisplay(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     DamagePtr damage = xf86_config->rotation_damage;
     RegionPtr region;
@@ -328,7 +328,7 @@ xf86RotateFreeShadow(ScrnInfoPtr pScrn)
 void
 xf86RotateCloseScreen(ScreenPtr screen)
 {
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     int c;
 
diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c
index 678d2be..7fd70fc 100644
--- a/hw/xfree86/ramdac/xf86Cursor.c
+++ b/hw/xfree86/ramdac/xf86Cursor.c
@@ -55,7 +55,7 @@ static Bool xf86CursorSwitchMode(int, DisplayModePtr, int);
 Bool
 xf86InitCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     xf86CursorScreenPtr ScreenPriv;
     miPointerScreenPtr PointPriv;
 
@@ -120,7 +120,7 @@ xf86InitCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
 static Bool
 xf86CursorCloseScreen(int i, ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     miPointerScreenPtr PointPriv =
         (miPointerScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
                                               miPointerScreenKey);
diff --git a/hw/xfree86/ramdac/xf86HWCurs.c b/hw/xfree86/ramdac/xf86HWCurs.c
index 9572149..cb62d9b 100644
--- a/hw/xfree86/ramdac/xf86HWCurs.c
+++ b/hw/xfree86/ramdac/xf86HWCurs.c
@@ -105,7 +105,7 @@ xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
         infoPtr->RealizeCursor = RealizeCursorInterleave0;
     }
 
-    infoPtr->pScrn = xf86Screens[pScreen->myNum];
+    infoPtr->pScrn = xf86ScreenToScrn(pScreen);
 
     return TRUE;
 }
diff --git a/hw/xfree86/ramdac/xf86RamDacCmap.c b/hw/xfree86/ramdac/xf86RamDacCmap.c
index 7a903d8..fa7a866 100644
--- a/hw/xfree86/ramdac/xf86RamDacCmap.c
+++ b/hw/xfree86/ramdac/xf86RamDacCmap.c
@@ -59,7 +59,7 @@ Bool
 RamDacHandleColormaps(ScreenPtr pScreen, int maxColors, int sigRGBbits,
                       unsigned int flags)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     RamDacRecPtr hwp = RAMDACSCRPTR(pScrn);
 
     if (hwp->LoadPalette == NULL)
diff --git a/hw/xfree86/shadowfb/shadow.c b/hw/xfree86/shadowfb/shadow.c
index 714dd14..5aeee6c 100644
--- a/hw/xfree86/shadowfb/shadow.c
+++ b/hw/xfree86/shadowfb/shadow.c
@@ -136,7 +136,7 @@ ShadowFBInit2(ScreenPtr pScreen,
               RefreshAreaFuncPtr preRefreshArea,
               RefreshAreaFuncPtr postRefreshArea)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     ShadowScreenPtr pPriv;
     PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
 
@@ -229,7 +229,7 @@ ShadowLeaveVT(int index, int flags)
 static Bool
 ShadowCloseScreen(int i, ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
     PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
 
diff --git a/hw/xfree86/vgahw/vgaCmap.c b/hw/xfree86/vgahw/vgaCmap.c
index 0cfabc5..25d406e 100644
--- a/hw/xfree86/vgahw/vgaCmap.c
+++ b/hw/xfree86/vgahw/vgaCmap.c
@@ -85,7 +85,7 @@ xColorItem *pdefs;
     /* This can get called before the ScrnInfoRec is installed so we
        can't rely on getting it with XF86SCRNINFO() */
     int scrnIndex = pmap->pScreen->myNum;
-    ScrnInfoPtr scrninfp = xf86Screens[scrnIndex];
+    ScrnInfoPtr scrninfp = xf86ScreenToScrn(pmap->pScreen);
     vgaHWPtr hwp = VGAHWPTR(scrninfp);
 
     unsigned char overscan = hwp->ModeReg.Attribute[OVERSCAN];
diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c
index e044682..a64f4f8 100644
--- a/hw/xfree86/vgahw/vgaHW.c
+++ b/hw/xfree86/vgahw/vgaHW.c
@@ -651,7 +651,7 @@ vgaHWSaveScreen(ScreenPtr pScreen, int mode)
     Bool on;
 
     if (pScreen != NULL)
-        pScrn = xf86Screens[pScreen->myNum];
+        pScrn = xf86ScreenToScrn(pScreen);
 
     on = xf86IsUnblank(mode);
 
@@ -1873,7 +1873,7 @@ vgaHWSetOverscan(ScrnInfoPtr pScrn, int overscan)
 Bool
 vgaHWHandleColormaps(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     if (pScrn->depth > 1 && pScrn->depth <= 8) {
         return xf86HandleColormaps(pScreen, 1 << pScrn->depth,
diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
index 661fa90..9a5d3fb 100644
--- a/hw/xfree86/xaa/xaaInit.c
+++ b/hw/xfree86/xaa/xaaInit.c
@@ -104,7 +104,7 @@ XAADestroyInfoRec(XAAInfoRecPtr infoRec)
 Bool
 XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XAAScreenPtr pScreenPriv;
     int i;
     PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
@@ -216,7 +216,7 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
 static Bool
 XAACloseScreen(int i, ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XAAScreenPtr pScreenPriv =
         (XAAScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
 
@@ -278,7 +278,7 @@ XAAGetSpans(DrawablePtr pDraw,
     ScreenPtr pScreen = pDraw->pScreen;
 
     XAA_SCREEN_PROLOGUE(pScreen, GetSpans);
-    if (xf86Screens[pScreen->myNum]->vtSema &&
+    if (xf86ScreenToScrn(pScreen)->vtSema &&
         ((pDraw->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pDraw))) {
         SYNC_CHECK(pDraw);
     }
@@ -311,7 +311,7 @@ static void
 XAAInitializeOffscreenDepths(ScreenPtr pScreen)
 {
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     int d, dep;
 
     infoRec->offscreenDepthsInitialized = TRUE;
@@ -329,7 +329,7 @@ static PixmapPtr
 XAACreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint)
 {
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XAAPixmapPtr pPriv;
     PixmapPtr pPix = NULL;
     int size = w * h;
diff --git a/hw/xfree86/xaa/xaaInitAccel.c b/hw/xfree86/xaa/xaaInitAccel.c
index 2a85a19..a36e0b7 100644
--- a/hw/xfree86/xaa/xaaInitAccel.c
+++ b/hw/xfree86/xaa/xaaInitAccel.c
@@ -116,7 +116,7 @@ Bool
 XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
 {
     int index = pScreen->myNum;
-    ScrnInfoPtr pScrn = xf86Screens[index];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     Bool HaveScreenToScreenCopy = FALSE;
     Bool HaveColorExpansion = FALSE;
     Bool HaveScanlineColorExpansion = FALSE;
diff --git a/hw/xfree86/xaa/xaaOverlayDF.c b/hw/xfree86/xaa/xaaOverlayDF.c
index 5918f65..470694c 100644
--- a/hw/xfree86/xaa/xaaOverlayDF.c
+++ b/hw/xfree86/xaa/xaaOverlayDF.c
@@ -171,7 +171,7 @@ static DevPrivateKeyRec XAAOverlayKeyRec;
 Bool
 XAAInitDualFramebufferOverlay(ScreenPtr pScreen, DepthChangeFuncPtr callback)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
     XAAOverlayPtr pOverPriv;
 
diff --git a/hw/xfree86/xaa/xaaPCache.c b/hw/xfree86/xaa/xaaPCache.c
index 02c0cd4..a168ceb 100644
--- a/hw/xfree86/xaa/xaaPCache.c
+++ b/hw/xfree86/xaa/xaaPCache.c
@@ -652,7 +652,7 @@ ConvertSomePartialsTo8x8(int *NumMono, int *NumColor, int *NumPartial,
 void
 XAAInitPixmapCache(ScreenPtr pScreen, RegionPtr areas, pointer data)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XAAInfoRecPtr infoRec = (XAAInfoRecPtr) data;
     XAAPixmapCachePrivatePtr pCachePriv;
     BoxPtr pBox = RegionRects(areas);
diff --git a/hw/xfree86/xaa/xaaStateChange.c b/hw/xfree86/xaa/xaaStateChange.c
index 0218cb5..cd2b601 100644
--- a/hw/xfree86/xaa/xaaStateChange.c
+++ b/hw/xfree86/xaa/xaaStateChange.c
@@ -1532,7 +1532,7 @@ XAAStateWrapSetupForCPUToScreenTexture2(ScrnInfoPtr pScrn, int op,
 Bool
 XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XAAStateWrapPtr pStatePriv;
     int i = 0;
 
commit 53932b3803fa2c02949fd7d4d0e433ea58fa89f1
Author: Dave Airlie <airlied at gmail.com>
Date:   Tue Apr 10 15:47:32 2012 +0100

    xf86: add helper functions to convert to from ScrnInfoPtr/ScreenPtr (v2)
    
    These are just simple functions that we should start migrating drivers
    to using.
    
    The end goal is to remove xf86Screens and screenInfo from the ABI.
    
    This includes a define XF86_HAS_SCRN_CONV that drivers can ifdef to provide
    their own copies. I'll probably post a generic compat.h file for drivers later.
    
    v2: add asserts.
    
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index e6d41d6..ef99106 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -449,6 +449,13 @@ xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
 extern _X_EXPORT Bool
 VidModeExtensionInit(ScreenPtr pScreen);
 
+/* convert ScreenPtr to ScrnInfoPtr */
+extern _X_EXPORT ScrnInfoPtr xf86ScreenToScrn(ScreenPtr pScreen);
+/* convert ScrnInfoPtr to ScreenPtr */
+extern _X_EXPORT ScreenPtr xf86ScrnToScreen(ScrnInfoPtr pScrn);
+
 #endif                          /* _NO_XF86_PROTOTYPES */
 
+#define XF86_HAS_SCRN_CONV 1 /* define for drivers to use in api compat */
+
 #endif                          /* _XF86_H */
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 8c948cf..6834a0c 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1834,3 +1834,17 @@ xf86MotionHistoryAllocate(InputInfoPtr pInfo)
 {
     AllocateMotionHistory(pInfo->dev);
 }
+
+ScrnInfoPtr
+xf86ScreenToScrn(ScreenPtr pScreen)
+{
+    assert(pScreen->myNum < xf86NumScreens);
+    return xf86Screens[pScreen->myNum];
+}
+
+ScreenPtr
+xf86ScrnToScreen(ScrnInfoPtr pScrn)
+{
+    assert(pScrn->scrnIndex < screenInfo.numScreens);
+    return screenInfo.screens[pScrn->scrnIndex];
+}
commit 39f73e813f7d404498629f6104a9003d092af28d
Author: Dave Airlie <airlied at redhat.com>
Date:   Tue May 8 13:01:12 2012 +0100

    xf86/pci: fix slot claiming counting.
    
    Currently if we claim a slot for a PCI driver, we never let it go properly,
    this prevents the fallback probe from reusing the slot, even though it
    isn't claimed for that pci slot.
    
    So if you set the modesetting driver to point at a specific kms device,
    that isn't a PCI device (i.e. USB dongle), then the modesetting driver
    loads, the pci probe tries to bind the config slot to the primary PCI
    device, however we then check the kms device bus id to discover it
    isn't valid. However we don't remove the claim on the slot. Next the
    old probe function is called and there is no slots to claim.
    
    This patch fixes that and converts the pciSlotClaimed boolean into
    a counter, and changes the unclaim api to take a device pointer
    to remove from the entity.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index fc4c34e..e6d41d6 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -97,12 +97,12 @@ extern _X_EXPORT Bool VTSwitchEnabled;  /* kbd driver */
 /* PCI related */
 #ifdef XSERVER_LIBPCIACCESS
 #include <pciaccess.h>
-extern _X_EXPORT Bool pciSlotClaimed;
+extern _X_EXPORT int 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 void xf86UnclaimPciSlot(struct pci_device *);
+extern _X_EXPORT void xf86UnclaimPciSlot(struct pci_device *, GDevPtr dev);
 extern _X_EXPORT Bool xf86ParsePciBusString(const char *busID, int *bus,
                                             int *device, int *func);
 extern _X_EXPORT Bool xf86ComparePciBusString(const char *busID, int bus,
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index b176e8c..b876434 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -420,6 +420,26 @@ xf86AddDevToEntity(int entityIndex, GDevPtr dev)
     dev->claimed = TRUE;
 }
 
+
+void
+xf86RemoveDevFromEntity(int entityIndex, GDevPtr dev)
+{
+    EntityPtr pEnt;
+    int i, j;
+    if (entityIndex >= xf86NumEntities)
+        return;
+
+    pEnt = xf86Entities[entityIndex];
+    for (i = 0; i < pEnt->numInstances; i++) {
+        if (pEnt->devices[i] == dev) {
+            for (j = i; j < pEnt->numInstances - 1; j++)
+                pEnt->devices[j] = pEnt->devices[j + 1];
+            break;
+        }
+    }
+    pEnt->numInstances--;
+    dev->claimed = FALSE;
+}
 /*
  * xf86GetEntityInfo() -- This function hands information from the
  * EntityRec struct to the drivers. The EntityRec structure itself
diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index 8d9cb55..6c5efea 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -116,6 +116,7 @@ extern _X_EXPORT void xf86AccessLeave(void);
 extern _X_EXPORT void xf86PostProbe(void);
 extern _X_EXPORT void xf86ClearEntityListForScreen(int scrnIndex);
 extern _X_EXPORT void xf86AddDevToEntity(int entityIndex, GDevPtr dev);
+extern _X_EXPORT void xf86RemoveDevFromEntity(int entityIndex, GDevPtr dev);
 
 /* xf86Config.c */
 
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index e52f1da..d758260 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -52,7 +52,7 @@
 #define PCI_VENDOR_GENERIC		0x00FF
 
 /* Bus-specific globals */
-Bool pciSlotClaimed = FALSE;
+int pciSlotClaimed = 0;
 
 #define PCIINFOCLASSES(c) \
     ( (((c) & 0x00ff0000) == (PCI_CLASS_PREHISTORIC << 16)) \
@@ -223,7 +223,7 @@ xf86ClaimPciSlot(struct pci_device *d, DriverPtr drvp,
         p->inUse = FALSE;
         if (dev)
             xf86AddDevToEntity(num, dev);
-        pciSlotClaimed = TRUE;
+        pciSlotClaimed++;
 
         return num;
     }
@@ -235,7 +235,7 @@ xf86ClaimPciSlot(struct pci_device *d, DriverPtr drvp,
  * Unclaim PCI slot, e.g. if probing failed, so that a different driver can claim.
  */
 void
-xf86UnclaimPciSlot(struct pci_device *d)
+xf86UnclaimPciSlot(struct pci_device *d, GDevPtr dev)
 {
     int i;
 
@@ -244,6 +244,8 @@ xf86UnclaimPciSlot(struct pci_device *d)
 
         if ((p->bus.type == BUS_PCI) && (p->bus.id.pci == d)) {
             /* Probably the slot should be deallocated? */
+            xf86RemoveDevFromEntity(i, dev);
+            pciSlotClaimed--;
             p->bus.type = BUS_NONE;
             return;
         }
@@ -537,7 +539,7 @@ xf86PciProbeDev(DriverPtr drvp)
                         foundScreen = TRUE;
                     }
                     else
-                        xf86UnclaimPciSlot(pPci);
+                        xf86UnclaimPciSlot(pPci, devList[i]);
                 }
 
                 break;
commit 07dcc3f1a98dff2ee374a15ac5beac778d2ccc97
Author: Dave Airlie <airlied at redhat.com>
Date:   Sun May 6 17:13:02 2012 +0100

    config/udev: add pre_init stage to config and udev.
    
    In order to use udev for gpu enumeration, we need to init udev earlier
    than input initialisations. This splits the config init stuff so that udev
    pre init sets up before output initialisation.
    
    this is just a prepatory patch, doesn't change anything major.
    
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/config/config-backends.h b/config/config-backends.h
index e5622d5..62abc0a 100644
--- a/config/config-backends.h
+++ b/config/config-backends.h
@@ -33,6 +33,7 @@ void remove_devices(const char *backend, const char *config_info);
 BOOL device_is_duplicate(const char *config_info);
 
 #ifdef CONFIG_UDEV
+int config_udev_pre_init(void);
 int config_udev_init(void);
 void config_udev_fini(void);
 #else
diff --git a/config/config.c b/config/config.c
index 2b96dbb..24e7ba7 100644
--- a/config/config.c
+++ b/config/config.c
@@ -33,6 +33,15 @@
 #include "config-backends.h"
 
 void
+config_pre_init(void)
+{
+#ifdef CONFIG_UDEV
+    if (!config_udev_pre_init())
+        ErrorF("[config] failed to pre-init udev\n");
+#endif
+}
+
+void
 config_init(void)
 {
 #ifdef CONFIG_UDEV
diff --git a/config/udev.c b/config/udev.c
index 8b3ca04..1995184 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -281,15 +281,14 @@ block_handler(pointer data, struct timeval **tv, pointer read_mask)
 }
 
 int
-config_udev_init(void)
+config_udev_pre_init(void)
 {
     struct udev *udev;
-    struct udev_enumerate *enumerate;
-    struct udev_list_entry *devices, *device;
 
     udev = udev_new();
     if (!udev)
         return 0;
+
     udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
     if (!udev_monitor)
         return 0;
@@ -302,12 +301,21 @@ config_udev_init(void)
     if (SeatId && strcmp(SeatId, "seat0"))
         udev_monitor_filter_add_match_tag(udev_monitor, SeatId);
 #endif
-
     if (udev_monitor_enable_receiving(udev_monitor)) {
         ErrorF("config/udev: failed to bind the udev monitor\n");
         return 0;
     }
+    return 1;
+}
 
+int
+config_udev_init(void)
+{
+    struct udev *udev;
+    struct udev_enumerate *enumerate;
+    struct udev_list_entry *devices, *device;
+
+    udev = udev_monitor_get_udev(udev_monitor);
     enumerate = udev_enumerate_new(udev);
     if (!enumerate)
         return 0;
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index f42dd10..ead47cc 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -405,6 +405,8 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
 
     xf86Initialising = TRUE;
 
+    config_pre_init();
+
     if (serverGeneration == 1) {
         if ((xf86ServerName = strrchr(argv[0], '/')) != 0)
             xf86ServerName++;
diff --git a/include/hotplug.h b/include/hotplug.h
index caa3201..f3eeea2 100644
--- a/include/hotplug.h
+++ b/include/hotplug.h
@@ -26,6 +26,7 @@
 #ifndef HOTPLUG_H
 #define HOTPLUG_H
 
+extern _X_EXPORT void config_pre_init(void);
 extern _X_EXPORT void config_init(void);
 extern _X_EXPORT void config_fini(void);
 
commit a2a02882ab65133e6c0c69db1f38bc20b406236f
Author: Dave Airlie <airlied at redhat.com>
Date:   Sun May 6 17:35:34 2012 +0100

    xfree86: add modesetting driver to fallback list on Linux
    
    Add the modesetting driver to the fallback list on Linux, after vesa
    before fbdev.
    
    Acked-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index 43c746b..d0eb0af 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -270,6 +270,10 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
 #endif
     }
 
+#if defined(__linux__)
+    matches[i++] = xnfstrdup("modesetting");
+#endif
+
 #if !defined(sun)
     /* Fallback to platform default frame buffer driver */
     if (i < (nmatches - 1)) {
commit 5a3a98fcb799c2ac8fa7494645ad9030f1cac837
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Fri Apr 27 13:35:32 2012 -0700

    Undocument Font Module loading
    
    Code was deleted in commit affec10635343668839994ea2bac16c1d4524200
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml
index 7a6dce1..6a08732 100644
--- a/hw/xfree86/doc/ddxDesign.xml
+++ b/hw/xfree86/doc/ddxDesign.xml
@@ -5989,26 +5989,6 @@ typedef struct {
 
 	  </blockquote></para></blockquote>
 
-      <blockquote><para>
-	  <programlisting>
-    void LoadFont(FontModule *font);
-	  </programlisting>
-	  <blockquote><para>
-    This registers the entry points for the font rasteriser module
-    identified by <parameter>font</parameter>.  The <structname>FontModule</structname>
-    struct is defined as:
-
-	      <programlisting>
- typedef struct {
-    InitFont    initFunc;
-    char *      name;
-    pointer     module;
-} FontModule;
-	      </programlisting>
-	    </para>
-
-	  </blockquote></para></blockquote>
-
     </sect2>
 
   </sect1>
commit afcb7ba24ebd9968d48a192df438e7f1c0ecb770
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Fri Apr 27 13:31:56 2012 -0700

    Undocument mandatory loadable modules
    
    The code to implement was deleted when BaseModules[] was emptied by
    the replacement of the "pcidata" module with libpciaccess calls
    in commit 46f55f5dead5d70cdff30531d80a72f6be042315.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml
index ca5efc9..7a6dce1 100644
--- a/hw/xfree86/doc/ddxDesign.xml
+++ b/hw/xfree86/doc/ddxDesign.xml
@@ -665,11 +665,6 @@ Here is what <function>InitOutput()</function> does:
       </para>
 
       <para>
-    The core server contains a list of mandatory modules.  These are loaded
-    first.  Currently the only module on this list is the bitmap font module.
-      </para>
-
-      <para>
     The next set of modules loaded are those specified explicitly in the
     &k.module; section of the config file.
       </para>
commit c3180a74a4fc6304bcfe676e3285d707874a9fea
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Fri Apr 6 21:51:37 2012 -0700

    cvt man page should use Hz, not kHz, for vertical refresh rate
    
    https://bugs.freedesktop.org/show_bug.cgi?id=48311
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/hw/xfree86/utils/man/cvt.man b/hw/xfree86/utils/man/cvt.man
index 310e464..8d70ead 100644
--- a/hw/xfree86/utils/man/cvt.man
+++ b/hw/xfree86/utils/man/cvt.man
@@ -19,8 +19,8 @@ standard is printed. This modeline can be included in Xorg
 .SH OPTIONS
 .TP 8
 .BR refresh
-Provide a vertical refresh rate in kHz.  The CVT standard prefers either 50.0,
-60.0, 75.0 or 85.0kHz.  The default is 60.0kHz.
+Provide a vertical refresh rate in Hz.  The CVT standard prefers either 50.0,
+60.0, 75.0 or 85.0Hz.  The default is 60.0Hz.
 .TP 8
 .BR \-v | \-\-verbose
 Warn verbosely when a given mode does not completely correspond with CVT
commit 96e0ab54962ab59f03275a098ee02c1f0f86b94e
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Thu Jan 26 15:44:40 2012 -0800

    Convert sbusPaletteKey to latest DevPrivate API
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Mark Kettenis <kettenis at openbsd.org>
    Reviewed-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/common/xf86sbusBus.c b/hw/xfree86/common/xf86sbusBus.c
index c993b60..27d24f8 100644
--- a/hw/xfree86/common/xf86sbusBus.c
+++ b/hw/xfree86/common/xf86sbusBus.c
@@ -619,8 +619,9 @@ xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn, sbusDevicePtr psdp)
     pScrn->virtualY = psdp->height;
 }
 
-static sbusPaletteKeyIndex;
-static DevPrivateKey sbusPaletteKey = &sbusPaletteKeyIndex;
+static DevPrivateKeyRec sbusPaletteKeyRec;
+#define sbusPaletteKey (&sbusPaletteKeyRec)
+
 typedef struct _sbusCmap {
     sbusDevicePtr psdp;
     CloseScreenProcPtr CloseScreen;
@@ -692,6 +693,9 @@ xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp)
     struct fbcmap fbcmap;
     unsigned char data[2];
 
+    if (!dixRegisterPrivateKey(sbusPaletteKey, PRIVATE_SCREEN, 0))
+        FatalError("Cannot register sbus private key");
+
     cmap = xnfcalloc(1, sizeof(sbusCmapRec));
     dixSetPrivate(&pScreen->devPrivates, sbusPaletteKey, cmap);
     cmap->psdp = psdp;
commit ba883a0f3435d5da82a8134e696c4905eea70f23
Merge: ae1c48e acdc4f5
Author: Keith Packard <keithp at keithp.com>
Date:   Thu May 17 16:49:19 2012 -0700

    Merge remote-tracking branch 'jeremyhu/master'

commit ae1c48ebc8a3c0b32b3d732e8a340bfe00bb9f79
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed May 16 10:54:48 2012 +1000

    Xi: fix "discards ''const' qualifier" warnings
    
    extinit.c: In function 'XInputExtensionInit':
    extinit.c:1301:29: warning: assignment discards 'const' qualifier from
    pointer target type [enabled by default]
    extinit.c:1303:36: warning: assignment discards 'const' qualifier from
    pointer target type [enabled by default]
    
    property.c: In function 'XIChangeDeviceProperty':
    xiproperty.c:757:39: warning: cast discards '__attribute__((const))'
    qualifier from pointer target type [-Wcast-qual]
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>

diff --git a/Xi/extinit.c b/Xi/extinit.c
index 4483076..494e887 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -1137,6 +1137,9 @@ IResetProc(ExtensionEntry * unused)
     EventSwapVector[DevicePresenceNotify] = NotImplemented;
     EventSwapVector[DevicePropertyNotify] = NotImplemented;
     RestoreExtensionEvents();
+
+    free(xi_all_devices.name);
+    free(xi_all_master_devices.name);
 }
 
 /***********************************************************************
@@ -1298,9 +1301,9 @@ XInputExtensionInit(void)
         memset(&xi_all_devices, 0, sizeof(xi_all_devices));
         memset(&xi_all_master_devices, 0, sizeof(xi_all_master_devices));
         xi_all_devices.id = XIAllDevices;
-        xi_all_devices.name = "XIAllDevices";
+        xi_all_devices.name = strdup("XIAllDevices");
         xi_all_master_devices.id = XIAllMasterDevices;
-        xi_all_master_devices.name = "XIAllMasterDevices";
+        xi_all_master_devices.name = strdup("XIAllMasterDevices");
 
         inputInfo.all_devices = &xi_all_devices;
         inputInfo.all_master_devices = &xi_all_master_devices;
diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index e17efe4..5f46b54 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -754,7 +754,7 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type,
             break;
         }
         if (new_data)
-            memcpy((char *) new_data, (char *) value, len * size_in_bytes);
+            memcpy((char *) new_data, value, len * size_in_bytes);
         if (old_data)
             memcpy((char *) old_data, (char *) prop_value->data,
                    prop_value->size * size_in_bytes);
commit e42bf98283ddc4eac2213c96e8ebcd711583e6b1
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed May 16 10:47:45 2012 +1000

    Xi: fix "shadows previous local" warnings
    
    exevents.c: In function 'DeepCopyFeedbackClasses':
    exevents.c:272:20: warning: declaration of 'classes' shadows a previous
    local [-Wshadow]
    exevents.c:245:16: warning: shadowed declaration is here [-Wshadow]
    (and a few more like this)
    
    exevents.c: In function 'DeliverTouchEmulatedEvent':
    exevents.c:1442:27: warning: declaration of 'win' shadows a parameter
    [-Wshadow]
    exevents.c:1404:55: warning: shadowed declaration is here [-Wshadow]
    exevents.c:1475:28: warning: declaration of 'listener' shadows a parameter
    [-Wshadow]
    exevents.c:1403:62: warning: shadowed declaration is here [-Wshadow]
    
    xiselectev.c: In function 'ProcXISelectEvents':
    xiselectev.c:178:34: warning: declaration of 'dummy' shadows a previous
    local [-Wshadow]
    xiselectev.c:91:18: warning: shadowed declaration is here [-Wshadow]
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index d578758..4aad527 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -269,8 +269,6 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
         }
     }
     else if (to->intfeed && !from->intfeed) {
-        ClassesPtr classes;
-
         classes = to->unused_classes;
         classes->intfeed = to->intfeed;
         to->intfeed = NULL;
@@ -301,8 +299,6 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
         }
     }
     else if (to->stringfeed && !from->stringfeed) {
-        ClassesPtr classes;
-
         classes = to->unused_classes;
         classes->stringfeed = to->stringfeed;
         to->stringfeed = NULL;
@@ -334,8 +330,6 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
         }
     }
     else if (to->bell && !from->bell) {
-        ClassesPtr classes;
-
         classes = to->unused_classes;
         classes->bell = to->bell;
         to->bell = NULL;
@@ -369,8 +363,6 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
         }
     }
     else if (to->leds && !from->leds) {
-        ClassesPtr classes;
-
         classes = to->unused_classes;
         classes->leds = to->leds;
         to->leds = NULL;
@@ -417,8 +409,6 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to)
         }
     }
     else if (to->kbdfeed && !from->kbdfeed) {
-        ClassesPtr classes;
-
         classes = to->unused_classes;
         classes->kbdfeed = to->kbdfeed;
         to->kbdfeed = NULL;
@@ -437,8 +427,6 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to)
         CopyKeyClass(from, to);
     }
     else if (to->key && !from->key) {
-        ClassesPtr classes;
-
         classes = to->unused_classes;
         classes->key = to->key;
         to->key = NULL;
@@ -494,8 +482,6 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to)
         }
     }
     else if (to->focus) {
-        ClassesPtr classes;
-
         classes = to->unused_classes;
         classes->focus = to->focus;
         to->focus = NULL;
@@ -536,8 +522,6 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
         }
     }
     else if (to->ptrfeed && !from->ptrfeed) {
-        ClassesPtr classes;
-
         classes = to->unused_classes;
         classes->ptrfeed = to->ptrfeed;
         to->ptrfeed = NULL;
@@ -564,8 +548,6 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
         v->sourceid = from->id;
     }
     else if (to->valuator && !from->valuator) {
-        ClassesPtr classes;
-
         classes = to->unused_classes;
         classes->valuator = to->valuator;
         to->valuator = NULL;
@@ -601,8 +583,6 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
         to->button->sourceid = from->id;
     }
     else if (to->button && !from->button) {
-        ClassesPtr classes;
-
         classes = to->unused_classes;
         classes->button = to->button;
         to->button = NULL;
@@ -624,8 +604,6 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
         to->proximity->sourceid = from->id;
     }
     else if (to->proximity) {
-        ClassesPtr classes;
-
         classes = to->unused_classes;
         classes->proximity = to->proximity;
         to->proximity = NULL;
@@ -1461,9 +1439,9 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
 
             if (grab->ownerEvents) {
                 WindowPtr focus = NullWindow;
-                WindowPtr win = dev->spriteInfo->sprite->win;
+                WindowPtr sprite_win = dev->spriteInfo->sprite->win;
 
-                deliveries = DeliverDeviceEvents(win, ptrev, grab, focus, dev);
+                deliveries = DeliverDeviceEvents(sprite_win, ptrev, grab, focus, dev);
             }
 
             if (!deliveries)
@@ -1494,7 +1472,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
          * the event.
          */
         if (!devgrab && dev->deviceGrab.grab && dev->deviceGrab.implicitGrab) {
-            TouchListener *listener;
+            TouchListener *l;
 
             devgrab = dev->deviceGrab.grab;
 
@@ -1504,13 +1482,13 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
              * selection. Implicit grab activation occurs through delivering an
              * event selection. Thus, we update the last listener in the array.
              */
-            listener = &ti->listeners[ti->num_listeners - 1];
-            listener->listener = devgrab->resource;
+            l = &ti->listeners[ti->num_listeners - 1];
+            l->listener = devgrab->resource;
 
             if (devgrab->grabtype != XI2 || devgrab->type != XI_TouchBegin)
-                listener->type = LISTENER_POINTER_GRAB;
+                l->type = LISTENER_POINTER_GRAB;
             else
-                listener->type = LISTENER_GRAB;
+                l->type = LISTENER_GRAB;
         }
 
     }
diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c
index 43a67c8..e7e719d 100644
--- a/Xi/xiselectev.c
+++ b/Xi/xiselectev.c
@@ -175,17 +175,17 @@ ProcXISelectEvents(ClientPtr client)
                 if (inputMasks)
                     iclient = inputMasks->inputClients;
                 for (; iclient; iclient = iclient->next) {
-                    DeviceIntPtr dummy;
+                    DeviceIntPtr tmp;
 
                     if (CLIENT_ID(iclient->resource) == client->index)
                         continue;
 
-                    dixLookupDevice(&dummy, evmask->deviceid, serverClient,
+                    dixLookupDevice(&tmp, evmask->deviceid, serverClient,
                                     DixReadAccess);
-                    if (!dummy)
+                    if (!tmp)
                         return BadImplementation;       /* this shouldn't happen */
 
-                    if (xi2mask_isset(iclient->xi2mask, dummy, XI_TouchBegin))
+                    if (xi2mask_isset(iclient->xi2mask, tmp, XI_TouchBegin))
                         return BadAccess;
                 }
             }
commit ca6d25ad2d1fb4efae9d40c7e74c8494f9918625
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed May 16 10:10:11 2012 +1000

    dix: Move DeviceFocusEvent from Xi into enterleave.c
    
    This is only called from the enterleave implementation, so move it and its
    helper functions to there. No functional changes.
    
    Fixes build error introduced in 31174565ec0090b4c03c9334c82878be2455f938 if
    building with '-Werror=implicit-function-declaration'
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index e9f0207..d578758 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -2114,240 +2114,6 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type,
     return TRUE;
 }
 
-static void
-FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k,
-                     ButtonClassPtr b, ValuatorClassPtr v, int first)
-{
-    ev->type = DeviceStateNotify;
-    ev->deviceid = dev->id;
-    ev->time = currentTime.milliseconds;
-    ev->classes_reported = 0;
-    ev->num_keys = 0;
-    ev->num_buttons = 0;
-    ev->num_valuators = 0;
-
-    if (b) {
-        ev->classes_reported |= (1 << ButtonClass);
-        ev->num_buttons = b->numButtons;
-        memcpy((char *) ev->buttons, (char *) b->down, 4);
-    }
-    else if (k) {
-        ev->classes_reported |= (1 << KeyClass);
-        ev->num_keys = k->xkbInfo->desc->max_key_code -
-            k->xkbInfo->desc->min_key_code;
-        memmove((char *) &ev->keys[0], (char *) k->down, 4);
-    }
-    if (v) {
-        int nval = v->numAxes - first;
-
-        ev->classes_reported |= (1 << ValuatorClass);
-        ev->classes_reported |= valuator_get_mode(dev, 0) << ModeBitsShift;
-        ev->num_valuators = nval < 3 ? nval : 3;
-        switch (ev->num_valuators) {
-        case 3:
-            ev->valuator2 = v->axisVal[first + 2];
-        case 2:
-            ev->valuator1 = v->axisVal[first + 1];
-        case 1:
-            ev->valuator0 = v->axisVal[first];
-            break;
-        }
-    }
-}
-
-static void
-FixDeviceValuator(DeviceIntPtr dev, deviceValuator * ev, ValuatorClassPtr v,
-                  int first)
-{
-    int nval = v->numAxes - first;
-
-    ev->type = DeviceValuator;
-    ev->deviceid = dev->id;
-    ev->num_valuators = nval < 3 ? nval : 3;
-    ev->first_valuator = first;
-    switch (ev->num_valuators) {
-    case 3:
-        ev->valuator2 = v->axisVal[first + 2];
-    case 2:
-        ev->valuator1 = v->axisVal[first + 1];
-    case 1:
-        ev->valuator0 = v->axisVal[first];
-        break;
-    }
-    first += ev->num_valuators;
-}
-
-static void
-DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win)
-{
-    int evcount = 1;
-    deviceStateNotify *ev, *sev;
-    deviceKeyStateNotify *kev;
-    deviceButtonStateNotify *bev;
-
-    KeyClassPtr k;
-    ButtonClassPtr b;
-    ValuatorClassPtr v;
-    int nval = 0, nkeys = 0, nbuttons = 0, first = 0;
-
-    if (!(wOtherInputMasks(win)) ||
-        !(wOtherInputMasks(win)->inputEvents[dev->id] & DeviceStateNotifyMask))
-        return;
-
-    if ((b = dev->button) != NULL) {
-        nbuttons = b->numButtons;
-        if (nbuttons > 32)
-            evcount++;
-    }
-    if ((k = dev->key) != NULL) {
-        nkeys = k->xkbInfo->desc->max_key_code - k->xkbInfo->desc->min_key_code;
-        if (nkeys > 32)
-            evcount++;
-        if (nbuttons > 0) {
-            evcount++;
-        }
-    }
-    if ((v = dev->valuator) != NULL) {
-        nval = v->numAxes;
-
-        if (nval > 3)
-            evcount++;
-        if (nval > 6) {
-            if (!(k && b))
-                evcount++;
-            if (nval > 9)
-                evcount += ((nval - 7) / 3);
-        }
-    }
-
-    sev = ev = (deviceStateNotify *) malloc(evcount * sizeof(xEvent));
-    FixDeviceStateNotify(dev, ev, NULL, NULL, NULL, first);
-
-    if (b != NULL) {
-        FixDeviceStateNotify(dev, ev++, NULL, b, v, first);
-        first += 3;
-        nval -= 3;
-        if (nbuttons > 32) {
-            (ev - 1)->deviceid |= MORE_EVENTS;
-            bev = (deviceButtonStateNotify *) ev++;
-            bev->type = DeviceButtonStateNotify;
-            bev->deviceid = dev->id;
-            memcpy((char *) &bev->buttons[4], (char *) &b->down[4],
-                   DOWN_LENGTH - 4);
-        }
-        if (nval > 0) {
-            (ev - 1)->deviceid |= MORE_EVENTS;
-            FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
-            first += 3;
-            nval -= 3;
-        }
-    }
-
-    if (k != NULL) {
-        FixDeviceStateNotify(dev, ev++, k, NULL, v, first);
-        first += 3;
-        nval -= 3;
-        if (nkeys > 32) {
-            (ev - 1)->deviceid |= MORE_EVENTS;
-            kev = (deviceKeyStateNotify *) ev++;
-            kev->type = DeviceKeyStateNotify;
-            kev->deviceid = dev->id;
-            memmove((char *) &kev->keys[0], (char *) &k->down[4], 28);
-        }
-        if (nval > 0) {
-            (ev - 1)->deviceid |= MORE_EVENTS;
-            FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
-            first += 3;
-            nval -= 3;
-        }
-    }
-
-    while (nval > 0) {
-        FixDeviceStateNotify(dev, ev++, NULL, NULL, v, first);
-        first += 3;
-        nval -= 3;
-        if (nval > 0) {
-            (ev - 1)->deviceid |= MORE_EVENTS;
-            FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
-            first += 3;
-            nval -= 3;
-        }
-    }
-
-    DeliverEventsToWindow(dev, win, (xEvent *) sev, evcount,
-                          DeviceStateNotifyMask, NullGrab);
-    free(sev);
-}
-
-void
-DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
-                 WindowPtr pWin)
-{
-    deviceFocus event;
-    xXIFocusInEvent *xi2event;
-    DeviceIntPtr mouse;
-    int btlen, len, i;
-
-    mouse = IsFloating(dev) ? dev : GetMaster(dev, MASTER_POINTER);
-
-    /* XI 2 event */
-    btlen = (mouse->button) ? bits_to_bytes(mouse->button->numButtons) : 0;
-    btlen = bytes_to_int32(btlen);
-    len = sizeof(xXIFocusInEvent) + btlen * 4;
-
-    xi2event = calloc(1, len);
-    xi2event->type = GenericEvent;
-    xi2event->extension = IReqCode;
-    xi2event->evtype = type;
-    xi2event->length = bytes_to_int32(len - sizeof(xEvent));
-    xi2event->buttons_len = btlen;
-    xi2event->detail = detail;
-    xi2event->time = currentTime.milliseconds;
-    xi2event->deviceid = dev->id;
-    xi2event->sourceid = dev->id;       /* a device doesn't change focus by itself */
-    xi2event->mode = mode;
-    xi2event->root_x = FP1616(mouse->spriteInfo->sprite->hot.x, 0);
-    xi2event->root_y = FP1616(mouse->spriteInfo->sprite->hot.y, 0);
-
-    for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++)
-        if (BitIsOn(mouse->button->down, i))
-            SetBit(&xi2event[1], mouse->button->map[i]);
-
-    if (dev->key) {
-        xi2event->mods.base_mods = dev->key->xkbInfo->state.base_mods;
-        xi2event->mods.latched_mods = dev->key->xkbInfo->state.latched_mods;
-        xi2event->mods.locked_mods = dev->key->xkbInfo->state.locked_mods;
-        xi2event->mods.effective_mods = dev->key->xkbInfo->state.mods;
-
-        xi2event->group.base_group = dev->key->xkbInfo->state.base_group;
-        xi2event->group.latched_group = dev->key->xkbInfo->state.latched_group;
-        xi2event->group.locked_group = dev->key->xkbInfo->state.locked_group;
-        xi2event->group.effective_group = dev->key->xkbInfo->state.group;
-    }
-
-    FixUpEventFromWindow(dev->spriteInfo->sprite, (xEvent *) xi2event, pWin,
-                         None, FALSE);
-
-    DeliverEventsToWindow(dev, pWin, (xEvent *) xi2event, 1,
-                          GetEventFilter(dev, (xEvent *) xi2event), NullGrab);
-
-    free(xi2event);
-
-    /* XI 1.x event */
-    event.deviceid = dev->id;
-    event.mode = mode;
-    event.type = (type == XI_FocusIn) ? DeviceFocusIn : DeviceFocusOut;
-    event.detail = detail;
-    event.window = pWin->drawable.id;
-    event.time = currentTime.milliseconds;
-
-    DeliverEventsToWindow(dev, pWin, (xEvent *) &event, 1,
-                          DeviceFocusChangeMask, NullGrab);
-
-    if (event.type == DeviceFocusIn)
-        DeliverStateNotifyEvent(dev, pWin);
-}
-
 int
 CheckGrabValues(ClientPtr client, GrabParameters *param)
 {
diff --git a/dix/enterleave.c b/dix/enterleave.c
index 725080a..761ab3b 100644
--- a/dix/enterleave.c
+++ b/dix/enterleave.c
@@ -30,11 +30,15 @@
 
 #include <X11/X.h>
 #include <X11/extensions/XI2.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/extensions/XI2proto.h>
 #include "inputstr.h"
 #include "windowstr.h"
 #include "scrnintstr.h"
 #include "exglobals.h"
 #include "enterleave.h"
+#include "eventconvert.h"
+#include "xkbsrv.h"
 
 /**
  * @file
@@ -602,6 +606,241 @@ DoEnterLeaveEvents(DeviceIntPtr pDev,
     DeviceEnterLeaveEvents(pDev, sourceid, fromWin, toWin, mode);
 }
 
+static void
+FixDeviceValuator(DeviceIntPtr dev, deviceValuator * ev, ValuatorClassPtr v,
+                  int first)
+{
+    int nval = v->numAxes - first;
+
+    ev->type = DeviceValuator;
+    ev->deviceid = dev->id;
+    ev->num_valuators = nval < 3 ? nval : 3;
+    ev->first_valuator = first;
+    switch (ev->num_valuators) {
+    case 3:
+        ev->valuator2 = v->axisVal[first + 2];
+    case 2:
+        ev->valuator1 = v->axisVal[first + 1];
+    case 1:
+        ev->valuator0 = v->axisVal[first];
+        break;
+    }
+    first += ev->num_valuators;
+}
+
+static void
+FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k,
+                     ButtonClassPtr b, ValuatorClassPtr v, int first)
+{
+    ev->type = DeviceStateNotify;
+    ev->deviceid = dev->id;
+    ev->time = currentTime.milliseconds;
+    ev->classes_reported = 0;
+    ev->num_keys = 0;
+    ev->num_buttons = 0;
+    ev->num_valuators = 0;
+
+    if (b) {
+        ev->classes_reported |= (1 << ButtonClass);
+        ev->num_buttons = b->numButtons;
+        memcpy((char *) ev->buttons, (char *) b->down, 4);
+    }
+    else if (k) {
+        ev->classes_reported |= (1 << KeyClass);
+        ev->num_keys = k->xkbInfo->desc->max_key_code -
+            k->xkbInfo->desc->min_key_code;
+        memmove((char *) &ev->keys[0], (char *) k->down, 4);
+    }
+    if (v) {
+        int nval = v->numAxes - first;
+
+        ev->classes_reported |= (1 << ValuatorClass);
+        ev->classes_reported |= valuator_get_mode(dev, 0) << ModeBitsShift;
+        ev->num_valuators = nval < 3 ? nval : 3;
+        switch (ev->num_valuators) {
+        case 3:
+            ev->valuator2 = v->axisVal[first + 2];
+        case 2:
+            ev->valuator1 = v->axisVal[first + 1];
+        case 1:
+            ev->valuator0 = v->axisVal[first];
+            break;
+        }
+    }
+}
+
+
+static void
+DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win)
+{
+    int evcount = 1;
+    deviceStateNotify *ev, *sev;
+    deviceKeyStateNotify *kev;
+    deviceButtonStateNotify *bev;
+
+    KeyClassPtr k;
+    ButtonClassPtr b;
+    ValuatorClassPtr v;
+    int nval = 0, nkeys = 0, nbuttons = 0, first = 0;
+
+    if (!(wOtherInputMasks(win)) ||
+        !(wOtherInputMasks(win)->inputEvents[dev->id] & DeviceStateNotifyMask))
+        return;
+
+    if ((b = dev->button) != NULL) {
+        nbuttons = b->numButtons;
+        if (nbuttons > 32)
+            evcount++;
+    }
+    if ((k = dev->key) != NULL) {
+        nkeys = k->xkbInfo->desc->max_key_code - k->xkbInfo->desc->min_key_code;
+        if (nkeys > 32)
+            evcount++;
+        if (nbuttons > 0) {
+            evcount++;
+        }
+    }
+    if ((v = dev->valuator) != NULL) {
+        nval = v->numAxes;
+
+        if (nval > 3)
+            evcount++;
+        if (nval > 6) {
+            if (!(k && b))
+                evcount++;
+            if (nval > 9)
+                evcount += ((nval - 7) / 3);
+        }
+    }
+
+    sev = ev = (deviceStateNotify *) malloc(evcount * sizeof(xEvent));
+    FixDeviceStateNotify(dev, ev, NULL, NULL, NULL, first);
+
+    if (b != NULL) {
+        FixDeviceStateNotify(dev, ev++, NULL, b, v, first);
+        first += 3;
+        nval -= 3;
+        if (nbuttons > 32) {
+            (ev - 1)->deviceid |= MORE_EVENTS;
+            bev = (deviceButtonStateNotify *) ev++;
+            bev->type = DeviceButtonStateNotify;
+            bev->deviceid = dev->id;
+            memcpy((char *) &bev->buttons[4], (char *) &b->down[4],
+                   DOWN_LENGTH - 4);
+        }
+        if (nval > 0) {
+            (ev - 1)->deviceid |= MORE_EVENTS;
+            FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
+            first += 3;
+            nval -= 3;
+        }
+    }
+
+    if (k != NULL) {
+        FixDeviceStateNotify(dev, ev++, k, NULL, v, first);
+        first += 3;
+        nval -= 3;
+        if (nkeys > 32) {
+            (ev - 1)->deviceid |= MORE_EVENTS;
+            kev = (deviceKeyStateNotify *) ev++;
+            kev->type = DeviceKeyStateNotify;
+            kev->deviceid = dev->id;
+            memmove((char *) &kev->keys[0], (char *) &k->down[4], 28);
+        }
+        if (nval > 0) {
+            (ev - 1)->deviceid |= MORE_EVENTS;
+            FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
+            first += 3;
+            nval -= 3;
+        }
+    }
+
+    while (nval > 0) {
+        FixDeviceStateNotify(dev, ev++, NULL, NULL, v, first);
+        first += 3;
+        nval -= 3;
+        if (nval > 0) {
+            (ev - 1)->deviceid |= MORE_EVENTS;
+            FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
+            first += 3;
+            nval -= 3;
+        }
+    }
+
+    DeliverEventsToWindow(dev, win, (xEvent *) sev, evcount,
+                          DeviceStateNotifyMask, NullGrab);
+    free(sev);
+}
+
+void
+DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
+                 WindowPtr pWin)
+{
+    deviceFocus event;
+    xXIFocusInEvent *xi2event;
+    DeviceIntPtr mouse;
+    int btlen, len, i;
+
+    mouse = IsFloating(dev) ? dev : GetMaster(dev, MASTER_POINTER);
+
+    /* XI 2 event */
+    btlen = (mouse->button) ? bits_to_bytes(mouse->button->numButtons) : 0;
+    btlen = bytes_to_int32(btlen);
+    len = sizeof(xXIFocusInEvent) + btlen * 4;
+
+    xi2event = calloc(1, len);
+    xi2event->type = GenericEvent;
+    xi2event->extension = IReqCode;
+    xi2event->evtype = type;
+    xi2event->length = bytes_to_int32(len - sizeof(xEvent));
+    xi2event->buttons_len = btlen;
+    xi2event->detail = detail;
+    xi2event->time = currentTime.milliseconds;
+    xi2event->deviceid = dev->id;
+    xi2event->sourceid = dev->id;       /* a device doesn't change focus by itself */
+    xi2event->mode = mode;
+    xi2event->root_x = FP1616(mouse->spriteInfo->sprite->hot.x, 0);
+    xi2event->root_y = FP1616(mouse->spriteInfo->sprite->hot.y, 0);
+
+    for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++)
+        if (BitIsOn(mouse->button->down, i))
+            SetBit(&xi2event[1], mouse->button->map[i]);
+
+    if (dev->key) {
+        xi2event->mods.base_mods = dev->key->xkbInfo->state.base_mods;
+        xi2event->mods.latched_mods = dev->key->xkbInfo->state.latched_mods;
+        xi2event->mods.locked_mods = dev->key->xkbInfo->state.locked_mods;
+        xi2event->mods.effective_mods = dev->key->xkbInfo->state.mods;
+
+        xi2event->group.base_group = dev->key->xkbInfo->state.base_group;
+        xi2event->group.latched_group = dev->key->xkbInfo->state.latched_group;
+        xi2event->group.locked_group = dev->key->xkbInfo->state.locked_group;
+        xi2event->group.effective_group = dev->key->xkbInfo->state.group;
+    }
+
+    FixUpEventFromWindow(dev->spriteInfo->sprite, (xEvent *) xi2event, pWin,
+                         None, FALSE);
+
+    DeliverEventsToWindow(dev, pWin, (xEvent *) xi2event, 1,
+                          GetEventFilter(dev, (xEvent *) xi2event), NullGrab);
+
+    free(xi2event);
+
+    /* XI 1.x event */
+    event.deviceid = dev->id;
+    event.mode = mode;
+    event.type = (type == XI_FocusIn) ? DeviceFocusIn : DeviceFocusOut;
+    event.detail = detail;
+    event.window = pWin->drawable.id;
+    event.time = currentTime.milliseconds;
+
+    DeliverEventsToWindow(dev, pWin, (xEvent *) &event, 1,
+                          DeviceFocusChangeMask, NullGrab);
+
+    if (event.type == DeviceFocusIn)
+        DeliverStateNotifyEvent(dev, pWin);
+}
+
 /**
  * Send focus out events to all windows between 'child' and 'ancestor'.
  * Events are sent running up the hierarchy.
diff --git a/dix/enterleave.h b/dix/enterleave.h
index c937c0e..a59d057 100644
--- a/dix/enterleave.h
+++ b/dix/enterleave.h
@@ -52,6 +52,11 @@ extern void DeviceEnterLeaveEvent(DeviceIntPtr mouse,
                                   int type,
                                   int mode,
                                   int detail, WindowPtr pWin, Window child);
+extern void DeviceFocusEvent(DeviceIntPtr dev,
+                             int type,
+                             int mode,
+                             int detail ,
+                             WindowPtr pWin);
 
 extern void EnterWindow(DeviceIntPtr dev, WindowPtr win, int mode);
 
diff --git a/include/exevents.h b/include/exevents.h
index feea170..321fc42 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -162,13 +162,6 @@ extern void
  ProcessOtherEvent(InternalEvent * /* ev */ ,
                    DeviceIntPtr /* other */ );
 
-extern void
- DeviceFocusEvent(DeviceIntPtr /* dev */ ,
-                  int /* type */ ,
-                  int /* mode */ ,
-                  int /* detail */ ,
-                  WindowPtr /* pWin */ );
-
 extern int
  CheckGrabValues(ClientPtr /* client */ ,
                  GrabParameters * /* param */ );
commit 749a593e49adccdf1225be28a521412ec85333f4
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed May 9 11:30:46 2012 +1000

    dix: undo transformation for missing valuators (#49347)
    
    last.valuators contains the transformed valuators of the device. If the
    device submits events with x/y missing, we need to get that from
    last.valuators and undo the transformation to that axis.
    
    X.Org Bug 49347 <http://bugs.freedesktop.org/show_bug.cgi?id=49347>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>

diff --git a/dix/getevents.c b/dix/getevents.c
index c960d44..ae4112f 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1166,16 +1166,33 @@ static void
 transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
 {
     double x, y, ox, oy;
+    int has_x, has_y;
+
+    has_x = valuator_mask_fetch_double(mask, 0, &ox);
+    has_y = valuator_mask_fetch_double(mask, 1, &oy);
+
+    if (!has_x && !has_y)
+        return;
+
+    if (!has_x || !has_y) {
+        struct pixman_f_transform invert;
+
+        /* undo transformation from last event */
+        ox = dev->last.valuators[0];
+        oy = dev->last.valuators[1];
+
+        pixman_f_transform_invert(&invert, &dev->transform);
+        transform(&invert, &ox, &oy);
+
+        x = ox;
+        y = oy;
+    }
 
     if (valuator_mask_isset(mask, 0))
         ox = x = valuator_mask_get_double(mask, 0);
-    else
-        ox = x = dev->last.valuators[0];
 
     if (valuator_mask_isset(mask, 1))
         oy = y = valuator_mask_get_double(mask, 1);
-    else
-        oy = y = dev->last.valuators[1];
 
     transform(&dev->transform, &x, &y);
 
commit 03318835a5a87a8a5cb3515130b5380d565c0d91
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon May 14 15:06:56 2012 +1000

    include: don't redeclare device events in xkbsrv.h
    
    ../../include/xkbsrv.h:308:51: warning: redundant redeclaration of
    ‘DeviceKeyPress’ [-Wredundant-decls]
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index 3b72885..a19c8fb 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -305,9 +305,6 @@ extern _X_EXPORT CARD32 xkbDebugFlags;
 #define	_XkbErrCode3(a,b,c)	_XkbErrCode2(a,(((unsigned int)(b))<<16)|(c))
 #define	_XkbErrCode4(a,b,c,d) _XkbErrCode3(a,b,((((unsigned int)(c))<<8)|(d)))
 
-extern _X_EXPORT int DeviceKeyPress, DeviceKeyRelease, DeviceMotionNotify;
-extern _X_EXPORT int DeviceButtonPress, DeviceButtonRelease;
-
 #define	Status		int
 
 extern _X_EXPORT void XkbUseMsg(void
commit 43754803c13c232fd5c37eb3d4b1ca2898d6a6cd
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon May 14 15:07:57 2012 +1000

    test: don't shadow parameter 'len'
    
    protocol-xiquerydevice.c:226:25: warning: declaration of ‘len’ shadows a
    parameter [-Wshadow]
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>

diff --git a/test/xi2/protocol-xiquerydevice.c b/test/xi2/protocol-xiquerydevice.c
index b45358e..9d13bbb 100644
--- a/test/xi2/protocol-xiquerydevice.c
+++ b/test/xi2/protocol-xiquerydevice.c
@@ -223,7 +223,7 @@ reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void *closure)
                            any->type == XIValuatorClass);
 
                 if (any->type == XIButtonClass) {
-                    int len;
+                    int l;
                     xXIButtonInfo *bi = (xXIButtonInfo *) any;
 
                     if (client->swapped)
@@ -231,10 +231,9 @@ reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void *closure)
 
                     assert(bi->num_buttons == devices.vcp->button->numButtons);
 
-                    len =
-                        2 + bi->num_buttons +
+                    l = 2 + bi->num_buttons +
                         bytes_to_int32(bits_to_bytes(bi->num_buttons));
-                    assert(bi->length == len);
+                    assert(bi->length == l);
                 }
                 else if (any->type == XIValuatorClass) {
                     xXIValuatorInfo *vi = (xXIValuatorInfo *) any;
commit 1bafc9f26bef0997c98b97efa888ed5e2a54f6f0
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon May 14 15:01:09 2012 +1000

    test: fix redundant declaration of "BadDevice"
    
    In file included from protocol-common.c:36:0:
    protocol-common.h:36:12: warning: redundant redeclaration of ‘BadDevice’
    [-Wredundant-decls]
    In file included from protocol-common.c:30:0:
    ../../Xi/exglobals.h:41:12: note: previous declaration of ‘BadDevice’ was
    here
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>

diff --git a/test/xi2/protocol-common.h b/test/xi2/protocol-common.h
index 1b17175..f27f248 100644
--- a/test/xi2/protocol-common.h
+++ b/test/xi2/protocol-common.h
@@ -33,8 +33,6 @@
 #ifndef PROTOCOL_COMMON_H
 #define PROTOCOL_COMMON_H
 
-extern int BadDevice;
-
 /* Check default values in a reply */
 #define reply_check_defaults(rep, len, type) \
     { \
diff --git a/test/xi2/protocol-xipassivegrabdevice.c b/test/xi2/protocol-xipassivegrabdevice.c
index 1d8c46b..84b386b 100644
--- a/test/xi2/protocol-xipassivegrabdevice.c
+++ b/test/xi2/protocol-xipassivegrabdevice.c
@@ -37,6 +37,7 @@
 #include "scrnintstr.h"
 #include "xipassivegrab.h"
 #include "exevents.h"
+#include "exglobals.h"
 
 #include "protocol-common.h"
 
diff --git a/test/xi2/protocol-xiquerydevice.c b/test/xi2/protocol-xiquerydevice.c
index e588f8d..b45358e 100644
--- a/test/xi2/protocol-xiquerydevice.c
+++ b/test/xi2/protocol-xiquerydevice.c
@@ -32,6 +32,7 @@
 #include <X11/Xatom.h>
 #include "inputstr.h"
 #include "extinit.h"
+#include "exglobals.h"
 #include "scrnintstr.h"
 #include "xkbsrv.h"
 
diff --git a/test/xi2/protocol-xiquerypointer.c b/test/xi2/protocol-xiquerypointer.c
index ff7ff5c..fc66b64 100644
--- a/test/xi2/protocol-xiquerypointer.c
+++ b/test/xi2/protocol-xiquerypointer.c
@@ -37,6 +37,7 @@
 #include "scrnintstr.h"
 #include "xiquerypointer.h"
 #include "exevents.h"
+#include "exglobals.h"
 
 #include "protocol-common.h"
 
diff --git a/test/xi2/protocol-xiselectevents.c b/test/xi2/protocol-xiselectevents.c
index 4daba87..8f6b947 100644
--- a/test/xi2/protocol-xiselectevents.c
+++ b/test/xi2/protocol-xiselectevents.c
@@ -55,6 +55,7 @@
 #include "windowstr.h"
 #include "extinit.h"            /* for XInputExtensionInit */
 #include "scrnintstr.h"
+#include "exglobals.h"
 #include "xiselectev.h"
 
 #include "protocol-common.h"
diff --git a/test/xi2/protocol-xisetclientpointer.c b/test/xi2/protocol-xisetclientpointer.c
index 51db4ac..90f1b94 100644
--- a/test/xi2/protocol-xisetclientpointer.c
+++ b/test/xi2/protocol-xisetclientpointer.c
@@ -44,6 +44,7 @@
 #include "scrnintstr.h"
 #include "xisetclientpointer.h"
 #include "exevents.h"
+#include "exglobals.h"
 
 #include "protocol-common.h"
 
diff --git a/test/xi2/protocol-xiwarppointer.c b/test/xi2/protocol-xiwarppointer.c
index c279ac4..4bea333 100644
--- a/test/xi2/protocol-xiwarppointer.c
+++ b/test/xi2/protocol-xiwarppointer.c
@@ -37,6 +37,7 @@
 #include "scrnintstr.h"
 #include "xiwarppointer.h"
 #include "exevents.h"
+#include "exglobals.h"
 
 #include "protocol-common.h"
 
commit 47e1d0ea43eb7a6caf774f375f11849d0d515e14
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon May 14 14:56:02 2012 +1000

    test: fix "userdata shadows global declaration" warnings
    
    protocol-xiquerypointer.c:124:72: warning: declaration of
    ‘userdata’ shadows a global declaration [-Wshadow]
    
    and similar
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>

diff --git a/test/xi2/protocol-xipassivegrabdevice.c b/test/xi2/protocol-xipassivegrabdevice.c
index 53c65bd..1d8c46b 100644
--- a/test/xi2/protocol-xipassivegrabdevice.c
+++ b/test/xi2/protocol-xipassivegrabdevice.c
@@ -54,7 +54,7 @@ int __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev,
                       GrabParameters *param, enum InputLevel grabtype,
                       GrabMask *mask);
 static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len,
-                                           char *data, void *userdata);
+                                           char *data, void *closure);
 
 int
 __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
@@ -85,7 +85,7 @@ __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev,
 }
 
 static void
-reply_XIPassiveGrabDevice(ClientPtr client, int len, char *data, void *userdata)
+reply_XIPassiveGrabDevice(ClientPtr client, int len, char *data, void *closure)
 {
     xXIPassiveGrabDeviceReply *rep = (xXIPassiveGrabDeviceReply *) data;
 
@@ -107,7 +107,7 @@ reply_XIPassiveGrabDevice(ClientPtr client, int len, char *data, void *userdata)
 
 static void
 reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data,
-                               void *userdata)
+                               void *closure)
 {
     int i;
 
diff --git a/test/xi2/protocol-xiquerydevice.c b/test/xi2/protocol-xiquerydevice.c
index 5e59e80..e588f8d 100644
--- a/test/xi2/protocol-xiquerydevice.c
+++ b/test/xi2/protocol-xiquerydevice.c
@@ -54,9 +54,9 @@ struct test_data {
 };
 
 static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data,
-                                     void *userdata);
+                                     void *closure);
 static void reply_XIQueryDevice(ClientPtr client, int len, char *data,
-                                void *userdata);
+                                void *closure);
 
 /* reply handling for the first bytes that constitute the reply */
 static void
@@ -86,10 +86,10 @@ reply_XIQueryDevice(ClientPtr client, int len, char *data, void *userdata)
 
 /* reply handling for the trailing bytes that constitute the device info */
 static void
-reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void *userdata)
+reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void *closure)
 {
     int i, j;
-    struct test_data *querydata = (struct test_data *) userdata;
+    struct test_data *querydata = (struct test_data *) closure;
 
     DeviceIntPtr dev;
     xXIDeviceInfo *info = (xXIDeviceInfo *) data;
diff --git a/test/xi2/protocol-xiquerypointer.c b/test/xi2/protocol-xiquerypointer.c
index 4756a6b..ff7ff5c 100644
--- a/test/xi2/protocol-xiquerypointer.c
+++ b/test/xi2/protocol-xiquerypointer.c
@@ -42,7 +42,7 @@
 
 static ClientRec client_request;
 static void reply_XIQueryPointer_data(ClientPtr client, int len,
-                                      char *data, void *userdata);
+                                      char *data, void *closure);
 
 static struct {
     DeviceIntPtr dev;
@@ -70,7 +70,7 @@ __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
 }
 
 static void
-reply_XIQueryPointer(ClientPtr client, int len, char *data, void *userdata)
+reply_XIQueryPointer(ClientPtr client, int len, char *data, void *closure)
 {
     xXIQueryPointerReply *rep = (xXIQueryPointerReply *) data;
     SpritePtr sprite;
@@ -121,7 +121,7 @@ reply_XIQueryPointer(ClientPtr client, int len, char *data, void *userdata)
 }
 
 static void
-reply_XIQueryPointer_data(ClientPtr client, int len, char *data, void *userdata)
+reply_XIQueryPointer_data(ClientPtr client, int len, char *data, void *closure)
 {
     reply_handler = reply_XIQueryPointer;
 }
diff --git a/test/xi2/protocol-xiqueryversion.c b/test/xi2/protocol-xiqueryversion.c
index 1347e86..aff0237 100644
--- a/test/xi2/protocol-xiqueryversion.c
+++ b/test/xi2/protocol-xiqueryversion.c
@@ -59,10 +59,10 @@ struct test_data {
 };
 
 static void
-reply_XIQueryVersion(ClientPtr client, int len, char *data, void *userdata)
+reply_XIQueryVersion(ClientPtr client, int len, char *data, void *closure)
 {
     xXIQueryVersionReply *rep = (xXIQueryVersionReply *) data;
-    struct test_data *versions = (struct test_data *) userdata;
+    struct test_data *versions = (struct test_data *) closure;
     unsigned int sver, cver, ver;
 
     if (client->swapped) {
@@ -85,10 +85,10 @@ reply_XIQueryVersion(ClientPtr client, int len, char *data, void *userdata)
 }
 
 static void
-reply_XIQueryVersion_multiple(ClientPtr client, int len, char *data, void *userdata)
+reply_XIQueryVersion_multiple(ClientPtr client, int len, char *data, void *closure)
 {
     xXIQueryVersionReply *rep = (xXIQueryVersionReply *) data;
-    struct test_data *versions = (struct test_data *) userdata;
+    struct test_data *versions = (struct test_data *) closure;
 
     reply_check_defaults(rep, len, XIQueryVersion);
     assert(rep->length == 0);
commit e6da635826bdda7f67bd492dda8dba8a97809213
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon May 14 14:51:58 2012 +1000

    test: fix "redundant declaration of devices" warning
    
    In file included from protocol-xiwarppointer.c:41:0:
    protocol-common.h:91:23: warning: redundant redeclaration of ‘devices’
    [-Wredundant-decls]
    protocol-common.h:86:3: note: previous declaration of ‘devices’ was here
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>

diff --git a/test/xi2/protocol-common.h b/test/xi2/protocol-common.h
index 04a1e89..1b17175 100644
--- a/test/xi2/protocol-common.h
+++ b/test/xi2/protocol-common.h
@@ -83,7 +83,7 @@ struct devices {
 
     int num_devices;
     int num_master_devices;
-} devices;
+};
 
 /**
  * The set of default devices available in all tests if necessary.
commit 693a31e704c0745b209e69711522417c4fa8541e
Author: Simon Thum <simon.thum at gmx.de>
Date:   Mon Apr 2 18:49:53 2012 +0200

    dix: indentation fixes for pointer acceleration
    
    Signed-off-by: Simon Thum <simon.thum at gmx.de>
    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 7f38865..0c62a01 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1332,13 +1332,10 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
 
 /* global list of acceleration schemes */
 ValuatorAccelerationRec pointerAccelerationScheme[] = {
-    {PtrAccelNoOp, NULL, NULL, NULL, NULL}
-    ,
+    {PtrAccelNoOp, NULL, NULL, NULL, NULL},
     {PtrAccelPredictable, acceleratePointerPredictable, NULL,
-     InitPredictableAccelerationScheme, AccelerationDefaultCleanup}
-    ,
-    {PtrAccelLightweight, acceleratePointerLightweight, NULL, NULL, NULL}
-    ,
+     InitPredictableAccelerationScheme, AccelerationDefaultCleanup},
+    {PtrAccelLightweight, acceleratePointerLightweight, NULL, NULL, NULL},
     {-1, NULL, NULL, NULL, NULL}        /* terminator */
 };
 
@@ -1375,8 +1372,7 @@ InitPointerAccelerationScheme(DeviceIntPtr dev, int scheme)
 
     if (pointerAccelerationScheme[i].AccelInitProc) {
         if (!pointerAccelerationScheme[i].AccelInitProc(dev,
-                                                        &pointerAccelerationScheme
-                                                        [i])) {
+                                            &pointerAccelerationScheme[i])) {
             return FALSE;
         }
     }
diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index a788575..338f415 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -788,7 +788,8 @@ ComputeAcceleration(DeviceIntPtr dev,
         result +=
             4.0f * BasicComputeAcceleration(dev, vel,
                                             (vel->last_velocity +
-                                             vel->velocity) / 2, threshold,
+                                             vel->velocity) / 2,
+                                            threshold,
                                             acc);
         result /= 6.0f;
         DebugAccelF("(dix ptracc) profile average [%.2f ... %.2f] is %.3f\n",
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
index 8778646..3bd982a 100644
--- a/include/ptrveloc.h
+++ b/include/ptrveloc.h
@@ -101,48 +101,43 @@ typedef struct _PredictableAccelSchemeRec {
 } PredictableAccelSchemeRec, *PredictableAccelSchemePtr;
 
 extern _X_EXPORT void
- InitVelocityData(DeviceVelocityPtr vel);
+InitVelocityData(DeviceVelocityPtr vel);
 
 extern _X_EXPORT void
- InitTrackers(DeviceVelocityPtr vel, int ntracker);
+InitTrackers(DeviceVelocityPtr vel, int ntracker);
 
 extern _X_EXPORT BOOL
 ProcessVelocityData2D(DeviceVelocityPtr vel, double dx, double dy, int time);
 
 extern _X_EXPORT double
-
 BasicComputeAcceleration(DeviceIntPtr dev, DeviceVelocityPtr vel,
                          double velocity, double threshold, double acc);
 
 extern _X_EXPORT void
- FreeVelocityData(DeviceVelocityPtr vel);
+FreeVelocityData(DeviceVelocityPtr vel);
 
 extern _X_EXPORT int
- SetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
+SetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
 
 extern _X_EXPORT DeviceVelocityPtr
 GetDevicePredictableAccelData(DeviceIntPtr dev);
 
 extern _X_EXPORT void
-
 SetDeviceSpecificAccelerationProfile(DeviceVelocityPtr vel,
                                      PointerAccelerationProfileFunc profile);
 
 extern _X_INTERNAL void
- AccelerationDefaultCleanup(DeviceIntPtr dev);
+AccelerationDefaultCleanup(DeviceIntPtr dev);
 
 extern _X_INTERNAL Bool
-
 InitPredictableAccelerationScheme(DeviceIntPtr dev,
                                   struct _ValuatorAccelerationRec *protoScheme);
 
 extern _X_INTERNAL void
-
 acceleratePointerPredictable(DeviceIntPtr dev, ValuatorMask *val,
                              CARD32 evtime);
 
 extern _X_INTERNAL void
-
 acceleratePointerLightweight(DeviceIntPtr dev, ValuatorMask *val,
                              CARD32 evtime);
 


More information about the Xquartz-changes mailing list