xserver: Branch 'glucose-2' - 78 commits

Alan Hourihane alanh at kemper.freedesktop.org
Wed Apr 18 16:58:55 EEST 2007


 GL/glx/Makefile.am                     |    4 
 GL/glx/glxcontext.h                    |    3 
 GL/glx/glxdri.c                        |    6 
 GL/glx/glxext.c                        |    2 
 GL/glx/glxext.h                        |    2 
 GL/glx/glxglcore.c                     |   33 --
 GL/glx/glxscreens.h                    |    3 
 GL/glx/indirect_size_get.c             |    6 
 GL/mesa/.gitignore                     |    2 
 GL/mesa/X/Makefile.am                  |    9 
 GL/mesa/X/xf86glx_util.c               |  151 ---------
 GL/mesa/X/xf86glx_util.h               |  105 ------
 GL/mesa/X/xf86glxint.h                 |   45 --
 GL/mesa/tnl/Makefile.am                |    2 
 GL/symlink-mesa.sh                     |    5 
 Xext/sync.c                            |    2 
 Xext/xcmisc.c                          |   13 
 Xext/xvmain.c                          |    8 
 Xext/xvmc.c                            |    2 
 Xi/allowev.c                           |    6 
 Xi/chgdctl.c                           |    6 
 Xi/chgfctl.c                           |   20 -
 Xi/chgkbd.c                            |    6 
 Xi/chgkmap.c                           |   10 
 Xi/chgprop.c                           |   10 
 Xi/chgptr.c                            |    6 
 Xi/closedev.c                          |    6 
 Xi/devbell.c                           |    6 
 Xi/exevents.c                          |   32 +-
 Xi/extinit.c                           |   24 -
 Xi/getbmap.c                           |    8 
 Xi/getdctl.c                           |   18 -
 Xi/getfctl.c                           |   20 -
 Xi/getfocus.c                          |    6 
 Xi/getkmap.c                           |    8 
 Xi/getmmap.c                           |    6 
 Xi/getprop.c                           |    8 
 Xi/getselev.c                          |    8 
 Xi/getvers.c                           |    8 
 Xi/grabdev.c                           |   10 
 Xi/grabdevb.c                          |    8 
 Xi/grabdevk.c                          |    8 
 Xi/gtmotion.c                          |    8 
 Xi/listdev.c                           |   24 -
 Xi/opendev.c                           |    8 
 Xi/queryst.c                           |   10 
 Xi/selectev.c                          |   10 
 Xi/sendexev.c                          |   10 
 Xi/setbmap.c                           |    8 
 Xi/setdval.c                           |    8 
 Xi/setfocus.c                          |    8 
 Xi/setmmap.c                           |    6 
 Xi/setmode.c                           |    8 
 Xi/stubs.c                             |   20 +
 Xi/ungrdev.c                           |    6 
 Xi/ungrdevb.c                          |    4 
 Xi/ungrdevk.c                          |    4 
 config/config.c                        |  113 +++++--
 configure.ac                           |   24 -
 dix/atom.c                             |    6 
 dix/devices.c                          |   36 +-
 dix/dispatch.c                         |    8 
 dix/dixfonts.c                         |    4 
 dix/dixutils.c                         |    4 
 dix/events.c                           |  466 +++++++++++++++++++++++++++++-
 dix/extension.c                        |    2 
 dix/getevents.c                        |   24 +
 dix/initatoms.c                        |    2 
 dix/main.c                             |    2 
 dix/privates.c                         |   28 -
 dix/resource.c                         |    4 
 exa/exa.c                              |    3 
 exa/exa.h                              |   19 +
 fb/Makefile.am                         |    2 
 fb/fbcmap.c                            |   91 -----
 fb/fbcmap_mi.c                         |  123 ++++++++
 hw/darwin/Makefile.am                  |    6 
 hw/dmx/Makefile.am                     |    7 
 hw/dmx/dmxcursor.c                     |  133 ++++++--
 hw/dmx/dmxinput.c                      |    3 
 hw/dmx/dmxinput.h                      |    2 
 hw/dmx/input/dmxbackend.c              |   20 -
 hw/dmx/input/dmxcommon.c               |   16 -
 hw/dmx/input/dmxconsole.c              |    9 
 hw/dmx/input/dmxdummy.c                |    2 
 hw/dmx/input/dmxevents.c               |  227 +++++++++++---
 hw/dmx/input/dmxinputinit.c            |  102 ++++++
 hw/dmx/input/dmxxinput.c               |    6 
 hw/dmx/input/lnx-keyboard.c            |   12 
 hw/kdrive/ati/ati_dma.c                |    2 
 hw/kdrive/src/kinput.c                 |   13 
 hw/vfb/Makefile.am                     |    4 
 hw/xfree86/common/xf86Config.c         |   12 
 hw/xfree86/common/xf86Configure.c      |   15 
 hw/xfree86/common/xf86DGA.c            |    3 
 hw/xfree86/common/xf86Helper.c         |    3 
 hw/xfree86/common/xf86Module.h         |    2 
 hw/xfree86/common/xf86Option.c         |    4 
 hw/xfree86/common/xf86Xinput.c         |   91 ++++-
 hw/xfree86/ddc/edid_modes.c            |   13 
 hw/xfree86/dixmods/Makefile.am         |    8 
 hw/xfree86/doc/man/xorg.conf.man.pre   |    4 
 hw/xfree86/dri/dri.c                   |  504 +++++++++++++++++++++------------
 hw/xfree86/dri/dri.h                   |   18 +
 hw/xfree86/dri/dristruct.h             |   24 +
 hw/xfree86/dri/sarea.h                 |    5 
 hw/xfree86/loader/loadmod.c            |    2 
 hw/xfree86/modes/xf86Crtc.c            |  145 +++++++--
 hw/xfree86/modes/xf86Crtc.h            |   19 +
 hw/xfree86/modes/xf86EdidModes.c       |   23 +
 hw/xfree86/modes/xf86RandR12.c         |   22 +
 hw/xfree86/modes/xf86RandR12.h         |    1 
 hw/xfree86/os-support/bsd/Makefile.am  |    3 
 hw/xfree86/os-support/bsd/ppc_video.c  |   33 ++
 hw/xfree86/os-support/bus/linuxPci.c   |    4 
 hw/xfree86/os-support/linux/lnx_init.c |   14 
 hw/xfree86/parser/Flags.c              |   28 -
 hw/xfree86/parser/write.c              |   20 -
 hw/xfree86/utils/xorgcfg/text-mode.c   |    4 
 hw/xfree86/xaa/xaaDashLine.c           |    2 
 hw/xfree86/xaa/xaaGC.c                 |    2 
 hw/xfree86/xaa/xaaGCmisc.c             |    2 
 hw/xfree86/xaa/xaaInit.c               |   11 
 hw/xfree86/xaa/xaaLineMisc.c           |    2 
 hw/xfree86/xaa/xaaWrapper.c            |    2 
 hw/xfree86/xaa/xaalocal.h              |    3 
 hw/xnest/Display.c                     |    2 
 hw/xnest/Events.c                      |    8 
 hw/xnest/Makefile.am                   |    4 
 hw/xprint/Makefile.am                  |    2 
 hw/xprint/ddxInit.c                    |    6 
 include/input.h                        |    5 
 mi/micmap.c                            |    4 
 mi/mieq.c                              |    6 
 os/WaitFor.c                           |    9 
 os/log.c                               |    4 
 os/oscolor.c                           |    2 
 os/utils.c                             |    8 
 randr/rrcrtc.c                         |    6 
 randr/rrscreen.c                       |   31 +-
 render/glyph.c                         |    4 
 141 files changed, 2280 insertions(+), 1187 deletions(-)

New commits:
diff-tree da2c4faa9f09e2aba358f803070f687bed76da43 (from parents)
Merge: 1970562753660729dc0cecab8072dd991cfd61da 53fb42e65c2b2ff58a4a324b7f05cff8a587720a
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Wed Apr 18 14:58:19 2007 +0100

    Merge branch 'origin' into glucose-2

diff --cc hw/xfree86/dri/dri.c
index cef5ef3,35da8a6..987a9f9
@@@ -77,9 -78,9 +78,10 @@@
  extern Bool noPanoramiXExtension;
  #endif
  
+ static int DRIEntPrivIndex = -1;
  static int DRIScreenPrivIndex = -1;
  static int DRIWindowPrivIndex = -1;
 +static int DRIPixmapPrivIndex = -1;
  static unsigned long DRIGeneration = 0;
  static unsigned int DRIDrawableValidationStamp = 0;
  
diff-tree 53fb42e65c2b2ff58a4a324b7f05cff8a587720a (from fc162c6cfa06f0b012743d6d79cef45cf0166229)
Author: Erik Andrén <erik.andren at gmail.com>
Date:   Tue Apr 17 21:34:47 2007 -0700

    Syncmaster 226 monitor needs 60Hz refresh (#10545).
    
    I've managed to solve my own bug (#10545) by applying the following
    patch to the xserver.
    
    Please apply.
    
    <Conspiracy mode on>
    This monitor is "Vista Certified". I wonder if this is a pure coincidence...
    <Conspiracy mode off>
    
    With kind regards
    Erik Andrén
    (cherry picked from commit a63704f14a1d97b9a00fef6fa290e74e51b9732b)

diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index 18e42dd..46cb6c4 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -86,6 +86,11 @@ static Bool quirk_prefer_large_60 (int s
     if (memcmp (DDC->vendor.name, "ACR", 4) == 0 &&
 	DDC->vendor.prod_id == 44358)
 	return TRUE;
+
+    /* Samsung SyncMaster 226BW */
+    if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
+	DDC->vendor.prod_id == 638)
+	return TRUE;
     
     return FALSE;
 }
diff-tree fc162c6cfa06f0b012743d6d79cef45cf0166229 (from c41e3bd713206c0bbd8ab8cef4c83eb7ba7e1c3c)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Mon Apr 16 09:55:58 2007 -0700

    Allow outputs to be explicitly enabled in config, overriding detect.
    
    Option "Enable" "True" will force the server to enable an output at startup
    time, even if the output is not connected. This also causes the default
    modes to be added for this output, allowing even sync ranges to be used to
    pick out standard modes.
    (cherry picked from commit a3d73ba2cb7e13a6d129cd88d6a7f7d756e2ced2)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 87820de..ad0f5ff 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -436,15 +436,29 @@ xf86OutputSetMonitor (xf86OutputPtr outp
 }
 
 static Bool
-xf86OutputEnabled (xf86OutputPtr    output)
+xf86OutputEnabled (xf86OutputPtr output)
 {
-    /* Check to see if this output was disabled in the config file */
-    if (xf86ReturnOptValBool (output->options, OPTION_ENABLE, TRUE) == FALSE ||
-	xf86ReturnOptValBool (output->options, OPTION_DISABLE, FALSE) == TRUE)
+    Bool    enable, disable;
+
+    /* check to see if this output was enabled in the config file */
+    if (xf86GetOptValBool (output->options, OPTION_ENABLE, &enable) && enable)
+    {
+	xf86DrvMsg (output->scrn->scrnIndex, X_INFO,
+		    "Output %s enabled by config file\n", output->name);
+	return TRUE;
+    }
+    /* or if this output was disabled in the config file */
+    if (xf86GetOptValBool (output->options, OPTION_DISABLE, &disable) && disable)
     {
+	xf86DrvMsg (output->scrn->scrnIndex, X_INFO,
+		    "Output %s disabled by config file\n", output->name);
 	return FALSE;
     }
-    return TRUE;
+    /* otherwise, enable if it is not disconnected */
+    enable = output->status != XF86OutputStatusDisconnected;
+    xf86DrvMsg (output->scrn->scrnIndex, X_INFO,
+    	    "Output %s %sconnected\n", output->name, enable ? "" : "dis");
+    return enable;
 }
 
 static Bool
@@ -1232,7 +1246,7 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, 
 	 */
 	output->status = (*output->funcs->detect)(output);
 
-	if (output->status == XF86OutputStatusDisconnected)
+	if (!xf86OutputEnabled (output))
 	{
 	    xf86OutputSetEDID (output, NULL);
 	    continue;
@@ -1543,8 +1557,7 @@ xf86InitialConfiguration (ScrnInfoPtr sc
 	xf86OutputPtr output = config->output[o];
 	
 	modes[o] = NULL;
-	enabled[o] = (xf86OutputEnabled (output) &&
-		      output->status != XF86OutputStatusDisconnected);
+	enabled[o] = xf86OutputEnabled (output);
     }
     
     /*
@@ -1589,8 +1602,20 @@ xf86InitialConfiguration (ScrnInfoPtr sc
     {
 	xf86OutputPtr output = config->output[o];
 	
-	if (enabled[o] && !modes[o])
-	    modes[o] = xf86ClosestMode (output, target_mode, target_rotation, width, height);
+	if (enabled[o])
+	{
+	    if (!modes[o])
+		modes[o] = xf86ClosestMode (output, target_mode,
+					    target_rotation, width, height);
+	    if (!modes[o])
+		xf86DrvMsg (scrn->scrnIndex, X_ERROR,
+			    "Output %s enabled but has no modes\n",
+			    output->name);
+	    else
+		xf86DrvMsg (scrn->scrnIndex, X_INFO,
+			    "Output %s using initial mode %s\n",
+			    output->name, modes[o]->name);
+	}
     }
 
     /*
diff-tree c41e3bd713206c0bbd8ab8cef4c83eb7ba7e1c3c (from 97a2c2579c56c304705c934f3b536473645747df)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Mon Apr 16 09:53:42 2007 -0700

    Use default screen monitor for one of the outputs.
    
    By default, use the screen monitor section for output 0, however, a driver
    can change which output gets the screen monitor by calling
    xf86OutputUseScreenMonitor.
    (cherry picked from commit f4a8e54caf6b9431711383a39f55a18e7fd654f4)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 7e7c7e7..87820de 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -414,10 +414,25 @@ xf86OutputSetMonitor (xf86OutputPtr outp
     xfree (option_name);
     output->conf_monitor = xf86findMonitor (monitor,
 					    xf86configptr->conf_monitor_lst);
+    /*
+     * Find the monitor section of the screen and use that
+     */
+    if (!output->conf_monitor && output->use_screen_monitor)
+	output->conf_monitor = xf86findMonitor (output->scrn->monitor->id,
+						xf86configptr->conf_monitor_lst);
     if (output->conf_monitor)
+    {
+	xf86DrvMsg (output->scrn->scrnIndex, X_INFO,
+		    "Output %s using monitor section %s\n",
+		    output->name, output->conf_monitor->mon_identifier);
 	xf86ProcessOptions (output->scrn->scrnIndex,
 			    output->conf_monitor->mon_option_lst,
 			    output->options);
+    }
+    else
+	xf86DrvMsg (output->scrn->scrnIndex, X_INFO,
+		    "Output %s has no monitor section\n",
+		    output->name);
 }
 
 static Bool
@@ -463,7 +478,7 @@ xf86OutputInitialRotation (xf86OutputPtr
 
 xf86OutputPtr
 xf86OutputCreate (ScrnInfoPtr		    scrn,
-		  const xf86OutputFuncsRec *funcs,
+		  const xf86OutputFuncsRec  *funcs,
 		  const char		    *name)
 {
     xf86OutputPtr	output, *outputs;
@@ -486,6 +501,10 @@ xf86OutputCreate (ScrnInfoPtr		    scrn,
 	strcpy (output->name, name);
     }
     output->subpixel_order = SubPixelUnknown;
+    /*
+     * Use the old per-screen monitor section for the first output
+     */
+    output->use_screen_monitor = (xf86_config->num_output == 0);
 #ifdef RANDR_12_INTERFACE
     output->randr_output = NULL;
 #endif
@@ -537,6 +556,16 @@ xf86OutputRename (xf86OutputPtr output, 
 }
 
 void
+xf86OutputUseScreenMonitor (xf86OutputPtr output, Bool use_screen_monitor)
+{
+    if (use_screen_monitor != output->use_screen_monitor)
+    {
+	output->use_screen_monitor = use_screen_monitor;
+	xf86OutputSetMonitor (output);
+    }
+}
+
+void
 xf86OutputDestroy (xf86OutputPtr output)
 {
     ScrnInfoPtr		scrn = output->scrn;
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 030f6bf..0c019e0 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -479,6 +479,9 @@ struct _xf86Output {
     /** driver private information */
     void		*driver_private;
     
+    /** Whether to use the old per-screen Monitor config section */
+    Bool		use_screen_monitor;
+
 #ifdef RANDR_12_INTERFACE
     /**
      * RandR 1.2 output structure.
@@ -618,9 +621,12 @@ xf86CrtcInUse (xf86CrtcPtr crtc);
  * Output functions
  */
 xf86OutputPtr
-xf86OutputCreate (ScrnInfoPtr		scrn,
-		      const xf86OutputFuncsRec *funcs,
-		      const char	*name);
+xf86OutputCreate (ScrnInfoPtr		    scrn,
+		  const xf86OutputFuncsRec  *funcs,
+		  const char		    *name);
+
+void
+xf86OutputUseScreenMonitor (xf86OutputPtr output, Bool use_screen_monitor);
 
 Bool
 xf86OutputRename (xf86OutputPtr output, const char *name);
diff-tree 97a2c2579c56c304705c934f3b536473645747df (from deda7791dfa34d0563c8d7fa2a0660ac27e6858c)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Mon Apr 16 09:39:47 2007 -0700

    Using wrong log level in extension to built-in message
    
    was: typo in built-in module log message
    (cherry picked from commit 00cfd1f765895b4d1b2234f3203727a8871b64b0)

diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index db12da4..6a1c65e 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -869,7 +869,7 @@ doLoadModule(const char *module, const c
     for (cim = compiled_in_modules; *cim; cim++)
 	if (!strcmp (module, *cim))
 	{
-	    xf86MsgVerb(X_INFO, 3, "Module already built-in\n");
+	    xf86MsgVerb(X_INFO, 0, "Module already built-in\n");
 	    return (ModuleDescPtr) 1;
 	}
 
diff-tree deda7791dfa34d0563c8d7fa2a0660ac27e6858c (from 02d42f344ce020c9b84723671cb9c68d5c064933)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 16 11:35:22 2007 -0600

    remove sources deleted in Mesa

diff --git a/GL/mesa/tnl/Makefile.am b/GL/mesa/tnl/Makefile.am
index 84301d3..b3c8206 100644
--- a/GL/mesa/tnl/Makefile.am
+++ b/GL/mesa/tnl/Makefile.am
@@ -21,8 +21,6 @@ INCLUDES = -I at MESA_SOURCE@/include \
 nodist_libtnl_la_SOURCES = t_context.c \
                       t_draw.c \
                       t_pipeline.c \
-                      t_vb_arbprogram.c \
-                      t_vb_arbprogram_sse.c \
                       t_vb_cull.c \
                       t_vb_fog.c \
                       t_vb_light.c \
diff-tree 02d42f344ce020c9b84723671cb9c68d5c064933 (from b5823ea3e1ed5a0449d44da05165a46719dcf287)
Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Date:   Mon Apr 16 17:24:53 2007 +0200

    Changes for single-entity multi-screen DRI.
    
    The entity (device) has a locking SAREA and a master file descriptor
    that optionally isn't closed between server generation.
    
    The locking SAREA contains the device hardware lock.
    Each DRI screen creates an new SAREA containing the drawable lock,
    drawable-and private info, the drawable SAREA.
    
    The first screen optionally shares its drawable SAREA with the
    device SAREA.
    
    Default is to close the master descriptor between server generations,
    and to share the drawable SAREA of the first screen with the device locking
    SAREA. Thus we should (hopefully) have full backwards compatibility.
    
    Mesa changes to support single-device multiple screens are pending.

diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index 7bd07c0..35da8a6 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -43,6 +43,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 #include <string.h>
 #include <stdio.h>
 #include <sys/ioctl.h>
+#include <errno.h>
 
 #define NEED_REPLIES
 #define NEED_EVENTS
@@ -77,6 +78,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 extern Bool noPanoramiXExtension;
 #endif
 
+static int DRIEntPrivIndex = -1;
 static int DRIScreenPrivIndex = -1;
 static int DRIWindowPrivIndex = -1;
 static unsigned long DRIGeneration = 0;
@@ -112,18 +114,203 @@ DRIDrvMsg(int scrnIndex, MessageType typ
 }
 
 
+static void
+DRIOpenDRMCleanup(DRIEntPrivPtr pDRIEntPriv)
+{
+    if (pDRIEntPriv->pLSAREA != NULL) {
+	drmUnmap(pDRIEntPriv->pLSAREA, pDRIEntPriv->sAreaSize);
+	pDRIEntPriv->pLSAREA = NULL;
+    }
+    if (pDRIEntPriv->hLSAREA != 0) {
+	drmRmMap(pDRIEntPriv->drmFD, pDRIEntPriv->hLSAREA);
+    }
+    if (pDRIEntPriv->drmFD >= 0) {
+	drmClose(pDRIEntPriv->drmFD);
+	pDRIEntPriv->drmFD = 0;
+    }
+}
+
+int
+DRIMasterFD(ScrnInfoPtr pScrn)
+{
+    return DRI_ENT_PRIV(pScrn)->drmFD;
+}
+
+void *
+DRIMasterSareaPointer(ScrnInfoPtr pScrn)
+{
+    return DRI_ENT_PRIV(pScrn)->pLSAREA;
+}
+
+drm_handle_t
+DRIMasterSareaHandle(ScrnInfoPtr pScrn)
+{
+    return DRI_ENT_PRIV(pScrn)->hLSAREA;
+}
+
+
+Bool
+DRIOpenDRMMaster(ScrnInfoPtr pScrn,
+		 unsigned long sAreaSize,
+		 const char *busID,
+		 const char *drmDriverName)
+{
+    drmSetVersion saveSv, sv;
+    Bool drmWasAvailable;
+    DRIEntPrivPtr pDRIEntPriv;
+    DRIEntPrivRec tmp;
+    drmVersionPtr drmlibv;
+    int drmlibmajor, drmlibminor;
+    const char *openBusID;
+    int count;
+    int err;
+
+    if (DRIEntPrivIndex == -1)
+	DRIEntPrivIndex = xf86AllocateEntityPrivateIndex();
+
+    pDRIEntPriv = DRI_ENT_PRIV(pScrn);
+
+    if (pDRIEntPriv && pDRIEntPriv->drmFD != -1)
+	return TRUE;
+
+    drmWasAvailable = drmAvailable();
+
+    memset(&tmp, 0, sizeof(tmp));
+
+    /* Check the DRM lib version.
+     * drmGetLibVersion was not supported in version 1.0, so check for
+     * symbol first to avoid possible crash or hang.
+     */
+
+    drmlibmajor = 1;
+    drmlibminor = 0;
+    if (xf86LoaderCheckSymbol("drmGetLibVersion")) {
+	drmlibv = drmGetLibVersion(-1);
+	if (drmlibv != NULL) {
+	    drmlibmajor = drmlibv->version_major;
+	    drmlibminor = drmlibv->version_minor;
+	    drmFreeVersion(drmlibv);
+	}
+    }
+
+    /* Check if the libdrm can handle falling back to loading based on name
+     * if a busid string is passed.
+     */
+    openBusID = (drmlibmajor == 1 && drmlibminor >= 2) ? busID : NULL;
+
+    tmp.drmFD = -1;
+    sv.drm_di_major = 1;
+    sv.drm_di_minor = 1;
+    sv.drm_dd_major = -1;
+
+    saveSv = sv;
+    count = 10;
+    while (count--) {
+	tmp.drmFD = drmOpen(drmDriverName, openBusID);
+
+	if (tmp.drmFD < 0) {
+	    DRIDrvMsg(-1, X_ERROR, "[drm] drmOpen failed.\n");
+	    goto out_err;
+	}
+
+	err = drmSetInterfaceVersion(tmp.drmFD, &sv);
+
+	if (err != -EPERM)
+	    break;
+
+	sv = saveSv;
+	drmClose(tmp.drmFD);
+	tmp.drmFD = -1;
+	usleep(100000);
+    }
+
+    if (tmp.drmFD <= 0) {
+	DRIDrvMsg(-1, X_ERROR, "[drm] DRM was busy with another master.\n");
+	goto out_err;
+    }
+
+    if (!drmWasAvailable) {
+	DRIDrvMsg(-1, X_INFO,
+		  "[drm] loaded kernel module for \"%s\" driver.\n",
+		  drmDriverName);
+    }
+
+    if (err != 0) {
+	sv.drm_di_major = 1;
+	sv.drm_di_minor = 0;
+    }
+
+    DRIDrvMsg(-1, X_INFO, "[drm] DRM interface version %d.%d\n",
+	      sv.drm_di_major, sv.drm_di_minor);
+
+    if (sv.drm_di_major == 1 && sv.drm_di_minor >= 1)
+	err = 0;
+    else
+	err = drmSetBusid(tmp.drmFD, busID);
+
+    if (err) {
+	DRIDrvMsg(-1, X_ERROR, "[drm] Could not set DRM device bus ID.\n");
+	goto out_err;
+    }
+
+    /*
+     * Create a lock-containing sarea.
+     */
+
+    if (drmAddMap( tmp.drmFD, 0, sAreaSize, DRM_SHM,
+		   DRM_CONTAINS_LOCK, &tmp.hLSAREA) < 0) {
+        DRIDrvMsg(-1, X_INFO, "[drm] Could not create SAREA for DRM lock.\n");
+	tmp.hLSAREA = 0;
+	goto out_err;
+    }
+
+    if (drmMap( tmp.drmFD, tmp.hLSAREA, sAreaSize,
+		(drmAddressPtr)(&tmp.pLSAREA)) < 0) {
+        DRIDrvMsg(-1, X_INFO, "[drm] Mapping SAREA for DRM lock failed.\n");
+	tmp.pLSAREA = NULL;
+	goto out_err;
+    }
+
+    memset(tmp.pLSAREA, 0, sAreaSize);
+
+    /*
+     * Reserved contexts are handled by the first opened screen.
+     */
+
+    tmp.resOwner = NULL;
+
+    if (!pDRIEntPriv)
+	pDRIEntPriv = xnfcalloc(sizeof(*pDRIEntPriv), 1);
+
+    if (!pDRIEntPriv) {
+        DRIDrvMsg(-1, X_INFO, "[drm] Failed to allocate memory for "
+		  "DRM device.\n");
+	goto out_err;
+    }
+    *pDRIEntPriv = tmp;
+    xf86GetEntityPrivate((pScrn)->entityList[0],DRIEntPrivIndex)->ptr =
+	pDRIEntPriv;
+
+    DRIDrvMsg(-1, X_INFO, "[drm] DRM open master succeeded.\n");
+    return TRUE;
+
+  out_err:
+
+    DRIOpenDRMCleanup(&tmp);
+    return FALSE;
+}
+
+
 Bool
 DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
 {
     DRIScreenPrivPtr    pDRIPriv;
     drm_context_t *       reserved;
     int                 reserved_count;
-    int                 i, fd, drmWasAvailable;
+    int                 i;
     Bool                xineramaInCore = FALSE;
-    int                 err = 0;
-    char                *openbusid;
-    drmVersionPtr       drmlibv;
-    int                 drmlibmajor, drmlibminor, drmdimajor, drmdiminor;
+    DRIEntPrivPtr       pDRIEntPriv;
+    ScrnInfoPtr         pScrn = xf86Screens[pScreen->myNum];
 
     if (DRIGeneration != serverGeneration) {
 	if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0)
@@ -153,47 +340,12 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfo
 	}
     }
 
-    drmWasAvailable = drmAvailable();
-
-    /* Check the DRM lib version.
-     * drmGetLibVersion was not supported in version 1.0, so check for
-     * symbol first to avoid possible crash or hang.
-     */
-    drmlibmajor = 1;
-    drmlibminor = 0;
-    if (xf86LoaderCheckSymbol("drmGetLibVersion")) {
-	drmlibv = drmGetLibVersion(-1);
-	if (drmlibv != NULL) {
-	    drmlibmajor = drmlibv->version_major;
-	    drmlibminor = drmlibv->version_minor;
-	    drmFreeVersion(drmlibv);
-	}
-    }
-
-    /* Check if the libdrm can handle falling back to loading based on name
-     * if a busid string is passed.
-     */
-    if (drmlibmajor == 1 && drmlibminor >= 2)
-	openbusid = pDRIInfo->busIdString;
-    else
-	openbusid = NULL;
-
-    /* Note that drmOpen will try to load the kernel module, if needed. */
-    fd = drmOpen(pDRIInfo->drmDriverName, openbusid);
-    if (fd < 0) {
-        /* failed to open DRM */
-        pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
-        DRIDrvMsg(pScreen->myNum, X_INFO,
-                  "[drm] drmOpen failed\n");
-        return FALSE;
-    }
+    if (!DRIOpenDRMMaster(pScrn, pDRIInfo->SAREASize,
+			  pDRIInfo->busIdString,
+			  pDRIInfo->drmDriverName))
+	return FALSE;
 
-    if (!drmWasAvailable) {
-       /* drmOpen loaded the kernel module, print a message to say so */
-       DRIDrvMsg(pScreen->myNum, X_INFO,
-                 "[drm] loaded kernel module for \"%s\" driver\n",
-                 pDRIInfo->drmDriverName);
-    }
+    pDRIEntPriv = DRI_ENT_PRIV(pScrn);
 
     pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec));
     if (!pDRIPriv) {
@@ -202,7 +354,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfo
     }
 
     pScreen->devPrivates[DRIScreenPrivIndex].ptr = (pointer) pDRIPriv;
-    pDRIPriv->drmFD = fd;
+    pDRIPriv->drmFD = pDRIEntPriv->drmFD;
     pDRIPriv->directRenderingSupport = TRUE;
     pDRIPriv->pDriverInfo = pDRIInfo;
     pDRIPriv->nrWindows = 0;
@@ -214,89 +366,54 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfo
 
     pDRIPriv->grabbedDRILock = FALSE;
     pDRIPriv->drmSIGIOHandlerInstalled = FALSE;
+    *pDRMFD = pDRIPriv->drmFD;
 
-    if (drmlibmajor == 1 && drmlibminor >= 2) {
-	drmSetVersion sv;
+    if (pDRIEntPriv->sAreaGrabbed || pDRIInfo->allocSarea) {
 
-	/* Get the interface version, asking for 1.1. */
-	sv.drm_di_major = 1;
-	sv.drm_di_minor = 1;
-	sv.drm_dd_major = -1;
-	err = drmSetInterfaceVersion(pDRIPriv->drmFD, &sv);
-	if (err == 0) {
-	    drmdimajor = sv.drm_di_major;
-	    drmdiminor = sv.drm_di_minor;
-	} else {
-	    /* failure, so set it to 1.0.0. */
-	    drmdimajor = 1;
-	    drmdiminor = 0;
+	if (drmAddMap( pDRIPriv->drmFD,
+		       0,
+		       pDRIPriv->pDriverInfo->SAREASize,
+		       DRM_SHM,
+		       0,
+		       &pDRIPriv->hSAREA) < 0)
+	{
+	    pDRIPriv->directRenderingSupport = FALSE;
+	    pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+	    drmClose(pDRIPriv->drmFD);
+	    DRIDrvMsg(pScreen->myNum, X_INFO,
+		      "[drm] drmAddMap failed\n");
+	    return FALSE;
 	}
-    }
-    else {
-	/* We can't check the DI DRM interface version, so set it to 1.0.0. */
-	drmdimajor = 1;
-	drmdiminor = 0;
-    }
-    DRIDrvMsg(pScreen->myNum, X_INFO,
-              "[drm] DRM interface version %d.%d\n", drmdimajor, drmdiminor);
-
-    /* If the interface minor number is 1.1, then we've opened a DRM device
-     * that already had the busid set through drmOpen.
-     */
-    if (drmdimajor == 1 && drmdiminor >= 1)
-	err = 0;
-    else
-	err = drmSetBusid(pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString);
-
-    if (err < 0) {
-	pDRIPriv->directRenderingSupport = FALSE;
-	pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
-	drmClose(pDRIPriv->drmFD);
-        DRIDrvMsg(pScreen->myNum, X_INFO,
-                  "[drm] drmSetBusid failed (%d, %s), %s\n",
-                  pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString, strerror(-err));
-	return FALSE;
-    }
-
-    *pDRMFD = pDRIPriv->drmFD;
-    DRIDrvMsg(pScreen->myNum, X_INFO,
-	      "[drm] created \"%s\" driver at busid \"%s\"\n",
-	      pDRIPriv->pDriverInfo->drmDriverName,
-	      pDRIPriv->pDriverInfo->busIdString);
+	DRIDrvMsg(pScreen->myNum, X_INFO,
+		  "[drm] added %d byte SAREA at %p\n",
+		  pDRIPriv->pDriverInfo->SAREASize, pDRIPriv->hSAREA);
 
-    if (drmAddMap( pDRIPriv->drmFD,
-		   0,
-		   pDRIPriv->pDriverInfo->SAREASize,
-		   DRM_SHM,
-		   DRM_CONTAINS_LOCK,
-		   &pDRIPriv->hSAREA) < 0)
-    {
-	pDRIPriv->directRenderingSupport = FALSE;
-	pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
-	drmClose(pDRIPriv->drmFD);
-        DRIDrvMsg(pScreen->myNum, X_INFO,
-                  "[drm] drmAddMap failed\n");
-	return FALSE;
+	/* Backwards compat. */
+	if (drmMap( pDRIPriv->drmFD,
+		    pDRIPriv->hSAREA,
+		    pDRIPriv->pDriverInfo->SAREASize,
+		    (drmAddressPtr)(&pDRIPriv->pSAREA)) < 0)
+	{
+	    pDRIPriv->directRenderingSupport = FALSE;
+	    pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+	    drmClose(pDRIPriv->drmFD);
+	    DRIDrvMsg(pScreen->myNum, X_INFO,
+		      "[drm] drmMap failed\n");
+	    return FALSE;
+	}
+	DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] mapped SAREA %p to %p\n",
+		  pDRIPriv->hSAREA, pDRIPriv->pSAREA);
+	memset(pDRIPriv->pSAREA, 0, pDRIPriv->pDriverInfo->SAREASize);
+    } else {
+	DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] Using the DRM lock "
+		  "SAREA also for drawables.\n");
+	pDRIPriv->hSAREA = pDRIEntPriv->hLSAREA;
+	pDRIPriv->pSAREA = (XF86DRISAREAPtr) pDRIEntPriv->pLSAREA;
+	pDRIEntPriv->sAreaGrabbed = TRUE;
     }
-    DRIDrvMsg(pScreen->myNum, X_INFO,
-	      "[drm] added %d byte SAREA at %p\n",
-	      pDRIPriv->pDriverInfo->SAREASize, pDRIPriv->hSAREA);
 
-    if (drmMap( pDRIPriv->drmFD,
-		pDRIPriv->hSAREA,
-		pDRIPriv->pDriverInfo->SAREASize,
-		(drmAddressPtr)(&pDRIPriv->pSAREA)) < 0)
-    {
-	pDRIPriv->directRenderingSupport = FALSE;
-	pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
-	drmClose(pDRIPriv->drmFD);
-        DRIDrvMsg(pScreen->myNum, X_INFO,
-                  "[drm] drmMap failed\n");
-	return FALSE;
-    }
-    memset(pDRIPriv->pSAREA, 0, pDRIPriv->pDriverInfo->SAREASize);
-    DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] mapped SAREA %p to %p\n",
-	      pDRIPriv->hSAREA, pDRIPriv->pSAREA);
+    pDRIPriv->hLSAREA = pDRIEntPriv->hLSAREA;
+    pDRIPriv->pLSAREA = pDRIEntPriv->pLSAREA;
 
     if (drmAddMap( pDRIPriv->drmFD,
 		   (drm_handle_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress,
@@ -316,22 +433,26 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfo
     DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] framebuffer handle = %p\n",
 	      pDRIPriv->hFrameBuffer);
 
-				/* Add tags for reserved contexts */
-    if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
-					      &reserved_count))) {
-	int  i;
-	void *tag;
-
-	for (i = 0; i < reserved_count; i++) {
-	    tag = DRICreateContextPrivFromHandle(pScreen,
-						 reserved[i],
-						 DRI_CONTEXT_RESERVED);
-	    drmAddContextTag(pDRIPriv->drmFD, reserved[i], tag);
+    if (pDRIEntPriv->resOwner == NULL) {
+	pDRIEntPriv->resOwner = pScreen;
+
+	/* Add tags for reserved contexts */
+	if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
+						  &reserved_count))) {
+	    int  i;
+	    void *tag;
+
+	    for (i = 0; i < reserved_count; i++) {
+		tag = DRICreateContextPrivFromHandle(pScreen,
+						     reserved[i],
+						     DRI_CONTEXT_RESERVED);
+		drmAddContextTag(pDRIPriv->drmFD, reserved[i], tag);
+	    }
+	    drmFreeReservedContextList(reserved);
+	    DRIDrvMsg(pScreen->myNum, X_INFO,
+		      "[drm] added %d reserved context%s for kernel\n",
+		      reserved_count, reserved_count > 1 ? "s" : "");
 	}
-	drmFreeReservedContextList(reserved);
-	DRIDrvMsg(pScreen->myNum, X_INFO,
-		  "[drm] added %d reserved context%s for kernel\n",
-		  reserved_count, reserved_count > 1 ? "s" : "");
     }
 
     /* validate max drawable table entry set by driver */
@@ -349,6 +470,11 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfo
 	pDRIPriv->pSAREA->drawableTable[i].flags = 0;
     }
 
+    pDRIPriv->pLockRefCount = &pDRIEntPriv->lockRefCount;
+    pDRIPriv->pLockingContext = &pDRIEntPriv->lockingContext;
+
+    pDRIEntPriv->refCount++;
+
     return TRUE;
 }
 
@@ -490,6 +616,9 @@ DRICloseScreen(ScreenPtr pScreen)
     DRIInfoPtr       pDRIInfo;
     drm_context_t *    reserved;
     int              reserved_count;
+    ScrnInfoPtr      pScrn = xf86Screens[pScreen->myNum];
+    DRIEntPrivPtr    pDRIEntPriv = DRI_ENT_PRIV(pScrn);
+    Bool closeMaster;
 
     if (pDRIPriv && pDRIPriv->directRenderingSupport) {
 
@@ -542,38 +671,55 @@ DRICloseScreen(ScreenPtr pScreen)
 	}
 
 				/* Remove tags for reserved contexts */
-	if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
+	if (pDRIEntPriv->resOwner == pScreen) {
+	    pDRIEntPriv->resOwner = NULL;
+
+	    if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
 						  &reserved_count))) {
-	    int  i;
+		int  i;
 
-	    for (i = 0; i < reserved_count; i++) {
-		DRIDestroyContextPriv(drmGetContextTag(pDRIPriv->drmFD,
-						       reserved[i]));
+		for (i = 0; i < reserved_count; i++) {
+		    DRIDestroyContextPriv(drmGetContextTag(pDRIPriv->drmFD,
+							   reserved[i]));
+		}
+		drmFreeReservedContextList(reserved);
+		DRIDrvMsg(pScreen->myNum, X_INFO,
+			  "[drm] removed %d reserved context%s for kernel\n",
+			  reserved_count, reserved_count > 1 ? "s" : "");
 	    }
-	    drmFreeReservedContextList(reserved);
-	    DRIDrvMsg(pScreen->myNum, X_INFO,
-		      "[drm] removed %d reserved context%s for kernel\n",
-		      reserved_count, reserved_count > 1 ? "s" : "");
 	}
 
 	/* Make sure signals get unblocked etc. */
 	drmUnlock(pDRIPriv->drmFD, pDRIPriv->myContext);
-	pDRIPriv->lockRefCount = 0;
-	DRIDrvMsg(pScreen->myNum, X_INFO,
-		  "[drm] unmapping %d bytes of SAREA %p at %p\n",
-		  pDRIInfo->SAREASize,
-		  pDRIPriv->hSAREA,
-		  pDRIPriv->pSAREA);
-	if (drmUnmap(pDRIPriv->pSAREA, pDRIInfo->SAREASize)) {
-	    DRIDrvMsg(pScreen->myNum, X_ERROR,
-		      "[drm] unable to unmap %d bytes"
-		      " of SAREA %p at %p\n",
+	pDRIPriv->pLockRefCount = NULL;
+	closeMaster = (--pDRIEntPriv->refCount == 0) &&
+	    !pDRIEntPriv->keepFDOpen;
+	if (closeMaster || pDRIPriv->hSAREA != pDRIEntPriv->hLSAREA) {
+	    DRIDrvMsg(pScreen->myNum, X_INFO,
+		      "[drm] unmapping %d bytes of SAREA %p at %p\n",
 		      pDRIInfo->SAREASize,
 		      pDRIPriv->hSAREA,
 		      pDRIPriv->pSAREA);
+	    if (drmUnmap(pDRIPriv->pSAREA, pDRIInfo->SAREASize)) {
+		DRIDrvMsg(pScreen->myNum, X_ERROR,
+			  "[drm] unable to unmap %d bytes"
+			  " of SAREA %p at %p\n",
+			  pDRIInfo->SAREASize,
+			  pDRIPriv->hSAREA,
+			  pDRIPriv->pSAREA);
+	    }
+	} else {
+	    pDRIEntPriv->sAreaGrabbed = FALSE;
 	}
 
-	drmClose(pDRIPriv->drmFD);
+	if (closeMaster || (pDRIEntPriv->drmFD != pDRIPriv->drmFD)) {
+	    drmClose(pDRIPriv->drmFD);
+	    if (pDRIEntPriv->drmFD == pDRIPriv->drmFD) {
+		DRIDrvMsg(pScreen->myNum, X_INFO,
+			  "[drm] Closed DRM master.\n");
+		pDRIEntPriv->drmFD = -1;
+	    }
+	}
 
 	xfree(pDRIPriv);
 	pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
@@ -2001,28 +2147,46 @@ void
 DRILock(ScreenPtr pScreen, int flags)
 {
     DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-    if(!pDRIPriv) return;
 
-    if (!pDRIPriv->lockRefCount)
-        DRM_LOCK(pDRIPriv->drmFD, pDRIPriv->pSAREA, pDRIPriv->myContext, flags);
-    pDRIPriv->lockRefCount++;
+    if(!pDRIPriv || !pDRIPriv->pLockRefCount) return;
+
+    if (!*pDRIPriv->pLockRefCount) {
+        DRM_LOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext, flags);
+	*pDRIPriv->pLockingContext = pDRIPriv->myContext;
+    } else if (*pDRIPriv->pLockingContext != pDRIPriv->myContext) {
+	DRIDrvMsg(pScreen->myNum, X_ERROR,
+		  "[DRI] Locking deadlock.\n"
+		  "\tAlready locked with context %d,\n"
+		  "\ttrying to lock with context %d.\n",
+		  pDRIPriv->pLockingContext,
+		  pDRIPriv->myContext);
+    }
+    (*pDRIPriv->pLockRefCount)++;
 }
 
 void
 DRIUnlock(ScreenPtr pScreen)
 {
     DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-    if(!pDRIPriv) return;
 
-    if (pDRIPriv->lockRefCount > 0) {
-        pDRIPriv->lockRefCount--;
-    }
-    else {
-        ErrorF("DRIUnlock called when not locked\n");
+    if(!pDRIPriv || !pDRIPriv->pLockRefCount) return;
+
+    if (*pDRIPriv->pLockRefCount > 0) {
+	if (pDRIPriv->myContext != *pDRIPriv->pLockingContext) {
+	    DRIDrvMsg(pScreen->myNum, X_ERROR,
+		      "[DRI] Unlocking inconsistency:\n"
+		      "\tContext %d trying to unlock lock held by context %d\n",
+		      pDRIPriv->pLockingContext,
+		      pDRIPriv->myContext);
+	}
+	(*pDRIPriv->pLockRefCount)--;
+    } else {
+        DRIDrvMsg(pScreen->myNum, X_ERROR,
+		  "DRIUnlock called when not locked.\n");
         return;
     }
-    if (!pDRIPriv->lockRefCount)
-        DRM_UNLOCK(pDRIPriv->drmFD, pDRIPriv->pSAREA, pDRIPriv->myContext);
+    if (! *pDRIPriv->pLockRefCount)
+        DRM_UNLOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext);
 }
 
 void *
diff --git a/hw/xfree86/dri/dri.h b/hw/xfree86/dri/dri.h
index f65c571..a21338a 100644
--- a/hw/xfree86/dri/dri.h
+++ b/hw/xfree86/dri/dri.h
@@ -107,7 +107,7 @@ typedef struct {
  */
 
 #define DRIINFO_MAJOR_VERSION   5
-#define DRIINFO_MINOR_VERSION   1
+#define DRIINFO_MINOR_VERSION   2
 #define DRIINFO_PATCH_VERSION   0
 
 typedef struct {
@@ -176,9 +176,17 @@ typedef struct {
 
     /* New with DRI version 5.1.0 */
     void        (*ClipNotify)(ScreenPtr pScreen, WindowPtr *ppWin, int num);
+
+    /* New with DRI version 5.2.0 */
+    Bool                allocSarea;
+    Bool                keepFDOpen;
 } DRIInfoRec, *DRIInfoPtr;
 
 
+extern Bool DRIOpenDRMMaster(ScrnInfoPtr pScrn, unsigned long sAreaSize,
+			     const char *busID,
+			     const char *drmDriverName);
+
 extern Bool DRIScreenInit(ScreenPtr pScreen,
                           DRIInfoPtr pDRIInfo,
                           int *pDRMFD);
@@ -344,6 +352,14 @@ extern char *DRICreatePCIBusID(pciVideoP
 
 extern int drmInstallSIGIOHandler(int fd, void (*f)(int, void *, void *));
 extern int drmRemoveSIGIOHandler(int fd);
+extern int DRIMasterFD(ScrnInfoPtr pScrn);
+
+extern void *DRIMasterSareaPointer(ScrnInfoPtr pScrn);
+
+extern drm_handle_t DRIMasterSareaHandle(ScrnInfoPtr pScrn);
+
+
+
 #define _DRI_H_
 
 #endif
diff --git a/hw/xfree86/dri/dristruct.h b/hw/xfree86/dri/dristruct.h
index 9c42ff9..a3bac85 100644
--- a/hw/xfree86/dri/dristruct.h
+++ b/hw/xfree86/dri/dristruct.h
@@ -73,6 +73,11 @@ struct _DRIContextPrivRec
 #define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
     (screenInfo.screens[screenIndex]->devPrivates[DRIScreenPrivIndex].ptr))
 
+#define DRI_ENT_PRIV(pScrn)  \
+    ((DRIEntPrivIndex < 0) ? \
+     NULL:		     \
+     ((DRIEntPrivPtr)(xf86GetEntityPrivate((pScrn)->entityList[0], \
+					   DRIEntPrivIndex)->ptr)))
 
 typedef struct _DRIScreenPrivRec
 {
@@ -103,6 +108,25 @@ typedef struct _DRIScreenPrivRec
     Bool		wrapped;
     Bool		windowsTouched;
     int			lockRefCount;
+    drm_handle_t        hLSAREA;      /* Handle to SAREA containing lock, for mapping */
+    XF86DRILSAREAPtr    pLSAREA;      /* Mapped pointer to SAREA containing lock */
+    int*                pLockRefCount;
+    int*                pLockingContext;
 } DRIScreenPrivRec, *DRIScreenPrivPtr;
 
+
+typedef struct _DRIEntPrivRec {
+    int drmFD;
+    Bool drmOpened;
+    Bool sAreaGrabbed;
+    drm_handle_t hLSAREA;
+    XF86DRILSAREAPtr pLSAREA;
+    unsigned long sAreaSize;
+    int lockRefCount;
+    int lockingContext;
+    ScreenPtr resOwner;
+    Bool keepFDOpen;
+    int refCount;
+} DRIEntPrivRec, *DRIEntPrivPtr;
+
 #endif /* DRI_STRUCT_H */
diff --git a/hw/xfree86/dri/sarea.h b/hw/xfree86/dri/sarea.h
index a0d6084..1528cc1 100644
--- a/hw/xfree86/dri/sarea.h
+++ b/hw/xfree86/dri/sarea.h
@@ -89,4 +89,9 @@ typedef struct _XF86DRISAREA {
     drm_context_t			dummy_context;
 } XF86DRISAREARec, *XF86DRISAREAPtr;
 
+typedef struct _XF86DRILSAREA  {
+    drmLock                     lock;
+    drmLock                     otherLocks[31];
+} XF86DRILSAREARec, *XF86DRILSAREAPtr;
+
 #endif
diff-tree b5823ea3e1ed5a0449d44da05165a46719dcf287 (from cc4eb1c7ea1bace7ed69cfd80c99d22933282ae1)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Sun Apr 15 22:59:19 2007 -0300

    RandR 1.2 spec says CRTC info contains screen-relative geometry.
    
    Was reporting mode size instead of adjusting for rotation.
    (cherry picked from commit e2e7c47a528447e90cff6cf10d2ce457742ef48d)

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 1dfc3bb..c8c2be2 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -518,6 +518,7 @@ ProcRRGetCrtcInfo (ClientPtr client)
     RROutput			*outputs;
     RROutput			*possible;
     int				i, j, k, n;
+    int				width, height;
     
     REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
     crtc = LookupCrtc(client, stuff->crtc, DixReadAccess);
@@ -540,8 +541,9 @@ ProcRRGetCrtcInfo (ClientPtr client)
     rep.timestamp = pScrPriv->lastSetTime.milliseconds;
     rep.x = crtc->x;
     rep.y = crtc->y;
-    rep.width = mode ? mode->mode.width : 0;
-    rep.height = mode ? mode->mode.height : 0;
+    RRCrtcGetScanoutSize (crtc, &width, &height);
+    rep.width = width;
+    rep.height = height;
     rep.mode = mode ? mode->mode.id : 0;
     rep.rotation = crtc->rotation;
     rep.rotations = crtc->rotations;
diff-tree cc4eb1c7ea1bace7ed69cfd80c99d22933282ae1 (from eba81a0a01f8a61151d8bf9f3d83bda85ca26e73)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Fri Apr 13 15:04:29 2007 -0300

    Add quirk for Acer AL1706 monitor to force 60hz refresh.
    
    This Acer monitor reports support for 75hz refresh via EDID, and yet when
    that rate is delivered, the monitor does not sync and reports out of range.
    Use the existing 60hz quirk for this monitor.
    (cherry picked from commit 1328a288e9030a472a915077160f090d1afd4126)

diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index 7a8ec19..18e42dd 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -82,6 +82,11 @@ static Bool quirk_prefer_large_60 (int s
 	DDC->vendor.prod_id == 1516)
 	return TRUE;
     
+    /* Acer AL1706 */
+    if (memcmp (DDC->vendor.name, "ACR", 4) == 0 &&
+	DDC->vendor.prod_id == 44358)
+	return TRUE;
+    
     return FALSE;
 }
 
diff-tree eba81a0a01f8a61151d8bf9f3d83bda85ca26e73 (from 6b040b79f0e247b6f2da8f7d239443743e96de67)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Sat Apr 14 18:30:09 2007 +0300

    glx: move __glXMesaProvider from GLcore module to glx module.
    
    This treats the GLcore provider similar to DRI provider, using a subset of
    XMesa as the GLcore interface.

diff --git a/GL/glx/Makefile.am b/GL/glx/Makefile.am
index cd1130d..c4141bc 100644
--- a/GL/glx/Makefile.am
+++ b/GL/glx/Makefile.am
@@ -46,12 +46,13 @@ libglx_la_SOURCES = \
         glxdrawable.h \
         glxext.c \
         glxext.h \
-	glxvisuals.c \
+        glxglcore.c \
         glxscreens.c \
         glxscreens.h \
         glxserver.h \
         glxutil.c \
         glxutil.h \
+        glxvisuals.c \
         indirect_dispatch.c \
         indirect_dispatch.h \
         indirect_dispatch_swap.c \
diff --git a/GL/glx/glxglcore.c b/GL/glx/glxglcore.c
new file mode 100644
index 0000000..ecfa4d7
--- /dev/null
+++ b/GL/glx/glxglcore.c
@@ -0,0 +1,409 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ *   Kevin E. Martin <kevin at precisioninsight.com>
+ *   Brian E. Paul <brian at precisioninsight.com>
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <string.h>
+
+#include <GL/xmesa.h>
+#include <GL/internal/glcore.h>
+#include <glxserver.h>
+#include <glxscreens.h>
+#include <glxdrawable.h>
+#include <glxcontext.h>
+#include <glxutil.h>
+
+#include "glcontextmodes.h"
+#include "os.h"
+
+typedef struct __GLXMESAscreen   __GLXMESAscreen;
+typedef struct __GLXMESAcontext  __GLXMESAcontext;
+typedef struct __GLXMESAdrawable __GLXMESAdrawable;
+
+struct __GLXMESAscreen {
+    __GLXscreen   base;
+    int           index;
+    int		  num_vis;
+    XMesaVisual  *xm_vis;
+};
+
+struct __GLXMESAcontext {
+    __GLXcontext base;
+    XMesaContext xmesa;
+};
+
+struct __GLXMESAdrawable {
+    __GLXdrawable base;
+    XMesaBuffer   xm_buf;
+};
+
+static XMesaVisual find_mesa_visual(__GLXscreen *screen, VisualID vid);
+
+
+static void
+__glXMesaDrawableDestroy(__GLXdrawable *base)
+{
+    __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
+
+    if (glxPriv->xm_buf != NULL)
+      XMesaDestroyBuffer(glxPriv->xm_buf);
+    xfree(glxPriv);
+}
+
+static GLboolean
+__glXMesaDrawableResize(__GLXdrawable *base)
+{
+    __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
+
+    XMesaResizeBuffers(glxPriv->xm_buf);
+
+    return GL_TRUE;
+}
+
+static GLboolean
+__glXMesaDrawableSwapBuffers(__GLXdrawable *base)
+{
+    __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
+
+    /* This is terrifying: XMesaSwapBuffers() ends up calling CopyArea
+     * to do the buffer swap, but this assumes that the server holds
+     * the lock and has its context visible.  If another screen uses a
+     * DRI driver, that will have installed the DRI enter/leave server
+     * functions, which lifts the lock during GLX dispatch.  This is
+     * why we need to re-take the lock and swap in the server context
+     * before calling XMesaSwapBuffers() here.  /me shakes head. */
+
+    __glXenterServer();
+
+    XMesaSwapBuffers(glxPriv->xm_buf);
+
+    __glXleaveServer();
+
+    return GL_TRUE;
+}
+
+
+static __GLXdrawable *
+__glXMesaScreenCreateDrawable(__GLXscreen *screen,
+			      DrawablePtr pDraw,
+			      XID drawId,
+			      __GLcontextModes *modes)
+{
+    __GLXMESAdrawable *glxPriv;
+    XMesaVisual xm_vis;
+
+    glxPriv = xalloc(sizeof *glxPriv);
+    if (glxPriv == NULL)
+	return NULL;
+
+    memset(glxPriv, 0, sizeof *glxPriv);
+
+    if (!__glXDrawableInit(&glxPriv->base, screen, pDraw, drawId, modes)) {
+        xfree(glxPriv);
+	return NULL;
+    }
+
+    glxPriv->base.destroy     = __glXMesaDrawableDestroy;
+    glxPriv->base.resize      = __glXMesaDrawableResize;
+    glxPriv->base.swapBuffers = __glXMesaDrawableSwapBuffers;
+
+    xm_vis = find_mesa_visual(screen, modes->visualID);
+    if (xm_vis == NULL) {
+	ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
+	       modes->visualID);
+	xfree(glxPriv);
+	return NULL;
+    }
+
+    if (glxPriv->base.type == DRAWABLE_WINDOW) {
+	glxPriv->xm_buf = XMesaCreateWindowBuffer(xm_vis, (WindowPtr)pDraw);
+    } else {
+	glxPriv->xm_buf = XMesaCreatePixmapBuffer(xm_vis, (PixmapPtr)pDraw, 0);
+    }
+
+    return &glxPriv->base;
+}
+
+static void
+__glXMesaContextDestroy(__GLXcontext *baseContext)
+{
+    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
+
+    XMesaDestroyContext(context->xmesa);
+    __glXContextDestroy(&context->base);
+    xfree(context);
+}
+
+static int
+__glXMesaContextMakeCurrent(__GLXcontext *baseContext)
+
+{
+    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
+    __GLXMESAdrawable *drawPriv = (__GLXMESAdrawable *) context->base.drawPriv;
+    __GLXMESAdrawable *readPriv = (__GLXMESAdrawable *) context->base.readPriv;
+
+    return XMesaMakeCurrent2(context->xmesa,
+			     drawPriv->xm_buf,
+			     readPriv->xm_buf);
+}
+
+static int
+__glXMesaContextLoseCurrent(__GLXcontext *baseContext)
+{
+    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
+
+    return XMesaLoseCurrent(context->xmesa);
+}
+
+static int
+__glXMesaContextCopy(__GLXcontext *baseDst,
+		     __GLXcontext *baseSrc,
+		     unsigned long mask)
+{
+    __GLXMESAcontext *dst = (__GLXMESAcontext *) baseDst;
+    __GLXMESAcontext *src = (__GLXMESAcontext *) baseSrc;
+
+    return XMesaCopyContext(src->xmesa, dst->xmesa, mask);
+}
+
+static int
+__glXMesaContextForceCurrent(__GLXcontext *baseContext)
+{
+    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
+
+    /* GlxSetRenderTables() call for XGL moved in XMesaForceCurrent() */
+
+    return XMesaForceCurrent(context->xmesa);
+}
+
+static __GLXcontext *
+__glXMesaScreenCreateContext(__GLXscreen *screen,
+			     __GLcontextModes *modes,
+			     __GLXcontext *baseShareContext)
+{
+    __GLXMESAcontext *context;
+    __GLXMESAcontext *shareContext = (__GLXMESAcontext *) baseShareContext;
+    XMesaVisual xm_vis;
+    XMesaContext xm_share;
+
+    context = xalloc (sizeof (__GLXMESAcontext));
+    if (context == NULL)
+	return NULL;
+
+    memset(context, 0, sizeof *context);
+
+    context->base.pGlxScreen = screen;
+    context->base.modes      = modes;
+
+    context->base.destroy        = __glXMesaContextDestroy;
+    context->base.makeCurrent    = __glXMesaContextMakeCurrent;
+    context->base.loseCurrent    = __glXMesaContextLoseCurrent;
+    context->base.copy           = __glXMesaContextCopy;
+    context->base.forceCurrent   = __glXMesaContextForceCurrent;
+
+    xm_vis = find_mesa_visual(screen, modes->visualID);
+    if (!xm_vis) {
+	ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
+	       modes->visualID);
+	xfree(context);
+	return NULL;
+    }
+
+    xm_share = shareContext ? shareContext->xmesa : NULL;
+    context->xmesa = XMesaCreateContext(xm_vis, xm_share);
+    if (!context->xmesa) {
+	xfree(context);
+	return NULL;
+    }
+
+    return &context->base;
+}
+
+static void
+__glXMesaScreenDestroy(__GLXscreen *screen)
+{
+    __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen;
+    int i;
+
+    for (i = 0; i < mesaScreen->num_vis; i++) {
+	if (mesaScreen->xm_vis[i])
+	    XMesaDestroyVisual(mesaScreen->xm_vis[i]);
+    }
+
+    xfree(mesaScreen->xm_vis);
+
+    __glXScreenDestroy(screen);
+
+    xfree(screen);
+}
+
+static XMesaVisual
+find_mesa_visual(__GLXscreen *screen, VisualID vid)
+{
+    __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen;
+    const __GLcontextModes *modes;
+    unsigned i = 0;
+
+    for ( modes = screen->modes ; modes != NULL ; modes = modes->next ) {
+	if ( modes->visualID == vid ) {
+	    break;
+	}
+
+	i++;
+    }
+
+    return (modes != NULL) ? mesaScreen->xm_vis[i] : NULL;
+}
+
+static void init_screen_visuals(__GLXMESAscreen *screen)
+{
+    ScreenPtr pScreen = screen->base.pScreen;
+    __GLcontextModes *modes;
+    XMesaVisual *pXMesaVisual;
+    int *used;
+    int i, j, size;
+
+    /* Alloc space for the list of XMesa visuals */
+    size = screen->base.numVisuals * sizeof(XMesaVisual);
+    pXMesaVisual = (XMesaVisual *) xalloc(size);
+    memset(pXMesaVisual, 0, size);
+
+    /* FIXME: Change 'used' to be a array of bits (rather than of ints),
+     * FIXME: create a stack array of 8 or 16 bytes.  If 'numVisuals' is less
+     * FIXME: than 64 or 128 the stack array can be used instead of calling
+     * FIXME: __glXMalloc / __glXFree.  If nothing else, convert 'used' to
+     * FIXME: array of bytes instead of ints!
+     */
+    used = (int *) xalloc(pScreen->numVisuals * sizeof(int));
+    memset(used, 0, pScreen->numVisuals * sizeof(int));
+
+    i = 0;
+    for ( modes = screen->base.modes; modes != NULL; modes = modes->next ) {
+	const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+	const int nplanes = (modes->rgbBits - modes->alphaBits);
+	const VisualPtr pVis = pScreen->visuals;
+
+	for (j = 0; j < pScreen->numVisuals; j++) {
+	    if (pVis[j].class     == vis_class &&
+		pVis[j].nplanes   == nplanes &&
+		pVis[j].redMask   == modes->redMask &&
+		pVis[j].greenMask == modes->greenMask &&
+		pVis[j].blueMask  == modes->blueMask &&
+		!used[j]) {
+
+		/* Create the XMesa visual */
+		pXMesaVisual[i] =
+		    XMesaCreateVisual(pScreen,
+				      &pVis[j],
+				      modes->rgbMode,
+				      (modes->alphaBits > 0),
+				      modes->doubleBufferMode,
+				      modes->stereoMode,
+				      GL_TRUE, /* ximage_flag */
+				      modes->depthBits,
+				      modes->stencilBits,
+				      modes->accumRedBits,
+				      modes->accumGreenBits,
+				      modes->accumBlueBits,
+				      modes->accumAlphaBits,
+				      modes->samples,
+				      modes->level,
+				      modes->visualRating);
+		/* Set the VisualID */
+		modes->visualID = pVis[j].vid;
+
+		/* Mark this visual used */
+		used[j] = 1;
+		break;
+	    }
+	}
+
+	if ( j == pScreen->numVisuals ) {
+	    ErrorF("No matching visual for __GLcontextMode with "
+		   "visual class = %d (%d), nplanes = %u\n",
+		   vis_class, 
+		   modes->visualType,
+		   (modes->rgbBits - modes->alphaBits) );
+	}
+	else if ( modes->visualID == -1 ) {
+	    FatalError( "Matching visual found, but visualID still -1!\n" );
+	}
+
+	i++;
+    }
+
+    xfree(used);
+
+    screen->num_vis = pScreen->numVisuals;
+    screen->xm_vis = pXMesaVisual;
+}
+
+static __GLXscreen *
+__glXMesaScreenProbe(ScreenPtr pScreen)
+{
+    __GLXMESAscreen *screen;
+
+    screen = xalloc(sizeof *screen);
+    if (screen == NULL)
+	return NULL;
+
+    __glXScreenInit(&screen->base, pScreen);
+
+    screen->base.destroy        = __glXMesaScreenDestroy;
+    screen->base.createContext  = __glXMesaScreenCreateContext;
+    screen->base.createDrawable = __glXMesaScreenCreateDrawable;
+    screen->base.pScreen       = pScreen;
+
+    /*
+     * Find the GLX visuals that are supported by this screen and create
+     * XMesa's visuals.
+     */
+    init_screen_visuals(screen);
+
+    return &screen->base;
+}
+
+__GLXprovider __glXMesaProvider = {
+    __glXMesaScreenProbe,
+    "MESA",
+    NULL
+};
+
+__GLXprovider *
+GlxGetMesaProvider (void)
+{
+    return &__glXMesaProvider;
+}
diff --git a/GL/mesa/X/Makefile.am b/GL/mesa/X/Makefile.am
index f8f16c3..ace1181 100644
--- a/GL/mesa/X/Makefile.am
+++ b/GL/mesa/X/Makefile.am
@@ -22,8 +22,6 @@ AM_CFLAGS = \
 	-DXFree86Server \
 	@GLX_DEFINES@
 
-libX_la_SOURCES = xf86glx.c
-
 nodist_libX_la_SOURCES = \
                   xm_api.c \
 		  xm_buffer.c \
diff --git a/GL/mesa/X/xf86glx.c b/GL/mesa/X/xf86glx.c
deleted file mode 100644
index ecfa4d7..0000000
--- a/GL/mesa/X/xf86glx.c
+++ /dev/null
@@ -1,409 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin at precisioninsight.com>
- *   Brian E. Paul <brian at precisioninsight.com>
- *
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <string.h>
-
-#include <GL/xmesa.h>
-#include <GL/internal/glcore.h>
-#include <glxserver.h>
-#include <glxscreens.h>
-#include <glxdrawable.h>
-#include <glxcontext.h>
-#include <glxutil.h>
-
-#include "glcontextmodes.h"
-#include "os.h"
-
-typedef struct __GLXMESAscreen   __GLXMESAscreen;
-typedef struct __GLXMESAcontext  __GLXMESAcontext;
-typedef struct __GLXMESAdrawable __GLXMESAdrawable;
-
-struct __GLXMESAscreen {
-    __GLXscreen   base;
-    int           index;
-    int		  num_vis;
-    XMesaVisual  *xm_vis;
-};
-
-struct __GLXMESAcontext {
-    __GLXcontext base;
-    XMesaContext xmesa;
-};
-
-struct __GLXMESAdrawable {
-    __GLXdrawable base;
-    XMesaBuffer   xm_buf;
-};
-
-static XMesaVisual find_mesa_visual(__GLXscreen *screen, VisualID vid);
-
-
-static void
-__glXMesaDrawableDestroy(__GLXdrawable *base)
-{
-    __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
-
-    if (glxPriv->xm_buf != NULL)
-      XMesaDestroyBuffer(glxPriv->xm_buf);
-    xfree(glxPriv);
-}
-
-static GLboolean
-__glXMesaDrawableResize(__GLXdrawable *base)
-{
-    __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
-
-    XMesaResizeBuffers(glxPriv->xm_buf);
-
-    return GL_TRUE;
-}
-
-static GLboolean
-__glXMesaDrawableSwapBuffers(__GLXdrawable *base)
-{
-    __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
-
-    /* This is terrifying: XMesaSwapBuffers() ends up calling CopyArea
-     * to do the buffer swap, but this assumes that the server holds
-     * the lock and has its context visible.  If another screen uses a
-     * DRI driver, that will have installed the DRI enter/leave server
-     * functions, which lifts the lock during GLX dispatch.  This is
-     * why we need to re-take the lock and swap in the server context
-     * before calling XMesaSwapBuffers() here.  /me shakes head. */
-
-    __glXenterServer();
-
-    XMesaSwapBuffers(glxPriv->xm_buf);
-
-    __glXleaveServer();
-
-    return GL_TRUE;
-}
-
-
-static __GLXdrawable *
-__glXMesaScreenCreateDrawable(__GLXscreen *screen,
-			      DrawablePtr pDraw,
-			      XID drawId,
-			      __GLcontextModes *modes)
-{
-    __GLXMESAdrawable *glxPriv;
-    XMesaVisual xm_vis;
-
-    glxPriv = xalloc(sizeof *glxPriv);
-    if (glxPriv == NULL)
-	return NULL;
-
-    memset(glxPriv, 0, sizeof *glxPriv);
-
-    if (!__glXDrawableInit(&glxPriv->base, screen, pDraw, drawId, modes)) {
-        xfree(glxPriv);
-	return NULL;
-    }
-
-    glxPriv->base.destroy     = __glXMesaDrawableDestroy;
-    glxPriv->base.resize      = __glXMesaDrawableResize;
-    glxPriv->base.swapBuffers = __glXMesaDrawableSwapBuffers;
-
-    xm_vis = find_mesa_visual(screen, modes->visualID);
-    if (xm_vis == NULL) {
-	ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
-	       modes->visualID);
-	xfree(glxPriv);
-	return NULL;
-    }
-
-    if (glxPriv->base.type == DRAWABLE_WINDOW) {
-	glxPriv->xm_buf = XMesaCreateWindowBuffer(xm_vis, (WindowPtr)pDraw);
-    } else {
-	glxPriv->xm_buf = XMesaCreatePixmapBuffer(xm_vis, (PixmapPtr)pDraw, 0);
-    }
-
-    return &glxPriv->base;
-}
-
-static void
-__glXMesaContextDestroy(__GLXcontext *baseContext)
-{
-    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
-
-    XMesaDestroyContext(context->xmesa);
-    __glXContextDestroy(&context->base);
-    xfree(context);
-}
-
-static int
-__glXMesaContextMakeCurrent(__GLXcontext *baseContext)
-
-{
-    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
-    __GLXMESAdrawable *drawPriv = (__GLXMESAdrawable *) context->base.drawPriv;
-    __GLXMESAdrawable *readPriv = (__GLXMESAdrawable *) context->base.readPriv;
-
-    return XMesaMakeCurrent2(context->xmesa,
-			     drawPriv->xm_buf,
-			     readPriv->xm_buf);
-}
-
-static int
-__glXMesaContextLoseCurrent(__GLXcontext *baseContext)
-{
-    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
-
-    return XMesaLoseCurrent(context->xmesa);
-}
-
-static int
-__glXMesaContextCopy(__GLXcontext *baseDst,
-		     __GLXcontext *baseSrc,
-		     unsigned long mask)
-{
-    __GLXMESAcontext *dst = (__GLXMESAcontext *) baseDst;
-    __GLXMESAcontext *src = (__GLXMESAcontext *) baseSrc;
-
-    return XMesaCopyContext(src->xmesa, dst->xmesa, mask);
-}
-
-static int
-__glXMesaContextForceCurrent(__GLXcontext *baseContext)
-{
-    __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
-
-    /* GlxSetRenderTables() call for XGL moved in XMesaForceCurrent() */
-
-    return XMesaForceCurrent(context->xmesa);
-}
-
-static __GLXcontext *
-__glXMesaScreenCreateContext(__GLXscreen *screen,
-			     __GLcontextModes *modes,
-			     __GLXcontext *baseShareContext)
-{
-    __GLXMESAcontext *context;
-    __GLXMESAcontext *shareContext = (__GLXMESAcontext *) baseShareContext;
-    XMesaVisual xm_vis;
-    XMesaContext xm_share;
-
-    context = xalloc (sizeof (__GLXMESAcontext));
-    if (context == NULL)
-	return NULL;
-
-    memset(context, 0, sizeof *context);
-
-    context->base.pGlxScreen = screen;
-    context->base.modes      = modes;
-
-    context->base.destroy        = __glXMesaContextDestroy;
-    context->base.makeCurrent    = __glXMesaContextMakeCurrent;
-    context->base.loseCurrent    = __glXMesaContextLoseCurrent;
-    context->base.copy           = __glXMesaContextCopy;
-    context->base.forceCurrent   = __glXMesaContextForceCurrent;
-
-    xm_vis = find_mesa_visual(screen, modes->visualID);
-    if (!xm_vis) {
-	ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
-	       modes->visualID);
-	xfree(context);
-	return NULL;
-    }
-
-    xm_share = shareContext ? shareContext->xmesa : NULL;
-    context->xmesa = XMesaCreateContext(xm_vis, xm_share);
-    if (!context->xmesa) {
-	xfree(context);
-	return NULL;
-    }
-
-    return &context->base;
-}
-
-static void
-__glXMesaScreenDestroy(__GLXscreen *screen)
-{
-    __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen;
-    int i;
-
-    for (i = 0; i < mesaScreen->num_vis; i++) {
-	if (mesaScreen->xm_vis[i])
-	    XMesaDestroyVisual(mesaScreen->xm_vis[i]);
-    }
-
-    xfree(mesaScreen->xm_vis);
-
-    __glXScreenDestroy(screen);
-
-    xfree(screen);
-}
-
-static XMesaVisual
-find_mesa_visual(__GLXscreen *screen, VisualID vid)
-{
-    __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen;
-    const __GLcontextModes *modes;
-    unsigned i = 0;
-
-    for ( modes = screen->modes ; modes != NULL ; modes = modes->next ) {
-	if ( modes->visualID == vid ) {
-	    break;
-	}
-
-	i++;
-    }
-
-    return (modes != NULL) ? mesaScreen->xm_vis[i] : NULL;
-}
-
-static void init_screen_visuals(__GLXMESAscreen *screen)
-{
-    ScreenPtr pScreen = screen->base.pScreen;
-    __GLcontextModes *modes;
-    XMesaVisual *pXMesaVisual;
-    int *used;
-    int i, j, size;
-
-    /* Alloc space for the list of XMesa visuals */
-    size = screen->base.numVisuals * sizeof(XMesaVisual);
-    pXMesaVisual = (XMesaVisual *) xalloc(size);
-    memset(pXMesaVisual, 0, size);
-
-    /* FIXME: Change 'used' to be a array of bits (rather than of ints),
-     * FIXME: create a stack array of 8 or 16 bytes.  If 'numVisuals' is less
-     * FIXME: than 64 or 128 the stack array can be used instead of calling
-     * FIXME: __glXMalloc / __glXFree.  If nothing else, convert 'used' to
-     * FIXME: array of bytes instead of ints!
-     */
-    used = (int *) xalloc(pScreen->numVisuals * sizeof(int));
-    memset(used, 0, pScreen->numVisuals * sizeof(int));
-
-    i = 0;
-    for ( modes = screen->base.modes; modes != NULL; modes = modes->next ) {
-	const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
-	const int nplanes = (modes->rgbBits - modes->alphaBits);
-	const VisualPtr pVis = pScreen->visuals;
-
-	for (j = 0; j < pScreen->numVisuals; j++) {
-	    if (pVis[j].class     == vis_class &&
-		pVis[j].nplanes   == nplanes &&
-		pVis[j].redMask   == modes->redMask &&
-		pVis[j].greenMask == modes->greenMask &&
-		pVis[j].blueMask  == modes->blueMask &&
-		!used[j]) {
-
-		/* Create the XMesa visual */
-		pXMesaVisual[i] =
-		    XMesaCreateVisual(pScreen,
-				      &pVis[j],
-				      modes->rgbMode,
-				      (modes->alphaBits > 0),
-				      modes->doubleBufferMode,
-				      modes->stereoMode,
-				      GL_TRUE, /* ximage_flag */
-				      modes->depthBits,
-				      modes->stencilBits,
-				      modes->accumRedBits,
-				      modes->accumGreenBits,
-				      modes->accumBlueBits,
-				      modes->accumAlphaBits,
-				      modes->samples,
-				      modes->level,
-				      modes->visualRating);
-		/* Set the VisualID */
-		modes->visualID = pVis[j].vid;
-
-		/* Mark this visual used */
-		used[j] = 1;
-		break;
-	    }
-	}
-
-	if ( j == pScreen->numVisuals ) {
-	    ErrorF("No matching visual for __GLcontextMode with "
-		   "visual class = %d (%d), nplanes = %u\n",
-		   vis_class, 
-		   modes->visualType,
-		   (modes->rgbBits - modes->alphaBits) );
-	}
-	else if ( modes->visualID == -1 ) {
-	    FatalError( "Matching visual found, but visualID still -1!\n" );
-	}
-
-	i++;
-    }
-
-    xfree(used);
-
-    screen->num_vis = pScreen->numVisuals;
-    screen->xm_vis = pXMesaVisual;
-}
-
-static __GLXscreen *
-__glXMesaScreenProbe(ScreenPtr pScreen)
-{
-    __GLXMESAscreen *screen;
-
-    screen = xalloc(sizeof *screen);
-    if (screen == NULL)
-	return NULL;
-
-    __glXScreenInit(&screen->base, pScreen);
-
-    screen->base.destroy        = __glXMesaScreenDestroy;
-    screen->base.createContext  = __glXMesaScreenCreateContext;
-    screen->base.createDrawable = __glXMesaScreenCreateDrawable;
-    screen->base.pScreen       = pScreen;
-
-    /*
-     * Find the GLX visuals that are supported by this screen and create
-     * XMesa's visuals.
-     */
-    init_screen_visuals(screen);
-
-    return &screen->base;
-}
-
-__GLXprovider __glXMesaProvider = {
-    __glXMesaScreenProbe,
-    "MESA",
-    NULL
-};
-
-__GLXprovider *
-GlxGetMesaProvider (void)
-{
-    return &__glXMesaProvider;
-}
diff-tree 6b040b79f0e247b6f2da8f7d239443743e96de67 (from 2c833f60acb3dc358815a99cd295ef7fc695c45d)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Sat Apr 14 18:29:52 2007 +0300

    glx: drop xmesaP.h include from xf86glx.c
    
    The declarations for the xfree86-specific XMesa functions were moved up to
    xmesa.h, requires Mesa as of 2007-04-13.

diff --git a/GL/mesa/X/xf86glx.c b/GL/mesa/X/xf86glx.c
index 6fffdeb..ecfa4d7 100644
--- a/GL/mesa/X/xf86glx.c
+++ b/GL/mesa/X/xf86glx.c
@@ -45,7 +45,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 #include <glxdrawable.h>
 #include <glxcontext.h>
 #include <glxutil.h>
-#include "xmesaP.h"
 
 #include "glcontextmodes.h"
 #include "os.h"
diff-tree 2c833f60acb3dc358815a99cd295ef7fc695c45d (from 7ccebc50b98ac175fdbdfaab081bcead62e60ee3)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Sat Apr 14 18:29:25 2007 +0300

    glx: drop stray CAPI define.
    
    SI imports/exports were dropped from Mesa.

diff --git a/GL/glx/glxcontext.h b/GL/glx/glxcontext.h
index a54e323..eb10ee2 100644
--- a/GL/glx/glxcontext.h
+++ b/GL/glx/glxcontext.h
@@ -40,9 +40,6 @@
 **
 */
 
-/* XXX: should be defined somewhere globally */
-#define CAPI
-
 #include "GL/internal/glcore.h"
 
 typedef struct __GLXtextureFromPixmap __GLXtextureFromPixmap;
diff --git a/GL/glx/glxscreens.h b/GL/glx/glxscreens.h
index a7700f6..bba4557 100644
--- a/GL/glx/glxscreens.h
+++ b/GL/glx/glxscreens.h
@@ -40,9 +40,6 @@
 **
 */
 
-/* XXX: should be defined somewhere globally */
-#define CAPI
-
 #include "GL/internal/glcore.h"
 
 /*
diff-tree 7ccebc50b98ac175fdbdfaab081bcead62e60ee3 (from 33a5d9605e3e282f6aa1921d7321a2a12ef02c42)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Fri Apr 13 13:08:44 2007 +0930

    Documentation for events.c.

diff --git a/dix/events.c b/dix/events.c
index 093a316..bc6b6ae 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -107,6 +107,10 @@ of the copyright holder.
 
 ******************************************************************/
 
+/** @file
+ * This file handles event delivery and a big part of the server-side protocol
+ * handling (the parts for input devices).
+ */
 
 #ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
@@ -168,7 +172,9 @@ static xEvent *xeviexE;
 #include "dixevents.h"
 #include "dixgrabs.h"
 #include "dispatch.h"
-
+/**
+ * Extension events type numbering starts at EXTENSION_EVENT_BASE.
+ */
 #define EXTENSION_EVENT_BASE  64
 
 #define NoSuchEvent 0x80000000	/* so doesn't match NoEventMask */
@@ -214,6 +220,28 @@ _X_EXPORT CallbackListPtr DeviceEventCal
 Mask DontPropagateMasks[DNPMCOUNT];
 static int DontPropagateRefCnts[DNPMCOUNT];
 
+/**
+ * Main input device struct. 
+ *     inputInfo.pointer 
+ *     is the core pointer. Referred to as "virtual core pointer", "VCP",
+ *     "core pointer" or inputInfo.pointer. There is exactly one core pointer,
+ *     but multiple devices may send core events. If a device generates core
+ *     events, those events will appear to originate from the core pointer.
+ * 
+ *     inputInfo.keyboard
+ *     is the core keyboard ("virtual core keyboard", "VCK", "core keyboard").
+ *     See inputInfo.pointer.
+ * 
+ *     inputInfo.devices
+ *     linked list containing all devices including VCK and VCP. The VCK will
+ *     always be the first entry, the VCP the second entry in the device list.
+ *
+ *     inputInfo.off_devices
+ *     Devices that have not been initialized and are thus turned off.
+ *
+ *     inputInfo.numDevices
+ *     Total number of devices.
+ */
 _X_EXPORT InputInfo inputInfo;
 
 static struct {
@@ -228,12 +256,19 @@ static struct {
  * The window trace information is used to avoid having to compute all the
  * windows between the root and the current pointer window each time a button
  * or key goes down. The grabs on each of those windows must be checked.
+ * 
+ * @see XYToWindow() for a documentation on how the array is set up.
  */
 static WindowPtr *spriteTrace = (WindowPtr *)NULL;
 #define ROOT spriteTrace[0]
 static int spriteTraceSize = 0;
 static int spriteTraceGood;
 
+/**
+ * DIX sprite information. This is the sprite as seen from the DIX. It does
+ * not represent the actual sprite rendered to the screen.
+ * 
+ */
 static  struct {
     CursorPtr	current;
     BoxRec	hotLimits;	/* logical constraints of hot spot */
@@ -270,6 +305,9 @@ static WindowPtr XYToWindow(
     int y
 );
 
+/**
+ * Max event opcode.
+ */
 extern int lastEvent;
 
 static Mask lastEventMask;
@@ -849,6 +887,13 @@ PointerConfinedToScreen(void)
     return sprite.confined;
 }
 
+/**
+ * Update the sprite cursor to the given cursor.
+ *
+ * ChangeToCursor() will display the new cursor and free the old cursor (if
+ * applicable). If the provided cursor is already the updated cursor, nothing
+ * happens.
+ */
 static void
 ChangeToCursor(CursorPtr cursor)
 {
@@ -873,7 +918,9 @@ ChangeToCursor(CursorPtr cursor)
     }
 }
 
-/* returns true if b is a descendent of a */
+/**
+ * @returns true if b is a descendent of a 
+ */
 Bool
 IsParent(WindowPtr a, WindowPtr b)
 {
@@ -882,6 +929,11 @@ IsParent(WindowPtr a, WindowPtr b)
     return FALSE;
 }
 
+/**
+ * Update the cursor displayed on the screen.
+ *
+ * Called whenever a cursor may have changed shape or position.  
+ */
 static void
 PostNewCursor(void)
 {
@@ -912,24 +964,36 @@ PostNewCursor(void)
 	}
 }
 
+/**
+ * @return root window of current active screen.
+ */
 _X_EXPORT WindowPtr
 GetCurrentRootWindow(void)
 {
     return ROOT;
 }
 
+/**
+ * @return window underneath the cursor sprite.
+ */
 _X_EXPORT WindowPtr
 GetSpriteWindow(void)
 {
     return sprite.win;
 }
 
+/**
+ * @return current sprite cursor.
+ */
 _X_EXPORT CursorPtr
 GetSpriteCursor(void)
 {
     return sprite.current;
 }
 
+/**
+ * Set x/y current sprite position in screen coordinates.
+ */
 _X_EXPORT void
 GetSpritePosition(int *px, int *py)
 {
@@ -1231,6 +1295,19 @@ CheckGrabForSyncs(DeviceIntPtr thisDev, 
     ComputeFreezes();
 }
 
+/**
+ * Activate a pointer grab on the given device. A pointer grab will cause all
+ * core pointer events to be delivered to the grabbing client only. Can cause
+ * the cursor to change if a grab cursor is set.
+ * 
+ * As a pointer grab can only be issued on the core devices, mouse is always
+ * inputInfo.pointer. Extension devices are set up for ActivateKeyboardGrab().
+ * 
+ * @param mouse The device to grab.
+ * @param grab The grab structure, needs to be setup.
+ * @param autoGrab True if the grab was caused by a button down event and not
+ * explicitely by a client. 
+ */
 void
 ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab, 
                     TimeStamp time, Bool autoGrab)
@@ -1259,6 +1336,12 @@ ActivatePointerGrab(DeviceIntPtr mouse, 
     CheckGrabForSyncs(mouse,(Bool)grab->pointerMode, (Bool)grab->keyboardMode);
 }
 
+/**
+ * Delete grab on given device, update the sprite.
+ *
+ * As a pointer grab can only be issued on the core devices, mouse is always
+ * inputInfo.pointer. Extension devices are set up for ActivateKeyboardGrab().
+ */
 void
 DeactivatePointerGrab(DeviceIntPtr mouse)
 {
@@ -1283,6 +1366,11 @@ DeactivatePointerGrab(DeviceIntPtr mouse
     ComputeFreezes();
 }
 
+/**
+ * Activate a keyboard grab on the given device. 
+ *
+ * Extension devices have ActivateKeyboardGrab() set as their grabbing proc.
+ */
 void
 ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool passive)
 {
@@ -1309,6 +1397,9 @@ ActivateKeyboardGrab(DeviceIntPtr keybd,
     CheckGrabForSyncs(keybd, (Bool)grab->keyboardMode, (Bool)grab->pointerMode);
 }
 
+/**
+ * Delete keyboard grab for the given device. 
+ */
 void
 DeactivateKeyboardGrab(DeviceIntPtr keybd)
 {
@@ -1441,6 +1532,11 @@ AllowSome(ClientPtr client, TimeStamp ti
     }
 }
 
+/**
+ * Server-side protocol handling for AllowEvents request.
+ *
+ * Release some events from a frozen device. Only applicable for core devices.
+ */
 int
 ProcAllowEvents(ClientPtr client)
 {
@@ -1484,6 +1580,9 @@ ProcAllowEvents(ClientPtr client)
     return Success;
 }
 
+/**
+ * Deactivate grabs from any device that has been grabbed by the client.
+ */
 void
 ReleaseActiveGrabs(ClientPtr client)
 {
@@ -1510,6 +1609,30 @@ ReleaseActiveGrabs(ClientPtr client)
  *            The following procedures deal with delivering events        *
  **************************************************************************/
 
+/**
+ * Deliver the given events to the given client.
+ *
+ * More than one event may be delivered at a time. This is the case with
+ * DeviceMotionNotifies which may be followed by DeviceValuator events.
+ *
+ * TryClientEvents() is the last station before actually writing the events to
+ * the socket. Anything that is not filtered here, will get delivered to the
+ * client. 
+ * An event is only delivered if 
+ *   - mask and filter match up.
+ *   - no other client has a grab on the device that caused the event.
+ * 
+ *
+ * @param client The target client to deliver to.
+ * @param pEvents The events to be delivered.
+ * @param count Number of elements in pEvents.
+ * @param mask Event mask as set by the window.
+ * @param filter Mask based on event type.
+ * @param grab Possible grab on the device that caused the event. 
+ *
+ * @return 1 if event was delivered, 0 if not or -1 if grab was not set by the
+ * client.
+ */
 _X_EXPORT int
 TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask, 
                  Mask filter, GrabPtr grab)
@@ -1588,6 +1711,23 @@ TryClientEvents (ClientPtr client, xEven
     }
 }
 
+/**
+ * Deliver events to a window. At this point, we do not yet know if the event
+ * actually needs to be delivered. May activate a grab if the event is a
+ * button press.
+ *
+ * More than one event may be delivered at a time. This is the case with
+ * DeviceMotionNotifies which may be followed by DeviceValuator events.
+ * 
+ * @param pWin The window that would get the event.
+ * @param pEvents The events to be delivered.
+ * @param count Number of elements in pEvents.
+ * @param filter Mask based on event type.
+ * @param grab Possible grab on the device that caused the event. 
+ * @param mskidx Mask index, depending on device that caused event.
+ *
+ * @return Number of events delivered to various clients.
+ */
 int
 DeliverEventsToWindow(WindowPtr pWin, xEvent *pEvents, int count, 
                       Mask filter, GrabPtr grab, int mskidx)
@@ -1707,6 +1847,15 @@ XineramaTryClientEventsResult(
 }
 #endif
 
+/**
+ * Try to deliver events to the interested parties.
+ *
+ * @param pWin The window that would get the event.
+ * @param pEvents The events to be delivered.
+ * @param count Number of elements in pEvents.
+ * @param filter Mask based on event type.
+ * @param dontClient Don't deliver to the dontClient.
+ */
 int
 MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents, 
                            int count, Mask filter, ClientPtr dontClient)
@@ -1744,6 +1893,14 @@ MaybeDeliverEventsToClient(WindowPtr pWi
     return 2;
 }
 
+/**
+ * Adjust event fields to comply with the window properties.
+ *
+ * @param xE Event to be modified in place
+ * @param pWin The window to get the information from.
+ * @param child Child window setting for event (if applicable)
+ * @param calcChild If True, calculate the child window.
+ */
 static void
 FixUpEventFromWindow(
     xEvent *xE,
@@ -1798,6 +1955,22 @@ FixUpEventFromWindow(
     }
 }
 
+/**
+ * Deliver events caused by input devices. Called for all core input events
+ * and XI events. No filtering of events happens before DeliverDeviceEvents(),
+ * it will be called for any event that comes out of the event queue.
+ * 
+ * For all core events, dev is either inputInfo.pointer or inputInfo.keyboard.
+ * For all extension events, dev is the device that caused the event.
+ *
+ * @param pWin Window to deliver event to.
+ * @param xE Events to deliver.
+ * @param grab Possible grab on a device.
+ * @param stopAt Don't recurse up to the root window.
+ * @param dev The device that is responsible for the event.
+ * @param count number of events in xE.
+ *
+ */
 int
 DeliverDeviceEvents(WindowPtr pWin, xEvent *xE, GrabPtr grab, 
                     WindowPtr stopAt, DeviceIntPtr dev, int count)
@@ -1861,7 +2034,19 @@ DeliverDeviceEvents(WindowPtr pWin, xEve
     return 0;
 }
 
-/* not useful for events that propagate up the tree or extension events */
+/**
+ * Deliver event to a window and it's immediate parent. Used for most window
+ * events (CreateNotify, ConfigureNotify, etc.). Not useful for events that
+ * propagate up the tree or extension events 
+ *
+ * In case of a ReparentNotify event, the event will be delivered to the
+ * otherParent as well.
+ *
+ * @param pWin Window to deliver events to.
+ * @param xE Events to deliver.
+ * @param count number of events in xE.
+ * @param otherParent Used for ReparentNotify events.
+ */
 _X_EXPORT int
 DeliverEvents(WindowPtr pWin, xEvent *xE, int count, 
               WindowPtr otherParent)
@@ -1926,6 +2111,17 @@ PointInBorderSize(WindowPtr pWin, int x,
     return FALSE;
 }
 
+/**
+ * Traversed from the root window to the window at the position x/y. While
+ * traversing, it sets up the traversal history in the spriteTrace array.
+ * After completing, the spriteTrace history is set in the following way:
+ *   spriteTrace[0] ... root window
+ *   spriteTrace[1] ... top level window that encloses x/y
+ *       ...
+ *   spriteTrace[spriteTraceGood - 1] ... window at x/y
+ *
+ * @returns the window at the given coordinates.
+ */
 static WindowPtr 
 XYToWindow(int x, int y)
 {
@@ -1974,6 +2170,12 @@ XYToWindow(int x, int y)
     return spriteTrace[spriteTraceGood-1];
 }
 
+/**
+ * Update the sprite coordinates based on the event. Update the cursor
+ * position, then update the event with the new coordinates that may have been
+ * changed. If the window underneath the sprite has changed, change to new
+ * cursor and send enter/leave events.
+ */
 static Bool
 CheckMotion(xEvent *xE)
 {
@@ -2046,6 +2248,10 @@ CheckMotion(xEvent *xE)
     return TRUE;
 }
 
+/**
+ * Windows have restructured, we need to update the sprite position and the
+ * sprite's cursor.
+ */
 _X_EXPORT void
 WindowsRestructured(void)
 {
@@ -2091,6 +2297,10 @@ void ReinitializeRootWindow(WindowPtr wi
 }
 #endif
 
+/**
+ * Set the given window to sane values, display the cursor in the center of
+ * the screen. Called from main() with the root window on the first screen.
+ */
 void
 DefineInitialRootWindow(WindowPtr win)
 {
@@ -2297,6 +2507,10 @@ XineramaWarpPointer(ClientPtr client)
 #endif
 
 
+/**
+ * Server-side protocol handling for WarpPointer request.
+ * Warps the cursor position to the coordinates given in the request.
+ */
 int
 ProcWarpPointer(ClientPtr client)
 {
@@ -2405,8 +2619,15 @@ BorderSizeNotEmpty(WindowPtr pWin)
      return FALSE;
 }
 
-/* "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a
-	passive grab set on the window to be activated. */
+/** 
+ * "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a
+ * passive grab set on the window to be activated. 
+ * 
+ * @param pWin The window that may be subject to a passive grab.
+ * @param device Device that caused the event.
+ * @param xE List of events (multiple ones for DeviceMotionNotify)
+ * @count number of elements in xE.
+ */
 
 static Bool
 CheckPassiveGrabsOnWindow(
@@ -2556,6 +2777,16 @@ CheckDeviceGrabs(DeviceIntPtr device, xE
     return FALSE;
 }
 
+/**
+ * Called for keyboard events to deliver event to whatever client owns the
+ * focus. Event is delivered to the keyboard's focus window, the root window
+ * or to the window owning the input focus.
+ *
+ * @param keybd The keyboard originating the event.
+ * @param xE The event list.
+ * @param window Window underneath the sprite.
+ * @param count number of events in xE.
+ */
 void
 DeliverFocusedEvent(DeviceIntPtr keybd, xEvent *xE, WindowPtr window, int count)
 {
@@ -2584,6 +2815,13 @@ DeliverFocusedEvent(DeviceIntPtr keybd, 
 				NullGrab, mskidx);
 }
 
+/**
+ * Deliver an event from a device that is currently grabbed. Uses
+ * DeliverDeviceEvents() for further delivery if a ownerEvents is set on the
+ * grab. If not, TryClientEvents() is used.
+ *
+ * @param deactivateGrab True if the device's grab should be deactivated.
+ */
 void
 DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev, 
                     Bool deactivateGrab, int count)
@@ -2666,6 +2904,17 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIn
 	}
 }
 
+/**
+ * Main keyboard event processing function for core keyboard events. 
+ * Updates the events fields from the current pointer state and delivers the
+ * event.
+ *
+ * For key events, xE will always be a single event.
+ *
+ * @param xE Event list
+ * @param keybd The device that caused an event.
+ * @param count Number of elements in xE.
+ */
 void
 #ifdef XKB
 CoreProcessKeyboardEvent (xEvent *xE, DeviceIntPtr keybd, int count)
@@ -2861,6 +3110,18 @@ FixKeyState (xEvent *xE, DeviceIntPtr ke
 }
 #endif
 
+/** 
+ * Main pointer event processing function for core pointer events. 
+ * For motion events: update the sprite.
+ * For all other events: Update the event fields based on the current sprite
+ * state.
+ *
+ * For core pointer events, xE will always be a single event.
+ *
+ * @param xE Event list
+ * @param mouse The device that caused an event.
+ * @param count Number of elements in xE.
+ */
 void
 #ifdef XKB
 CoreProcessPointerEvent (xEvent *xE, DeviceIntPtr mouse, int count)
@@ -2974,6 +3235,18 @@ ProcessPointerEvent (xEvent *xE, DeviceI
 #define AtMostOneClient \
 	(SubstructureRedirectMask | ResizeRedirectMask | ButtonPressMask)
 
+/**
+ * Recalculate which events may be deliverable for the given window.
+ * Recalculated mask is used for quicker determination which events may be
+ * delivered to a window.
+ *
+ * The otherEventMasks on a WindowOptional is the combination of all event
+ * masks set by all clients on the window.
+ * deliverableEventMask is the combination of the eventMask and the
+ * otherEventMask.
+ *
+ * Traverses to siblings and parents of the window.
+ */
 void
 RecalculateDeliverableEvents(pWin)
     WindowPtr pWin;
@@ -3172,6 +3445,9 @@ EventSuppressForWindow(WindowPtr pWin, C
     return Success;
 }
 
+/**
+ * @return The window that is the first ancestor of both a and b.
+ */
 static WindowPtr 
 CommonAncestor(
     WindowPtr a,
@@ -3182,6 +3458,10 @@ CommonAncestor(
     return NullWindow;
 }
 
+/**
+ * Assembles an EnterNotify or LeaveNotify and sends it event to the client. 
+ * The core devices are used to fill in the event fields.
+ */
 static void
 EnterLeaveEvent(
     int type,
@@ -3264,6 +3544,10 @@ EnterLeaveEvent(
     }
 }
 
+/**
+ * Send enter notifies to all parent windows up to ancestor.
+ * This function recurses.
+ */
 static void
 EnterNotifies(WindowPtr ancestor, WindowPtr child, int mode, int detail)
 {
@@ -3275,6 +3559,11 @@ EnterNotifies(WindowPtr ancestor, Window
     EnterLeaveEvent(EnterNotify, mode, detail, parent, child->drawable.id);
 }
 
+
+/**
+ * Send leave notifies to all parent windows up to ancestor.
+ * This function recurses.
+ */
 static void
 LeaveNotifies(WindowPtr child, WindowPtr ancestor, int mode, int detail)
 {
@@ -3289,6 +3578,13 @@ LeaveNotifies(WindowPtr child, WindowPtr
     }
 }
 
+/**
+ * Figure out if enter/leave events are necessary and send them to the
+ * appropriate windows.
+ * 
+ * @param fromWin Window the sprite moved out of.
+ * @param toWin Window the sprite moved into.
+ */
 static void
 DoEnterLeaveEvents(WindowPtr fromWin, WindowPtr toWin, int mode)
 {
@@ -3522,6 +3818,23 @@ DoFocusEvents(DeviceIntPtr dev, WindowPt
     }
 }
 
+/**
+ * Set the input focus to the given window. Subsequent keyboard events will be
+ * delivered to the given window.
+ * 
+ * Usually called from ProcSetInputFocus as result of a client request. If so,
+ * the device is the inputInfo.keyboard.
+ * If called from ProcXSetInputFocus as result of a client xinput request, the
+ * device is set to the device specified by the client.
+ *
+ * @param client Client that requested input focus change.
+ * @param dev Focus device. 
+ * @param focusID The window to obtain the focus. Can be PointerRoot or None.
+ * @param revertTo Specifies where the focus reverts to when window becomes
+ * unviewable.
+ * @param ctime Specifies the time.
+ * @param followOK True if pointer is allowed to follow the keyboard.
+ */
 int
 SetInputFocus(
     ClientPtr client,
@@ -3598,6 +3911,11 @@ SetInputFocus(
     return Success;
 }
 
+/**
+ * Server-side protocol handling for SetInputFocus request.
+ *
+ * Sets the input focus for the virtual core keyboard.
+ */
 int
 ProcSetInputFocus(client)
     ClientPtr client;
@@ -3613,6 +3931,12 @@ ProcSetInputFocus(client)
 			 stuff->revertTo, stuff->time, FALSE);
 }
 
+/**
+ * Server-side protocol handling for GetInputFocus request.
+ * 
+ * Sends the current input focus for the virtual core keyboard back to the
+ * client.
+ */
 int
 ProcGetInputFocus(ClientPtr client)
 {
@@ -3634,6 +3958,12 @@ ProcGetInputFocus(ClientPtr client)
     return Success;
 }
 
+/**
+ * Server-side protocol handling for Grabpointer request.
+ *
+ * Sets an active grab on the inputInfo.pointer and returns success status to
+ * client.
+ */
 int
 ProcGrabPointer(ClientPtr client)
 {
@@ -3741,6 +4071,14 @@ ProcGrabPointer(ClientPtr client)
     return Success;
 }
 
+/**
+ * Server-side protocol handling for ChangeActivePointerGrab request.
+ *
+ * Changes properties of the grab hold by the client. If the client does not
+ * hold an active grab on the device, nothing happens. 
+ *
+ * Works on the core pointer only.
+ */
 int
 ProcChangeActivePointerGrab(ClientPtr client)
 {
@@ -3787,6 +4125,11 @@ ProcChangeActivePointerGrab(ClientPtr cl
     return Success;
 }
 
+/**
+ * Server-side protocol handling for UngrabPointer request.
+ *
+ * Deletes the pointer grab on the core pointer device.
+ */
 int
 ProcUngrabPointer(ClientPtr client)
 {
@@ -3806,6 +4149,24 @@ ProcUngrabPointer(ClientPtr client)
     return Success;
 }
 
+/**
+ * Sets a grab on the given device.
+ * 
+ * Called from ProcGrabKeyboard to work on the inputInfo.keyboard.
+ * Called from ProcXGrabDevice to work on the device specified by the client.
+ * 
+ * The parameters this_mode and other_mode represent the keyboard_mode and
+ * pointer_mode parameters of XGrabKeyboard(). 
+ * See man page for details on all the parameters
+ * 
+ * @param client Client that owns the grab.
+ * @param dev The device to grab. 
+ * @param this_mode GrabModeSync or GrabModeAsync
+ * @param other_mode GrabModeSync or GrabModeAsync
+ * @param status Return code to be returned to the caller.
+ * 
+ * @returns Success or BadValue.
+ */
 int
 GrabDevice(ClientPtr client, DeviceIntPtr dev, 
            unsigned this_mode, unsigned other_mode, Window grabWindow, 
@@ -3864,6 +4225,11 @@ GrabDevice(ClientPtr client, DeviceIntPt
     return Success;
 }
 
+/**
+ * Server-side protocol handling for GrabKeyboard request.
+ *
+ * Grabs the inputInfo.keyboad and returns success status to client.
+ */
 int
 ProcGrabKeyboard(ClientPtr client)
 {
@@ -3892,6 +4258,11 @@ ProcGrabKeyboard(ClientPtr client)
     return Success;
 }
 
+/**
+ * Server-side protocol handling for UngrabKeyboard request.
+ *
+ * Deletes a possible grab on the inputInfo.keyboard.
+ */
 int
 ProcUngrabKeyboard(ClientPtr client)
 {
@@ -3911,6 +4282,11 @@ ProcUngrabKeyboard(ClientPtr client)
     return Success;
 }
 
+/**
+ * Server-side protocol handling for QueryPointer request.
+ *
+ * Returns the current state and position of the core pointer to the client. 
+ */
 int
 ProcQueryPointer(ClientPtr client)
 {
@@ -3969,6 +4345,10 @@ ProcQueryPointer(ClientPtr client)
     return(Success);    
 }
 
+/**
+ * Initializes the device list and the DIX sprite to sane values. Allocates
+ * trace memory used for quick window traversal.
+ */
 void
 InitEvents(void)
 {
@@ -4030,6 +4410,11 @@ CloseDownEvents(void)
   spriteTraceSize = 0;
 }
 
+/**
+ * Server-side protocol handling for SendEvent request.
+ *
+ * Locates the window to send the event to and forwards the event. 
+ */
 int
 ProcSendEvent(ClientPtr client)
 {
@@ -4117,6 +4502,12 @@ ProcSendEvent(ClientPtr client)
     return Success;
 }
 
+/**
+ * Server-side protocol handling for UngrabKey request.
+ *
+ * Deletes a passive grab for the given key. Only works on the
+ * inputInfo.keyboard.
+ */
 int
 ProcUngrabKey(ClientPtr client)
 {
@@ -4159,6 +4550,12 @@ ProcUngrabKey(ClientPtr client)
     return(Success);
 }
 
+/**
+ * Server-side protocol handling for GrabKey request.
+ *
+ * Creates a grab for the inputInfo.keyboard and adds it to the list of
+ * passive grabs. 
+ */
 int
 ProcGrabKey(ClientPtr client)
 {
@@ -4214,6 +4611,12 @@ ProcGrabKey(ClientPtr client)
 }
 
 
+/**
+ * Server-side protocol handling for GrabButton request.
+ *
+ * Creates a grab for the inputInfo.pointer and adds it as a passive grab to
+ * the list.
+ */
 int
 ProcGrabButton(ClientPtr client)
 {
@@ -4287,6 +4690,11 @@ ProcGrabButton(ClientPtr client)
     return AddPassiveGrabToList(grab);
 }
 
+/**
+ * Server-side protocol handling for UngrabButton request.
+ *
+ * Deletes a passive grab on the inputInfo.pointer from the list.
+ */
 int
 ProcUngrabButton(ClientPtr client)
 {
@@ -4320,6 +4728,17 @@ ProcUngrabButton(ClientPtr client)
     return(Success);
 }
 
+/**
+ * Deactivate any grab that may be on the window, remove the focus.
+ * Delete any XInput extension events from the window too. Does not change the
+ * window mask. Use just before the window is deleted.
+ *
+ * If freeResources is set, passive grabs on the window are deleted.
+ *
+ * @param pWin The window to delete events from.
+ * @param freeResources True if resources associated with the window should be
+ * deleted.
+ */
 void
 DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
 {
@@ -4409,7 +4828,9 @@ DeleteWindowFromAnyEvents(WindowPtr pWin
 }
 
 /**
- * Call this whenever some window at or below pWin has changed geometry 
+ * Call this whenever some window at or below pWin has changed geometry. If
+ * there is a grab on the window, the cursor will be re-confined into the
+ * window.
  */
 _X_EXPORT void
 CheckCursorConfinement(WindowPtr pWin)
@@ -4445,6 +4866,9 @@ EventMaskForClient(WindowPtr pWin, Clien
     return 0;
 }
 
+/**
+ * Server-side protocol handling for RecolorCursor request.
+ */
 int
 ProcRecolorCursor(ClientPtr client)
 {
@@ -4486,6 +4910,20 @@ ProcRecolorCursor(ClientPtr client)
     return (Success);
 }
 
+/**
+ * Write the given events to a client, swapping the byte order if necessary.
+ * To swap the byte ordering, a callback is called that has to be set up for
+ * the given event type.
+ *
+ * In the case of DeviceMotionNotify trailed by DeviceValuators, the events
+ * can be more than one. Usually it's just one event. 
+ *
+ * Do not modify the event structure passed in. See comment below.
+ * 
+ * @param pClient Client to send events to.
+ * @param count Number of events.
+ * @param events The event list.
+ */
 _X_EXPORT void
 WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
 {
diff-tree 33a5d9605e3e282f6aa1921d7321a2a12ef02c42 (from 0910540e4322bba72a2fa0a907072eab2547a7b6)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Apr 11 18:28:57 2007 +0300

    XFree86: DGA: Don't call ProcessInputEvents from CloseScreen
    
    By the time CloseScreen gets called, we can't call ProcessInputEvents, as
    the event queue will get unhappy.  So just unregister our hooks instantly,
    and hope that they don't get called.

diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 43db1ee..9474ec8 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -249,14 +249,11 @@ DGACloseScreen(int i, ScreenPtr pScreen)
    DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
 
    if (XDGAEventBase) {
-       OsBlockSignals();
-       ProcessInputEvents();
        mieqSetHandler(*XDGAEventBase + MotionNotify, NULL);
        mieqSetHandler(*XDGAEventBase + ButtonPress, NULL);
        mieqSetHandler(*XDGAEventBase + ButtonRelease, NULL);
        mieqSetHandler(*XDGAEventBase + KeyPress, NULL);
        mieqSetHandler(*XDGAEventBase + KeyRelease, NULL);
-       OsReleaseSignals();
     }
 
    FreeMarkedVisuals(pScreen);
diff-tree 0910540e4322bba72a2fa0a907072eab2547a7b6 (from aecbc712144dd1aaf462bd758821438b1d22d957)
Author: Remigiusz Marcinkiewicz <enleth at enleth.com>
Date:   Wed Apr 11 01:09:26 2007 +0300

    Config: Extend D-BUS API
    
    Return device ID where available.
    Add listDevices call, which does what it says on the box.

diff --git a/config/config.c b/config/config.c
index aae5c6e..9828091 100644
--- a/config/config.c
+++ b/config/config.c
@@ -92,12 +92,15 @@ configTeardown(void)
 }
 
 static int
-configAddDevice(DBusMessage *message, DBusMessageIter *iter, DBusError *error)
+configAddDevice(DBusMessage *message, DBusMessageIter *iter, 
+                DBusMessage *reply, DBusMessageIter *r_iter,
+                DBusError *error)
 {
     DBusMessageIter subiter;
     InputOption *tmpo = NULL, *options = NULL;
     char *tmp = NULL;
     int ret = BadMatch;
+    DeviceIntPtr dev = NULL;
 
     DebugF("[config] adding device\n");
 
@@ -165,12 +168,28 @@ configAddDevice(DBusMessage *message, DB
         dbus_message_iter_next(iter);
     }
 
-    ret = NewInputDeviceRequest(options);
-    if (ret != Success)
+    ret = NewInputDeviceRequest(options, &dev);
+    if (ret != Success) {
         DebugF("[config] NewInputDeviceRequest failed\n");
+        goto unwind;
+    }
+
+    if (!dev) {
+        DebugF("[config] NewInputDeviceRequest succeeded, without device\n"); 
+        ret = BadMatch;
+        goto unwind;
+    }
+
+    if (!dbus_message_iter_append_basic(r_iter, DBUS_TYPE_INT32, &(dev->id))) {
+        ErrorF("[config] couldn't append to iterator\n");
+        ret = BadAlloc;
+        goto unwind;
+    }
 
-    /* Fall through, must deallocate memory we've allocated */
 unwind:
+    if (dev && ret != Success)
+        RemoveDevice(dev);
+
     while (options) {
         tmpo = options;
         options = options->next;
@@ -218,17 +237,47 @@ unwind:
     return ret;
 }
 
+static int
+configListDevices(DBusMessage *message, DBusMessageIter *iter,
+                   DBusMessage *reply, DBusMessageIter *r_iter,
+                   DBusError *error)
+{
+    DeviceIntPtr d;
+    int ret = BadMatch;
+
+    for (d = inputInfo.devices; d; d = d->next) {
+        if (!dbus_message_iter_append_basic(r_iter, DBUS_TYPE_INT32,
+                                            &(d->id))) {
+            ErrorF("[config] couldn't append to iterator\n");
+            ret = BadAlloc;
+            goto unwind;
+        }
+        if (!dbus_message_iter_append_basic(r_iter, DBUS_TYPE_STRING,
+                                            &(d->name))) {
+            ErrorF("[config] couldn't append to iterator\n");
+            ret = BadAlloc;
+            goto unwind;
+        }
+    }
+
+unwind:
+    return ret;
+}
+
 static DBusHandlerResult
 configMessage(DBusConnection *connection, DBusMessage *message, void *closure)
 {
     DBusMessageIter iter;
     DBusError error;
     DBusMessage *reply;
+    DBusMessageIter r_iter;
     DBusConnection *bus = closure;
     int ret = BadDrawable; /* nonsensical value */
 
     dbus_error_init(&error);
 
+    DebugF("[config] received a message\n");
+
     if (strcmp(dbus_message_get_interface(message),
                "org.x.config.input") == 0) {
         if (!dbus_message_iter_init(message, &iter)) {
@@ -237,26 +286,33 @@ configMessage(DBusConnection *connection
             return DBUS_HANDLER_RESULT_NEED_MEMORY; /* ?? */
         }
 
+        if (!(reply = dbus_message_new_method_return(message))) {
+            ErrorF("[config] failed to create the reply message\n");
+            dbus_error_free(&error);
+            return DBUS_HANDLER_RESULT_NEED_MEMORY;
+        }
+        dbus_message_iter_init_append(reply, &r_iter);
+        
         if (strcmp(dbus_message_get_member(message), "add") == 0)
-            ret = configAddDevice(message, &iter, &error);
+            ret = configAddDevice(message, &iter, reply, &r_iter, &error);
         else if (strcmp(dbus_message_get_member(message), "remove") == 0)
             ret = configRemoveDevice(message, &iter, &error);
+        else if (strcmp(dbus_message_get_member(message), "listDevices") == 0)
+            ret = configListDevices(message, &iter, reply, &r_iter, &error);
         if (ret != BadDrawable && ret != BadAlloc) {
-            reply = dbus_message_new_method_return(message);
-            dbus_message_iter_init_append(reply, &iter);
 
-            if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret)) {
-                ErrorF("[config] couldn't append to iterator\n");
-                dbus_error_free(&error);
-                return DBUS_HANDLER_RESULT_HANDLED;
-            }
+            if (!strlen(dbus_message_get_signature(reply)))
+                if (!dbus_message_iter_append_basic(&r_iter, DBUS_TYPE_INT32, &ret)) {
+                    ErrorF("[config] couldn't append to iterator\n");
+                    dbus_error_free(&error);
+                    return DBUS_HANDLER_RESULT_HANDLED;
+                }
 
             if (!dbus_connection_send(bus, reply, NULL))
                 ErrorF("[config] failed to send reply\n");
-            dbus_connection_flush(bus);
-
-            dbus_message_unref(reply);
         }
+        dbus_message_unref(reply);
+        dbus_connection_flush(bus);
     }
 
     dbus_error_free(&error);
diff-tree aecbc712144dd1aaf462bd758821438b1d22d957 (from 4f05f9591e5492c72f3856bd7a2ff13378f59f2b)
Author: Remigiusz Marcinkiewicz <enleth at enleth.com>
Date:   Wed Apr 11 00:38:16 2007 +0300

    Input: Allow a pointer to a device to be returned in NIDR
    
    Allow a pointer to the first device added to be returned, so we know which
    device(s) were added by the NIDR call.

diff --git a/Xi/stubs.c b/Xi/stubs.c
index d425fe9..40cd02f 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -226,7 +226,7 @@ ChangeDeviceControl(ClientPtr client, De
  *
  */
 int
-NewInputDeviceRequest(InputOption *options)
+NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
 {
     return BadValue;
 }
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index a9a743b..7edcc51 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -2307,7 +2307,7 @@ ChangeDeviceControl(register ClientPtr c
 }
 
 int
-NewInputDeviceRequest(InputOption *options)
+NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
 {
     InputOption *option = NULL;
     KdPointerInfo *pi = NULL;
@@ -2372,6 +2372,12 @@ NewInputDeviceRequest(InputOption *optio
         }
     }
 
+    if (pi) {
+        *pdev = pi->dixdev;
+    } else if(ki) {
+        *pdev = ki->dixdev;
+    }
+
     return Success;
 }
 
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index f662c17..6ebb087 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -315,7 +315,7 @@ AddOtherInputDevices()
 #endif
 
 int
-NewInputDeviceRequest (InputOption *options)
+NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
 {
     IDevRec *idev = NULL;
     InputDriverPtr drv = NULL;
@@ -409,6 +409,7 @@ NewInputDeviceRequest (InputOption *opti
     if (dev->inited && dev->startup)
         EnableDevice(dev);
 
+    *pdev = dev;
     return Success;
 
 unwind:
diff --git a/include/input.h b/include/input.h
index 1e65709..b399d3a 100644
--- a/include/input.h
+++ b/include/input.h
@@ -445,7 +445,8 @@ extern DeviceIntPtr LookupDeviceIntRec(
 
 /* Implemented by the DDX. */
 extern int NewInputDeviceRequest(
-    InputOption *options);
+    InputOption *options,
+    DeviceIntPtr *dev);
 extern void DeleteInputDeviceRequest(
     DeviceIntPtr dev);
 
diff-tree 4f05f9591e5492c72f3856bd7a2ff13378f59f2b (from 20674dcbb2373a0af287883bc008fb6fb23d4466)
Author: Magnus Vigerlöf <Magnus.Vigerlof at home.se>
Date:   Tue Apr 10 23:57:48 2007 +0300

    Input: Always add devices with first available ID
    
    Scan the device list when adding a new device, and make sure we can use
    the first available ID, instead of always incrementing.

diff --git a/dix/devices.c b/dix/devices.c
index 004cb13..c2d4f22 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -86,15 +86,27 @@ DeviceIntPtr
 AddInputDevice(DeviceProc deviceProc, Bool autoStart)
 {
     DeviceIntPtr dev, *prev; /* not a typo */
+    DeviceIntPtr devtmp;
+    int devid;
+    char devind[MAX_DEVICES];
+
+    /* Find next available id */
+    memset(devind, 0, sizeof(char)*MAX_DEVICES);
+    for (devtmp = inputInfo.devices; devtmp; devtmp = devtmp->next)
+	devind[devtmp->id]++;
+    for (devtmp = inputInfo.off_devices; devtmp; devtmp = devtmp->next)
+	devind[devtmp->id]++;
+    for (devid = 0; devid < MAX_DEVICES && devind[devid]; devid++)
+	;
 
-    if (inputInfo.numDevices >= MAX_DEVICES)
+    if (devid >= MAX_DEVICES)
 	return (DeviceIntPtr)NULL;
     dev = (DeviceIntPtr) xcalloc(sizeof(DeviceIntRec), 1);
     if (!dev)
 	return (DeviceIntPtr)NULL;
     dev->name = (char *)NULL;
     dev->type = 0;
-    dev->id = inputInfo.numDevices;
+    dev->id = devid;
     inputInfo.numDevices++;
     dev->public.on = FALSE;
     dev->public.processInputProc = (ProcessInputProc)NoopDDA;
@@ -572,6 +584,7 @@ RemoveDevice(DeviceIntPtr dev)
     }
     
     if (ret == Success) {
+        inputInfo.numDevices--;
         ev.type = DevicePresenceNotify;
         ev.time = currentTime.milliseconds;
         ev.devchange = 0;
diff-tree 20674dcbb2373a0af287883bc008fb6fb23d4466 (from 82962bbae2b4fda274625d1712ef839ce1ab9dc8)
Author: Magnus Vigerlöf <Magnus.Vigerlof at home.se>
Date:   Tue Apr 10 23:55:36 2007 +0300

    Config: Fix memory leaks
    
    Fix memory leaks that could occur along the error path.

diff --git a/config/config.c b/config/config.c
index b8d2428..aae5c6e 100644
--- a/config/config.c
+++ b/config/config.c
@@ -110,6 +110,11 @@ configAddDevice(DBusMessage *message, DB
 
     options->key = xstrdup("_source");
     options->value = xstrdup("client/dbus");
+    if(!options->key || !options->value) {
+        ErrorF("[config] couldn't allocate first key/value pair\n");
+        ret = BadAlloc;
+        goto unwind;
+    }
 
     while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_ARRAY) {
         tmpo = (InputOption *) xcalloc(sizeof(InputOption), 1);
@@ -118,6 +123,8 @@ configAddDevice(DBusMessage *message, DB
             ret = BadAlloc;
             goto unwind;
         }
+        tmpo->next = options;
+        options = tmpo;
 
         dbus_message_iter_recurse(iter, &subiter);
 
@@ -132,8 +139,8 @@ configAddDevice(DBusMessage *message, DB
                    tmp);
             MALFORMED_MESSAGE();
         }
-        tmpo->key = xstrdup(tmp);
-        if (!tmpo->key) {
+        options->key = xstrdup(tmp);
+        if (!options->key) {
             ErrorF("[config] couldn't duplicate key!\n");
             ret = BadAlloc;
             goto unwind;
@@ -148,15 +155,13 @@ configAddDevice(DBusMessage *message, DB
         dbus_message_iter_get_basic(&subiter, &tmp);
         if (!tmp)
             MALFORMED_MESSAGE();
-        tmpo->value = xstrdup(tmp);
-        if (!tmpo->value) {
+        options->value = xstrdup(tmp);
+        if (!options->value) {
             ErrorF("[config] couldn't duplicate option!\n");
             ret = BadAlloc;
             goto unwind;
         }
 
-        tmpo->next = options;
-        options = tmpo;
         dbus_message_iter_next(iter);
     }
 
@@ -164,16 +169,8 @@ configAddDevice(DBusMessage *message, DB
     if (ret != Success)
         DebugF("[config] NewInputDeviceRequest failed\n");
 
-    return ret;
-
+    /* Fall through, must deallocate memory we've allocated */
 unwind:
-    if (tmpo->key)
-        xfree(tmpo->key);
-    if (tmpo->value)
-        xfree(tmpo->value);
-    if (tmpo)
-        xfree(tmpo);
-
     while (options) {
         tmpo = options;
         options = options->next;
diff-tree 82962bbae2b4fda274625d1712ef839ce1ab9dc8 (from 7b82a836c66ba88566255052caff63577e1a0384)
Author: Magnus Vigerlöf <Magnus.Vigerlof at home.se>
Date:   Tue Apr 10 23:54:32 2007 +0300

    Input: Add DeleteInputDeviceRequest
    
    Add DIDR, which asks the DDX to remove a device, analogous to
    NewInputDeviceRequest.  Only implemented for XFree86 at the moment.

diff --git a/Xi/stubs.c b/Xi/stubs.c
index ed041b8..d425fe9 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -230,3 +230,15 @@ NewInputDeviceRequest(InputOption *optio
 {
     return BadValue;
 }
+
+/****************************************************************************
+ *
+ * Caller: configRemoveDevice (and others)
+ *
+ * Remove the specified device previously added.
+ *
+ */
+void
+DeleteInputDeviceRequest(DeviceIntPtr dev)
+{
+}
diff --git a/config/config.c b/config/config.c
index d72b588..b8d2428 100644
--- a/config/config.c
+++ b/config/config.c
@@ -212,7 +212,7 @@ configRemoveDevice(DBusMessage *message,
      * already been removed. */
     OsBlockSignals();
     ProcessInputEvents();
-    RemoveDevice(pDev);
+    DeleteInputDeviceRequest(pDev);
     OsReleaseSignals();
 
     return Success;
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 857f04f..a9a743b 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -2374,3 +2374,8 @@ NewInputDeviceRequest(InputOption *optio
 
     return Success;
 }
+
+void
+DeleteInputDeviceRequest(DeviceIntPtr pDev)
+{
+}
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 913735b..e0b758f 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -371,8 +371,11 @@ xf86DeleteInput(InputInfoPtr pInp, int f
     if (pInp->drv)
 	pInp->drv->refCount--;
 
+    /* This should *really* be handled in drv->UnInit(dev) call instead */
+#if 0
     if (pInp->private)
 	xfree(pInp->private);
+#endif
 
     /* Remove the entry from the list. */
     if (pInp == xf86InputDevs)
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 3800d9a..f662c17 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -427,6 +427,26 @@ unwind:
     return rval;
 }
 
+void
+DeleteInputDeviceRequest(DeviceIntPtr pDev)
+{
+    LocalDevicePtr pInfo = (LocalDevicePtr) pDev->public.devicePrivate;
+    InputDriverPtr drv = pInfo->drv;
+    IDevRec *idev = pInfo->conf_idev;
+
+    RemoveDevice(pDev);
+
+    if(drv->UnInit)
+        drv->UnInit(drv, pInfo, 0);
+    else
+        xf86DeleteInput(pInfo, 0);
+
+    xfree(idev->driver);
+    xfree(idev->identifier);
+    xf86optionListFree(idev->commonOptions);
+    xfree(idev);
+}
+
 /* 
  * convenient functions to post events
  */
diff --git a/include/input.h b/include/input.h
index fc607d3..1e65709 100644
--- a/include/input.h
+++ b/include/input.h
@@ -446,6 +446,8 @@ extern DeviceIntPtr LookupDeviceIntRec(
 /* Implemented by the DDX. */
 extern int NewInputDeviceRequest(
     InputOption *options);
+extern void DeleteInputDeviceRequest(
+    DeviceIntPtr dev);
 
 extern void DDXRingBell(
     int volume,
diff-tree 7b82a836c66ba88566255052caff63577e1a0384 (from 4771fa8747791498e504d73afccfb5833499a38b)
Author: Magnus Vigerlöf <Magnus.Vigerlof at home.se>
Date:   Tue Apr 10 23:52:08 2007 +0300

    XFree86: Fix memory leaks, option parsing, in NewInputDeviceRequest
    
    Plugged some possible memory leaks, and added some more checks on the
    options, particular for driver/identifier.  Added an unwind.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 17ffed8..3800d9a 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -322,6 +322,7 @@ NewInputDeviceRequest (InputOption *opti
     InputInfoPtr pInfo = NULL;
     InputOption *option = NULL;
     DeviceIntPtr dev = NULL;
+    int rval = Success;
 
     idev = xcalloc(sizeof(*idev), 1);
     if (!idev)
@@ -329,64 +330,101 @@ NewInputDeviceRequest (InputOption *opti
 
     for (option = options; option; option = option->next) {
         if (strcmp(option->key, "driver") == 0) {
-            if (!xf86LoadOneModule(option->value, NULL))
-                return BadName;
+            if (idev->driver) {
+                rval = BadRequest;
+                goto unwind;
+            }
+            /* Memory leak for every attached device if we don't
+             * test if the module is already loaded first */
             drv = xf86LookupInputDriver(option->value);
+            if (!drv)
+                if(xf86LoadOneModule(option->value, NULL))
+                    drv = xf86LookupInputDriver(option->value);
             if (!drv) {
                 xf86Msg(X_ERROR, "No input driver matching `%s'\n",
                         option->value);
-                return BadName;
+                rval = BadName;
+                goto unwind;
             }
             idev->driver = xstrdup(option->value);
             if (!idev->driver) {
-                xfree(idev);
-                return BadAlloc;
+                rval = BadAlloc;
+                goto unwind;
             }
         }
         if (strcmp(option->key, "name") == 0 ||
             strcmp(option->key, "identifier") == 0) {
+            if (idev->identifier) {
+                rval = BadRequest;
+                goto unwind;
+            }
             idev->identifier = xstrdup(option->value);
             if (!idev->identifier) {
-                xfree(idev);
-                return BadAlloc;
+                rval = BadAlloc;
+                goto unwind;
             }
         }
     }
+    if(!idev->driver || !idev->identifier) {
+        xf86Msg(X_ERROR, "No input driver/identifier specified (ignoring)\n");
+        rval = BadRequest;
+        goto unwind;
+    }
 
     if (!drv->PreInit) {
         xf86Msg(X_ERROR,
                 "Input driver `%s' has no PreInit function (ignoring)\n",
                 drv->driverName);
-        return BadImplementation;
+        rval = BadImplementation;
+        goto unwind;
     }
 
-    idev->commonOptions = NULL;
-    for (option = options; option; option = option->next)
+    for (option = options; option; option = option->next) {
+        /* Steal option key/value strings from the provided list.
+         * We need those strings, the InputOption list doesn't. */
         idev->commonOptions = xf86addNewOption(idev->commonOptions,
                                                option->key, option->value);
-    idev->extraOptions = NULL;
+        option->key = NULL;
+        option->value = NULL;
+    }
 
     pInfo = drv->PreInit(drv, idev, 0);
 
     if (!pInfo) {
         xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n", idev->identifier);
-        return BadMatch;
+        rval = BadMatch;
+        goto unwind;
     }
     else if (!(pInfo->flags & XI86_CONFIGURED)) {
         xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
                 idev->identifier);
-        xf86DeleteInput(pInfo, 0);
-        return BadMatch;
+        rval = BadMatch;
+        goto unwind;
     }
 
     xf86ActivateDevice(pInfo);
 
     dev = pInfo->dev;
-    dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
+    ActivateDevice(dev);
     if (dev->inited && dev->startup)
         EnableDevice(dev);
 
     return Success;
+
+unwind:
+    if(pInfo) {
+        if(drv->UnInit)
+            drv->UnInit(drv, pInfo, 0);
+        else
+            xf86DeleteInput(pInfo, 0);
+    }
+    if(idev->driver)
+        xfree(idev->driver);
+    if(idev->identifier)
+        xfree(idev->identifier);
+    xf86optionListFree(idev->commonOptions);
+    xfree(idev);
+    return rval;
 }
 
 /* 
diff-tree 4771fa8747791498e504d73afccfb5833499a38b (from 07c56abf84080c020a3e7b7703a447c7f996975c)
Author: Magnus Vigerlöf <Magnus.Vigerlof at home.se>
Date:   Tue Apr 10 23:48:00 2007 +0300

    XFree86: Fix memory leak in option parsing
    
    Fix option parsing functions and callers thereof to not leak memory.

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index cbeda0b..0421bf9 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1271,7 +1271,7 @@ checkCoreInputDevices(serverLayoutPtr se
 			      (count + 1) * sizeof(IDevRec));
 	    indp[count - 1] = Pointer;
 	    indp[count - 1].extraOptions =
-				xf86addNewOption(NULL, "CorePointer", NULL);
+				xf86addNewOption(NULL, xnfstrdup("CorePointer"), NULL);
 	    indp[count].identifier = NULL;
 	    servlayoutp->inputs = indp;
 	}
@@ -1310,7 +1310,7 @@ checkCoreInputDevices(serverLayoutPtr se
 			      (count + 1) * sizeof(IDevRec));
 	    indp[count - 1] = Pointer;
 	    indp[count - 1].extraOptions =
-				xf86addNewOption(NULL, "AlwaysCore", NULL);
+				xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL);
 	    indp[count].identifier = NULL;
 	    servlayoutp->inputs = indp;
 	}
@@ -1401,7 +1401,7 @@ checkCoreInputDevices(serverLayoutPtr se
 			      (count + 1) * sizeof(IDevRec));
 	    indp[count - 1] = Keyboard;
 	    indp[count - 1].extraOptions =
-				xf86addNewOption(NULL, "CoreKeyboard", NULL);
+				xf86addNewOption(NULL, xnfstrdup("CoreKeyboard"), NULL);
 	    indp[count].identifier = NULL;
 	    servlayoutp->inputs = indp;
 	}
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index 4b482df..7b04bd6 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -309,13 +309,16 @@ configureInputSection (void)
     mouse->inp_identifier = "Mouse0";
     mouse->inp_driver = "mouse";
     mouse->inp_option_lst = 
-		xf86addNewOption(mouse->inp_option_lst, "Protocol", DFLT_MOUSE_PROTO);
+		xf86addNewOption(mouse->inp_option_lst, xstrdup("Protocol"),
+				xstrdup(DFLT_MOUSE_PROTO));
 #ifndef __SCO__
     mouse->inp_option_lst = 
-		xf86addNewOption(mouse->inp_option_lst, "Device", DFLT_MOUSE_DEV);
+		xf86addNewOption(mouse->inp_option_lst, xstrdup("Device"),
+				xstrdup(DFLT_MOUSE_DEV));
 #endif
     mouse->inp_option_lst = 
-		xf86addNewOption(mouse->inp_option_lst, "ZAxisMapping", "4 5 6 7");
+		xf86addNewOption(mouse->inp_option_lst, xstrdup("ZAxisMapping"),
+				xstrdup("4 5 6 7"));
     ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse);
     return ptr;
 }
@@ -519,7 +522,7 @@ configureLayoutSection (void)
 	iptr->iref_option_lst = NULL;
 	iptr->iref_inputdev_str = "Mouse0";
 	iptr->iref_option_lst =
-		xf86addNewOption (iptr->iref_option_lst, "CorePointer", NULL);
+		xf86addNewOption (iptr->iref_option_lst, xstrdup("CorePointer"), NULL);
 	ptr->lay_input_lst = (XF86ConfInputrefPtr)
 		xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
     }
@@ -532,7 +535,7 @@ configureLayoutSection (void)
 	iptr->iref_option_lst = NULL;
 	iptr->iref_inputdev_str = "Keyboard0";
 	iptr->iref_option_lst =
-		xf86addNewOption (iptr->iref_option_lst, "CoreKeyboard", NULL);
+		xf86addNewOption (iptr->iref_option_lst, xstrdup("CoreKeyboard"), NULL);
 	ptr->lay_input_lst = (XF86ConfInputrefPtr)
 		xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
     }
@@ -751,7 +754,7 @@ configureDDCMonitorSection (int screennu
     }
 
     if (ConfiguredMonitor->features.dpms) {
-      ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, "DPMS", NULL);
+      ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, xstrdup("DPMS"), NULL);
     }
 
     return ptr;
diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c
index 7afb63a..50a7d9c 100644
--- a/hw/xfree86/common/xf86Option.c
+++ b/hw/xfree86/common/xf86Option.c
@@ -289,7 +289,7 @@ xf86CheckBoolOption(pointer optlist, con
 _X_EXPORT pointer
 xf86ReplaceIntOption(pointer optlist, const char *name, const int val)
 {
-    char *tmp = xnfalloc(16);
+    char tmp[16];
     sprintf(tmp,"%i",val);
     return xf86AddNewOption(optlist,name,tmp);
 }
@@ -297,7 +297,7 @@ xf86ReplaceIntOption(pointer optlist, co
 _X_EXPORT pointer
 xf86ReplaceRealOption(pointer optlist, const char *name, const double val)
 {
-    char *tmp = xnfalloc(32);
+    char tmp[32];
     snprintf(tmp,32,"%f",val);
     return xf86AddNewOption(optlist,name,tmp);
 }
diff --git a/hw/xfree86/parser/Flags.c b/hw/xfree86/parser/Flags.c
index 4adea1a..5b60a51 100644
--- a/hw/xfree86/parser/Flags.c
+++ b/hw/xfree86/parser/Flags.c
@@ -198,21 +198,21 @@ addNewOption2 (XF86OptionPtr head, char 
 {
 	XF86OptionPtr new, old = NULL;
 
-	/* Don't allow duplicates */
- 	if (head != NULL && (old = xf86findOption(head, name)) != NULL)
- 		new = old;
- 	else {
+	/* Don't allow duplicates, free old strings */
+	if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
+		new = old;
+		xf86conffree(new->opt_name);
+		xf86conffree(new->opt_val);
+	}
+	else
 		new = xf86confcalloc (1, sizeof (XF86OptionRec));
- 		new->list.next = NULL;
- 	}
- 	new->opt_name = name;
- 	new->opt_val = val;
- 	new->opt_used = used;
-	
-  	if (old == NULL)
-		return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new));
- 	else 
- 		return head;
+	new->opt_name = name;
+	new->opt_val = val;
+	new->opt_used = used;
+
+	if (old)
+		return head;
+	return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new));
 }
 
 XF86OptionPtr
diff --git a/hw/xfree86/utils/xorgcfg/text-mode.c b/hw/xfree86/utils/xorgcfg/text-mode.c
index 9797ca2..8800c29 100644
--- a/hw/xfree86/utils/xorgcfg/text-mode.c
+++ b/hw/xfree86/utils/xorgcfg/text-mode.c
@@ -2111,7 +2111,7 @@ LayoutConfig(void)
 		    else
 			iref->iref_option_lst =
 			    xf86addNewOption(iref->iref_option_lst,
-					  "CorePointer", NULL);
+					  XtNewString("CorePointer"), NULL);
 		    option = xf86findOption(mref->iref_option_lst,
 					    "CorePointer");
 		    XtFree(option->opt_name);
@@ -2209,7 +2209,7 @@ LayoutConfig(void)
 		    else
 			iref->iref_option_lst =
 			    xf86addNewOption(iref->iref_option_lst,
-					  "CoreKeyboard", NULL);
+					  XtNewString("CoreKeyboard"), NULL);
 		    option = xf86findOption(kref->iref_option_lst,
 					    "CoreKeyboard");
 		    XtFree(option->opt_name);
diff-tree 07c56abf84080c020a3e7b7703a447c7f996975c (from e92743bc9839c36914a44f3e5bc8cd85773ac794)
Author: Magnus Vigerlöf <Magnus.Vigerlof at home.se>
Date:   Tue Apr 10 23:43:58 2007 +0300

    Input: Plug memory leak in device free
    
    Remember to also free the motion history, if we're using the DIX-managed
    history.

diff --git a/dix/devices.c b/dix/devices.c
index 9631c86..004cb13 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -431,8 +431,13 @@ CloseDevice(DeviceIntPtr dev)
 	xfree(dev->key);
     }
 
-    if (dev->valuator)
+    if (dev->valuator) {
+        /* Counterpart to 'biggest hack ever' in init. */
+        if (dev->valuator->motion &&
+            dev->valuator->GetMotionProc == GetMotionHistory)
+            xfree(dev->valuator->motion);
         xfree(dev->valuator);
+    }
 
     if (dev->button) {
 #ifdef XKB
diff-tree e92743bc9839c36914a44f3e5bc8cd85773ac794 (from e49f836d6fa2768cd6d2a6d0227b5dbf516013dc)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Apr 8 14:02:02 2007 +0300

    getevents: Copy modifier state from extended to core devices
    
    Make core events carry the same modifier state as the extended events, so
    that holding down Ctrl on keyboard A and pressing Q on keyboard B won't
    cause your app to quit.

diff --git a/dix/getevents.c b/dix/getevents.c
index 62f3bcb..6969f78 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -714,6 +714,7 @@ _X_EXPORT void
 SwitchCoreKeyboard(DeviceIntPtr pDev)
 {
     KeyClassPtr ckeyc = inputInfo.keyboard->key;
+    int i = 0;
 
     if (inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr != pDev) {
         memcpy(ckeyc->modifierMap, pDev->key->modifierMap, MAP_LENGTH);
@@ -728,6 +729,25 @@ SwitchCoreKeyboard(DeviceIntPtr pDev)
         ckeyc->curKeySyms.maxKeyCode = pDev->key->curKeySyms.maxKeyCode;
         SetKeySymsMap(&ckeyc->curKeySyms, &pDev->key->curKeySyms);
 
+        /*
+         * Copy state from the extended keyboard to core.  If you omit this,
+         * holding Ctrl on keyboard one, and pressing Q on keyboard two, will
+         * cause your app to quit.  This feels wrong to me, hence the below
+         * code.
+         *
+         * XXX: If you synthesise core modifier events, the state will get
+         *      clobbered here.  You'll have to work out something sensible
+         *      to fix that.  Good luck.
+         */
+
+#define KEYBOARD_MASK (ShiftMask | LockMask | ControlMask | Mod1Mask | \
+                       Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask)
+        ckeyc->state &= ~(KEYBOARD_MASK);
+        ckeyc->state |= (pDev->key->state & KEYBOARD_MASK);
+#undef KEYBOARD_MASK
+        for (i = 0; i < 8; i++)
+            ckeyc->modifierKeyCount[i] = pDev->key->modifierKeyCount[i];
+
 #ifdef XKB
         if (!noXkbExtension && pDev->key->xkbInfo && pDev->key->xkbInfo->desc) {
             if (!XkbCopyKeymap(pDev->key->xkbInfo->desc, ckeyc->xkbInfo->desc,
diff-tree e49f836d6fa2768cd6d2a6d0227b5dbf516013dc (from 4aae2de74b9224bac2b2e2522637dac09abc3837)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Apr 8 13:56:41 2007 +0300

    mieq: Use larger default queue size
    
    Use a default queue size of 512 rather than 256, else Xephyr is too slow
    without a host cursor, so events get stuck in the queue.

diff --git a/mi/mieq.c b/mi/mieq.c
index 34509cd..a03fff1 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -58,7 +58,7 @@ in this Software without prior written a
 # include <X11/extensions/dpms.h>
 #endif
 
-#define QUEUE_SIZE  256
+#define QUEUE_SIZE  512
 
 typedef struct _Event {
     xEvent          event[7];
diff-tree 4aae2de74b9224bac2b2e2522637dac09abc3837 (from f77a8ea849d171a8ca00b2b7334866ace1ffbf73)
Author: Jared D. McNeill <jmcneill at netbsd.org>
Date:   Tue Apr 10 12:57:15 2007 -0700

    Add a real xf86EnableIO/xf86DisableIO for NetBSD/PPC.

diff --git a/hw/xfree86/os-support/bsd/Makefile.am b/hw/xfree86/os-support/bsd/Makefile.am
index 0992404..0432ba9 100644
--- a/hw/xfree86/os-support/bsd/Makefile.am
+++ b/hw/xfree86/os-support/bsd/Makefile.am
@@ -38,8 +38,7 @@ ARCH_SOURCES = i386_video.c
 endif
 
 if PPC_VIDEO
-ARCH_SOURCES = ppc_video.c \
-	$(srcdir)/../shared/ioperm_noop.c
+ARCH_SOURCES = ppc_video.c
 endif
 
 if SPARC64_VIDEO
diff --git a/hw/xfree86/os-support/bsd/ppc_video.c b/hw/xfree86/os-support/bsd/ppc_video.c
index ae65c8f..6a23b4e 100644
--- a/hw/xfree86/os-support/bsd/ppc_video.c
+++ b/hw/xfree86/os-support/bsd/ppc_video.c
@@ -56,6 +56,9 @@
 static pointer ppcMapVidMem(int, unsigned long, unsigned long, int flags);
 static void ppcUnmapVidMem(int, pointer, unsigned long);
 
+Bool xf86EnableIO(void);
+void xf86DisableIO(void);
+
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
@@ -63,6 +66,7 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 	pVidMem->mapMem = ppcMapVidMem;
 	pVidMem->unmapMem = ppcUnmapVidMem;
 	pVidMem->initialised = TRUE;
+	xf86EnableIO();
 }
 
 
@@ -138,3 +142,32 @@ xf86EnableInterrupts()
 
 	return;
 }
+
+Bool xf86EnableIO()
+{
+        int fd = xf86Info.screenFd;
+
+        xf86MsgVerb(X_WARNING, 3, "xf86EnableIO %d\n", fd);
+        if (ioBase == MAP_FAILED)
+        {
+                ioBase=mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, fd,
+                    0xf2000000);
+                xf86MsgVerb(X_INFO, 3, "xf86EnableIO: %08x\n", ioBase);
+                if (ioBase == MAP_FAILED) {
+                        xf86MsgVerb(X_WARNING, 3, "Can't map IO space!\n");
+			return FALSE;
+		}
+        }
+	return TRUE;
+}
+
+void xf86DisableIO()
+{
+
+        if (ioBase != MAP_FAILED)
+        {
+                munmap(__UNVOLATILE(ioBase), 0x10000);
+                ioBase = MAP_FAILED;
+        }
+}
+
diff-tree f77a8ea849d171a8ca00b2b7334866ace1ffbf73 (from bcf17df69a232e5e84609abacdca36274316e170)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Mon Apr 9 14:29:46 2007 -0700

    Rotate screen size as needed from RandR 1.1 change requests.
    
    Screen size must reflect rotated mode size when setting rotated mode using
    RandR 1.1 SetScreenConfig request.
    (cherry picked from commit efcec7dbd3c2736c7b421d29c4d37e231aa681d2)

diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index f83fce3..d92a0ff 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -741,6 +741,7 @@ ProcRRSetScreenConfig (ClientPtr client)
     RRModePtr		    mode;
     RR10DataPtr		    pData = NULL;
     RRScreenSizePtr    	    pSize;
+    int			    width, height;
     
     UpdateCurrentTime ();
 
@@ -883,8 +884,14 @@ ProcRRSetScreenConfig (ClientPtr client)
      * If the screen size is changing, adjust all of the other outputs
      * to fit the new size, mirroring as much as possible
      */
-    if (mode->mode.width != pScreen->width || 
-	mode->mode.height != pScreen->height)
+    width = mode->mode.width;
+    height = mode->mode.height;
+    if (rotation & (RR_Rotate_90|RR_Rotate_270))
+    {
+	width = mode->mode.height;
+	height = mode->mode.width;
+    }
+    if (width != pScreen->width || height != pScreen->height)
     {
 	int	c;
 
@@ -898,7 +905,7 @@ ProcRRSetScreenConfig (ClientPtr client)
 		goto sendReply;
 	    }
 	}
-	if (!RRScreenSizeSet (pScreen, mode->mode.width, mode->mode.height,
+	if (!RRScreenSizeSet (pScreen, width, height,
 			      pScreen->mmWidth, pScreen->mmHeight))
 	{
 	    rep.status = RRSetConfigFailed;
diff-tree bcf17df69a232e5e84609abacdca36274316e170 (from 67e1c98895a566f927e1ae2384d56cfca104f971)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Mon Apr 9 14:12:27 2007 -0700

    Disable CRTC when SetSingleMode has no matching mode. Update RandR as well.
    
    xf86SetSingleMode tries to resize all crtcs to match the selected mode. When
    a CRTC has no matching mode, it now disables the CRTC (instead of crashing).
    
    Also, poke the RandR extension when xf86SetSingleMode is done so that
    appropriate events can be delivered, and so that future RandR queries return
    correct information.
    (cherry picked from commit dc6c4f6989f87149d8605604f4514f5cbf11de67)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 0fe03d3..7e7c7e7 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -233,8 +233,6 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, Displ
     int			saved_x, saved_y;
     Rotation		saved_rotation;
 
-    adjusted_mode = xf86DuplicateMode(mode);
-
     crtc->enabled = xf86CrtcInUse (crtc);
     
     if (!crtc->enabled)
@@ -243,6 +241,8 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, Displ
 	return TRUE;
     }
 
+    adjusted_mode = xf86DuplicateMode(mode);
+
     didLock = crtc->funcs->lock (crtc);
 
     saved_mode = crtc->mode;
@@ -1833,6 +1833,11 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, Di
 	    else
 		crtc_mode = xf86OutputFindClosestMode (output, desired);
 	}
+	if (!crtc_mode)
+	{
+	    crtc->enabled = FALSE;
+	    continue;
+	}
 	if (!xf86CrtcSetMode (crtc, crtc_mode, rotation, 0, 0))
 	    ok = FALSE;
 	else
@@ -1844,6 +1849,7 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, Di
 	}
     }
     xf86DisableUnusedFunctions(pScrn);
+    xf86RandR12TellChanged (pScrn->pScreen);
     return ok;
 }
 
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 6f52ee2..90de585 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -1048,6 +1048,28 @@ xf86RandR12CreateScreenResources12 (Scre
     return TRUE;
 }
 
+/*
+ * Something happened within the screen configuration due
+ * to DGA, VidMode or hot key. Tell RandR
+ */
+
+void
+xf86RandR12TellChanged (ScreenPtr pScreen)
+{
+    ScrnInfoPtr		pScrn = xf86Screens[pScreen->myNum];
+    xf86CrtcConfigPtr   config = XF86_CRTC_CONFIG_PTR(pScrn);
+    XF86RandRInfoPtr	randrp = XF86RANDRINFO(pScreen);
+    int			c;
+
+    if (!randrp)
+	return;
+    xf86RandR12SetInfo12 (pScreen);
+    for (c = 0; c < config->num_crtc; c++)
+	xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc);
+
+    RRTellChanged (pScreen);
+}
+
 static void
 xf86RandR12PointerMoved (int scrnIndex, int x, int y)
 {
diff --git a/hw/xfree86/modes/xf86RandR12.h b/hw/xfree86/modes/xf86RandR12.h
index 8a4668b..0d3346a 100644
--- a/hw/xfree86/modes/xf86RandR12.h
+++ b/hw/xfree86/modes/xf86RandR12.h
@@ -33,5 +33,6 @@ Bool xf86RandR12SetConfig(ScreenPtr pScr
 Rotation xf86RandR12GetRotation(ScreenPtr pScreen);
 void xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y);
 Bool xf86RandR12PreInit (ScrnInfoPtr pScrn);
+void xf86RandR12TellChanged (ScreenPtr pScreen);
 
 #endif /* _XF86_RANDR_H_ */
diff-tree 67e1c98895a566f927e1ae2384d56cfca104f971 (from a08d5157f70567a0aa9583d4a15e62437340cf34)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Mon Apr 9 19:08:52 2007 -0400

    Look for the PCI ROM file elsewhere in sysfs.
    
    /sys/devices reflects the bus topology, and we don't care that much.
    Easier (and more reliable) to just look in /sys/bus/pci/devices, which
    is a flat view.

diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
index 55ed878..2aaa89c 100644
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ b/hw/xfree86/os-support/bus/linuxPci.c
@@ -773,8 +773,8 @@ xf86ReadDomainMemory(PCITAG Tag, ADDRESS
     bus  = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(Tag));
     dev  = PCI_DEV_FROM_TAG(Tag);
     func = PCI_FUNC_FROM_TAG(Tag);
-    sprintf(file, "/sys/devices/pci%04x:%02x/%04x:%02x:%02x.%1x/rom",
-	    dom, bus, dom, bus, dev, func);
+    sprintf(file, "/sys/bus/pci/devices/%04x:%02x:%02x.%1x/rom",
+	    dom, bus, dev, func);
 
     /*
      * If the caller wants the ROM and the sysfs rom interface exists,
diff-tree a08d5157f70567a0aa9583d4a15e62437340cf34 (from 72b477f964c748a1ab668781643cc11877f19738)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Mon Apr 9 19:04:56 2007 -0400

    VT activate or waitactive are fatal if they fail.
    
    Also, be sure to waitactive on the way down, to make sure we're off the VT
    before exiting.

diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index 85b6def..9775180 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -245,15 +245,15 @@ xf86OpenConsole(void)
 	    lnx_savefont();
 #endif
 	    /*
-	     * now get the VT
+	     * now get the VT.  This _must_ succeed, or else fail completely.
 	     */
 	    if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0)
-	        xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed: %s\n",
-		        strerror(errno));
+	        FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n",
+		           strerror(errno));
 
 	    if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0)
-	        xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed: %s\n",
-		    strerror(errno));
+	        FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n",
+			   strerror(errno));
 
 	    if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
 	        FatalError("xf86OpenConsole: VT_GETMODE failed %s\n",
@@ -350,6 +350,10 @@ xf86CloseConsole()
 	    if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT) < 0)
 	        xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n",
 		        strerror(errno));
+	    if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, activeVT) < 0)
+		xf86Msg(X_WARNING,
+			"xf86CloseConsole: VT_WAITACTIVE failed: %s\n",
+			strerror(errno));
 	    activeVT = -1;
         }
 
diff-tree 72b477f964c748a1ab668781643cc11877f19738 (from 1f6741db19d4c91b1eacb497dff1814acb1bf0c3)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Mon Apr 9 18:59:01 2007 -0400

    Don't write out empty sections from the parser.

diff --git a/hw/xfree86/parser/write.c b/hw/xfree86/parser/write.c
index 1869f56..3924001 100644
--- a/hw/xfree86/parser/write.c
+++ b/hw/xfree86/parser/write.c
@@ -107,13 +107,19 @@ doWriteConfigFile (const char *filename,
 
 	xf86printLayoutSection (cf, cptr->conf_layout_lst);
 
-	fprintf (cf, "Section \"Files\"\n");
-	xf86printFileSection (cf, cptr->conf_files);
-	fprintf (cf, "EndSection\n\n");
-
-	fprintf (cf, "Section \"Module\"\n");
-	xf86printModuleSection (cf, cptr->conf_modules);
-	fprintf (cf, "EndSection\n\n");
+	if (cptr->conf_files != NULL)
+	{
+		fprintf (cf, "Section \"Files\"\n");
+		xf86printFileSection (cf, cptr->conf_files);
+		fprintf (cf, "EndSection\n\n");
+	}
+
+	if (cptr->conf_modules != NULL)
+	{
+		fprintf (cf, "Section \"Module\"\n");
+		xf86printModuleSection (cf, cptr->conf_modules);
+		fprintf (cf, "EndSection\n\n");
+	}
 
 	xf86printVendorSection (cf, cptr->conf_vendor_lst);
 
diff-tree 1f6741db19d4c91b1eacb497dff1814acb1bf0c3 (from f24391dbfd12a84253dfec794ee7884afd52e197)
Author: Stefan Huehner <stefan at huehner.org>
Date:   Mon Apr 9 14:33:15 2007 -0700

    Bug #10560: Code-Cleanup: function declarations () -> (void)
    
    X.Org Bugzilla #10560: <https://bugs.freedesktop.org/show_bug.cgi?id=10560>
    Patch #9511 <https://bugs.freedesktop.org/attachment.cgi?id=9511>

diff --git a/Xext/sync.c b/Xext/sync.c
index 531b48c..c5441a1 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -2509,7 +2509,7 @@ ServertimeBracketValues(pCounter, pbrack
 }
 
 static void
-SyncInitServerTime()
+SyncInitServerTime(void)
 {
     CARD64 resolution;
 
diff --git a/Xext/xvmain.c b/Xext/xvmain.c
index 2233901..ddf3d1d 100644
--- a/Xext/xvmain.c
+++ b/Xext/xvmain.c
@@ -153,7 +153,7 @@ static int XvdiSendVideoNotify(XvPortPtr
 */
 
 void 
-XvExtensionInit()
+XvExtensionInit(void)
 {
   ExtensionEntry *extEntry;
 
@@ -205,7 +205,7 @@ XvExtensionInit()
 }
 
 static Bool
-CreateResourceTypes()
+CreateResourceTypes(void)
 
 {
   
@@ -335,13 +335,13 @@ XvResetProc(ExtensionEntry* extEntry)
 }
 
 _X_EXPORT int
-XvGetScreenIndex()
+XvGetScreenIndex(void)
 {
   return XvScreenIndex;
 }
 
 _X_EXPORT unsigned long
-XvGetRTPort()
+XvGetRTPort(void)
 {
   return XvRTPort;
 }
diff --git a/Xext/xvmc.c b/Xext/xvmc.c
index 737fc5d..ae35893 100644
--- a/Xext/xvmc.c
+++ b/Xext/xvmc.c
@@ -675,7 +675,7 @@ SProcXvMCDispatch (ClientPtr client)
 }
 
 void 
-XvMCExtensionInit()
+XvMCExtensionInit(void)
 {
    ExtensionEntry *extEntry;
 
diff --git a/config/config.c b/config/config.c
index 6c40143..d72b588 100644
--- a/config/config.c
+++ b/config/config.c
@@ -410,13 +410,13 @@ configReconnect(OsTimerPtr timer, CARD32
 }
 
 void
-configInitialise()
+configInitialise(void)
 {
     TimerSet(NULL, 0, 1, configReconnect, NULL);
 }
 
 void
-configFini()
+configFini(void)
 {
     DBusError error;
 
diff --git a/dix/atom.c b/dix/atom.c
index bd3223c..6ae3e31 100644
--- a/dix/atom.c
+++ b/dix/atom.c
@@ -167,7 +167,7 @@ NameForAtom(Atom atom)
 }
 
 void
-AtomError()
+AtomError(void)
 {
     FatalError("initializing atoms");
 }
@@ -185,7 +185,7 @@ FreeAtom(NodePtr patom)
 }
 
 void
-FreeAllAtoms()
+FreeAllAtoms(void)
 {
     if(atomRoot == (NodePtr)NULL)
 	return;
@@ -197,7 +197,7 @@ FreeAllAtoms()
 }
 
 void
-InitAtoms()
+InitAtoms(void)
 {
     FreeAllAtoms();
     tableLength = InitialTableSize;
diff --git a/dix/devices.c b/dix/devices.c
index f622be7..9631c86 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -314,7 +314,7 @@ CorePointerProc(DeviceIntPtr pDev, int w
 }
 
 void
-InitCoreDevices()
+InitCoreDevices(void)
 {
     DeviceIntPtr dev;
 
@@ -373,7 +373,7 @@ InitCoreDevices()
 }
 
 int
-InitAndStartDevices()
+InitAndStartDevices(void)
 {
     DeviceIntPtr dev, next;
 
@@ -503,7 +503,7 @@ CloseDevice(DeviceIntPtr dev)
 }
 
 void
-CloseDownDevices()
+CloseDownDevices(void)
 {
     DeviceIntPtr dev, next;
 
@@ -580,7 +580,7 @@ RemoveDevice(DeviceIntPtr dev)
 }
 
 int
-NumMotionEvents()
+NumMotionEvents(void)
 {
     return inputInfo.pointer->valuator->numMotionEvents;
 }
@@ -598,13 +598,13 @@ RegisterKeyboardDevice(DeviceIntPtr devi
 }
 
 _X_EXPORT DevicePtr
-LookupKeyboardDevice()
+LookupKeyboardDevice(void)
 {
     return inputInfo.keyboard ? &inputInfo.keyboard->public : NULL;
 }
 
 _X_EXPORT DevicePtr
-LookupPointerDevice()
+LookupPointerDevice(void)
 {
     return inputInfo.pointer ? &inputInfo.pointer->public : NULL;
 }
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 490b29c..6aba9db 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -218,7 +218,7 @@ SetInputCheck(HWEventQueuePtr c0, HWEven
 }
 
 _X_EXPORT void
-UpdateCurrentTime()
+UpdateCurrentTime(void)
 {
     TimeStamp systime;
 
@@ -237,7 +237,7 @@ UpdateCurrentTime()
 
 /* Like UpdateCurrentTime, but can't call ProcessInputEvents */
 _X_EXPORT void
-UpdateCurrentTimeIf()
+UpdateCurrentTimeIf(void)
 {
     TimeStamp systime;
 
@@ -250,7 +250,7 @@ UpdateCurrentTimeIf()
 }
 
 void
-InitSelections()
+InitSelections(void)
 {
     if (CurrentSelections)
 	xfree(CurrentSelections);
@@ -3654,7 +3654,7 @@ CloseDownClient(ClientPtr client)
 }
 
 static void
-KillAllClients()
+KillAllClients(void)
 {
     int i;
     for (i=1; i<currentMaxClients; i++)
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index 62ad575..c21b3ec 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -1878,7 +1878,7 @@ DeleteClientFontStuff(ClientPtr client)
 }
 
 void
-InitFonts ()
+InitFonts (void)
 {
     patternCache = MakeFontPatternCache();
 
@@ -1997,7 +1997,7 @@ RegisterFPEFunctions(NameCheckFunc name_
 }
 
 void
-FreeFonts()
+FreeFonts(void)
 {
     if (patternCache) {
 	FreeFontPatternCache(patternCache);
diff --git a/dix/dixutils.c b/dix/dixutils.c
index 44d82c9..30327d3 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -550,7 +550,7 @@ RemoveBlockAndWakeupHandlers (BlockHandl
 }
 
 void
-InitBlockAndWakeupHandlers ()
+InitBlockAndWakeupHandlers (void)
 {
     xfree (handlers);
     handlers = (BlockHandlerPtr) 0;
@@ -950,7 +950,7 @@ DeleteCallbackList(CallbackListPtr *pcbl
 }
 
 void 
-InitCallbackManager()
+InitCallbackManager(void)
 {
     int i;
 
diff --git a/dix/events.c b/dix/events.c
index e008e36..093a316 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -844,7 +844,7 @@ ConfineCursorToWindow(WindowPtr pWin, Bo
 }
 
 _X_EXPORT Bool
-PointerConfinedToScreen()
+PointerConfinedToScreen(void)
 {
     return sprite.confined;
 }
@@ -913,19 +913,19 @@ PostNewCursor(void)
 }
 
 _X_EXPORT WindowPtr
-GetCurrentRootWindow()
+GetCurrentRootWindow(void)
 {
     return ROOT;
 }
 
 _X_EXPORT WindowPtr
-GetSpriteWindow()
+GetSpriteWindow(void)
 {
     return sprite.win;
 }
 
 _X_EXPORT CursorPtr
-GetSpriteCursor()
+GetSpriteCursor(void)
 {
     return sprite.current;
 }
@@ -939,7 +939,7 @@ GetSpritePosition(int *px, int *py)
 
 #ifdef PANORAMIX
 _X_EXPORT int
-XineramaGetCursorScreen()
+XineramaGetCursorScreen(void)
 {
     if(!noPanoramiXExtension) {
 	return sprite.screen->myNum;
@@ -1114,7 +1114,7 @@ FreezeThaw(DeviceIntPtr dev, Bool frozen
 }
 
 void
-ComputeFreezes()
+ComputeFreezes(void)
 {
     DeviceIntPtr replayDev = syncEvents.replayDev;
     int i;
@@ -2047,7 +2047,7 @@ CheckMotion(xEvent *xE)
 }
 
 _X_EXPORT void
-WindowsRestructured()
+WindowsRestructured(void)
 {
     (void) CheckMotion((xEvent *)NULL);
 }
@@ -3970,7 +3970,7 @@ ProcQueryPointer(ClientPtr client)
 }
 
 void
-InitEvents()
+InitEvents(void)
 {
     int i;
 
diff --git a/dix/extension.c b/dix/extension.c
index 88dff15..186574d 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -278,7 +278,7 @@ MinorOpcodeOfRequest(ClientPtr client)
 }
 
 void
-CloseDownExtensions()
+CloseDownExtensions(void)
 {
     int i,j;
 
diff --git a/dix/getevents.c b/dix/getevents.c
index 3f636bc..62f3bcb 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -73,7 +73,7 @@ extern Bool XkbCopyKeymap(XkbDescPtr src
  * Pick some arbitrary size for Xi motion history.
  */
 _X_EXPORT int
-GetMotionHistorySize()
+GetMotionHistorySize(void)
 {
     return MOTION_HISTORY_SIZE;
 }
@@ -183,7 +183,7 @@ updateMotionHistory(DeviceIntPtr pDev, C
  * xEvent *events = xcalloc(sizeof(xEvent), GetMaximumEventsNum());
  */
 _X_EXPORT int
-GetMaximumEventsNum() {
+GetMaximumEventsNum(void) {
     /* Two base events -- core and device, plus valuator events.  Multiply
      * by two if we're doing key repeats. */
     int ret = 2 + MAX_VALUATOR_EVENTS;
diff --git a/dix/initatoms.c b/dix/initatoms.c
index a5972af..de101bd 100644
--- a/dix/initatoms.c
+++ b/dix/initatoms.c
@@ -11,7 +11,7 @@
 #include <X11/Xatom.h>
 #include "misc.h"
 #include "dix.h"
-void MakePredeclaredAtoms()
+void MakePredeclaredAtoms(void)
 {
     if (MakeAtom("PRIMARY", 7, 1) != XA_PRIMARY) AtomError();
     if (MakeAtom("SECONDARY", 9, 1) != XA_SECONDARY) AtomError();
diff --git a/dix/main.c b/dix/main.c
index 92c30b6..9a67ed9 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -544,7 +544,7 @@ static int padlength[4] = {0, 3, 2, 1};
 static
 #endif
 Bool
-CreateConnectionBlock()
+CreateConnectionBlock(void)
 {
     xConnSetup setup;
     xWindowRoot root;
diff --git a/dix/privates.c b/dix/privates.c
index a66fc3d..2465971 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -60,7 +60,7 @@ unsigned *extensionPrivateSizes;
 unsigned totalExtensionSize;
 
 void
-ResetExtensionPrivates()
+ResetExtensionPrivates(void)
 {
     extensionPrivateCount = 0;
     extensionPrivateLen = 0;
@@ -71,7 +71,7 @@ ResetExtensionPrivates()
 }
 
 _X_EXPORT int
-AllocateExtensionPrivateIndex()
+AllocateExtensionPrivateIndex(void)
 {
     return extensionPrivateCount++;
 }
@@ -117,7 +117,7 @@ unsigned *clientPrivateSizes;
 unsigned totalClientSize;
 
 void
-ResetClientPrivates()
+ResetClientPrivates(void)
 {
     clientPrivateCount = 0;
     clientPrivateLen = 0;
@@ -128,7 +128,7 @@ ResetClientPrivates()
 }
 
 _X_EXPORT int
-AllocateClientPrivateIndex()
+AllocateClientPrivateIndex(void)
 {
     return clientPrivateCount++;
 }
@@ -171,7 +171,7 @@ AllocateClientPrivate(int index2, unsign
 int  screenPrivateCount;
 
 void
-ResetScreenPrivates()
+ResetScreenPrivates(void)
 {
     screenPrivateCount = 0;
 }
@@ -180,7 +180,7 @@ ResetScreenPrivates()
  * so we have to worry about resizing existing devPrivates
  */
 _X_EXPORT int
-AllocateScreenPrivateIndex()
+AllocateScreenPrivateIndex(void)
 {
     int		idx;
     int		i;
@@ -213,13 +213,13 @@ AllocateScreenPrivateIndex()
 static int  windowPrivateCount;
 
 void
-ResetWindowPrivates()
+ResetWindowPrivates(void)
 {
     windowPrivateCount = 0;
 }
 
 _X_EXPORT int
-AllocateWindowPrivateIndex()
+AllocateWindowPrivateIndex(void)
 {
     return windowPrivateCount++;
 }
@@ -263,13 +263,13 @@ AllocateWindowPrivate(ScreenPtr pScreen,
 static int  gcPrivateCount;
 
 void
-ResetGCPrivates()
+ResetGCPrivates(void)
 {
     gcPrivateCount = 0;
 }
 
 _X_EXPORT int
-AllocateGCPrivateIndex()
+AllocateGCPrivateIndex(void)
 {
     return gcPrivateCount++;
 }
@@ -312,13 +312,13 @@ AllocateGCPrivate(ScreenPtr pScreen, int
 static int  pixmapPrivateCount;
 
 void
-ResetPixmapPrivates()
+ResetPixmapPrivates(void)
 {
     pixmapPrivateCount = 0;
 }
 
 _X_EXPORT int
-AllocatePixmapPrivateIndex()
+AllocatePixmapPrivateIndex(void)
 {
     return pixmapPrivateCount++;
 }
@@ -363,7 +363,7 @@ AllocatePixmapPrivate(ScreenPtr pScreen,
 int  colormapPrivateCount;
 
 void
-ResetColormapPrivates()
+ResetColormapPrivates(void)
 {
     colormapPrivateCount = 0;
 }
@@ -424,7 +424,7 @@ AllocateColormapPrivateIndex (InitCmapPr
 static int devicePrivateIndex = 0;
 
 _X_EXPORT int
-AllocateDevicePrivateIndex()
+AllocateDevicePrivateIndex(void)
 {
     return devicePrivateIndex++;
 }
diff --git a/dix/resource.c b/dix/resource.c
index a5a7eed..f4bf1fc 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -235,7 +235,7 @@ CreateNewResourceType(DeleteType deleteF
 }
 
 _X_EXPORT RESTYPE
-CreateNewResourceClass()
+CreateNewResourceClass(void)
 {
     RESTYPE next = lastResourceClass >> 1;
 
@@ -844,7 +844,7 @@ FreeClientResources(ClientPtr client)
 }
 
 void
-FreeAllResources()
+FreeAllResources(void)
 {
     int	i;
 
diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c
index 1ec0609..0129041 100644
--- a/hw/xnest/Display.c
+++ b/hw/xnest/Display.c
@@ -176,7 +176,7 @@ xnestOpenDisplay(int argc, char *argv[])
 }
 
 void
-xnestCloseDisplay()
+xnestCloseDisplay(void)
 {
   if (!xnestDoFullGeneration || !xnestDisplay) return;
 
diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c
index a209241..38fefa7 100644
--- a/hw/xnest/Events.c
+++ b/hw/xnest/Events.c
@@ -52,7 +52,7 @@ ProcessInputEvents()
 }
 
 int
-TimeSinceLastInputEvent()
+TimeSinceLastInputEvent(void)
 {
     if (lastEventTime == 0)
         lastEventTime = GetTimeInMillis();
@@ -60,7 +60,7 @@ TimeSinceLastInputEvent()
 }
 
 void
-SetTimeSinceLastInputEvent()
+SetTimeSinceLastInputEvent(void)
 {
   lastEventTime = GetTimeInMillis();
 }
@@ -78,7 +78,7 @@ xnestNotExposurePredicate(Display *displ
 }
 
 void
-xnestCollectExposures()
+xnestCollectExposures(void)
 {
   XEvent X;
   WindowPtr pWin;
@@ -113,7 +113,7 @@ xnestQueueKeyEvent(int type, unsigned in
 }
 
 void
-xnestCollectEvents()
+xnestCollectEvents(void)
 {
   XEvent X;
   xEvent x;
diff --git a/mi/micmap.c b/mi/micmap.c
index 977c587..33d9481 100644
--- a/mi/micmap.c
+++ b/mi/micmap.c
@@ -385,7 +385,7 @@ static int  miVisualPriority[] = {
 static miVisualsPtr	miVisuals;
 
 _X_EXPORT void
-miClearVisualTypes()
+miClearVisualTypes(void)
 {
     miVisualsPtr v;
 
@@ -690,7 +690,7 @@ miDoInitVisuals(VisualPtr *visualp, Dept
 }
 
 void
-miResetInitVisuals()
+miResetInitVisuals(void)
 {
     miInitVisualsProc = miDoInitVisuals;
 }
diff --git a/mi/mieq.c b/mi/mieq.c
index 5bd87eb..34509cd 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -80,7 +80,7 @@ typedef struct _EventQueue {
 static EventQueueRec miEventQueue;
 
 Bool
-mieqInit()
+mieqInit(void)
 {
     int i;
 
@@ -195,7 +195,7 @@ mieqSetHandler(int event, mieqHandler ha
 
 /* Call this from ProcessInputEvents(). */
 void
-mieqProcessInputEvents()
+mieqProcessInputEvents(void)
 {
     EventRec *e = NULL;
     int x = 0, y = 0;
diff --git a/os/log.c b/os/log.c
index b1d628c..e8aa3fa 100644
--- a/os/log.c
+++ b/os/log.c
@@ -221,7 +221,7 @@ LogInit(const char *fname, const char *b
 }
 
 void
-LogClose()
+LogClose(void)
 {
     if (logFile) {
 	fclose(logFile);
@@ -616,7 +616,7 @@ Error(char *str)
 }
 
 void
-LogPrintMarkers()
+LogPrintMarkers(void)
 {
     /* Show what the message marker symbols mean. */
     ErrorF("Markers: ");
diff --git a/os/oscolor.c b/os/oscolor.c
index a13a3a6..d53e4d8 100644
--- a/os/oscolor.c
+++ b/os/oscolor.c
@@ -102,7 +102,7 @@ typedef struct _builtinColor {
 #define NUM_BUILTIN_COLORS  (sizeof (BuiltinColors) / sizeof (BuiltinColors[0]))
 
 Bool
-OsInitColors()
+OsInitColors(void)
 {
     return TRUE;
 }
diff --git a/render/glyph.c b/render/glyph.c
index 5987cbc..583a52b 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -86,13 +86,13 @@ static int	globalTotalGlyphPrivateSize =
 static int	glyphPrivateCount = 0;
 
 void
-ResetGlyphPrivates ()
+ResetGlyphPrivates (void)
 {
     glyphPrivateCount = 0;
 }
 
 int
-AllocateGlyphPrivateIndex ()
+AllocateGlyphPrivateIndex (void)
 {
     return glyphPrivateCount++;
 }
diff-tree f24391dbfd12a84253dfec794ee7884afd52e197 (from 4c2e28b0916b5f75cfefb6df9fa0a7a09675539a)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Mon Apr 9 12:30:31 2007 -0700

    In AIGLX EnterVT processing, invoke driver EnterVT before resuming glx.
    
    As the driver EnterVT function generally re-enables the hardware and
    prepares it for rendering, it must be called before any gl functions are
    called which could touch the hardware.

diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c
index 5e683a8..c30f372 100644
--- a/GL/glx/glxdri.c
+++ b/GL/glx/glxdri.c
@@ -829,12 +829,16 @@ static Bool
 glxDRIEnterVT (int index, int flags)
 {
     __GLXDRIscreen *screen = (__GLXDRIscreen *) __glXgetActiveScreen(index);
+    Bool ret;
 
     LogMessage(X_INFO, "AIGLX: Resuming AIGLX clients after VT switch\n");
 
+    if (!(*screen->enterVT) (index, flags))
+	return FALSE;
+    
     glxResumeClients();
 
-    return (*screen->enterVT) (index, flags);
+    return TRUE;
 }
 
 static void
diff-tree 4c2e28b0916b5f75cfefb6df9fa0a7a09675539a (from 4beeab8424774ea4c3142f29b90e33f1fc7cb154)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Mon Apr 9 12:28:53 2007 -0700

    Add setrlimit call in -core option to make dumps occur.
    
    Default core size limit for most environments is 0, which disables core
    dumps. Add code in the -core option processing path to set the core limit to
    the maximum value.

diff --git a/os/utils.c b/os/utils.c
index e605a6c..5058285 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -64,6 +64,8 @@ OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/Xos.h>
 #include <stdio.h>
 #include <time.h>
+#include <sys/time.h>
+#include <sys/resource.h>
 #include "misc.h"
 #include <X11/X.h>
 #define XSERV_t
@@ -795,7 +797,13 @@ ProcessCommandLine(int argc, char *argv[
 		UseMsg();
 	}
 	else if ( strcmp( argv[i], "-core") == 0)
+	{
+	    struct rlimit   core_limit;
 	    CoreDump = TRUE;
+	    getrlimit (RLIMIT_CORE, &core_limit);
+	    core_limit.rlim_cur = core_limit.rlim_max;
+	    setrlimit (RLIMIT_CORE, &core_limit);
+	}
 	else if ( strcmp( argv[i], "-dpi") == 0)
 	{
 	    if(++i < argc)
diff-tree 4beeab8424774ea4c3142f29b90e33f1fc7cb154 (from 0a6ac992363343487dfe0a0fc985ea55bd448382)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Apr 8 13:39:06 2007 +0300

    XFree86: Treat evdev and vmmouse as mouse drivers (bug #10512, #10559)
    
    When we see an evdev or vmmouse section, assume that it's a mouse, and
    don't add a default mouse device.  This will break users who have an
    evdev keyboard section but no mouse, and want the mouse to get added
    by default.

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 4db844e..cbeda0b 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1287,9 +1287,13 @@ checkCoreInputDevices(serverLayoutPtr se
      * always synthesize a 'mouse' section configured to send core
      * events, unless a 'void' section is found, in which case the user
      * probably wants to run footless.
+     *
+     * If you're using an evdev keyboard and expect a default mouse
+     * section ... deal.
      */
     for (i = servlayoutp->inputs; i->identifier && i->driver; i++) {
-	if (!strcmp(i->driver, "void") || !strcmp(i->driver, "mouse")) {
+	if (!strcmp(i->driver, "void") || !strcmp(i->driver, "mouse") ||
+            !strcmp(i->driver, "vmmouse") || !strcmp(i->driver, "evdev")) {
 	    found = 1; break;
 	}
     }
diff-tree 0a6ac992363343487dfe0a0fc985ea55bd448382 (from 7e385598613778de14c0feea0d32f17d7aa66a8e)
Author: Brian <brian at yutani.localnet.net>
Date:   Sat Apr 7 12:41:57 2007 -0600

    regenerated to fix bug 10371

diff --git a/GL/glx/indirect_size_get.c b/GL/glx/indirect_size_get.c
index 150c6a1..ccb25f8 100644
--- a/GL/glx/indirect_size_get.c
+++ b/GL/glx/indirect_size_get.c
@@ -639,7 +639,7 @@ __glGetBooleanv_size(GLenum e)
     case GL_PROGRAM_ERROR_POSITION_ARB:
     case GL_DEPTH_CLAMP_NV:
     case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
-/*      case GL_NUM_TEXTURE_COMPRESSED_FORMATS_ARB:*/
+/*      case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:*/
     case GL_MAX_VERTEX_UNITS_ARB:
     case GL_ACTIVE_VERTEX_UNITS_ARB:
     case GL_WEIGHT_SUM_UNITY_ARB:
@@ -699,6 +699,8 @@ __glGetBooleanv_size(GLenum e)
 /*      case GL_POINT_SPRITE_NV:*/
     case GL_POINT_SPRITE_R_MODE_NV:
     case GL_MAX_VERTEX_ATTRIBS_ARB:
+    case GL_MAX_TEXTURE_COORDS_ARB:
+    case GL_MAX_TEXTURE_IMAGE_UNITS_ARB:
     case GL_DEPTH_BOUNDS_TEST_EXT:
     case GL_STENCIL_TEST_TWO_SIDE_EXT:
     case GL_ACTIVE_STENCIL_FACE_EXT:
@@ -1005,8 +1007,6 @@ __glGetProgramivARB_size(GLenum e)
     case GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB:
     case GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB:
     case GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB:
-    case GL_MAX_TEXTURE_COORDS_ARB:
-    case GL_MAX_TEXTURE_IMAGE_UNITS_ARB:
     case GL_PROGRAM_FORMAT_ARB:
     case GL_PROGRAM_INSTRUCTIONS_ARB:
     case GL_MAX_PROGRAM_INSTRUCTIONS_ARB:
diff-tree 7e385598613778de14c0feea0d32f17d7aa66a8e (from 5a804f2e97ab59745482660a635b801ac2b9e769)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Fri Apr 6 13:38:12 2007 +0300

    GLcore: fix after moving xf86glx_util.[hc] to Mesa.

diff --git a/GL/mesa/.gitignore b/GL/mesa/.gitignore
index a00885d..6b92b24 100644
--- a/GL/mesa/.gitignore
+++ b/GL/mesa/.gitignore
@@ -1,6 +1,6 @@
 X/drivers
 X/glxheader.h
-X/xmesaP.h
+X/xm*.h
 X/xm*.c
 mesa/drivers
 mesa/glxheader.h
diff --git a/GL/mesa/X/Makefile.am b/GL/mesa/X/Makefile.am
index 056d31a..f8f16c3 100644
--- a/GL/mesa/X/Makefile.am
+++ b/GL/mesa/X/Makefile.am
@@ -22,14 +22,13 @@ AM_CFLAGS = \
 	-DXFree86Server \
 	@GLX_DEFINES@
 
-libX_la_SOURCES = xf86glx.c \
-                  xf86glx_util.c \
-                  xf86glx_util.h
+libX_la_SOURCES = xf86glx.c
 
 nodist_libX_la_SOURCES = \
                   xm_api.c \
 		  xm_buffer.c \
                   xm_dd.c \
+                  xm_image.c \
                   xm_line.c \
                   xm_span.c \
                   xm_tri.c \
diff --git a/GL/mesa/X/xf86glx_util.c b/GL/mesa/X/xf86glx_util.c
deleted file mode 100644
index 6af773f..0000000
--- a/GL/mesa/X/xf86glx_util.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin at precisioninsight.com>
- *   Brian Paul <brian at precisioninsight.com>
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdlib.h>
-
-#include "xf86glx_util.h"
-#include <X11/Xmd.h>
-
-#ifdef ROUNDUP
-#undef ROUNDUP
-#endif
-
-#define ROUNDUP(nbytes, pad) ((((nbytes) + ((pad)-1)) / (pad)) * ((pad)>>3))
-
-XMesaImage *XMesaCreateImage(int bitsPerPixel, int width, int height, char *data)
-{
-    XMesaImage *image;
-
-    image = (XMesaImage *)xalloc(sizeof(XMesaImage));
-
-    if (image) {
-	image->width = width;
-	image->height = height;
-	image->data = data;
-	/* Always pad to 32 bits */
-	image->bytes_per_line = ROUNDUP((bitsPerPixel * width), 32);
-	image->bits_per_pixel = bitsPerPixel;
-    }
-
-    return image;
-}
-
-void XMesaDestroyImage(XMesaImage *image)
-{
-    if (image->data)
-	free(image->data);
-    xfree(image);
-}
-
-unsigned long XMesaGetPixel(XMesaImage *image, int x, int y)
-{
-    CARD8  *row = (CARD8 *)(image->data + y*image->bytes_per_line);
-    CARD8  *i8;
-    CARD16 *i16;
-    CARD32 *i32;
-    switch (image->bits_per_pixel) {
-    case 8:
-	i8 = (CARD8 *)row;
-	return i8[x];
-	break;
-    case 15:
-    case 16:
-	i16 = (CARD16 *)row;
-	return i16[x];
-	break;
-    case 24: /* WARNING: architecture specific code */
-	i8 = (CARD8 *)row;
-	return (((CARD32)i8[x*3]) |
-		(((CARD32)i8[x*3+1])<<8) |
-		(((CARD32)i8[x*3+2])<<16));
-	break;
-    case 32:
-	i32 = (CARD32 *)row;
-	return i32[x];
-	break;
-    }
-    return 0;
-}
-
-#ifndef XMESA_USE_PUTPIXEL_MACRO
-void XMesaPutPixel(XMesaImage *image, int x, int y, unsigned long pixel)
-{
-    CARD8  *row = (CARD8 *)(image->data + y*image->bytes_per_line);
-    CARD8  *i8;
-    CARD16 *i16;
-    CARD32 *i32;
-    switch (image->bits_per_pixel) {
-    case 8:
-	i8 = (CARD8 *)row;
-	i8[x] = (CARD8)pixel;
-	break;
-    case 15:
-    case 16:
-	i16 = (CARD16 *)row;
-	i16[x] = (CARD16)pixel;
-	break;
-    case 24: /* WARNING: architecture specific code */
-	i8 = (CARD8 *)__row;
-	i8[x*3]   = (CARD8)(p);
-	i8[x*3+1] = (CARD8)(p>>8);
-	i8[x*3+2] = (CARD8)(p>>16);
-    case 32:
-	i32 = (CARD32 *)row;
-	i32[x] = (CARD32)pixel;
-	break;
-    }
-}
-#endif
-
-void XMesaPutImageHelper(ScreenPtr display,
-			 DrawablePtr d, GCPtr gc,
-			 XMesaImage *image,
-			 int src_x, int src_y,
-			 int dest_x, int dest_y,
-			 unsigned int width, unsigned int height)
-{
-    /* NOT_DONE: Verify that the following works for all depths */
-    char *src = (image->data +
-		 src_y * image->bytes_per_line +
-		 ((src_x * image->bits_per_pixel) >> 3));
-
-    ValidateGC(d, gc);
-    (*gc->ops->PutImage)(d, gc, d->depth, dest_x, dest_y, width, height,
-			 0, ZPixmap, src);
-}
diff --git a/GL/mesa/X/xf86glx_util.h b/GL/mesa/X/xf86glx_util.h
deleted file mode 100644
index bb31412..0000000
--- a/GL/mesa/X/xf86glx_util.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin at precisioninsight.com>
- *   Brian Paul <brian at precisioninsight.com>
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef _XF86GLX_UTIL_H_
-#define _XF86GLX_UTIL_H_
-
-#ifdef __CYGWIN__
-#undef WIN32
-#undef _WIN32
-#endif
-
-#include <screenint.h>
-#include <pixmap.h>
-#include <gc.h>
-#include "GL/xmesa.h"
-
-#define XMESA_USE_PUTPIXEL_MACRO
-
-struct _XMesaImageRec {
-    int width, height;
-    char *data;
-    int bytes_per_line; /* Padded to 32 bits */
-    int bits_per_pixel;
-};
-
-extern XMesaImage *XMesaCreateImage(int bitsPerPixel, int width, int height,
-				    char *data);
-extern void XMesaDestroyImage(XMesaImage *image);
-extern unsigned long XMesaGetPixel(XMesaImage *image, int x, int y);
-#ifdef XMESA_USE_PUTPIXEL_MACRO
-#define XMesaPutPixel(__i,__x,__y,__p) \
-{ \
-    CARD8  *__row = (CARD8 *)(__i->data + __y*__i->bytes_per_line); \
-    CARD8  *__i8; \
-    CARD16 *__i16; \
-    CARD32 *__i32; \
-    switch (__i->bits_per_pixel) { \
-    case 8: \
-	__i8 = (CARD8 *)__row; \
-	__i8[__x] = (CARD8)__p; \
-	break; \
-    case 15: \
-    case 16: \
-	__i16 = (CARD16 *)__row; \
-	__i16[__x] = (CARD16)__p; \
-	break; \
-    case 24: /* WARNING: architecture specific code */ \
-	__i8 = (CARD8 *)__row; \
-	__i8[__x*3]   = (CARD8)(__p); \
-	__i8[__x*3+1] = (CARD8)(__p>>8); \
-	__i8[__x*3+2] = (CARD8)(__p>>16); \
-	break; \
-    case 32: \
-	__i32 = (CARD32 *)__row; \
-	__i32[__x] = (CARD32)__p; \
-	break; \
-    } \
-}
-#else
-extern void XMesaPutPixel(XMesaImage *image, int x, int y,
-			  unsigned long pixel);
-#endif
-
-extern void XMesaPutImageHelper(ScreenPtr display,
-				DrawablePtr d, GCPtr gc,
-				XMesaImage *image,
-				int src_x, int src_y,
-				int dest_x, int dest_y,
-				unsigned int width, unsigned int height);
-
-#endif /* _XF86GLX_UTIL_H_ */
diff --git a/GL/symlink-mesa.sh b/GL/symlink-mesa.sh
index 3d96716..0cfe1c9 100755
--- a/GL/symlink-mesa.sh
+++ b/GL/symlink-mesa.sh
@@ -168,6 +168,8 @@ symlink_mesa_x() {
     action xm_api.c
     action xm_buffer.c
     action xm_dd.c
+    action xm_image.c
+    action xm_image.h
     action xm_line.c
     action xm_span.c
     action xm_tri.c
diff-tree 5a804f2e97ab59745482660a635b801ac2b9e769 (from a4e2fc703484fffed8dd50c1b4b24c564be4d3cd)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Thu Apr 5 19:14:31 2007 +0300

    configure: minor cosmetic, move GLX extension options together.

diff --git a/configure.ac b/configure.ac
index fde6a89..cb8b435 100644
--- a/configure.ac
+++ b/configure.ac
@@ -453,9 +453,6 @@ AC_ARG_WITH(os-vendor,       AS_HELP_STR
 AC_ARG_WITH(builderstring,   AS_HELP_STRING([--with-builderstring=BUILDERSTRING], [Additional builder string]),
 				[ BUILDERSTRING="$withval" ]
 				[ ])
-AC_ARG_WITH(mesa-source,     AS_HELP_STRING([--with-mesa-source=MESA_SOURCE], [Path to Mesa source tree]),
-                                [ MESA_SOURCE="$withval" ],
-                                [ MESA_SOURCE="" ])
 AC_ARG_WITH(fontdir,         AS_HELP_STRING([--with-fontdir=FONTDIR], [Path to top level dir where fonts are installed (default: ${libdir}/X11/fonts)]),
                                 [ FONTDIR="$withval" ],
                                 [ FONTDIR="${libdir}/X11/fonts" ])
@@ -472,9 +469,6 @@ AC_ARG_WITH(xkb-output,       AS_HELP_ST
 AC_ARG_WITH(rgb-path,         AS_HELP_STRING([--with-rgb-path=PATH], [Path to RGB database (default: ${datadir}/X11/rgb)]),
 				[ RGBPATH="$withval" ],
 				[ RGBPATH="${datadir}/X11/rgb" ])
-AC_ARG_WITH(dri-driver-path,  AS_HELP_STRING([--with-dri-driver-path=PATH], [Path to DRI drivers (default: ${libdir}/dri)]),
-				[ DRI_DRIVER_PATH="$withval" ],
-				[ DRI_DRIVER_PATH="${libdir}/dri" ])
 APPLE_APPLICATIONS_DIR="${bindir}/Applications"
 AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir=PATH], [Path to the Applications directory (default: ${bindir}/Applications)]),
                                [ APPLE_APPLICATIONS_DIR="${withval}" ].
@@ -494,6 +488,20 @@ AC_ARG_ENABLE(null-root-cursor, AS_HELP_
                                  [NULL_ROOT_CURSOR=$enableval],
                                  [NULL_ROOT_CURSOR=no])
 
+dnl GLX build options
+AC_ARG_WITH(mesa-source,     AS_HELP_STRING([--with-mesa-source=MESA_SOURCE], [Path to Mesa source tree]),
+                                [ MESA_SOURCE="$withval" ],
+                                [ MESA_SOURCE="" ])
+AC_ARG_WITH(dri-driver-path,  AS_HELP_STRING([--with-dri-driver-path=PATH], [Path to DRI drivers (default: ${libdir}/dri)]),
+				[ DRI_DRIVER_PATH="$withval" ],
+				[ DRI_DRIVER_PATH="${libdir}/dri" ])
+AC_ARG_ENABLE(aiglx,          AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]),
+                                [AIGLX=$enableval],
+                                [AIGLX=yes])
+AC_ARG_ENABLE(glx-tls,        AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: disabled)]),
+                                [GLX_USE_TLS=$enableval],
+                                [GLX_USE_TLS=no])
+
 dnl Extensions.
 AC_ARG_ENABLE(composite,      AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
 AC_ARG_ENABLE(mitshm,         AS_HELP_STRING([--disable-shm], [Build SHM extension (default: enabled)]), [MITSHM=$enableval], [MITSHM=yes])
@@ -508,13 +516,11 @@ AC_ARG_ENABLE(screensaver,    AS_HELP_ST
 AC_ARG_ENABLE(xdmcp,          AS_HELP_STRING([--disable-xdmcp], [Build XDMCP extension (default: auto)]), [XDMCP=$enableval], [XDMCP=auto])
 AC_ARG_ENABLE(xdm-auth-1,     AS_HELP_STRING([--disable-xdm-auth-1], [Build XDM-Auth-1 extension (default: auto)]), [XDMAUTH=$enableval], [XDMAUTH=auto])
 AC_ARG_ENABLE(glx,            AS_HELP_STRING([--disable-glx], [Build GLX extension (default: enabled)]), [GLX=$enableval], [GLX=yes])
-AC_ARG_ENABLE(aiglx,          AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]), [AIGLX=$enableval], [AIGLX=yes])
-AC_ARG_ENABLE(glx-tls,        AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: disabled)]), [GLX_USE_TLS=$enableval], [GLX_USE_TLS=no])
 AC_ARG_ENABLE(dri,            AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), [DRI=$enableval])
 AC_ARG_ENABLE(xinerama,	      AS_HELP_STRING([--disable-xinerama], [Build Xinerama extension (default: enabled)]), [XINERAMA=$enableval], [XINERAMA=yes])
 AC_ARG_ENABLE(xf86vidmode,    AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: auto)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=auto])
 AC_ARG_ENABLE(xf86misc,       AS_HELP_STRING([--disable-xf86misc], [Build XF86Misc extension (default: auto)]), [XF86MISC=$enableval], [XF86MISC=auto])
-AC_ARG_ENABLE(xace,     AS_HELP_STRING([--disable-xace], [Build X-ACE extension (default: enabled)]), [XACE=$enableval], [XACE=yes])
+AC_ARG_ENABLE(xace,           AS_HELP_STRING([--disable-xace], [Build X-ACE extension (default: enabled)]), [XACE=$enableval], [XACE=yes])
 AC_ARG_ENABLE(xcsecurity,     AS_HELP_STRING([--disable-xcsecurity], [Build Security extension (default: enabled)]), [XCSECURITY=$enableval], [XCSECURITY=$XACE])
 AC_ARG_ENABLE(appgroup,       AS_HELP_STRING([--disable-appgroup], [Build XC-APPGROUP extension (default: enabled)]), [APPGROUP=$enableval], [APPGROUP=$XCSECURITY])
 AC_ARG_ENABLE(xcalibrate,     AS_HELP_STRING([--enable-xcalibrate], [Build XCalibrate extension (default: disabled)]), [XCALIBRATE=$enableval], [XCALIBRATE=no])
diff-tree a4e2fc703484fffed8dd50c1b4b24c564be4d3cd (from 38ca7d388c47c4800c74442172d6595a9b3dfcc7)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Thu Apr 5 19:13:47 2007 +0300

    glx: Remove stray __GLinterface.
    
    __GLinterface was droped from glcore.h

diff --git a/GL/glx/glxext.c b/GL/glx/glxext.c
index 1f6c7f3..ca874e3 100644
--- a/GL/glx/glxext.c
+++ b/GL/glx/glxext.c
@@ -275,7 +275,7 @@ static GLboolean errorOccured = GL_FALSE
 /*
 ** The GL was will call this routine if an error occurs.
 */
-void __glXErrorCallBack(__GLinterface *gc, GLenum code)
+void __glXErrorCallBack(GLenum code)
 {
     errorOccured = GL_TRUE;
 }
diff --git a/GL/glx/glxext.h b/GL/glx/glxext.h
index edd66a8..dc4cd4a 100644
--- a/GL/glx/glxext.h
+++ b/GL/glx/glxext.h
@@ -66,7 +66,7 @@ typedef struct {
 extern GLboolean __glXFreeContext(__GLXcontext *glxc);
 extern void __glXFlushContextCache(void);
 
-extern void __glXErrorCallBack(__GLinterface *gc, GLenum code);
+extern void __glXErrorCallBack(GLenum code);
 extern void __glXClearErrorOccured(void);
 extern GLboolean __glXErrorOccured(void);
 extern void __glXResetLargeCommandStatus(__GLXclientState*);
diff-tree 38ca7d388c47c4800c74442172d6595a9b3dfcc7 (from f8482967ae8080f49dd1bbb0b79cc65020df679f)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Thu Apr 5 19:13:14 2007 +0300

    glx: fix symlink, glcontextmodes.c was moved to mesa/src/glx/

diff --git a/GL/symlink-mesa.sh b/GL/symlink-mesa.sh
index 7d1e06e..3d96716 100755
--- a/GL/symlink-mesa.sh
+++ b/GL/symlink-mesa.sh
@@ -225,9 +225,6 @@ symlink_glx() {
     dst_dir glx
 
     action indirect_size.h
-
-    src_dir src/mesa/drivers/dri/common
-
     action glcontextmodes.c
     action glcontextmodes.h
 
diff-tree f8482967ae8080f49dd1bbb0b79cc65020df679f (from c10df5b967d4da4e11786520317e2917de5541fa)
Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Date:   Wed Apr 4 12:28:48 2007 +0200

    Add an EXA driver callback to determine whether a pixmap is
    
    "offscreen" in exa terms, which means accessible to the GPU.
    Bump exa minor. The change is backwards-compatible.

diff --git a/exa/exa.c b/exa/exa.c
index dd27d5e..23fe555 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -322,6 +322,9 @@ exaPixmapIsOffscreen(PixmapPtr p)
     if (p->devPrivate.ptr == NULL)
 	return TRUE;
 
+    if (pExaScr->info->PixmapIsOffscreen)
+	return pExaScr->info->PixmapIsOffscreen(p);
+
     return ((unsigned long) ((CARD8 *) p->devPrivate.ptr -
 			     (CARD8 *) pExaScr->info->memoryBase) <
 	    pExaScr->info->memorySize);
diff --git a/exa/exa.h b/exa/exa.h
index bf723f7..6c39a8f 100644
--- a/exa/exa.h
+++ b/exa/exa.h
@@ -39,7 +39,7 @@
 #include "fb.h"
 
 #define EXA_VERSION_MAJOR   2
-#define EXA_VERSION_MINOR   1
+#define EXA_VERSION_MINOR   2
 #define EXA_VERSION_RELEASE 0
 
 typedef struct _ExaOffscreenArea ExaOffscreenArea;
@@ -636,6 +636,23 @@ typedef struct _ExaDriver {
      */
     void	(*FinishAccess)(PixmapPtr pPix, int index);
 
+    /**
+     * PixmapIsOffscreen() is an optional driver replacement to
+     * exaPixmapIsOffscreen(). Set to NULL if you want the standard behaviour
+     * of exaPixmapIsOffscreen().
+     *
+     * @param pPix the pixmap
+     * @return TRUE if the given drawable is in framebuffer memory.
+     *
+     * exaPixmapIsOffscreen() is used to determine if a pixmap is in offscreen
+     * memory, meaning that acceleration could probably be done to it, and that it
+     * will need to be wrapped by PrepareAccess()/FinishAccess() when accessing it
+     * with the CPU.
+     *
+     *
+     */
+    Bool	(*PixmapIsOffscreen)(PixmapPtr pPix);
+
 	/** @name PrepareAccess() and FinishAccess() indices
 	 * @{
 	 */
diff-tree c10df5b967d4da4e11786520317e2917de5541fa (from e1dea151db6405e12d991feacba9446320739ee8)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Tue Apr 3 15:47:01 2007 -0700

    Swap RRScreenChangeNotifyEvent dimensions when the screen has one crtc and it's rotated.
    
    RandR 1.1 clients expect the size fields in this event to be the unrotated
    dimensions of the screen.  This behavior is "weird", but that's the way the old
    code worked so we need to be bug-compatible with it.

diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index ad74ac3..f83fce3 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -116,11 +116,19 @@ RRDeliverScreenEvent (ClientPtr client, 
 
     se.sequenceNumber = client->sequence;
     se.sizeID = RR10CurrentSizeID (pScreen);
-    
-    se.widthInPixels = pScreen->width;
-    se.heightInPixels = pScreen->height;
-    se.widthInMillimeters = pScreen->mmWidth;
-    se.heightInMillimeters = pScreen->mmHeight;
+
+    if (se.rotation & (RR_Rotate_90 | RR_Rotate_270)) {
+	se.widthInPixels = pScreen->height;
+	se.heightInPixels = pScreen->width;
+	se.widthInMillimeters = pScreen->mmHeight;
+	se.heightInMillimeters = pScreen->mmWidth;
+    } else {
+	se.widthInPixels = pScreen->width;
+	se.heightInPixels = pScreen->height;
+	se.widthInMillimeters = pScreen->mmWidth;
+	se.heightInMillimeters = pScreen->mmHeight;
+    }
+
     WriteEventsToClient (client, 1, (xEvent *) &se);
 }
 
diff-tree e1dea151db6405e12d991feacba9446320739ee8 (from 0ee40c935750e25a9e178cdd70f6b2c667e79344)
Author: Brian <brian at yutani.localnet.net>
Date:   Tue Apr 3 11:21:50 2007 -0600

    Implement a minor hack in dmxCheckFunctionKeys() to detect special keys.
    
    Keep track of status of (left) alt/ctrl keys so that ctrl-alt-q to exit
    can be detected.  Not ideal, but works for now.

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index e4d556b..4810b17 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -103,17 +103,36 @@ static int dmxCheckFunctionKeys(DMXLocal
 {
     DMXInputInfo   *dmxInput = &dmxInputs[dmxLocal->inputIdx];
     unsigned short state = 0;
-    
+
+#if 1 /* hack to detect ctrl-alt-q, etc */
+    static int ctrl = 0, alt = 0;
+    /* keep track of ctrl/alt key status */
+    if (type == KeyPress && keySym == 0xffe3) {
+        ctrl = 1;
+    }
+    else if (type == KeyRelease && keySym == 0xffe3) {
+        ctrl = 0;
+    }
+    else if (type == KeyPress && keySym == 0xffe9) {
+        alt = 1;
+    }
+    else if (type == KeyRelease && keySym == 0xffe9) {
+        alt = 0;
+    }
+    if (!ctrl || !alt)
+        return 0;
+#else
     if (dmxLocal->sendsCore)
         state = dmxLocalCoreKeyboard->pDevice->key->state;
     else if (dmxLocal->pDevice->key)
         state = dmxLocal->pDevice->key->state;
     
-    ErrorF/*DMXDBG3*/("dmxCheckFunctionKeys: keySym=0x%04x %s state=0x%04x\n",
+    DMXDBG3("dmxCheckFunctionKeys: keySym=0x%04x %s state=0x%04x\n",
             keySym, type == KeyPress ? "press" : "release", state);
 
     if ((state & (ControlMask|Mod1Mask)) != (ControlMask|Mod1Mask))
         return 0;
+#endif
 
     switch (keySym) {
     case XK_g:
@@ -679,7 +698,7 @@ void dmxEnqueue(DevicePtr pDev, int type
             xE.u.u.detail = dmxFixup(pDev, detail, keySym);
 
         events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-        ErrorF("KEY %d  sym %d\n", detail, (int) keySym);
+        /*ErrorF("KEY %d  sym %d\n", detail, (int) keySym);*/
         nevents = GetKeyboardEvents(events, p, type, detail);
         for (i = 0; i < nevents; i++)
             mieqEnqueue(p, events + i);
diff-tree 0ee40c935750e25a9e178cdd70f6b2c667e79344 (from 23974f20bf0e0c2786cc75af026af5484f6dc331)
Author: Brian <brian at yutani.localnet.net>
Date:   Tue Apr 3 09:31:00 2007 -0600

    s/intead/instead/

diff --git a/fb/fbcmap.c b/fb/fbcmap.c
index a8cfb79..c29a513 100644
--- a/fb/fbcmap.c
+++ b/fb/fbcmap.c
@@ -40,7 +40,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "fb.h"
 
 #ifdef XFree86Server
-#error "You should be compiling fbcmap_mi.c intead of fbcmap.c!"
+#error "You should be compiling fbcmap_mi.c instead of fbcmap.c!"
 #endif
 
 
diff-tree 23974f20bf0e0c2786cc75af026af5484f6dc331 (from a240c039c47c0be22ea5e100692307b26d938747)
Author: Brian <brian at yutani.localnet.net>
Date:   Tue Apr 3 09:30:24 2007 -0600

    add DDXRingBell() stub to solve link problem

diff --git a/hw/xprint/ddxInit.c b/hw/xprint/ddxInit.c
index 8e7ec2e..a465c4c 100644
--- a/hw/xprint/ddxInit.c
+++ b/hw/xprint/ddxInit.c
@@ -89,6 +89,12 @@ InitOutput(
 
 }
 
+void
+DDXRingBell(int volume, int pitch, int duration)
+{
+   /* dummy func; link fails without */
+}
+
 static void
 BellProc(
     int volume,
diff-tree a240c039c47c0be22ea5e100692307b26d938747 (from 1cc8db72816cd079f30255046e10043c350bf683)
Author: Brian <brian at yutani.localnet.net>
Date:   Tue Apr 3 09:27:57 2007 -0600

    Split the xserver/fb/fbcmap.c file into two files.
    
    Now, fbcmap_mi.c contains the fb functions which just wrap mi functions.
    Previously, these were in fbcmap.c and compiled when XFree86Server was defined.
    Now, clients of fbcmap should either use fbcmap.c or fbcmap_mi.c and not worry
    about setting the XFree86Server symbol.

diff --git a/fb/Makefile.am b/fb/Makefile.am
index 1649669..ab135c9 100644
--- a/fb/Makefile.am
+++ b/fb/Makefile.am
@@ -78,4 +78,4 @@ libwfb_la_SOURCES = $(libfb_la_SOURCES)
 
 libfb_la_LIBADD = libfbmmx.la
 
-EXTRA_DIST = fbcmap.c
+EXTRA_DIST = fbcmap.c fbcmap_mi.c
diff --git a/fb/fbcmap.c b/fb/fbcmap.c
index 9cf5bcb..a8cfb79 100644
--- a/fb/fbcmap.c
+++ b/fb/fbcmap.c
@@ -39,7 +39,12 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "resource.h"
 #include "fb.h"
 
-#ifndef XFree86Server
+#ifdef XFree86Server
+#error "You should be compiling fbcmap_mi.c intead of fbcmap.c!"
+#endif
+
+
+
 ColormapPtr FbInstalledMaps[MAXSCREENS];
 
 int
@@ -584,87 +589,3 @@ fbInitVisuals (VisualPtr    *visualp, 
     *defaultVisp = depth[i].vids[j];
     return TRUE;
 }
-#else
-
-#include "micmap.h"
-
-int
-fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
-{
-    return miListInstalledColormaps(pScreen, pmaps);
-}
-
-void
-fbInstallColormap(ColormapPtr pmap)
-{
-    miInstallColormap(pmap);
-}
-
-void
-fbUninstallColormap(ColormapPtr pmap)
-{
-    miUninstallColormap(pmap);
-}
-
-void
-fbResolveColor(unsigned short   *pred,
-	       unsigned short   *pgreen,
-	       unsigned short   *pblue,
-	       VisualPtr	pVisual)
-{
-    miResolveColor(pred, pgreen, pblue, pVisual);
-}
-
-Bool
-fbInitializeColormap(ColormapPtr pmap)
-{
-    return miInitializeColormap(pmap);
-}
-
-int
-fbExpandDirectColors (ColormapPtr   pmap,
-		      int	    ndef,
-		      xColorItem    *indefs,
-		      xColorItem    *outdefs)
-{
-    return miExpandDirectColors(pmap, ndef, indefs, outdefs);
-}
-
-Bool
-fbCreateDefColormap(ScreenPtr pScreen)
-{
-    return miCreateDefColormap(pScreen);
-}
-
-void
-fbClearVisualTypes(void)
-{
-    miClearVisualTypes();
-}
-
-Bool
-fbSetVisualTypes (int depth, int visuals, int bitsPerRGB)
-{
-    return miSetVisualTypes(depth, visuals, bitsPerRGB, -1);
-}
-
-/*
- * Given a list of formats for a screen, create a list
- * of visuals and depths for the screen which coorespond to
- * the set which can be used with this version of fb.
- */
-
-Bool
-fbInitVisuals (VisualPtr    *visualp, 
-	       DepthPtr	    *depthp,
-	       int	    *nvisualp,
-	       int	    *ndepthp,
-	       int	    *rootDepthp,
-	       VisualID	    *defaultVisp,
-	       unsigned long	sizes,
-	       int	    bitsPerRGB)
-{
-    return miInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp,
-			 defaultVisp, sizes, bitsPerRGB, -1);
-}
-#endif
diff --git a/fb/fbcmap_mi.c b/fb/fbcmap_mi.c
new file mode 100644
index 0000000..58bcae3
--- /dev/null
+++ b/fb/fbcmap_mi.c
@@ -0,0 +1,123 @@
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to 
+distribution  of  the software  without specific prior 
+written permission. Sun and X Consortium make no 
+representations about the suitability of this software for 
+any purpose. It is provided "as is" without any express or 
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+
+/**
+ * This version of fbcmap.c is implemented in terms of mi functions.
+ * These functions used to be in fbcmap.c and depended upon the symbol
+ * XFree86Server being defined.
+ */
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "fb.h"
+#include "micmap.h"
+
+int
+fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
+{
+    return miListInstalledColormaps(pScreen, pmaps);
+}
+
+void
+fbInstallColormap(ColormapPtr pmap)
+{
+    miInstallColormap(pmap);
+}
+
+void
+fbUninstallColormap(ColormapPtr pmap)
+{
+    miUninstallColormap(pmap);
+}
+
+void
+fbResolveColor(unsigned short   *pred,
+	       unsigned short   *pgreen,
+	       unsigned short   *pblue,
+	       VisualPtr	pVisual)
+{
+    miResolveColor(pred, pgreen, pblue, pVisual);
+}
+
+Bool
+fbInitializeColormap(ColormapPtr pmap)
+{
+    return miInitializeColormap(pmap);
+}
+
+int
+fbExpandDirectColors (ColormapPtr   pmap,
+		      int	    ndef,
+		      xColorItem    *indefs,
+		      xColorItem    *outdefs)
+{
+    return miExpandDirectColors(pmap, ndef, indefs, outdefs);
+}
+
+Bool
+fbCreateDefColormap(ScreenPtr pScreen)
+{
+    return miCreateDefColormap(pScreen);
+}
+
+void
+fbClearVisualTypes(void)
+{
+    miClearVisualTypes();
+}
+
+Bool
+fbSetVisualTypes (int depth, int visuals, int bitsPerRGB)
+{
+    return miSetVisualTypes(depth, visuals, bitsPerRGB, -1);
+}
+
+/*
+ * Given a list of formats for a screen, create a list
+ * of visuals and depths for the screen which coorespond to
+ * the set which can be used with this version of fb.
+ */
+Bool
+fbInitVisuals (VisualPtr    *visualp, 
+	       DepthPtr	    *depthp,
+	       int	    *nvisualp,
+	       int	    *ndepthp,
+	       int	    *rootDepthp,
+	       VisualID	    *defaultVisp,
+	       unsigned long	sizes,
+	       int	    bitsPerRGB)
+{
+    return miInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp,
+			 defaultVisp, sizes, bitsPerRGB, -1);
+}
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 3e28d32..b8641bb 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -26,12 +26,12 @@ libdarwinShared_a_SOURCES = darwin.c \
 
 bin_PROGRAMS = XDarwin Xquartz
 XDarwin_SOURCES = \
-                  $(top_srcdir)/fb/fbcmap.c \
+                  $(top_srcdir)/fb/fbcmap_mi.c \
                   $(top_srcdir)/mi/miinitext.c \
                   $(top_srcdir)/Xi/stubs.c
 
 Xquartz_SOURCES = \
-                  $(top_srcdir)/fb/fbcmap.c \
+                  $(top_srcdir)/fb/fbcmap_mi.c \
                   $(top_srcdir)/mi/miinitext.c \
                   $(top_srcdir)/Xi/stubs.c \
                   apple/X11Application.m \
@@ -115,7 +115,7 @@ x11app:
 	cd apple && xcodebuild CFLAGS="$(XSERVERCFLAGS_CFLAGS)" LDFLAGS="$(XSERVERCFLAGS_LIBS)"
 
 XDarwinApp_SOURCES = \
-                $(top_srcdir)/fb/fbcmap.c \
+                $(top_srcdir)/fb/fbcmap_mi.c \
                 $(top_srcdir)/mi/miinitext.c \
 		$(top_srcdir)/Xi/stubs.c 
 
diff --git a/hw/dmx/Makefile.am b/hw/dmx/Makefile.am
index 41dc5d2..002ea11 100644
--- a/hw/dmx/Makefile.am
+++ b/hw/dmx/Makefile.am
@@ -16,9 +16,6 @@ GLX_INCS = -I$(top_srcdir)/hw/xfree86/di
 GLX_DEFS = @GL_CFLAGS@ 
 endif
 
-# It's essential that fbcmap.c be compiled with this flag for DMX to work!!
-DMX_CFLAGS = -DXFree86Server=1
-
 if BUILDDOCS
 SUBDIRS += doc
 endif
@@ -76,7 +73,7 @@ Xdmx_SOURCES = dmx.c \
                dmxwindow.c \
                dmxwindow.h \
                $(top_srcdir)/mi/miinitext.c \
-               $(top_srcdir)/fb/fbcmap.c \
+               $(top_srcdir)/fb/fbcmap_mi.c \
                $(GLX_SRCS) 
 
 
diff --git a/hw/vfb/Makefile.am b/hw/vfb/Makefile.am
index 40c3854..6842b45 100644
--- a/hw/vfb/Makefile.am
+++ b/hw/vfb/Makefile.am
@@ -14,8 +14,8 @@ SRCS =	InitInput.c \
 	$(top_srcdir)/Xi/stubs.c \
 	$(top_srcdir)/mi/miinitext.c
 
-libfbcmap_a_CFLAGS = $(AM_CFLAGS) -DXFree86Server
-libfbcmap_a_SOURCES = $(top_srcdir)/fb/fbcmap.c
+libfbcmap_a_CFLAGS = $(AM_CFLAGS)
+libfbcmap_a_SOURCES = $(top_srcdir)/fb/fbcmap_mi.c
 
 Xvfb_SOURCES = $(SRCS)
 
diff --git a/hw/xfree86/dixmods/Makefile.am b/hw/xfree86/dixmods/Makefile.am
index 58099bc..1581019 100644
--- a/hw/xfree86/dixmods/Makefile.am
+++ b/hw/xfree86/dixmods/Makefile.am
@@ -75,13 +75,13 @@ libdbe_la_SOURCES = dbemodule.c
 
 libfb_la_LDFLAGS = -avoid-version
 libfb_la_LIBADD = $(top_builddir)/fb/libfb.la
-libfb_la_SOURCES = $(top_builddir)/fb/fbcmap.c fbmodule.c
-libfb_la_CFLAGS = -DXFree86Server $(AM_CFLAGS)
+libfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
+libfb_la_CFLAGS = $(AM_CFLAGS)
 
 libwfb_la_LDFLAGS = -avoid-version
 libwfb_la_LIBADD = $(top_builddir)/fb/libwfb.la
-libwfb_la_SOURCES = $(top_builddir)/fb/fbcmap.c fbmodule.c
-libwfb_la_CFLAGS = -DXFree86Server $(AM_CFLAGS) -DFB_ACCESS_WRAPPER
+libwfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
+libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER
 
 libglx_la_LDFLAGS = -avoid-version
 if AIGLX
diff --git a/hw/xnest/Makefile.am b/hw/xnest/Makefile.am
index b897616..e958c0e 100644
--- a/hw/xnest/Makefile.am
+++ b/hw/xnest/Makefile.am
@@ -45,8 +45,8 @@ SRCS =	Args.c \
 	$(top_srcdir)/Xi/stubs.c \
 	$(top_srcdir)/mi/miinitext.c
 
-libfbcmap_a_SOURCES = $(top_srcdir)/fb/fbcmap.c
-libfbcmap_a_CFLAGS = $(AM_CFLAGS) -DXFree86Server
+libfbcmap_a_SOURCES = $(top_srcdir)/fb/fbcmap_mi.c
+libfbcmap_a_CFLAGS = $(AM_CFLAGS)
 
 Xnest_SOURCES = $(SRCS)
 
diff --git a/hw/xprint/Makefile.am b/hw/xprint/Makefile.am
index d4f22d2..45168b1 100644
--- a/hw/xprint/Makefile.am
+++ b/hw/xprint/Makefile.am
@@ -38,6 +38,6 @@ Xprt_SOURCES =			\
 	Util.c			\
 	miinitext-wrapper.c	\
 	dpmsstubs-wrapper.c     \
-        $(top_srcdir)/fb/fbcmap.c
+        $(top_srcdir)/fb/fbcmap_mi.c
 
 EXTRA_DIST = ValTree.c
diff-tree 1cc8db72816cd079f30255046e10043c350bf683 (from parents)
Merge: 645d87cf8ef724d4591614f9994cdc4d7549a7a8 a39f297ada4fa87c858395ae2aacefac5f8fba05
Author: Matthieu Herrb <matthieu at roadrock.(none)>
Date:   Tue Apr 3 16:04:45 2007 +0200

    Merge branch 'master' of ssh://herrb@git.freedesktop.org/git/xorg/xserver

diff-tree 645d87cf8ef724d4591614f9994cdc4d7549a7a8 (from f2808005f4ee72c5fd7f5f3dcca181306485113e)
Author: Matthieu Herrb <matthieu at roadrock.(none)>
Date:   Tue Apr 3 15:47:18 2007 +0200

    CVE-2007-1003: XC-MISC Extension ProcXCMiscGetXIDList() Memory Corruption

diff --git a/Xext/xcmisc.c b/Xext/xcmisc.c
index f26218e..8c7a86e 100644
--- a/Xext/xcmisc.c
+++ b/Xext/xcmisc.c
@@ -42,6 +42,12 @@ from The Open Group.
 #include <X11/extensions/xcmiscstr.h>
 #include "modinit.h"
 
+#if HAVE_STDINT_H
+#include <stdint.h>
+#elif !defined(UINT32_MAX)
+#define UINT32_MAX 0xffffffffU
+#endif
+
 #if 0
 static unsigned char XCMiscCode;
 #endif
@@ -143,7 +149,10 @@ ProcXCMiscGetXIDList(client)
 
     REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
 
-    pids = (XID *)ALLOCATE_LOCAL(stuff->count * sizeof(XID));
+    if (stuff->count > UINT32_MAX / sizeof(XID))
+	    return BadAlloc;
+
+    pids = (XID *)Xalloc(stuff->count * sizeof(XID));
     if (!pids)
     {
 	return BadAlloc;
@@ -164,7 +173,7 @@ ProcXCMiscGetXIDList(client)
     	client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
 	WriteSwappedDataToClient(client, count * sizeof(XID), pids);
     }
-    DEALLOCATE_LOCAL(pids);
+    Xfree(pids);
     return(client->noClientException);
 }
 
diff-tree a39f297ada4fa87c858395ae2aacefac5f8fba05 (from 11797ffdcc22160317a5ebbc9291472570a51c6d)
Author: Keith Packard <keithp at viola.jf.intel.com>
Date:   Mon Apr 2 14:15:36 2007 -0700

    Don't erase current crtc for outputs on CloseScreen
    
    Erasing this variable causes some outputs (SDVO on intel) to fail
    to be correctly reset at server reset time.
    (cherry picked from commit 56262a4ee943f328d089a8eb4aa70b9a4bd5d135)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 32bdcba..0fe03d3 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -598,7 +598,6 @@ xf86CrtcCloseScreen (int index, ScreenPt
     {
 	xf86OutputPtr	output = config->output[o];
 
-	output->crtc = NULL;
 	output->randr_output = NULL;
     }
     for (c = 0; c < config->num_crtc; c++)
diff-tree 11797ffdcc22160317a5ebbc9291472570a51c6d (from e44f106ffc796c025abdfb66717c06db8b12b4e4)
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Apr 2 18:21:58 2007 -0700

    Move modes/ debugging output under Option "ModeDebug" in the Device section.

diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre
index cc60d07..19315c0 100644
--- a/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -958,6 +958,10 @@ the driver-specific documentation recomm
 This optional entry specifies the pixel clock frequency that is used
 for the regular text mode.  The frequency is specified in MHz.  This is
 rarely used.
+.TP 7
+.BI "Option \*qModeDebug\*q \*q" boolean \*q
+Enable printing of additional debugging information about modesetting to
+the server log.
 .ig
 .TP 7
 This optional entry allows an IRQ number to be specified.
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 7d86b66..32bdcba 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -377,6 +377,15 @@ static OptionInfoRec xf86OutputOptions[]
     {-1,		    NULL,		OPTV_NONE,    {0}, FALSE },
 };
 
+enum {
+    OPTION_MODEDEBUG,
+};
+
+static OptionInfoRec xf86DeviceOptions[] = {
+    {OPTION_MODEDEBUG,	    "ModeDebug",	OPTV_STRING,  {0}, FALSE },
+    {-1,		    NULL,		OPTV_NONE,    {0}, FALSE },
+};
+
 static void
 xf86OutputSetMonitor (xf86OutputPtr output)
 {
@@ -1160,8 +1169,6 @@ xf86SortModes (DisplayModePtr input)
     return output;
 }
 
-#define DEBUG_REPROBE 1
-
 void
 xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
 {
@@ -1330,7 +1337,8 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, 
 	    if (mode->status == MODE_OK)
 		mode->status = (*output->funcs->mode_valid)(output, mode);
 	
-	xf86PruneInvalidModes(scrn, &output->probed_modes, TRUE);
+	xf86PruneInvalidModes(scrn, &output->probed_modes,
+			      config->debug_modes);
 	
 	output->probed_modes = xf86SortModes (output->probed_modes);
 	
@@ -1363,17 +1371,17 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, 
 	
 	output->initial_rotation = xf86OutputInitialRotation (output);
 
-#ifdef DEBUG_REPROBE
-	if (output->probed_modes != NULL) {
-	    xf86DrvMsg(scrn->scrnIndex, X_INFO,
-		       "Printing probed modes for output %s\n",
-		       output->name);
-	} else {
-	    xf86DrvMsg(scrn->scrnIndex, X_INFO,
-		       "No remaining probed modes for output %s\n",
-		       output->name);
+	if (config->debug_modes) {
+	    if (output->probed_modes != NULL) {
+		xf86DrvMsg(scrn->scrnIndex, X_INFO,
+			   "Printing probed modes for output %s\n",
+			   output->name);
+	    } else {
+		xf86DrvMsg(scrn->scrnIndex, X_INFO,
+			   "No remaining probed modes for output %s\n",
+			   output->name);
+	    }
 	}
-#endif
 	for (mode = output->probed_modes; mode != NULL; mode = mode->next)
 	{
 	    /* The code to choose the best mode per pipe later on will require
@@ -1382,9 +1390,8 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, 
 	    mode->VRefresh = xf86ModeVRefresh(mode);
 	    xf86SetModeCrtc(mode, INTERLACE_HALVE_V);
 
-#ifdef DEBUG_REPROBE
-	    xf86PrintModeline(scrn->scrnIndex, mode);
-#endif
+	    if (config->debug_modes)
+		xf86PrintModeline(scrn->scrnIndex, mode);
 	}
     }
 }
@@ -1479,6 +1486,15 @@ xf86InitialConfiguration (ScrnInfoPtr sc
     int			width;
     int			height;
 
+    /* Set up the device options */
+    config->options = xnfalloc (sizeof (xf86DeviceOptions));
+    memcpy (config->options, xf86DeviceOptions, sizeof (xf86DeviceOptions));
+    xf86ProcessOptions (scrn->scrnIndex,
+			scrn->options,
+			config->options);
+    config->debug_modes = xf86ReturnOptValBool (config->options,
+						OPTION_MODEDEBUG, FALSE);
+
     if (scrn->display->virtualX)
 	width = scrn->display->virtualX;
     else
@@ -1962,10 +1978,12 @@ xf86OutputSetEDID (xf86OutputPtr output,
     
     output->MonInfo = edid_mon;
 
-    /* Debug info for now, at least */
-    xf86DrvMsg(scrn->scrnIndex, X_INFO, "EDID for output %s\n", output->name);
-    xf86PrintEDID(edid_mon);
-    
+    if (config->debug_modes) {
+	xf86DrvMsg(scrn->scrnIndex, X_INFO, "EDID for output %s\n",
+		   output->name);
+	xf86PrintEDID(edid_mon);
+    }
+
     /* Set the DDC properties for the 'compat' output */
     if (output == config->output[config->compat_output])
         xf86SetDDCproperties(scrn, edid_mon);
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 42daf60..030f6bf 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -552,6 +552,13 @@ typedef struct _xf86CrtcConfig {
     CARD8		*cursor_image;
     Bool		cursor_on;
     CARD32		cursor_fg, cursor_bg;
+
+    /**
+     * Options parsed from the related device section
+     */
+    OptionInfoPtr	options;
+
+    Bool		debug_modes;
 } xf86CrtcConfigRec, *xf86CrtcConfigPtr;
 
 extern int xf86CrtcConfigPrivateIndex;
diff-tree e44f106ffc796c025abdfb66717c06db8b12b4e4 (from 8d8bc8927760fad631bef83fa2841b455ff6d511)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 16:26:15 2007 -0600

    clean-up, debug code

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 288570d..e4d556b 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -109,11 +109,11 @@ static int dmxCheckFunctionKeys(DMXLocal
     else if (dmxLocal->pDevice->key)
         state = dmxLocal->pDevice->key->state;
     
-    DMXDBG3("dmxCheckFunctionKeys: keySym=0x%04x %s state=0x%04x\n",
+    ErrorF/*DMXDBG3*/("dmxCheckFunctionKeys: keySym=0x%04x %s state=0x%04x\n",
             keySym, type == KeyPress ? "press" : "release", state);
 
     if ((state & (ControlMask|Mod1Mask)) != (ControlMask|Mod1Mask))
-       return 0;
+        return 0;
 
     switch (keySym) {
     case XK_g:
@@ -679,7 +679,7 @@ void dmxEnqueue(DevicePtr pDev, int type
             xE.u.u.detail = dmxFixup(pDev, detail, keySym);
 
         events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-        ErrorF("KEY %d\n", detail);
+        ErrorF("KEY %d  sym %d\n", detail, (int) keySym);
         nevents = GetKeyboardEvents(events, p, type, detail);
         for (i = 0; i < nevents; i++)
             mieqEnqueue(p, events + i);
@@ -719,12 +719,12 @@ void dmxEnqueue(DevicePtr pDev, int type
                                  * modifier map on the backend/console
                                  * input device so that we have complete
                                  * control of the input device LEDs. */
-       ErrorF("Enter/Leave/Keymap/Mapping\n");
         return;
     default:
 #ifdef XINPUT
         if (type == ProximityIn || type == ProximityOut) {
-            if (dmxLocal->sendsCore) return; /* Not a core event */
+            if (dmxLocal->sendsCore)
+                return; /* Not a core event */
             break;
         }
 #endif
diff-tree 8d8bc8927760fad631bef83fa2841b455ff6d511 (from 3e482de7b145a5eed79b81c30c359fe43647824a)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 16:21:57 2007 -0600

    fix formatting

diff --git a/hw/dmx/input/dmxcommon.c b/hw/dmx/input/dmxcommon.c
index 278a74e..1dcc1e9 100644
--- a/hw/dmx/input/dmxcommon.c
+++ b/hw/dmx/input/dmxcommon.c
@@ -241,13 +241,15 @@ void dmxCommonKbdGetMap(DevicePtr pDev, 
 
                                 /* Compute pModMap  */
     modifier_mapping     = XGetModifierMapping(priv->display);
-    for (i = 0; i < MAP_LENGTH; i++) pModMap[i] = 0;
+    for (i = 0; i < MAP_LENGTH; i++)
+        pModMap[i] = 0;
     for (j = 0; j < 8; j++) {
         int max_keypermod = modifier_mapping->max_keypermod;
         
         for (i = 0; i < max_keypermod; i++) {
             CARD8 keycode = modifier_mapping->modifiermap[j*max_keypermod + i];
-            if (keycode) pModMap[keycode] |= 1 << j;
+            if (keycode)
+                pModMap[keycode] |= 1 << j;
         }
     }
     XFreeModifiermap(modifier_mapping);
@@ -611,6 +613,7 @@ void dmxCommonSaveState(pointer private)
                         &priv->dmxLocal->kctrl);
 
     priv->savedModMap                   = XGetModifierMapping(priv->display);
+
     modmap                              = XNewModifiermap(0);
     XSetModifierMapping(priv->display, modmap);
     if (dmxInput->scrnIdx != -1)
@@ -627,8 +630,10 @@ void dmxCommonRestoreState(pointer priva
     int retcode = -1;
     CARD32 start;
 
-    if (dmxInput->console) priv = dmxInput->devs[0]->private;
-    if (!priv->stateSaved) return;
+    if (dmxInput->console)
+        priv = dmxInput->devs[0]->private;
+    if (!priv->stateSaved)
+        return;
     priv->stateSaved = 0;
     
     DMXDBG0("dmxCommonRestoreState\n");
@@ -645,7 +650,8 @@ void dmxCommonRestoreState(pointer priva
         CARD32 tmp;
         
         retcode = XSetModifierMapping(priv->display, priv->savedModMap);
-        if (retcode == MappingSuccess) break;
+        if (retcode == MappingSuccess)
+            break;
         if (retcode == MappingBusy)
             dmxLogInput(dmxInput, "Keyboard busy, waiting\n");
         else
diff-tree 3e482de7b145a5eed79b81c30c359fe43647824a (from 76a7a5ca1f068c27c9b5fbd49d5a1da80ed6f488)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 15:38:15 2007 -0600

    checkpoint: more clean-up

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 17047f7..288570d 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -662,70 +662,56 @@ void dmxEnqueue(DevicePtr pDev, int type
 {
     GETDMXINPUTFROMPDEV;
     xEvent xE;
+    DeviceIntPtr p = dmxLocal->pDevice;
+    int i, nevents, valuators[3];
+    xEvent *events;
 
     DMXDBG2("dmxEnqueue: Enqueuing type=%d detail=0x%0x\n", type, detail);
 
     switch (type) {
     case KeyPress:
     case KeyRelease:
-        if (!keySym) keySym = dmxKeyCodeToKeySym(dmxLocal, detail);
+        if (!keySym)
+            keySym = dmxKeyCodeToKeySym(dmxLocal, detail);
         if (dmxCheckFunctionKeys(dmxLocal, type, keySym))
             return;
         if (dmxLocal->sendsCore && dmxLocal != dmxLocalCoreKeyboard)
             xE.u.u.detail = dmxFixup(pDev, detail, keySym);
-        {
-           DeviceIntPtr p = dmxLocal->pDevice;
-           int i, nevents;
-           xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-           ErrorF("KEY %d\n", detail);
-           nevents = GetKeyboardEvents(events, p, type, detail);
-           for (i = 0; i < nevents; i++)
-              mieqEnqueue(p, events + i);
-           xfree(events);
-           return;
-        }
-        break;
+
+        events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+        ErrorF("KEY %d\n", detail);
+        nevents = GetKeyboardEvents(events, p, type, detail);
+        for (i = 0; i < nevents; i++)
+            mieqEnqueue(p, events + i);
+        xfree(events);
+        return;
+
     case ButtonPress:
     case ButtonRelease:
         detail = dmxGetButtonMapping(dmxLocal, detail);
-        {
-           DeviceIntPtr p = dmxLocal->pDevice;
-           int i, nevents, valuators[3];
-           xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-           valuators[2] = e->xbutton.button;
-           nevents = GetPointerEvents(events, p, type, detail,
-                                      POINTER_ABSOLUTE,
-                                      0,   /* first_valuator = 0 */
-                                      0,   /* num_valuators = 0 */
-                                      valuators);
-
-           ErrorF("BUTTON %d, %d %d  n=%d\n",
-                  valuators[0], valuators[1], valuators[2], nevents);
-
-           for (i = 0; i < nevents; i++)
-              mieqEnqueue(p, events + i);
-           xfree(events);
-           return;
-        }
-        break;
+        events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+        nevents = GetPointerEvents(events, p, type, detail,
+                                   POINTER_ABSOLUTE,
+                                   0,   /* first_valuator = 0 */
+                                   0,   /* num_valuators = 0 */
+                                   valuators);
+        for (i = 0; i < nevents; i++)
+            mieqEnqueue(p, events + i);
+        xfree(events);
+        return;
+
     case MotionNotify:
-        {
-           DeviceIntPtr p = dmxLocal->pDevice;
-           int i, nevents, valuators[3];
-           xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-           valuators[0] = e->xmotion.x;
-           valuators[1] = e->xmotion.y;
-           valuators[2] = e->xmotion.state;
-           nevents = GetPointerEvents(events, p, type, detail, 
-                                      POINTER_ABSOLUTE, 0, 3, valuators);
-           ErrorF("MOTION %d, %d  n = %d\n", valuators[0], valuators[1], nevents);
-           for (i = 0; i < nevents; i++)
-              mieqEnqueue(p, events + i);
-           xfree(events);
-           return;
-        }
-        break;
-                                /* Always ignore these events */
+        events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+        valuators[0] = e->xmotion.x;
+        valuators[1] = e->xmotion.y;
+        valuators[2] = e->xmotion.state;
+        nevents = GetPointerEvents(events, p, type, detail, 
+                                   POINTER_ABSOLUTE, 0, 3, valuators);
+        for (i = 0; i < nevents; i++)
+            mieqEnqueue(p, events + i);
+        xfree(events);
+        return;
+
     case EnterNotify:
     case LeaveNotify:
     case KeymapNotify:
@@ -754,25 +740,19 @@ void dmxEnqueue(DevicePtr pDev, int type
         return;
     }
 
+#if 00 /* dead code? */
     memset(&xE, 0, sizeof(xE));
     xE.u.u.type                = type;
     xE.u.u.detail              = detail;
     xE.u.keyButtonPointer.time = GetTimeInMillis();
 
 #ifdef XINPUT
-    if (!dmxLocal->sendsCore) dmxEnqueueExtEvent(dmxLocal, &xE, block);
+    if (!dmxLocal->sendsCore)
+        dmxEnqueueExtEvent(dmxLocal, &xE, block);
     else
 #endif
-#if 00 /*BP*/
         dmxeqEnqueue(&xE);
-#else
-    /* never get here! */
-    if (0) {
-       DeviceIntPtr p = dmxLocal->pDevice;
-       ErrorF("enque %d\n", type);
-       mieqEnqueue(p, &xE);
-    }
-#endif
+#endif /*00*/
 }
 
 /** A pointer to this routine is passed to low-level input drivers so
diff-tree 76a7a5ca1f068c27c9b5fbd49d5a1da80ed6f488 (from 69baad321d35dae0bfa535be0c6ed2131fed1e60)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 15:24:05 2007 -0600

    formatting fixes

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index bca1a10..17047f7 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -112,7 +112,8 @@ static int dmxCheckFunctionKeys(DMXLocal
     DMXDBG3("dmxCheckFunctionKeys: keySym=0x%04x %s state=0x%04x\n",
             keySym, type == KeyPress ? "press" : "release", state);
 
-    if ((state & (ControlMask|Mod1Mask)) != (ControlMask|Mod1Mask)) return 0;
+    if ((state & (ControlMask|Mod1Mask)) != (ControlMask|Mod1Mask))
+       return 0;
 
     switch (keySym) {
     case XK_g:
@@ -147,16 +148,25 @@ static void dmxEnqueueExtEvent(DMXLocalI
     int                    type      = e->u.u.type;
 
     switch (e->u.u.type) {
-    case KeyPress:      type = DeviceKeyPress;      break;
-    case KeyRelease:    type = DeviceKeyRelease;    break;
-    case ButtonPress:   type = DeviceButtonPress;   break;
-    case ButtonRelease: type = DeviceButtonRelease; break;
+    case KeyPress:
+        type = DeviceKeyPress;
+        break;
+    case KeyRelease:
+        type = DeviceKeyRelease;
+        break;
+    case ButtonPress:
+        type = DeviceButtonPress;
+        break;
+    case ButtonRelease:
+        type = DeviceButtonRelease;
+        break;
     case MotionNotify:
         dmxLog(dmxError,
                "dmxEnqueueExtEvent: MotionNotify not allowed here\n");
         return;
     default:
-        if (e->u.u.type == ProximityIn || e->u.u.type == ProximityOut) break;
+        if (e->u.u.type == ProximityIn || e->u.u.type == ProximityOut)
+            break;
         dmxLogInput(dmxInput,
                     "dmxEnqueueExtEvent: Unhandled %s event (%d)\n",
                     e->u.u.type >= LASTEvent ? "extension" : "non-extension",
@@ -174,9 +184,11 @@ static void dmxEnqueueExtEvent(DMXLocalI
     xv->num_valuators  = 0;
     xv->first_valuator = 0;
 
-    if (block) dmxSigioBlock();
+    if (block)
+        dmxSigioBlock();
     dmxeqEnqueue(xE);
-    if (block) dmxSigioUnblock();
+    if (block)
+        dmxSigioUnblock();
 }
 #endif
 
@@ -186,7 +198,8 @@ DMXScreenInfo *dmxFindFirstScreen(int x,
 
     for (i = 0; i < dmxNumScreens; i++) {
         DMXScreenInfo *dmxScreen = &dmxScreens[i];
-        if (dmxOnScreen(x, y, dmxScreen)) return dmxScreen;
+        if (dmxOnScreen(x, y, dmxScreen))
+            return dmxScreen;
     }
     return NULL;
 }
@@ -223,7 +236,8 @@ dmxCoreMotion(DevicePtr pDev, int x, int
     int           localY;
     int           i;
 
-    if (!dmxGlobalInvalid && dmxGlobalX == x && dmxGlobalY == y) return;
+    if (!dmxGlobalInvalid && dmxGlobalX == x && dmxGlobalY == y)
+        return;
     
     DMXDBG5("dmxCoreMotion(%d,%d,%d) dmxGlobalX=%d dmxGlobalY=%d\n",
             x, y, delta, dmxGlobalX, dmxGlobalY);
@@ -232,10 +246,14 @@ dmxCoreMotion(DevicePtr pDev, int x, int
     dmxGlobalX       = x;
     dmxGlobalY       = y;
 
-    if (dmxGlobalX < 0)                dmxGlobalX = 0;
-    if (dmxGlobalY < 0)                dmxGlobalY = 0;
-    if (dmxGlobalX >= dmxGlobalWidth)  dmxGlobalX = dmxGlobalWidth  + delta -1;
-    if (dmxGlobalY >= dmxGlobalHeight) dmxGlobalY = dmxGlobalHeight + delta -1;
+    if (dmxGlobalX < 0)
+        dmxGlobalX = 0;
+    if (dmxGlobalY < 0)
+        dmxGlobalY = 0;
+    if (dmxGlobalX >= dmxGlobalWidth)
+        dmxGlobalX = dmxGlobalWidth  + delta -1;
+    if (dmxGlobalY >= dmxGlobalHeight)
+        dmxGlobalY = dmxGlobalHeight + delta -1;
     
     if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
         localX = dmxGlobalX - dmxScreen->rootXOrigin;
@@ -283,7 +301,6 @@ dmxCoreMotion(DevicePtr pDev, int x, int
                                  * drivers */
     for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) {
         int j;
-
         for (j = 0; j < dmxInput->numDevs; j += dmxInput->devs[j]->binding)
             if (!dmxInput->detached
                 && dmxInput->devs[j]->sendsCore
@@ -386,10 +403,12 @@ static void dmxExtMotion(DMXLocalInputIn
         }
     }
 
-    if (block) dmxSigioBlock();
+    if (block)
+        dmxSigioBlock();
     dmxPointerPutMotionEvent(pDevice, firstAxis, axesCount, v, xev->time);
     dmxeqEnqueue(xE);
-    if (block) dmxSigioUnblock();
+    if (block)
+        dmxSigioUnblock();
 }
 
 static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
@@ -403,7 +422,8 @@ static int dmxTranslateAndEnqueueExtEven
     XDeviceKeyEvent        *ke     = (XDeviceKeyEvent *)e;
     XDeviceMotionEvent     *me     = (XDeviceMotionEvent *)e;
 
-    if (!e) return -1;          /* No extended event passed, cannot handle */
+    if (!e)
+        return -1;          /* No extended event passed, cannot handle */
     
     if ((XID)dmxLocal->deviceId != ke->deviceid) {
                                 /* Search for the correct dmxLocal,
@@ -414,7 +434,8 @@ static int dmxTranslateAndEnqueueExtEven
         DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
         for (i = 0; i < dmxInput->numDevs; i++) {
             dmxLocal = dmxInput->devs[i];
-            if ((XID)dmxLocal->deviceId == ke->deviceid) break;
+            if ((XID)dmxLocal->deviceId == ke->deviceid)
+                break;
         }
     }
 
@@ -463,9 +484,11 @@ static int dmxTranslateAndEnqueueExtEven
         xv->valuator4      = ke->axis_data[4];
         xv->valuator5      = ke->axis_data[5];
 
-        if (block) dmxSigioBlock();
+        if (block)
+            dmxSigioBlock();
         dmxeqEnqueue(xE);
-        if (block) dmxSigioUnblock();
+        if (block)
+            dmxSigioUnblock();
         break;
 
     case XI_DeviceMotionNotify:
@@ -568,7 +591,8 @@ static KeySym dmxKeyCodeToKeySym(DMXLoca
     if (!dmxLocal || !dmxLocal->pDevice || !dmxLocal->pDevice->key)
         return NoSymbol;
     pKeySyms = &dmxLocal->pDevice->key->curKeySyms;
-    if (!pKeySyms) return NoSymbol;
+    if (!pKeySyms)
+        return NoSymbol;
     
     if (keyCode > pKeySyms->minKeyCode && keyCode <= pKeySyms->maxKeyCode) {
         DMXDBG2("dmxKeyCodeToKeySym: Translated keyCode=%d to keySym=0x%04x\n",
@@ -617,8 +641,10 @@ static int dmxFixup(DevicePtr pDev, int 
                dmxLocal->pDevice->name);
         return NoSymbol;
     }
-    if (!keySym) keySym = dmxKeyCodeToKeySym(dmxLocal, detail);
-    if (keySym == NoSymbol) return detail;
+    if (!keySym)
+        keySym = dmxKeyCodeToKeySym(dmxLocal, detail);
+    if (keySym == NoSymbol)
+        return detail;
     keyCode = dmxKeySymToKeyCode(dmxLocalCoreKeyboard, keySym, detail);
 
     return keyCode ? keyCode : detail;
diff-tree 69baad321d35dae0bfa535be0c6ed2131fed1e60 (from 44eb15adeee3b299677070f39625daa53679bd13)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 15:21:22 2007 -0600

    clean-up dmxCoreMotion() dmxCoreMotion2()

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 3634324..bca1a10 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -192,8 +192,6 @@ DMXScreenInfo *dmxFindFirstScreen(int x,
 }
 
 
-#if 11/*BP*/
-
 /**
  * Enqueue a motion event.
  */
@@ -215,8 +213,8 @@ static void enqueueMotion(DevicePtr pDev
 }
 
 
-static void
-dmxCoreMotion2(DevicePtr pDev, int x, int y, int delta, DMXBlockType block)
+void
+dmxCoreMotion(DevicePtr pDev, int x, int y, int delta, DMXBlockType block)
 {
     DMXScreenInfo *dmxScreen;
     DMXInputInfo  *dmxInput;
@@ -239,8 +237,6 @@ dmxCoreMotion2(DevicePtr pDev, int x, in
     if (dmxGlobalX >= dmxGlobalWidth)  dmxGlobalX = dmxGlobalWidth  + delta -1;
     if (dmxGlobalY >= dmxGlobalHeight) dmxGlobalY = dmxGlobalHeight + delta -1;
     
-    ErrorF("Global Pos: %d, %d\n", dmxGlobalX, dmxGlobalY);
-
     if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
         localX = dmxGlobalX - dmxScreen->rootXOrigin;
         localY = dmxGlobalY - dmxScreen->rootYOrigin;
@@ -249,13 +245,8 @@ dmxCoreMotion2(DevicePtr pDev, int x, in
                                 /* Screen is old screen */
             if (block)
                 dmxSigioBlock();
-#if 000
-            miPointerSetPosition(inputInfo.pointer, &localX, &localY,
-                                 GetTimeInMillis());
-#else
             if (pDev)
                enqueueMotion(pDev, localX, localY);
-#endif
             if (block)
                 dmxSigioUnblock();
         } else {
@@ -267,13 +258,8 @@ dmxCoreMotion2(DevicePtr pDev, int x, in
             dmxeqProcessInputEvents();
             miPointerSetScreen(inputInfo.pointer, dmxScreen->index,
                                localX, localY);
-#if 000
-            miPointerSetPosition(inputInfo.pointer, &localX, &localY,
-                                 GetTimeInMillis());
-#else
             if (pDev)
                enqueueMotion(pDev, localX, localY);
-#endif
             if (block)
                 dmxSigioUnblock();
         }
@@ -307,105 +293,6 @@ dmxCoreMotion2(DevicePtr pDev, int x, in
     }
     if (!dmxScreen) ProcessInputEvents();
 }
-#endif
-
-void dmxCoreMotion(DevicePtr pDev, int x, int y, int delta, DMXBlockType block)
-{
-    DMXScreenInfo *dmxScreen;
-    DMXInputInfo  *dmxInput;
-    ScreenPtr     pScreen;
-    int           localX;
-    int           localY;
-    int           i;
-
-#if 11/*BP*/
-    dmxCoreMotion2(pDev, x, y, delta, block);
-    return;
-#endif
-
-    if (!dmxGlobalInvalid && dmxGlobalX == x && dmxGlobalY == y) return;
-    
-    DMXDBG5("dmxCoreMotion(%d,%d,%d) dmxGlobalX=%d dmxGlobalY=%d\n",
-            x, y, delta, dmxGlobalX, dmxGlobalY);
-
-    dmxGlobalInvalid = 0;
-    dmxGlobalX       = x;
-    dmxGlobalY       = y;
-
-    if (dmxGlobalX < 0)                dmxGlobalX = 0;
-    if (dmxGlobalY < 0)                dmxGlobalY = 0;
-    if (dmxGlobalX >= dmxGlobalWidth)  dmxGlobalX = dmxGlobalWidth  + delta -1;
-    if (dmxGlobalY >= dmxGlobalHeight) dmxGlobalY = dmxGlobalHeight + delta -1;
-    
-    if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
-        localX = dmxGlobalX - dmxScreen->rootXOrigin;
-        localY = dmxGlobalY - dmxScreen->rootYOrigin;
-#if 00 /*BP*/
-        if ((pScreen = miPointerCurrentScreen())
-#else
-        if ((pScreen = miPointerGetScreen(inputInfo.pointer))
-#endif
-            && pScreen->myNum == dmxScreen->index) {
-                                /* Screen is old screen */
-            if (block) dmxSigioBlock();
-#if 00 /*BP*/
-            miPointerAbsoluteCursor(localX, localY, GetTimeInMillis());
-#else
-            miPointerSetPosition(inputInfo.pointer, &localX, &localY,
-                                 GetTimeInMillis());
-#endif
-            if (block) dmxSigioUnblock();
-        } else {
-                                /* Screen is new */
-            DMXDBG4("   New screen: old=%d new=%d localX=%d localY=%d\n",
-                    pScreen->myNum, dmxScreen->index, localX, localY);
-            if (block) dmxSigioBlock();
-            dmxeqProcessInputEvents();
-#if 00 /*BP*/
-            miPointerSetNewScreen(dmxScreen->index, localX, localY);
-            miPointerAbsoluteCursor(localX, localY, GetTimeInMillis());
-#else
-            miPointerSetScreen(inputInfo.pointer, dmxScreen->index,
-                               localX, localY);
-            miPointerSetPosition(inputInfo.pointer, &localX, &localY,
-                                 GetTimeInMillis());
-#endif
-            if (block) dmxSigioUnblock();
-        }
-#if 00 /*BP*/
-        miPointerPosition(&localX, &localY);
-#else
-        miPointerGetPosition(inputInfo.pointer, &localX, &localY);
-#endif
-
-#if 00 /*BP*/
-        if ((pScreen = miPointerCurrentScreen())) {
-#else
-        if ((pScreen = miPointerGetScreen(inputInfo.pointer))) {
-#endif
-            dmxGlobalX = localX + dmxScreens[pScreen->myNum].rootXOrigin;
-            dmxGlobalY = localY + dmxScreens[pScreen->myNum].rootYOrigin;
-            DMXDBG6("   Moved to dmxGlobalX=%d dmxGlobalY=%d"
-                    " on screen index=%d/%d localX=%d localY=%d\n",
-                    dmxGlobalX, dmxGlobalY,
-                    dmxScreen ? dmxScreen->index : -1, pScreen->myNum,
-                    localX, localY);
-        }
-    }
-                                /* Send updates down to all core input
-                                 * drivers */
-    for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) {
-        int j;
-
-        for (j = 0; j < dmxInput->numDevs; j += dmxInput->devs[j]->binding)
-            if (!dmxInput->detached
-                && dmxInput->devs[j]->sendsCore
-                && dmxInput->devs[j]->update_position)
-                dmxInput->devs[j]->update_position(dmxInput->devs[j]->private,
-                                                   dmxGlobalX, dmxGlobalY);
-    }
-    if (!dmxScreen) ProcessInputEvents();
-}
 
 
 
@@ -760,25 +647,20 @@ void dmxEnqueue(DevicePtr pDev, int type
             return;
         if (dmxLocal->sendsCore && dmxLocal != dmxLocalCoreKeyboard)
             xE.u.u.detail = dmxFixup(pDev, detail, keySym);
-#if 11/*BP*/
         {
            DeviceIntPtr p = dmxLocal->pDevice;
            int i, nevents;
            xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+           ErrorF("KEY %d\n", detail);
            nevents = GetKeyboardEvents(events, p, type, detail);
-           ErrorF("KEY %d  n=%d\n", detail, nevents);
            for (i = 0; i < nevents; i++)
               mieqEnqueue(p, events + i);
            xfree(events);
            return;
         }
-#endif
         break;
     case ButtonPress:
     case ButtonRelease:
-#if 00 /*BP*/
-        detail = dmxGetButtonMapping(dmxLocal, detail);
-#else
         detail = dmxGetButtonMapping(dmxLocal, detail);
         {
            DeviceIntPtr p = dmxLocal->pDevice;
@@ -799,15 +681,8 @@ void dmxEnqueue(DevicePtr pDev, int type
            xfree(events);
            return;
         }
-#endif
         break;
     case MotionNotify:
-        /* All MotionNotify events should be sent via dmxCoreMotion and
-         * dmxExtMotion -- no input driver should build motion events by
-         * hand. */
-#if 00 /*BP*/
-        dmxLog(dmxError, "dmxEnqueueXEvent: MotionNotify not allowed here\n");
-#else
         {
            DeviceIntPtr p = dmxLocal->pDevice;
            int i, nevents, valuators[3];
@@ -815,25 +690,14 @@ void dmxEnqueue(DevicePtr pDev, int type
            valuators[0] = e->xmotion.x;
            valuators[1] = e->xmotion.y;
            valuators[2] = e->xmotion.state;
-           nevents = GetPointerEvents(events,
-                                      /*pDev*/p,
-                                      /*KeyPress*/type,
-                                      detail,
-                                      POINTER_ABSOLUTE,
-                                      0, 3, valuators);
+           nevents = GetPointerEvents(events, p, type, detail, 
+                                      POINTER_ABSOLUTE, 0, 3, valuators);
            ErrorF("MOTION %d, %d  n = %d\n", valuators[0], valuators[1], nevents);
-           /*
-           ErrorF("NEW MOTION %d st %d (%d,%d,%d) n=%d\n",
-                  detail, e->xmotion.state,
-                  valuators[0], valuators[1], valuators[2],
-                  nevents);
-           */
            for (i = 0; i < nevents; i++)
               mieqEnqueue(p, events + i);
            xfree(events);
            return;
         }
-#endif
         break;
                                 /* Always ignore these events */
     case EnterNotify:
diff-tree 44eb15adeee3b299677070f39625daa53679bd13 (from 0f873a9d4f02b399c37b4058c6a9a2e21aa205e8)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 15:12:04 2007 -0600

    checkpoint clean-up

diff --git a/hw/dmx/input/dmxbackend.c b/hw/dmx/input/dmxbackend.c
index 315979e..7aa8510 100644
--- a/hw/dmx/input/dmxbackend.c
+++ b/hw/dmx/input/dmxbackend.c
@@ -242,11 +242,7 @@ static int dmxBackendOffscreen(int scree
 void dmxBackendUpdatePosition(pointer private, int x, int y)
 {
     GETPRIVFROMPRIVATE;
-#if 00 /*BP*/
-    int           screen      = miPointerCurrentScreen()->myNum;
-#else
     int           screen      = miPointerGetScreen(inputInfo.pointer)->myNum;
-#endif
     DMXScreenInfo *dmxScreen  = &dmxScreens[priv->myScreen];
     int           oldRelative = priv->relative;
     int           topscreen   = dmxBackendFindOverlapping(priv, screen, x, y);
@@ -397,7 +393,6 @@ void dmxBackendCollectEvents(DevicePtr p
             }
             break;
 	case MotionNotify:
-#if 001 /*BP*/
             DMXDBG9("dmxBackendCollectEvents: MotionNotify %d/%d (mi %d)"
                     " newscreen=%d: %d %d (e=%d; last=%d,%d)\n",
                     dmxScreen->index, priv->myScreen,
@@ -451,25 +446,15 @@ void dmxBackendCollectEvents(DevicePtr p
                         (dmxScreen->rootYOrigin + X.xmotion.y
                          - dmxScreen->rootY));
             }
-#else
-            /*
-            ErrorF("motion %d, %d, %d\n",
-                   X.xmotion.x, X.xmotion.y, X.xmotion.state);
-            */
-            enqueue(priv->mou, X.type, 0/*X.xbutton.button*/, 0, &X, block);
-#endif
 	    break;
 
         case KeyPress:
         case KeyRelease:
             enqueue(priv->kbd, X.type, X.xkey.keycode, 0, NULL, block);
             break;
-#if 11/*BP*/
         case ButtonPress:
         case ButtonRelease:
-           ErrorF("press/release at %d, %d\n", X.xbutton.x, X.xbutton.y);
-           /* fall-through */
-#endif
+            /* fall-through */
 	default:
                                 /* Pass the whole event here, because
                                  * this may be an extension event. */
diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index d174a59..3634324 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -194,30 +194,20 @@ DMXScreenInfo *dmxFindFirstScreen(int x,
 
 #if 11/*BP*/
 
+/**
+ * Enqueue a motion event.
+ */
 static void enqueueMotion(DevicePtr pDev, int x, int y)
 {
-    GETDMXINPUTFROMPDEV;
+    GETDMXLOCALFROMPDEV;
     DeviceIntPtr p = dmxLocal->pDevice;
     int i, nevents, valuators[3];
     xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-    int detail = 0;
-
+    int detail = 0;  /* XXX should this be mask of pressed buttons? */
     valuators[0] = x;
     valuators[1] = y;
-    valuators[2] = detail;
-    nevents = GetPointerEvents(events,
-                               /*pDev*/p,
-                               MotionNotify,
-                               detail,
-                               POINTER_ABSOLUTE,
-                               0, 2, valuators);
-    ErrorF("MOTION2 %d, %d  n = %d\n", valuators[0], valuators[1], nevents);
-    /*
-      ErrorF("NEW MOTION %d st %d (%d,%d,%d) n=%d\n",
-      detail, e->xmotion.state,
-      valuators[0], valuators[1], valuators[2],
-      nevents);
-    */
+    nevents = GetPointerEvents(events, p, MotionNotify, detail,
+                               POINTER_ABSOLUTE, 0, 2, valuators);
     for (i = 0; i < nevents; i++)
        mieqEnqueue(p, events + i);
     xfree(events);
@@ -347,8 +337,6 @@ void dmxCoreMotion(DevicePtr pDev, int x
     if (dmxGlobalX >= dmxGlobalWidth)  dmxGlobalX = dmxGlobalWidth  + delta -1;
     if (dmxGlobalY >= dmxGlobalHeight) dmxGlobalY = dmxGlobalHeight + delta -1;
     
-    ErrorF("Global Pos: %d, %d\n", dmxGlobalX, dmxGlobalY);
-
     if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
         localX = dmxGlobalX - dmxScreen->rootXOrigin;
         localY = dmxGlobalY - dmxScreen->rootYOrigin;
@@ -397,7 +385,6 @@ void dmxCoreMotion(DevicePtr pDev, int x
 #endif
             dmxGlobalX = localX + dmxScreens[pScreen->myNum].rootXOrigin;
             dmxGlobalY = localY + dmxScreens[pScreen->myNum].rootYOrigin;
-           ErrorF("Global is now %d, %d\n", dmxGlobalX, dmxGlobalY);
             DMXDBG6("   Moved to dmxGlobalX=%d dmxGlobalY=%d"
                     " on screen index=%d/%d localX=%d localY=%d\n",
                     dmxGlobalX, dmxGlobalY,
@@ -750,7 +737,7 @@ static int dmxFixup(DevicePtr pDev, int 
     return keyCode ? keyCode : detail;
 }
 
-/** Enqueue a non-motion event from the \a pDev device with the
+/** Enqueue an event from the \a pDev device with the
  * specified \a type and \a detail.  If the event is a KeyPress or
  * KeyRelease event, then the \a keySym is also specified.
  *
@@ -778,10 +765,7 @@ void dmxEnqueue(DevicePtr pDev, int type
            DeviceIntPtr p = dmxLocal->pDevice;
            int i, nevents;
            xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-           nevents = GetKeyboardEvents(events,
-                                       /*pDev*/p,
-                                       /*KeyPress*/type,
-                                       /*n*/detail);
+           nevents = GetKeyboardEvents(events, p, type, detail);
            ErrorF("KEY %d  n=%d\n", detail, nevents);
            for (i = 0; i < nevents; i++)
               mieqEnqueue(p, events + i);
@@ -795,6 +779,7 @@ void dmxEnqueue(DevicePtr pDev, int type
 #if 00 /*BP*/
         detail = dmxGetButtonMapping(dmxLocal, detail);
 #else
+        detail = dmxGetButtonMapping(dmxLocal, detail);
         {
            DeviceIntPtr p = dmxLocal->pDevice;
            int i, nevents, valuators[3];
diff-tree 0f873a9d4f02b399c37b4058c6a9a2e21aa205e8 (from 3a0ce1084a18e17a3c8a009d99c228652b8763a9)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 14:51:38 2007 -0600

    remove some debug code

diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index d14aeb7..a9d902e 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -505,7 +505,6 @@ static int dmxDeviceOnOff(DeviceIntPtr p
                                               GetMaximumEventsNum(),
 #endif
                                               Relative);
-                ErrorF("MOTION BUFFER SIZE %d\n", GetMaximumEventsNum());
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
@@ -588,10 +587,6 @@ static void dmxProcessInputEvents(DMXInp
 {
     int i;
 
-    /*
-    ErrorF("%s\n", __FUNCTION__);
-    */
-
     dmxeqProcessInputEvents();
 #if 00 /*BP*/
     miPointerUpdate();
diff-tree 3a0ce1084a18e17a3c8a009d99c228652b8763a9 (from 12016f20f7f5365f30cfbeb05568b3fb89759e5a)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 14:51:21 2007 -0600

    for completeness, init dummy's min/maxval[1] values (vertical axis)

diff --git a/hw/dmx/input/dmxdummy.c b/hw/dmx/input/dmxdummy.c
index d6e614e..b9c72b0 100644
--- a/hw/dmx/input/dmxdummy.c
+++ b/hw/dmx/input/dmxdummy.c
@@ -79,7 +79,9 @@ void dmxDummyMouGetInfo(DevicePtr pDev, 
     info->valuatorClass    = 1;
     info->numRelAxes       = 2;
     info->minval[0]        = 0;
+    info->minval[1]        = 0;
     info->maxval[0]        = 0;
+    info->maxval[1]        = 0;
     info->res[0]           = 1;
     info->minres[0]        = 0;
     info->maxres[0]        = 1;
diff-tree 12016f20f7f5365f30cfbeb05568b3fb89759e5a (from 0aaf28e5633a59563b89a2e42d19fabc84adc3ed)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 14:50:48 2007 -0600

    As for normal mouse device, init valuator maxval[] to real values, not zero.

diff --git a/hw/dmx/input/dmxconsole.c b/hw/dmx/input/dmxconsole.c
index 835909e..aac5e08 100644
--- a/hw/dmx/input/dmxconsole.c
+++ b/hw/dmx/input/dmxconsole.c
@@ -860,12 +860,17 @@ void dmxConsoleInit(DevicePtr pDev)
  * for pointers. */
 void dmxConsoleMouGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
 {
+    GETPRIVFROMPDEV;
+
     info->buttonClass      = 1;
     dmxCommonMouGetMap(pDev, info->map, &info->numButtons);
     info->valuatorClass    = 1;
     info->numRelAxes       = 2;
-    info->minval[0]        = 0;
-    info->maxval[0]        = 0;
+    info->minval[0] = 0;
+    info->minval[1] = 0;
+    /* max possible console window size: */
+    info->maxval[0] = DisplayWidth(priv->display, DefaultScreen(priv->display));
+    info->maxval[1] = DisplayHeight(priv->display, DefaultScreen(priv->display));
     info->res[0]           = 1;
     info->minres[0]        = 0;
     info->maxres[0]        = 1;
diff-tree 0aaf28e5633a59563b89a2e42d19fabc84adc3ed (from 0013bf6ddb3867c9a504603434d8c2ec83f3f3bc)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 12:41:30 2007 -0600

    In dmxBackendMouGetInfo() initialize the info->minval[], maxval[] arrays to the size of the backend display.
    
    It seems that the changes to X input exposed a problem that wasn't detected
    before.  The axis clipping code in GetPointerEvents() uses those limits to
    constrain the pointer's coordinate range.  The max was zero so the pointer
    couldn't move.

diff --git a/hw/dmx/input/dmxbackend.c b/hw/dmx/input/dmxbackend.c
index 09a2a32..315979e 100644
--- a/hw/dmx/input/dmxbackend.c
+++ b/hw/dmx/input/dmxbackend.c
@@ -592,12 +592,16 @@ void dmxBackendInit(DevicePtr pDev)
 /** Get information about the backend pointer (for initialization). */
 void dmxBackendMouGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
 {
+    const DMXScreenInfo *dmxScreen = dmxBackendInitPrivate(pDev);
+
     info->buttonClass      = 1;
     dmxCommonMouGetMap(pDev, info->map, &info->numButtons);
     info->valuatorClass    = 1;
     info->numRelAxes       = 2;
     info->minval[0]        = 0;
-    info->maxval[0]        = 0;
+    info->minval[1]        = 0;
+    info->maxval[0]        = dmxScreen->beWidth;
+    info->maxval[1]        = dmxScreen->beHeight;
     info->res[0]           = 1;
     info->minres[0]        = 0;
     info->maxres[0]        = 1;
diff-tree 0013bf6ddb3867c9a504603434d8c2ec83f3f3bc (from 08a88d1803f672555141011e082fbc0edeedcf05)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 12:39:04 2007 -0600

    undo 1280 valuator hack

diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index cf68051..d14aeb7 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -509,7 +509,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           1280/*info.maxval[0]*/, info.res[0],
+                                           info.maxval[0], info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numRelAxes) {
@@ -520,7 +520,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           1280/*info.maxval[0]*/, info.res[0],
+                                           info.maxval[0], info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numAbsAxes) {
@@ -531,7 +531,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numAbsAxes; i++)
                     InitValuatorAxisStruct(pDevice, i+info.numRelAxes,
-                                           info.minval[i+1], 1280/*info.maxval[i+1]*/,
+                                           info.minval[i+1], info.maxval[i+1],
                                            info.res[i+1], info.minres[i+1],
                                            info.maxres[i+1]);
 #endif
diff-tree 08a88d1803f672555141011e082fbc0edeedcf05 (from 70683e338dacc48e3adf489d66ec33b29dfc3b77)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 12:28:14 2007 -0600

    Pass num_valuators=0 for ButtonPress/Release. This seems to fix the button coordinate problem

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index fae2049..d174a59 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -799,20 +799,12 @@ void dmxEnqueue(DevicePtr pDev, int type
            DeviceIntPtr p = dmxLocal->pDevice;
            int i, nevents, valuators[3];
            xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-
-           valuators[0] = e->xbutton.x;
-           valuators[1] = e->xbutton.y;
-           /*
-           valuators[0] = dmxGlobalX;
-           valuators[1] = dmxGlobalY;
-           */
            valuators[2] = e->xbutton.button;
-           nevents = GetPointerEvents(events,
-                                      /*pDev*/p,
-                                      /*KeyPress*/type,
-                                      detail,
+           nevents = GetPointerEvents(events, p, type, detail,
                                       POINTER_ABSOLUTE,
-                                      0, 2/*3*/, valuators);
+                                      0,   /* first_valuator = 0 */
+                                      0,   /* num_valuators = 0 */
+                                      valuators);
 
            ErrorF("BUTTON %d, %d %d  n=%d\n",
                   valuators[0], valuators[1], valuators[2], nevents);
diff-tree 70683e338dacc48e3adf489d66ec33b29dfc3b77 (from f2808005f4ee72c5fd7f5f3dcca181306485113e)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Apr 2 12:26:27 2007 -0600

    formatting fixes

diff --git a/hw/dmx/input/dmxbackend.c b/hw/dmx/input/dmxbackend.c
index 7efb2ee..09a2a32 100644
--- a/hw/dmx/input/dmxbackend.c
+++ b/hw/dmx/input/dmxbackend.c
@@ -358,7 +358,8 @@ void dmxBackendCollectEvents(DevicePtr p
 	switch (X.type) {
         case EnterNotify:
             dmxCommonSaveState(priv);
-            if (entered++) continue;
+            if (entered++)
+                continue;
             priv->entered = 1;
             ignoreLeave   = 1;
             DMXDBG5("dmxBackendCollectEvents: Enter %lu %d,%d; GRAB %s %p\n",
@@ -382,7 +383,8 @@ void dmxBackendCollectEvents(DevicePtr p
                 continue;
             }
             dmxCommonRestoreState(priv);
-            if (left++) continue;
+            if (left++)
+                continue;
             DMXDBG7("dmxBackendCollectEvents: Leave %lu %d,%d %d %d %s %s\n",
                     X.xcrossing.root, X.xcrossing.x, X.xcrossing.y,
                     X.xcrossing.detail, X.xcrossing.focus,
@@ -403,7 +405,8 @@ void dmxBackendCollectEvents(DevicePtr p
                     priv->newscreen,
                     X.xmotion.x, X.xmotion.y,
                     entered, priv->lastX, priv->lastY);
-            if (dmxBackendPendingMotionEvent(priv, TRUE)) continue;
+            if (dmxBackendPendingMotionEvent(priv, TRUE))
+                continue;
             if (!(dmxScreen = dmxBackendFindWindow(priv, X.xmotion.window)))
                 dmxLog(dmxFatal,
                        "   Event on non-existant window %lu\n",
diff-tree f2808005f4ee72c5fd7f5f3dcca181306485113e (from 5257b32e492bd2082bef6a4cd0fea03ce093c0f8)
Author: Alberto Mardegan <mardy at users.sourceforge.net>
Date:   Sat Mar 31 16:51:24 2007 +0200

    Bug #6620: Fixed a missing 'else' in ATIPseudoDMAInit().
    
    Before this, we'd write some registers twice on R200 hardware and also
    possibly end up with a bad value in atis->cce_pri_size.

diff --git a/hw/kdrive/ati/ati_dma.c b/hw/kdrive/ati/ati_dma.c
index f75ff12..70b86d3 100644
--- a/hw/kdrive/ati/ati_dma.c
+++ b/hw/kdrive/ati/ati_dma.c
@@ -788,7 +788,7 @@ ATIPseudoDMAInit(ScreenPtr pScreen)
 		atis->cce_pri_size = MMIO_IN32(mmio, RADEON_REG_CP_CSQ_CNTL) &
 		    R200_CSQ_CNT_PRIMARY_MASK;
 		MMIO_OUT32(mmio, RADEON_REG_ME_CNTL, RADEON_ME_MODE_FREE_RUN);
-	} if (atic->is_radeon) {
+	} else if (atic->is_radeon) {
 		MMIO_OUT32(mmio, RADEON_REG_CP_CSQ_CNTL,
 		    RADEON_CSQ_PRIPIO_INDDIS);
 		atis->cce_pri_size = MMIO_IN32(mmio, RADEON_REG_CP_CSQ_CNTL) &
diff-tree 5257b32e492bd2082bef6a4cd0fea03ce093c0f8 (from 73fdc16bc4f4e21ff604b3f9ded23b40398fb1b6)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Wed Mar 28 15:51:24 2007 -0700

    Bump video driver ABI to 2.0 for cw change (commit 6ed08949af4f7ac09170d3d9581e4092b24a84ee).

diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index 2811839..8e644c4 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -84,7 +84,7 @@ typedef enum {
  * mask is 0xFFFF0000.
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 3)
-#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(1, 2)
+#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(2, 0)
 #define ABI_XINPUT_VERSION	SET_ABI_VERSION(1, 0)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(0, 3)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 5)
diff-tree 73fdc16bc4f4e21ff604b3f9ded23b40398fb1b6 (from ebdc8ce5c108dc3b6b0004e7c7939d1a5bef8676)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Mar 30 16:07:26 2007 -0600

    formatting fixes

diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index d76dd9b..cf68051 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -472,8 +472,10 @@ static int dmxDeviceOnOff(DeviceIntPtr p
     memset(&info, 0, sizeof(info));
     switch (what) {
     case DEVICE_INIT:
-        if (dmxLocal->init) dmxLocal->init(pDev);
-        if (dmxLocal->get_info) dmxLocal->get_info(pDev, &info);
+        if (dmxLocal->init)
+            dmxLocal->init(pDev);
+        if (dmxLocal->get_info)
+            dmxLocal->get_info(pDev, &info);
         if (info.keyboard) {    /* XKEYBOARD makes this a special case */
             dmxKeyboardOn(pDevice, &info);
             break;
@@ -594,7 +596,8 @@ static void dmxProcessInputEvents(DMXInp
 #if 00 /*BP*/
     miPointerUpdate();
 #endif
-    if (dmxInput->detached) return;
+    if (dmxInput->detached)
+        return;
     for (i = 0; i < dmxInput->numDevs; i += dmxInput->devs[i]->binding)
         if (dmxInput->devs[i]->process_input) {
 #if 11 /*BP*/
@@ -633,7 +636,8 @@ static void dmxUpdateWindowInformation(D
     }
 #endif
 
-    if (dmxInput->detached) return;
+    if (dmxInput->detached)
+        return;
     for (i = 0; i < dmxInput->numDevs; i += dmxInput->devs[i]->binding)
         if (dmxInput->devs[i]->update_info)
             dmxInput->devs[i]->update_info(dmxInput->devs[i]->private,
@@ -644,7 +648,8 @@ static void dmxCollectAll(DMXInputInfo *
 {
     int i;
 
-    if (dmxInput->detached) return;
+    if (dmxInput->detached)
+        return;
     for (i = 0; i < dmxInput->numDevs; i += dmxInput->devs[i]->binding)
         if (dmxInput->devs[i]->collect_events)
             dmxInput->devs[i]->collect_events(&dmxInput->devs[i]
@@ -741,7 +746,8 @@ static DeviceIntPtr dmxAddDevice(DMXLoca
     char         *devname;
     DMXInputInfo *dmxInput;
 
-    if (!dmxLocal) return NULL;
+    if (!dmxLocal)
+        return NULL;
     dmxInput = &dmxInputs[dmxLocal->inputIdx];
 
     if (dmxLocal->sendsCore) {
diff-tree ebdc8ce5c108dc3b6b0004e7c7939d1a5bef8676 (from 3c7413e0c2f87e154aa8aa4a83bd585a6d1091e8)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Mar 30 16:05:46 2007 -0600

    Checkpoint DMX updates: things are working much better now, but still not 100% right.
    
    Use new dmxCoreMotion2() function which enqueues motion events with
    GetPointerEvents()/mieqEnqueue().
    The clipAxis() code in GetPointerEvents() is causing some grief.  The
    limits seem to have always been (0,0) according to the original calls
    to InitValuatorAxisStruct() in dmxinputinit.c.
    Terrible hack for now: Call InitValuatorAxisStruct() with hard-coded max
    values of 1280 (my screen width).

diff --git a/hw/dmx/dmxcursor.c b/hw/dmx/dmxcursor.c
index 11c89d8..a7d9378 100644
--- a/hw/dmx/dmxcursor.c
+++ b/hw/dmx/dmxcursor.c
@@ -889,7 +889,7 @@ static void dmxSetCursor(ScreenPtr pScre
     gx = start->rootXOrigin + x;
     gy = start->rootYOrigin + y;
     if (x && y && (GX != gx || GY != gy))
-        dmxCoreMotion(gx, gy, 0, DMX_NO_BLOCK);
+        dmxCoreMotion(NULL, gx, gy, 0, DMX_NO_BLOCK);
     
     if (!start->over || !dmxCursorDoMultiCursors || start->cursorNotShared) {
         _dmxSetCursor(pScreen, pCursor, x, y);
diff --git a/hw/dmx/dmxinput.h b/hw/dmx/dmxinput.h
index 59fa823..3fb5870 100644
--- a/hw/dmx/dmxinput.h
+++ b/hw/dmx/dmxinput.h
@@ -154,7 +154,7 @@ typedef enum {
 
 extern void          dmxGetGlobalPosition(int *x, int *y);
 extern DMXScreenInfo *dmxFindFirstScreen(int x, int y);
-extern void          dmxCoreMotion(int x, int y, int delta,
+extern void          dmxCoreMotion(DevicePtr pDev, int x, int y, int delta,
                                    DMXBlockType block);
 
 /* Support for dynamic addition of inputs.  This functions is defined in
diff --git a/hw/dmx/input/dmxbackend.c b/hw/dmx/input/dmxbackend.c
index 61d1bfe..7efb2ee 100644
--- a/hw/dmx/input/dmxbackend.c
+++ b/hw/dmx/input/dmxbackend.c
@@ -395,7 +395,7 @@ void dmxBackendCollectEvents(DevicePtr p
             }
             break;
 	case MotionNotify:
-#if 00 /*BP*/
+#if 001 /*BP*/
             DMXDBG9("dmxBackendCollectEvents: MotionNotify %d/%d (mi %d)"
                     " newscreen=%d: %d %d (e=%d; last=%d,%d)\n",
                     dmxScreen->index, priv->myScreen,
diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 0cc3054..fae2049 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -191,7 +191,42 @@ DMXScreenInfo *dmxFindFirstScreen(int x,
     return NULL;
 }
 
-void dmxCoreMotion(int x, int y, int delta, DMXBlockType block)
+
+#if 11/*BP*/
+
+static void enqueueMotion(DevicePtr pDev, int x, int y)
+{
+    GETDMXINPUTFROMPDEV;
+    DeviceIntPtr p = dmxLocal->pDevice;
+    int i, nevents, valuators[3];
+    xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+    int detail = 0;
+
+    valuators[0] = x;
+    valuators[1] = y;
+    valuators[2] = detail;
+    nevents = GetPointerEvents(events,
+                               /*pDev*/p,
+                               MotionNotify,
+                               detail,
+                               POINTER_ABSOLUTE,
+                               0, 2, valuators);
+    ErrorF("MOTION2 %d, %d  n = %d\n", valuators[0], valuators[1], nevents);
+    /*
+      ErrorF("NEW MOTION %d st %d (%d,%d,%d) n=%d\n",
+      detail, e->xmotion.state,
+      valuators[0], valuators[1], valuators[2],
+      nevents);
+    */
+    for (i = 0; i < nevents; i++)
+       mieqEnqueue(p, events + i);
+    xfree(events);
+    return;
+}
+
+
+static void
+dmxCoreMotion2(DevicePtr pDev, int x, int y, int delta, DMXBlockType block)
 {
     DMXScreenInfo *dmxScreen;
     DMXInputInfo  *dmxInput;
@@ -214,6 +249,106 @@ void dmxCoreMotion(int x, int y, int del
     if (dmxGlobalX >= dmxGlobalWidth)  dmxGlobalX = dmxGlobalWidth  + delta -1;
     if (dmxGlobalY >= dmxGlobalHeight) dmxGlobalY = dmxGlobalHeight + delta -1;
     
+    ErrorF("Global Pos: %d, %d\n", dmxGlobalX, dmxGlobalY);
+
+    if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
+        localX = dmxGlobalX - dmxScreen->rootXOrigin;
+        localY = dmxGlobalY - dmxScreen->rootYOrigin;
+        if ((pScreen = miPointerGetScreen(inputInfo.pointer))
+            && pScreen->myNum == dmxScreen->index) {
+                                /* Screen is old screen */
+            if (block)
+                dmxSigioBlock();
+#if 000
+            miPointerSetPosition(inputInfo.pointer, &localX, &localY,
+                                 GetTimeInMillis());
+#else
+            if (pDev)
+               enqueueMotion(pDev, localX, localY);
+#endif
+            if (block)
+                dmxSigioUnblock();
+        } else {
+                                /* Screen is new */
+            DMXDBG4("   New screen: old=%d new=%d localX=%d localY=%d\n",
+                    pScreen->myNum, dmxScreen->index, localX, localY);
+            if (block)
+                dmxSigioBlock();
+            dmxeqProcessInputEvents();
+            miPointerSetScreen(inputInfo.pointer, dmxScreen->index,
+                               localX, localY);
+#if 000
+            miPointerSetPosition(inputInfo.pointer, &localX, &localY,
+                                 GetTimeInMillis());
+#else
+            if (pDev)
+               enqueueMotion(pDev, localX, localY);
+#endif
+            if (block)
+                dmxSigioUnblock();
+        }
+#if 00
+        miPointerGetPosition(inputInfo.pointer, &localX, &localY);
+
+        if ((pScreen = miPointerGetScreen(inputInfo.pointer))) {
+            dmxGlobalX = localX + dmxScreens[pScreen->myNum].rootXOrigin;
+            dmxGlobalY = localY + dmxScreens[pScreen->myNum].rootYOrigin;
+            ErrorF("Global is now %d, %d  %d, %d\n", dmxGlobalX, dmxGlobalY,
+                   localX, localY);
+            DMXDBG6("   Moved to dmxGlobalX=%d dmxGlobalY=%d"
+                    " on screen index=%d/%d localX=%d localY=%d\n",
+                    dmxGlobalX, dmxGlobalY,
+                    dmxScreen ? dmxScreen->index : -1, pScreen->myNum,
+                    localX, localY);
+        }
+#endif
+    }
+                                /* Send updates down to all core input
+                                 * drivers */
+    for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) {
+        int j;
+
+        for (j = 0; j < dmxInput->numDevs; j += dmxInput->devs[j]->binding)
+            if (!dmxInput->detached
+                && dmxInput->devs[j]->sendsCore
+                && dmxInput->devs[j]->update_position)
+                dmxInput->devs[j]->update_position(dmxInput->devs[j]->private,
+                                                   dmxGlobalX, dmxGlobalY);
+    }
+    if (!dmxScreen) ProcessInputEvents();
+}
+#endif
+
+void dmxCoreMotion(DevicePtr pDev, int x, int y, int delta, DMXBlockType block)
+{
+    DMXScreenInfo *dmxScreen;
+    DMXInputInfo  *dmxInput;
+    ScreenPtr     pScreen;
+    int           localX;
+    int           localY;
+    int           i;
+
+#if 11/*BP*/
+    dmxCoreMotion2(pDev, x, y, delta, block);
+    return;
+#endif
+
+    if (!dmxGlobalInvalid && dmxGlobalX == x && dmxGlobalY == y) return;
+    
+    DMXDBG5("dmxCoreMotion(%d,%d,%d) dmxGlobalX=%d dmxGlobalY=%d\n",
+            x, y, delta, dmxGlobalX, dmxGlobalY);
+
+    dmxGlobalInvalid = 0;
+    dmxGlobalX       = x;
+    dmxGlobalY       = y;
+
+    if (dmxGlobalX < 0)                dmxGlobalX = 0;
+    if (dmxGlobalY < 0)                dmxGlobalY = 0;
+    if (dmxGlobalX >= dmxGlobalWidth)  dmxGlobalX = dmxGlobalWidth  + delta -1;
+    if (dmxGlobalY >= dmxGlobalHeight) dmxGlobalY = dmxGlobalHeight + delta -1;
+    
+    ErrorF("Global Pos: %d, %d\n", dmxGlobalX, dmxGlobalY);
+
     if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
         localX = dmxGlobalX - dmxScreen->rootXOrigin;
         localY = dmxGlobalY - dmxScreen->rootYOrigin;
@@ -285,6 +420,8 @@ void dmxCoreMotion(int x, int y, int del
     if (!dmxScreen) ProcessInputEvents();
 }
 
+
+
 #ifdef XINPUT
 #define DMX_MAX_AXES 32         /* Max axes reported by this routine */
 static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
@@ -534,12 +671,18 @@ void dmxMotion(DevicePtr pDev, int *v, i
         return;
     }
 #endif
-    if (axesCount == 2) switch (type) {
-      case DMX_RELATIVE:          dmxCoreMotion(dmxGlobalX - v[0],
-                                                dmxGlobalY - v[1],
-                                                0, block);              break;
-      case DMX_ABSOLUTE:          dmxCoreMotion(v[0], v[1], 0, block);  break;
-      case DMX_ABSOLUTE_CONFINED: dmxCoreMotion(v[0], v[1], -1, block); break;
+    if (axesCount == 2) {
+        switch (type) {
+        case DMX_RELATIVE:
+            dmxCoreMotion(pDev, dmxGlobalX - v[0], dmxGlobalY - v[1], 0, block);
+            break;
+        case DMX_ABSOLUTE:
+            dmxCoreMotion(pDev, v[0], v[1], 0, block);
+            break;
+        case DMX_ABSOLUTE_CONFINED:
+            dmxCoreMotion(pDev, v[0], v[1], -1, block);
+            break;
+        }
     }
 }
 
@@ -669,7 +812,7 @@ void dmxEnqueue(DevicePtr pDev, int type
                                       /*KeyPress*/type,
                                       detail,
                                       POINTER_ABSOLUTE,
-                                      0, 3, valuators);
+                                      0, 2/*3*/, valuators);
 
            ErrorF("BUTTON %d, %d %d  n=%d\n",
                   valuators[0], valuators[1], valuators[2], nevents);
diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index 1465ade..d76dd9b 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -507,7 +507,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           info.maxval[0], info.res[0],
+                                           1280/*info.maxval[0]*/, info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numRelAxes) {
@@ -518,7 +518,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           info.maxval[0], info.res[0],
+                                           1280/*info.maxval[0]*/, info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numAbsAxes) {
@@ -529,7 +529,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numAbsAxes; i++)
                     InitValuatorAxisStruct(pDevice, i+info.numRelAxes,
-                                           info.minval[i+1], info.maxval[i+1],
+                                           info.minval[i+1], 1280/*info.maxval[i+1]*/,
                                            info.res[i+1], info.minres[i+1],
                                            info.maxres[i+1]);
 #endif
diff-tree 3c7413e0c2f87e154aa8aa4a83bd585a6d1091e8 (from 7989dacdcb1449b10d7733dda11cd96e260e9fae)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Mar 30 14:07:04 2007 -0600

    Tweak some parameters, etc.  Things seem a little better now, but still a ways to go.

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 3027457..0cc3054 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -262,6 +262,7 @@ void dmxCoreMotion(int x, int y, int del
 #endif
             dmxGlobalX = localX + dmxScreens[pScreen->myNum].rootXOrigin;
             dmxGlobalY = localY + dmxScreens[pScreen->myNum].rootYOrigin;
+           ErrorF("Global is now %d, %d\n", dmxGlobalX, dmxGlobalY);
             DMXDBG6("   Moved to dmxGlobalX=%d dmxGlobalY=%d"
                     " on screen index=%d/%d localX=%d localY=%d\n",
                     dmxGlobalX, dmxGlobalY,
@@ -655,19 +656,20 @@ void dmxEnqueue(DevicePtr pDev, int type
            DeviceIntPtr p = dmxLocal->pDevice;
            int i, nevents, valuators[3];
            xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-           /*
+
            valuators[0] = e->xbutton.x;
            valuators[1] = e->xbutton.y;
-           */
+           /*
            valuators[0] = dmxGlobalX;
            valuators[1] = dmxGlobalY;
+           */
            valuators[2] = e->xbutton.button;
            nevents = GetPointerEvents(events,
                                       /*pDev*/p,
                                       /*KeyPress*/type,
                                       detail,
                                       POINTER_ABSOLUTE,
-                                      0, 1, valuators);
+                                      0, 3, valuators);
 
            ErrorF("BUTTON %d, %d %d  n=%d\n",
                   valuators[0], valuators[1], valuators[2], nevents);
@@ -698,7 +700,7 @@ void dmxEnqueue(DevicePtr pDev, int type
                                       /*KeyPress*/type,
                                       detail,
                                       POINTER_ABSOLUTE,
-                                      0, 1, valuators);
+                                      0, 3, valuators);
            ErrorF("MOTION %d, %d  n = %d\n", valuators[0], valuators[1], nevents);
            /*
            ErrorF("NEW MOTION %d st %d (%d,%d,%d) n=%d\n",
diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index c098c46..1465ade 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -507,7 +507,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           /*1280*/info.maxval[0], info.res[0],
+                                           info.maxval[0], info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numRelAxes) {
@@ -518,7 +518,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           /*1280*/info.maxval[0], info.res[0],
+                                           info.maxval[0], info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numAbsAxes) {
@@ -529,7 +529,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numAbsAxes; i++)
                     InitValuatorAxisStruct(pDevice, i+info.numRelAxes,
-                                           info.minval[i+1], /*1280*/info.maxval[i+1],
+                                           info.minval[i+1], info.maxval[i+1],
                                            info.res[i+1], info.minres[i+1],
                                            info.maxres[i+1]);
 #endif
diff-tree 7989dacdcb1449b10d7733dda11cd96e260e9fae (from 1ea842960fddbc6363cc6e7f914d70ba45525a6b)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Mar 30 13:44:24 2007 -0600

    num_valuators=1 for GetPointerEvents(), hack ButtonPress/Release position

diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 9a31ba6..3027457 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -655,19 +655,19 @@ void dmxEnqueue(DevicePtr pDev, int type
            DeviceIntPtr p = dmxLocal->pDevice;
            int i, nevents, valuators[3];
            xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+           /*
            valuators[0] = e->xbutton.x;
            valuators[1] = e->xbutton.y;
-           /*
+           */
            valuators[0] = dmxGlobalX;
            valuators[1] = dmxGlobalY;
-           */
            valuators[2] = e->xbutton.button;
            nevents = GetPointerEvents(events,
                                       /*pDev*/p,
                                       /*KeyPress*/type,
                                       detail,
                                       POINTER_ABSOLUTE,
-                                      0, 0, valuators);
+                                      0, 1, valuators);
 
            ErrorF("BUTTON %d, %d %d  n=%d\n",
                   valuators[0], valuators[1], valuators[2], nevents);
@@ -698,7 +698,7 @@ void dmxEnqueue(DevicePtr pDev, int type
                                       /*KeyPress*/type,
                                       detail,
                                       POINTER_ABSOLUTE,
-                                      0, 0, valuators);
+                                      0, 1, valuators);
            ErrorF("MOTION %d, %d  n = %d\n", valuators[0], valuators[1], nevents);
            /*
            ErrorF("NEW MOTION %d st %d (%d,%d,%d) n=%d\n",
diff-tree 1ea842960fddbc6363cc6e7f914d70ba45525a6b (from 92e8cdbd32b0d86cabd4ad88e3240bf90c018b9a)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Mar 30 13:43:15 2007 -0600

    more debug

diff --git a/hw/dmx/input/dmxbackend.c b/hw/dmx/input/dmxbackend.c
index 48de4c9..61d1bfe 100644
--- a/hw/dmx/input/dmxbackend.c
+++ b/hw/dmx/input/dmxbackend.c
@@ -464,9 +464,8 @@ void dmxBackendCollectEvents(DevicePtr p
 #if 11/*BP*/
         case ButtonPress:
         case ButtonRelease:
-           /*
            ErrorF("press/release at %d, %d\n", X.xbutton.x, X.xbutton.y);
-           */
+           /* fall-through */
 #endif
 	default:
                                 /* Pass the whole event here, because
diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 90b45a9..9a31ba6 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -638,9 +638,7 @@ void dmxEnqueue(DevicePtr pDev, int type
                                        /*pDev*/p,
                                        /*KeyPress*/type,
                                        /*n*/detail);
-           /*
-           ErrorF("NEW KEY EVENT %d  n=%d\n", detail, nevents);
-           */
+           ErrorF("KEY %d  n=%d\n", detail, nevents);
            for (i = 0; i < nevents; i++)
               mieqEnqueue(p, events + i);
            xfree(events);
@@ -659,6 +657,10 @@ void dmxEnqueue(DevicePtr pDev, int type
            xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
            valuators[0] = e->xbutton.x;
            valuators[1] = e->xbutton.y;
+           /*
+           valuators[0] = dmxGlobalX;
+           valuators[1] = dmxGlobalY;
+           */
            valuators[2] = e->xbutton.button;
            nevents = GetPointerEvents(events,
                                       /*pDev*/p,
@@ -666,11 +668,10 @@ void dmxEnqueue(DevicePtr pDev, int type
                                       detail,
                                       POINTER_ABSOLUTE,
                                       0, 0, valuators);
-           /*
-           ErrorF("NEW PTR EVENT %d (%d,%d,%d) n=%d\n",
-                  detail, valuators[0], valuators[1], valuators[2],
-                  nevents);
-           */
+
+           ErrorF("BUTTON %d, %d %d  n=%d\n",
+                  valuators[0], valuators[1], valuators[2], nevents);
+
            for (i = 0; i < nevents; i++)
               mieqEnqueue(p, events + i);
            xfree(events);
@@ -698,6 +699,7 @@ void dmxEnqueue(DevicePtr pDev, int type
                                       detail,
                                       POINTER_ABSOLUTE,
                                       0, 0, valuators);
+           ErrorF("MOTION %d, %d  n = %d\n", valuators[0], valuators[1], nevents);
            /*
            ErrorF("NEW MOTION %d st %d (%d,%d,%d) n=%d\n",
                   detail, e->xmotion.state,
diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index 7c0ae58..c098c46 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -503,10 +503,11 @@ static int dmxDeviceOnOff(DeviceIntPtr p
                                               GetMaximumEventsNum(),
 #endif
                                               Relative);
+                ErrorF("MOTION BUFFER SIZE %d\n", GetMaximumEventsNum());
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           info.maxval[0], info.res[0],
+                                           /*1280*/info.maxval[0], info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numRelAxes) {
@@ -517,7 +518,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
                     InitValuatorAxisStruct(pDevice, i, info.minval[0],
-                                           info.maxval[0], info.res[0],
+                                           /*1280*/info.maxval[0], info.res[0],
                                            info.minres[0], info.maxres[0]);
 #endif
             } else if (info.numAbsAxes) {
@@ -528,7 +529,7 @@ static int dmxDeviceOnOff(DeviceIntPtr p
 #ifdef XINPUT
                 for (i = 0; i < info.numAbsAxes; i++)
                     InitValuatorAxisStruct(pDevice, i+info.numRelAxes,
-                                           info.minval[i+1], info.maxval[i+1],
+                                           info.minval[i+1], /*1280*/info.maxval[i+1],
                                            info.res[i+1], info.minres[i+1],
                                            info.maxres[i+1]);
 #endif
diff-tree 92e8cdbd32b0d86cabd4ad88e3240bf90c018b9a (from d92da3d5f309392ac398c0975ef17bb04312d5e2)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Mar 30 13:19:33 2007 -0600

    Checkpoint fixes to DMX for X input changes.
    
    Xdmx builds and runs now.
    Keyboard seems OK, and mouse pointer moves, but everything else is flakey.
    Something is still seriously wrong.

diff --git a/hw/dmx/dmxcursor.c b/hw/dmx/dmxcursor.c
index 09b50b8..11c89d8 100644
--- a/hw/dmx/dmxcursor.c
+++ b/hw/dmx/dmxcursor.c
@@ -182,7 +182,12 @@ static void dmxCrossScreen(ScreenPtr pSc
 static void dmxWarpCursor(ScreenPtr pScreen, int x, int y)
 {
     DMXDBG3("dmxWarpCursor(%d,%d,%d)\n", pScreen->myNum, x, y);
+#if 11 /*BP*/
+    /* This call is depracated.  Replace with???? */
     miPointerWarpCursor(pScreen, x, y);
+#else
+    pScreen->SetCursorPosition(pScreen, x, y, FALSE);
+#endif
 }
 
 miPointerScreenFuncRec dmxPointerCursorFuncs =
@@ -190,7 +195,7 @@ miPointerScreenFuncRec dmxPointerCursorF
     dmxCursorOffScreen,
     dmxCrossScreen,
     dmxWarpCursor,
-    dmxeqEnqueue,
+    dmxeqEnqueue,        /*XXX incompatible type/function! */
     dmxeqSwitchScreen
 };
 
@@ -939,8 +944,13 @@ void dmxCheckCursor(void)
         pScreen                  = screenInfo.screens[dmxScreen->index];
 
         if (!dmxOnScreen(x, y, dmxScreen)) {
+#if 00
             if (firstScreen && i == miPointerCurrentScreen()->myNum)
                 miPointerSetNewScreen(firstScreen->index, x, y);
+#else
+            if (firstScreen && i == miPointerGetScreen(inputInfo.pointer)->myNum)
+                miPointerSetScreen(inputInfo.pointer, firstScreen->index, x, y);
+#endif
             _dmxSetCursor(pScreen, NULL,
                           x - dmxScreen->rootXOrigin,
                           y - dmxScreen->rootYOrigin);
diff --git a/hw/dmx/dmxinput.c b/hw/dmx/dmxinput.c
index 37f4583..f47899c 100644
--- a/hw/dmx/dmxinput.c
+++ b/hw/dmx/dmxinput.c
@@ -49,6 +49,7 @@
 
 #include "inputstr.h"
 #include "input.h"
+#include "mi.h"
 
 /** Returns TRUE if the key is a valid modifier.  For PC-class
  * keyboards, all keys can be used as modifiers, so return TRUE
@@ -75,6 +76,8 @@ void InitInput(int argc, char **argv)
         dmxLog(dmxWarning, "Use keyboard/mouse pair with the first -input\n");
         dmxLog(dmxFatal,   "At least one core keyboard/mouse pair required\n");
     }
+
+    mieqInit();
 }
 
 /** Called from dix/dispatch.c in Dispatch() whenever input events
diff --git a/hw/dmx/input/dmxbackend.c b/hw/dmx/input/dmxbackend.c
index 8985a1b..48de4c9 100644
--- a/hw/dmx/input/dmxbackend.c
+++ b/hw/dmx/input/dmxbackend.c
@@ -242,7 +242,11 @@ static int dmxBackendOffscreen(int scree
 void dmxBackendUpdatePosition(pointer private, int x, int y)
 {
     GETPRIVFROMPRIVATE;
+#if 00 /*BP*/
     int           screen      = miPointerCurrentScreen()->myNum;
+#else
+    int           screen      = miPointerGetScreen(inputInfo.pointer)->myNum;
+#endif
     DMXScreenInfo *dmxScreen  = &dmxScreens[priv->myScreen];
     int           oldRelative = priv->relative;
     int           topscreen   = dmxBackendFindOverlapping(priv, screen, x, y);
@@ -391,6 +395,7 @@ void dmxBackendCollectEvents(DevicePtr p
             }
             break;
 	case MotionNotify:
+#if 00 /*BP*/
             DMXDBG9("dmxBackendCollectEvents: MotionNotify %d/%d (mi %d)"
                     " newscreen=%d: %d %d (e=%d; last=%d,%d)\n",
                     dmxScreen->index, priv->myScreen,
@@ -443,12 +448,26 @@ void dmxBackendCollectEvents(DevicePtr p
                         (dmxScreen->rootYOrigin + X.xmotion.y
                          - dmxScreen->rootY));
             }
+#else
+            /*
+            ErrorF("motion %d, %d, %d\n",
+                   X.xmotion.x, X.xmotion.y, X.xmotion.state);
+            */
+            enqueue(priv->mou, X.type, 0/*X.xbutton.button*/, 0, &X, block);
+#endif
 	    break;
 
         case KeyPress:
         case KeyRelease:
             enqueue(priv->kbd, X.type, X.xkey.keycode, 0, NULL, block);
             break;
+#if 11/*BP*/
+        case ButtonPress:
+        case ButtonRelease:
+           /*
+           ErrorF("press/release at %d, %d\n", X.xbutton.x, X.xbutton.y);
+           */
+#endif
 	default:
                                 /* Pass the whole event here, because
                                  * this may be an extension event. */
diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 5316f0f..90b45a9 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -56,6 +56,7 @@
 #include "opaque.h"
 #include "inputstr.h"
 #include "mipointer.h"
+#include "mi.h"
 
 #ifdef XINPUT
 #include "XIstubs.h"
@@ -216,11 +217,20 @@ void dmxCoreMotion(int x, int y, int del
     if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
         localX = dmxGlobalX - dmxScreen->rootXOrigin;
         localY = dmxGlobalY - dmxScreen->rootYOrigin;
+#if 00 /*BP*/
         if ((pScreen = miPointerCurrentScreen())
+#else
+        if ((pScreen = miPointerGetScreen(inputInfo.pointer))
+#endif
             && pScreen->myNum == dmxScreen->index) {
                                 /* Screen is old screen */
             if (block) dmxSigioBlock();
+#if 00 /*BP*/
             miPointerAbsoluteCursor(localX, localY, GetTimeInMillis());
+#else
+            miPointerSetPosition(inputInfo.pointer, &localX, &localY,
+                                 GetTimeInMillis());
+#endif
             if (block) dmxSigioUnblock();
         } else {
                                 /* Screen is new */
@@ -228,13 +238,28 @@ void dmxCoreMotion(int x, int y, int del
                     pScreen->myNum, dmxScreen->index, localX, localY);
             if (block) dmxSigioBlock();
             dmxeqProcessInputEvents();
+#if 00 /*BP*/
             miPointerSetNewScreen(dmxScreen->index, localX, localY);
             miPointerAbsoluteCursor(localX, localY, GetTimeInMillis());
+#else
+            miPointerSetScreen(inputInfo.pointer, dmxScreen->index,
+                               localX, localY);
+            miPointerSetPosition(inputInfo.pointer, &localX, &localY,
+                                 GetTimeInMillis());
+#endif
             if (block) dmxSigioUnblock();
         }
+#if 00 /*BP*/
         miPointerPosition(&localX, &localY);
+#else
+        miPointerGetPosition(inputInfo.pointer, &localX, &localY);
+#endif
 
+#if 00 /*BP*/
         if ((pScreen = miPointerCurrentScreen())) {
+#else
+        if ((pScreen = miPointerGetScreen(inputInfo.pointer))) {
+#endif
             dmxGlobalX = localX + dmxScreens[pScreen->myNum].rootXOrigin;
             dmxGlobalY = localY + dmxScreens[pScreen->myNum].rootYOrigin;
             DMXDBG6("   Moved to dmxGlobalX=%d dmxGlobalY=%d"
@@ -604,16 +629,87 @@ void dmxEnqueue(DevicePtr pDev, int type
             return;
         if (dmxLocal->sendsCore && dmxLocal != dmxLocalCoreKeyboard)
             xE.u.u.detail = dmxFixup(pDev, detail, keySym);
+#if 11/*BP*/
+        {
+           DeviceIntPtr p = dmxLocal->pDevice;
+           int i, nevents;
+           xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+           nevents = GetKeyboardEvents(events,
+                                       /*pDev*/p,
+                                       /*KeyPress*/type,
+                                       /*n*/detail);
+           /*
+           ErrorF("NEW KEY EVENT %d  n=%d\n", detail, nevents);
+           */
+           for (i = 0; i < nevents; i++)
+              mieqEnqueue(p, events + i);
+           xfree(events);
+           return;
+        }
+#endif
         break;
     case ButtonPress:
     case ButtonRelease:
+#if 00 /*BP*/
         detail = dmxGetButtonMapping(dmxLocal, detail);
+#else
+        {
+           DeviceIntPtr p = dmxLocal->pDevice;
+           int i, nevents, valuators[3];
+           xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+           valuators[0] = e->xbutton.x;
+           valuators[1] = e->xbutton.y;
+           valuators[2] = e->xbutton.button;
+           nevents = GetPointerEvents(events,
+                                      /*pDev*/p,
+                                      /*KeyPress*/type,
+                                      detail,
+                                      POINTER_ABSOLUTE,
+                                      0, 0, valuators);
+           /*
+           ErrorF("NEW PTR EVENT %d (%d,%d,%d) n=%d\n",
+                  detail, valuators[0], valuators[1], valuators[2],
+                  nevents);
+           */
+           for (i = 0; i < nevents; i++)
+              mieqEnqueue(p, events + i);
+           xfree(events);
+           return;
+        }
+#endif
         break;
     case MotionNotify:
         /* All MotionNotify events should be sent via dmxCoreMotion and
          * dmxExtMotion -- no input driver should build motion events by
          * hand. */
+#if 00 /*BP*/
         dmxLog(dmxError, "dmxEnqueueXEvent: MotionNotify not allowed here\n");
+#else
+        {
+           DeviceIntPtr p = dmxLocal->pDevice;
+           int i, nevents, valuators[3];
+           xEvent *events = Xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+           valuators[0] = e->xmotion.x;
+           valuators[1] = e->xmotion.y;
+           valuators[2] = e->xmotion.state;
+           nevents = GetPointerEvents(events,
+                                      /*pDev*/p,
+                                      /*KeyPress*/type,
+                                      detail,
+                                      POINTER_ABSOLUTE,
+                                      0, 0, valuators);
+           /*
+           ErrorF("NEW MOTION %d st %d (%d,%d,%d) n=%d\n",
+                  detail, e->xmotion.state,
+                  valuators[0], valuators[1], valuators[2],
+                  nevents);
+           */
+           for (i = 0; i < nevents; i++)
+              mieqEnqueue(p, events + i);
+           xfree(events);
+           return;
+        }
+#endif
         break;
                                 /* Always ignore these events */
     case EnterNotify:
@@ -623,6 +719,7 @@ void dmxEnqueue(DevicePtr pDev, int type
                                  * modifier map on the backend/console
                                  * input device so that we have complete
                                  * control of the input device LEDs. */
+       ErrorF("Enter/Leave/Keymap/Mapping\n");
         return;
     default:
 #ifdef XINPUT
@@ -652,7 +749,16 @@ void dmxEnqueue(DevicePtr pDev, int type
     if (!dmxLocal->sendsCore) dmxEnqueueExtEvent(dmxLocal, &xE, block);
     else
 #endif
+#if 00 /*BP*/
         dmxeqEnqueue(&xE);
+#else
+    /* never get here! */
+    if (0) {
+       DeviceIntPtr p = dmxLocal->pDevice;
+       ErrorF("enque %d\n", type);
+       mieqEnqueue(p, &xE);
+    }
+#endif
 }
 
 /** A pointer to this routine is passed to low-level input drivers so
diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index 0519d2b..7c0ae58 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -72,6 +72,7 @@
 #include "input.h"
 #include "mipointer.h"
 #include "windowstr.h"
+#include "mi.h"
 
 #ifdef XINPUT
 #include <X11/extensions/XI.h>
@@ -222,6 +223,57 @@ static DMXLocalInputInfoRec DMXLocalDevi
     { NULL }                    /* Must be last */
 };
 
+
+#if 11 /*BP*/
+void
+DDXRingBell(int volume, int pitch, int duration)
+{
+   /* NO-OP */
+}
+
+/* taken from kdrive/src/kinput.c: */
+static void
+dmxKbdCtrl (DeviceIntPtr pDevice, KeybdCtrl *ctrl)
+{
+#if 0
+    KdKeyboardInfo *ki;
+
+    for (ki = kdKeyboards; ki; ki = ki->next) {
+        if (ki->dixdev && ki->dixdev->id == pDevice->id)
+            break;
+    }
+
+    if (!ki || !ki->dixdev || ki->dixdev->id != pDevice->id || !ki->driver)
+        return;
+
+    KdSetLeds(ki, ctrl->leds);
+    ki->bellPitch = ctrl->bell_pitch;
+    ki->bellDuration = ctrl->bell_duration; 
+#endif
+}
+
+/* taken from kdrive/src/kinput.c: */
+static void
+dmxBell(int volume, DeviceIntPtr pDev, pointer arg, int something)
+{
+#if 0
+    KeybdCtrl *ctrl = arg;
+    KdKeyboardInfo *ki = NULL;
+    
+    for (ki = kdKeyboards; ki; ki = ki->next) {
+        if (ki->dixdev && ki->dixdev->id == pDev->id)
+            break;
+    }
+
+    if (!ki || !ki->dixdev || ki->dixdev->id != pDev->id || !ki->driver)
+        return;
+    
+    KdRingBell(ki, volume, ctrl->bell_pitch, ctrl->bell_duration);
+#endif
+}
+
+#endif /*BP*/
+
 static void _dmxChangePointerControl(DMXLocalInputInfoPtr dmxLocal,
                                      PtrCtrl *ctrl)
 {
@@ -427,7 +479,15 @@ static int dmxDeviceOnOff(DeviceIntPtr p
             break;
         }
         if (info.keyClass) {
+#if 00 /*BP*/
             InitKeyClassDeviceStruct(pDevice, &info.keySyms, info.modMap);
+#else
+            DevicePtr pDev = (DevicePtr) pDevice;
+            InitKeyboardDeviceStruct(pDev,
+                                     &info.keySyms,
+                                     info.modMap,
+                                     dmxBell, dmxKbdCtrl);
+#endif
         }
         if (info.buttonClass) {
             InitButtonClassDeviceStruct(pDevice, info.numButtons, info.map);
@@ -435,8 +495,13 @@ static int dmxDeviceOnOff(DeviceIntPtr p
         if (info.valuatorClass) {
             if (info.numRelAxes && dmxLocal->sendsCore) {
                 InitValuatorClassDeviceStruct(pDevice, info.numRelAxes,
+#if 00 /*BP*/
                                               miPointerGetMotionEvents,
                                               miPointerGetMotionBufferSize(),
+#else
+                                              GetMotionHistory,
+                                              GetMaximumEventsNum(),
+#endif
                                               Relative);
 #ifdef XINPUT
                 for (i = 0; i < info.numRelAxes; i++)
@@ -520,12 +585,26 @@ static void dmxProcessInputEvents(DMXInp
 {
     int i;
 
+    /*
+    ErrorF("%s\n", __FUNCTION__);
+    */
+
     dmxeqProcessInputEvents();
+#if 00 /*BP*/
     miPointerUpdate();
+#endif
     if (dmxInput->detached) return;
     for (i = 0; i < dmxInput->numDevs; i += dmxInput->devs[i]->binding)
-        if (dmxInput->devs[i]->process_input)
+        if (dmxInput->devs[i]->process_input) {
+#if 11 /*BP*/
+            miPointerUpdateSprite(dmxInput->devs[i]->pDevice);
+#endif
             dmxInput->devs[i]->process_input(dmxInput->devs[i]->private);
+        }
+
+#if 11 /*BP*/
+    mieqProcessInputEvents();
+#endif
 }
 
 static void dmxUpdateWindowInformation(DMXInputInfo *dmxInput,
@@ -710,8 +789,13 @@ static DeviceIntPtr dmxAddDevice(DMXLoca
 
     registerProcPtr(pDevice);
 
-    if (dmxLocal->isCore && dmxLocal->type == DMX_LOCAL_MOUSE)
+    if (dmxLocal->isCore && dmxLocal->type == DMX_LOCAL_MOUSE) {
+#if 00 /*BP*/
         miRegisterPointerDevice(screenInfo.screens[0], pDevice);
+#else
+        /* Nothing? dmxDeviceOnOff() should get called to init, right? */
+#endif
+    }
 
     if (dmxLocal->create_private)
         dmxLocal->private = dmxLocal->create_private(pDevice);
diff --git a/hw/dmx/input/dmxxinput.c b/hw/dmx/input/dmxxinput.c
index 81d1cfb..ad2a77c 100644
--- a/hw/dmx/input/dmxxinput.c
+++ b/hw/dmx/input/dmxxinput.c
@@ -99,9 +99,13 @@ int ChangePointerDevice(DeviceIntPtr old
     }
     dmxLocalNew->savedMotionProc       = new_dev->valuator->GetMotionProc;
     dmxLocalNew->savedMotionEvents     = new_dev->valuator->numMotionEvents;
+#if 00 /*BP*/
     new_dev->valuator->GetMotionProc   = miPointerGetMotionEvents;
     new_dev->valuator->numMotionEvents = miPointerGetMotionBufferSize();
-
+#else
+    new_dev->valuator->GetMotionProc   = GetMotionHistory;
+    new_dev->valuator->numMotionEvents = GetMaximumEventsNum();
+#endif
                                 /* Switch our notion of core pointer */
     dmxLocalOld->isCore         = 0;
     dmxLocalOld->sendsCore      = dmxLocalOld->savedSendsCore;
diff --git a/hw/dmx/input/lnx-keyboard.c b/hw/dmx/input/lnx-keyboard.c
index 97cc307..b09492b 100644
--- a/hw/dmx/input/lnx-keyboard.c
+++ b/hw/dmx/input/lnx-keyboard.c
@@ -164,7 +164,9 @@
 #include <sys/kd.h>
 #include <termios.h>
 #include "atKeynames.h"
+#if 00
 #include "xf86Keymap.h"
+#endif
 #include <linux/keyboard.h>
 
 #define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0]))
@@ -800,7 +802,12 @@ static void kbdLinuxReadKernelMapping(in
   tbl[2] = 8;	/* alt */
   tbl[3] = tbl[2] | 1;
 
+#if 00/*BP*/
   k = map+GLYPHS_PER_KEY;
+#else
+  ErrorF("kbdLinuxReadKernelMapping() is broken/no-op'd\n");
+  return;
+#endif
   maxkey = NUM_AT2LNX;
 
   for (i = 0; i < maxkey; ++i) {
@@ -927,8 +934,13 @@ static void kbdLinuxGetMap(DevicePtr pDe
     char          type;
     int           i;
 
+#if 00/*BP*/
     mapCopy = xalloc(sizeof(map));
     memcpy(mapCopy, map, sizeof(map));
+#else
+    ErrorF("kbdLinuxGetMap() is broken/no-op'd\n");
+    return;
+#endif
 
     kbdLinuxReadKernelMapping(priv->fd, pKeySyms);
 
diff-tree d92da3d5f309392ac398c0975ef17bb04312d5e2 (from 44acb2517d9fb07790d9d799aa9cc727d1b7d35c)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Mar 30 12:56:34 2007 -0600

    more formatting fixes

diff --git a/hw/dmx/dmxcursor.c b/hw/dmx/dmxcursor.c
index ef49652..09b50b8 100644
--- a/hw/dmx/dmxcursor.c
+++ b/hw/dmx/dmxcursor.c
@@ -130,14 +130,16 @@ static Bool dmxCursorOffScreen(ScreenPtr
     int           globalX;
     int           globalY;
     
-    if (screenInfo.numScreens == 1) return FALSE;
+    if (screenInfo.numScreens == 1)
+        return FALSE;
 
                                 /* On current screen? */
     dmxScreen = &dmxScreens[(*ppScreen)->myNum];
     if (localX >= 0
         && localX < dmxScreen->rootWidth
         && localY >= 0
-        && localY < dmxScreen->rootHeight) return FALSE;
+        && localY < dmxScreen->rootHeight)
+        return FALSE;
 
                                 /* Convert to global coordinate space */
     globalX = dmxScreen->rootXOrigin + localX;
@@ -162,7 +164,8 @@ static Bool dmxCursorOffScreen(ScreenPtr
             && globalX < dmxScreen->rootXOrigin + dmxScreen->rootWidth
             && globalY >= dmxScreen->rootYOrigin
             && globalY < dmxScreen->rootYOrigin + dmxScreen->rootHeight) {
-            if (dmxScreen->index == (*ppScreen)->myNum) return FALSE;
+            if (dmxScreen->index == (*ppScreen)->myNum)
+                return FALSE;
             *ppScreen = screenInfo.screens[dmxScreen->index];
             *x        = globalX - dmxScreen->rootXOrigin;
             *y        = globalY - dmxScreen->rootYOrigin;
diff-tree 44acb2517d9fb07790d9d799aa9cc727d1b7d35c (from 9f24798af50896cc3262c1201f75c10a688f2a83)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Mar 30 12:54:22 2007 -0600

    Fix some bad formatting.
    
    Doing this:
        if (something) stmt;
    is evil if you're debugging and want to break on stmt!

diff --git a/hw/dmx/dmxcursor.c b/hw/dmx/dmxcursor.c
index e74a052..ef49652 100644
--- a/hw/dmx/dmxcursor.c
+++ b/hw/dmx/dmxcursor.c
@@ -198,7 +198,8 @@ static int *dmxSLCreate(void)
     int *list = malloc(dmxNumScreens * sizeof(*list));
     int i;
     
-    for (i = 0; i < dmxNumScreens; i++) list[i] = 1;
+    for (i = 0; i < dmxNumScreens; i++)
+        list[i] = 1;
     return list;
 }
 
@@ -212,7 +213,9 @@ static void dmxSLFree(int *list)
 static int dmxSLFindNext(int *list)
 {
     int i;
-    for (i = 0; i < dmxNumScreens; i++) if (list[i]) return i;
+    for (i = 0; i < dmxNumScreens; i++)
+        if (list[i])
+            return i;
     return -1;
 }
 
@@ -225,7 +228,8 @@ static int dmxTryComputeScreenOrigins(in
     int             changed = 0;
 
     for (i = 0; i < dmxNumScreens; i++) {
-        if (!screensLeft[i]) continue;
+        if (!screensLeft[i])
+            continue;
         screen  = &dmxScreens[i];
         switch (screen->where) {
         case PosAbsolute:
@@ -235,14 +239,16 @@ static int dmxTryComputeScreenOrigins(in
             break;
         case PosRelative:
             ref = screen->whereRefScreen;
-            if (screensLeft[ref]) break;
+            if (screensLeft[ref])
+                break;
             dixScreenOrigins[i].x = dixScreenOrigins[ref].x + screen->whereX;
             dixScreenOrigins[i].y = dixScreenOrigins[ref].y + screen->whereY;
             ++changed, screensLeft[i] = 0;
             break;
         case PosRightOf:
             ref = screen->whereRefScreen;
-            if (screensLeft[ref]) break;
+            if (screensLeft[ref])
+                break;
             pScreen = screenInfo.screens[ref];
             dixScreenOrigins[i].x = dixScreenOrigins[ref].x + pScreen->width;
             dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
@@ -250,7 +256,8 @@ static int dmxTryComputeScreenOrigins(in
             break;
         case PosLeftOf:
             ref = screen->whereRefScreen;
-            if (screensLeft[ref]) break;
+            if (screensLeft[ref])
+                break;
             pScreen = screenInfo.screens[i];
             dixScreenOrigins[i].x = dixScreenOrigins[ref].x - pScreen->width;
             dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
@@ -258,7 +265,8 @@ static int dmxTryComputeScreenOrigins(in
             break;
         case PosBelow:
             ref = screen->whereRefScreen;
-            if (screensLeft[ref]) break;
+            if (screensLeft[ref])
+                break;
             pScreen = screenInfo.screens[ref];
             dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
             dixScreenOrigins[i].y = dixScreenOrigins[ref].y + pScreen->height;
@@ -266,7 +274,8 @@ static int dmxTryComputeScreenOrigins(in
             break;
         case PosAbove:
             ref = screen->whereRefScreen;
-            if (screensLeft[ref]) break;
+            if (screensLeft[ref])
+                break;
             pScreen = screenInfo.screens[i];
             dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
             dixScreenOrigins[i].y = dixScreenOrigins[ref].y - pScreen->height;
@@ -308,8 +317,10 @@ static void dmxComputeScreenOrigins(void
     minX = dixScreenOrigins[0].x;
     minY = dixScreenOrigins[0].y;
     for (i = 1; i < dmxNumScreens; i++) { /* Compute minX, minY */
-	if (dixScreenOrigins[i].x < minX) minX = dixScreenOrigins[i].x;
-	if (dixScreenOrigins[i].y < minY) minY = dixScreenOrigins[i].y;
+	if (dixScreenOrigins[i].x < minX)
+            minX = dixScreenOrigins[i].x;
+	if (dixScreenOrigins[i].y < minY)
+            minY = dixScreenOrigins[i].y;
     }
     if (minX || minY) {
 	for (i = 0; i < dmxNumScreens; i++) {
@@ -411,28 +422,36 @@ int dmxOnScreen(int x, int y, DMXScreenI
 static int dmxDoesOverlap(DMXScreenInfo *a, DMXScreenInfo *b)
 {
     if (dmxOnScreen(a->rootXOrigin,
-                    a->rootYOrigin,                 b)) return 1;
+                    a->rootYOrigin,                 b))
+        return 1;
 
     if (dmxOnScreen(a->rootXOrigin,
-                    a->rootYOrigin + a->scrnWidth,  b)) return 1;
+                    a->rootYOrigin + a->scrnWidth,  b))
+        return 1;
 
     if (dmxOnScreen(a->rootXOrigin + a->scrnHeight,
-                    a->rootYOrigin,                 b)) return 1;
+                    a->rootYOrigin,                 b))
+        return 1;
 
     if (dmxOnScreen(a->rootXOrigin + a->scrnHeight,
-                    a->rootYOrigin + a->scrnWidth,  b)) return 1;
+                    a->rootYOrigin + a->scrnWidth,  b))
+        return 1;
 
     if (dmxOnScreen(b->rootXOrigin,
-                    b->rootYOrigin,                 a)) return 1;
+                    b->rootYOrigin,                 a))
+        return 1;
 
     if (dmxOnScreen(b->rootXOrigin,
-                    b->rootYOrigin + b->scrnWidth,  a)) return 1;
+                    b->rootYOrigin + b->scrnWidth,  a))
+        return 1;
 
     if (dmxOnScreen(b->rootXOrigin + b->scrnHeight,
-                    b->rootYOrigin,                 a)) return 1;
+                    b->rootYOrigin,                 a))
+        return 1;
 
     if (dmxOnScreen(b->rootXOrigin + b->scrnHeight,
-                    b->rootYOrigin + b->scrnWidth,  a)) return 1;
+                    b->rootYOrigin + b->scrnWidth,  a))
+        return 1;
 
     return 0;
 }
@@ -476,7 +495,8 @@ static void *dmxTestSameDisplay(DMXScree
 {
     DMXScreenInfo *b = closure;
 
-    if (a == b) return a;
+    if (a == b)
+        return a;
     return NULL;
 }
 
@@ -489,14 +509,16 @@ void dmxInitOverlap(void)
     int           i, j;
     DMXScreenInfo *a, *b, *pt;
 
-    for (i = 0; i < dmxNumScreens; i++) dmxScreens[i].over = NULL;
+    for (i = 0; i < dmxNumScreens; i++)
+        dmxScreens[i].over = NULL;
 
     for (i = 0; i < dmxNumScreens; i++) {
         a = &dmxScreens[i];
         
         for (j = i+1; j < dmxNumScreens; j++) {
             b = &dmxScreens[j];
-            if (b->over) continue;
+            if (b->over)
+                continue;
             
             if (dmxDoesOverlap(a, b)) {
                 DMXDBG6("%d overlaps %d: a=%p %p b=%p %p\n",
@@ -510,7 +532,8 @@ void dmxInitOverlap(void)
     for (i = 0; i < dmxNumScreens; i++) {
         a = &dmxScreens[i];
         
-        if (!a->over) continue;
+        if (!a->over)
+            continue;
         
                                 /* Flag all pairs that are on same display */
         for (pt = a->over; pt != a; pt = pt->over) {
@@ -521,7 +544,8 @@ void dmxInitOverlap(void)
                  * screens that mutually overlap on the backend display,
                  * so we call dmxDoesOverlap, which is stricter than the
                  * ->over set. */
-                if (!dmxDoesOverlap(a, pt)) continue;
+                if (!dmxDoesOverlap(a, pt))
+                    continue;
                 a->cursorNotShared  = 1;
                 pt->cursorNotShared = 1;
                 dmxLog(dmxInfo,
@@ -731,9 +755,11 @@ static Bool dmxRealizeCursor(ScreenPtr p
         return _dmxRealizeCursor(pScreen, pCursor);
 
     for (pt = start->over; /* condition at end of loop */; pt = pt->over) {
-        if (pt->cursorNotShared) continue;
+        if (pt->cursorNotShared)
+            continue;
         _dmxRealizeCursor(screenInfo.screens[pt->index], pCursor);
-        if (pt == start) break;
+        if (pt == start)
+            break;
     }
     return TRUE;
 }
@@ -747,9 +773,11 @@ static Bool dmxUnrealizeCursor(ScreenPtr
         return _dmxUnrealizeCursor(pScreen, pCursor);
 
     for (pt = start->over; /* condition at end of loop */; pt = pt->over) {
-        if (pt->cursorNotShared) continue;
+        if (pt->cursorNotShared)
+            continue;
         _dmxUnrealizeCursor(screenInfo.screens[pt->index], pCursor);
-        if (pt == start) break;
+        if (pt == start)
+            break;
     }
     return TRUE;
 }
@@ -758,10 +786,13 @@ static CursorPtr dmxFindCursor(DMXScreen
 {
     DMXScreenInfo *pt;
 
-    if (!start || !start->over) return GetSpriteCursor();
+    if (!start || !start->over)
+        return GetSpriteCursor();
     for (pt = start->over; /* condition at end of loop */; pt = pt->over) {
-        if (pt->cursor) return pt->cursor;
-        if (pt == start) break;
+        if (pt->cursor)
+            return pt->cursor;
+        if (pt == start)
+            break;
     }
     return GetSpriteCursor();
 }
@@ -769,7 +800,12 @@ static CursorPtr dmxFindCursor(DMXScreen
 /** Move the cursor to coordinates (\a x, \a y)on \a pScreen.  This
  * function is usually called via #dmxPointerSpriteFuncs, except during
  * reconfiguration when the cursor is repositioned to force an update on
- * newley overlapping screens and on screens that no longer overlap. */
+ * newley overlapping screens and on screens that no longer overlap.
+ *
+ * The coords (x,y) are in global coord space.  We'll loop over the
+ * back-end screens and see if they contain the global coord.  If so, call
+ * _dmxMoveCursor() (XWarpPointer) to position the pointer on that screen.
+ */
 void dmxMoveCursor(ScreenPtr pScreen, int x, int y)
 {
     DMXScreenInfo *start = &dmxScreens[pScreen->myNum];
@@ -783,7 +819,8 @@ void dmxMoveCursor(ScreenPtr pScreen, in
     }
 
     for (pt = start->over; /* condition at end of loop */; pt = pt->over) {
-        if (pt->cursorNotShared) continue;
+        if (pt->cursorNotShared)
+            continue;
         if (dmxOnScreen(x + start->rootXOrigin, y + start->rootYOrigin, pt)) {
             if (/* pt != start && */ !pt->cursorVisible) {
                 if (!pt->cursor) {
@@ -811,7 +848,8 @@ void dmxMoveCursor(ScreenPtr pScreen, in
                           x + start->rootXOrigin - pt->rootXOrigin,
                           y + start->rootYOrigin - pt->rootYOrigin);
         }
-        if (pt == start) break;
+        if (pt == start)
+            break;
     }
 }
 
@@ -851,7 +889,8 @@ static void dmxSetCursor(ScreenPtr pScre
     }
 
     for (pt = start->over; /* condition at end of loop */; pt = pt->over) {
-        if (pt->cursorNotShared) continue;
+        if (pt->cursorNotShared)
+            continue;
         if (dmxOnScreen(x + start->rootXOrigin, y + start->rootYOrigin, pt)) {
             _dmxSetCursor(screenInfo.screens[pt->index], pCursor,
                           x + start->rootXOrigin - pt->rootXOrigin,
@@ -861,7 +900,8 @@ static void dmxSetCursor(ScreenPtr pScre
                           x + start->rootXOrigin - pt->rootXOrigin,
                           y + start->rootYOrigin - pt->rootYOrigin);
         }
-        if (pt == start) break;
+        if (pt == start)
+            break;
     }
 }
 
diff-tree 9f24798af50896cc3262c1201f75c10a688f2a83 (from 76756f27561c6386cba0d338441e8ec7b98500ce)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Mar 30 12:49:34 2007 -0600

    ompile fbcmap.c w/ -DXFree86Server instead of linking libfbcmap.a.
    
    The former works, the later doesn't (DMX blows up on visuals/pixel formats).
    This undos Daniel's patch, which undid my prev patch.  Revisit someday.

diff --git a/hw/dmx/Makefile.am b/hw/dmx/Makefile.am
index 17d27ed..41dc5d2 100644
--- a/hw/dmx/Makefile.am
+++ b/hw/dmx/Makefile.am
@@ -2,7 +2,6 @@ DIST_SUBDIRS = input config glxProxy exa
 
 SUBDIRS = input config examples
 bin_PROGRAMS = Xdmx
-noinst_LIBRARIES = libfbcmap.a
 
 if XINERAMA
 PANORAMIX_SRCS = $(top_srcdir)/Xext/panoramiX.c
@@ -17,6 +16,9 @@ GLX_INCS = -I$(top_srcdir)/hw/xfree86/di
 GLX_DEFS = @GL_CFLAGS@ 
 endif
 
+# It's essential that fbcmap.c be compiled with this flag for DMX to work!!
+DMX_CFLAGS = -DXFree86Server=1
+
 if BUILDDOCS
 SUBDIRS += doc
 endif
@@ -26,11 +28,9 @@ AM_CFLAGS = \
       $(DIX_CFLAGS) \
       $(GLX_INCS) \
       $(GLX_DEFS) \
+      $(DMX_CFLAGS) \
       @DMXMODULES_CFLAGS@
 
-libfbcmap_a_SOURCES = libfbcmap.a
-libfbcmap_a_CFLAGS = $(AM_CFLAGS) -DXFree86Server
-
 Xdmx_SOURCES = dmx.c \
                dmxcb.c \
                dmxcb.h \
@@ -76,6 +76,7 @@ Xdmx_SOURCES = dmx.c \
                dmxwindow.c \
                dmxwindow.h \
                $(top_srcdir)/mi/miinitext.c \
+               $(top_srcdir)/fb/fbcmap.c \
                $(GLX_SRCS) 
 
 
@@ -89,7 +90,6 @@ Xdmx_LDADD = $(XORG_CORE_LIBS) \
              $(GLX_LIBS) \
              input/libdmxinput.a \
              config/libdmxconfig.a \
-	     libfbcmap.a \
              @DMXMODULES_LIBS@
 
 # Man page
diff-tree 76756f27561c6386cba0d338441e8ec7b98500ce (from 307d2b57bbfcc281656011533627bea6ab98189e)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Thu Nov 30 04:20:32 2006 +0200

    Make xf86glx.c unaware of Mesa internals
    
    Use newly added XMesaCopyContext() and drop the GlxSetRenderTables() call
    for Xgl, as this is now done inside XMesaForceCurrent(). This leaves xmesaP.h
    but only for the declarations of the three XMesa/XFree86 functions. Also,
    GlxSetRenderTables() stays but is only used in hw/xgl/glxext/ .
    
    Also drop xf86glxint.h, no longer used.
    
    Depends on mesa commit 7439a36785b6a2783e80a40a96c09db8f56dc2bc of 2007-03-30.

diff --git a/GL/glx/Makefile.am b/GL/glx/Makefile.am
index 8184f60..cd1130d 100644
--- a/GL/glx/Makefile.am
+++ b/GL/glx/Makefile.am
@@ -14,7 +14,6 @@ AM_CFLAGS = \
 	-I at MESA_SOURCE@/src/mesa/glapi \
 	-I at MESA_SOURCE@/src/mesa/main \
 	-DXFree86Server \
-	-DNO_LIBCWRAPPER \
 	@GLX_DEFINES@
 
 # none yet
diff --git a/GL/mesa/X/Makefile.am b/GL/mesa/X/Makefile.am
index 45345a7..056d31a 100644
--- a/GL/mesa/X/Makefile.am
+++ b/GL/mesa/X/Makefile.am
@@ -20,13 +20,11 @@ INCLUDES = -I at MESA_SOURCE@/include \
 AM_CFLAGS = \
 	$(DIX_CFLAGS) \
 	-DXFree86Server \
-	@GLX_DEFINES@ \
-	-DXFree86Server
+	@GLX_DEFINES@
 
 libX_la_SOURCES = xf86glx.c \
                   xf86glx_util.c \
-                  xf86glx_util.h \
-                  xf86glxint.h
+                  xf86glx_util.h
 
 nodist_libX_la_SOURCES = \
                   xm_api.c \
diff --git a/GL/mesa/X/xf86glx.c b/GL/mesa/X/xf86glx.c
index 47c87f6..6fffdeb 100644
--- a/GL/mesa/X/xf86glx.c
+++ b/GL/mesa/X/xf86glx.c
@@ -37,40 +37,19 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 #endif
 
 #include <string.h>
-#include <regionstr.h>
-#include <resource.h>
-#include <GL/gl.h>
-#include <GL/glxint.h>
-#include <GL/glxtokens.h>
-#include <scrnintstr.h>
-#include <windowstr.h>
-#include <config.h>
+
+#include <GL/xmesa.h>
+#include <GL/internal/glcore.h>
 #include <glxserver.h>
 #include <glxscreens.h>
 #include <glxdrawable.h>
 #include <glxcontext.h>
-#include <glxext.h>
 #include <glxutil.h>
-#include "context.h"
 #include "xmesaP.h"
-#include "context.h"
 
 #include "glcontextmodes.h"
 #include "os.h"
 
-/*
- * This define is for the glcore.h header file.
- * If you add it here, then make sure you also add it in
- * ../../../glx/Imakefile.
- */
-#if 0
-#define DEBUG
-#include <GL/internal/glcore.h>
-#undef DEBUG
-#else
-#include <GL/internal/glcore.h>
-#endif
-
 typedef struct __GLXMESAscreen   __GLXMESAscreen;
 typedef struct __GLXMESAcontext  __GLXMESAcontext;
 typedef struct __GLXMESAdrawable __GLXMESAdrawable;
@@ -218,8 +197,7 @@ __glXMesaContextCopy(__GLXcontext *baseD
     __GLXMESAcontext *dst = (__GLXMESAcontext *) baseDst;
     __GLXMESAcontext *src = (__GLXMESAcontext *) baseSrc;
 
-    _mesa_copy_context(&src->xmesa->mesa, &dst->xmesa->mesa, mask);
-    return GL_TRUE;
+    return XMesaCopyContext(src->xmesa, dst->xmesa, mask);
 }
 
 static int
@@ -227,7 +205,7 @@ __glXMesaContextForceCurrent(__GLXcontex
 {
     __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
 
-    GlxSetRenderTables (context->xmesa->mesa.CurrentDispatch);
+    /* GlxSetRenderTables() call for XGL moved in XMesaForceCurrent() */
 
     return XMesaForceCurrent(context->xmesa);
 }
diff --git a/GL/mesa/X/xf86glx_util.c b/GL/mesa/X/xf86glx_util.c
index ffb5280..6af773f 100644
--- a/GL/mesa/X/xf86glx_util.c
+++ b/GL/mesa/X/xf86glx_util.c
@@ -37,8 +37,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
 #include <stdlib.h>
 
-#include <gcstruct.h>
-#include "pixmapstr.h"
 #include "xf86glx_util.h"
 #include <X11/Xmd.h>
 
diff --git a/GL/mesa/X/xf86glxint.h b/GL/mesa/X/xf86glxint.h
deleted file mode 100644
index 8c7e913..0000000
--- a/GL/mesa/X/xf86glxint.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin at precisioninsight.com>
- *
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef _XF86GLXINT_H_
-#define _XF86GLXINT_H_
-
-#include <miscstruct.h>
-#include <GL/gl.h>
-#include <GL/xmesa.h>
-
-#endif /* _XF86GLXINT_H_ */
diff-tree 307d2b57bbfcc281656011533627bea6ab98189e (from 82a8b99a6c46018885600011913267d8af9dfe13)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Mar 29 15:23:41 2007 +0930

    Xi:     remove 'register' keywords.

diff --git a/Xi/allowev.c b/Xi/allowev.c
index ea9c5de..85b6eaf 100644
--- a/Xi/allowev.c
+++ b/Xi/allowev.c
@@ -76,9 +76,9 @@ SOFTWARE.
  */
 
 int
-SProcXAllowDeviceEvents(register ClientPtr client)
+SProcXAllowDeviceEvents(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xAllowDeviceEventsReq);
     swaps(&stuff->length, n);
@@ -94,7 +94,7 @@ SProcXAllowDeviceEvents(register ClientP
  */
 
 int
-ProcXAllowDeviceEvents(register ClientPtr client)
+ProcXAllowDeviceEvents(ClientPtr client)
 {
     TimeStamp time;
     DeviceIntPtr thisdev;
diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c
index badd938..9676fb7 100644
--- a/Xi/chgdctl.c
+++ b/Xi/chgdctl.c
@@ -78,9 +78,9 @@ SOFTWARE.
  */
 
 int
-SProcXChangeDeviceControl(register ClientPtr client)
+SProcXChangeDeviceControl(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xChangeDeviceControlReq);
     swaps(&stuff->length, n);
@@ -287,7 +287,7 @@ void
 SRepXChangeDeviceControl(ClientPtr client, int size,
 			 xChangeDeviceControlReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/chgfctl.c b/Xi/chgfctl.c
index 82616c6..2e0e13c 100644
--- a/Xi/chgfctl.c
+++ b/Xi/chgfctl.c
@@ -78,9 +78,9 @@ SOFTWARE.
  */
 
 int
-SProcXChangeFeedbackControl(register ClientPtr client)
+SProcXChangeFeedbackControl(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xChangeFeedbackControlReq);
     swaps(&stuff->length, n);
@@ -99,7 +99,7 @@ static int
 ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
 		  KbdFeedbackPtr k, xKbdFeedbackCtl * f)
 {
-    register char n;
+    char n;
     KeybdCtrl kctrl;
     int t;
     int key = DO_ALL;
@@ -231,7 +231,7 @@ static int
 ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
 		  PtrFeedbackPtr p, xPtrFeedbackCtl * f)
 {
-    register char n;
+    char n;
     PtrCtrl pctrl;	/* might get BadValue part way through */
 
     if (client->swapped) {
@@ -303,7 +303,7 @@ ChangeIntegerFeedback(ClientPtr client, 
 		      long unsigned int mask, IntegerFeedbackPtr i,
 		      xIntegerFeedbackCtl * f)
 {
-    register char n;
+    char n;
 
     if (client->swapped) {
 	swaps(&f->length, n);
@@ -326,8 +326,8 @@ ChangeStringFeedback(ClientPtr client, D
 		     long unsigned int mask, StringFeedbackPtr s,
 		     xStringFeedbackCtl * f)
 {
-    register char n;
-    register long *p;
+    char n;
+    long *p;
     int i, j;
     KeySym *syms, *sup_syms;
 
@@ -376,7 +376,7 @@ ChangeBellFeedback(ClientPtr client, Dev
 		   long unsigned int mask, BellFeedbackPtr b,
 		   xBellFeedbackCtl * f)
 {
-    register char n;
+    char n;
     int t;
     BellCtrl bctrl;	/* might get BadValue part way through */
 
@@ -440,7 +440,7 @@ static int
 ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
 		  LedFeedbackPtr l, xLedFeedbackCtl * f)
 {
-    register char n;
+    char n;
     LedCtrl lctrl;	/* might get BadValue part way through */
 
     if (client->swapped) {
@@ -520,7 +520,7 @@ ProcXChangeFeedbackControl(ClientPtr cli
 	break;
     case StringFeedbackClass:
     {
-	register char n;
+	char n;
 	xStringFeedbackCtl *f = ((xStringFeedbackCtl *) & stuff[1]);
 
 	if (client->swapped) {
diff --git a/Xi/chgkbd.c b/Xi/chgkbd.c
index 8134b40..2cf8225 100644
--- a/Xi/chgkbd.c
+++ b/Xi/chgkbd.c
@@ -78,9 +78,9 @@ SOFTWARE.
  */
 
 int
-SProcXChangeKeyboardDevice(register ClientPtr client)
+SProcXChangeKeyboardDevice(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xChangeKeyboardDeviceReq);
     swaps(&stuff->length, n);
@@ -96,7 +96,7 @@ SProcXChangeKeyboardDevice(register Clie
  */
 
 int
-ProcXChangeKeyboardDevice(register ClientPtr client)
+ProcXChangeKeyboardDevice(ClientPtr client)
 {
     REQUEST(xChangeKeyboardDeviceReq);
     REQUEST_SIZE_MATCH(xChangeKeyboardDeviceReq);
diff --git a/Xi/chgkmap.c b/Xi/chgkmap.c
index 047b899..eac520f 100644
--- a/Xi/chgkmap.c
+++ b/Xi/chgkmap.c
@@ -76,11 +76,11 @@ SOFTWARE.
  */
 
 int
-SProcXChangeDeviceKeyMapping(register ClientPtr client)
+SProcXChangeDeviceKeyMapping(ClientPtr client)
 {
-    register char n;
-    register long *p;
-    register int i, count;
+    char n;
+    long *p;
+    int i, count;
 
     REQUEST(xChangeDeviceKeyMappingReq);
     swaps(&stuff->length, n);
@@ -101,7 +101,7 @@ SProcXChangeDeviceKeyMapping(register Cl
  */
 
 int
-ProcXChangeDeviceKeyMapping(register ClientPtr client)
+ProcXChangeDeviceKeyMapping(ClientPtr client)
 {
     int ret;
     unsigned len;
diff --git a/Xi/chgprop.c b/Xi/chgprop.c
index bab4597..59a93c6 100644
--- a/Xi/chgprop.c
+++ b/Xi/chgprop.c
@@ -78,11 +78,11 @@ SOFTWARE.
  */
 
 int
-SProcXChangeDeviceDontPropagateList(register ClientPtr client)
+SProcXChangeDeviceDontPropagateList(ClientPtr client)
 {
-    register char n;
-    register long *p;
-    register int i;
+    char n;
+    long *p;
+    int i;
 
     REQUEST(xChangeDeviceDontPropagateListReq);
     swaps(&stuff->length, n);
@@ -104,7 +104,7 @@ SProcXChangeDeviceDontPropagateList(regi
  */
 
 int
-ProcXChangeDeviceDontPropagateList(register ClientPtr client)
+ProcXChangeDeviceDontPropagateList(ClientPtr client)
 {
     int i, rc;
     WindowPtr pWin;
diff --git a/Xi/chgptr.c b/Xi/chgptr.c
index 22c8a5f..a949068 100644
--- a/Xi/chgptr.c
+++ b/Xi/chgptr.c
@@ -82,9 +82,9 @@ SOFTWARE.
  */
 
 int
-SProcXChangePointerDevice(register ClientPtr client)
+SProcXChangePointerDevice(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xChangePointerDeviceReq);
     swaps(&stuff->length, n);
@@ -99,7 +99,7 @@ SProcXChangePointerDevice(register Clien
  */
 
 int
-ProcXChangePointerDevice(register ClientPtr client)
+ProcXChangePointerDevice(ClientPtr client)
 {
     REQUEST(xChangePointerDeviceReq);
     REQUEST_SIZE_MATCH(xChangePointerDeviceReq);
diff --git a/Xi/closedev.c b/Xi/closedev.c
index 3d47b5f..8d38ec8 100644
--- a/Xi/closedev.c
+++ b/Xi/closedev.c
@@ -77,9 +77,9 @@ SOFTWARE.
  */
 
 int
-SProcXCloseDevice(register ClientPtr client)
+SProcXCloseDevice(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xCloseDeviceReq);
     swaps(&stuff->length, n);
@@ -141,7 +141,7 @@ DeleteEventsFromChildren(DeviceIntPtr de
  */
 
 int
-ProcXCloseDevice(register ClientPtr client)
+ProcXCloseDevice(ClientPtr client)
 {
     int i;
     WindowPtr pWin, p1;
diff --git a/Xi/devbell.c b/Xi/devbell.c
index b112386..ba873c7 100644
--- a/Xi/devbell.c
+++ b/Xi/devbell.c
@@ -75,9 +75,9 @@ SOFTWARE.
  */
 
 int
-SProcXDeviceBell(register ClientPtr client)
+SProcXDeviceBell(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xDeviceBellReq);
     swaps(&stuff->length, n);
@@ -91,7 +91,7 @@ SProcXDeviceBell(register ClientPtr clie
  */
 
 int
-ProcXDeviceBell(register ClientPtr client)
+ProcXDeviceBell(ClientPtr client)
 {
     DeviceIntPtr dev;
     KbdFeedbackPtr k;
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 164fce3..9e71a9e 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -104,12 +104,12 @@ RegisterOtherDevice(DeviceIntPtr device)
 }
 
  /*ARGSUSED*/ void
-ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count)
+ProcessOtherEvent(xEventPtr xE, DeviceIntPtr other, int count)
 {
-    register BYTE *kptr;
-    register int i;
-    register CARD16 modifiers;
-    register CARD16 mask;
+    BYTE *kptr;
+    int i;
+    CARD16 modifiers;
+    CARD16 mask;
     GrabPtr grab = other->grab;
     Bool deactivateDeviceGrab = FALSE;
     int key = 0, bit = 0, rootX, rootY;
@@ -288,7 +288,7 @@ ProcessOtherEvent(xEventPtr xE, register
 _X_EXPORT int
 InitProximityClassDeviceStruct(DeviceIntPtr dev)
 {
-    register ProximityClassPtr proxc;
+    ProximityClassPtr proxc;
 
     proxc = (ProximityClassPtr) xalloc(sizeof(ProximityClassRec));
     if (!proxc)
@@ -301,7 +301,7 @@ _X_EXPORT void
 InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval, int maxval,
 		       int resolution, int min_res, int max_res)
 {
-    register AxisInfoPtr ax;
+    AxisInfoPtr ax;
    
     if (!dev || !dev->valuator)
         return;
@@ -378,7 +378,7 @@ FixDeviceValuator(DeviceIntPtr dev, devi
 
 void
 DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
-		 register WindowPtr pWin)
+		 WindowPtr pWin)
 {
     deviceFocus event;
 
@@ -703,9 +703,9 @@ MakeInputMasks(WindowPtr pWin)
 void
 RecalculateDeviceDeliverableEvents(WindowPtr pWin)
 {
-    register InputClientsPtr others;
+    InputClientsPtr others;
     struct _OtherInputMasks *inputMasks;	/* default: NULL */
-    register WindowPtr pChild, tmp;
+    WindowPtr pChild, tmp;
     int i;
 
     pChild = pWin;
@@ -739,9 +739,9 @@ RecalculateDeviceDeliverableEvents(Windo
 }
 
 int
-InputClientGone(register WindowPtr pWin, XID id)
+InputClientGone(WindowPtr pWin, XID id)
 {
-    register InputClientsPtr other, prev;
+    InputClientsPtr other, prev;
 
     if (!wOtherInputMasks(pWin))
 	return (Success);
@@ -839,7 +839,7 @@ SendEvent(ClientPtr client, DeviceIntPtr
 int
 SetButtonMapping(ClientPtr client, DeviceIntPtr dev, int nElts, BYTE * map)
 {
-    register int i;
+    int i;
     ButtonClassPtr b = dev->button;
 
     if (b == NULL)
@@ -865,7 +865,7 @@ SetModifierMapping(ClientPtr client, Dev
 {
     KeyCode *map = NULL;
     int inputMapLen;
-    register int i;
+    int i;
 
     *k = dev->key;
     if (*k == NULL)
@@ -1141,7 +1141,7 @@ CheckDeviceGrabAndHintWindow(WindowPtr p
 static Mask
 DeviceEventMaskForClient(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client)
 {
-    register InputClientsPtr other;
+    InputClientsPtr other;
 
     if (!wOtherInputMasks(pWin))
 	return 0;
@@ -1154,7 +1154,7 @@ DeviceEventMaskForClient(DeviceIntPtr de
 }
 
 void
-MaybeStopDeviceHint(register DeviceIntPtr dev, ClientPtr client)
+MaybeStopDeviceHint(DeviceIntPtr dev, ClientPtr client)
 {
     WindowPtr pWin;
     GrabPtr grab = dev->grab;
diff --git a/Xi/extinit.c b/Xi/extinit.c
index fed54ab..b1ec321 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -216,7 +216,7 @@ static XExtensionVersion thisversion = {
  */
 
 static int
-ProcIDispatch(register ClientPtr client)
+ProcIDispatch(ClientPtr client)
 {
     REQUEST(xReq);
     if (stuff->data == X_GetExtensionVersion)
@@ -305,7 +305,7 @@ ProcIDispatch(register ClientPtr client)
  */
 
 static int
-SProcIDispatch(register ClientPtr client)
+SProcIDispatch(ClientPtr client)
 {
     REQUEST(xReq);
     if (stuff->data == X_GetExtensionVersion)
@@ -464,8 +464,8 @@ SReplyIDispatch(ClientPtr client, int le
 static void
 SEventDeviceValuator(deviceValuator * from, deviceValuator * to)
 {
-    register char n;
-    register int i;
+    char n;
+    int i;
     INT32 *ip B32;
 
     *to = *from;
@@ -480,7 +480,7 @@ SEventDeviceValuator(deviceValuator * fr
 static void
 SEventFocus(deviceFocus * from, deviceFocus * to)
 {
-    register char n;
+    char n;
 
     *to = *from;
     swaps(&to->sequenceNumber, n);
@@ -491,8 +491,8 @@ SEventFocus(deviceFocus * from, deviceFo
 static void
 SDeviceStateNotifyEvent(deviceStateNotify * from, deviceStateNotify * to)
 {
-    register int i;
-    register char n;
+    int i;
+    char n;
     INT32 *ip B32;
 
     *to = *from;
@@ -508,7 +508,7 @@ static void
 SDeviceKeyStateNotifyEvent(deviceKeyStateNotify * from,
 			   deviceKeyStateNotify * to)
 {
-    register char n;
+    char n;
 
     *to = *from;
     swaps(&to->sequenceNumber, n);
@@ -518,7 +518,7 @@ static void
 SDeviceButtonStateNotifyEvent(deviceButtonStateNotify * from,
 			      deviceButtonStateNotify * to)
 {
-    register char n;
+    char n;
 
     *to = *from;
     swaps(&to->sequenceNumber, n);
@@ -527,7 +527,7 @@ SDeviceButtonStateNotifyEvent(deviceButt
 static void
 SChangeDeviceNotifyEvent(changeDeviceNotify * from, changeDeviceNotify * to)
 {
-    register char n;
+    char n;
 
     *to = *from;
     swaps(&to->sequenceNumber, n);
@@ -537,7 +537,7 @@ SChangeDeviceNotifyEvent(changeDeviceNot
 static void
 SDeviceMappingNotifyEvent(deviceMappingNotify * from, deviceMappingNotify * to)
 {
-    register char n;
+    char n;
 
     *to = *from;
     swaps(&to->sequenceNumber, n);
@@ -547,7 +547,7 @@ SDeviceMappingNotifyEvent(deviceMappingN
 static void
 SDevicePresenceNotifyEvent (devicePresenceNotify *from, devicePresenceNotify *to)
 {
-    register char n;
+    char n;
 
     *to = *from;
     swaps(&to->sequenceNumber,n);
diff --git a/Xi/getbmap.c b/Xi/getbmap.c
index 3287476..5e8cf07 100644
--- a/Xi/getbmap.c
+++ b/Xi/getbmap.c
@@ -74,9 +74,9 @@ SOFTWARE.
  */
 
 int
-SProcXGetDeviceButtonMapping(register ClientPtr client)
+SProcXGetDeviceButtonMapping(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xGetDeviceButtonMappingReq);
     swaps(&stuff->length, n);
@@ -90,7 +90,7 @@ SProcXGetDeviceButtonMapping(register Cl
  */
 
 int
-ProcXGetDeviceButtonMapping(register ClientPtr client)
+ProcXGetDeviceButtonMapping(ClientPtr client)
 {
     DeviceIntPtr dev;
     xGetDeviceButtonMappingReply rep;
@@ -136,7 +136,7 @@ void
 SRepXGetDeviceButtonMapping(ClientPtr client, int size,
 			    xGetDeviceButtonMappingReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/getdctl.c b/Xi/getdctl.c
index c264d4f..88f061e 100644
--- a/Xi/getdctl.c
+++ b/Xi/getdctl.c
@@ -75,9 +75,9 @@ SOFTWARE.
  */
 
 int
-SProcXGetDeviceControl(register ClientPtr client)
+SProcXGetDeviceControl(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xGetDeviceControlReq);
     swaps(&stuff->length, n);
@@ -96,7 +96,7 @@ static void
 CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf,
 			 int length)
 {
-    register char n;
+    char n;
     AxisInfoPtr a;
     xDeviceResolutionState *r;
     int i, *iptr;
@@ -127,7 +127,7 @@ CopySwapDeviceResolution(ClientPtr clien
 static void CopySwapDeviceAbsCalib (ClientPtr client, AbsoluteClassPtr dts,
                                 char *buf)
 {
-    register char n;
+    char n;
     xDeviceAbsCalibState *calib = (xDeviceAbsCalibState *) buf;
 
     calib->control = DEVICE_ABS_CALIB;
@@ -158,7 +158,7 @@ static void CopySwapDeviceAbsCalib (Clie
 static void CopySwapDeviceAbsArea (ClientPtr client, AbsoluteClassPtr dts,
                                 char *buf)
 {
-    register char n;
+    char n;
     xDeviceAbsAreaState *area = (xDeviceAbsAreaState *) buf;
 
     area->control = DEVICE_ABS_AREA;
@@ -184,7 +184,7 @@ static void CopySwapDeviceAbsArea (Clien
 
 static void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf)
 {
-    register char n;
+    char n;
     xDeviceCoreState *c = (xDeviceCoreState *) buf;
 
     c->control = DEVICE_CORE;
@@ -201,7 +201,7 @@ static void CopySwapDeviceCore (ClientPt
 
 static void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf)
 {
-    register char n;
+    char n;
     xDeviceEnableState *e = (xDeviceEnableState *) buf;
 
     e->control = DEVICE_ENABLE;
@@ -225,7 +225,7 @@ static void CopySwapDeviceEnable (Client
 void
 SRepXGetDeviceControl(ClientPtr client, int size, xGetDeviceControlReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
@@ -243,7 +243,7 @@ ProcXGetDeviceControl(ClientPtr client)
 {
     int total_length = 0;
     char *buf, *savbuf;
-    register DeviceIntPtr dev;
+    DeviceIntPtr dev;
     xGetDeviceControlReply rep;
 
     REQUEST(xGetDeviceControlReq);
diff --git a/Xi/getfctl.c b/Xi/getfctl.c
index 28360ee..5ca90db 100644
--- a/Xi/getfctl.c
+++ b/Xi/getfctl.c
@@ -75,9 +75,9 @@ SOFTWARE.
  */
 
 int
-SProcXGetFeedbackControl(register ClientPtr client)
+SProcXGetFeedbackControl(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xGetFeedbackControlReq);
     swaps(&stuff->length, n);
@@ -94,7 +94,7 @@ static void
 CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf)
 {
     int i;
-    register char n;
+    char n;
     xKbdFeedbackState *k2;
 
     k2 = (xKbdFeedbackState *) * buf;
@@ -128,7 +128,7 @@ CopySwapKbdFeedback(ClientPtr client, Kb
 static void
 CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf)
 {
-    register char n;
+    char n;
     xPtrFeedbackState *p2;
 
     p2 = (xPtrFeedbackState *) * buf;
@@ -156,7 +156,7 @@ CopySwapPtrFeedback(ClientPtr client, Pt
 static void
 CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf)
 {
-    register char n;
+    char n;
     xIntegerFeedbackState *i2;
 
     i2 = (xIntegerFeedbackState *) * buf;
@@ -185,7 +185,7 @@ static void
 CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf)
 {
     int i;
-    register char n;
+    char n;
     xStringFeedbackState *s2;
     KeySym *kptr;
 
@@ -221,7 +221,7 @@ CopySwapStringFeedback(ClientPtr client,
 static void
 CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf)
 {
-    register char n;
+    char n;
     xLedFeedbackState *l2;
 
     l2 = (xLedFeedbackState *) * buf;
@@ -247,7 +247,7 @@ CopySwapLedFeedback(ClientPtr client, Le
 static void
 CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf)
 {
-    register char n;
+    char n;
     xBellFeedbackState *b2;
 
     b2 = (xBellFeedbackState *) * buf;
@@ -276,7 +276,7 @@ void
 SRepXGetFeedbackControl(ClientPtr client, int size,
 			xGetFeedbackControlReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
@@ -295,7 +295,7 @@ ProcXGetFeedbackControl(ClientPtr client
 {
     int total_length = 0;
     char *buf, *savbuf;
-    register DeviceIntPtr dev;
+    DeviceIntPtr dev;
     KbdFeedbackPtr k;
     PtrFeedbackPtr p;
     IntegerFeedbackPtr i;
diff --git a/Xi/getfocus.c b/Xi/getfocus.c
index 1bcb673..245b5f1 100644
--- a/Xi/getfocus.c
+++ b/Xi/getfocus.c
@@ -75,9 +75,9 @@ SOFTWARE.
  */
 
 int
-SProcXGetDeviceFocus(register ClientPtr client)
+SProcXGetDeviceFocus(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xGetDeviceFocusReq);
     swaps(&stuff->length, n);
@@ -138,7 +138,7 @@ ProcXGetDeviceFocus(ClientPtr client)
 void
 SRepXGetDeviceFocus(ClientPtr client, int size, xGetDeviceFocusReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/getkmap.c b/Xi/getkmap.c
index 041e2c6..989f3d5 100644
--- a/Xi/getkmap.c
+++ b/Xi/getkmap.c
@@ -76,9 +76,9 @@ SOFTWARE.
  */
 
 int
-SProcXGetDeviceKeyMapping(register ClientPtr client)
+SProcXGetDeviceKeyMapping(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xGetDeviceKeyMappingReq);
     swaps(&stuff->length, n);
@@ -92,7 +92,7 @@ SProcXGetDeviceKeyMapping(register Clien
  */
 
 int
-ProcXGetDeviceKeyMapping(register ClientPtr client)
+ProcXGetDeviceKeyMapping(ClientPtr client)
 {
     xGetDeviceKeyMappingReply rep;
     DeviceIntPtr dev;
@@ -154,7 +154,7 @@ void
 SRepXGetDeviceKeyMapping(ClientPtr client, int size,
 			 xGetDeviceKeyMappingReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/getmmap.c b/Xi/getmmap.c
index e664dc9..038937e 100644
--- a/Xi/getmmap.c
+++ b/Xi/getmmap.c
@@ -75,9 +75,9 @@ SOFTWARE.
  */
 
 int
-SProcXGetDeviceModifierMapping(register ClientPtr client)
+SProcXGetDeviceModifierMapping(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xGetDeviceModifierMappingReq);
     swaps(&stuff->length, n);
@@ -141,7 +141,7 @@ void
 SRepXGetDeviceModifierMapping(ClientPtr client, int size,
 			      xGetDeviceModifierMappingReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/getprop.c b/Xi/getprop.c
index 058c595..6fa1986 100644
--- a/Xi/getprop.c
+++ b/Xi/getprop.c
@@ -79,9 +79,9 @@ extern int ExtEventIndex;
  */
 
 int
-SProcXGetDeviceDontPropagateList(register ClientPtr client)
+SProcXGetDeviceDontPropagateList(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xGetDeviceDontPropagateListReq);
     swaps(&stuff->length, n);
@@ -97,7 +97,7 @@ SProcXGetDeviceDontPropagateList(registe
  */
 
 int
-ProcXGetDeviceDontPropagateList(register ClientPtr client)
+ProcXGetDeviceDontPropagateList(ClientPtr client)
 {
     CARD16 count = 0;
     int i, rc;
@@ -187,7 +187,7 @@ void
 SRepXGetDeviceDontPropagateList(ClientPtr client, int size,
 				xGetDeviceDontPropagateListReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/getselev.c b/Xi/getselev.c
index 533c66c..9c5f219 100644
--- a/Xi/getselev.c
+++ b/Xi/getselev.c
@@ -77,9 +77,9 @@ SOFTWARE.
  */
 
 int
-SProcXGetSelectedExtensionEvents(register ClientPtr client)
+SProcXGetSelectedExtensionEvents(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xGetSelectedExtensionEventsReq);
     swaps(&stuff->length, n);
@@ -96,7 +96,7 @@ SProcXGetSelectedExtensionEvents(registe
  */
 
 int
-ProcXGetSelectedExtensionEvents(register ClientPtr client)
+ProcXGetSelectedExtensionEvents(ClientPtr client)
 {
     int i, rc, total_length = 0;
     xGetSelectedExtensionEventsReply rep;
@@ -177,7 +177,7 @@ void
 SRepXGetSelectedExtensionEvents(ClientPtr client, int size,
 				xGetSelectedExtensionEventsReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/getvers.c b/Xi/getvers.c
index c5f1750..b3f4c1c 100644
--- a/Xi/getvers.c
+++ b/Xi/getvers.c
@@ -76,9 +76,9 @@ XExtensionVersion AllExtensionVersions[1
  */
 
 int
-SProcXGetExtensionVersion(register ClientPtr client)
+SProcXGetExtensionVersion(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xGetExtensionVersionReq);
     swaps(&stuff->length, n);
@@ -94,7 +94,7 @@ SProcXGetExtensionVersion(register Clien
  */
 
 int
-ProcXGetExtensionVersion(register ClientPtr client)
+ProcXGetExtensionVersion(ClientPtr client)
 {
     xGetExtensionVersionReply rep;
 
@@ -136,7 +136,7 @@ void
 SRepXGetExtensionVersion(ClientPtr client, int size,
 			 xGetExtensionVersionReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/grabdev.c b/Xi/grabdev.c
index 3af2346..e2809ef 100644
--- a/Xi/grabdev.c
+++ b/Xi/grabdev.c
@@ -79,11 +79,11 @@ extern int ExtEventIndex;
  */
 
 int
-SProcXGrabDevice(register ClientPtr client)
+SProcXGrabDevice(ClientPtr client)
 {
-    register char n;
-    register long *p;
-    register int i;
+    char n;
+    long *p;
+    int i;
 
     REQUEST(xGrabDeviceReq);
     swaps(&stuff->length, n);
@@ -202,7 +202,7 @@ CreateMaskFromList(ClientPtr client, XEv
 void
 SRepXGrabDevice(ClientPtr client, int size, xGrabDeviceReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/grabdevb.c b/Xi/grabdevb.c
index 4333550..df62d0c 100644
--- a/Xi/grabdevb.c
+++ b/Xi/grabdevb.c
@@ -77,11 +77,11 @@ SOFTWARE.
  */
 
 int
-SProcXGrabDeviceButton(register ClientPtr client)
+SProcXGrabDeviceButton(ClientPtr client)
 {
-    register char n;
-    register long *p;
-    register int i;
+    char n;
+    long *p;
+    int i;
 
     REQUEST(xGrabDeviceButtonReq);
     swaps(&stuff->length, n);
diff --git a/Xi/grabdevk.c b/Xi/grabdevk.c
index 71e72d5..b74592f 100644
--- a/Xi/grabdevk.c
+++ b/Xi/grabdevk.c
@@ -77,11 +77,11 @@ SOFTWARE.
  */
 
 int
-SProcXGrabDeviceKey(register ClientPtr client)
+SProcXGrabDeviceKey(ClientPtr client)
 {
-    register char n;
-    register long *p;
-    register int i;
+    char n;
+    long *p;
+    int i;
 
     REQUEST(xGrabDeviceKeyReq);
     swaps(&stuff->length, n);
diff --git a/Xi/gtmotion.c b/Xi/gtmotion.c
index 435ab0b..cfc7f89 100644
--- a/Xi/gtmotion.c
+++ b/Xi/gtmotion.c
@@ -75,9 +75,9 @@ SOFTWARE.
  */
 
 int
-SProcXGetDeviceMotionEvents(register ClientPtr client)
+SProcXGetDeviceMotionEvents(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xGetDeviceMotionEventsReq);
     swaps(&stuff->length, n);
@@ -162,7 +162,7 @@ ProcXGetDeviceMotionEvents(ClientPtr cli
     WriteReplyToClient(client, sizeof(xGetDeviceMotionEventsReply), &rep);
     if (nEvents) {
 	if (client->swapped) {
-	    register char n;
+	    char n;
 
 	    bufptr = coords;
 	    for (i = 0; i < nEvents * (axes + 1); i++) {
@@ -188,7 +188,7 @@ void
 SRepXGetDeviceMotionEvents(ClientPtr client, int size,
 			   xGetDeviceMotionEventsReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/listdev.c b/Xi/listdev.c
index 257ee59..160ad02 100644
--- a/Xi/listdev.c
+++ b/Xi/listdev.c
@@ -77,9 +77,9 @@ SOFTWARE.
  */
 
 int
-SProcXListInputDevices(register ClientPtr client)
+SProcXListInputDevices(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xListInputDevicesReq);
     swaps(&stuff->length, n);
@@ -144,9 +144,9 @@ CopyDeviceName(char **namebuf, char *nam
  */
 
 static void
-CopySwapButtonClass(register ClientPtr client, ButtonClassPtr b, char **buf)
+CopySwapButtonClass(ClientPtr client, ButtonClassPtr b, char **buf)
 {
-    register char n;
+    char n;
     xButtonInfoPtr b2;
 
     b2 = (xButtonInfoPtr) * buf;
@@ -166,10 +166,10 @@ CopySwapButtonClass(register ClientPtr c
  */
 
 static void
-CopySwapDevice(register ClientPtr client, DeviceIntPtr d, int num_classes,
+CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes,
 	       char **buf)
 {
-    register char n;
+    char n;
     xDeviceInfoPtr dev;
 
     dev = (xDeviceInfoPtr) * buf;
@@ -200,9 +200,9 @@ CopySwapDevice(register ClientPtr client
  */
 
 static void
-CopySwapKeyClass(register ClientPtr client, KeyClassPtr k, char **buf)
+CopySwapKeyClass(ClientPtr client, KeyClassPtr k, char **buf)
 {
-    register char n;
+    char n;
     xKeyInfoPtr k2;
 
     k2 = (xKeyInfoPtr) * buf;
@@ -230,10 +230,10 @@ CopySwapKeyClass(register ClientPtr clie
  */
 
 static int
-CopySwapValuatorClass(register ClientPtr client, ValuatorClassPtr v, char **buf)
+CopySwapValuatorClass(ClientPtr client, ValuatorClassPtr v, char **buf)
 {
     int i, j, axes, t_axes;
-    register char n;
+    char n;
     xValuatorInfoPtr v2;
     AxisInfo *a;
     xAxisInfoPtr a2;
@@ -305,7 +305,7 @@ ListDeviceInfo(ClientPtr client, DeviceI
  */
 
 int
-ProcXListInputDevices(register ClientPtr client)
+ProcXListInputDevices(ClientPtr client)
 {
     xListInputDevicesReply rep;
     int numdevs = 0;
@@ -367,7 +367,7 @@ ProcXListInputDevices(register ClientPtr
 void
 SRepXListInputDevices(ClientPtr client, int size, xListInputDevicesReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/opendev.c b/Xi/opendev.c
index 6361068..4b7b6a6 100644
--- a/Xi/opendev.c
+++ b/Xi/opendev.c
@@ -79,9 +79,9 @@ extern CARD8 event_base[];
  */
 
 int
-SProcXOpenDevice(register ClientPtr client)
+SProcXOpenDevice(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xOpenDeviceReq);
     swaps(&stuff->length, n);
@@ -95,7 +95,7 @@ SProcXOpenDevice(register ClientPtr clie
  */
 
 int
-ProcXOpenDevice(register ClientPtr client)
+ProcXOpenDevice(ClientPtr client)
 {
     xInputClassInfo evbase[numInputClasses];
     Bool enableit = FALSE;
@@ -179,7 +179,7 @@ ProcXOpenDevice(register ClientPtr clien
 void
 SRepXOpenDevice(ClientPtr client, int size, xOpenDeviceReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/queryst.c b/Xi/queryst.c
index c4cc5a2..972cd2c 100644
--- a/Xi/queryst.c
+++ b/Xi/queryst.c
@@ -58,9 +58,9 @@ from The Open Group.
  */
 
 int
-SProcXQueryDeviceState(register ClientPtr client)
+SProcXQueryDeviceState(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xQueryDeviceStateReq);
     swaps(&stuff->length, n);
@@ -74,9 +74,9 @@ SProcXQueryDeviceState(register ClientPt
  */
 
 int
-ProcXQueryDeviceState(register ClientPtr client)
+ProcXQueryDeviceState(ClientPtr client)
 {
-    register char n;
+    char n;
     int i;
     int num_classes = 0;
     int total_length = 0;
@@ -187,7 +187,7 @@ ProcXQueryDeviceState(register ClientPtr
 void
 SRepXQueryDeviceState(ClientPtr client, int size, xQueryDeviceStateReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/selectev.c b/Xi/selectev.c
index 8c893ca..d52db1b 100644
--- a/Xi/selectev.c
+++ b/Xi/selectev.c
@@ -128,11 +128,11 @@ HandleDevicePresenceMask(ClientPtr clien
  */
 
 int
-SProcXSelectExtensionEvent(register ClientPtr client)
+SProcXSelectExtensionEvent(ClientPtr client)
 {
-    register char n;
-    register long *p;
-    register int i;
+    char n;
+    long *p;
+    int i;
 
     REQUEST(xSelectExtensionEventReq);
     swaps(&stuff->length, n);
@@ -154,7 +154,7 @@ SProcXSelectExtensionEvent(register Clie
  */
 
 int
-ProcXSelectExtensionEvent(register ClientPtr client)
+ProcXSelectExtensionEvent(ClientPtr client)
 {
     int ret;
     int i;
diff --git a/Xi/sendexev.c b/Xi/sendexev.c
index c2763bb..eac9abe 100644
--- a/Xi/sendexev.c
+++ b/Xi/sendexev.c
@@ -80,11 +80,11 @@ extern int lastEvent;	/* Defined in exte
  */
 
 int
-SProcXSendExtensionEvent(register ClientPtr client)
+SProcXSendExtensionEvent(ClientPtr client)
 {
-    register char n;
-    register long *p;
-    register int i;
+    char n;
+    long *p;
+    int i;
     xEvent eventT;
     xEvent *eventP;
     EventSwapPtr proc;
@@ -119,7 +119,7 @@ SProcXSendExtensionEvent(register Client
  */
 
 int
-ProcXSendExtensionEvent(register ClientPtr client)
+ProcXSendExtensionEvent(ClientPtr client)
 {
     int ret;
     DeviceIntPtr dev;
diff --git a/Xi/setbmap.c b/Xi/setbmap.c
index 14b1689..bdfa513 100644
--- a/Xi/setbmap.c
+++ b/Xi/setbmap.c
@@ -78,9 +78,9 @@ SOFTWARE.
  */
 
 int
-SProcXSetDeviceButtonMapping(register ClientPtr client)
+SProcXSetDeviceButtonMapping(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xSetDeviceButtonMappingReq);
     swaps(&stuff->length, n);
@@ -94,7 +94,7 @@ SProcXSetDeviceButtonMapping(register Cl
  */
 
 int
-ProcXSetDeviceButtonMapping(register ClientPtr client)
+ProcXSetDeviceButtonMapping(ClientPtr client)
 {
     int ret;
     xSetDeviceButtonMappingReply rep;
@@ -149,7 +149,7 @@ void
 SRepXSetDeviceButtonMapping(ClientPtr client, int size,
 			    xSetDeviceButtonMappingReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/setdval.c b/Xi/setdval.c
index 958b2ac..e947a74 100644
--- a/Xi/setdval.c
+++ b/Xi/setdval.c
@@ -75,9 +75,9 @@ SOFTWARE.
  */
 
 int
-SProcXSetDeviceValuators(register ClientPtr client)
+SProcXSetDeviceValuators(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xSetDeviceValuatorsReq);
     swaps(&stuff->length, n);
@@ -91,7 +91,7 @@ SProcXSetDeviceValuators(register Client
  */
 
 int
-ProcXSetDeviceValuators(register ClientPtr client)
+ProcXSetDeviceValuators(ClientPtr client)
 {
     DeviceIntPtr dev;
     xSetDeviceValuatorsReply rep;
@@ -152,7 +152,7 @@ void
 SRepXSetDeviceValuators(ClientPtr client, int size,
 			xSetDeviceValuatorsReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/setfocus.c b/Xi/setfocus.c
index 59fe076..aaf88ce 100644
--- a/Xi/setfocus.c
+++ b/Xi/setfocus.c
@@ -78,9 +78,9 @@ SOFTWARE.
  */
 
 int
-SProcXSetDeviceFocus(register ClientPtr client)
+SProcXSetDeviceFocus(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xSetDeviceFocusReq);
     swaps(&stuff->length, n);
@@ -97,10 +97,10 @@ SProcXSetDeviceFocus(register ClientPtr 
  */
 
 int
-ProcXSetDeviceFocus(register ClientPtr client)
+ProcXSetDeviceFocus(ClientPtr client)
 {
     int ret;
-    register DeviceIntPtr dev;
+    DeviceIntPtr dev;
 
     REQUEST(xSetDeviceFocusReq);
     REQUEST_SIZE_MATCH(xSetDeviceFocusReq);
diff --git a/Xi/setmmap.c b/Xi/setmmap.c
index 645f246..0078499 100644
--- a/Xi/setmmap.c
+++ b/Xi/setmmap.c
@@ -76,9 +76,9 @@ SOFTWARE.
  */
 
 int
-SProcXSetDeviceModifierMapping(register ClientPtr client)
+SProcXSetDeviceModifierMapping(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xSetDeviceModifierMappingReq);
     swaps(&stuff->length, n);
@@ -145,7 +145,7 @@ void
 SRepXSetDeviceModifierMapping(ClientPtr client, int size,
 			      xSetDeviceModifierMappingReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/setmode.c b/Xi/setmode.c
index 11feb6d..688f2a2 100644
--- a/Xi/setmode.c
+++ b/Xi/setmode.c
@@ -75,9 +75,9 @@ SOFTWARE.
  */
 
 int
-SProcXSetDeviceMode(register ClientPtr client)
+SProcXSetDeviceMode(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xSetDeviceModeReq);
     swaps(&stuff->length, n);
@@ -91,7 +91,7 @@ SProcXSetDeviceMode(register ClientPtr c
  */
 
 int
-ProcXSetDeviceMode(register ClientPtr client)
+ProcXSetDeviceMode(ClientPtr client)
 {
     DeviceIntPtr dev;
     xSetDeviceModeReply rep;
@@ -139,7 +139,7 @@ ProcXSetDeviceMode(register ClientPtr cl
 void
 SRepXSetDeviceMode(ClientPtr client, int size, xSetDeviceModeReply * rep)
 {
-    register char n;
+    char n;
 
     swaps(&rep->sequenceNumber, n);
     swapl(&rep->length, n);
diff --git a/Xi/stubs.c b/Xi/stubs.c
index e2ed1ce..ed041b8 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -168,7 +168,7 @@ OpenInputDevice(DeviceIntPtr dev, Client
  */
 
 int
-SetDeviceMode(register ClientPtr client, DeviceIntPtr dev, int mode)
+SetDeviceMode(ClientPtr client, DeviceIntPtr dev, int mode)
 {
     return BadMatch;
 }
@@ -186,7 +186,7 @@ SetDeviceMode(register ClientPtr client,
  */
 
 int
-SetDeviceValuators(register ClientPtr client, DeviceIntPtr dev,
+SetDeviceValuators(ClientPtr client, DeviceIntPtr dev,
 		   int *valuators, int first_valuator, int num_valuators)
 {
     return BadMatch;
@@ -201,7 +201,7 @@ SetDeviceValuators(register ClientPtr cl
  */
 
 int
-ChangeDeviceControl(register ClientPtr client, DeviceIntPtr dev,
+ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
 		    xDeviceCtl * control)
 {
     switch (control->control) {
diff --git a/Xi/ungrdev.c b/Xi/ungrdev.c
index 980fa93..0abbd2e 100644
--- a/Xi/ungrdev.c
+++ b/Xi/ungrdev.c
@@ -74,9 +74,9 @@ SOFTWARE.
  */
 
 int
-SProcXUngrabDevice(register ClientPtr client)
+SProcXUngrabDevice(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xUngrabDeviceReq);
     swaps(&stuff->length, n);
@@ -92,7 +92,7 @@ SProcXUngrabDevice(register ClientPtr cl
  */
 
 int
-ProcXUngrabDevice(register ClientPtr client)
+ProcXUngrabDevice(ClientPtr client)
 {
     DeviceIntPtr dev;
     GrabPtr grab;
diff --git a/Xi/ungrdevb.c b/Xi/ungrdevb.c
index 8db9307..b9f236b 100644
--- a/Xi/ungrdevb.c
+++ b/Xi/ungrdevb.c
@@ -80,9 +80,9 @@ SOFTWARE.
  */
 
 int
-SProcXUngrabDeviceButton(register ClientPtr client)
+SProcXUngrabDeviceButton(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xUngrabDeviceButtonReq);
     swaps(&stuff->length, n);
diff --git a/Xi/ungrdevk.c b/Xi/ungrdevk.c
index ebb83bc..d316990 100644
--- a/Xi/ungrdevk.c
+++ b/Xi/ungrdevk.c
@@ -80,9 +80,9 @@ SOFTWARE.
  */
 
 int
-SProcXUngrabDeviceKey(register ClientPtr client)
+SProcXUngrabDeviceKey(ClientPtr client)
 {
-    register char n;
+    char n;
 
     REQUEST(xUngrabDeviceKeyReq);
     swaps(&stuff->length, n);
diff-tree 82a8b99a6c46018885600011913267d8af9dfe13 (from 8c7f56d92d8471ee059c14d322af5f7f555dd5c6)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Wed Mar 28 15:17:02 2007 -0400

    Move the XAA private indices to be static.
    
    Technically this is an ABI break, if you aren't smart enough to be using the
    getter functions.  Cope.

diff --git a/hw/xfree86/xaa/xaaDashLine.c b/hw/xfree86/xaa/xaaDashLine.c
index 2a94a9e..1a4732b 100644
--- a/hw/xfree86/xaa/xaaDashLine.c
+++ b/hw/xfree86/xaa/xaaDashLine.c
@@ -35,7 +35,7 @@ XAAPolyLinesDashed(
 #endif
 ){
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-    XAAGCPtr   pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGCIndex].ptr;
+    XAAGCPtr   pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr;
     BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip);
     int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip);
     unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
diff --git a/hw/xfree86/xaa/xaaGC.c b/hw/xfree86/xaa/xaaGC.c
index e220811..f3434c9 100644
--- a/hw/xfree86/xaa/xaaGC.c
+++ b/hw/xfree86/xaa/xaaGC.c
@@ -38,7 +38,7 @@ Bool
 XAACreateGC(GCPtr pGC)
 {
     ScreenPtr    pScreen = pGC->pScreen;
-    XAAGCPtr     pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGCIndex].ptr);
+    XAAGCPtr     pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);
     Bool         ret;
 
     XAA_SCREEN_PROLOGUE(pScreen,CreateGC);
diff --git a/hw/xfree86/xaa/xaaGCmisc.c b/hw/xfree86/xaa/xaaGCmisc.c
index f7bd576..a7a3f40 100644
--- a/hw/xfree86/xaa/xaaGCmisc.c
+++ b/hw/xfree86/xaa/xaaGCmisc.c
@@ -305,7 +305,7 @@ XAAValidatePolylines(
    DrawablePtr   pDraw )
 {
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-   XAAGCPtr   pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGCIndex].ptr;
+   XAAGCPtr   pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr;
 
    if(pGC->lineStyle == LineSolid) changes &= ~GCDashList;
    if(!changes) return;
diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
index 79a0e4c..529dbd1 100644
--- a/hw/xfree86/xaa/xaaInit.c
+++ b/hw/xfree86/xaa/xaaInit.c
@@ -42,14 +42,9 @@ static int  XAASetDGAMode(int index, int
 static void XAAEnableDisableFBAccess (int index, Bool enable);
 static Bool XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask);
 
-/*
- * XXX These three should be static, but that breaks ABI compat with XF4.4
- * and Xorg 6.7.0 modules.  DO NOT use them in new code, you should never
- * be setting them, and you've got Get functions below.
- */
-int XAAScreenIndex = -1;
-int XAAGCIndex = -1;
-int XAAPixmapIndex = -1;
+static int XAAScreenIndex = -1;
+static int XAAGCIndex = -1;
+static int XAAPixmapIndex = -1;
 
 static unsigned long XAAGeneration = 0;
 
diff --git a/hw/xfree86/xaa/xaaLineMisc.c b/hw/xfree86/xaa/xaaLineMisc.c
index d786737..537b08b 100644
--- a/hw/xfree86/xaa/xaaLineMisc.c
+++ b/hw/xfree86/xaa/xaaLineMisc.c
@@ -64,7 +64,7 @@ void
 XAAComputeDash(GCPtr pGC)
 {
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-    XAAGCPtr   pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGCIndex].ptr;
+    XAAGCPtr   pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr;
     Bool EvenDash = (pGC->numInDashList & 0x01) ? FALSE : TRUE;
     int PatternLength = 0;
     unsigned char* DashPtr = (unsigned char*)pGC->dash;
diff --git a/hw/xfree86/xaa/xaaWrapper.c b/hw/xfree86/xaa/xaaWrapper.c
index 5b52568..6d8107b 100644
--- a/hw/xfree86/xaa/xaaWrapper.c
+++ b/hw/xfree86/xaa/xaaWrapper.c
@@ -522,7 +522,7 @@ void
 XAASync(ScreenPtr pScreen)
 {
     XAAScreenPtr pScreenPriv = 
-	(XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr;
+	(XAAScreenPtr) pScreen->devPrivates[XAAGetScreenIndex()].ptr;
     XAAInfoRecPtr infoRec = pScreenPriv->AccelInfoRec;
 
     if(infoRec->NeedToSync) {
diff --git a/hw/xfree86/xaa/xaalocal.h b/hw/xfree86/xaa/xaalocal.h
index 7210d84..c365a7d 100644
--- a/hw/xfree86/xaa/xaalocal.h
+++ b/hw/xfree86/xaa/xaalocal.h
@@ -1640,9 +1640,6 @@ XAAGetPixelFromRGBA (
 extern GCOps XAAFallbackOps;
 extern GCOps *XAAGetFallbackOps(void);
 extern GCFuncs XAAGCFuncs;
-extern int XAAScreenIndex;	/* XXX DONTUSE */
-extern int XAAGCIndex;		/* XXX DONTUSE */
-extern int XAAPixmapIndex;	/* XXX DONTUSE */
 extern int XAAGetScreenIndex(void);
 extern int XAAGetGCIndex(void);
 extern int XAAGetPixmapIndex(void);
diff-tree 8c7f56d92d8471ee059c14d322af5f7f555dd5c6 (from 5ba4d9eedf1b4ce4795bf910cd184872e2d9b3fc)
Author: Tomas Janousek <tomi at nomi.cz>
Date:   Wed Mar 28 14:46:30 2007 -0400

    Bug #10296: Fix timer rescheduling.

diff --git a/os/WaitFor.c b/os/WaitFor.c
index d39964f..4a606ac 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -125,7 +125,7 @@ struct _OsTimerRec {
 };
 
 static void DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev);
-static void CheckAllTimers(CARD32 now);
+static void CheckAllTimers(void);
 static OsTimerPtr timers = NULL;
 
 /*****************
@@ -204,7 +204,7 @@ WaitForSomething(int *pClientsReady)
 	    timeout = timers->expires - now;
             if (timeout > 0 && timeout > timers->delta + 250) {
                 /* time has rewound.  reset the timers. */
-                CheckAllTimers(now);
+                CheckAllTimers();
             }
 
 	    if (timers) {
@@ -436,11 +436,14 @@ ANYSET(FdMask *src)
 /* If time has rewound, re-run every affected timer.
  * Timers might drop out of the list, so we have to restart every time. */
 static void
-CheckAllTimers(CARD32 now)
+CheckAllTimers(void)
 {
     OsTimerPtr timer;
+    CARD32 now;
 
 start:
+    now = GetTimeInMillis();
+
     for (timer = timers; timer; timer = timer->next) {
         if (timer->expires - now > timer->delta + 250) {
             TimerForce(timer);
diff-tree 5ba4d9eedf1b4ce4795bf910cd184872e2d9b3fc (from 85220446359a75ea2c359b418b4051c04eea739c)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Wed Mar 28 12:03:19 2007 -0400

    Refuse to create tiny modes from EDID detailed timing.

diff --git a/hw/xfree86/ddc/edid_modes.c b/hw/xfree86/ddc/edid_modes.c
index cfc8ddc..926bc89 100644
--- a/hw/xfree86/ddc/edid_modes.c
+++ b/hw/xfree86/ddc/edid_modes.c
@@ -107,6 +107,19 @@ DDCModeFromDetailedTiming(int scrnIndex,
 {
     DisplayModePtr Mode;
 
+    /*
+     * Refuse to create modes that are insufficiently large.  64 is a random
+     * number, maybe the spec says something about what the minimum is.  In
+     * particular I see this frequently with _old_ EDID, 1.0 or so, so maybe
+     * our parser is just being too aggresive there.
+     */
+    if (timing->h_active < 64 || timing->v_active < 64) {
+	xf86DrvMsg(scrnIndex, X_INFO,
+		   "%s: Ignoring tiny %dx%d mode\n", __func__,
+		   timing->h_active, timing->v_active);
+	return NULL;
+    }
+
     /* We don't do stereo */
     if (timing->stereo) {
         xf86DrvMsg(scrnIndex, X_INFO,
diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index c4cf687..7a8ec19 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -197,6 +197,19 @@ DDCModeFromDetailedTiming(int scrnIndex,
 {
     DisplayModePtr Mode;
 
+    /*
+     * Refuse to create modes that are insufficiently large.  64 is a random
+     * number, maybe the spec says something about what the minimum is.  In
+     * particular I see this frequently with _old_ EDID, 1.0 or so, so maybe
+     * our parser is just being too aggresive there.
+     */
+    if (timing->h_active < 64 || timing->v_active < 64) {
+	xf86DrvMsg(scrnIndex, X_INFO,
+		   "%s: Ignoring tiny %dx%d mode\n", __func__,
+		   timing->h_active, timing->v_active);
+	return NULL;
+    }
+
     /* We don't do stereo */
     if (timing->stereo) {
         xf86DrvMsg(scrnIndex, X_INFO,



More information about the xorg-commit mailing list