xserver: Branch 'glucose-2' - 46 commits

Alan Hourihane alanh at kemper.freedesktop.org
Tue Mar 27 14:24:19 EEST 2007


 GL/glx/glxdri.c                             |    1 
 GL/mesa/main/Makefile.am                    |    1 
 GL/mesa/shader/Makefile.am                  |   13 
 GL/mesa/shader/slang/Makefile.am            |   22 
 GL/mesa/swrast/Makefile.am                  |    2 
 GL/mesa/tnl/Makefile.am                     |    1 
 Xext/appgroup.c                             |   52 -
 Xext/appgroup.h                             |   22 
 Xext/panoramiX.c                            |   48 -
 Xext/panoramiX.h                            |   12 
 Xext/panoramiXh.h                           |    5 
 Xext/panoramiXsrv.h                         |    3 
 Xext/saver.c                                |    4 
 Xext/security.c                             |    2 
 Xext/securitysrv.h                          |    9 
 Xext/xace.c                                 |    4 
 Xext/xace.h                                 |   10 
 Xext/xevie.c                                |    4 
 Xi/chgfctl.c                                |  261 +++----
 Xi/chgfctl.h                                |   42 -
 Xi/chgptr.h                                 |    8 
 Xi/closedev.c                               |   92 +-
 Xi/closedev.h                               |   10 
 Xi/exevents.c                               |   58 -
 Xi/exglobals.h                              |    2 
 Xi/extinit.c                                |  384 +++++-----
 Xi/getdctl.c                                |  213 ++---
 Xi/getdctl.h                                |   24 
 Xi/getfctl.c                                |  198 ++---
 Xi/getfctl.h                                |   30 
 Xi/listdev.c                                |  224 +++---
 Xi/listdev.h                                |   38 -
 afb/afb.h                                   |  124 ---
 afb/afbbitblt.c                             |  146 ----
 afb/afbcmap.c                               |   18 
 afb/afbgc.c                                 |  266 +++----
 afb/afbimage.c                              |   31 
 afb/afbpixmap.c                             |   10 
 afb/afbscrinit.c                            |   50 -
 afb/afbsetsp.c                              |   18 
 composite/compalloc.c                       |    2 
 composite/compext.c                         |   16 
 composite/compinit.c                        |    2 
 composite/compint.h                         |   15 
 configure.ac                                |    2 
 damageext/damageext.c                       |   18 
 damageext/damageextint.h                    |   14 
 dbe/dbe.c                                   |   31 
 dbe/dbestruct.h                             |    5 
 dbe/midbe.c                                 |   25 
 dix/devices.c                               |   13 
 dix/dispatch.c                              |   64 -
 dix/dixutils.c                              |    6 
 dix/events.c                                |    4 
 dix/extension.c                             |   81 --
 dix/gc.c                                    |   13 
 dix/getevents.c                             |    2 
 dix/resource.c                              |    2 
 dix/swaprep.c                               |  109 +-
 dix/window.c                                |  124 +--
 hw/dmx/dmxclient.h                          |    4 
 hw/kdrive/src/kinput.c                      |    2 
 hw/xfree86/Makefile.am                      |    1 
 hw/xfree86/common/xf86Bus.c                 |   31 
 hw/xfree86/common/xf86Bus.h                 |    3 
 hw/xfree86/common/xf86Config.c              |   30 
 hw/xfree86/common/xf86Config.h              |    1 
 hw/xfree86/common/xf86Configure.c           |    2 
 hw/xfree86/common/xf86DGA.c                 |  180 +++-
 hw/xfree86/common/xf86Events.c              |    4 
 hw/xfree86/common/xf86Globals.c             |    1 
 hw/xfree86/common/xf86Helper.c              |   13 
 hw/xfree86/common/xf86Priv.h                |    2 
 hw/xfree86/common/xf86XKB.c                 |    2 
 hw/xfree86/common/xf86Xinput.c              |   46 +
 hw/xfree86/common/xf86Xinput.h              |    8 
 hw/xfree86/common/xf86xv.c                  |    2 
 hw/xfree86/ddc/xf86DDC.c                    |   53 -
 hw/xfree86/dixmods/extmod/dgaproc.h         |    5 
 hw/xfree86/dixmods/glxmodule.c              |    4 
 hw/xfree86/dixmods/xkbKillSrv.c             |    2 
 hw/xfree86/dixmods/xkbPrivate.c             |    2 
 hw/xfree86/dixmods/xkbVT.c                  |    2 
 hw/xfree86/doc/man/xorg.conf.man.pre        |   79 ++
 hw/xfree86/dri/dri.c                        |    6 
 hw/xfree86/i2c/xf86i2cmodule.c              |   36 
 hw/xfree86/loader/Makefile.am               |    3 
 hw/xfree86/loader/dixsym.c                  |    2 
 hw/xfree86/loader/loader.c                  |  116 ---
 hw/xfree86/loader/loaderProcs.h             |    4 
 hw/xfree86/loader/loadmod.c                 |  105 --
 hw/xfree86/loader/xf86sym.c                 |    6 
 hw/xfree86/modes/Makefile.am                |    4 
 hw/xfree86/modes/xf86Crtc.c                 |   49 +
 hw/xfree86/modes/xf86Crtc.h                 |  114 ++-
 hw/xfree86/modes/xf86Cursors.c              |  607 ++++++++++++++++
 hw/xfree86/modes/xf86RandR12.c              |  140 +++
 hw/xfree86/modes/xf86Rotate.c               |   93 +-
 hw/xfree86/os-support/shared/libc_wrapper.c |    2 
 hw/xfree86/parser/DRI.c                     |   31 
 hw/xfree86/parser/Flags.c                   |    9 
 hw/xfree86/parser/Layout.c                  |   38 -
 hw/xfree86/parser/Module.c                  |    2 
 hw/xfree86/parser/Monitor.c                 |   32 
 hw/xfree86/parser/Screen.c                  |    2 
 hw/xfree86/parser/Vendor.c                  |   15 
 hw/xfree86/parser/Video.c                   |   34 
 hw/xfree86/parser/configProcs.h             |   16 
 hw/xfree86/parser/read.c                    |   38 -
 hw/xfree86/parser/scan.c                    |   16 
 hw/xfree86/parser/xf86Parser.h              |    1 
 hw/xfree86/ramdac/Makefile.am               |    6 
 hw/xfree86/ramdac/xf86Cursor.h              |    3 
 hw/xfree86/ramdac/xf86RamDacMod.c           |   46 -
 hw/xfree86/x86emu/prim_ops.c                |    4 
 hw/xfree86/xf4bpp/Makefile.am               |    1 
 hw/xfree86/xf4bpp/offscreen.c               |   19 
 hw/xfree86/xf4bpp/ppcGC.c                   |    9 
 hw/xfree86/xf4bpp/ppcPolyRec.c              |  130 ---
 hw/xfree86/xf4bpp/xf4bpp.h                  |    8 
 hw/xgl/egl/kinput.c                         |    2 
 hw/xgl/glx/xglx.c                           |    2 
 hw/xnest/Display.c                          |    2 
 hw/xnest/Keyboard.c                         |    2 
 hw/xnest/Screen.c                           |    2 
 hw/xwin/InitOutput.c                        |    2 
 hw/xwin/winconfig.c                         |    2 
 hw/xwin/winkeybd.c                          |    2 
 include/dix.h                               |   75 --
 include/exevents.h                          |   16 
 include/extinit.h                           |  119 ---
 include/extnsionst.h                        |   35 
 include/gc.h                                |    5 
 include/globals.h                           |    4 
 include/inputstr.h                          |    2 
 include/os.h                                |   14 
 include/swaprep.h                           |   18 
 include/window.h                            |   19 
 include/windowstr.h                         |    6 
 include/xkbsrv.h                            | 1022 ++++++++++++++++++++++++++++
 mi/mi.h                                     |   54 -
 mi/miarc.c                                  |   15 
 mi/mibitblt.c                               |   10 
 mi/midash.c                                 |  193 -----
 mi/mieq.c                                   |   24 
 mi/mifillarc.c                              |   18 
 mi/mifillarc.h                              |   24 
 mi/mioverlay.c                              |    4 
 mi/mipointer.c                              |   47 -
 mi/mipointer.h                              |   15 
 mi/mipoly.h                                 |    8 
 mi/mipolytext.c                             |   51 -
 mi/mipolyutil.c                             |   10 
 mi/miregion.c                               |   33 
 mi/miscrinit.c                              |   10 
 mi/mispans.c                                |   30 
 mi/mispans.h                                |   16 
 mi/miwideline.c                             |   51 -
 mi/miwideline.h                             |   42 -
 mi/mizerarc.c                               |    6 
 mi/mizerarc.h                               |    6 
 miext/damage/damage.c                       |   18 
 miext/damage/damagestr.h                    |    6 
 os/access.c                                 |    6 
 os/auth.c                                   |   20 
 os/connection.c                             |   10 
 os/io.c                                     |   23 
 os/osdep.h                                  |   14 
 os/utils.c                                  |    8 
 os/xdmcp.c                                  |   72 -
 randr/mirandr.c                             |   28 
 randr/randr.c                               |    2 
 randr/randrstr.h                            |   66 +
 randr/rrcrtc.c                              |  196 +++--
 randr/rrdispatch.c                          |    7 
 randr/rrinfo.c                              |   17 
 randr/rrmode.c                              |  217 +++++
 randr/rroutput.c                            |  150 +++-
 randr/rrproperty.c                          |  184 +++--
 randr/rrscreen.c                            |   16 
 record/set.c                                |    8 
 render/animcur.c                            |    4 
 render/glyph.c                              |    6 
 render/glyphstr.h                           |    2 
 render/picture.c                            |    2 
 xfixes/xfixes.c                             |    8 
 xfixes/xfixesint.h                          |    3 
 xkb/Makefile.am                             |    3 
 xkb/XKBAlloc.c                              |  157 ----
 xkb/XKBGAlloc.c                             |    2 
 xkb/XKBMAlloc.c                             |   82 --
 xkb/XKBMisc.c                               |  183 -----
 xkb/ddxBeep.c                               |    2 
 xkb/ddxCtrls.c                              |    2 
 xkb/ddxDevBtn.c                             |    2 
 xkb/ddxFakeBtn.c                            |    2 
 xkb/ddxFakeMtn.c                            |    2 
 xkb/ddxInit.c                               |    2 
 xkb/ddxKeyClick.c                           |    2 
 xkb/ddxKillSrv.c                            |    2 
 xkb/ddxLEDs.c                               |    4 
 xkb/ddxList.c                               |    2 
 xkb/ddxLoad.c                               |    8 
 xkb/ddxPrivate.c                            |    2 
 xkb/ddxVT.c                                 |    2 
 xkb/maprules.c                              |    2 
 xkb/xkb.c                                   |   63 -
 xkb/xkb.h                                   |   42 -
 xkb/xkbAccessX.c                            |    8 
 xkb/xkbActions.c                            |    8 
 xkb/xkbDflts.h                              |   37 -
 xkb/xkbEvents.c                             |   46 -
 xkb/xkbInit.c                               |   26 
 xkb/xkbLEDs.c                               |  453 ++++--------
 xkb/xkbPrKeyEv.c                            |    2 
 xkb/xkbSwap.c                               |    2 
 xkb/xkbUtils.c                              |   64 -
 xkb/xkberrs.c                               |   31 
 xkb/xkbfmisc.c                              |  109 --
 xkb/xkbout.c                                |  126 ---
 xkb/xkbtext.c                               |   96 --
 xkb/xkmread.c                               |   14 
 222 files changed, 4558 insertions(+), 5379 deletions(-)

New commits:
diff-tree d5aacae5b6cf72c2bdec031907de39392505ce1f (from parents)
Merge: b54340a7a9864f8851c3d7d6c767bdcf5520d804 b8f846a9dfc6697d59ad5482ba7c9d738875318e
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Tue Mar 27 12:23:44 2007 +0100

    Merge branch 'master' into glucose-2

diff-tree b8f846a9dfc6697d59ad5482ba7c9d738875318e (from a63ee90bc2d490f6c5c1802c164391963cf6c1d9)
Author: Dave Airlie <airlied at linux.ie>
Date:   Tue Mar 27 14:17:40 2007 +1000

    gl: oops dodgy s appeared pointed out by jcristau on irc..

diff --git a/GL/mesa/shader/slang/Makefile.am b/GL/mesa/shader/slang/Makefile.am
index 479de63..4bd48e9 100644
--- a/GL/mesa/shader/slang/Makefile.am
+++ b/GL/mesa/shader/slang/Makefile.am
@@ -18,8 +18,7 @@ INCLUDES = -I at MESA_SOURCE@/include \
            -I../.. \
            -I$(top_srcdir)/hw/xfree86/os-support
 
-nodist_libslang_la_SOURCES = s
-		      slang_builtin.c \
+nodist_libslang_la_SOURCES = slang_builtin.c \
 		      slang_codegen.c \
 		      slang_compile.c \
 		      slang_compile_function.c \
diff-tree a63ee90bc2d490f6c5c1802c164391963cf6c1d9 (from d387a3ddf76716791e5e8b8f0954ca0df3c579d6)
Author: Dave Airlie <airlied at pegasus.(none)>
Date:   Tue Mar 27 11:05:52 2007 +1000

    gl: update for latest mesa glsl-compiler merge

diff --git a/GL/mesa/main/Makefile.am b/GL/mesa/main/Makefile.am
index 20b7935..2b838e9 100644
--- a/GL/mesa/main/Makefile.am
+++ b/GL/mesa/main/Makefile.am
@@ -68,6 +68,7 @@ nodist_libmain_la_SOURCES = accum.c \
                     rastpos.c \
                     rbadaptors.c \
                     renderbuffer.c \
+                    shaders.c \
                     state.c \
                     stencil.c \
                     texcompress.c \
diff --git a/GL/mesa/shader/Makefile.am b/GL/mesa/shader/Makefile.am
index 3519545..abde275 100644
--- a/GL/mesa/shader/Makefile.am
+++ b/GL/mesa/shader/Makefile.am
@@ -27,8 +27,13 @@ nodist_libshader_la_SOURCES = \
                       atifragshader.c \
                       nvfragparse.c \
                       nvprogram.c \
-                      nvvertexec.c \
-		      nvvertparse.c \
+                      nvvertparse.c \
+                      prog_debug.c \
+                      prog_execute.c \
+                      prog_instruction.c \
+                      prog_parameter.c \
+                      prog_print.c \
                       program.c \
-                      shaderobjects.c \
-		      shaderobjects_3dlabs.c
+                      programopt.c \
+                      prog_statevars.c \
+                      shader_api.c
diff --git a/GL/mesa/shader/slang/Makefile.am b/GL/mesa/shader/slang/Makefile.am
index 04001c4..479de63 100644
--- a/GL/mesa/shader/slang/Makefile.am
+++ b/GL/mesa/shader/slang/Makefile.am
@@ -18,23 +18,24 @@ INCLUDES = -I at MESA_SOURCE@/include \
            -I../.. \
            -I$(top_srcdir)/hw/xfree86/os-support
 
-nodist_libslang_la_SOURCES = slang_analyse.c \
-		      slang_assemble_assignment.c \
-		      slang_assemble.c \
-		      slang_assemble_conditional.c \
-		      slang_assemble_constructor.c \
-		      slang_assemble_typeinfo.c \
+nodist_libslang_la_SOURCES = s
+		      slang_builtin.c \
+		      slang_codegen.c \
 		      slang_compile.c \
 		      slang_compile_function.c \
 		      slang_compile_operation.c \
 		      slang_compile_struct.c \
 		      slang_compile_variable.c \
-		      slang_execute.c \
-		      slang_execute_x86.c \
-		      slang_export.c \
-		      slang_library_texsample.c \
+		      slang_emit.c \
+		      slang_ir.c \
+		      slang_label.c \
 		      slang_library_noise.c \
 		      slang_link.c \
+		      slang_log.c \
 		      slang_preprocess.c \
+		      slang_print.c \
+		      slang_simplify.c \
 		      slang_storage.c \
-		      slang_utility.c
+		      slang_typeinfo.c \
+		      slang_utility.c \
+		      slang_variable.c
diff --git a/GL/mesa/swrast/Makefile.am b/GL/mesa/swrast/Makefile.am
index 5ed6576..9a6aa92 100644
--- a/GL/mesa/swrast/Makefile.am
+++ b/GL/mesa/swrast/Makefile.am
@@ -23,7 +23,6 @@ nodist_libswrast_la_SOURCES = s_aaline.c
                       s_aatriangle.c \
                       s_accum.c \
                       s_alpha.c \
-                      s_arbshader.c \
                       s_atifragshader.c \
                       s_bitmap.c \
                       s_blend.c \
@@ -39,7 +38,6 @@ nodist_libswrast_la_SOURCES = s_aaline.c
                       s_lines.c \
                       s_logic.c \
                       s_masking.c \
-                      s_nvfragprog.c \
                       s_points.c \
                       s_readpix.c \
                       s_span.c \
diff --git a/GL/mesa/tnl/Makefile.am b/GL/mesa/tnl/Makefile.am
index 5d9bdb1..84301d3 100644
--- a/GL/mesa/tnl/Makefile.am
+++ b/GL/mesa/tnl/Makefile.am
@@ -23,7 +23,6 @@ nodist_libtnl_la_SOURCES = t_context.c \
                       t_pipeline.c \
                       t_vb_arbprogram.c \
                       t_vb_arbprogram_sse.c \
-                      t_vb_arbshader.c \
                       t_vb_cull.c \
                       t_vb_fog.c \
                       t_vb_light.c \
diff-tree d387a3ddf76716791e5e8b8f0954ca0df3c579d6 (from 92ba435bd9aa7b6eca9aef8e5193576ef62fc9db)
Author: Dave Airlie <airlied at pegasus.(none)>
Date:   Tue Mar 27 11:00:13 2007 +1000

    fix loading of GLcore after recent loading changes

diff --git a/hw/xfree86/dixmods/glxmodule.c b/hw/xfree86/dixmods/glxmodule.c
index 401707a..5384f43 100644
--- a/hw/xfree86/dixmods/glxmodule.c
+++ b/hw/xfree86/dixmods/glxmodule.c
@@ -95,8 +95,8 @@ __glXMesaProxyScreenProbe(ScreenPtr pScr
   static __GLXprovider *provider;
 
   if (provider == NULL) {
-    GLcore = LoadSubModuleLocal(glxModule, "GLcore", NULL, NULL, NULL, NULL, 
-				NULL, NULL);
+    GLcore = LoadSubModule(glxModule, "GLcore", NULL, NULL, NULL, NULL, 
+			   NULL, NULL);
     if (GLcore == NULL)
       return NULL;
 
diff-tree 92ba435bd9aa7b6eca9aef8e5193576ef62fc9db (from f7c5aa0dc0fa3569a2ee412c4f996960f936b6ed)
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Mar 26 12:44:58 2007 -0700

    Update xorg.conf manpage for new RandR 1.2 monitor options.

diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre
index bbba211..cc60d07 100644
--- a/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -1004,12 +1004,22 @@ The
 .B Identifier
 entry specifies the unique name for this monitor.  The
 .B Monitor
-section provides information about the specifications of the monitor,
-monitor-specific
+section may be used to provide information about the specifications of the
+monitor, monitor-specific
 .BR Options ,
-and information about the video modes to use with the monitor.  Specifying
-video modes is optional because the server now has a built-in list of
-VESA standard modes.  When modes are specified explicitly in the
+and information about the video modes to use with the monitor.
+.PP
+With RandR 1.2-enabled drivers, monitor sections are tied to specific outputs 
+of the video card.  Each output has a name, and the server will look for a
+Monitor named
+.B \*qMonitor-outputname\*q
+for configuration of that output (for example, 
+.B \*qMonitor-VGA\*q
+for a VGA output)
+.PP
+Specifying video modes is optional because the server will use the DDC or other
+information provided by the monitor to automatically configure the list of
+modes available.  When modes are specified explicitly in the
 .B Monitor
 section (with the
 .BR Modes ,
@@ -1017,7 +1027,8 @@ section (with the
 or
 .B UseModes
 keywords), built-in modes with the same names are not included.  Built-in
-modes with different names are, however, still implicitly included.
+modes with different names are, however, still implicitly included, when they
+meet the requirements of the monitor.
 .PP
 The entries that may be used in
 .B Monitor
@@ -1214,6 +1225,62 @@ monitors do not require it.  The default
 This optional entry specifies the vertical refresh rate that the server
 should aim for when selecting video modes.  Without this option, the
 default is to prefer modes with higher refresh rates.
+.TP 7
+.BI "Option " "\*qPreferredMode\*q  " \*qstring\*q
+This optional entry specifies a mode to be marked as the preferred initial mode
+of the monitor.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qPosition\*q  " "\*qx y\*q"
+This optional entry specifies the position of the monitor within the X
+screen.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qLeftOf\*q  " \*qmonitor\*q
+This optional entry specifies that the monitor should be positioned to the
+left of the monitor of the given name.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qRightOf\*q  " \*qmonitor\*q
+This optional entry specifies that the monitor should be positioned to the
+right of the monitor of the given name.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qAbove\*q  " \*qmonitor\*q
+This optional entry specifies that the monitor should be positioned above the
+monitor of the given name.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qBelow\*q  " \*qmonitor\*q
+This optional entry specifies that the monitor should be positioned below the
+monitor of the given name.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qEnable\*q  " \*qbool\*q
+This optional entry specifies whether the monitor should be turned on
+at startup.  By default, the server will attempt to enable all connected
+monitors.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qMinClock\*q  " \*qfrequency\*q
+This optional entry specifies the minimum dot clock, in kHz, that is supported
+by the monitor.
+.TP 7
+.BI "Option " "\*qMaxClock\*q  " \*qfrequency\*q
+This optional entry specifies the maximum dot clock, in kHz, that is supported
+by the monitor.
+.TP 7
+.BI "Option " "\*qIgnore\*q  " \*qbool\*q
+This optional entry specifies that the monitor should be ignored entirely,
+and not reported through RandR.  This is useful if the hardware reports the
+presence of outputs that don't exist.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qRotate\*q  " \*qrotation\*q
+This optional entry specifies the initial rotation of the given monitor.
+Valid values for rotation are \*qnormal\*q, \*qleft\*q, \*qright\*q, and
+\*qinverted\*q.
+(RandR 1.2-supporting drivers only)
 
 .SH MODES SECTION
 The config file may have multiple
diff-tree f7c5aa0dc0fa3569a2ee412c4f996960f936b6ed (from 2e3cc861f90415f200826bc71dab6298d759c42b)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Mon Mar 26 10:21:44 2007 -0400

    Remove dead NEED_DBE_BUF_BITS code.

diff --git a/dbe/dbe.c b/dbe/dbe.c
index 862393b..d63620d 100644
--- a/dbe/dbe.c
+++ b/dbe/dbe.c
@@ -82,36 +82,6 @@ static Bool	firstRegistrationPass = TRUE
 
 /******************************************************************************
  *
- * DBE DIX Procedure: DbeValidateBuffer
- *
- * Description:
- *
- *     This function is called from VALIDATE_DRAWABLE_AND_GC and from
- *     various places in dispatch.c if the server has been compiled with
- *     the flags -DNEED_DBE_BUF_BITS and -DNEED_DBE_BUF_VALIDATE.  
- *     When pWin->dstBuffer changes, this function will be called with pWin
- *     as the first argument, the drawable ID that was specified as the
- *     second argument (could be a back buffer id), and True for the third
- *     argument.
- *     When pWin->srcBuffer changes, the third argument will be False, and
- *     the first two arguments are as described for dstBuffer.
- *
- *     This function should prepare the hardware to access the specified
- *     buffer for reads (if dstbuf is False) or writes (if dstbuf is True).
- *
- *****************************************************************************/
-
-void
-DbeValidateBuffer(WindowPtr pWin, XID drawID, Bool dstbuf)
-{
-    DbeScreenPrivPtr pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(pWin);
-    if (pDbeScreenPriv->ValidateBuffer)
-	(*pDbeScreenPriv->ValidateBuffer)(pWin, drawID, dstbuf);
-}
-
-
-/******************************************************************************
- *
  * DBE DIX Procedure: DbeRegisterFunction
  *
  * Description:
@@ -317,7 +287,6 @@ DbeStubScreen(DbeScreenPrivPtr pDbeScree
     pDbeScreenPriv->EndIdiom            = NULL;
     pDbeScreenPriv->WinPrivDelete       = NULL;
     pDbeScreenPriv->ResetProc           = NULL;
-    pDbeScreenPriv->ValidateBuffer	= NULL;
 
     (*nStubbedScreens)++;
 
diff --git a/dbe/dbestruct.h b/dbe/dbestruct.h
index 460cc75..835074c 100644
--- a/dbe/dbestruct.h
+++ b/dbe/dbestruct.h
@@ -221,11 +221,6 @@ typedef struct _DbeScreenPrivRec
     void	(*ResetProc)(
 		ScreenPtr /*pScreen*/
 );
-    void	(*ValidateBuffer)(
-		WindowPtr /*pWin*/,
-		XID /*bufId*/,
-		Bool /*dstbuffer*/
-);
 
     /* Device-specific private information.
      */
diff --git a/dbe/midbe.c b/dbe/midbe.c
index 76f0577..014e365 100644
--- a/dbe/midbe.c
+++ b/dbe/midbe.c
@@ -759,11 +759,6 @@ miDbeResetProc(ScreenPtr pScreen)
 
 } /* miDbeResetProc() */
 
-static void
-miDbeNopValidateBuffer(WindowPtr pWin, XID bufId, Bool dstbuffer)
-{
-}
-
 
 /******************************************************************************
  *
@@ -821,9 +816,6 @@ miDbeInit(ScreenPtr pScreen, DbeScreenPr
     pDbeScreenPriv->ResetProc             = miDbeResetProc;
     pDbeScreenPriv->WinPrivDelete         = miDbeWinPrivDelete;
 
-    /* The mi implementation doesn't need buffer validation. */
-    pDbeScreenPriv->ValidateBuffer	  = miDbeNopValidateBuffer;
-
     return(TRUE);
 
 } /* miDbeInit() */
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 3d8e71f..490b29c 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -1803,8 +1803,6 @@ ProcCopyArea(ClientPtr client)
     else
         pSrc = pDst;
 
-    SET_DBE_SRCBUF(pSrc, stuff->srcDrawable);
-
     pRgn = (*pGC->ops->CopyArea)(pSrc, pDst, pGC, stuff->srcX, stuff->srcY,
 				 stuff->width, stuff->height, 
 				 stuff->dstX, stuff->dstY);
@@ -1847,8 +1845,6 @@ ProcCopyPlane(ClientPtr client)
     else
         psrcDraw = pdstDraw;
 
-    SET_DBE_SRCBUF(psrcDraw, stuff->srcDrawable);
-
     /* Check to see if stuff->bitPlane has exactly ONE good bit set */
     if(stuff->bitPlane == 0 || (stuff->bitPlane & (stuff->bitPlane - 1)) ||
        (stuff->bitPlane > (1L << (psrcDraw->depth - 1))))
@@ -2208,8 +2204,6 @@ DoGetImage(ClientPtr client, int format,
 	xgi.visual = None;
     }
 
-    SET_DBE_SRCBUF(pDraw, drawable);
-
     xgi.type = X_Reply;
     xgi.sequenceNumber = client->sequence;
     xgi.depth = pDraw->depth;
diff --git a/dix/window.c b/dix/window.c
index 7d99477..96002eb 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -297,10 +297,6 @@ SetWindowToDefaults(WindowPtr pWin)
     pWin->deliverableEvents = 0;
     pWin->dontPropagate = 0;
     pWin->forcedBS = FALSE;
-#ifdef NEED_DBE_BUF_BITS
-    pWin->srcBuffer = DBE_FRONT_BUFFER;
-    pWin->dstBuffer = DBE_FRONT_BUFFER;
-#endif
 #ifdef COMPOSITE
     pWin->redirectDraw = 0;
 #endif
diff --git a/include/dix.h b/include/dix.h
index b412683..2d452d1 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -81,59 +81,6 @@ SOFTWARE.
         return(BadIDChoice);\
     }
 
-/*
- * We think that most hardware implementations of DBE will want
- * LookupID*(dbe_back_buffer_id) to return the window structure that the
- * id is a back buffer for.  Since both front and back buffers will
- * return the same structure, you need to be able to distinguish
- * somewhere what kind of buffer (front/back) was being asked for, so
- * that ddx can render to the right place.  That's the problem that the
- * following code solves.  Note: we couldn't embed this in the LookupID*
- * functions because the VALIDATE_DRAWABLE_AND_GC macro often circumvents
- * those functions by checking a one-element cache.  That's why we're
- * mucking with VALIDATE_DRAWABLE_AND_GC.
- * 
- * If you put -DNEED_DBE_BUF_BITS into PervasiveDBEDefines, the window
- * structure will have two additional bits defined, srcBuffer and
- * dstBuffer, and their values will be maintained via the macros
- * SET_DBE_DSTBUF and SET_DBE_SRCBUF (below).  If you also
- * put -DNEED_DBE_BUF_VALIDATE into PervasiveDBEDefines, the function
- * DbeValidateBuffer will be called any time the bits change to give you
- * a chance to do some setup.  See the DBE code for more details on this
- * function.  We put in these levels of conditionality so that you can do
- * just what you need to do, and no more.  If neither of these defines
- * are used, the bits won't be there, and VALIDATE_DRAWABLE_AND_GC will
- * be unchanged.	dpw
- */
-
-#if defined(NEED_DBE_BUF_BITS)
-#define SET_DBE_DSTBUF(_pDraw, _drawID) \
-        SET_DBE_BUF(_pDraw, _drawID, dstBuffer, TRUE)
-#define SET_DBE_SRCBUF(_pDraw, _drawID) \
-        SET_DBE_BUF(_pDraw, _drawID, srcBuffer, FALSE)
-#if defined (NEED_DBE_BUF_VALIDATE)
-#define SET_DBE_BUF(_pDraw, _drawID, _whichBuffer, _dstbuf) \
-    if (_pDraw->type == DRAWABLE_WINDOW)\
-    {\
-	int thisbuf = (_pDraw->id == _drawID);\
-	if (thisbuf != ((WindowPtr)_pDraw)->_whichBuffer)\
-	{\
-	     ((WindowPtr)_pDraw)->_whichBuffer = thisbuf;\
-	     DbeValidateBuffer((WindowPtr)_pDraw, _drawID, _dstbuf);\
-	}\
-     }
-#else /* want buffer bits, but don't need to call DbeValidateBuffer */
-#define SET_DBE_BUF(_pDraw, _drawID, _whichBuffer, _dstbuf) \
-    if (_pDraw->type == DRAWABLE_WINDOW)\
-    {\
-	((WindowPtr)_pDraw)->_whichBuffer = (_pDraw->id == _drawID);\
-    }
-#endif /* NEED_DBE_BUF_VALIDATE */
-#else /* don't want buffer bits in window */
-#define SET_DBE_DSTBUF(_pDraw, _drawID) /**/
-#define SET_DBE_SRCBUF(_pDraw, _drawID) /**/
-#endif /* NEED_DBE_BUF_BITS */
-
 #define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, pGC, client)\
     if ((stuff->gc == INVALID) || (client->lastGCID != stuff->gc) ||\
 	(client->lastDrawableID != drawID))\
@@ -158,7 +105,6 @@ SOFTWARE.
         pGC = client->lastGC;\
         pDraw = client->lastDrawable;\
     }\
-    SET_DBE_DSTBUF(pDraw, drawID);\
     if (pGC->serialNumber != pDraw->serialNumber)\
 	ValidateGC(pDraw, pGC);
 
diff --git a/include/windowstr.h b/include/windowstr.h
index a37dc6b..9fd6d76 100644
--- a/include/windowstr.h
+++ b/include/windowstr.h
@@ -129,12 +129,6 @@ typedef struct _Window {
     unsigned		viewable:1;	/* realized && InputOutput */
     unsigned		dontPropagate:3;/* index into DontPropagateMasks */
     unsigned		forcedBS:1;	/* system-supplied backingStore */
-#ifdef NEED_DBE_BUF_BITS
-#define DBE_FRONT_BUFFER 1
-#define DBE_BACK_BUFFER  0
-    unsigned		dstBuffer:1;	/* destination buffer for rendering */
-    unsigned		srcBuffer:1;	/* source buffer for rendering */
-#endif
 #ifdef COMPOSITE
     unsigned		redirectDraw:1;	/* rendering is redirected from here */
 #endif
diff-tree 2e3cc861f90415f200826bc71dab6298d759c42b (from e88fa75c9b468b88bb7b87b1da235c6eb2fe8164)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sun Mar 25 22:01:34 2007 -0400

    Since ddc, i2c, and ramdac are in core now, remove their ModuleData stubs.

diff --git a/hw/xfree86/ddc/xf86DDC.c b/hw/xfree86/ddc/xf86DDC.c
index 8080c8d..21984bc 100644
--- a/hw/xfree86/ddc/xf86DDC.c
+++ b/hw/xfree86/ddc/xf86DDC.c
@@ -15,52 +15,6 @@
 
 static const OptionInfoRec *DDCAvailableOptions(void *unused);
 
-#if DDC_MODULE
-
-static MODULESETUPPROTO(ddcSetup);
-
-static XF86ModuleVersionInfo ddcVersRec =
-{
-    "ddc",
-    MODULEVENDORSTRING,
-    MODINFOSTRING1,
-    MODINFOSTRING2,
-    XORG_VERSION_CURRENT,
-    1, 0, 0,
-    ABI_CLASS_VIDEODRV,		/* needs the video driver ABI */
-    ABI_VIDEODRV_VERSION,
-    MOD_CLASS_NONE,
-    {0,0,0,0}
-};
-
-_X_EXPORT XF86ModuleData ddcModuleData = { &ddcVersRec, ddcSetup, NULL };
-
-ModuleInfoRec DDC = {
-    1,
-    "DDC",
-    NULL,
-    0,
-    DDCAvailableOptions,
-};
-
-static pointer
-ddcSetup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
-    static Bool setupDone = FALSE;
-
-    if (!setupDone) {
-	setupDone = TRUE;
-	xf86AddModuleInfo(&DDC, module);
-    } 
-    /*
-     * The return value must be non-NULL on success even though there
-     * is no TearDownProc.
-     */
-    return (pointer)1;
-}
-
-#endif
-
 #define RETRIES 4
 
 static unsigned char *EDIDRead_DDC1(
diff --git a/hw/xfree86/i2c/xf86i2cmodule.c b/hw/xfree86/i2c/xf86i2cmodule.c
deleted file mode 100644
index 3c6d313..0000000
--- a/hw/xfree86/i2c/xf86i2cmodule.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* (c) Itai Nahshon
- *
- * This code is derived from and inspired by the I2C driver
- * from the Linux kernel.
- *      (c) 1998 Gerd Knorr <kraxel at cs.tu-berlin.de>
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Module.h"
-
-static MODULESETUPPROTO(i2cSetup);
-
-static XF86ModuleVersionInfo i2cVersRec =
-{
-        "i2c",
-        MODULEVENDORSTRING,
-        MODINFOSTRING1,
-        MODINFOSTRING2,
-        XORG_VERSION_CURRENT,
-        1, 2, 0,
-        ABI_CLASS_VIDEODRV,		/* This needs the video driver ABI */
-        ABI_VIDEODRV_VERSION,
-        MOD_CLASS_NONE,
-        {0,0,0,0}
-};
-
-_X_EXPORT XF86ModuleData i2cModuleData = { &i2cVersRec, i2cSetup, NULL };
-
-static pointer
-i2cSetup(pointer module, pointer opts, int *errmaj, int *errmin) {
-/* ErrorF("i2cSetup\n"); */
-   return (pointer)1;
-}
diff --git a/hw/xfree86/ramdac/xf86RamDacMod.c b/hw/xfree86/ramdac/xf86RamDacMod.c
deleted file mode 100644
index b4187a9..0000000
--- a/hw/xfree86/ramdac/xf86RamDacMod.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 1998 by Alan Hourihane, Wigan, England.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Alan Hourihane not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Alan Hourihane makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors:  Alan Hourihane, <alanh at fairlite.demon.co.uk>
- *
- * Generic RAMDAC module.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Module.h"
-
-static XF86ModuleVersionInfo VersRec = {
-	"ramdac",
-	MODULEVENDORSTRING,
-	MODINFOSTRING1,
-	MODINFOSTRING2,
-	XORG_VERSION_CURRENT,
-	0, 1, 0,
-	ABI_CLASS_VIDEODRV,
-	ABI_VIDEODRV_VERSION,
-	MOD_CLASS_NONE,
-	{0, 0, 0, 0}
-};
-
-_X_EXPORT XF86ModuleData ramdacModuleData = { &VersRec, NULL, NULL };
diff-tree e88fa75c9b468b88bb7b87b1da235c6eb2fe8164 (from 4b5802ddbd45271be3cadeae0a83a6742df2515b)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sun Mar 18 17:39:08 2007 -0400

    Static cleanup on Xi/

diff --git a/Xi/chgfctl.c b/Xi/chgfctl.c
index d0acc59..82616c6 100644
--- a/Xi/chgfctl.c
+++ b/Xi/chgfctl.c
@@ -89,137 +89,13 @@ SProcXChangeFeedbackControl(register Cli
     return (ProcXChangeFeedbackControl(client));
 }
 
-/***********************************************************************
- *
- * Change the control attributes.
- *
- */
-
-int
-ProcXChangeFeedbackControl(ClientPtr client)
-{
-    unsigned len;
-    DeviceIntPtr dev;
-    KbdFeedbackPtr k;
-    PtrFeedbackPtr p;
-    IntegerFeedbackPtr i;
-    StringFeedbackPtr s;
-    BellFeedbackPtr b;
-    LedFeedbackPtr l;
-
-    REQUEST(xChangeFeedbackControlReq);
-    REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);
-
-    len = stuff->length - (sizeof(xChangeFeedbackControlReq) >> 2);
-    dev = LookupDeviceIntRec(stuff->deviceid);
-    if (dev == NULL) {
-	SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
-			  BadDevice);
-	return Success;
-    }
-
-    switch (stuff->feedbackid) {
-    case KbdFeedbackClass:
-	if (len != (sizeof(xKbdFeedbackCtl) >> 2)) {
-	    SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
-			      0, BadLength);
-	    return Success;
-	}
-	for (k = dev->kbdfeed; k; k = k->next)
-	    if (k->ctrl.id == ((xKbdFeedbackCtl *) & stuff[1])->id) {
-		ChangeKbdFeedback(client, dev, stuff->mask, k,
-				  (xKbdFeedbackCtl *) & stuff[1]);
-		return Success;
-	    }
-	break;
-    case PtrFeedbackClass:
-	if (len != (sizeof(xPtrFeedbackCtl) >> 2)) {
-	    SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
-			      0, BadLength);
-	    return Success;
-	}
-	for (p = dev->ptrfeed; p; p = p->next)
-	    if (p->ctrl.id == ((xPtrFeedbackCtl *) & stuff[1])->id) {
-		ChangePtrFeedback(client, dev, stuff->mask, p,
-				  (xPtrFeedbackCtl *) & stuff[1]);
-		return Success;
-	    }
-	break;
-    case StringFeedbackClass:
-    {
-	register char n;
-	xStringFeedbackCtl *f = ((xStringFeedbackCtl *) & stuff[1]);
-
-	if (client->swapped) {
-	    swaps(&f->num_keysyms, n);
-	}
-	if (len != ((sizeof(xStringFeedbackCtl) >> 2) + f->num_keysyms)) {
-	    SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
-			      0, BadLength);
-	    return Success;
-	}
-	for (s = dev->stringfeed; s; s = s->next)
-	    if (s->ctrl.id == ((xStringFeedbackCtl *) & stuff[1])->id) {
-		ChangeStringFeedback(client, dev, stuff->mask, s,
-				     (xStringFeedbackCtl *) & stuff[1]);
-		return Success;
-	    }
-	break;
-    }
-    case IntegerFeedbackClass:
-	if (len != (sizeof(xIntegerFeedbackCtl) >> 2)) {
-	    SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
-			      0, BadLength);
-	    return Success;
-	}
-	for (i = dev->intfeed; i; i = i->next)
-	    if (i->ctrl.id == ((xIntegerFeedbackCtl *) & stuff[1])->id) {
-		ChangeIntegerFeedback(client, dev, stuff->mask, i,
-				      (xIntegerFeedbackCtl *) & stuff[1]);
-		return Success;
-	    }
-	break;
-    case LedFeedbackClass:
-	if (len != (sizeof(xLedFeedbackCtl) >> 2)) {
-	    SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
-			      0, BadLength);
-	    return Success;
-	}
-	for (l = dev->leds; l; l = l->next)
-	    if (l->ctrl.id == ((xLedFeedbackCtl *) & stuff[1])->id) {
-		ChangeLedFeedback(client, dev, stuff->mask, l,
-				  (xLedFeedbackCtl *) & stuff[1]);
-		return Success;
-	    }
-	break;
-    case BellFeedbackClass:
-	if (len != (sizeof(xBellFeedbackCtl) >> 2)) {
-	    SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
-			      0, BadLength);
-	    return Success;
-	}
-	for (b = dev->bell; b; b = b->next)
-	    if (b->ctrl.id == ((xBellFeedbackCtl *) & stuff[1])->id) {
-		ChangeBellFeedback(client, dev, stuff->mask, b,
-				   (xBellFeedbackCtl *) & stuff[1]);
-		return Success;
-	    }
-	break;
-    default:
-	break;
-    }
-
-    SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, BadMatch);
-    return Success;
-}
-
 /******************************************************************************
  *
  * This procedure changes KbdFeedbackClass data.
  *
  */
 
-int
+static int
 ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
 		  KbdFeedbackPtr k, xKbdFeedbackCtl * f)
 {
@@ -351,7 +227,7 @@ ChangeKbdFeedback(ClientPtr client, Devi
  *
  */
 
-int
+static int
 ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
 		  PtrFeedbackPtr p, xPtrFeedbackCtl * f)
 {
@@ -422,7 +298,7 @@ ChangePtrFeedback(ClientPtr client, Devi
  *
  */
 
-int
+static int
 ChangeIntegerFeedback(ClientPtr client, DeviceIntPtr dev,
 		      long unsigned int mask, IntegerFeedbackPtr i,
 		      xIntegerFeedbackCtl * f)
@@ -445,7 +321,7 @@ ChangeIntegerFeedback(ClientPtr client, 
  *
  */
 
-int
+static int
 ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev,
 		     long unsigned int mask, StringFeedbackPtr s,
 		     xStringFeedbackCtl * f)
@@ -495,7 +371,7 @@ ChangeStringFeedback(ClientPtr client, D
  *
  */
 
-int
+static int
 ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev,
 		   long unsigned int mask, BellFeedbackPtr b,
 		   xBellFeedbackCtl * f)
@@ -560,7 +436,7 @@ ChangeBellFeedback(ClientPtr client, Dev
  *
  */
 
-int
+static int
 ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask,
 		  LedFeedbackPtr l, xLedFeedbackCtl * f)
 {
@@ -585,3 +461,128 @@ ChangeLedFeedback(ClientPtr client, Devi
 
     return Success;
 }
+
+/***********************************************************************
+ *
+ * Change the control attributes.
+ *
+ */
+
+int
+ProcXChangeFeedbackControl(ClientPtr client)
+{
+    unsigned len;
+    DeviceIntPtr dev;
+    KbdFeedbackPtr k;
+    PtrFeedbackPtr p;
+    IntegerFeedbackPtr i;
+    StringFeedbackPtr s;
+    BellFeedbackPtr b;
+    LedFeedbackPtr l;
+
+    REQUEST(xChangeFeedbackControlReq);
+    REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);
+
+    len = stuff->length - (sizeof(xChangeFeedbackControlReq) >> 2);
+    dev = LookupDeviceIntRec(stuff->deviceid);
+    if (dev == NULL) {
+	SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0,
+			  BadDevice);
+	return Success;
+    }
+
+    switch (stuff->feedbackid) {
+    case KbdFeedbackClass:
+	if (len != (sizeof(xKbdFeedbackCtl) >> 2)) {
+	    SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
+			      0, BadLength);
+	    return Success;
+	}
+	for (k = dev->kbdfeed; k; k = k->next)
+	    if (k->ctrl.id == ((xKbdFeedbackCtl *) & stuff[1])->id) {
+		ChangeKbdFeedback(client, dev, stuff->mask, k,
+				  (xKbdFeedbackCtl *) & stuff[1]);
+		return Success;
+	    }
+	break;
+    case PtrFeedbackClass:
+	if (len != (sizeof(xPtrFeedbackCtl) >> 2)) {
+	    SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
+			      0, BadLength);
+	    return Success;
+	}
+	for (p = dev->ptrfeed; p; p = p->next)
+	    if (p->ctrl.id == ((xPtrFeedbackCtl *) & stuff[1])->id) {
+		ChangePtrFeedback(client, dev, stuff->mask, p,
+				  (xPtrFeedbackCtl *) & stuff[1]);
+		return Success;
+	    }
+	break;
+    case StringFeedbackClass:
+    {
+	register char n;
+	xStringFeedbackCtl *f = ((xStringFeedbackCtl *) & stuff[1]);
+
+	if (client->swapped) {
+	    swaps(&f->num_keysyms, n);
+	}
+	if (len != ((sizeof(xStringFeedbackCtl) >> 2) + f->num_keysyms)) {
+	    SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
+			      0, BadLength);
+	    return Success;
+	}
+	for (s = dev->stringfeed; s; s = s->next)
+	    if (s->ctrl.id == ((xStringFeedbackCtl *) & stuff[1])->id) {
+		ChangeStringFeedback(client, dev, stuff->mask, s,
+				     (xStringFeedbackCtl *) & stuff[1]);
+		return Success;
+	    }
+	break;
+    }
+    case IntegerFeedbackClass:
+	if (len != (sizeof(xIntegerFeedbackCtl) >> 2)) {
+	    SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
+			      0, BadLength);
+	    return Success;
+	}
+	for (i = dev->intfeed; i; i = i->next)
+	    if (i->ctrl.id == ((xIntegerFeedbackCtl *) & stuff[1])->id) {
+		ChangeIntegerFeedback(client, dev, stuff->mask, i,
+				      (xIntegerFeedbackCtl *) & stuff[1]);
+		return Success;
+	    }
+	break;
+    case LedFeedbackClass:
+	if (len != (sizeof(xLedFeedbackCtl) >> 2)) {
+	    SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
+			      0, BadLength);
+	    return Success;
+	}
+	for (l = dev->leds; l; l = l->next)
+	    if (l->ctrl.id == ((xLedFeedbackCtl *) & stuff[1])->id) {
+		ChangeLedFeedback(client, dev, stuff->mask, l,
+				  (xLedFeedbackCtl *) & stuff[1]);
+		return Success;
+	    }
+	break;
+    case BellFeedbackClass:
+	if (len != (sizeof(xBellFeedbackCtl) >> 2)) {
+	    SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl,
+			      0, BadLength);
+	    return Success;
+	}
+	for (b = dev->bell; b; b = b->next)
+	    if (b->ctrl.id == ((xBellFeedbackCtl *) & stuff[1])->id) {
+		ChangeBellFeedback(client, dev, stuff->mask, b,
+				   (xBellFeedbackCtl *) & stuff[1]);
+		return Success;
+	    }
+	break;
+    default:
+	break;
+    }
+
+    SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, BadMatch);
+    return Success;
+}
+
diff --git a/Xi/chgfctl.h b/Xi/chgfctl.h
index 81e1153..cfa9fc6 100644
--- a/Xi/chgfctl.h
+++ b/Xi/chgfctl.h
@@ -36,46 +36,4 @@ int SProcXChangeFeedbackControl(ClientPt
 int ProcXChangeFeedbackControl(ClientPtr	/* client */
     );
 
-int ChangeKbdFeedback(ClientPtr /* client */ ,
-		      DeviceIntPtr /* dev */ ,
-		      unsigned long /* mask */ ,
-		      KbdFeedbackPtr /* k */ ,
-		      xKbdFeedbackCtl *	/* f */
-    );
-
-int ChangePtrFeedback(ClientPtr /* client */ ,
-		      DeviceIntPtr /* dev */ ,
-		      unsigned long /* mask */ ,
-		      PtrFeedbackPtr /* p */ ,
-		      xPtrFeedbackCtl *	/* f */
-    );
-
-int ChangeIntegerFeedback(ClientPtr /* client */ ,
-			  DeviceIntPtr /* dev */ ,
-			  unsigned long /* mask */ ,
-			  IntegerFeedbackPtr /* i */ ,
-			  xIntegerFeedbackCtl *	/* f */
-    );
-
-int ChangeStringFeedback(ClientPtr /* client */ ,
-			 DeviceIntPtr /* dev */ ,
-			 unsigned long /* mask */ ,
-			 StringFeedbackPtr /* s */ ,
-			 xStringFeedbackCtl *	/* f */
-    );
-
-int ChangeBellFeedback(ClientPtr /* client */ ,
-		       DeviceIntPtr /* dev */ ,
-		       unsigned long /* mask */ ,
-		       BellFeedbackPtr /* b */ ,
-		       xBellFeedbackCtl *	/* f */
-    );
-
-int ChangeLedFeedback(ClientPtr /* client */ ,
-		      DeviceIntPtr /* dev */ ,
-		      unsigned long /* mask */ ,
-		      LedFeedbackPtr /* l */ ,
-		      xLedFeedbackCtl *	/* f */
-    );
-
 #endif /* CHGFCTL_H */
diff --git a/Xi/chgptr.h b/Xi/chgptr.h
index fb3b5cc..2d8ab66 100644
--- a/Xi/chgptr.h
+++ b/Xi/chgptr.h
@@ -45,12 +45,4 @@ void SendEventToAllWindows(DeviceIntPtr 
 			   int	/* count */
     );
 
-void FindInterestedChildren(	/* FIXME: could be static? */
-			       DeviceIntPtr /* dev */ ,
-			       WindowPtr /* p1 */ ,
-			       Mask /* mask */ ,
-			       xEvent * /* ev */ ,
-			       int	/* count */
-    );
-
 #endif /* CHGPTR_H */
diff --git a/Xi/closedev.c b/Xi/closedev.c
index cc83e6a..3d47b5f 100644
--- a/Xi/closedev.c
+++ b/Xi/closedev.c
@@ -89,42 +89,29 @@ SProcXCloseDevice(register ClientPtr cli
 
 /***********************************************************************
  *
- * This procedure closes an input device.
+ * Clear out event selections and passive grabs from a window for the
+ * specified device.
  *
  */
 
-int
-ProcXCloseDevice(register ClientPtr client)
+static void
+DeleteDeviceEvents(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client)
 {
-    int i;
-    WindowPtr pWin, p1;
-    DeviceIntPtr d;
-
-    REQUEST(xCloseDeviceReq);
-    REQUEST_SIZE_MATCH(xCloseDeviceReq);
-
-    d = LookupDeviceIntRec(stuff->deviceid);
-    if (d == NULL) {
-	SendErrorToClient(client, IReqCode, X_CloseDevice, 0, BadDevice);
-	return Success;
-    }
-
-    if (d->grab && SameClient(d->grab, client))
-	(*d->DeactivateGrab) (d);	/* release active grab */
+    InputClientsPtr others;
+    OtherInputMasks *pOthers;
+    GrabPtr grab, next;
 
-    /* Remove event selections from all windows for events from this device 
-     * and selected by this client.
-     * Delete passive grabs from all windows for this device.      */
+    if ((pOthers = wOtherInputMasks(pWin)) != 0)
+	for (others = pOthers->inputClients; others; others = others->next)
+	    if (SameClient(others, client))
+		others->mask[dev->id] = NoEventMask;
 
-    for (i = 0; i < screenInfo.numScreens; i++) {
-	pWin = WindowTable[i];
-	DeleteDeviceEvents(d, pWin, client);
-	p1 = pWin->firstChild;
-	DeleteEventsFromChildren(d, p1, client);
+    for (grab = wPassiveGrabs(pWin); grab; grab = next) {
+	next = grab->next;
+	if ((grab->device == dev) &&
+	    (client->clientAsMask == CLIENT_BITS(grab->resource)))
+	    FreeResource(grab->resource, RT_NONE);
     }
-
-    CloseInputDevice(d, client);
-    return Success;
 }
 
 /***********************************************************************
@@ -134,7 +121,7 @@ ProcXCloseDevice(register ClientPtr clie
  *
  */
 
-void
+static void
 DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client)
 {
     WindowPtr p2;
@@ -149,27 +136,40 @@ DeleteEventsFromChildren(DeviceIntPtr de
 
 /***********************************************************************
  *
- * Clear out event selections and passive grabs from a window for the
- * specified device.
+ * This procedure closes an input device.
  *
  */
 
-void
-DeleteDeviceEvents(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client)
+int
+ProcXCloseDevice(register ClientPtr client)
 {
-    InputClientsPtr others;
-    OtherInputMasks *pOthers;
-    GrabPtr grab, next;
+    int i;
+    WindowPtr pWin, p1;
+    DeviceIntPtr d;
 
-    if ((pOthers = wOtherInputMasks(pWin)) != 0)
-	for (others = pOthers->inputClients; others; others = others->next)
-	    if (SameClient(others, client))
-		others->mask[dev->id] = NoEventMask;
+    REQUEST(xCloseDeviceReq);
+    REQUEST_SIZE_MATCH(xCloseDeviceReq);
 
-    for (grab = wPassiveGrabs(pWin); grab; grab = next) {
-	next = grab->next;
-	if ((grab->device == dev) &&
-	    (client->clientAsMask == CLIENT_BITS(grab->resource)))
-	    FreeResource(grab->resource, RT_NONE);
+    d = LookupDeviceIntRec(stuff->deviceid);
+    if (d == NULL) {
+	SendErrorToClient(client, IReqCode, X_CloseDevice, 0, BadDevice);
+	return Success;
+    }
+
+    if (d->grab && SameClient(d->grab, client))
+	(*d->DeactivateGrab) (d);	/* release active grab */
+
+    /* Remove event selections from all windows for events from this device 
+     * and selected by this client.
+     * Delete passive grabs from all windows for this device.      */
+
+    for (i = 0; i < screenInfo.numScreens; i++) {
+	pWin = WindowTable[i];
+	DeleteDeviceEvents(d, pWin, client);
+	p1 = pWin->firstChild;
+	DeleteEventsFromChildren(d, p1, client);
     }
+
+    CloseInputDevice(d, client);
+    return Success;
 }
diff --git a/Xi/closedev.h b/Xi/closedev.h
index 6853d50..400aaa6 100644
--- a/Xi/closedev.h
+++ b/Xi/closedev.h
@@ -36,14 +36,4 @@ int SProcXCloseDevice(ClientPtr	/* clien
 int ProcXCloseDevice(ClientPtr	/* client */
     );
 
-void DeleteEventsFromChildren(DeviceIntPtr /* dev */ ,
-			      WindowPtr /* p1 */ ,
-			      ClientPtr	/* client */
-    );
-
-void DeleteDeviceEvents(DeviceIntPtr /* dev */ ,
-			WindowPtr /* pWin */ ,
-			ClientPtr	/* client */
-    );
-
 #endif /* CLOSEDEV_H */
diff --git a/Xi/exevents.c b/Xi/exevents.c
index b7645f4..164fce3 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -994,33 +994,7 @@ ChangeKeyMapping(ClientPtr client,
     return client->noClientException;
 }
 
-void
-DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources)
-{
-    int i;
-    DeviceIntPtr dev;
-    InputClientsPtr ic;
-    struct _OtherInputMasks *inputMasks;
-
-    for (dev = inputInfo.devices; dev; dev = dev->next) {
-	if (dev == inputInfo.pointer || dev == inputInfo.keyboard)
-	    continue;
-	DeleteDeviceFromAnyExtEvents(pWin, dev);
-    }
-
-    for (dev = inputInfo.off_devices; dev; dev = dev->next)
-	DeleteDeviceFromAnyExtEvents(pWin, dev);
-
-    if (freeResources)
-	while ((inputMasks = wOtherInputMasks(pWin)) != 0) {
-	    ic = inputMasks->inputClients;
-	    for (i = 0; i < EMASKSIZE; i++)
-		inputMasks->dontPropagateMask[i] = 0;
-	    FreeResource(ic->resource, RT_NONE);
-	}
-}
-
-void
+static void
 DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev)
 {
     WindowPtr parent;
@@ -1085,6 +1059,32 @@ DeleteDeviceFromAnyExtEvents(WindowPtr p
 	    dev->valuator->motionHintWindow = NullWindow;
 }
 
+void
+DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources)
+{
+    int i;
+    DeviceIntPtr dev;
+    InputClientsPtr ic;
+    struct _OtherInputMasks *inputMasks;
+
+    for (dev = inputInfo.devices; dev; dev = dev->next) {
+	if (dev == inputInfo.pointer || dev == inputInfo.keyboard)
+	    continue;
+	DeleteDeviceFromAnyExtEvents(pWin, dev);
+    }
+
+    for (dev = inputInfo.off_devices; dev; dev = dev->next)
+	DeleteDeviceFromAnyExtEvents(pWin, dev);
+
+    if (freeResources)
+	while ((inputMasks = wOtherInputMasks(pWin)) != 0) {
+	    ic = inputMasks->inputClients;
+	    for (i = 0; i < EMASKSIZE; i++)
+		inputMasks->dontPropagateMask[i] = 0;
+	    FreeResource(ic->resource, RT_NONE);
+	}
+}
+
 int
 MaybeSendDeviceMotionNotifyHint(deviceKeyButtonPointer * pEvents, Mask mask)
 {
@@ -1138,7 +1138,7 @@ CheckDeviceGrabAndHintWindow(WindowPtr p
     }
 }
 
-Mask
+static Mask
 DeviceEventMaskForClient(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client)
 {
     register InputClientsPtr other;
@@ -1223,7 +1223,7 @@ ShouldFreeInputMasks(WindowPtr pWin, Boo
  *
  */
 
-void
+static void
 FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask,
                        xEvent * ev, int count)
 {
diff --git a/Xi/exglobals.h b/Xi/exglobals.h
index 61ebca8..50bb33f 100644
--- a/Xi/exglobals.h
+++ b/Xi/exglobals.h
@@ -45,7 +45,6 @@ extern Mask DevicePointerMotionMask;
 extern Mask DevicePointerMotionHintMask;
 extern Mask DeviceFocusChangeMask;
 extern Mask DeviceStateNotifyMask;
-extern Mask ChangeDeviceNotifyMask;
 extern Mask DeviceMappingNotifyMask;
 extern Mask DeviceOwnerGrabButtonMask;
 extern Mask DeviceButtonGrabMask;
diff --git a/Xi/extinit.c b/Xi/extinit.c
index d14e133..fed54ab 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -161,7 +161,7 @@ Mask DevicePointerMotionMask;
 Mask DevicePointerMotionHintMask;
 Mask DeviceFocusChangeMask;
 Mask DeviceStateNotifyMask;
-Mask ChangeDeviceNotifyMask;
+static Mask ChangeDeviceNotifyMask;
 Mask DeviceMappingNotifyMask;
 Mask DeviceOwnerGrabButtonMask;
 Mask DeviceButtonGrabMask;
@@ -208,51 +208,6 @@ static XExtensionVersion thisversion = {
     XI_Add_DevicePresenceNotify_Minor
 };
 
-/**********************************************************************
- *
- * IExtensionInit - initialize the input extension.
- *
- * Called from InitExtensions in main() or from QueryExtension() if the
- * extension is dynamically loaded.
- *
- * This extension has several events and errors.
- *
- */
-
-void
-XInputExtensionInit(void)
-{
-    ExtensionEntry *extEntry;
-
-    extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch,
-			    SProcIDispatch, IResetProc, StandardMinorOpcode);
-    if (extEntry) {
-	IReqCode = extEntry->base;
-	AllExtensionVersions[IReqCode - 128] = thisversion;
-	MakeDeviceTypeAtoms();
-	RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone);
-	FixExtensionEvents(extEntry);
-	ReplySwapVector[IReqCode] = (ReplySwapPtr) SReplyIDispatch;
-	EventSwapVector[DeviceValuator] = SEventIDispatch;
-	EventSwapVector[DeviceKeyPress] = SEventIDispatch;
-	EventSwapVector[DeviceKeyRelease] = SEventIDispatch;
-	EventSwapVector[DeviceButtonPress] = SEventIDispatch;
-	EventSwapVector[DeviceButtonRelease] = SEventIDispatch;
-	EventSwapVector[DeviceMotionNotify] = SEventIDispatch;
-	EventSwapVector[DeviceFocusIn] = SEventIDispatch;
-	EventSwapVector[DeviceFocusOut] = SEventIDispatch;
-	EventSwapVector[ProximityIn] = SEventIDispatch;
-	EventSwapVector[ProximityOut] = SEventIDispatch;
-	EventSwapVector[DeviceStateNotify] = SEventIDispatch;
-	EventSwapVector[DeviceKeyStateNotify] = SEventIDispatch;
-	EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch;
-	EventSwapVector[DeviceMappingNotify] = SEventIDispatch;
-	EventSwapVector[ChangeDeviceNotify] = SEventIDispatch;
-    } else {
-	FatalError("IExtensionInit: AddExtensions failed\n");
-    }
-}
-
 /*************************************************************************
  *
  * ProcIDispatch - main dispatch routine for requests to this extension.
@@ -260,7 +215,7 @@ XInputExtensionInit(void)
  *
  */
 
-int
+static int
 ProcIDispatch(register ClientPtr client)
 {
     REQUEST(xReq);
@@ -349,7 +304,7 @@ ProcIDispatch(register ClientPtr client)
  *
  */
 
-int
+static int
 SProcIDispatch(register ClientPtr client)
 {
     REQUEST(xReq);
@@ -441,7 +396,7 @@ SProcIDispatch(register ClientPtr client
     if (rep->RepType == X_##code) \
 	SRepX##code (client, len, (x##code##Reply *) rep)
 
-void
+static void
 SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
 					/* All we look at is the type field */
 {	/* This is common to all replies    */
@@ -500,68 +455,13 @@ SReplyIDispatch(ClientPtr client, int le
     }
 }
 
-/*****************************************************************************
- *
- *	SEventIDispatch
- *
- *	Swap any events defined in this extension.
- */
-#define DO_SWAP(func,type) func ((type *)from, (type *)to)
-
-void
-SEventIDispatch(xEvent * from, xEvent * to)
-{
-    int type = from->u.u.type & 0177;
-
-    if (type == DeviceValuator)
-	DO_SWAP(SEventDeviceValuator, deviceValuator);
-    else if (type == DeviceKeyPress) {
-	SKeyButtonPtrEvent(from, to);
-	to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
-    } else if (type == DeviceKeyRelease) {
-	SKeyButtonPtrEvent(from, to);
-	to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
-    } else if (type == DeviceButtonPress) {
-	SKeyButtonPtrEvent(from, to);
-	to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
-    } else if (type == DeviceButtonRelease) {
-	SKeyButtonPtrEvent(from, to);
-	to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
-    } else if (type == DeviceMotionNotify) {
-	SKeyButtonPtrEvent(from, to);
-	to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
-    } else if (type == DeviceFocusIn)
-	DO_SWAP(SEventFocus, deviceFocus);
-    else if (type == DeviceFocusOut)
-	DO_SWAP(SEventFocus, deviceFocus);
-    else if (type == ProximityIn) {
-	SKeyButtonPtrEvent(from, to);
-	to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
-    } else if (type == ProximityOut) {
-	SKeyButtonPtrEvent(from, to);
-	to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
-    } else if (type == DeviceStateNotify)
-	DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify);
-    else if (type == DeviceKeyStateNotify)
-	DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify);
-    else if (type == DeviceButtonStateNotify)
-	DO_SWAP(SDeviceButtonStateNotifyEvent, deviceButtonStateNotify);
-    else if (type == DeviceMappingNotify)
-	DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify);
-    else if (type == ChangeDeviceNotify)
-	DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify);
-    else {
-	FatalError("XInputExtension: Impossible event!\n");
-    }
-}
-
 /************************************************************************
  *
  * This function swaps the DeviceValuator event.
  *
  */
 
-void
+static void
 SEventDeviceValuator(deviceValuator * from, deviceValuator * to)
 {
     register char n;
@@ -577,7 +477,7 @@ SEventDeviceValuator(deviceValuator * fr
     }
 }
 
-void
+static void
 SEventFocus(deviceFocus * from, deviceFocus * to)
 {
     register char n;
@@ -588,7 +488,7 @@ SEventFocus(deviceFocus * from, deviceFo
     swapl(&to->window, n);
 }
 
-void
+static void
 SDeviceStateNotifyEvent(deviceStateNotify * from, deviceStateNotify * to)
 {
     register int i;
@@ -604,7 +504,7 @@ SDeviceStateNotifyEvent(deviceStateNotif
     }
 }
 
-void
+static void
 SDeviceKeyStateNotifyEvent(deviceKeyStateNotify * from,
 			   deviceKeyStateNotify * to)
 {
@@ -614,7 +514,7 @@ SDeviceKeyStateNotifyEvent(deviceKeyStat
     swaps(&to->sequenceNumber, n);
 }
 
-void
+static void
 SDeviceButtonStateNotifyEvent(deviceButtonStateNotify * from,
 			      deviceButtonStateNotify * to)
 {
@@ -624,7 +524,7 @@ SDeviceButtonStateNotifyEvent(deviceButt
     swaps(&to->sequenceNumber, n);
 }
 
-void
+static void
 SChangeDeviceNotifyEvent(changeDeviceNotify * from, changeDeviceNotify * to)
 {
     register char n;
@@ -634,7 +534,7 @@ SChangeDeviceNotifyEvent(changeDeviceNot
     swapl(&to->time, n);
 }
 
-void
+static void
 SDeviceMappingNotifyEvent(deviceMappingNotify * from, deviceMappingNotify * to)
 {
     register char n;
@@ -644,7 +544,7 @@ SDeviceMappingNotifyEvent(deviceMappingN
     swapl(&to->time, n);
 }
 
-void
+static void
 SDevicePresenceNotifyEvent (devicePresenceNotify *from, devicePresenceNotify *to)
 {
     register char n;
@@ -655,13 +555,106 @@ SDevicePresenceNotifyEvent (devicePresen
     swaps(&to->control, n);
 }
 
+/**************************************************************************
+ *
+ * Allow the specified event to have its propagation suppressed.
+ * The default is to not allow suppression of propagation.
+ *
+ */
+
+static void
+AllowPropagateSuppress(Mask mask)
+{
+    int i;
+
+    for (i = 0; i < MAX_DEVICES; i++)
+	PropagateMask[i] |= mask;
+}
+
+/**************************************************************************
+ *
+ * Return the next available extension event mask.
+ *
+ */
+
+static Mask
+GetNextExtEventMask(void)
+{
+    int i;
+    Mask mask = lastExtEventMask;
+
+    if (lastExtEventMask == 0) {
+	FatalError("GetNextExtEventMask: no more events are available.");
+    }
+    lastExtEventMask <<= 1;
+
+    for (i = 0; i < MAX_DEVICES; i++)
+	ExtValidMasks[i] |= mask;
+    return mask;
+}
+
+/**************************************************************************
+ *
+ * Record an event mask where there is no unique corresponding event type.
+ * We can't call SetMaskForEvent, since that would clobber the existing
+ * mask for that event.  MotionHint and ButtonMotion are examples.
+ *
+ * Since extension event types will never be less than 64, we can use
+ * 0-63 in the EventInfo array as the "type" to be used to look up this
+ * mask.  This means that the corresponding macros such as 
+ * DevicePointerMotionHint must have access to the same constants.
+ *
+ */
+
+static void
+SetEventInfo(Mask mask, int constant)
+{
+    EventInfo[ExtEventIndex].mask = mask;
+    EventInfo[ExtEventIndex++].type = constant;
+}
+
+/**************************************************************************
+ *
+ * Allow the specified event to be restricted to being selected by one
+ * client at a time.
+ * The default is to allow more than one client to select the event.
+ *
+ */
+
+static void
+SetExclusiveAccess(Mask mask)
+{
+    int i;
+
+    for (i = 0; i < MAX_DEVICES; i++)
+	ExtExclusiveMasks[i] |= mask;
+}
+
+/**************************************************************************
+ *
+ * Assign the specified mask to the specified event.
+ *
+ */
+
+static void
+SetMaskForExtEvent(Mask mask, int event)
+{
+
+    EventInfo[ExtEventIndex].mask = mask;
+    EventInfo[ExtEventIndex++].type = event;
+
+    if ((event < LASTEvent) || (event >= 128))
+	FatalError("MaskForExtensionEvent: bogus event number");
+    SetMaskForEvent(mask, event);
+}
+
 /************************************************************************
  *
  * This function sets up extension event types and masks.
  *
  */
 
-void
+static void
 FixExtensionEvents(ExtensionEntry * extEntry)
 {
     Mask mask;
@@ -767,7 +760,7 @@ FixExtensionEvents(ExtensionEntry * extE
  *
  */
 
-void
+static void
 RestoreExtensionEvents(void)
 {
     int i;
@@ -815,7 +808,7 @@ RestoreExtensionEvents(void)
  *
  */
 
-void
+static void
 IResetProc(ExtensionEntry * unused)
 {
 
@@ -859,7 +852,7 @@ AssignTypeAndName(DeviceIntPtr dev, Atom
  *
  */
 
-void
+static void
 MakeDeviceTypeAtoms(void)
 {
     int i;
@@ -892,95 +885,102 @@ LookupDeviceIntRec(CARD8 id)
     return NULL;
 }
 
-/**************************************************************************
- *
- * Allow the specified event to be restricted to being selected by one
- * client at a time.
- * The default is to allow more than one client to select the event.
- *
- */
-
-void
-SetExclusiveAccess(Mask mask)
-{
-    int i;
-
-    for (i = 0; i < MAX_DEVICES; i++)
-	ExtExclusiveMasks[i] |= mask;
-}
-
-/**************************************************************************
- *
- * Allow the specified event to have its propagation suppressed.
- * The default is to not allow suppression of propagation.
- *
- */
-
-void
-AllowPropagateSuppress(Mask mask)
-{
-    int i;
-
-    for (i = 0; i < MAX_DEVICES; i++)
-	PropagateMask[i] |= mask;
-}
-
-/**************************************************************************
+/*****************************************************************************
  *
- * Return the next available extension event mask.
+ *	SEventIDispatch
  *
+ *	Swap any events defined in this extension.
  */
+#define DO_SWAP(func,type) func ((type *)from, (type *)to)
 
-Mask
-GetNextExtEventMask(void)
+static void
+SEventIDispatch(xEvent * from, xEvent * to)
 {
-    int i;
-    Mask mask = lastExtEventMask;
+    int type = from->u.u.type & 0177;
 
-    if (lastExtEventMask == 0) {
-	FatalError("GetNextExtEventMask: no more events are available.");
+    if (type == DeviceValuator)
+	DO_SWAP(SEventDeviceValuator, deviceValuator);
+    else if (type == DeviceKeyPress) {
+	SKeyButtonPtrEvent(from, to);
+	to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
+    } else if (type == DeviceKeyRelease) {
+	SKeyButtonPtrEvent(from, to);
+	to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
+    } else if (type == DeviceButtonPress) {
+	SKeyButtonPtrEvent(from, to);
+	to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
+    } else if (type == DeviceButtonRelease) {
+	SKeyButtonPtrEvent(from, to);
+	to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
+    } else if (type == DeviceMotionNotify) {
+	SKeyButtonPtrEvent(from, to);
+	to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
+    } else if (type == DeviceFocusIn)
+	DO_SWAP(SEventFocus, deviceFocus);
+    else if (type == DeviceFocusOut)
+	DO_SWAP(SEventFocus, deviceFocus);
+    else if (type == ProximityIn) {
+	SKeyButtonPtrEvent(from, to);
+	to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
+    } else if (type == ProximityOut) {
+	SKeyButtonPtrEvent(from, to);
+	to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
+    } else if (type == DeviceStateNotify)
+	DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify);
+    else if (type == DeviceKeyStateNotify)
+	DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify);
+    else if (type == DeviceButtonStateNotify)
+	DO_SWAP(SDeviceButtonStateNotifyEvent, deviceButtonStateNotify);
+    else if (type == DeviceMappingNotify)
+	DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify);
+    else if (type == ChangeDeviceNotify)
+	DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify);
+    else {
+	FatalError("XInputExtension: Impossible event!\n");
     }
-    lastExtEventMask <<= 1;
-
-    for (i = 0; i < MAX_DEVICES; i++)
-	ExtValidMasks[i] |= mask;
-    return mask;
 }
 
-/**************************************************************************
- *
- * Assign the specified mask to the specified event.
+/**********************************************************************
  *
- */
-
-void
-SetMaskForExtEvent(Mask mask, int event)
-{
-
-    EventInfo[ExtEventIndex].mask = mask;
-    EventInfo[ExtEventIndex++].type = event;
-
-    if ((event < LASTEvent) || (event >= 128))
-	FatalError("MaskForExtensionEvent: bogus event number");
-    SetMaskForEvent(mask, event);
-}
-
-/**************************************************************************
+ * IExtensionInit - initialize the input extension.
  *
- * Record an event mask where there is no unique corresponding event type.
- * We can't call SetMaskForEvent, since that would clobber the existing
- * mask for that event.  MotionHint and ButtonMotion are examples.
+ * Called from InitExtensions in main() or from QueryExtension() if the
+ * extension is dynamically loaded.
  *
- * Since extension event types will never be less than 64, we can use
- * 0-63 in the EventInfo array as the "type" to be used to look up this
- * mask.  This means that the corresponding macros such as 
- * DevicePointerMotionHint must have access to the same constants.
+ * This extension has several events and errors.
  *
  */
 
 void
-SetEventInfo(Mask mask, int constant)
+XInputExtensionInit(void)
 {
-    EventInfo[ExtEventIndex].mask = mask;
-    EventInfo[ExtEventIndex++].type = constant;
+    ExtensionEntry *extEntry;
+
+    extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch,
+			    SProcIDispatch, IResetProc, StandardMinorOpcode);
+    if (extEntry) {
+	IReqCode = extEntry->base;
+	AllExtensionVersions[IReqCode - 128] = thisversion;
+	MakeDeviceTypeAtoms();
+	RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone);
+	FixExtensionEvents(extEntry);
+	ReplySwapVector[IReqCode] = (ReplySwapPtr) SReplyIDispatch;
+	EventSwapVector[DeviceValuator] = SEventIDispatch;
+	EventSwapVector[DeviceKeyPress] = SEventIDispatch;
+	EventSwapVector[DeviceKeyRelease] = SEventIDispatch;
+	EventSwapVector[DeviceButtonPress] = SEventIDispatch;
+	EventSwapVector[DeviceButtonRelease] = SEventIDispatch;
+	EventSwapVector[DeviceMotionNotify] = SEventIDispatch;
+	EventSwapVector[DeviceFocusIn] = SEventIDispatch;
+	EventSwapVector[DeviceFocusOut] = SEventIDispatch;
+	EventSwapVector[ProximityIn] = SEventIDispatch;
+	EventSwapVector[ProximityOut] = SEventIDispatch;
+	EventSwapVector[DeviceStateNotify] = SEventIDispatch;
+	EventSwapVector[DeviceKeyStateNotify] = SEventIDispatch;
+	EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch;
+	EventSwapVector[DeviceMappingNotify] = SEventIDispatch;
+	EventSwapVector[ChangeDeviceNotify] = SEventIDispatch;
+    } else {
+	FatalError("IExtensionInit: AddExtensions failed\n");
+    }
 }
diff --git a/Xi/getdctl.c b/Xi/getdctl.c
index d738ef8..c264d4f 100644
--- a/Xi/getdctl.c
+++ b/Xi/getdctl.c
@@ -88,112 +88,11 @@ SProcXGetDeviceControl(register ClientPt
 
 /***********************************************************************
  *
- * Get the state of the specified device control.
- *
- */
-
-int
-ProcXGetDeviceControl(ClientPtr client)
-{
-    int total_length = 0;
-    char *buf, *savbuf;
-    register DeviceIntPtr dev;
-    xGetDeviceControlReply rep;
-
-    REQUEST(xGetDeviceControlReq);
-    REQUEST_SIZE_MATCH(xGetDeviceControlReq);
-
-    dev = LookupDeviceIntRec(stuff->deviceid);
-    if (dev == NULL) {
-	SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadDevice);
-	return Success;
-    }
-
-    rep.repType = X_Reply;
-    rep.RepType = X_GetDeviceControl;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
-    switch (stuff->control) {
-    case DEVICE_RESOLUTION:
-	if (!dev->valuator) {
-	    SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
-			      BadMatch);
-	    return Success;
-	}
-	total_length = sizeof(xDeviceResolutionState) +
-	    (3 * sizeof(int) * dev->valuator->numAxes);
-	break;
-    case DEVICE_ABS_CALIB:
-        if (!dev->absolute) {
-            SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
-                              BadMatch);
-            return Success;
-        }
-
-        total_length = sizeof(xDeviceAbsCalibCtl);
-        break;
-    case DEVICE_ABS_AREA:
-        if (!dev->absolute) {
-            SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
-                              BadMatch);
-            return Success;
-        }
-
-        total_length = sizeof(xDeviceAbsAreaCtl);
-        break;
-    case DEVICE_CORE:
-        total_length = sizeof(xDeviceCoreCtl);
-        break;
-    case DEVICE_ENABLE:
-        total_length = sizeof(xDeviceEnableCtl);
-        break;
-    default:
-	SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadValue);
-	return Success;
-    }
-
-    buf = (char *)xalloc(total_length);
-    if (!buf) {
-	SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadAlloc);
-	return Success;
-    }
-    savbuf = buf;
-
-    switch (stuff->control) {
-    case DEVICE_RESOLUTION:
-	CopySwapDeviceResolution(client, dev->valuator, buf, total_length);
-	break;
-    case DEVICE_ABS_CALIB:
-        CopySwapDeviceAbsCalib(client, dev->absolute, buf);
-        break;
-    case DEVICE_ABS_AREA:
-        CopySwapDeviceAbsArea(client, dev->absolute, buf);
-        break;
-    case DEVICE_CORE:
-        CopySwapDeviceCore(client, dev, buf);
-        break;
-    case DEVICE_ENABLE:
-        CopySwapDeviceEnable(client, dev, buf);
-        break;
-    default:
-	break;
-    }
-
-    rep.length = (total_length + 3) >> 2;
-    WriteReplyToClient(client, sizeof(xGetDeviceControlReply), &rep);
-    WriteToClient(client, total_length, savbuf);
-    xfree(savbuf);
-    return Success;
-}
-
-/***********************************************************************
- *
  * This procedure copies DeviceResolution data, swapping if necessary.
  *
  */
 
-void
+static void
 CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf,
 			 int length)
 {
@@ -225,7 +124,7 @@ CopySwapDeviceResolution(ClientPtr clien
     }
 }
 
-void CopySwapDeviceAbsCalib (ClientPtr client, AbsoluteClassPtr dts,
+static void CopySwapDeviceAbsCalib (ClientPtr client, AbsoluteClassPtr dts,
                                 char *buf)
 {
     register char n;
@@ -256,7 +155,7 @@ void CopySwapDeviceAbsCalib (ClientPtr c
     }
 }
 
-void CopySwapDeviceAbsArea (ClientPtr client, AbsoluteClassPtr dts,
+static void CopySwapDeviceAbsArea (ClientPtr client, AbsoluteClassPtr dts,
                                 char *buf)
 {
     register char n;
@@ -283,7 +182,7 @@ void CopySwapDeviceAbsArea (ClientPtr cl
     }
 }
 
-void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf)
+static void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf)
 {
     register char n;
     xDeviceCoreState *c = (xDeviceCoreState *) buf;
@@ -300,7 +199,7 @@ void CopySwapDeviceCore (ClientPtr clien
     }
 }
 
-void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf)
+static void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf)
 {
     register char n;
     xDeviceEnableState *e = (xDeviceEnableState *) buf;
@@ -316,7 +215,6 @@ void CopySwapDeviceEnable (ClientPtr cli
     }
 }
 
-
 /***********************************************************************
  *
  * This procedure writes the reply for the xGetDeviceControl function,
@@ -333,3 +231,104 @@ SRepXGetDeviceControl(ClientPtr client, 
     swapl(&rep->length, n);
     WriteToClient(client, size, (char *)rep);
 }
+
+/***********************************************************************
+ *
+ * Get the state of the specified device control.
+ *
+ */
+
+int
+ProcXGetDeviceControl(ClientPtr client)
+{
+    int total_length = 0;
+    char *buf, *savbuf;
+    register DeviceIntPtr dev;
+    xGetDeviceControlReply rep;
+
+    REQUEST(xGetDeviceControlReq);
+    REQUEST_SIZE_MATCH(xGetDeviceControlReq);
+
+    dev = LookupDeviceIntRec(stuff->deviceid);
+    if (dev == NULL) {
+	SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadDevice);
+	return Success;
+    }
+
+    rep.repType = X_Reply;
+    rep.RepType = X_GetDeviceControl;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+
+    switch (stuff->control) {
+    case DEVICE_RESOLUTION:
+	if (!dev->valuator) {
+	    SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
+			      BadMatch);
+	    return Success;
+	}
+	total_length = sizeof(xDeviceResolutionState) +
+	    (3 * sizeof(int) * dev->valuator->numAxes);
+	break;
+    case DEVICE_ABS_CALIB:
+        if (!dev->absolute) {
+            SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
+                              BadMatch);
+            return Success;
+        }
+
+        total_length = sizeof(xDeviceAbsCalibCtl);
+        break;
+    case DEVICE_ABS_AREA:
+        if (!dev->absolute) {
+            SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
+                              BadMatch);
+            return Success;
+        }
+
+        total_length = sizeof(xDeviceAbsAreaCtl);
+        break;
+    case DEVICE_CORE:
+        total_length = sizeof(xDeviceCoreCtl);
+        break;
+    case DEVICE_ENABLE:
+        total_length = sizeof(xDeviceEnableCtl);
+        break;
+    default:
+	SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadValue);
+	return Success;
+    }
+
+    buf = (char *)xalloc(total_length);
+    if (!buf) {
+	SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadAlloc);
+	return Success;
+    }
+    savbuf = buf;
+
+    switch (stuff->control) {
+    case DEVICE_RESOLUTION:
+	CopySwapDeviceResolution(client, dev->valuator, buf, total_length);
+	break;
+    case DEVICE_ABS_CALIB:
+        CopySwapDeviceAbsCalib(client, dev->absolute, buf);
+        break;
+    case DEVICE_ABS_AREA:
+        CopySwapDeviceAbsArea(client, dev->absolute, buf);
+        break;
+    case DEVICE_CORE:
+        CopySwapDeviceCore(client, dev, buf);
+        break;
+    case DEVICE_ENABLE:
+        CopySwapDeviceEnable(client, dev, buf);
+        break;
+    default:
+	break;
+    }
+
+    rep.length = (total_length + 3) >> 2;
+    WriteReplyToClient(client, sizeof(xGetDeviceControlReply), &rep);
+    WriteToClient(client, total_length, savbuf);
+    xfree(savbuf);
+    return Success;
+}
diff --git a/Xi/getdctl.h b/Xi/getdctl.h
index 36868d8..19c189f 100644
--- a/Xi/getdctl.h
+++ b/Xi/getdctl.h
@@ -36,30 +36,6 @@ int SProcXGetDeviceControl(ClientPtr	/* 
 int ProcXGetDeviceControl(ClientPtr	/* client */
     );
 
-void CopySwapDeviceResolution(ClientPtr /* client */ ,
-			      ValuatorClassPtr /* v */ ,
-			      char * /* buf */ ,
-			      int	/* length */
-    );
-
-void CopySwapDeviceAbsCalib (ClientPtr client,
-                             AbsoluteClassPtr dts,
-                             char *buf);
-
-void CopySwapDeviceAbsArea (ClientPtr client,
-                            AbsoluteClassPtr dts,
-                            char *buf);
-
-void CopySwapDeviceCore(ClientPtr /* client */ ,
-                        DeviceIntPtr /* dev */ ,
-                        char * /* buf */
-    );
-
-void CopySwapDeviceEnable(ClientPtr /* client */ ,
-                          DeviceIntPtr /* dev */ ,
-                          char * /* buf */
-    );
-
 void SRepXGetDeviceControl(ClientPtr /* client */ ,
 			   int /* size */ ,
 			   xGetDeviceControlReply *	/* rep */
diff --git a/Xi/getfctl.c b/Xi/getfctl.c
index 870348f..28360ee 100644
--- a/Xi/getfctl.c
+++ b/Xi/getfctl.c
@@ -86,104 +86,11 @@ SProcXGetFeedbackControl(register Client
 
 /***********************************************************************
  *
- * Get the feedback control state.
- *
- */
-
-int
-ProcXGetFeedbackControl(ClientPtr client)
-{
-    int total_length = 0;
-    char *buf, *savbuf;
-    register DeviceIntPtr dev;
-    KbdFeedbackPtr k;
-    PtrFeedbackPtr p;
-    IntegerFeedbackPtr i;
-    StringFeedbackPtr s;
-    BellFeedbackPtr b;
-    LedFeedbackPtr l;
-    xGetFeedbackControlReply rep;
-
-    REQUEST(xGetFeedbackControlReq);
-    REQUEST_SIZE_MATCH(xGetFeedbackControlReq);
-
-    dev = LookupDeviceIntRec(stuff->deviceid);
-    if (dev == NULL) {
-	SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadDevice);
-	return Success;
-    }
-
-    rep.repType = X_Reply;
-    rep.RepType = X_GetFeedbackControl;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.num_feedbacks = 0;
-
-    for (k = dev->kbdfeed; k; k = k->next) {
-	rep.num_feedbacks++;
-	total_length += sizeof(xKbdFeedbackState);
-    }
-    for (p = dev->ptrfeed; p; p = p->next) {
-	rep.num_feedbacks++;
-	total_length += sizeof(xPtrFeedbackState);
-    }
-    for (s = dev->stringfeed; s; s = s->next) {
-	rep.num_feedbacks++;
-	total_length += sizeof(xStringFeedbackState) +
-	    (s->ctrl.num_symbols_supported * sizeof(KeySym));
-    }
-    for (i = dev->intfeed; i; i = i->next) {
-	rep.num_feedbacks++;
-	total_length += sizeof(xIntegerFeedbackState);
-    }
-    for (l = dev->leds; l; l = l->next) {
-	rep.num_feedbacks++;
-	total_length += sizeof(xLedFeedbackState);
-    }
-    for (b = dev->bell; b; b = b->next) {
-	rep.num_feedbacks++;
-	total_length += sizeof(xBellFeedbackState);
-    }
-
-    if (total_length == 0) {
-	SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadMatch);
-	return Success;
-    }
-
-    buf = (char *)xalloc(total_length);
-    if (!buf) {
-	SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadAlloc);
-	return Success;
-    }
-    savbuf = buf;
-
-    for (k = dev->kbdfeed; k; k = k->next)
-	CopySwapKbdFeedback(client, k, &buf);
-    for (p = dev->ptrfeed; p; p = p->next)
-	CopySwapPtrFeedback(client, p, &buf);
-    for (s = dev->stringfeed; s; s = s->next)
-	CopySwapStringFeedback(client, s, &buf);
-    for (i = dev->intfeed; i; i = i->next)
-	CopySwapIntegerFeedback(client, i, &buf);
-    for (l = dev->leds; l; l = l->next)
-	CopySwapLedFeedback(client, l, &buf);
-    for (b = dev->bell; b; b = b->next)
-	CopySwapBellFeedback(client, b, &buf);
-
-    rep.length = (total_length + 3) >> 2;
-    WriteReplyToClient(client, sizeof(xGetFeedbackControlReply), &rep);
-    WriteToClient(client, total_length, savbuf);
-    xfree(savbuf);
-    return Success;
-}
-
-/***********************************************************************
- *
  * This procedure copies KbdFeedbackClass data, swapping if necessary.
  *
  */
 
-void
+static void
 CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf)
 {
     int i;
@@ -218,7 +125,7 @@ CopySwapKbdFeedback(ClientPtr client, Kb
  *
  */
 
-void
+static void
 CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf)
 {
     register char n;
@@ -246,7 +153,7 @@ CopySwapPtrFeedback(ClientPtr client, Pt
  *
  */
 
-void
+static void
 CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf)
 {
     register char n;
@@ -274,7 +181,7 @@ CopySwapIntegerFeedback(ClientPtr client
  *
  */
 
-void
+static void
 CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf)
 {
     int i;
@@ -311,7 +218,7 @@ CopySwapStringFeedback(ClientPtr client,
  *
  */
 
-void
+static void
 CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf)
 {
     register char n;
@@ -337,7 +244,7 @@ CopySwapLedFeedback(ClientPtr client, Le
  *
  */
 
-void
+static void
 CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf)
 {
     register char n;
@@ -376,3 +283,96 @@ SRepXGetFeedbackControl(ClientPtr client
     swaps(&rep->num_feedbacks, n);
     WriteToClient(client, size, (char *)rep);
 }
+
+/***********************************************************************
+ *
+ * Get the feedback control state.
+ *
+ */
+
+int
+ProcXGetFeedbackControl(ClientPtr client)
+{
+    int total_length = 0;
+    char *buf, *savbuf;
+    register DeviceIntPtr dev;
+    KbdFeedbackPtr k;
+    PtrFeedbackPtr p;
+    IntegerFeedbackPtr i;
+    StringFeedbackPtr s;
+    BellFeedbackPtr b;
+    LedFeedbackPtr l;
+    xGetFeedbackControlReply rep;
+
+    REQUEST(xGetFeedbackControlReq);
+    REQUEST_SIZE_MATCH(xGetFeedbackControlReq);
+
+    dev = LookupDeviceIntRec(stuff->deviceid);
+    if (dev == NULL) {
+	SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadDevice);
+	return Success;
+    }
+
+    rep.repType = X_Reply;
+    rep.RepType = X_GetFeedbackControl;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    rep.num_feedbacks = 0;
+
+    for (k = dev->kbdfeed; k; k = k->next) {
+	rep.num_feedbacks++;
+	total_length += sizeof(xKbdFeedbackState);
+    }
+    for (p = dev->ptrfeed; p; p = p->next) {
+	rep.num_feedbacks++;
+	total_length += sizeof(xPtrFeedbackState);
+    }
+    for (s = dev->stringfeed; s; s = s->next) {
+	rep.num_feedbacks++;
+	total_length += sizeof(xStringFeedbackState) +
+	    (s->ctrl.num_symbols_supported * sizeof(KeySym));
+    }
+    for (i = dev->intfeed; i; i = i->next) {
+	rep.num_feedbacks++;
+	total_length += sizeof(xIntegerFeedbackState);
+    }
+    for (l = dev->leds; l; l = l->next) {
+	rep.num_feedbacks++;
+	total_length += sizeof(xLedFeedbackState);
+    }
+    for (b = dev->bell; b; b = b->next) {
+	rep.num_feedbacks++;
+	total_length += sizeof(xBellFeedbackState);
+    }
+
+    if (total_length == 0) {
+	SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadMatch);
+	return Success;
+    }
+
+    buf = (char *)xalloc(total_length);
+    if (!buf) {
+	SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadAlloc);
+	return Success;
+    }
+    savbuf = buf;
+
+    for (k = dev->kbdfeed; k; k = k->next)
+	CopySwapKbdFeedback(client, k, &buf);
+    for (p = dev->ptrfeed; p; p = p->next)
+	CopySwapPtrFeedback(client, p, &buf);
+    for (s = dev->stringfeed; s; s = s->next)
+	CopySwapStringFeedback(client, s, &buf);
+    for (i = dev->intfeed; i; i = i->next)
+	CopySwapIntegerFeedback(client, i, &buf);
+    for (l = dev->leds; l; l = l->next)
+	CopySwapLedFeedback(client, l, &buf);
+    for (b = dev->bell; b; b = b->next)
+	CopySwapBellFeedback(client, b, &buf);
+
+    rep.length = (total_length + 3) >> 2;
+    WriteReplyToClient(client, sizeof(xGetFeedbackControlReply), &rep);
+    WriteToClient(client, total_length, savbuf);
+    xfree(savbuf);
+    return Success;
+}
diff --git a/Xi/getfctl.h b/Xi/getfctl.h
index 7d2d17a..0ad58aa 100644
--- a/Xi/getfctl.h
+++ b/Xi/getfctl.h
@@ -36,36 +36,6 @@ int SProcXGetFeedbackControl(ClientPtr	/
 int ProcXGetFeedbackControl(ClientPtr	/* client */
     );
 
-void CopySwapKbdFeedback(ClientPtr /* client */ ,
-			 KbdFeedbackPtr /* k */ ,
-			 char **	/* buf */
-    );
-
-void CopySwapPtrFeedback(ClientPtr /* client */ ,
-			 PtrFeedbackPtr /* p */ ,
-			 char **	/* buf */
-    );
-
-void CopySwapIntegerFeedback(ClientPtr /* client */ ,
-			     IntegerFeedbackPtr /* i */ ,
-			     char **	/* buf */
-    );
-
-void CopySwapStringFeedback(ClientPtr /* client */ ,
-			    StringFeedbackPtr /* s */ ,
-			    char **	/* buf */
-    );
-
-void CopySwapLedFeedback(ClientPtr /* client */ ,
-			 LedFeedbackPtr /* l */ ,
-			 char **	/* buf */
-    );
-
-void CopySwapBellFeedback(ClientPtr /* client */ ,
-			  BellFeedbackPtr /* b */ ,
-			  char **	/* buf */
-    );
-
 void SRepXGetFeedbackControl(ClientPtr /* client */ ,
 			     int /* size */ ,
 			     xGetFeedbackControlReply *	/* rep */
diff --git a/Xi/listdev.c b/Xi/listdev.c
index 02d55ad..257ee59 100644
--- a/Xi/listdev.c
+++ b/Xi/listdev.c
@@ -88,71 +88,12 @@ SProcXListInputDevices(register ClientPt
 
 /***********************************************************************
  *
- * This procedure lists the input devices available to the server.
- *
- */
-
-int
-ProcXListInputDevices(register ClientPtr client)
-{
-    xListInputDevicesReply rep;
-    int numdevs = 0;
-    int namesize = 1;	/* need 1 extra byte for strcpy */
-    int size = 0;
-    int total_length;
-    char *devbuf;
-    char *classbuf;
-    char *namebuf;
-    char *savbuf;
-    xDeviceInfo *dev;
-    DeviceIntPtr d;
-
-    REQUEST_SIZE_MATCH(xListInputDevicesReq);
-
-    rep.repType = X_Reply;
-    rep.RepType = X_ListInputDevices;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
-    AddOtherInputDevices();
-
-    for (d = inputInfo.devices; d; d = d->next) {
-	SizeDeviceInfo(d, &namesize, &size);
-        numdevs++;
-    }
-    for (d = inputInfo.off_devices; d; d = d->next) {
-	SizeDeviceInfo(d, &namesize, &size);
-        numdevs++;
-    }
-
-    total_length = numdevs * sizeof(xDeviceInfo) + size + namesize;
-    devbuf = (char *)xalloc(total_length);
-    classbuf = devbuf + (numdevs * sizeof(xDeviceInfo));
-    namebuf = classbuf + size;
-    savbuf = devbuf;
-
-    dev = (xDeviceInfoPtr) devbuf;
-    for (d = inputInfo.devices; d; d = d->next, dev++)
-	ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf);
-    for (d = inputInfo.off_devices; d; d = d->next, dev++)
-	ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf);
-
-    rep.ndevices = numdevs;
-    rep.length = (total_length + 3) >> 2;
-    WriteReplyToClient(client, sizeof(xListInputDevicesReply), &rep);
-    WriteToClient(client, total_length, savbuf);
-    xfree(savbuf);
-    return Success;
-}
-
-/***********************************************************************
- *
  * This procedure calculates the size of the information to be returned
  * for an input device.
  *
  */
 
-void
+static void
 SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size)
 {
     int chunks;
@@ -173,32 +114,6 @@ SizeDeviceInfo(DeviceIntPtr d, int *name
 
 /***********************************************************************
  *
- * This procedure lists information to be returned for an input device.
- *
- */
-
-void
-ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev,
-	       char **devbuf, char **classbuf, char **namebuf)
-{
-    CopyDeviceName(namebuf, d->name);
-    CopySwapDevice(client, d, 0, devbuf);
-    if (d->key != NULL) {
-	CopySwapKeyClass(client, d->key, classbuf);
-	dev->num_classes++;
-    }
-    if (d->button != NULL) {
-	CopySwapButtonClass(client, d->button, classbuf);
-	dev->num_classes++;
-    }
-    if (d->valuator != NULL) {
-	dev->num_classes +=
-	    CopySwapValuatorClass(client, d->valuator, classbuf);
-    }
-}
-
-/***********************************************************************
- *
  * This procedure copies data to the DeviceInfo struct, swapping if necessary.
  *
  * We need the extra byte in the allocated buffer, because the trailing null
@@ -207,7 +122,7 @@ ListDeviceInfo(ClientPtr client, DeviceI
  *
  */
 
-void
+static void
 CopyDeviceName(char **namebuf, char *name)
 {
     char *nameptr = (char *)*namebuf;
@@ -224,11 +139,33 @@ CopyDeviceName(char **namebuf, char *nam
 
 /***********************************************************************
  *
+ * This procedure copies ButtonClass information, swapping if necessary.
+ *
+ */
+
+static void
+CopySwapButtonClass(register ClientPtr client, ButtonClassPtr b, char **buf)
+{
+    register char n;
+    xButtonInfoPtr b2;
+
+    b2 = (xButtonInfoPtr) * buf;
+    b2->class = ButtonClass;
+    b2->length = sizeof(xButtonInfo);
+    b2->num_buttons = b->numButtons;
+    if (client->swapped) {
+	swaps(&b2->num_buttons, n);	/* macro - braces are required */
+    }
+    *buf += sizeof(xButtonInfo);
+}
+
+/***********************************************************************
+ *
  * This procedure copies data to the DeviceInfo struct, swapping if necessary.
  *
  */
 
-void
+static void
 CopySwapDevice(register ClientPtr client, DeviceIntPtr d, int num_classes,
 	       char **buf)
 {
@@ -262,7 +199,7 @@ CopySwapDevice(register ClientPtr client
  *
  */
 
-void
+static void
 CopySwapKeyClass(register ClientPtr client, KeyClassPtr k, char **buf)
 {
     register char n;
@@ -282,28 +219,6 @@ CopySwapKeyClass(register ClientPtr clie
 
 /***********************************************************************
  *
- * This procedure copies ButtonClass information, swapping if necessary.
- *
- */
-
-void
-CopySwapButtonClass(register ClientPtr client, ButtonClassPtr b, char **buf)
-{
-    register char n;
-    xButtonInfoPtr b2;
-
-    b2 = (xButtonInfoPtr) * buf;
-    b2->class = ButtonClass;
-    b2->length = sizeof(xButtonInfo);
-    b2->num_buttons = b->numButtons;
-    if (client->swapped) {
-	swaps(&b2->num_buttons, n);	/* macro - braces are required */
-    }
-    *buf += sizeof(xButtonInfo);
-}
-
-/***********************************************************************
- *
  * This procedure copies ValuatorClass information, swapping if necessary.
  *
  * Devices may have up to 255 valuators.  The length of a ValuatorClass is
@@ -314,7 +229,7 @@ CopySwapButtonClass(register ClientPtr c
  *
  */
 
-int
+static int
 CopySwapValuatorClass(register ClientPtr client, ValuatorClassPtr v, char **buf)
 {
     int i, j, axes, t_axes;
@@ -359,6 +274,91 @@ CopySwapValuatorClass(register ClientPtr
 
 /***********************************************************************
  *
+ * This procedure lists information to be returned for an input device.
+ *
+ */
+
+static void
+ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev,
+	       char **devbuf, char **classbuf, char **namebuf)
+{
+    CopyDeviceName(namebuf, d->name);
+    CopySwapDevice(client, d, 0, devbuf);
+    if (d->key != NULL) {
+	CopySwapKeyClass(client, d->key, classbuf);
+	dev->num_classes++;
+    }
+    if (d->button != NULL) {
+	CopySwapButtonClass(client, d->button, classbuf);
+	dev->num_classes++;
+    }
+    if (d->valuator != NULL) {
+	dev->num_classes +=
+	    CopySwapValuatorClass(client, d->valuator, classbuf);
+    }
+}
+
+/***********************************************************************
+ *
+ * This procedure lists the input devices available to the server.
+ *
+ */
+
+int
+ProcXListInputDevices(register ClientPtr client)
+{
+    xListInputDevicesReply rep;
+    int numdevs = 0;
+    int namesize = 1;	/* need 1 extra byte for strcpy */
+    int size = 0;
+    int total_length;
+    char *devbuf;
+    char *classbuf;
+    char *namebuf;
+    char *savbuf;
+    xDeviceInfo *dev;
+    DeviceIntPtr d;
+
+    REQUEST_SIZE_MATCH(xListInputDevicesReq);
+
+    rep.repType = X_Reply;
+    rep.RepType = X_ListInputDevices;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+
+    AddOtherInputDevices();
+
+    for (d = inputInfo.devices; d; d = d->next) {
+	SizeDeviceInfo(d, &namesize, &size);
+        numdevs++;
+    }
+    for (d = inputInfo.off_devices; d; d = d->next) {
+	SizeDeviceInfo(d, &namesize, &size);
+        numdevs++;
+    }
+
+    total_length = numdevs * sizeof(xDeviceInfo) + size + namesize;
+    devbuf = (char *)xalloc(total_length);
+    classbuf = devbuf + (numdevs * sizeof(xDeviceInfo));
+    namebuf = classbuf + size;
+    savbuf = devbuf;
+
+    dev = (xDeviceInfoPtr) devbuf;
+    for (d = inputInfo.devices; d; d = d->next, dev++)
+	ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf);
+    for (d = inputInfo.off_devices; d; d = d->next, dev++)
+	ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf);
+
+    rep.ndevices = numdevs;
+    rep.length = (total_length + 3) >> 2;
+    WriteReplyToClient(client, sizeof(xListInputDevicesReply), &rep);
+    WriteToClient(client, total_length, savbuf);
+    xfree(savbuf);
+    return Success;
+}
+
+/***********************************************************************
+ *
  * This procedure writes the reply for the XListInputDevices function,
  * if the client and server have a different byte ordering.
  *
diff --git a/Xi/listdev.h b/Xi/listdev.h
index bdd67ce..db376de 100644
--- a/Xi/listdev.h
+++ b/Xi/listdev.h
@@ -36,44 +36,6 @@ int SProcXListInputDevices(ClientPtr	/* 
 int ProcXListInputDevices(ClientPtr	/* client */
     );
 
-void SizeDeviceInfo(DeviceIntPtr /* d */ ,
-		    int * /* namesize */ ,
-		    int *	/* size */
-    );
-
-void ListDeviceInfo(ClientPtr /* client */ ,
-		    DeviceIntPtr /* d */ ,
-		    xDeviceInfoPtr /* dev */ ,
-		    char ** /* devbuf */ ,
-		    char ** /* classbuf */ ,
-		    char **	/* namebuf */
-    );
-
-void CopyDeviceName(char ** /* namebuf */ ,
-		    char *	/* name */
-    );
-
-void CopySwapDevice(ClientPtr /* client */ ,
-		    DeviceIntPtr /* d */ ,
-		    int /* num_classes */ ,
-		    char **	/* buf */
-    );
-
-void CopySwapKeyClass(ClientPtr /* client */ ,
-		      KeyClassPtr /* k */ ,
-		      char **	/* buf */
-    );
-
-void CopySwapButtonClass(ClientPtr /* client */ ,
-			 ButtonClassPtr /* b */ ,
-			 char **	/* buf */
-    );
-
-int CopySwapValuatorClass(ClientPtr /* client */ ,
-			  ValuatorClassPtr /* v */ ,
-			  char **	/* buf */
-    );
-
 void SRepXListInputDevices(ClientPtr /* client */ ,
 			   int /* size */ ,
 			   xListInputDevicesReply *	/* rep */
diff --git a/include/exevents.h b/include/exevents.h
index 7fbaddb..69d4abc 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -148,10 +148,6 @@ extern void DeleteWindowFromAnyExtEvents
 	WindowPtr              /* pWin */,
 	Bool                   /* freeResources */);
 
-extern void DeleteDeviceFromAnyExtEvents(
-	WindowPtr              /* pWin */,
-	DeviceIntPtr           /* dev */);
-
 extern int MaybeSendDeviceMotionNotifyHint (
 	deviceKeyButtonPointer * /* pEvents */,
 	Mask                   /* mask */);
@@ -164,11 +160,6 @@ extern void CheckDeviceGrabAndHintWindow
 	ClientPtr              /* client */,
 	Mask                   /* deliveryMask */);
 
-extern Mask DeviceEventMaskForClient(
-	DeviceIntPtr           /* dev */,
-	WindowPtr              /* pWin */,
-	ClientPtr              /* client */);
-
 extern void MaybeStopDeviceHint(
 	DeviceIntPtr           /* dev */,
 	ClientPtr              /* client */);
@@ -179,13 +170,6 @@ extern int DeviceEventSuppressForWindow(
 	Mask                   /* mask */,
 	int                    /* maskndx */);
 
-void FindInterestedChildren(
-        DeviceIntPtr           /* dev */,
-        WindowPtr              /* p1 */,
-        Mask                   /* mask */,
-        xEvent *               /* ev */,
-        int                    /* count */);
-
 void SendEventToAllWindows(
         DeviceIntPtr           /* dev */,
         Mask                   /* mask */,
diff --git a/include/extinit.h b/include/extinit.h
index 2087d74..e616b6d 100644
--- a/include/extinit.h
+++ b/include/extinit.h
@@ -37,93 +37,6 @@ XInputExtensionInit(
 	void
 	);
 
-
-int
-ProcIDispatch (
-	ClientPtr              /* client */
-	);
-
-int
-SProcIDispatch(
-	ClientPtr              /* client */
-	);
-
-void
-SReplyIDispatch (
-	ClientPtr              /* client */,
-	int                    /* len */,
-	xGrabDeviceReply *     /* rep */
-	);
-
-void
-SEventIDispatch (
-	xEvent *               /* from */,
-	xEvent *               /* to */
-	);
-
-void
-SEventDeviceValuator (
-	deviceValuator *       /* from */,
-	deviceValuator *       /* to */
-	);
-
-void
-SEventFocus (
-	deviceFocus *          /* from */,
-	deviceFocus *          /* to */
-	);
-
-void
-SDeviceStateNotifyEvent (
-	deviceStateNotify *    /* from */,
-	deviceStateNotify *    /* to */
-	);
-
-void
-SDeviceKeyStateNotifyEvent (
-	deviceKeyStateNotify * /* from */,
-	deviceKeyStateNotify * /* to */
-	);
-
-void
-SDeviceButtonStateNotifyEvent (
-	deviceButtonStateNotify * /* from */,
-	deviceButtonStateNotify * /* to */
-	);
-
-void
-SChangeDeviceNotifyEvent (
-	changeDeviceNotify *   /* from */,
-	changeDeviceNotify *   /* to */
-	);
-
-void
-SDeviceMappingNotifyEvent (
-	deviceMappingNotify *  /* from */,
-	deviceMappingNotify *  /* to */
-	);
-
-void
-SDevicePresenceNotifyEvent (
-       devicePresenceNotify * /* from */,
-       devicePresenceNotify * /* to */
-       );
-
-void
-FixExtensionEvents (
-	ExtensionEntry 	*      /* extEntry */
-	);
-
-void
-RestoreExtensionEvents (
-	void
-	);
-
-void
-IResetProc(
-	ExtensionEntry *       /* unused */
-	);
-
 void
 AssignTypeAndName (
 	DeviceIntPtr           /* dev */,
@@ -131,41 +44,9 @@ AssignTypeAndName (
 	char *                 /* name */
 	);
 
-void
-MakeDeviceTypeAtoms (
-	void
-);
-
 DeviceIntPtr
 LookupDeviceIntRec (
 	CARD8                  /* id */
 	);
 
-void
-SetExclusiveAccess (
-	Mask                   /* mask */
-	);
-
-void
-AllowPropagateSuppress (
-	Mask                   /* mask */
-	);
-
-Mask
-GetNextExtEventMask (
-	void
-);
-
-void
-SetMaskForExtEvent(
-	Mask                   /* mask */,
-	int                    /* event */
-	);
-
-void
-SetEventInfo(
-	Mask                   /* mask */,
-	int                    /* constant */
-	);
-
 #endif /* EXTINIT_H */
diff-tree 4b5802ddbd45271be3cadeae0a83a6742df2515b (from 04b87d6dfae02e4ecdb5216d12c6cdafd1e8c2b4)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sun Mar 25 17:57:54 2007 -0400

    General DIX static and dead code cleanup.

diff --git a/dix/dispatch.c b/dix/dispatch.c
index 02665ed..3d8e71f 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -299,7 +299,6 @@ long	    SmartScheduleMaxSlice = SMART_S
 long	    SmartScheduleTime;
 static ClientPtr   SmartLastClient;
 static int	   SmartLastIndex[SMART_MAX_PRIORITY-SMART_MIN_PRIORITY+1];
-int         SmartScheduleClient(int *clientReady, int nready);
 
 #ifdef SMART_DEBUG
 long	    SmartLastPrint;
@@ -308,7 +307,7 @@ long	    SmartLastPrint;
 void        Dispatch(void);
 void        InitProcVectors(void);
 
-int
+static int
 SmartScheduleClient (int *clientReady, int nready)
 {
     ClientPtr	pClient;
@@ -834,7 +833,7 @@ ProcCirculateWindow(ClientPtr client)
     return(client->noClientException);
 }
 
-int
+static int
 GetGeometry(ClientPtr client, xGetGeometryReply *rep)
 {
     DrawablePtr pDraw;
@@ -2157,8 +2156,7 @@ ProcPutImage(ClientPtr client)
      return (client->noClientException);
 }
 
-
-int
+static int
 DoGetImage(ClientPtr client, int format, Drawable drawable, 
            int x, int y, int width, int height, 
            Mask planemask, xGetImageReply **im_return)
@@ -3383,6 +3381,28 @@ ProcChangeAccessControl(ClientPtr client
     return (result);
 }
 
+/*********************
+ * CloseDownRetainedResources
+ *
+ *    Find all clients that are gone and have terminated in RetainTemporary 
+ *    and destroy their resources.
+ *********************/
+
+static void
+CloseDownRetainedResources(void)
+{
+    int i;
+    ClientPtr client;
+
+    for (i=1; i<currentMaxClients; i++)
+    {
+        client = clients[i];
+        if (client && (client->closeDownMode == RetainTemporary)
+	    && (client->clientGone))
+	    CloseDownClient(client);
+    }
+}
+
 int
 ProcKillClient(ClientPtr client)
 {
@@ -3651,28 +3671,6 @@ KillAllClients()
         }
 }
 
-/*********************
- * CloseDownRetainedResources
- *
- *    Find all clients that are gone and have terminated in RetainTemporary 
- *    and  destroy their resources.
- *********************/
-
-void
-CloseDownRetainedResources()
-{
-    int i;
-    ClientPtr client;
-
-    for (i=1; i<currentMaxClients; i++)
-    {
-        client = clients[i];
-        if (client && (client->closeDownMode == RetainTemporary)
-	    && (client->clientGone))
-	    CloseDownClient(client);
-    }
-}
-
 extern int clientPrivateLen;
 extern unsigned *clientPrivateSizes;
 extern unsigned totalClientSize;
diff --git a/dix/dixutils.c b/dix/dixutils.c
index c0728da..44d82c9 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -882,9 +882,7 @@ static CallbackFuncsRec default_cbfuncs 
     _DeleteCallbackList
 };
 
-/* ===== Public Procedures ===== */
-
-Bool
+static Bool
 CreateCallbackList(CallbackListPtr *pcbl, CallbackFuncsPtr cbfuncs)
 {
     CallbackListPtr  cbl;
@@ -916,6 +914,8 @@ CreateCallbackList(CallbackListPtr *pcbl
     return TRUE;
 }
 
+/* ===== Public Procedures ===== */
+
 _X_EXPORT Bool 
 AddCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, pointer data)
 {
diff --git a/dix/extension.c b/dix/extension.c
index fb4ee6b..88dff15 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -66,8 +66,6 @@ SOFTWARE.
 #define LAST_EVENT  128
 #define LAST_ERROR 255
 
-static ScreenProcEntry AuxillaryScreenProcs[MAXSCREENS];
-
 static ExtensionEntry **extensions = (ExtensionEntry **)NULL;
 
 int lastEvent = EXTENSION_EVENT_BASE;
@@ -298,21 +296,8 @@ CloseDownExtensions()
     extensions = (ExtensionEntry **)NULL;
     lastEvent = EXTENSION_EVENT_BASE;
     lastError = FirstExtensionError;
-    for (i=0; i<MAXSCREENS; i++)
-    {
-	ScreenProcEntry *spentry = &AuxillaryScreenProcs[i];
-
-	while (spentry->num)
-	{
-	    spentry->num--;
-	    xfree(spentry->procList[spentry->num].name);
-	}
-	xfree(spentry->procList);
-	spentry->procList = (ProcEntryPtr)NULL;
-    }
 }
 
-
 int
 ProcQueryExtension(ClientPtr client)
 {
@@ -406,72 +391,6 @@ ProcListExtensions(ClientPtr client)
     return(client->noClientException);
 }
 
-
-ExtensionLookupProc 
-LookupProc(char *name, GCPtr pGC)
-{
-    int i;
-    ScreenProcEntry *spentry;
-    spentry  = &AuxillaryScreenProcs[pGC->pScreen->myNum];
-    if (spentry->num)    
-    {
-        for (i = 0; i < spentry->num; i++)
-            if (strcmp(name, spentry->procList[i].name) == 0)
-                return(spentry->procList[i].proc);
-    }
-    return (ExtensionLookupProc)NULL;
-}
-
-Bool
-RegisterProc(char *name, GC *pGC, ExtensionLookupProc proc)
-{
-    return RegisterScreenProc(name, pGC->pScreen, proc);
-}
-
-Bool
-RegisterScreenProc(char *name, ScreenPtr pScreen, ExtensionLookupProc proc)
-{
-    ScreenProcEntry *spentry;
-    ProcEntryPtr procEntry = (ProcEntryPtr)NULL;
-    char *newname;
-    int i;
-
-    spentry = &AuxillaryScreenProcs[pScreen->myNum];
-    /* first replace duplicates */
-    if (spentry->num)
-    {
-        for (i = 0; i < spentry->num; i++)
-            if (strcmp(name, spentry->procList[i].name) == 0)
-	    {
-                procEntry = &spentry->procList[i];
-		break;
-	    }
-    }
-    if (procEntry)
-        procEntry->proc = proc;
-    else
-    {
-	newname = (char *)xalloc(strlen(name)+1);
-	if (!newname)
-	    return FALSE;
-	procEntry = (ProcEntryPtr)
-			    xrealloc(spentry->procList,
-				     sizeof(ProcEntryRec) * (spentry->num+1));
-	if (!procEntry)
-	{
-	    xfree(newname);
-	    return FALSE;
-	}
-	spentry->procList = procEntry;
-        procEntry += spentry->num;
-        procEntry->name = newname;
-        strcpy(newname, name);
-        procEntry->proc = proc;
-        spentry->num++;        
-    }
-    return TRUE;
-}
-
 #ifdef XSERVER_DTRACE
 void LoadExtensionNames(char **RequestNames) {
     int i;
diff --git a/dix/gc.c b/dix/gc.c
index 7b7953d..7a76dd9 100644
--- a/dix/gc.c
+++ b/dix/gc.c
@@ -907,17 +907,6 @@ FreeGC(pointer value, XID gid)
     return(Success);
 }
 
-void
-SetGCMask(GCPtr pGC, Mask selectMask, Mask newDataMask)
-{
-    pGC->stateChanges = (~selectMask & pGC->stateChanges) |
-		        (selectMask & newDataMask);
-    if (selectMask & newDataMask)
-        pGC->serialNumber |= GC_CHANGE_SERIAL_BIT;        
-}
-
-
-
 /* CreateScratchGC(pScreen, depth)
     like CreateGC, but doesn't do the default tile or stipple,
 since we can't create them without already having a GC.  any code
diff --git a/dix/swaprep.c b/dix/swaprep.c
index 6f4b277..7d3251a 100644
--- a/dix/swaprep.c
+++ b/dix/swaprep.c
@@ -317,7 +317,7 @@ SQueryPointerReply(ClientPtr pClient, in
     (void)WriteToClient(pClient, size, (char *) pRep);
 }
 
-void
+static void
 SwapTimecoord(xTimecoord* pCoord)
 {
     char n;
@@ -584,7 +584,7 @@ SAllocColorPlanesReply(ClientPtr pClient
     (void)WriteToClient(pClient, size, (char *) pRep);
 }
 
-void
+static void
 SwapRGB(xrgb *prgb)
 {
     char n;
@@ -1159,6 +1159,58 @@ SKeymapNotifyEvent(xEvent *from, xEvent 
     *to = *from;
 }
 
+static void
+SwapConnSetup(xConnSetup *pConnSetup, xConnSetup *pConnSetupT)
+{
+    cpswapl(pConnSetup->release, pConnSetupT->release);
+    cpswapl(pConnSetup->ridBase, pConnSetupT->ridBase);
+    cpswapl(pConnSetup->ridMask, pConnSetupT->ridMask);
+    cpswapl(pConnSetup->motionBufferSize, pConnSetupT->motionBufferSize);
+    cpswaps(pConnSetup->nbytesVendor, pConnSetupT->nbytesVendor);
+    cpswaps(pConnSetup->maxRequestSize, pConnSetupT->maxRequestSize);
+    pConnSetupT->minKeyCode = pConnSetup->minKeyCode;
+    pConnSetupT->maxKeyCode = pConnSetup->maxKeyCode;
+    pConnSetupT->numRoots = pConnSetup->numRoots;
+    pConnSetupT->numFormats = pConnSetup->numFormats;
+    pConnSetupT->imageByteOrder = pConnSetup->imageByteOrder;
+    pConnSetupT->bitmapBitOrder = pConnSetup->bitmapBitOrder;
+    pConnSetupT->bitmapScanlineUnit = pConnSetup->bitmapScanlineUnit;
+    pConnSetupT->bitmapScanlinePad = pConnSetup->bitmapScanlinePad;
+}
+
+static void
+SwapWinRoot(xWindowRoot *pRoot, xWindowRoot *pRootT)
+{
+    cpswapl(pRoot->windowId, pRootT->windowId);
+    cpswapl(pRoot->defaultColormap, pRootT->defaultColormap);
+    cpswapl(pRoot->whitePixel, pRootT->whitePixel);
+    cpswapl(pRoot->blackPixel, pRootT->blackPixel);
+    cpswapl(pRoot->currentInputMask, pRootT->currentInputMask);
+    cpswaps(pRoot->pixWidth, pRootT->pixWidth);
+    cpswaps(pRoot->pixHeight, pRootT->pixHeight);
+    cpswaps(pRoot->mmWidth, pRootT->mmWidth);
+    cpswaps(pRoot->mmHeight, pRootT->mmHeight);
+    cpswaps(pRoot->minInstalledMaps, pRootT->minInstalledMaps);
+    cpswaps(pRoot->maxInstalledMaps, pRootT->maxInstalledMaps);
+    cpswapl(pRoot->rootVisualID, pRootT->rootVisualID);
+    pRootT->backingStore = pRoot->backingStore;
+    pRootT->saveUnders = pRoot->saveUnders;
+    pRootT->rootDepth = pRoot->rootDepth;
+    pRootT->nDepths = pRoot->nDepths;
+}
+
+static void
+SwapVisual(xVisualType *pVis, xVisualType *pVisT)
+{
+    cpswapl(pVis->visualID, pVisT->visualID);
+    pVisT->class = pVis->class;
+    pVisT->bitsPerRGB = pVis->bitsPerRGB;
+    cpswaps(pVis->colormapEntries, pVisT->colormapEntries);
+    cpswapl(pVis->redMask, pVisT->redMask);
+    cpswapl(pVis->greenMask, pVisT->greenMask);
+    cpswapl(pVis->blueMask, pVisT->blueMask);
+}
+
 _X_EXPORT void
 SwapConnSetupInfo(
     char 	*pInfo,
@@ -1210,7 +1262,6 @@ SwapConnSetupInfo(
     }
 }
 
-
 void
 WriteSConnectionInfo(ClientPtr pClient, unsigned long size, char *pInfo)
 {
@@ -1227,58 +1278,6 @@ WriteSConnectionInfo(ClientPtr pClient, 
     DEALLOCATE_LOCAL(pInfoTBase);
 }
 
-void
-SwapConnSetup(xConnSetup *pConnSetup, xConnSetup *pConnSetupT)
-{
-    cpswapl(pConnSetup->release, pConnSetupT->release);
-    cpswapl(pConnSetup->ridBase, pConnSetupT->ridBase);
-    cpswapl(pConnSetup->ridMask, pConnSetupT->ridMask);
-    cpswapl(pConnSetup->motionBufferSize, pConnSetupT->motionBufferSize);
-    cpswaps(pConnSetup->nbytesVendor, pConnSetupT->nbytesVendor);
-    cpswaps(pConnSetup->maxRequestSize, pConnSetupT->maxRequestSize);
-    pConnSetupT->minKeyCode = pConnSetup->minKeyCode;
-    pConnSetupT->maxKeyCode = pConnSetup->maxKeyCode;
-    pConnSetupT->numRoots = pConnSetup->numRoots;
-    pConnSetupT->numFormats = pConnSetup->numFormats;
-    pConnSetupT->imageByteOrder = pConnSetup->imageByteOrder;
-    pConnSetupT->bitmapBitOrder = pConnSetup->bitmapBitOrder;
-    pConnSetupT->bitmapScanlineUnit = pConnSetup->bitmapScanlineUnit;
-    pConnSetupT->bitmapScanlinePad = pConnSetup->bitmapScanlinePad;
-}
-
-void
-SwapWinRoot(xWindowRoot *pRoot, xWindowRoot *pRootT)
-{
-    cpswapl(pRoot->windowId, pRootT->windowId);
-    cpswapl(pRoot->defaultColormap, pRootT->defaultColormap);
-    cpswapl(pRoot->whitePixel, pRootT->whitePixel);
-    cpswapl(pRoot->blackPixel, pRootT->blackPixel);
-    cpswapl(pRoot->currentInputMask, pRootT->currentInputMask);
-    cpswaps(pRoot->pixWidth, pRootT->pixWidth);
-    cpswaps(pRoot->pixHeight, pRootT->pixHeight);
-    cpswaps(pRoot->mmWidth, pRootT->mmWidth);
-    cpswaps(pRoot->mmHeight, pRootT->mmHeight);
-    cpswaps(pRoot->minInstalledMaps, pRootT->minInstalledMaps);
-    cpswaps(pRoot->maxInstalledMaps, pRootT->maxInstalledMaps);
-    cpswapl(pRoot->rootVisualID, pRootT->rootVisualID);
-    pRootT->backingStore = pRoot->backingStore;
-    pRootT->saveUnders = pRoot->saveUnders;
-    pRootT->rootDepth = pRoot->rootDepth;
-    pRootT->nDepths = pRoot->nDepths;
-}
-
-void
-SwapVisual(xVisualType *pVis, xVisualType *pVisT)
-{
-    cpswapl(pVis->visualID, pVisT->visualID);
-    pVisT->class = pVis->class;
-    pVisT->bitsPerRGB = pVis->bitsPerRGB;
-    cpswaps(pVis->colormapEntries, pVisT->colormapEntries);
-    cpswapl(pVis->redMask, pVisT->redMask);
-    cpswapl(pVis->greenMask, pVisT->greenMask);
-    cpswapl(pVis->blueMask, pVisT->blueMask);
-}
-
 _X_EXPORT void
 SwapConnSetupPrefix(xConnSetupPrefix *pcspFrom, xConnSetupPrefix *pcspTo)
 {
diff --git a/dix/window.c b/dix/window.c
index 2a82f2e..7d99477 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -539,7 +539,7 @@ InitRootWindow(WindowPtr pWin)
  * window from which the region came.
  */
 
-void
+static void
 ClippedRegionFromBox(WindowPtr pWin, RegionPtr Rgn,
                      int x, int y,
                      int w, int h)
@@ -836,6 +836,26 @@ CreateWindow(Window wid, WindowPtr pPare
 }
 
 static void
+DisposeWindowOptional (WindowPtr pWin)
+{
+    if (!pWin->optional)
+	return;
+    /*
+     * everything is peachy.  Delete the optional record
+     * and clean up
+     */
+    if (pWin->optional->cursor)
+    {
+	FreeCursor (pWin->optional->cursor, (Cursor)0);
+	pWin->cursorIsNone = FALSE;
+    }
+    else
+	pWin->cursorIsNone = TRUE;
+    xfree (pWin->optional);
+    pWin->optional = NULL;
+}
+
+static void
 FreeWindowResources(WindowPtr pWin)
 {
     ScreenPtr pScreen = pWin->drawable.pScreen;
@@ -2703,6 +2723,30 @@ RealizeTree(WindowPtr pWin)
     }
 }
 
+static WindowPtr windowDisableMapUnmapEvents;
+
+void
+DisableMapUnmapEvents(WindowPtr pWin)
+{
+    assert (windowDisableMapUnmapEvents == NULL);
+    
+    windowDisableMapUnmapEvents = pWin;
+}
+
+void
+EnableMapUnmapEvents(WindowPtr pWin)
+{
+    assert (windowDisableMapUnmapEvents != NULL);
+
+    windowDisableMapUnmapEvents = NULL;
+}
+
+static Bool
+MapUnmapEventsEnabled(WindowPtr pWin)
+{
+    return pWin != windowDisableMapUnmapEvents;
+}
+
 /*****
  * MapWindow
  *    If some other client has selected SubStructureReDirect on the parent
@@ -3203,21 +3247,6 @@ HandleSaveSet(ClientPtr client)
 
 /**
  *
- *  \param x,y  in root
- *  \param box  "return" value
- */
-Bool
-VisibleBoundingBoxFromPoint(WindowPtr pWin, int x, int y, BoxPtr box)
-{
-    if (!pWin->realized)
-	return (FALSE);
-    if (POINT_IN_REGION(pWin->drawable.pScreen, &pWin->clipList, x, y, box))
-	return(TRUE);
-    return(FALSE);
-}
-
-/**
- *
  * \param x,y  in root
  */
 Bool
@@ -3324,30 +3353,6 @@ SendVisibilityNotify(WindowPtr pWin)
     DeliverEvents(pWin, &event, 1, NullWindow);
 }
 
-static WindowPtr windowDisableMapUnmapEvents;
-
-void
-DisableMapUnmapEvents(WindowPtr pWin)
-{
-    assert (windowDisableMapUnmapEvents == NULL);
-    
-    windowDisableMapUnmapEvents = pWin;
-}
-
-void
-EnableMapUnmapEvents(WindowPtr pWin)
-{
-    assert (windowDisableMapUnmapEvents != NULL);
-
-    windowDisableMapUnmapEvents = NULL;
-}
-
-Bool
-MapUnmapEventsEnabled(WindowPtr pWin)
-{
-    return pWin != windowDisableMapUnmapEvents;
-}
-
 #define RANDOM_WIDTH 32
 
 #ifndef NOLOGOHACK
@@ -3700,41 +3705,6 @@ MakeWindowOptional (WindowPtr pWin)
     return TRUE;
 }
 
-void
-DisposeWindowOptional (WindowPtr pWin)
-{
-    if (!pWin->optional)
-	return;
-    /*
-     * everything is peachy.  Delete the optional record
-     * and clean up
-     */
-    /*
-     * TOG changed this code to:
-     *
-     *	    if (pWin->cursorIsNone == FALSE)
-     *		FreeCursor (pWin->optional->cursor, (Cursor)0);
-     *	    pWin->cursorIsNone = TRUE;
-     *
-     * This is blatently wrong; windows without optionals can have
-     * two different cursor values, either None or sharing their
-     * parents cursor.  This difference is controlled by the
-     * cursorIsNone value; when TRUE, the window has no cursor,
-     * when false, it shares its cursor with its parent; TOG
-     * made it impossible for a window to have a cursor without
-     * an optional record.
-     */
-    if (pWin->optional->cursor)
-    {
-	FreeCursor (pWin->optional->cursor, (Cursor)0);
-	pWin->cursorIsNone = FALSE;
-    }
-    else
-	pWin->cursorIsNone = TRUE;
-    xfree (pWin->optional);
-    pWin->optional = NULL;
-}
-
 #ifndef NOLOGOHACK
 static void
 DrawLogo(WindowPtr pWin)
diff --git a/include/dix.h b/include/dix.h
index 5c2c5b8..b412683 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -220,8 +220,6 @@ extern int dixDestroyPixmap(
     pointer /*value*/,
     XID /*pid*/);
 
-extern void CloseDownRetainedResources(void);
-
 extern void InitClient(
     ClientPtr /*client*/,
     int /*i*/,
@@ -243,25 +241,10 @@ extern void DeleteWindowFromAnySelection
 extern void MarkClientException(
     ClientPtr /*client*/);
 
-extern int GetGeometry(
-    ClientPtr /*client*/,
-    xGetGeometryReply* /* wa */);
-
 extern int SendConnSetup(
     ClientPtr /*client*/,
     char* /*reason*/);
 
-extern int DoGetImage(
-    ClientPtr	/*client*/,
-    int /*format*/,
-    Drawable /*drawable*/,
-    int /*x*/, 
-    int /*y*/, 
-    int /*width*/, 
-    int /*height*/,
-    Mask /*planemask*/,
-    xGetImageReply ** /*im_return*/);
-
 #if defined(DDXBEFORERESET)
 extern void ddxBeforeReset (void);
 #endif
@@ -632,10 +615,6 @@ typedef struct _CallbackProcs {
     DeleteCallbackListProcPtr	DeleteCallbackList;
 } CallbackFuncsRec, *CallbackFuncsPtr;
 
-extern Bool CreateCallbackList(
-    CallbackListPtr * /*pcbl*/,
-    CallbackFuncsPtr /*cbfuncs*/);
-
 extern Bool AddCallback(
     CallbackListPtr * /*pcbl*/,
     CallbackProcPtr /*callback*/,
diff --git a/include/extnsionst.h b/include/extnsionst.h
index 38d4bd7..28ae1d5 100644
--- a/include/extnsionst.h
+++ b/include/extnsionst.h
@@ -85,32 +85,11 @@ extern void NotImplemented (	/* FIXME: t
 	xEvent *,
 	xEvent *);
 
-typedef void (* ExtensionLookupProc)(
-#ifdef EXTENSION_PROC_ARGS
-    EXTENSION_PROC_ARGS
-#else
-    /* args no longer indeterminate */
-    char *name,
-    GCPtr pGC
-#endif
-);
-
-typedef struct _ProcEntry {
-    char *name;
-    ExtensionLookupProc proc;
-} ProcEntryRec, *ProcEntryPtr;
-
-typedef struct _ScreenProcEntry {
-    int num;
-    ProcEntryPtr procList;
-} ScreenProcEntry;
-
 #define    SetGCVector(pGC, VectorElement, NewRoutineAddress, Atom)    \
     pGC->VectorElement = NewRoutineAddress;
 
 #define    GetGCValue(pGC, GCElement)    (pGC->GCElement)
 
-
 extern ExtensionEntry *AddExtension(
     char* /*name*/,
     int /*NumEvents*/,
@@ -128,20 +107,6 @@ extern Bool AddExtensionAlias(
 extern ExtensionEntry *CheckExtension(const char *extname);
 extern ExtensionEntry *GetExtensionEntry(int major);
 
-extern ExtensionLookupProc LookupProc(
-    char* /*name*/,
-    GCPtr /*pGC*/);
-
-extern Bool RegisterProc(
-    char* /*name*/,
-    GCPtr /*pGC*/,
-    ExtensionLookupProc /*proc*/);
-
-extern Bool RegisterScreenProc(
-    char* /*name*/,
-    ScreenPtr /*pScreen*/,
-    ExtensionLookupProc /*proc*/);
-
 extern void DeclareExtensionSecurity(
     char * /*extname*/,
     Bool /*secure*/);
diff --git a/include/gc.h b/include/gc.h
index 6c7add6..3b7e38e 100644
--- a/include/gc.h
+++ b/include/gc.h
@@ -126,11 +126,6 @@ extern int FreeGC(
     pointer /*pGC*/,
     XID /*gid*/);
 
-extern void SetGCMask(
-    GCPtr /*pGC*/,
-    Mask /*selectMask*/,
-    Mask /*newDataMask*/);
-
 extern GCPtr CreateScratchGC(
     ScreenPtr /*pScreen*/,
     unsigned /*depth*/);
diff --git a/include/os.h b/include/os.h
index d4eed22..7399436 100644
--- a/include/os.h
+++ b/include/os.h
@@ -348,12 +348,6 @@ extern void InitAuthorization(char * /*f
 
 extern void RegisterAuthorizations(void);
 
-extern XID AuthorizationToID (
-	unsigned short	name_length,
-	char		*name,
-	unsigned short	data_length,
-	char		*data);
-
 extern int AuthorizationFromID (
 	XID 		id,
 	unsigned short	*name_lenp,
@@ -402,14 +396,6 @@ extern int ddxProcessArgument(int /*argc
 
 extern void ddxUseMsg(void);
 
-/*
- *  idiom processing stuff
- */
-
-extern xReqPtr PeekNextRequest(xReqPtr req, ClientPtr client, Bool readmore);
-
-extern void SkipRequests(xReqPtr req, ClientPtr client, int numskipped);
-
 /* int ReqLen(xReq *req, ClientPtr client)
  * Given a pointer to a *complete* request, return its length in bytes.
  * Note that if the request is a big request (as defined in the Big
diff --git a/include/swaprep.h b/include/swaprep.h
index 8a9dcf0..bebd3a8 100644
--- a/include/swaprep.h
+++ b/include/swaprep.h
@@ -91,9 +91,6 @@ extern void SQueryPointerReply(
     int /* size */,
     xQueryPointerReply * /* pRep */);
 
-extern void SwapTimecoord(
-    xTimecoord * /* pCoord */);
-
 extern void SwapTimeCoordWrite(
     ClientPtr /* pClient */,
     int /* size */,
@@ -174,9 +171,6 @@ extern void SAllocColorPlanesReply(
     int /* size */,
     xAllocColorPlanesReply * /* pRep */);
 
-extern void SwapRGB(
-    xrgb * /* prgb */);
-
 extern void SQColorsExtend(
     ClientPtr /* pClient */,
     int /* size */,
@@ -255,18 +249,6 @@ extern void WriteSConnectionInfo(
     unsigned long /* size */,
     char * /* pInfo */);
 
-extern void SwapConnSetup(
-    xConnSetup * /* pConnSetup */,
-    xConnSetup * /* pConnSetupT */);
-
-extern void SwapWinRoot(
-    xWindowRoot * /* pRoot */,
-    xWindowRoot * /* pRootT */);
-
-extern void SwapVisual(
-    xVisualType * /* pVis */,
-    xVisualType * /* pVisT */);
-
 extern void SwapConnSetupPrefix(
     xConnSetupPrefix * /* pcspFrom */,
     xConnSetupPrefix * /* pcspTo */);
diff --git a/include/window.h b/include/window.h
index bddeb25..cd8c5b2 100644
--- a/include/window.h
+++ b/include/window.h
@@ -93,14 +93,6 @@ extern Bool CreateRootWindow(
 extern void InitRootWindow(
     WindowPtr /*pWin*/);
 
-extern void ClippedRegionFromBox(
-    WindowPtr /*pWin*/,
-    RegionPtr /*Rgn*/,
-    int /*x*/,
-    int /*y*/,
-    int /*w*/,
-    int /*h*/);
-
 typedef WindowPtr (* RealChildHeadProc) (WindowPtr pWin);
 
 void RegisterRealChildHeadProc (RealChildHeadProc proc);
@@ -205,12 +197,6 @@ extern void UnmapSubwindows(
 extern void HandleSaveSet(
     ClientPtr /*client*/);
 
-extern Bool VisibleBoundingBoxFromPoint(
-    WindowPtr /*pWin*/,
-    int /*x*/,
-    int /*y*/,
-    BoxPtr /*box*/);
-
 extern Bool PointInWindowIsVisible(
     WindowPtr /*pWin*/,
     int /*x*/,
@@ -235,9 +221,6 @@ extern void CheckWindowOptionalNeed(
 extern Bool MakeWindowOptional(
     WindowPtr /*pWin*/);
 
-extern void DisposeWindowOptional(
-    WindowPtr /*pWin*/);
-
 extern WindowPtr MoveWindowInStack(
     WindowPtr /*pWin*/,
     WindowPtr /*pNextSib*/);
@@ -271,7 +254,5 @@ extern void DisableMapUnmapEvents(
     WindowPtr /* pWin */ );
 extern void EnableMapUnmapEvents(
     WindowPtr /* pWin */ );
-extern Bool MapUnmapEventsEnabled(
-    WindowPtr /* pWin */ );
 
 #endif /* WINDOW_H */
diff --git a/os/access.c b/os/access.c
index db5ca31..221b8cb 100644
--- a/os/access.c
+++ b/os/access.c
@@ -234,8 +234,8 @@ static Bool NewHost(int /*family*/,
 		    int /*len*/,
 		    int /* addingLocalHosts */);
 
-int LocalClientCredAndGroups(ClientPtr client, int *pUid, int *pGid, 
-                             int **pSuppGids, int *nSuppGids);
+static int LocalClientCredAndGroups(ClientPtr client, int *pUid, int *pGid, 
+				    int **pSuppGids, int *nSuppGids);
 
 
 /* XFree86 bug #156: To keep track of which hosts were explicitly requested in
@@ -1431,7 +1431,7 @@ LocalClientCred(ClientPtr client, int *p
  *
  * Used by localuser & localgroup ServerInterpreted access control forms below
  */
-int
+static int
 LocalClientCredAndGroups(ClientPtr client, int *pUid, int *pGid, 
 			 int **pSuppGids, int *nSuppGids)
 {
diff --git a/os/auth.c b/os/auth.c
index bf33b7e..b06333e 100644
--- a/os/auth.c
+++ b/os/auth.c
@@ -255,26 +255,6 @@ ResetAuthorization (void)
     ShouldLoadAuth = TRUE;
 }
 
-XID
-AuthorizationToID (
-	unsigned short	name_length,
-	char		*name,
-	unsigned short	data_length,
-	char		*data)
-{
-    int	i;
-
-    for (i = 0; i < NUM_AUTHORIZATION; i++) {
-    	if (protocols[i].name_length == name_length &&
-	    memcmp (protocols[i].name, name, (int) name_length) == 0 &&
-	    protocols[i].ToID)
-    	{
-	    return (*protocols[i].ToID) (data_length, data);
-    	}
-    }
-    return (XID) ~0L;
-}
-
 int
 AuthorizationFromID (
 	XID 		id,
diff --git a/os/io.c b/os/io.c
index 80a151f..4e83e68 100644
--- a/os/io.c
+++ b/os/io.c
@@ -90,6 +90,11 @@ SOFTWARE.
 _X_EXPORT CallbackListPtr       ReplyCallback;
 _X_EXPORT CallbackListPtr       FlushCallback;
 
+static ConnectionInputPtr AllocateInputBuffer(void);
+static ConnectionOutputPtr AllocateOutputBuffer(void);
+static xReqPtr PeekNextRequest(xReqPtr req, ClientPtr client, Bool readmore);
+static void SkipRequests(xReqPtr req, ClientPtr client, int numskipped);
+
 /* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
  * systems are broken and return EWOULDBLOCK when they should return EAGAIN
  */
@@ -635,7 +640,7 @@ ResetCurrentRequest(ClientPtr client)
  *
  **********************/
 
-xReqPtr
+static xReqPtr
 PeekNextRequest(
     xReqPtr req,	/* request we're starting from */
     ClientPtr client,	/* client whose requests we're skipping */
@@ -697,7 +702,7 @@ PeekNextRequest(
 
 _X_EXPORT CallbackListPtr SkippedRequestsCallback = NULL;
 
-void
+static void
 SkipRequests(
     xReqPtr req,	/* last request being skipped */
     ClientPtr client,   /* client whose requests we're skipping */
@@ -1165,7 +1170,7 @@ FlushClient(ClientPtr who, OsCommPtr oc,
     return extraCount; /* return only the amount explicitly requested */
 }
 
-ConnectionInputPtr
+static ConnectionInputPtr
 AllocateInputBuffer(void)
 {
     ConnectionInputPtr oci;
@@ -1186,7 +1191,7 @@ AllocateInputBuffer(void)
     return oci;
 }
 
-ConnectionOutputPtr
+static ConnectionOutputPtr
 AllocateOutputBuffer(void)
 {
     ConnectionOutputPtr oco;
diff --git a/os/osdep.h b/os/osdep.h
index 3d303f9..0984d51 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -210,10 +210,6 @@ extern void FreeOsBuffers(
 
 #include "dix.h"
 
-extern ConnectionInputPtr AllocateInputBuffer(void);
-
-extern ConnectionOutputPtr AllocateOutputBuffer(void);
-
 extern fd_set AllSockets;
 extern fd_set AllClients;
 extern fd_set LastSelectMask;
@@ -293,14 +289,12 @@ extern XID AuthSecurityCheck (AuthCheckA
 /* in xdmcp.c */
 extern void XdmcpUseMsg (void);
 extern int XdmcpOptions(int argc, char **argv, int i);
-extern void XdmcpSetAuthentication (ARRAY8Ptr name);
 extern void XdmcpRegisterConnection (
     int	    type,
     char    *address,
     int	    addrlen);
 extern void XdmcpRegisterAuthorizations (void);
 extern void XdmcpRegisterAuthorization (char *name, int namelen);
-extern void XdmcpRegisterDisplayClass (char *name, int length);
 extern void XdmcpInit (void);
 extern void XdmcpReset (void);
 extern void XdmcpOpenDisplay(int sock);
@@ -313,8 +307,6 @@ extern void XdmcpRegisterAuthentication 
     ValidatorFunc Validator,
     GeneratorFunc Generator,
     AddAuthorFunc AddAuth);
-extern int XdmcpCheckAuthentication (ARRAY8Ptr Name, ARRAY8Ptr Data, int packet_type);
-extern int XdmcpAddAuthorization (ARRAY8Ptr name, ARRAY8Ptr data);
 
 struct sockaddr_in;
 extern void XdmcpRegisterBroadcastAddress (struct sockaddr_in *addr);
diff --git a/os/xdmcp.c b/os/xdmcp.c
index cfc1005..310f33b 100644
--- a/os/xdmcp.c
+++ b/os/xdmcp.c
@@ -197,8 +197,6 @@ static void receive_packet(int /*socketf
 
 static void send_packet(void);
 
-extern void XdmcpDeadSession(char * /*reason*/);
-
 static void timeout(void);
 
 static void restart(void);
@@ -213,10 +211,23 @@ static void XdmcpWakeupHandler(
     int /*i*/,
     pointer /*LastSelectMask*/);
 
-void XdmcpRegisterManufacturerDisplayID(
-    char    * /*name*/,
-    int	    /*length*/);
+/*
+ * Register the Manufacturer display ID
+ */
+
+static ARRAY8 ManufacturerDisplayID;
+
+static void
+XdmcpRegisterManufacturerDisplayID (char *name, int length)
+{
+    int	    i;
 
+    XdmcpDisposeARRAY8 (&ManufacturerDisplayID);
+    if (!XdmcpAllocARRAY8 (&ManufacturerDisplayID, length))
+	return;
+    for (i = 0; i < length; i++)
+	ManufacturerDisplayID.data[i] = (CARD8) name[i];
+}
 
 static unsigned short	xdm_udp_port = XDM_UDP_PORT;
 static Bool	OneSession = FALSE;
@@ -417,7 +428,7 @@ static ARRAY8Ptr	AuthenticationName = &n
 static ARRAY8Ptr	AuthenticationData = &noAuthenticationData;
 static AuthenticationFuncsPtr	AuthenticationFuncs;
 
-void
+static void
 XdmcpSetAuthentication (ARRAY8Ptr name)
 {
     int	i;
@@ -549,7 +560,7 @@ XdmcpRegisterAuthorization (char *name, 
 
 static ARRAY8	DisplayClass;
 
-void
+static void
 XdmcpRegisterDisplayClass (char *name, int length)
 {
     int	    i;
@@ -561,24 +572,6 @@ XdmcpRegisterDisplayClass (char *name, i
 	DisplayClass.data[i] = (CARD8) name[i];
 }
 
-/*
- * Register the Manufacturer display ID
- */
-
-static ARRAY8 ManufacturerDisplayID;
-
-void
-XdmcpRegisterManufacturerDisplayID (char *name, int length)
-{
-    int	    i;
-
-    XdmcpDisposeARRAY8 (&ManufacturerDisplayID);
-    if (!XdmcpAllocARRAY8 (&ManufacturerDisplayID, length))
-	return;
-    for (i = 0; i < length; i++)
-	ManufacturerDisplayID.data[i] = (CARD8) name[i];
-}
-
 /* 
  * initialize XDMCP; create the socket, compute the display
  * number, set up the state machine
@@ -867,7 +860,7 @@ send_packet(void)
  * timeouts, or Keepalive failure.
  */
 
-void
+static void
 XdmcpDeadSession (char *reason)
 {
     ErrorF ("XDM: %s, declaring session dead\n", reason);
@@ -960,21 +953,16 @@ restart(void)
     send_packet();
 }
 
-int
-XdmcpCheckAuthentication (
-    ARRAY8Ptr	Name,
-    ARRAY8Ptr	Data,
-    int	packet_type)
+static int
+XdmcpCheckAuthentication (ARRAY8Ptr Name, ARRAY8Ptr Data, int packet_type)
 {
     return (XdmcpARRAY8Equal (Name, AuthenticationName) &&
 	    (AuthenticationName->length == 0 ||
 	     (*AuthenticationFuncs->Validator) (AuthenticationData, Data, packet_type)));
 }
 
-int
-XdmcpAddAuthorization (
-    ARRAY8Ptr	name,
-    ARRAY8Ptr	data)
+static int
+XdmcpAddAuthorization (ARRAY8Ptr name, ARRAY8Ptr data)
 {
     AddAuthorFunc AddAuth;
 
diff --git a/record/set.c b/record/set.c
index 0ebb088..07a3a63 100644
--- a/record/set.c
+++ b/record/set.c
@@ -164,10 +164,10 @@ BitVectorIterateSet(RecordSetPtr pSet, R
     return (RecordSetIteratePtr)(long)(pInterval->last + 1);
 }
 
-RecordSetOperations BitVectorSetOperations = {
+static RecordSetOperations BitVectorSetOperations = {
     BitVectorDestroySet, BitVectorIsMemberOfSet, BitVectorIterateSet };
 
-RecordSetOperations BitVectorNoFreeOperations = {
+static RecordSetOperations BitVectorNoFreeOperations = {
     NoopDestroySet, BitVectorIsMemberOfSet, BitVectorIterateSet };
 
 static int
@@ -277,10 +277,10 @@ IntervalListIterateSet(RecordSetPtr pSet
 	return (RecordSetIteratePtr)NULL;
 }
 
-RecordSetOperations IntervalListSetOperations = {
+static RecordSetOperations IntervalListSetOperations = {
     IntervalListDestroySet, IntervalListIsMemberOfSet, IntervalListIterateSet };
 
-RecordSetOperations IntervalListNoFreeOperations = {
+static RecordSetOperations IntervalListNoFreeOperations = {
     NoopDestroySet, IntervalListIsMemberOfSet, IntervalListIterateSet };
 
 static int
diff-tree 04b87d6dfae02e4ecdb5216d12c6cdafd1e8c2b4 (from af769892a91c9af59de53ca3bcd77fc4967daffb)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sun Mar 25 17:57:22 2007 -0400

    Static and dead code cleaup for Xext/

diff --git a/Xext/appgroup.c b/Xext/appgroup.c
index bb7a73c..7bd2055 100644
--- a/Xext/appgroup.c
+++ b/Xext/appgroup.c
@@ -116,8 +116,7 @@ int XagAppGroupFree(
     return Success;
 }
 
-/* static */
-void XagClientStateChange(
+static void XagClientStateChange(
     CallbackListPtr* pcbl,
     pointer nulldata,
     pointer calldata)
@@ -172,21 +171,6 @@ void XagClientStateChange(
     }
 }
 
-void
-XagExtensionInit(INITARGS)
-{
-    if (AddExtension (XAGNAME,
-		      0,
-		      XagNumberErrors,
-		      ProcXagDispatch,
-		      SProcXagDispatch,
-		      XagResetProc,
-		      StandardMinorOpcode)) {
-	RT_APPGROUP = CreateNewResourceType (XagAppGroupFree);
-	XaceRegisterCallback(XACE_AUTH_AVAIL, XagCallClientStateChange, NULL);
-    }
-}
-
 /*ARGSUSED*/
 static 
 void XagResetProc(
@@ -393,8 +377,7 @@ int AttrValidate(
     return client->noClientException;
 }
 
-/* static */
-int ProcXagCreate (
+static int ProcXagCreate (
     register ClientPtr client)
 {
     REQUEST (xXagCreateReq);
@@ -425,8 +408,7 @@ int ProcXagCreate (
     return client->noClientException;
 }
 
-/* static */
-int ProcXagDestroy(
+static int ProcXagDestroy(
     register ClientPtr client)
 {
     AppGroupPtr pAppGrp;
@@ -743,18 +725,7 @@ XID XagId(
     return (client->appgroup ? client->appgroup->appgroupId : 0);
 }
 
-void XagGetDeltaInfo(
-    ClientPtr client,
-    CARD32* buf)
-{
-    *buf++ = (CARD32) client->appgroup->default_root;
-    *buf++ = (CARD32) client->appgroup->root_visual;
-    *buf++ = (CARD32) client->appgroup->default_colormap;
-    *buf++ = (CARD32) client->appgroup->black_pixel;
-    *buf = (CARD32) client->appgroup->white_pixel;
-}
-
-void XagCallClientStateChange(
+static void XagCallClientStateChange(
     CallbackListPtr *pcbl,
     pointer nulldata,
     pointer calldata)
@@ -785,3 +756,18 @@ void XagCallClientStateChange(
 	XagClientStateChange (NULL, NULL, (pointer)&clientinfo);
     }
 }
+
+void
+XagExtensionInit(INITARGS)
+{
+    if (AddExtension (XAGNAME,
+		      0,
+		      XagNumberErrors,
+		      ProcXagDispatch,
+		      SProcXagDispatch,
+		      XagResetProc,
+		      StandardMinorOpcode)) {
+	RT_APPGROUP = CreateNewResourceType (XagAppGroupFree);
+	XaceRegisterCallback(XACE_AUTH_AVAIL, XagCallClientStateChange, NULL);
+    }
+}
diff --git a/Xext/appgroup.h b/Xext/appgroup.h
index a875068..778da5d 100644
--- a/Xext/appgroup.h
+++ b/Xext/appgroup.h
@@ -50,12 +50,6 @@ extern ClientPtr XagLeader(
     ClientPtr			/* client */
 );
 
-extern void XagCallClientStateChange(
-    CallbackListPtr *		/* pcbl */,
-    pointer 			/* nulldata */,
-    pointer 			/* calldata */
-);
-
 extern Bool XagIsControlledRoot (
     ClientPtr			/* client */,
     WindowPtr			/* pParent */
@@ -65,22 +59,6 @@ extern XID XagId (
     ClientPtr			/* client */
 );
 
-extern void XagGetDeltaInfo (
-    ClientPtr			/* client */,
-    CARD32*			/* buf */
-);
-
-extern void XagClientStateChange(
-    CallbackListPtr* pcbl,
-    pointer nulldata,
-    pointer calldata);
-
-extern int ProcXagCreate (
-    register ClientPtr client);
-
-extern int ProcXagDestroy(
-    register ClientPtr client);
-
 _XFUNCPROTOEND
 
 #endif /* _APPGROUP_SRV_H_ */
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 85f5913..95df043 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -77,7 +77,7 @@ int 		PanoramiXPixHeight = 0;
 _X_EXPORT int 	PanoramiXNumScreens = 0;
 
 _X_EXPORT PanoramiXData *panoramiXdataPtr = NULL;
-RegionRec   		PanoramiXScreenRegion = {{0, 0, 0, 0}, NULL};
+static RegionRec   	PanoramiXScreenRegion = {{0, 0, 0, 0}, NULL};
 
 static int		PanoramiXNumDepths;
 static DepthPtr		PanoramiXDepths;
@@ -109,7 +109,6 @@ static void PanoramiXResetProc(Extension
 #include "panoramiXh.h"
 
 int (* SavedProcVector[256]) (ClientPtr client) = { NULL, };
-ScreenInfo *GlobalScrInfo = NULL;
 
 static int PanoramiXGCIndex = -1;
 static int PanoramiXScreenIndex = -1;
@@ -135,7 +134,7 @@ static void XineramaChangeClip(GCPtr, in
 static void XineramaDestroyClip(GCPtr);
 static void XineramaCopyClip(GCPtr, GCPtr);
 
-GCFuncs XineramaGCFuncs = {
+static GCFuncs XineramaGCFuncs = {
     XineramaValidateGC, XineramaChangeGC, XineramaCopyGC, XineramaDestroyGC,
     XineramaChangeClip, XineramaDestroyClip, XineramaCopyClip
 };
@@ -168,7 +167,7 @@ XineramaCloseScreen (int i, ScreenPtr pS
     return (*pScreen->CloseScreen) (i, pScreen);
 }
 
-Bool
+static Bool
 XineramaCreateGC(GCPtr pGC)
 {
     ScreenPtr pScreen = pGC->pScreen;
@@ -330,8 +329,6 @@ XineramaDestroyClip(GCPtr pGC)
     Xinerama_GC_FUNC_EPILOGUE (pGC);
 }
 
-
-
 _X_EXPORT int
 XineramaDeleteResource(pointer data, XID id)
 {
@@ -339,32 +336,11 @@ XineramaDeleteResource(pointer data, XID
     return 1;
 }
 
-
-static Bool 
-XineramaFindIDOnAnyScreen(pointer resource, XID id, pointer privdata)
-{
-    PanoramiXRes *res = (PanoramiXRes*)resource;
-    int j;
-
-    FOR_NSCREENS(j) 
-	if(res->info[j].id == *((XID*)privdata)) return TRUE;
-    
-    return FALSE;
-}
-
-PanoramiXRes *
-PanoramiXFindIDOnAnyScreen(RESTYPE type, XID id)
-{
-    return LookupClientResourceComplex(clients[CLIENT_ID(id)], type,
-		XineramaFindIDOnAnyScreen, &id);
-}
-
 typedef struct {
    int screen;
    int id;
 } PanoramiXSearchData; 
 
-
 static Bool 
 XineramaFindIDByScrnum(pointer resource, XID id, pointer privdata)
 {
@@ -389,23 +365,6 @@ PanoramiXFindIDByScrnum(RESTYPE type, XI
 		XineramaFindIDByScrnum, &data);
 }
 
-WindowPtr
-PanoramiXChangeWindow(int ScrnNum, WindowPtr pWin)
-{
-    int num = pWin->drawable.pScreen->myNum;
-
-    if(num != ScrnNum) {
-	PanoramiXRes	*win;
-
-	win = PanoramiXFindIDByScrnum(XRT_WINDOW, pWin->drawable.id, num);
-
-        if (win) 
-           pWin = (WindowPtr) LookupIDByType(win->info[ScrnNum].id, RT_WINDOW);
-    }
-  
-    return pWin;
-}
-
 typedef struct _connect_callback_list {
     void (*func)(void);
     struct _connect_callback_list *next;
@@ -496,7 +455,6 @@ void PanoramiXExtensionInit(int argc, ch
     if (noPanoramiXExtension) 
 	return;
 
-    GlobalScrInfo = &screenInfo;		/* For debug visibility */
     PanoramiXNumScreens = screenInfo.numScreens;
     if (PanoramiXNumScreens == 1) {		/* Only 1 screen 	*/
 	noPanoramiXExtension = TRUE;
diff --git a/Xext/panoramiX.h b/Xext/panoramiX.h
index 7b33392..3ad90fa 100644
--- a/Xext/panoramiX.h
+++ b/Xext/panoramiX.h
@@ -94,18 +94,6 @@ typedef struct {
     (a).root = WindowTable[0]->drawable.id;          \
 }
 
-#define FORCE_WIN(a) {                                  \
-    if ((win = PanoramiXFindIDOnAnyScreen(XRT_WINDOW, a))) { \
-        (a) = win->info[0].id; /* Real ID */       	   \
-    }                                                      \
-}
-
-#define FORCE_CMAP(a) {                                  \
-    if ((win = PanoramiXFindIDOnAnyScreen(XRT_COLORMAP, a))) { \
-        (a) = win->info[0].id; /* Real ID */       	   \
-    }                                                      \
-}
-
 #define IS_SHARED_PIXMAP(r) (((r)->type == XRT_PIXMAP) && (r)->u.pix.shared)
 
 #define SKIP_FAKE_WINDOW(a) if(!LookupIDByType(a, XRT_WINDOW)) return
diff --git a/Xext/panoramiXh.h b/Xext/panoramiXh.h
index 6cee650..1a76a45 100644
--- a/Xext/panoramiXh.h
+++ b/Xext/panoramiXh.h
@@ -19,10 +19,10 @@ extern int PanoramiXGetGeometry(ClientPt
 extern int PanoramiXTranslateCoords(ClientPtr client);	
 extern int PanoramiXCreatePixmap(ClientPtr client);
 extern int PanoramiXFreePixmap(ClientPtr client);
-extern int PanoramiXCreateGC(ClientPtr client);
 extern int PanoramiXChangeGC(ClientPtr client);
 extern int PanoramiXCopyGC(ClientPtr client);
 extern int PanoramiXCopyColormapAndFree(ClientPtr client);
+extern int PanoramiXCreateGC(ClientPtr client);
 extern int PanoramiXSetDashes(ClientPtr client);
 extern int PanoramiXSetClipRectangles(ClientPtr client);
 extern int PanoramiXFreeGC(ClientPtr client);
@@ -64,7 +64,6 @@ PROC_EXTERN(ProcPanoramiXGetScreenSize);
  
 PROC_EXTERN(ProcXineramaQueryScreens);
 PROC_EXTERN(ProcXineramaIsActive);
-extern Bool XineramaCreateGC(GCPtr pGC);
 
 extern int SProcPanoramiXDispatch(ClientPtr client);
 
@@ -72,6 +71,4 @@ extern char *ConnectionInfo;
 extern int connBlockScreenStart;
 extern xConnSetupPrefix connSetupPrefix;
 
-extern ScreenInfo *GlobalScrInfo;
 extern int (* SavedProcVector[256]) (ClientPtr client);
-
diff --git a/Xext/panoramiXsrv.h b/Xext/panoramiXsrv.h
index bb032cf..ae90244 100644
--- a/Xext/panoramiXsrv.h
+++ b/Xext/panoramiXsrv.h
@@ -12,14 +12,11 @@ extern int PanoramiXNumScreens;
 extern PanoramiXData *panoramiXdataPtr;
 extern int PanoramiXPixWidth;
 extern int PanoramiXPixHeight;
-extern RegionRec PanoramiXScreenRegion;
 extern XID *PanoramiXVisualTable;
 
 extern void PanoramiXConsolidate(void);
 extern Bool PanoramiXCreateConnectionBlock(void);
 extern PanoramiXRes * PanoramiXFindIDByScrnum(RESTYPE, XID, int);
-extern PanoramiXRes * PanoramiXFindIDOnAnyScreen(RESTYPE, XID);
-extern WindowPtr PanoramiXChangeWindow(int, WindowPtr);
 extern Bool XineramaRegisterConnectionBlockCallback(void (*func)(void));
 extern int XineramaDeleteResource(pointer, XID);
 
diff --git a/Xext/saver.c b/Xext/saver.c
index 7e3ebf4..a9f1dd3 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -66,7 +66,7 @@ static unsigned char ScreenSaverReqCode 
 #endif
 static int ScreenSaverEventBase = 0;
 
-extern DISPATCH_PROC(ProcScreenSaverQueryInfo);
+static DISPATCH_PROC(ProcScreenSaverQueryInfo);
 static DISPATCH_PROC(ProcScreenSaverDispatch);
 static DISPATCH_PROC(ProcScreenSaverQueryVersion);
 static DISPATCH_PROC(ProcScreenSaverSelectInput);
@@ -774,7 +774,7 @@ ProcScreenSaverQueryVersion (client)
     return (client->noClientException);
 }
 
-int
+static int
 ProcScreenSaverQueryInfo (client)
     register ClientPtr	client;
 {
diff --git a/Xext/security.c b/Xext/security.c
index 7202d39..c17a438 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -77,7 +77,7 @@ typedef struct {
 #define AUTHID(client) \
     (((SecurityClientStateRec*)STATEPTR(client))->authId)
 
-CallbackListPtr SecurityValidateGroupCallback = NULL;  /* see security.h */
+static CallbackListPtr SecurityValidateGroupCallback = NULL;
 
 RESTYPE SecurityAuthorizationResType; /* resource type for authorizations */
 
diff --git a/Xext/securitysrv.h b/Xext/securitysrv.h
index 7c6f432..67d864e 100644
--- a/Xext/securitysrv.h
+++ b/Xext/securitysrv.h
@@ -72,15 +72,6 @@ typedef struct {
     struct _OtherClients *eventClients; /* clients wanting events */
 } SecurityAuthorizationRec, *SecurityAuthorizationPtr;
 
-/* The following callback is called when a GenerateAuthorization request
- * is processed to sanity check the group argument.  The call data will
- * be a pointer to a SecurityValidateGroupInfoRec (below).  
- * Functions registered on this callback are expected to examine the
- * group and set the valid field to TRUE if they recognize the group as a
- * legitimate group.  If they don't recognize it, they should not change the
- * valid field.
- */
-extern CallbackListPtr SecurityValidateGroupCallback;
 typedef struct {
     XID group;	/* the group that was sent in GenerateAuthorization */
     Bool valid; /* did anyone recognize it? if so, set to TRUE */
diff --git a/Xext/xace.c b/Xext/xace.c
index 6fc5c12..6385631 100644
--- a/Xext/xace.c
+++ b/Xext/xace.c
@@ -37,10 +37,10 @@ CallbackListPtr XaceHooks[XACE_NUM_HOOKS
  * from guessing extension major opcodes and using the extension even though
  * the extension can't be listed or queried.
  */
-int (*UntrustedProcVector[256])(
+static int (*UntrustedProcVector[256])(
     ClientPtr /*client*/
 );
-int (*SwappedUntrustedProcVector[256])(
+static int (*SwappedUntrustedProcVector[256])(
     ClientPtr /*client*/
 );
 
diff --git a/Xext/xace.h b/Xext/xace.h
index 7231b04..4143cd4 100644
--- a/Xext/xace.h
+++ b/Xext/xace.h
@@ -82,16 +82,6 @@ extern int XaceHook(
 /* From the original Security extension...
  */
 
-/* Proc vectors for untrusted clients, swapped and unswapped versions.
- * These are the same as the normal proc vectors except that extensions
- * that haven't declared themselves secure will have ProcBadRequest plugged
- * in for their major opcode dispatcher.  This prevents untrusted clients
- * from guessing extension major opcodes and using the extension even though
- * the extension can't be listed or queried.
- */
-extern int (*UntrustedProcVector[256])(ClientPtr client);
-extern int (*SwappedUntrustedProcVector[256])(ClientPtr client);
-
 extern void XaceCensorImage(
     ClientPtr client,
     RegionPtr pVisibleRegion,
diff --git a/Xext/xevie.c b/Xext/xevie.c
index 2fd68f8..7922913 100644
--- a/Xext/xevie.c
+++ b/Xext/xevie.c
@@ -105,7 +105,7 @@ typedef struct {
 } xevieKeycQueueRec, *xevieKeycQueuePtr;
 
 #define KEYC_QUEUE_SIZE	    100
-xevieKeycQueueRec keycq[KEYC_QUEUE_SIZE] = {{0, NULL}};
+static xevieKeycQueueRec keycq[KEYC_QUEUE_SIZE] = {{0, NULL}};
 static int keycqHead = 0, keycqTail = 0;
 
 static int              ProcDispatch (ClientPtr), SProcDispatch (ClientPtr);
diff-tree af769892a91c9af59de53ca3bcd77fc4967daffb (from 62224e39727fd6f1cf11a461983662f615a9fea1)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sun Mar 25 17:56:32 2007 -0400

    Static and dead code cleanup from mi/

diff --git a/mi/mi.h b/mi/mi.h
index 53b5c44..c71c9b7 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -85,18 +85,6 @@ extern RegionPtr miCopyArea(
     int /*yOut*/
 );
 
-extern void miOpqStipDrawable(
-    DrawablePtr /*pDraw*/,
-    GCPtr /*pGC*/,
-    RegionPtr /*prgnSrc*/,
-    MiBits * /*pbits*/,
-    int /*srcx*/,
-    int /*w*/,
-    int /*h*/,
-    int /*dstx*/,
-    int /*dsty*/
-);
-
 extern RegionPtr miCopyPlane(
     DrawablePtr /*pSrcDrawable*/,
     DrawablePtr /*pDstDrawable*/,
@@ -144,15 +132,6 @@ extern void miRecolorCursor(
 
 /* midash.c */
 
-extern miDashPtr miDashLine(
-    int /*npt*/,
-    DDXPointPtr /*ppt*/,
-    unsigned int /*nDash*/,
-    unsigned char * /*pDash*/,
-    unsigned int /*offset*/,
-    int * /*pnseg*/
-);
-
 extern void miStepDash(
     int /*dist*/,
     int * /*pDashIndex*/,
@@ -326,16 +305,6 @@ extern void miPolySegment(
 
 /* mipolytext.c */
 
-extern int miPolyText(
-    DrawablePtr /*pDraw*/,
-    GCPtr /*pGC*/,
-    int /*x*/,
-    int /*y*/,
-    int /*count*/,
-    char * /*chars*/,
-    FontEncoding /*fontEncoding*/
-);
-
 extern int miPolyText8(
     DrawablePtr /*pDraw*/,
     GCPtr /*pGC*/,
@@ -354,16 +323,6 @@ extern int miPolyText16(
     unsigned short * /*chars*/
 );
 
-extern int miImageText(
-    DrawablePtr /*pDraw*/,
-    GCPtr /*pGC*/,
-    int /*x*/,
-    int /*y*/,
-    int /*count*/,
-    char * /*chars*/,
-    FontEncoding /*fontEncoding*/
-);
-
 extern void miImageText8(
     DrawablePtr /*pDraw*/,
     GCPtr /*pGC*/,
@@ -403,10 +362,6 @@ extern Bool miRectAlloc(
     int /*n*/
 );
 
-extern void miSetExtents(
-    RegionPtr /*pReg*/
-);
-
 extern int miFindMaxBand(
     RegionPtr /*prgn*/
 );
@@ -417,7 +372,6 @@ extern Bool miValidRegion(
 );
 #endif
 
-extern Bool miRegionDataCopy(RegionPtr dst, RegionPtr src);
 extern Bool miRegionBroken(RegionPtr pReg);
 
 /* miscrinit.c */
@@ -432,11 +386,6 @@ extern Bool miModifyPixmapHeader(
     pointer /*pPixData*/
 );
 
-extern Bool miCloseScreen(
-    int /*index*/,
-    ScreenPtr /*pScreen*/
-);
-
 extern Bool miCreateScreenResources(
     ScreenPtr /*pScreen*/
 );
diff --git a/mi/miarc.c b/mi/miarc.c
index 8b6d8c0..2bbbb0e 100644
--- a/mi/miarc.c
+++ b/mi/miarc.c
@@ -425,15 +425,8 @@ static unsigned long lrustamp;
 static arcCacheRec *lastCacheHit = &arcCache[0];
 static RESTYPE cacheType;
 
-/*
- * External so it can be called when low on memory.
- * Call with a zero ID in that case.
- */
-/*ARGSUSED*/
-int
-miFreeArcCache (data, id)
-    pointer data;
-    XID	    id;
+static int
+miFreeArcCache (pointer data, XID id)
 {
     int k;
     arcCacheRec *cent;
@@ -3136,8 +3129,8 @@ struct finalSpanChunk {
 
 static struct finalSpanChunk	*chunks;
 
-struct finalSpan *
-realAllocSpan ()
+static struct finalSpan *
+realAllocSpan (void)
 {
 	struct finalSpanChunk	*newChunk;
 	struct finalSpan	*span;
diff --git a/mi/mibitblt.c b/mi/mibitblt.c
index e4b1407..e61855a 100644
--- a/mi/mibitblt.c
+++ b/mi/mibitblt.c
@@ -400,13 +400,9 @@ miGetPlane(
  * Note how the clipped out bits of the bitmap are always the background
  * color so that the stipple never causes FillRect to draw them.
  */
-void
-miOpqStipDrawable(pDraw, pGC, prgnSrc, pbits, srcx, w, h, dstx, dsty)
-    DrawablePtr pDraw;
-    GCPtr	pGC;
-    RegionPtr	prgnSrc;
-    MiBits	*pbits;
-    int		srcx, w, h, dstx, dsty;
+static void
+miOpqStipDrawable(DrawablePtr pDraw, GCPtr pGC, RegionPtr prgnSrc,
+		  MiBits *pbits, int srcx, int w, int h, int dstx, int dsty)
 {
     int		oldfill, i;
     unsigned long oldfg;
diff --git a/mi/midash.c b/mi/midash.c
index 6dd161a..912fb03 100644
--- a/mi/midash.c
+++ b/mi/midash.c
@@ -54,196 +54,6 @@ SOFTWARE.
 
 static miDashPtr CheckDashStorage(miDashPtr *ppseg, int nseg, int *pnsegMax);
 
-/* return a list of DashRec.  there will be an extra
-entry at the end holding the last point of the polyline.
-   this means that the code that actually draws dashes can
-get a pair of points for every dash.  only the point in the last
-dash record is useful; the other fields are not used.
-   nseg is the number of segments, not the number of points.
-
-example:
-
-   dash1.start
-   dash2.start
-   dash3.start
-   last-point
-
-defines a list of segments
-   (dash1.pt, dash2.pt)
-   (dash2.pt, dash3.pt)
-   (dash3.pt, last-point)
-and nseg == 3.
-
-NOTE:
-    EVEN_DASH == ~ODD_DASH
-
-NOTE ALSO:
-    miDashLines may return 0 segments, going from pt[0] to pt[0] with one dash.
-*/
-
-miDashPtr
-miDashLine(npt, ppt, nDash, pDash, offset, pnseg)
-int npt;
-DDXPointPtr ppt;
-unsigned int nDash;
-unsigned char *pDash;
-unsigned int offset;
-int *pnseg;
-{
-    DDXPointRec pt1, pt2;
-    int lenCur;		/* npt used from this dash */
-    int lenMax;		/* npt in this dash */
-    int iDash = 0;	/* index of current dash */
-    int which;		/* EVEN_DASH or ODD_DASH */
-    miDashPtr pseg;	/* list of dash segments */
-    miDashPtr psegBase;	/* start of list */
-    int nseg = 0;	/* number of dashes so far */
-    int nsegMax = 0;	/* num segs we can fit in this list */
-
-    int x, y, len;
-    int adx, ady, signdx, signdy;
-    int du, dv, e1, e2, e, base_e = 0;
-
-    lenCur = offset;
-    which = EVEN_DASH;
-    while(lenCur >= pDash[iDash])
-    {
-	lenCur -= pDash[iDash];
-	iDash++;
-	if (iDash >= nDash)
-	    iDash = 0;
-	which = ~which;
-    }
-    lenMax = pDash[iDash];
-
-    psegBase = (miDashPtr)NULL;
-    pt2 = ppt[0];		/* just in case there is only one point */
-
-    while(--npt)
-    {
-	if (PtEqual(ppt[0], ppt[1]))
-	{
-	    ppt++;
-	    continue;		/* no duplicated points in polyline */
-	}
-	pt1 = *ppt++;
-	pt2 = *ppt;
-
-	adx = pt2.x - pt1.x;
-	ady = pt2.y - pt1.y;
-	signdx = sign(adx);
-	signdy = sign(ady);
-	adx = abs(adx);
-	ady = abs(ady);
-
-	if (adx > ady)
-	{
-	    du = adx;
-	    dv = ady;
-	    len = adx;
-	}
-	else
-	{
-	    du = ady;
-	    dv = adx;
-	    len = ady;
-	}
-
-	e1 = dv * 2;
-	e2 = e1 - 2*du;
-	e = e1 - du;
-	x = pt1.x;
-	y = pt1.y;
-
-	nseg++;
-	pseg = CheckDashStorage(&psegBase, nseg, &nsegMax);
-	if (!pseg)
-	    return (miDashPtr)NULL;
-	pseg->pt = pt1;
-	pseg->e1 = e1;
-	pseg->e2 = e2;
-	base_e = pseg->e = e;
-	pseg->which = which;
-	pseg->newLine = 1;
-
-	while (len--)
-	{
-	    if (adx > ady)
-	    {
-		/* X_AXIS */
-		if (((signdx > 0) && (e < 0)) ||
-		    ((signdx <=0) && (e <=0))
-		   )
-		{
-		    e += e1;
-		}
-		else
-		{
-		    y += signdy;
-		    e += e2;
-		}
-		x += signdx;
-	    }
-	    else
-	    {
-		/* Y_AXIS */
-		if (((signdx > 0) && (e < 0)) ||
-		    ((signdx <=0) && (e <=0))
-		   )
-		{
-		    e +=e1;
-		}
-		else
-		{
-		    x += signdx;
-		    e += e2;
-		}
-		y += signdy;
-	    }
-
-	    lenCur++;
-	    if (lenCur >= lenMax && (len || npt <= 1))
-	    {
-		nseg++;
-		pseg = CheckDashStorage(&psegBase, nseg, &nsegMax);
-		if (!pseg)
-		    return (miDashPtr)NULL;
-		pseg->pt.x = x;
-		pseg->pt.y = y;
-		pseg->e1 = e1;
-		pseg->e2 = e2;
-		pseg->e = e;
-		which = ~which;
-		pseg->which = which;
-		pseg->newLine = 0;
-
-		/* move on to next dash */
-		iDash++;
-		if (iDash >= nDash)
-		    iDash = 0;
-		lenMax = pDash[iDash];
-		lenCur = 0;
-	    }
-	} /* while len-- */
-    } /* while --npt */
-
-    if (lenCur == 0 && nseg != 0)
-    {
-	nseg--;
-	which = ~which;
-    }
-    *pnseg = nseg;
-    pseg = CheckDashStorage(&psegBase, nseg+1, &nsegMax);
-    if (!pseg)
-	return (miDashPtr)NULL;
-    pseg->pt = pt2;
-    pseg->e = base_e;
-    pseg->which = which;
-    pseg->newLine = 0;
-    return psegBase;
-} 
-
-
 #define NSEGDELTA 16
 
 /* returns a pointer to the pseg[nseg-1], growing the storage as
@@ -251,8 +61,7 @@ necessary.  this interface seems unneces
 
 */
 
-static
-miDashPtr
+static miDashPtr
 CheckDashStorage(
     miDashPtr *ppseg,		/* base pointer */
     int nseg,			/* number of segment we want to write to */
diff --git a/mi/mifillarc.c b/mi/mifillarc.c
index 46c0738..c561b1f 100644
--- a/mi/mifillarc.c
+++ b/mi/mifillarc.c
@@ -107,10 +107,8 @@ miFillArcSetup(arc, info)
     }
 }
 
-void
-miFillArcDSetup(arc, info)
-    xArc *arc;
-    miFillArcDRec *info;
+static void
+miFillArcDSetup(xArc *arc, miFillArcDRec *info)
 {
     /* h^2 * (2x - 2xorg)^2 = w^2 * h^2 - w^2 * (2y - 2yorg)^2 */
     /* even: xorg = yorg = 0   odd:  xorg = .5, yorg = -.5 */
@@ -188,15 +186,9 @@ miGetArcEdge(
     }
 }
 
-void
-miEllipseAngleToSlope (angle, width, height, dxp, dyp, d_dxp, d_dyp)
-    int	    angle;
-    int	    width;
-    int	    height;
-    int	    *dxp;
-    int	    *dyp;
-    double  *d_dxp;
-    double  *d_dyp;
+static void
+miEllipseAngleToSlope (int angle, int width, int height, int *dxp, int *dyp,
+		       double *d_dxp, double *d_dyp)
 {
     int	    dx, dy;
     double  d_dx, d_dy, scale;
diff --git a/mi/mifillarc.h b/mi/mifillarc.h
index 53f6f23..3e3bb98 100644
--- a/mi/mifillarc.h
+++ b/mi/mifillarc.h
@@ -176,35 +176,11 @@ typedef struct _miArcSlice {
 #define miFillInArcLower(slw) (((iny + dy) != 0) && \
 			       ((slw > 1) || (ine != inxk)))
 
-extern int miFreeArcCache(
-    pointer /*data*/,
-    XID /*id*/
-);
-
-extern struct finalSpan *realAllocSpan(
-    void
-);
-
 extern void miFillArcSetup(
     xArc * /*arc*/,
     miFillArcRec * /*info*/
 );
 
-extern void miFillArcDSetup(
-    xArc * /*arc*/,
-    miFillArcDRec * /*info*/
-);
-
-extern void miEllipseAngleToSlope(
-    int /*angle*/,
-    int /*width*/,
-    int /*height*/,
-    int * /*dxp*/,
-    int * /*dyp*/,
-    double * /*d_dxp*/,
-    double * /*d_dyp*/
-);
-
 extern void miFillArcSliceSetup(
     xArc * /*arc*/,
     miArcSliceRec * /*slice*/,
diff --git a/mi/mipointer.c b/mi/mipointer.c
index b94feaa..b86a26a 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -1,9 +1,4 @@
 /*
- * mipointer.c
- */
-
-
-/*
 
 Copyright 1989, 1998  The Open Group
 
@@ -409,6 +404,27 @@ miPointerAbsoluteCursor (int x, int y, u
     miPointerSetPosition(inputInfo.pointer, &x, &y, time);
 }
 
+/* Move the pointer on the current screen,  and update the sprite. */
+static void
+miPointerMoved (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y,
+                     unsigned long time)
+{
+    SetupScreen(pScreen);
+
+    if (pDev && (pDev->coreEvents || pDev == inputInfo.pointer) &&
+        !pScreenPriv->waitForUpdate && pScreen == miPointer.pSpriteScreen)
+    {
+	miPointer.devx = x;
+	miPointer.devy = y;
+	if(!miPointer.pCursor->bits->emptyMask)
+	    (*pScreenPriv->spriteFuncs->MoveCursor) (pScreen, x, y);
+    }
+
+    miPointer.x = x;
+    miPointer.y = y;
+    miPointer.pScreen = pScreen;
+}
+
 _X_EXPORT void
 miPointerSetPosition(DeviceIntPtr pDev, int *x, int *y, unsigned long time)
 {
@@ -499,24 +515,3 @@ miPointerMove (ScreenPtr pScreen, int x,
     for (i = 0; i < nevents; i++)
         mieqEnqueue(inputInfo.pointer, &events[i]);
 }
-
-/* Move the pointer on the current screen,  and update the sprite. */
-void
-miPointerMoved (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y,
-                     unsigned long time)
-{
-    SetupScreen(pScreen);
-
-    if (pDev && (pDev->coreEvents || pDev == inputInfo.pointer) &&
-        !pScreenPriv->waitForUpdate && pScreen == miPointer.pSpriteScreen)
-    {
-	miPointer.devx = x;
-	miPointer.devy = y;
-	if(!miPointer.pCursor->bits->emptyMask)
-	    (*pScreenPriv->spriteFuncs->MoveCursor) (pScreen, x, y);
-    }
-
-    miPointer.x = x;
-    miPointer.y = y;
-    miPointer.pScreen = pScreen;
-}
diff --git a/mi/mipointer.h b/mi/mipointer.h
index 30e8944..1bce42c 100644
--- a/mi/mipointer.h
+++ b/mi/mipointer.h
@@ -1,10 +1,4 @@
 /*
- * mipointer.h
- *
- */
-
-
-/*
 
 Copyright 1989, 1998  The Open Group
 
@@ -172,15 +166,6 @@ extern void miPointerSetPosition(
 extern void miPointerUpdateSprite(
     DeviceIntPtr pDev);
 
-/* Moves the sprite to x, y on the current screen, and updates the event
- * history. */
-extern void miPointerMoved(
-    DeviceIntPtr pDev,
-    ScreenPtr pScreen,
-    int x,
-    int y,
-    unsigned long time);
-
 extern int miPointerScreenIndex;
 
 #endif /* MIPOINTER_H */
diff --git a/mi/mipoly.h b/mi/mipoly.h
index 8e04f67..c1bab49 100644
--- a/mi/mipoly.h
+++ b/mi/mipoly.h
@@ -180,14 +180,6 @@ typedef struct _ScanLineListBlock {
 
 /* mipolyutil.c */
 
-extern Bool miInsertEdgeInET(
-    EdgeTable * /*ET*/,
-    EdgeTableEntry * /*ETE*/,
-    int /*scanline*/,
-    ScanLineListBlock ** /*SLLBlock*/,
-    int * /*iSLLBlock*/
-);
-
 extern Bool miCreateETandAET(
     int /*count*/,
     DDXPointPtr /*pts*/,
diff --git a/mi/mipolytext.c b/mi/mipolytext.c
index 6af02e0..82b16f7 100644
--- a/mi/mipolytext.c
+++ b/mi/mipolytext.c
@@ -66,30 +66,6 @@ SOFTWARE.
 #include	"dixfontstr.h"
 #include	"mi.h"
 
-int
-miPolyText(pDraw, pGC, x, y, count, chars, fontEncoding)
-    DrawablePtr pDraw;
-    GCPtr	pGC;
-    int		x, y;
-    int		count;
-    char 	*chars;
-    FontEncoding fontEncoding;
-{
-    unsigned long n, i;
-    int w;
-    CharInfoPtr charinfo[255];	/* encoding only has 1 byte for count */
-
-    GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
-	      fontEncoding, &n, charinfo);
-    w = 0;
-    for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
-    if (n != 0)
-        (*pGC->ops->PolyGlyphBlt)(
-	    pDraw, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font));
-    return x+w;
-}
-
-
 _X_EXPORT int
 miPolyText8(pDraw, pGC, x, y, count, chars)
     DrawablePtr pDraw;
@@ -112,7 +88,6 @@ miPolyText8(pDraw, pGC, x, y, count, cha
     return x+w;
 }
 
-
 _X_EXPORT int
 miPolyText16(pDraw, pGC, x, y, count, chars)
     DrawablePtr pDraw;
@@ -136,31 +111,6 @@ miPolyText16(pDraw, pGC, x, y, count, ch
     return x+w;
 }
 
-
-int
-miImageText(pDraw, pGC, x, y, count, chars, fontEncoding)
-    DrawablePtr pDraw;
-    GCPtr	pGC;
-    int 	x, y;
-    int 	count;
-    char 	*chars;
-    FontEncoding fontEncoding;
-{
-    unsigned long n, i;
-    FontPtr font = pGC->font;
-    int w;
-    CharInfoPtr charinfo[255];
-
-    GetGlyphs(font, (unsigned long)count, (unsigned char *)chars,
-	      fontEncoding, &n, charinfo);
-    w = 0;
-    for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
-    if (n !=0 )
-        (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, n, charinfo, FONTGLYPHS(font));
-    return x+w;
-}
-
-
 _X_EXPORT void
 miImageText8(pDraw, pGC, x, y, count, chars)
     DrawablePtr pDraw;
@@ -179,7 +129,6 @@ miImageText8(pDraw, pGC, x, y, count, ch
         (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, n, charinfo, FONTGLYPHS(font));
 }
 
-
 _X_EXPORT void
 miImageText16(pDraw, pGC, x, y, count, chars)
     DrawablePtr pDraw;
diff --git a/mi/mipolyutil.c b/mi/mipolyutil.c
index fe72e55..6ec860a 100644
--- a/mi/mipolyutil.c
+++ b/mi/mipolyutil.c
@@ -73,13 +73,9 @@ SOFTWARE.
  *     bucket.  Finally, we can insert it.
  *
  */
-Bool
-miInsertEdgeInET(ET, ETE, scanline, SLLBlock, iSLLBlock)
-    EdgeTable *ET;
-    EdgeTableEntry *ETE;
-    int scanline;
-    ScanLineListBlock **SLLBlock;
-    int *iSLLBlock;
+static Bool
+miInsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE,  int scanline,
+		 ScanLineListBlock **SLLBlock, int *iSLLBlock)
 {
     EdgeTableEntry *start, *prev;
     ScanLineList *pSLL, *pPrevSLL;
diff --git a/mi/miregion.c b/mi/miregion.c
index 5422099..e980ad1 100644
--- a/mi/miregion.c
+++ b/mi/miregion.c
@@ -221,7 +221,7 @@ _X_EXPORT BoxRec miEmptyBox = {0, 0, 0, 
 _X_EXPORT RegDataRec miEmptyData = {0, 0};
 
 RegDataRec  miBrokenData = {0, 0};
-RegionRec   miBrokenRegion = { { 0, 0, 0, 0 }, &miBrokenData };
+static RegionRec   miBrokenRegion = { { 0, 0, 0, 0 }, &miBrokenData };
 
 _X_EXPORT void
 miPrintRegion(rgn)
@@ -913,7 +913,7 @@ miRegionOp(
  *
  *-----------------------------------------------------------------------
  */
-void
+static void
 miSetExtents (pReg)
     RegionPtr pReg;
 {
@@ -2182,35 +2182,6 @@ miTranslateRegion(pReg, x, y)
     }
 }
 
-Bool
-miRegionDataCopy(
-    RegionPtr dst,
-    RegionPtr src)
-{
-    good(dst);
-    good(src);
-    if (dst->data) 
-	return TRUE;
-    if (dst == src)
-	return TRUE;
-    if (!src->data || !src->data->size)
-    {
-	xfreeData(dst);
-	dst->data = (RegDataPtr)NULL;
-	return TRUE;
-    }
-    if (!dst->data || (dst->data->size < src->data->numRects))
-    {
-	xfreeData(dst);
-	dst->data = xallocData(src->data->numRects);
-	if (!dst->data)
-	    return miRegionBreak (dst);
-    }
-    dst->data->size = src->data->size;
-    dst->data->numRects = src->data->numRects;
-    return TRUE;
-}
-
 _X_EXPORT void
 miRegionReset(pReg, pBox)
     RegionPtr pReg;
diff --git a/mi/miscrinit.c b/mi/miscrinit.c
index 08cc3f6..cc40cbe 100644
--- a/mi/miscrinit.c
+++ b/mi/miscrinit.c
@@ -126,12 +126,8 @@ miModifyPixmapHeader(pPixmap, width, hei
     return TRUE;
 }
 
-
-/*ARGSUSED*/
-Bool
-miCloseScreen (iScreen, pScreen)
-    int		iScreen;
-    ScreenPtr	pScreen;
+static Bool
+miCloseScreen (int iScreen, ScreenPtr pScreen)
 {
     return ((*pScreen->DestroyPixmap)((PixmapPtr)pScreen->devPrivate));
 }
diff --git a/mi/mispans.c b/mi/mispans.c
index 61d72e4..530d9df 100644
--- a/mi/mispans.c
+++ b/mi/mispans.c
@@ -78,9 +78,7 @@ void miInitSpanGroup(spanGroup)
 #define YMIN(spans) (spans->points[0].y)
 #define YMAX(spans)  (spans->points[spans->count-1].y)
 
-void miSubtractSpans (spanGroup, sub)
-    SpanGroup	*spanGroup;
-    Spans	*sub;
+static void miSubtractSpans (SpanGroup *spanGroup, Spans *sub)
 {
     int		i, subCount, spansCount;
     int		ymin, ymax, xmin, xmax;
@@ -364,9 +362,8 @@ static int UniquifySpansX(
     return (newWidths - startNewWidths) + 1;
 } /* UniquifySpansX */
 
-void
-miDisposeSpanGroup (spanGroup)
-    SpanGroup	*spanGroup;
+static void
+miDisposeSpanGroup (SpanGroup *spanGroup)
 {
     int	    i;
     Spans   *spans;
@@ -538,24 +535,3 @@ void miFillUniqueSpanGroup(pDraw, pGC, s
     spanGroup->ymin = MAXSHORT;
     spanGroup->ymax = MINSHORT;
 }
-
-
-void miFillSpanGroup(pDraw, pGC, spanGroup)
-    DrawablePtr pDraw;
-    GCPtr	pGC;
-    SpanGroup   *spanGroup;
-{
-    int    i;
-    Spans  *spans;
-
-    for (i = 0, spans = spanGroup->group; i != spanGroup->count; i++, spans++) {
-	(*pGC->ops->FillSpans)
-	    (pDraw, pGC, spans->count, spans->points, spans->widths, TRUE);
-	xfree(spans->points);
-	xfree(spans->widths);
-    }
-
-    spanGroup->count = 0;
-    spanGroup->ymin = MAXSHORT;
-    spanGroup->ymax = MINSHORT;
-} /* FillSpanGroup */
diff --git a/mi/mispans.h b/mi/mispans.h
index 5b141af..258b292 100644
--- a/mi/mispans.h
+++ b/mi/mispans.h
@@ -71,13 +71,6 @@ extern void miAppendSpans(
     Spans * /*spans*/
 );
 
-/* Paint a span group, possibly with some overlap */
-extern void miFillSpanGroup(
-    DrawablePtr /*pDraw*/,
-    GCPtr /*pGC*/,
-    SpanGroup * /*spanGroup*/
-);
-
 /* Paint a span group, insuring that each pixel is painted at most once */
 extern void miFillUniqueSpanGroup(
     DrawablePtr /*pDraw*/,
@@ -90,15 +83,6 @@ extern void miFreeSpanGroup(
     SpanGroup * /*spanGroup*/
 );
 
-extern void miSubtractSpans(
-    SpanGroup * /*spanGroup*/,
-    Spans * /*sub*/
-);
-
-extern void miDisposeSpanGroup(
-    SpanGroup * /*spanGroup*/
-);
-
 extern int miClipSpans(
     RegionPtr /*prgnDst*/,
     DDXPointPtr /*ppt*/,
diff --git a/mi/miwideline.c b/mi/miwideline.c
index 7f99aca..08e4aa3 100644
--- a/mi/miwideline.c
+++ b/mi/miwideline.c
@@ -67,17 +67,11 @@ static void miLineArc(DrawablePtr pDraw,
  * spans-based polygon filler
  */
 
-void
-miFillPolyHelper (pDrawable, pGC, pixel, spanData, y, overall_height,
-		  left, right, left_count, right_count)
-    DrawablePtr	pDrawable;
-    GCPtr	pGC;
-    unsigned long   pixel;
-    SpanDataPtr	spanData;
-    int		y;			/* start y coordinate */
-    int		overall_height;		/* height of entire segment */
-    PolyEdgePtr	left, right;
-    int		left_count, right_count;
+static void
+miFillPolyHelper (DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel,
+		  SpanDataPtr spanData, int y, int overall_height,
+		  PolyEdgePtr left, PolyEdgePtr right,
+		  int left_count, int right_count)
 {
     int left_x = 0, left_e = 0;
     int	left_stepx = 0;
@@ -873,11 +867,8 @@ miLineArcD (
     return (pts - points);
 }
 
-int
-miRoundJoinFace (face, edge, leftEdge)
-    LineFacePtr face;
-    PolyEdgePtr edge;
-    Bool	*leftEdge;
+static int
+miRoundJoinFace (LineFacePtr face, PolyEdgePtr edge, Bool *leftEdge)
 {
     int	    y;
     int	    dx, dy;
@@ -1114,16 +1105,10 @@ miLineArc (
     }
 }
 
-void
-miLineProjectingCap (pDrawable, pGC, pixel, spanData, face, isLeft, xorg, yorg, isInt)
-    DrawablePtr		pDrawable;
-    GCPtr  		pGC;
-    unsigned long	pixel;
-    SpanDataPtr		spanData;
-    LineFacePtr 	face;
-    Bool	    	isLeft;
-    double	    	xorg, yorg;
-    Bool	    	isInt;
+static void
+miLineProjectingCap (DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel,
+		     SpanDataPtr spanData, LineFacePtr face, Bool isLeft,
+		     double xorg, double yorg, Bool isInt)
 {
     int	xorgi = 0, yorgi = 0;
     int	lw;
@@ -1506,11 +1491,8 @@ miWideSegment (
     }
 }
 
-SpanDataPtr
-miSetupSpanData (pGC, spanData, npt)
-    GCPtr pGC;
-    SpanDataPtr	spanData;
-    int		npt;
+static SpanDataPtr
+miSetupSpanData (GCPtr pGC, SpanDataPtr spanData, int npt)
 {
     if ((npt < 3 && pGC->capStyle != CapRound) || miSpansEasyRop(pGC->alu))
 	return (SpanDataPtr) NULL;
@@ -1520,11 +1502,8 @@ miSetupSpanData (pGC, spanData, npt)
     return spanData;
 }
 
-void
-miCleanupSpanData (pDrawable, pGC, spanData)
-    DrawablePtr	pDrawable;
-    GCPtr	pGC;
-    SpanDataPtr	spanData;
+static void
+miCleanupSpanData (DrawablePtr pDrawable, GCPtr pGC, SpanDataPtr spanData)
 {
     if (pGC->lineStyle == LineDoubleDash)
     {
diff --git a/mi/miwideline.h b/mi/miwideline.h
index 8cfa630..9d1aa03 100644
--- a/mi/miwideline.h
+++ b/mi/miwideline.h
@@ -153,24 +153,6 @@ typedef struct _LineFace {
     } \
 }
 
-extern void miFillPolyHelper(
-    DrawablePtr /*pDrawable*/,
-    GCPtr /*pGC*/,
-    unsigned long /*pixel*/,
-    SpanDataPtr /*spanData*/,
-    int /*y*/,
-    int /*overall_height*/,
-    PolyEdgePtr /*left*/,
-    PolyEdgePtr /*right*/,
-    int /*left_count*/,
-    int /*right_count*/
-);
-extern int miRoundJoinFace(
-    LineFacePtr /*face*/,
-    PolyEdgePtr /*edge*/,
-    Bool * /*leftEdge*/
-);
-
 extern void miRoundJoinClip(
     LineFacePtr /*pLeft*/,
     LineFacePtr /*pRight*/,
@@ -189,30 +171,6 @@ extern int miRoundCapClip(
     Bool * /*leftEdge*/
 );
 
-extern void miLineProjectingCap(
-    DrawablePtr /*pDrawable*/,
-    GCPtr /*pGC*/,
-    unsigned long /*pixel*/,
-    SpanDataPtr /*spanData*/,
-    LineFacePtr /*face*/,
-    Bool /*isLeft*/,
-    double /*xorg*/,
-    double /*yorg*/,
-    Bool /*isInt*/
-);
-
-extern SpanDataPtr miSetupSpanData(
-    GCPtr /*pGC*/,
-    SpanDataPtr /*spanData*/,
-    int /*npt*/
-);
-
-extern void miCleanupSpanData(
-    DrawablePtr /*pDrawable*/,
-    GCPtr /*pGC*/,
-    SpanDataPtr /*spanData*/
-);
-
 extern int miPolyBuildEdge(double x0, double y0, double k, int dx, int dy,
 				int xi, int yi, int left, PolyEdgePtr edge);
 extern int miPolyBuildPoly(PolyVertexPtr vertices, PolySlopePtr slopes,
diff --git a/mi/mizerarc.c b/mi/mizerarc.c
index f1adc9e..9d4715a 100644
--- a/mi/mizerarc.c
+++ b/mi/mizerarc.c
@@ -401,10 +401,8 @@ miZeroArcSetup(arc, info, ok360)
 
 #define DoPix(idx,xval,yval) if (mask & (1 << idx)) Pixelate(xval, yval);
 
-DDXPointPtr
-miZeroArcPts(arc, pts)
-    xArc *arc;
-    DDXPointPtr pts;
+static DDXPointPtr
+miZeroArcPts(xArc *arc, DDXPointPtr pts)
 {
     miZeroArcRec info;
     int x, y, a, b, d, mask;
diff --git a/mi/mizerarc.h b/mi/mizerarc.h
index 8119d88..28ebbe0 100644
--- a/mi/mizerarc.h
+++ b/mi/mizerarc.h
@@ -124,9 +124,3 @@ extern Bool miZeroArcSetup(
     miZeroArcRec * /*info*/,
     Bool /*ok360*/
 );
-
-extern DDXPointPtr miZeroArcPts(
-    xArc * /*arc*/,
-    DDXPointPtr /*pts*/
-);
-
diff-tree 62224e39727fd6f1cf11a461983662f615a9fea1 (from e8bc1988d9ff10b65717574175f70df3c4d6334d)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sun Mar 25 17:55:15 2007 -0400

    Static cleanup for xf86 ddx.

diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index e1cbdbb..9740b07 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -1791,6 +1791,15 @@ convertRange2Host(int entityIndex, resRa
     }
 }
 
+static void
+xf86ConvertListToHost(int entityIndex, resPtr list)
+{
+    while (list) {
+	convertRange2Host(entityIndex, &list->val);
+	list = list->next;
+    }
+}
+
 /*
  * xf86RegisterResources() -- attempts to register listed resources.
  * If list is NULL it tries to obtain resources implicitly. Function
@@ -2836,17 +2845,6 @@ xf86IsSubsetOf(resRange range, resPtr li
     return ret;
 }
 
-Bool
-xf86IsListSubsetOf(resPtr list, resPtr BaseList)
-{
-    while (list) {
-	if (! xf86IsSubsetOf(list->val,BaseList))
-	    return FALSE;
-	list = list->next;
-    }
-    return TRUE;
-}
-
 static resPtr
 findIntersect(resRange Range, resPtr list)
 {
@@ -3071,15 +3069,6 @@ xf86NoSharedResources(int screenIndex,re
     return TRUE;
 }
 
-void
-xf86ConvertListToHost(int entityIndex, resPtr list)
-{
-    while (list) {
-	convertRange2Host(entityIndex, &list->val);
-	list = list->next;
-    }
-}
-
 _X_EXPORT void
 xf86RegisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func, pointer arg)
 {
diff --git a/hw/xfree86/common/xf86Bus.h b/hw/xfree86/common/xf86Bus.h
index 225a5c7..8d71959 100644
--- a/hw/xfree86/common/xf86Bus.h
+++ b/hw/xfree86/common/xf86Bus.h
@@ -141,11 +141,9 @@ int xf86AllocateEntity(void);
 BusType StringToBusType(const char* busID, const char **retID);
 memType ChkConflict(resRange *rgp, resPtr res, xf86State state);
 Bool xf86IsSubsetOf(resRange range, resPtr list);
-Bool xf86IsListSubsetOf(resPtr list, resPtr BaseList);
 resPtr xf86ExtractTypeFromList(resPtr list, unsigned long type);
 resPtr xf86FindIntersect(resRange Range, resPtr list);
 void RemoveOverlaps(resPtr target, resPtr list, Bool pow2Alignment,
 		    Bool useEstimated);
-void xf86ConvertListToHost(int entityIndex, resPtr list);
 
 #endif /* _XF86_BUS_H */
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 1bd3c62..4db844e 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -538,25 +538,6 @@ xf86DriverlistFromCompile(void)
     return driverlist;
 }
 
-
-char **
-xf86InputDriverlistFromCompile(void)
-{
-    static char **driverlist = NULL;
-    static Bool generated = FALSE;
-
-    /* This string is modified in-place */
-    static char drivernames[] = IDRIVERS;
-
-    if (!generated) {
-        generated = TRUE;
-	driverlist = GenerateDriverlist("input", drivernames);
-    }
-
-    return driverlist;
-}
-
-
 /*
  * xf86ConfigError --
  *      Print a READABLE ErrorMessage!!!  All information that is 
@@ -2504,17 +2485,8 @@ xf86HandleConfigFile(Bool autoconfig)
     return CONFIG_OK;
 }
 
-
-/* These make the equivalent parser functions visible to the common layer. */
-Bool
-xf86PathIsAbsolute(const char *path)
-{
-    return (xf86pathIsAbsolute(path) != 0);
-}
-
 Bool
 xf86PathIsSafe(const char *path)
 {
     return (xf86pathIsSafe(path) != 0);
 }
-
diff --git a/hw/xfree86/common/xf86Config.h b/hw/xfree86/common/xf86Config.h
index 0786ec6..3787ba2 100644
--- a/hw/xfree86/common/xf86Config.h
+++ b/hw/xfree86/common/xf86Config.h
@@ -53,7 +53,6 @@ char ** xf86ModulelistFromConfig(pointer
 char ** xf86DriverlistFromConfig(void);
 char ** xf86DriverlistFromCompile(void);
 char ** xf86InputDriverlistFromConfig(void);
-char ** xf86InputDriverlistFromCompile(void);
 Bool xf86BuiltinInputDriver(const char *);
 ConfigStatus xf86HandleConfigFile(Bool);
 
diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
index 9b23710..b41fe6e 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -146,7 +146,6 @@ _X_EXPORT confDRIRec xf86ConfigDRI = {0,
 XF86ConfigPtr xf86configptr = NULL;
 Bool xf86Resetting = FALSE;
 Bool xf86Initialising = FALSE;
-Bool xf86ProbeFailed = FALSE;
 Bool xf86DoProbe = FALSE;
 Bool xf86DoConfigure = FALSE;
 DriverPtr *xf86DriverList = NULL;
diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index 9279dbd..59ce8da 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -100,7 +100,6 @@ extern int xf86NumModuleInfos;
 extern int xf86NumDrivers;
 extern Bool xf86Resetting;
 extern Bool xf86Initialising;
-extern Bool xf86ProbeFailed;
 extern int xf86NumScreens;
 extern pciVideoPtr *xf86PciVideoInfo;
 extern xf86CurrentAccessRec xf86CurrentAccess;
@@ -155,7 +154,6 @@ extern int pciTestMultiDeviceCard(int bu
 
 /* xf86Config.c */
 
-Bool xf86PathIsAbsolute(const char *path);
 Bool xf86PathIsSafe(const char *path);
 
 /* xf86DefaultModes */
diff --git a/hw/xfree86/os-support/shared/libc_wrapper.c b/hw/xfree86/os-support/shared/libc_wrapper.c
index 4c4af4c..a459d5d 100644
--- a/hw/xfree86/os-support/shared/libc_wrapper.c
+++ b/hw/xfree86/os-support/shared/libc_wrapper.c
@@ -628,7 +628,7 @@ typedef struct _xf86_file_ {
 	char*	fname;
 } XF86FILE_priv;
 
-XF86FILE_priv stdhnd[3] = {
+static XF86FILE_priv stdhnd[3] = {
 	{ 0, XF86FILE_magic, NULL, "$stdinp$" },
 	{ 0, XF86FILE_magic, NULL, "$stdout$" },
 	{ 0, XF86FILE_magic, NULL, "$stderr$" }
diff --git a/hw/xfree86/parser/Screen.c b/hw/xfree86/parser/Screen.c
index b7a64b0..79e1d24 100644
--- a/hw/xfree86/parser/Screen.c
+++ b/hw/xfree86/parser/Screen.c
@@ -83,7 +83,7 @@ static xf86ConfigSymTabRec DisplayTab[] 
 
 #define CLEANUP xf86freeDisplayList
 
-XF86ConfDisplayPtr
+static XF86ConfDisplayPtr
 xf86parseDisplaySubSection (void)
 {
 	int token;
diff --git a/hw/xfree86/parser/Vendor.c b/hw/xfree86/parser/Vendor.c
index 3e9358b..d1e6080 100644
--- a/hw/xfree86/parser/Vendor.c
+++ b/hw/xfree86/parser/Vendor.c
@@ -75,7 +75,7 @@ static xf86ConfigSymTabRec VendorSubTab[
 
 #define CLEANUP xf86freeVendorSubList
 
-XF86ConfVendSubPtr
+static XF86ConfVendSubPtr
 xf86parseVendorSubSection (void)
 {
 	int has_ident = FALSE;
@@ -242,16 +242,3 @@ xf86freeVendorSubList (XF86ConfVendSubPt
 		xf86conffree (prev);
 	}
 }
-
-XF86ConfVendorPtr
-xf86findVendor (const char *name, XF86ConfVendorPtr list)
-{
-	while (list)
-	{
-		if (xf86nameCompare (list->vnd_identifier, name) == 0)
-			return (list);
-		list = list->list.next;
-	}
-	return (NULL);
-}
-
diff --git a/hw/xfree86/parser/Video.c b/hw/xfree86/parser/Video.c
index fa0ff78..a8912cf 100644
--- a/hw/xfree86/parser/Video.c
+++ b/hw/xfree86/parser/Video.c
@@ -74,7 +74,23 @@ static xf86ConfigSymTabRec VideoPortTab[
 
 #define CLEANUP xf86freeVideoPortList
 
-XF86ConfVideoPortPtr
+static void
+xf86freeVideoPortList (XF86ConfVideoPortPtr ptr)
+{
+	XF86ConfVideoPortPtr prev;
+
+	while (ptr)
+	{
+		TestFree (ptr->vp_identifier);
+		TestFree (ptr->vp_comment);
+		xf86optionListFree (ptr->vp_option_lst);
+		prev = ptr;
+		ptr = ptr->list.next;
+		xf86conffree (prev);
+	}
+}
+
+static XF86ConfVideoPortPtr
 xf86parseVideoPortSubSection (void)
 {
 	int has_ident = FALSE;
@@ -266,22 +282,6 @@ xf86freeVideoAdaptorList (XF86ConfVideoA
 	}
 }
 
-void
-xf86freeVideoPortList (XF86ConfVideoPortPtr ptr)
-{
-	XF86ConfVideoPortPtr prev;
-
-	while (ptr)
-	{
-		TestFree (ptr->vp_identifier);
-		TestFree (ptr->vp_comment);
-		xf86optionListFree (ptr->vp_option_lst);
-		prev = ptr;
-		ptr = ptr->list.next;
-		xf86conffree (prev);
-	}
-}
-
 XF86ConfVideoAdaptorPtr
 xf86findVideoAdaptor (const char *ident, XF86ConfVideoAdaptorPtr p)
 {
diff --git a/hw/xfree86/parser/configProcs.h b/hw/xfree86/parser/configProcs.h
index e3961a9..3c9ce7a 100644
--- a/hw/xfree86/parser/configProcs.h
+++ b/hw/xfree86/parser/configProcs.h
@@ -66,7 +66,6 @@ int xf86validateMonitor(XF86ConfigPtr p,
 /* Pointer.c */
 XF86ConfInputPtr xf86parsePointerSection(void);
 /* Screen.c */
-XF86ConfDisplayPtr xf86parseDisplaySubSection(void);
 XF86ConfScreenPtr xf86parseScreenSection(void);
 void xf86printScreenSection(FILE *cf, XF86ConfScreenPtr ptr);
 void xf86freeScreenList(XF86ConfScreenPtr ptr);
@@ -76,16 +75,13 @@ void xf86freeModeList(XF86ModePtr ptr);
 int xf86validateScreen(XF86ConfigPtr p);
 /* Vendor.c */
 XF86ConfVendorPtr xf86parseVendorSection(void);
-XF86ConfVendSubPtr xf86parseVendorSubSection (void);
 void xf86freeVendorList(XF86ConfVendorPtr p);
 void xf86printVendorSection(FILE * cf, XF86ConfVendorPtr ptr);
 void xf86freeVendorSubList (XF86ConfVendSubPtr ptr);
 /* Video.c */
-XF86ConfVideoPortPtr xf86parseVideoPortSubSection(void);
 XF86ConfVideoAdaptorPtr xf86parseVideoAdaptorSection(void);
 void xf86printVideoAdaptorSection(FILE *cf, XF86ConfVideoAdaptorPtr ptr);
 void xf86freeVideoAdaptorList(XF86ConfVideoAdaptorPtr ptr);
-void xf86freeVideoPortList(XF86ConfVideoPortPtr ptr);
 /* scan.c */
 int xf86getToken(xf86ConfigSymTabRec *tab);
 int xf86getSubToken(char **comment);
diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h
index a682927..89de97b 100644
--- a/hw/xfree86/parser/xf86Parser.h
+++ b/hw/xfree86/parser/xf86Parser.h
@@ -469,7 +469,6 @@ XF86ConfModeLinePtr xf86findModeLine(con
 XF86ConfScreenPtr xf86findScreen(const char *ident, XF86ConfScreenPtr p);
 XF86ConfInputPtr xf86findInput(const char *ident, XF86ConfInputPtr p);
 XF86ConfInputPtr xf86findInputByDriver(const char *driver, XF86ConfInputPtr p);
-XF86ConfVendorPtr xf86findVendor(const char *name, XF86ConfVendorPtr list);
 XF86ConfVideoAdaptorPtr xf86findVideoAdaptor(const char *ident,
 						XF86ConfVideoAdaptorPtr p);
 
diff-tree e8bc1988d9ff10b65717574175f70df3c4d6334d (from 70e493d223b1e943e652191150bd0b7e1a6ebcfb)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sun Mar 25 15:13:05 2007 -0400

    Un-staticise VTSwitchEnabled, since kbd wants it apparently.

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index eae6cb1..3610c17 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -128,7 +128,7 @@ extern Bool noXkbExtension;
 #ifdef USE_VT_SYSREQ
 static Bool VTSysreqToggle = FALSE;
 #endif /* !USE_VT_SYSREQ */
-static Bool VTSwitchEnabled = TRUE;	/* Allows run-time disabling for
+_X_EXPORT Bool VTSwitchEnabled = TRUE;	/* Allows run-time disabling for
                                          *BSD and for avoiding VT
                                          switches when using the DRI
                                          automatic full screen mode.*/
diff-tree 70e493d223b1e943e652191150bd0b7e1a6ebcfb (from f36bf1a3e4ce9465ea4a6159c209924a3cafbe58)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sun Mar 25 14:55:28 2007 -0400

    Static and dead code cleanup over afb/

diff --git a/afb/afb.h b/afb/afb.h
index c05cc55..5aa2b0c 100644
--- a/afb/afb.h
+++ b/afb/afb.h
@@ -78,27 +78,6 @@ extern void afbDoBitblt(
 	unsigned long /*planemask*/
 );
 
-extern RegionPtr afbBitBlt(
-	DrawablePtr /*pSrc*/,
-	DrawablePtr /*pDst*/,
-	GCPtr /*pGC*/,
-	int /*srcx*/,
-	int /*srcy*/,
-	int /*width*/,
-	int /*height*/,
-	int /*dstx*/,
-	int /*dsty*/,
-	void (*doBitBlt)(
-		DrawablePtr /*pSrc*/,
-		DrawablePtr /*pDst*/,
-		int /*alu*/,
-		RegionPtr /*prgnDst*/,
-		DDXPointPtr /*pptSrc*/,
-		unsigned long /*planemask*/
-        ),
-	unsigned long /*planemask*/
-);
-
 extern RegionPtr afbCopyArea(
 	DrawablePtr /*pSrcDrawable*/,
 	DrawablePtr /*pDstDrawable*/,
@@ -111,27 +90,6 @@ extern RegionPtr afbCopyArea(
 	int /*dsty*/
 );
 
-extern RegionPtr afbCopyPlane(
-	DrawablePtr /*pSrcDrawable*/,
-	DrawablePtr /*pDstDrawable*/,
-	GCPtr/*pGC*/,
-	int /*srcx*/,
-	int /*srcy*/,
-	int /*width*/,
-	int /*height*/,
-	int /*dstx*/,
-	int /*dsty*/,
-	unsigned long /*plane*/
-);
-
-extern void afbCopy1ToN(
-	DrawablePtr /*pSrc*/,
-	DrawablePtr /*pDst*/,
-	int /*alu*/,
-	RegionPtr /*prgnDst*/,
-	DDXPointPtr /*pptSrc*/,
-	unsigned long /*planemask*/
-);
 /* afbbltC.c */
 
 extern void afbDoBitbltCopy(
@@ -273,23 +231,6 @@ extern Bool afbInitializeColormap(
 	ColormapPtr /*pmap*/
 );
 
-extern int afbExpandDirectColors(
-	ColormapPtr /*pmap*/,
-	int /*ndefs*/,
-	xColorItem * /*indefs*/,
-	xColorItem * /*outdefs*/
-);
-
-extern Bool afbCreateDefColormap(
-	ScreenPtr /*pScreen*/
-);
-
-extern Bool afbSetVisualTypes(
-	int /*depth*/,
-	int /*visuals*/,
-	int /*bitsPerRGB*/
-);
-
 extern Bool afbInitVisuals(
 	VisualPtr * /*visualp*/,
 	DepthPtr * /*depthp*/,
@@ -410,16 +351,6 @@ extern Bool afbCreateGC(
 	GCPtr /*pGC*/
 );
 
-extern void afbValidateGC(
-	GCPtr /*pGC*/,
-	unsigned long /*changes*/,
-	DrawablePtr /*pDrawable*/
-);
-
-extern void afbDestroyGC(
-	GCPtr /*pGC*/
-);
-
 extern void afbReduceRop(
 	int /*alu*/,
 	Pixel /*src*/,
@@ -428,19 +359,6 @@ extern void afbReduceRop(
 	unsigned char * /*rrops*/
 );
 
-extern void afbReduceOpaqueStipple (
-	Pixel /*fg*/,
-	Pixel /*bg*/,
-	unsigned long /*planemask*/,
-	int /*depth*/,
-	unsigned char * /*rrops*/
-);
-
-extern void afbComputeCompositeClip(
-   GCPtr /*pGC*/,
-   DrawablePtr /*pDrawable*/
-);
-
 /* afbgetsp.c */
 
 extern void afbGetSpans(
@@ -588,14 +506,6 @@ extern Bool afbDestroyPixmap(
 	PixmapPtr /*pPixmap*/
 );
 
-extern PixmapPtr afbCopyPixmap(
-	PixmapPtr /*pSrc*/
-);
-
-extern void afbPadPixmap(
-	PixmapPtr /*pPixmap*/
-);
-
 extern void afbXRotatePixmap(
 	PixmapPtr /*pPix*/,
 	int /*rw*/
@@ -637,20 +547,9 @@ extern void afbPushPixels(
 	int /*xOrg*/,
 	int /*yOrg*/
 );
-/* afbscrclse.c */
 
-extern Bool afbCloseScreen(
-	int /*index*/,
-	ScreenPtr /*pScreen*/
-);
 /* afbscrinit.c */
 
-extern Bool afbAllocatePrivates(
-	ScreenPtr /*pScreen*/,
-	int * /*pWinIndex*/,
-	int * /*pGCIndex*/
-);
-
 extern Bool afbScreenInit(
 	ScreenPtr /*pScreen*/,
 	pointer /*pbits*/,
@@ -661,15 +560,6 @@ extern Bool afbScreenInit(
 	int /*width*/
 );
 
-extern PixmapPtr afbGetWindowPixmap(
-	WindowPtr /*pWin*/
-);
-
-extern void afbSetWindowPixmap(
-	WindowPtr /*pWin*/,
-	PixmapPtr /*pPix*/
-);
-
 /* afbseg.c */
 
 extern void afbSegmentSS(
@@ -687,20 +577,6 @@ extern void afbSegmentSD(
 );
 /* afbsetsp.c */
 
-extern void afbSetScanline(
-	int /*y*/,
-	int /*xOrigin*/,
-	int /*xStart*/,
-	int /*xEnd*/,
-	PixelType * /*psrc*/,
-	int /*alu*/,
-	PixelType * /*pdstBase*/,
-	int /*widthDst*/,
-	int /*sizeDst*/,
-	int /*depthDst*/,
-	int /*sizeSrc*/
-);
-
 extern void afbSetSpans(
 	DrawablePtr /*pDrawable*/,
 	GCPtr /*pGC*/,
diff --git a/afb/afbbitblt.c b/afb/afbbitblt.c
index 594e987..2e416e3 100644
--- a/afb/afbbitblt.c
+++ b/afb/afbbitblt.c
@@ -67,9 +67,6 @@ SOFTWARE.
 #include "afb.h"
 #include "maskbits.h"
 
-
-static unsigned char afbRropsOS[AFB_MAX_DEPTH];
-
 /* CopyArea and CopyPlane for a monchrome frame buffer
 
 
@@ -126,34 +123,7 @@ afbDoBitblt(DrawablePtr pSrc, DrawablePt
 typedef void (*afb_blit_func)
     (DrawablePtr, DrawablePtr, int, RegionPtr, DDXPointPtr, unsigned long);
 
-RegionPtr
-afbCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GC *pGC, int srcx, int srcy, int width, int height, int dstx, int dsty)
-{
-	afb_blit_func doBitBlt;
-
-	switch (pGC->alu) {
-		case GXcopy:
-			doBitBlt = afbDoBitbltCopy;
-			break;
-		case GXxor:
-			doBitBlt = afbDoBitbltXor;
-			break;
-		case GXcopyInverted:
-			doBitBlt = afbDoBitbltCopyInverted;
-			break;
-		case GXor:
-			doBitBlt = afbDoBitbltOr;
-			break;
-		default:
-			doBitBlt = afbDoBitbltGeneral;
-			break;
-	}
-
-	return(afbBitBlt(pSrcDrawable, pDstDrawable, pGC, srcx, srcy,
-			 width, height, dstx, dsty, doBitBlt, pGC->planemask));
-}
-
-RegionPtr
+static RegionPtr
 afbBitBlt(register DrawablePtr pSrcDrawable, register DrawablePtr pDstDrawable, register GC *pGC, int srcx, int srcy, int width, int height, int dstx, int dsty, afb_blit_func doBitBlt, long unsigned int planemask)
 {
 	RegionPtr prgnSrcClip = NULL;		/* may be a new region, or just a copy */
@@ -346,102 +316,28 @@ afbBitBlt(register DrawablePtr pSrcDrawa
 }
 
 RegionPtr
-afbCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, register GC *pGC, int srcx, int srcy, int width, int height, int dstx, int dsty, long unsigned int plane)
+afbCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GC *pGC, int srcx, int srcy, int width, int height, int dstx, int dsty)
 {
-	int alu;
-	RegionPtr		prgnExposed = NULL;
-	unsigned long old_planemask;
-
-	if (pDstDrawable->depth == 1) {
-		old_planemask = pGC->planemask;
-		pGC->planemask = plane;
-		if ((pGC->fgPixel & 1) == 1 && (pGC->bgPixel & 1) == 0) {
-			prgnExposed = (*pGC->ops->CopyArea)(pSrcDrawable, pDstDrawable,
-							 pGC, srcx, srcy, width, height, dstx, dsty);
-		} else if ((pGC->fgPixel & 1) == (pGC->bgPixel & 1)) {
-			unsigned char rop;
-
-			afbReduceRop(pGC->alu, pGC->fgPixel, 1, 1, &rop);
-			alu = pGC->alu;
-			pGC->alu = rop;
-			prgnExposed = (*pGC->ops->CopyArea)(pSrcDrawable, pDstDrawable, pGC,
-															srcx, srcy, width, height, dstx,
-															dsty);
-			pGC->alu = alu;
-		} else { /* need to invert the src */
-			alu = pGC->alu;
-			pGC->alu = afbInverseAlu[alu];
-			prgnExposed = (*pGC->ops->CopyArea)(pSrcDrawable, pDstDrawable, pGC,
-															srcx, srcy, width, height, dstx,
-															dsty);
-			pGC->alu = alu;
-		}
-		pGC->planemask = old_planemask;
-	} else {
-		int free_pixmap = FALSE;
-		PixmapPtr pBitmap = (PixmapPtr)pSrcDrawable;
-		ScreenPtr pScreen = pSrcDrawable->pScreen;
-		GCPtr pGC1 = NULL;
-
-		if (pSrcDrawable == pDstDrawable ||
-			pSrcDrawable->type == DRAWABLE_WINDOW || pSrcDrawable->depth != 1) {
-			/* Copy a plane from source drawable to a tmp 1-bit deep pixmap */
-			/* XXX: Range check width and height */
-			pBitmap = (*pScreen->CreatePixmap)(pScreen, width, height, 1);
-
-			if (!pBitmap)
-				return(NULL);
-			pGC1 = GetScratchGC(1, pScreen);
-			if (!pGC1) {
-				(*pScreen->DestroyPixmap)(pBitmap);
-				return(NULL);
-			}
-			ValidateGC((DrawablePtr)pBitmap, pGC1);
-			(void)afbBitBlt(pSrcDrawable, (DrawablePtr)pBitmap, pGC1, srcx, srcy,
-								  width, height, 0, 0, afbDoBitbltCopy, plane);
-			free_pixmap = TRUE;
-		}
-#if 0
-		else {
-			/* XXX: could cope with N-deep pixmap source case without using tmp
-			 * src bitmap by setting up a scratch pixmap header and fiddle
-			 * around with the pbits pointer.
-			 */
-		}
-#endif
-		afbReduceOpaqueStipple(pGC->fgPixel, pGC->bgPixel, pGC->planemask,
-										pGC->depth, afbRropsOS);
-		(void)afbBitBlt((DrawablePtr)pBitmap, pDstDrawable, pGC, 0, 0, width,
-							  height, dstx, dsty, afbCopy1ToN, pGC->planemask);
-		if (free_pixmap) {
-			(*pScreen->DestroyPixmap)(pBitmap);
-			FreeScratchGC(pGC1);
-		}
+	afb_blit_func doBitBlt;
 
-		if (pGC->fExpose)
-			prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC, srcx,
-													  srcy, width, height, dstx, dsty,
-													  plane);
+	switch (pGC->alu) {
+		case GXcopy:
+			doBitBlt = afbDoBitbltCopy;
+			break;
+		case GXxor:
+			doBitBlt = afbDoBitbltXor;
+			break;
+		case GXcopyInverted:
+			doBitBlt = afbDoBitbltCopyInverted;
+			break;
+		case GXor:
+			doBitBlt = afbDoBitbltOr;
+			break;
+		default:
+			doBitBlt = afbDoBitbltGeneral;
+			break;
 	}
-	return prgnExposed;
-}
 
-void
-afbCopy1ToN(DrawablePtr pSrc, DrawablePtr pDst, int alu, RegionPtr prgnDst, DDXPointPtr pptSrc, long unsigned int planemask)
-{
-	int numRects = REGION_NUM_RECTS(prgnDst);
-	BoxPtr pbox = REGION_RECTS(prgnDst);
-	int r;
-
-	for (r = 0; r < numRects; r++, pbox++, pptSrc++) {
-		int dx = pptSrc->x;
-		int dy = pptSrc->y;
-
-		if (alu == GXcopy)
-			afbOpaqueStippleAreaCopy(pDst, 1, pbox, alu, (PixmapPtr)pSrc, dx, dy,
-											  afbRropsOS, planemask);
-		else
-			afbOpaqueStippleAreaGeneral(pDst, 1, pbox, alu, (PixmapPtr)pSrc, dx,
-												  dy, afbRropsOS, planemask);
-	}
+	return(afbBitBlt(pSrcDrawable, pDstDrawable, pGC, srcx, srcy,
+			 width, height, dstx, dsty, doBitBlt, pGC->planemask));
 }
diff --git a/afb/afbcmap.c b/afb/afbcmap.c
index e3b95fb..9608a36 100644
--- a/afb/afbcmap.c
+++ b/afb/afbcmap.c
@@ -70,24 +70,6 @@ afbInitializeColormap(register ColormapP
 	return miInitializeColormap(pmap);
 }
 
-int
-afbExpandDirectColors(ColormapPtr pmap, int ndef, xColorItem *indefs, xColorItem *outdefs)
-{
-	return miExpandDirectColors(pmap, ndef, indefs, outdefs);
-}
-
-Bool
-afbCreateDefColormap(ScreenPtr pScreen)
-{
-	return miCreateDefColormap(pScreen);
-}
-
-Bool
-afbSetVisualTypes(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 correspond to
diff --git a/afb/afbgc.c b/afb/afbgc.c
index 03475dd..59c09e0 100644
--- a/afb/afbgc.c
+++ b/afb/afbgc.c
@@ -69,6 +69,9 @@ SOFTWARE.
 
 #include "maskbits.h"
 
+static void afbDestroyGC(GCPtr);
+static void afbValidateGC(GCPtr, unsigned long, DrawablePtr);
+
 static GCFuncs afbFuncs = {
 		afbValidateGC,
 		miChangeGC,
@@ -102,6 +105,33 @@ static GCOps afbGCOps = {
 		afbPushPixels
 };
 
+static void
+afbReduceOpaqueStipple(PixelType fg, PixelType bg, unsigned long planemask,
+		       int depth, unsigned char *rop)
+{
+	register int d;
+	register Pixel mask = 1;
+
+	bg ^= fg;
+
+	for (d = 0; d < depth; d++, mask <<= 1) {
+		if (!(planemask & mask))
+			rop[d] = RROP_NOP;
+		else if (!(bg & mask)) {
+			/* Both fg and bg have a 0 or 1 in this plane */
+			if (fg & mask)
+				rop[d] = RROP_WHITE;
+			else
+				rop[d] = RROP_BLACK;
+		} else {
+			/* Both fg and bg have different bits on this plane */
+			if (fg & mask)
+				rop[d] = RROP_COPY;
+			else
+				rop[d] = RROP_INVERT;
+		}
+	}
+}
 
 Bool
 afbCreateGC(pGC)
@@ -136,6 +166,95 @@ afbCreateGC(pGC)
 	return TRUE;
 }
 
+static void
+afbComputeCompositeClip(GCPtr pGC, DrawablePtr pDrawable)
+{
+	if (pDrawable->type == DRAWABLE_WINDOW) {
+		WindowPtr pWin = (WindowPtr) pDrawable;
+		RegionPtr pregWin;
+		Bool freeTmpClip, freeCompClip;
+
+	if (pGC->subWindowMode == IncludeInferiors) {
+		pregWin = NotClippedByChildren(pWin);
+		freeTmpClip = TRUE;
+	} else {
+		pregWin = &pWin->clipList;
+		freeTmpClip = FALSE;
+	}
+	freeCompClip = pGC->freeCompClip;
+
+	/*
+	 * if there is no client clip, we can get by with just keeping the
+	 * pointer we got, and remembering whether or not should destroy (or
+	 * maybe re-use) it later.  this way, we avoid unnecessary copying of
+	 * regions.  (this wins especially if many clients clip by children
+	 * and have no client clip.)
+	 */
+	if (pGC->clientClipType == CT_NONE) {
+		if (freeCompClip)
+			REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
+			pGC->pCompositeClip = pregWin;
+			pGC->freeCompClip = freeTmpClip;
+		} else {
+			/*
+			 * we need one 'real' region to put into the composite clip. if
+			 * pregWin the current composite clip are real, we can get rid of
+			 * one. if pregWin is real and the current composite clip isn't,
+			 * use pregWin for the composite clip. if the current composite
+			 * clip is real and pregWin isn't, use the current composite
+			 * clip. if neither is real, create a new region.
+			 */
+
+			REGION_TRANSLATE(pGC->pScreen, pGC->clientClip,
+			pDrawable->x + pGC->clipOrg.x,
+			pDrawable->y + pGC->clipOrg.y);
+
+			if (freeCompClip) {
+				REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip, pregWin,
+									  pGC->clientClip);
+				if (freeTmpClip)
+					REGION_DESTROY(pGC->pScreen, pregWin);
+			} else if (freeTmpClip) {
+				REGION_INTERSECT(pGC->pScreen, pregWin, pregWin, pGC->clientClip);
+				pGC->pCompositeClip = pregWin;
+			} else {
+				pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, NullBox, 0);
+				REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+				pregWin, pGC->clientClip);
+			}
+			pGC->freeCompClip = TRUE;
+			REGION_TRANSLATE(pGC->pScreen, pGC->clientClip,
+			-(pDrawable->x + pGC->clipOrg.x),
+			-(pDrawable->y + pGC->clipOrg.y));
+		}
+	}	/* end of composite clip for a window */
+	else {
+		BoxRec pixbounds;
+
+		/* XXX should we translate by drawable.x/y here ? */
+		pixbounds.x1 = 0;
+		pixbounds.y1 = 0;
+		pixbounds.x2 = pDrawable->width;
+		pixbounds.y2 = pDrawable->height;
+
+		if (pGC->freeCompClip) {
+			REGION_RESET(pGC->pScreen, pGC->pCompositeClip, &pixbounds);
+		} else {
+			pGC->freeCompClip = TRUE;
+			pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, &pixbounds, 1);
+		}
+
+		if (pGC->clientClipType == CT_REGION) {
+			REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip, -pGC->clipOrg.x,
+								  -pGC->clipOrg.y);
+			REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
+								  pGC->pCompositeClip, pGC->clientClip);
+			REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip, pGC->clipOrg.x,
+								  pGC->clipOrg.y);
+		}
+	}	/* end of composite clip for pixmap */
+} /* end afbComputeCompositeClip */
+
 /* Clipping conventions
 		if the drawable is a window
 			CT_REGION ==> pCompositeClip really is the composite
@@ -147,7 +266,7 @@ afbCreateGC(pGC)
 */
 
 /*ARGSUSED*/
-void
+static void
 afbValidateGC(pGC, changes, pDrawable)
 	register GCPtr 		pGC;
 	unsigned long		changes;
@@ -434,7 +553,7 @@ afbValidateGC(pGC, changes, pDrawable)
 	} /* end of new_fill */
 }
 
-void
+static void
 afbDestroyGC(pGC)
 	GCPtr pGC;
 {
@@ -445,58 +564,6 @@ afbDestroyGC(pGC)
 	miDestroyGCOps(pGC->ops);
 }
 
-/* table to map alu(src, dst) to alu(~src, dst) */
-int afbInverseAlu[16] = {
-		GXclear,
-		GXandInverted,
-		GXnor,
-		GXcopyInverted,
-		GXand,
-		GXnoop,
-		GXequiv,
-		GXorInverted,
-		GXandReverse,
-		GXxor,
-		GXinvert,
-		GXnand,
-		GXcopy,
-		GXor,
-		GXorReverse,
-		GXset
-};
-
-void
-afbReduceOpaqueStipple(fg, bg, planemask, depth, rop)
-register PixelType fg;
-register PixelType bg;
-register unsigned long planemask;
-int depth;
-register unsigned char *rop;
-{
-	register int d;
-	register Pixel mask = 1;
-
-	bg ^= fg;
-
-	for (d = 0; d < depth; d++, mask <<= 1) {
-		if (!(planemask & mask))
-			rop[d] = RROP_NOP;
-		else if (!(bg & mask)) {
-			/* Both fg and bg have a 0 or 1 in this plane */
-			if (fg & mask)
-				rop[d] = RROP_WHITE;
-			else
-				rop[d] = RROP_BLACK;
-		} else {
-			/* Both fg and bg have different bits on this plane */
-			if (fg & mask)
-				rop[d] = RROP_COPY;
-			else
-				rop[d] = RROP_INVERT;
-		}
-	}
-}
-
 void
 afbReduceRop(alu, src, planemask, depth, rop)
 	register int alu;
@@ -615,94 +682,3 @@ afbReduceRop(alu, src, planemask, depth,
 			}
 	}
 }
-
-void
-afbComputeCompositeClip(pGC, pDrawable)
-	GCPtr pGC;
-	DrawablePtr pDrawable;
-{
-	if (pDrawable->type == DRAWABLE_WINDOW) {
-		WindowPtr pWin = (WindowPtr) pDrawable;
-		RegionPtr pregWin;
-		Bool freeTmpClip, freeCompClip;
-
-	if (pGC->subWindowMode == IncludeInferiors) {
-		pregWin = NotClippedByChildren(pWin);
-		freeTmpClip = TRUE;
-	} else {
-		pregWin = &pWin->clipList;
-		freeTmpClip = FALSE;
-	}
-	freeCompClip = pGC->freeCompClip;
-
-	/*
-	 * if there is no client clip, we can get by with just keeping the
-	 * pointer we got, and remembering whether or not should destroy (or
-	 * maybe re-use) it later.  this way, we avoid unnecessary copying of
-	 * regions.  (this wins especially if many clients clip by children
-	 * and have no client clip.)
-	 */
-	if (pGC->clientClipType == CT_NONE) {
-		if (freeCompClip)
-			REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
-			pGC->pCompositeClip = pregWin;
-			pGC->freeCompClip = freeTmpClip;
-		} else {
-			/*
-			 * we need one 'real' region to put into the composite clip. if
-			 * pregWin the current composite clip are real, we can get rid of
-			 * one. if pregWin is real and the current composite clip isn't,
-			 * use pregWin for the composite clip. if the current composite
-			 * clip is real and pregWin isn't, use the current composite
-			 * clip. if neither is real, create a new region.
-			 */
-
-			REGION_TRANSLATE(pGC->pScreen, pGC->clientClip,
-			pDrawable->x + pGC->clipOrg.x,
-			pDrawable->y + pGC->clipOrg.y);
-
-			if (freeCompClip) {
-				REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip, pregWin,
-									  pGC->clientClip);
-				if (freeTmpClip)
-					REGION_DESTROY(pGC->pScreen, pregWin);
-			} else if (freeTmpClip) {
-				REGION_INTERSECT(pGC->pScreen, pregWin, pregWin, pGC->clientClip);
-				pGC->pCompositeClip = pregWin;
-			} else {
-				pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, NullBox, 0);
-				REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
-				pregWin, pGC->clientClip);
-			}
-			pGC->freeCompClip = TRUE;
-			REGION_TRANSLATE(pGC->pScreen, pGC->clientClip,
-			-(pDrawable->x + pGC->clipOrg.x),
-			-(pDrawable->y + pGC->clipOrg.y));
-		}
-	}	/* end of composite clip for a window */
-	else {
-		BoxRec pixbounds;
-
-		/* XXX should we translate by drawable.x/y here ? */
-		pixbounds.x1 = 0;
-		pixbounds.y1 = 0;
-		pixbounds.x2 = pDrawable->width;
-		pixbounds.y2 = pDrawable->height;
-
-		if (pGC->freeCompClip) {
-			REGION_RESET(pGC->pScreen, pGC->pCompositeClip, &pixbounds);
-		} else {
-			pGC->freeCompClip = TRUE;
-			pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, &pixbounds, 1);
-		}
-
-		if (pGC->clientClipType == CT_REGION) {
-			REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip, -pGC->clipOrg.x,
-								  -pGC->clipOrg.y);
-			REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
-								  pGC->pCompositeClip, pGC->clientClip);
-			REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip, pGC->clipOrg.x,
-								  pGC->clipOrg.y);
-		}
-	}	/* end of composite clip for pixmap */
-} /* end afbComputeCompositeClip */
diff --git a/afb/afbimage.c b/afb/afbimage.c
index c82bb36..81f4973 100644
--- a/afb/afbimage.c
+++ b/afb/afbimage.c
@@ -42,39 +42,8 @@ afbPutImage(pDraw, pGC, depth, x, y, wid
 			(void)(*pGC->ops->CopyPlane)((DrawablePtr)pPixmap, pDraw, pGC, leftPad,
 												  0, width, height, x, y, 1);
 		else {
-#if 0
-			/* XXX: bit plane order wronge ! */
-			pPixmap->drawable.depth = 1;
-			pPixmap->drawable.bitsPerPixel = 1;
-
-			switch (pGC->alu) {
-				case GXcopy:
-					doBitBlt = afbDoBitbltCopy;
-					break;
-				case GXxor:
-					doBitBlt = afbDoBitbltXor;
-					break;
-				case GXcopyInverted:
-					doBitBlt = afbDoBitbltCopyInverted;
-					break;
-				case GXor:
-					doBitBlt = afbDoBitbltOr;
-					break;
-				default:
-					doBitBlt = afbDoBitbltGeneral;
-					break;
-			}
-
-			for (plane = (1L << (pPixmap->drawable.depth - 1)); plane;
-				  plane >>= 1) {
-				(void)afbBitBlt((DrawablePtr)pPixmap, pDraw, pGC, leftPad, 0,
-									  width, height, x, y, doBitBlt, plane);
-				/* pDraw->devKind += sizeDst; */
-			}
-#else
 			(void)(*pGC->ops->CopyArea)((DrawablePtr)pPixmap, pDraw, pGC, leftPad,
 												 0, width, height, x, y);
-#endif
 		}
 
 		pGC->fExpose = TRUE;
diff --git a/afb/afbpixmap.c b/afb/afbpixmap.c
index 6a3a485..77ba535 100644
--- a/afb/afbpixmap.c
+++ b/afb/afbpixmap.c
@@ -118,9 +118,8 @@ afbDestroyPixmap(pPixmap)
 }
 
 
-PixmapPtr
-afbCopyPixmap(pSrc)
-	register PixmapPtr pSrc;
+static PixmapPtr
+afbCopyPixmap(PixmapPtr pSrc)
 {
 	register PixmapPtr pDst;
 	int size;
@@ -148,9 +147,8 @@ afbCopyPixmap(pSrc)
 	  zero out area to be filled with replicate
 	  left shift and or in original as many times as needed
 */
-void
-afbPadPixmap(pPixmap)
-	PixmapPtr pPixmap;
+static void
+afbPadPixmap(PixmapPtr pPixmap)
 {
 	register int width = pPixmap->drawable.width;
 	register int h;
diff --git a/afb/afbscrinit.c b/afb/afbscrinit.c
index 2b0867f..7cb7423 100644
--- a/afb/afbscrinit.c
+++ b/afb/afbscrinit.c
@@ -77,7 +77,7 @@ int afbScreenPrivateIndex;
 
 static unsigned long afbGeneration = 0;
 
-BSFuncRec afbBSFuncRec = {
+static BSFuncRec afbBSFuncRec = {
 	afbSaveAreas,
 	afbRestoreAreas,
 	(BackingStoreSetClipmaskRgnProcPtr) 0,
@@ -85,7 +85,7 @@ BSFuncRec afbBSFuncRec = {
 	(BackingStoreGetSpansPixmapProcPtr) 0,
 };
 
-Bool
+static Bool
 afbCloseScreen(int index, ScreenPtr pScreen)
 {
 	int d;
@@ -119,7 +119,29 @@ afbCreateScreenResources(ScreenPtr pScre
 	return(retval);
 }
 
-Bool
+static PixmapPtr
+afbGetWindowPixmap(WindowPtr pWin)
+{
+#ifdef PIXMAP_PER_WINDOW
+    return (PixmapPtr)(pWin->devPrivates[frameWindowPrivateIndex].ptr);
+#else
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+
+    return (* pScreen->GetScreenPixmap)(pScreen);
+#endif
+}
+
+static void
+afbSetWindowPixmap(WindowPtr pWin, PixmapPtr pPix)
+{
+#ifdef PIXMAP_PER_WINDOW
+    pWin->devPrivates[frameWindowPrivateIndex].ptr = (pointer)pPix;
+#else
+    (* pWin->drawable.pScreen->SetScreenPixmap)(pPix);
+#endif
+}
+
+static Bool
 afbAllocatePrivates(ScreenPtr pScreen, int *pWinIndex, int *pGCIndex)
 {
 	if (afbGeneration != serverGeneration) {
@@ -216,25 +238,3 @@ afbScreenInit(register ScreenPtr pScreen
 
 	return TRUE;
 }
-
-PixmapPtr
-afbGetWindowPixmap(WindowPtr pWin)
-{
-#ifdef PIXMAP_PER_WINDOW
-    return (PixmapPtr)(pWin->devPrivates[frameWindowPrivateIndex].ptr);
-#else
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    return (* pScreen->GetScreenPixmap)(pScreen);
-#endif
-}
-
-void
-afbSetWindowPixmap(WindowPtr pWin, PixmapPtr pPix)
-{
-#ifdef PIXMAP_PER_WINDOW
-    pWin->devPrivates[frameWindowPrivateIndex].ptr = (pointer)pPix;
-#else
-    (* pWin->drawable.pScreen->SetScreenPixmap)(pPix);
-#endif
-}
diff --git a/afb/afbsetsp.c b/afb/afbsetsp.c
index adc7266..cb36dba 100644
--- a/afb/afbsetsp.c
+++ b/afb/afbsetsp.c
@@ -73,20 +73,10 @@ SOFTWARE.
  * boxes, we may not want to start grabbing bits at psrc but at some offset
  * further on.)
  */
-void
-afbSetScanline(y, xOrigin, xStart, xEnd, psrc, alu, pdstBase, widthDst,
-					 sizeDst, depthDst, sizeSrc)
-	int y;
-	int xOrigin;					/* where this scanline starts */
-	int xStart;						/* first bit to use from scanline */
-	int xEnd;						/* last bit to use from scanline + 1 */
-	register PixelType *psrc;
-	register int alu;				/* raster op */
-	PixelType *pdstBase;			/* start of the drawable */
-	int widthDst;					/* width of drawable in words */
-	int sizeDst;
-	int depthDst;
-	int sizeSrc;
+static void
+afbSetScanline(int y, int xOrigin, int xStart, int xEnd, PixelType *psrc,
+	       int alu, PixelType *pdstBase, int widthDst, int sizeDst,
+	       int depthDst, int sizeSrc)
 {
 	int w;							/* width of scanline in bits */
 	register PixelType *pdst;	/* where to put the bits */
diff-tree f36bf1a3e4ce9465ea4a6159c209924a3cafbe58 (from 9a0f25de7ca3c68af867b38936103d17daa92ac6)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sun Mar 25 12:28:13 2007 -0400

    Delete a dead file.

diff --git a/hw/xfree86/xf4bpp/ppcPolyRec.c b/hw/xfree86/xf4bpp/ppcPolyRec.c
deleted file mode 100644
index d7f8662..0000000
--- a/hw/xfree86/xf4bpp/ppcPolyRec.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright IBM Corporation 1987,1988,1989
- *
- * All Rights Reserved
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted,
- * provided that the above copyright notice appear in all copies and that 
- * both that copyright notice and this permission notice appear in
- * supporting documentation, and that the name of IBM not be
- * used in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission.
- *
- * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
-*/
-/***********************************************************
-
-Copyright (c) 1987  X Consortium
-
-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, sublicense, 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 shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the X Consortium shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from the X Consortium.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-/* $XConsortium: ppcPolyRec.c /main/4 1996/02/21 17:58:11 kaleb $ */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf4bpp.h"
-
-void
-xf4bppPolyRectangle(pDraw, pGC, nrects, pRects)
-    DrawablePtr	pDraw;
-    GCPtr	pGC;
-    int		nrects;
-    xRectangle	*pRects;
-{
-    int i;
-    xRectangle *pR = pRects;
-    xRectangle *tmprects, *tmprectsinit;
-    int lw, fs, ss;
-
-    if ( ! ( tmprectsinit = tmprects = (xRectangle *)ALLOCATE_LOCAL( ( sizeof ( xRectangle ) * nrects ) << 2 ) ) )
-	return;
-
-    lw = pGC->lineWidth;
-    ss = lw >> 1;		/* skinny side of line */
-    fs = ( lw + 1 ) >> 1;	/* fat side of line */
-
-    for (i=0; i<nrects; i++)
-    {
-	tmprects->x = pR->x - ss;
-	tmprects->y = pR->y - ss;
-	tmprects->width = pR->width + lw;
-	tmprects->height = lw;
-	tmprects++;
-
-	tmprects->x = pR->x - ss;
-	tmprects->y = pR->y + fs;
-	tmprects->width = lw;
-	tmprects->height = pR->height - lw;
-	tmprects++;
-
-	tmprects->x = pR->x + pR->width - ss;
-	tmprects->y = pR->y + fs;
-	tmprects->width = lw;
-	tmprects->height = pR->height - lw;
-	tmprects++;
-
-	tmprects->x = pR->x - ss;
-	tmprects->y = pR->y + pR->height - ss;
-	tmprects->width = pR->width + lw;
-	tmprects->height = lw;
-	tmprects++;
-
-	pR++;
-    }
-
-    (* pGC->ops->PolyFillRect)( pDraw, pGC, nrects << 2, tmprectsinit );
-
-    DEALLOCATE_LOCAL( tmprectsinit );
-    return ;
-}
diff-tree 9a0f25de7ca3c68af867b38936103d17daa92ac6 (from ac2356843e38b3400142bc54b65393c12976fc07)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sun Mar 25 12:27:01 2007 -0400

    Static cleanups, dead code deletion.

diff --git a/Xi/exglobals.h b/Xi/exglobals.h
index 3afd1bb..61ebca8 100644
--- a/Xi/exglobals.h
+++ b/Xi/exglobals.h
@@ -37,7 +37,6 @@ OR IN CONNECTION WITH THE USE OR PERFORM
 
 extern int IReqCode;
 extern int BadDevice;
-extern int BadEvent;
 extern int BadMode;
 extern int DeviceBusy;
 extern int BadClass;
diff --git a/Xi/extinit.c b/Xi/extinit.c
index 4548837..d14e133 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -116,7 +116,7 @@ int ExtEventIndex;
 Mask ExtValidMasks[EMASKSIZE];
 Mask ExtExclusiveMasks[EMASKSIZE];
 
-struct dev_type
+static struct dev_type
 {
     Atom type;
     char *name;
@@ -152,7 +152,7 @@ XExtEventInfo EventInfo[32];
 
 int IReqCode = 0;
 int BadDevice = 0;
-int BadEvent = 1;
+static int BadEvent = 1;
 int BadMode = 2;
 int DeviceBusy = 3;
 int BadClass = 4;
diff --git a/composite/compalloc.c b/composite/compalloc.c
index 5bbf0a2..ce1ef7d 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -48,7 +48,7 @@
 
 #include "compint.h"
 
-void
+static void
 compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
 {
     WindowPtr	    pWin = (WindowPtr) closure;
diff --git a/composite/compext.c b/composite/compext.c
index 13936fa..4c25cc7 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -50,10 +50,10 @@
 #include "compint.h"
 
 static CARD8	CompositeReqCode;
-int		CompositeClientPrivateIndex;
+static int	CompositeClientPrivateIndex;
 RESTYPE		CompositeClientWindowType;
 RESTYPE		CompositeClientSubwindowsType;
-RESTYPE		CompositeClientOverlayType;
+static RESTYPE	CompositeClientOverlayType;
 
 static void deleteCompOverlayClient (CompOverlayClientPtr pOcToDel, 
 				     ScreenPtr pScreen);
@@ -423,7 +423,7 @@ createOverlayWindow (ScreenPtr pScreen)
     return pWin;
 }
 
-int
+static int
 ProcCompositeGetOverlayWindow (ClientPtr client)
 {
     REQUEST(xCompositeGetOverlayWindowReq); 
@@ -477,7 +477,7 @@ ProcCompositeGetOverlayWindow (ClientPtr
     return client->noClientException;
 }
 
-int
+static int
 ProcCompositeReleaseOverlayWindow (ClientPtr client)
 {
     REQUEST(xCompositeReleaseOverlayWindowReq); 
@@ -515,7 +515,7 @@ ProcCompositeReleaseOverlayWindow (Clien
     return client->noClientException;
 }
 
-int (*ProcCompositeVector[CompositeNumberRequests])(ClientPtr) = {
+static int (*ProcCompositeVector[CompositeNumberRequests])(ClientPtr) = {
     ProcCompositeQueryVersion,
     ProcCompositeRedirectWindow,
     ProcCompositeRedirectSubwindows,
@@ -625,7 +625,7 @@ SProcCompositeNameWindowPixmap (ClientPt
     return (*ProcCompositeVector[stuff->compositeReqType]) (client);
 }
 
-int
+static int
 SProcCompositeGetOverlayWindow (ClientPtr client)
 {
     int n;
@@ -637,7 +637,7 @@ SProcCompositeGetOverlayWindow (ClientPt
     return (*ProcCompositeVector[stuff->compositeReqType]) (client);
 }
 
-int
+static int
 SProcCompositeReleaseOverlayWindow (ClientPtr client)
 {
     int n;
@@ -649,7 +649,7 @@ SProcCompositeReleaseOverlayWindow (Clie
     return (*ProcCompositeVector[stuff->compositeReqType]) (client);
 }
 
-int (*SProcCompositeVector[CompositeNumberRequests])(ClientPtr) = {
+static int (*SProcCompositeVector[CompositeNumberRequests])(ClientPtr) = {
     SProcCompositeQueryVersion,
     SProcCompositeRedirectWindow,
     SProcCompositeRedirectSubwindows,
diff --git a/composite/compinit.c b/composite/compinit.c
index 1d5cc7b..27261dc 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -51,7 +51,7 @@
 int	CompScreenPrivateIndex;
 int	CompWindowPrivateIndex;
 int	CompSubwindowsPrivateIndex;
-int	CompGeneration;
+static int	CompGeneration;
 
 
 static Bool
diff --git a/composite/compint.h b/composite/compint.h
index 3958b3b..0bd55a9 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -171,9 +171,6 @@ extern RESTYPE		CompositeClientSubwindow
  * compalloc.c
  */
 
-void
-compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure);
-
 Bool
 compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update);
 
@@ -292,18 +289,6 @@ compWindowUpdate (WindowPtr pWin);
 void
 deleteCompOverlayClientsForScreen (ScreenPtr pScreen);
 
-int
-ProcCompositeGetOverlayWindow (ClientPtr client);
-
-int
-ProcCompositeReleaseOverlayWindow (ClientPtr client);
-
-int
-SProcCompositeGetOverlayWindow (ClientPtr client);
-
-int
-SProcCompositeReleaseOverlayWindow (ClientPtr client);
-
 WindowPtr
 CompositeRealChildHead (WindowPtr pWin);
 
diff --git a/damageext/damageext.c b/damageext/damageext.c
index 739d20f..57a7bce 100755
--- a/damageext/damageext.c
+++ b/damageext/damageext.c
@@ -28,12 +28,12 @@
 
 #include "damageextint.h"
 
-unsigned char	DamageReqCode;
-int		DamageEventBase;
-int		DamageErrorBase;
-int		DamageClientPrivateIndex;
-RESTYPE		DamageExtType;
-RESTYPE		DamageExtWinType;
+static unsigned char	DamageReqCode;
+static int		DamageEventBase;
+static int		DamageErrorBase;
+static int		DamageClientPrivateIndex;
+static RESTYPE		DamageExtType;
+static RESTYPE		DamageExtWinType;
 
 /* Version of the damage extension supported by the server, as opposed to the
  * DAMAGE_* defines from damageproto for what version the proto header
@@ -319,7 +319,7 @@ static const int version_requests[] = {
 
 #define NUM_VERSION_REQUESTS	(sizeof (version_requests) / sizeof (version_requests[0]))
     
-int	(*ProcDamageVector[XDamageNumberRequests])(ClientPtr) = {
+static int (*ProcDamageVector[XDamageNumberRequests])(ClientPtr) = {
 /*************** Version 1 ******************/
     ProcDamageQueryVersion,
     ProcDamageCreate,
@@ -408,7 +408,7 @@ SProcDamageAdd (ClientPtr client)
     return (*ProcDamageVector[stuff->damageReqType]) (client);
 }
 
-int	(*SProcDamageVector[XDamageNumberRequests])(ClientPtr) = {
+static int (*SProcDamageVector[XDamageNumberRequests])(ClientPtr) = {
 /*************** Version 1 ******************/
     SProcDamageQueryVersion,
     SProcDamageCreate,
@@ -478,7 +478,7 @@ FreeDamageExtWin (pointer value, XID wid
     return Success;
 }
 
-void
+static void
 SDamageNotifyEvent (xDamageNotifyEvent *from,
 		    xDamageNotifyEvent *to)
 {
diff --git a/damageext/damageextint.h b/damageext/damageextint.h
index 6f14e4e..1ed07de 100644
--- a/damageext/damageextint.h
+++ b/damageext/damageextint.h
@@ -44,13 +44,6 @@
 #include "damage.h" 
 #include "xfixes.h"
 
-extern unsigned char	DamageReqCode;
-extern int		DamageEventBase;
-extern int		DamageErrorBase;
-extern int		DamageClientPrivateIndex;
-extern RESTYPE		DamageExtType;
-extern RESTYPE		DamageExtWinType;
-
 typedef struct _DamageClient {
     CARD32	major_version;
     CARD32	minor_version;
@@ -67,9 +60,6 @@ typedef struct _DamageExt {
     XID			id;
 } DamageExtRec, *DamageExtPtr;
 
-extern int	(*ProcDamageVector[/*XDamageNumberRequests*/])(ClientPtr);
-extern int	(*SProcDamageVector[/*XDamageNumberRequests*/])(ClientPtr);
-
 #define VERIFY_DAMAGEEXT(pDamageExt, rid, client, mode) { \
     pDamageExt = SecurityLookupIDByType (client, rid, DamageExtType, mode); \
     if (!pDamageExt) { \
@@ -79,10 +69,6 @@ extern int	(*SProcDamageVector[/*XDamage
 }
 
 void
-SDamageNotifyEvent (xDamageNotifyEvent *from,
-		    xDamageNotifyEvent *to);
-
-void
 DamageExtSetCritical (ClientPtr pClient, Bool critical);
 
 #endif /* _DAMAGEEXTINT_H_ */
diff --git a/dbe/midbe.c b/dbe/midbe.c
index e687b98..76f0577 100644
--- a/dbe/midbe.c
+++ b/dbe/midbe.c
@@ -59,21 +59,12 @@
 
 #include <stdio.h>
 
-/* DEFINES */
-
-
-/* TYPEDEFS */
-
-
-/* GLOBALS */
-
 static int	miDbePrivPrivGeneration  =  0;
 static int	miDbeWindowPrivPrivIndex = -1;
-RESTYPE		dbeDrawableResType;
-RESTYPE		dbeWindowPrivResType;
-int		dbeScreenPrivIndex = -1;
-int		dbeWindowPrivIndex = -1;
-
+static RESTYPE	dbeDrawableResType;
+static RESTYPE	dbeWindowPrivResType;
+static int	dbeScreenPrivIndex = -1;
+static int	dbeWindowPrivIndex = -1;
 
 
 /******************************************************************************
diff --git a/dix/devices.c b/dix/devices.c
index 5996b75..f622be7 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -79,7 +79,8 @@ SOFTWARE.
 #include "exglobals.h"
 #include "exevents.h"
 
-int CoreDevicePrivatesIndex = 0, CoreDevicePrivatesGeneration = -1;
+int CoreDevicePrivatesIndex = 0;
+static int CoreDevicePrivatesGeneration = -1;
 
 DeviceIntPtr
 AddInputDevice(DeviceProc deviceProc, Bool autoStart)
@@ -926,16 +927,16 @@ InitPtrFeedbackClassDeviceStruct(DeviceI
 }
 
 
-LedCtrl defaultLedControl = {
+static LedCtrl defaultLedControl = {
 	DEFAULT_LEDS, DEFAULT_LEDS_MASK, 0};
 
-BellCtrl defaultBellControl = {
+static BellCtrl defaultBellControl = {
 	DEFAULT_BELL,
 	DEFAULT_BELL_PITCH,
 	DEFAULT_BELL_DURATION,
 	0};
 
-IntegerCtrl defaultIntegerControl = {
+static IntegerCtrl defaultIntegerControl = {
 	DEFAULT_INT_RESOLUTION,
 	DEFAULT_INT_MIN_VALUE,
 	DEFAULT_INT_MAX_VALUE,
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 32f6788..02665ed 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -297,8 +297,8 @@ long	    SmartScheduleSlice = SMART_SCHE
 long	    SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL;
 long	    SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE;
 long	    SmartScheduleTime;
-ClientPtr   SmartLastClient;
-int	    SmartLastIndex[SMART_MAX_PRIORITY-SMART_MIN_PRIORITY+1];
+static ClientPtr   SmartLastClient;
+static int	   SmartLastIndex[SMART_MAX_PRIORITY-SMART_MIN_PRIORITY+1];
 int         SmartScheduleClient(int *clientReady, int nready);
 
 #ifdef SMART_DEBUG
diff --git a/dix/events.c b/dix/events.c
index 02598a3..e008e36 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -156,7 +156,7 @@ extern Mask      xevieFilters[128];
 extern int       xevieEventSent;
 extern int       xevieKBEventSent;
 int    xeviegrabState = 0;
-xEvent *xeviexE;
+static xEvent *xeviexE;
 #endif
 
 #include <X11/extensions/XIproto.h>
diff --git a/dix/extension.c b/dix/extension.c
index dc1a76f..fb4ee6b 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -66,7 +66,7 @@ SOFTWARE.
 #define LAST_EVENT  128
 #define LAST_ERROR 255
 
-ScreenProcEntry AuxillaryScreenProcs[MAXSCREENS];
+static ScreenProcEntry AuxillaryScreenProcs[MAXSCREENS];
 
 static ExtensionEntry **extensions = (ExtensionEntry **)NULL;
 
diff --git a/dix/gc.c b/dix/gc.c
index 89b246d..7b7953d 100644
--- a/dix/gc.c
+++ b/dix/gc.c
@@ -69,7 +69,7 @@ extern FontPtr defaultFont;
 
 static Bool CreateDefaultTile(GCPtr pGC);
 
-unsigned char DefaultDash[2] = {4, 4};
+static unsigned char DefaultDash[2] = {4, 4};
 
 _X_EXPORT void
 ValidateGC(DrawablePtr pDraw, GC *pGC)
diff --git a/dix/resource.c b/dix/resource.c
index 7092b2f..a5a7eed 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -246,7 +246,7 @@ CreateNewResourceClass()
     return next;
 }
 
-ClientResourceRec clientTable[MAXCLIENTS];
+static ClientResourceRec clientTable[MAXCLIENTS];
 
 /*****************
  * InitClientResources
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 7617bf7..e1cbdbb 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -2847,7 +2847,7 @@ xf86IsListSubsetOf(resPtr list, resPtr B
     return TRUE;
 }
 
-resPtr
+static resPtr
 findIntersect(resRange Range, resPtr list)
 {
     resRange range;
diff --git a/hw/xfree86/common/xf86Bus.h b/hw/xfree86/common/xf86Bus.h
index b638e90..225a5c7 100644
--- a/hw/xfree86/common/xf86Bus.h
+++ b/hw/xfree86/common/xf86Bus.h
@@ -143,7 +143,6 @@ memType ChkConflict(resRange *rgp, resPt
 Bool xf86IsSubsetOf(resRange range, resPtr list);
 Bool xf86IsListSubsetOf(resPtr list, resPtr BaseList);
 resPtr xf86ExtractTypeFromList(resPtr list, unsigned long type);
-resPtr findIntersect(resRange Range, resPtr list);
 resPtr xf86FindIntersect(resRange Range, resPtr list);
 void RemoveOverlaps(resPtr target, resPtr list, Bool pow2Alignment,
 		    Bool useEstimated);
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index f71486c..4b482df 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -68,7 +68,7 @@ static int nDevToConfig = 0, CurrentDriv
 
 _X_EXPORT xf86MonPtr ConfiguredMonitor;
 Bool xf86DoConfigurePass1 = TRUE;
-Bool foundMouse = FALSE;
+static Bool foundMouse = FALSE;
 
 #if defined(__UNIXOS2__)
 #define DFLT_MOUSE_DEV "mouse$"
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 05e62f1..eae6cb1 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -126,9 +126,9 @@ extern Bool noXkbExtension;
  */
 
 #ifdef USE_VT_SYSREQ
-Bool VTSysreqToggle = FALSE;
+static Bool VTSysreqToggle = FALSE;
 #endif /* !USE_VT_SYSREQ */
-Bool VTSwitchEnabled = TRUE;		/* Allows run-time disabling for
+static Bool VTSwitchEnabled = TRUE;	/* Allows run-time disabling for
                                          *BSD and for avoiding VT
                                          switches when using the DRI
                                          automatic full screen mode.*/
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 3e908b8..2b097d2 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -110,7 +110,7 @@ static void xf86XVAdjustFrame(int index,
 static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int);
 
 
-int XF86XVWindowIndex = -1;
+static int XF86XVWindowIndex = -1;
 int XF86XvScreenIndex = -1;
 static unsigned long XF86XVGeneration = 0;
 static unsigned long PortResource = 0;
diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c
index ddd624c..774a4c4 100644
--- a/hw/xfree86/loader/loader.c
+++ b/hw/xfree86/loader/loader.c
@@ -189,101 +189,6 @@ _LoaderListPop(int handle)
     return 0;
 }
 
-/*
- * _LoaderHandleToName() will return the name of the first module with a
- * given handle. This requires getting the last module on the LIFO with
- * the given handle.
- */
-char *
-_LoaderHandleToName(int handle)
-{
-    loaderPtr item = listHead;
-    loaderPtr aritem = NULL;
-    loaderPtr lastitem = NULL;
-
-    if (handle < 0) {
-	return "(built-in)";
-    }
-    while (item) {
-	if (item->handle == handle) {
-	    if (strchr(item->name, ':') == NULL)
-		aritem = item;
-	    else
-		lastitem = item;
-	}
-	item = item->next;
-    }
-
-    if (aritem)
-	return aritem->name;
-
-    if (lastitem)
-	return lastitem->name;
-
-    return 0;
-}
-
-/*
- * _LoaderHandleToCanonicalName() will return the cname of the first module
- * with a given handle. This requires getting the last module on the LIFO with
- * the given handle.
- */
-char *
-_LoaderHandleToCanonicalName(int handle)
-{
-    loaderPtr item = listHead;
-    loaderPtr lastitem = NULL;
-
-    if (handle < 0) {
-	return "(built-in)";
-    }
-    while (item) {
-	if (item->handle == handle) {
-	    lastitem = item;
-	}
-	item = item->next;
-    }
-
-    if (lastitem)
-	return lastitem->cname;
-
-    return NULL;
-}
-
-/*
- * _LoaderModuleToName() will return the name of the first module with a
- * given handle. This requires getting the last module on the LIFO with
- * the given handle.
- */
-char *
-_LoaderModuleToName(int module)
-{
-    loaderPtr item = listHead;
-    loaderPtr aritem = NULL;
-    loaderPtr lastitem = NULL;
-
-    if (module < 0) {
-	return "(built-in)";
-    }
-    while (item) {
-	if (item->module == module) {
-	    if (strchr(item->name, ':') == NULL)
-		aritem = item;
-	    else
-		lastitem = item;
-	}
-	item = item->next;
-    }
-
-    if (aritem)
-	return aritem->name;
-
-    if (lastitem)
-	return lastitem->name;
-
-    return 0;
-}
-
 /* These four are just ABI stubs */
 _X_EXPORT void
 LoaderRefSymbols(const char *sym0, ...)
@@ -450,35 +355,14 @@ LoaderUnload(int handle)
     return 0;
 }
 
-void
-LoaderDuplicateSymbol(const char *symbol, const int handle)
-{
-    ErrorF("Duplicate symbol %s in %s\n", symbol,
-	   listHead ? listHead->name : "(built-in)");
-    ErrorF("Also defined in %s\n", _LoaderHandleToName(handle));
-    FatalError("Module load failure\n");
-}
-
 unsigned long LoaderOptions = 0;
 
 void
-LoaderResetOptions(void)
-{
-    LoaderOptions = 0;
-}
-
-void
 LoaderSetOptions(unsigned long opts)
 {
     LoaderOptions |= opts;
 }
 
-void
-LoaderClearOptions(unsigned long opts)
-{
-    LoaderOptions &= ~opts;
-}
-
 _X_EXPORT int
 LoaderGetABIVersion(const char *abiclass)
 {
diff --git a/hw/xfree86/loader/loaderProcs.h b/hw/xfree86/loader/loaderProcs.h
index ecbd676..b71ad45 100644
--- a/hw/xfree86/loader/loaderProcs.h
+++ b/hw/xfree86/loader/loaderProcs.h
@@ -97,9 +97,6 @@ void LoadFont(FontModule *);
 void UnloadModule(ModuleDescPtr);
 void UnloadSubModule(ModuleDescPtr);
 void UnloadDriver(ModuleDescPtr);
-void FreeModuleDesc(ModuleDescPtr mod);
-ModuleDescPtr NewModuleDesc(const char *);
-ModuleDescPtr AddSibling(ModuleDescPtr head, ModuleDescPtr new);
 void LoaderSetPath(const char *path);
 void LoaderSortExtensions(void);
 
@@ -108,7 +105,6 @@ unsigned long LoaderGetModuleVersion(Mod
 
 void LoaderResetOptions(void);
 void LoaderSetOptions(unsigned long);
-void LoaderClearOptions(unsigned long);
 
 /* Options for LoaderSetOptions */
 #define LDR_OPT_ABI_MISMATCH_NONFATAL		0x0001
diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index a83b889..db12da4 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -745,6 +745,13 @@ CheckVersion(const char *module, XF86Mod
     return TRUE;
 }
 
+static ModuleDescPtr
+AddSibling(ModuleDescPtr head, ModuleDescPtr new)
+{
+    new->sib = head;
+    return (new);
+}
+
 _X_EXPORT ModuleDescPtr
 LoadSubModule(ModuleDescPtr parent, const char *module,
 	      const char **subdirlist, const char **patternlist,
@@ -775,35 +782,28 @@ LoadSubModule(ModuleDescPtr parent, cons
     return submod;
 }
 
-ModuleDescPtr
-LoadSubModuleLocal(ModuleDescPtr parent, const char *module,
-		   const char **subdirlist, const char **patternlist,
-		   pointer options, const XF86ModReqInfo * modreq,
-		   int *errmaj, int *errmin)
+static ModuleDescPtr
+NewModuleDesc(const char *name)
 {
-    ModuleDescPtr submod;
-
-    xf86MsgVerb(X_INFO, 3, "Loading local sub module \"%s\"\n", module);
+    ModuleDescPtr mdp = xalloc(sizeof(ModuleDesc));
 
-    if (PathIsAbsolute(module))
-    {
-	xf86Msg(X_ERROR,
-		"LoadSubModule: Absolute module path not permitted: \"%s\"\n",
-		module);
-	if (errmaj)
-	    *errmaj = LDR_BADUSAGE;
-	if (errmin)
-	    *errmin = 0;
-	return NULL;
+    if (mdp) {
+	mdp->child = NULL;
+	mdp->sib = NULL;
+	mdp->parent = NULL;
+	mdp->demand_next = NULL;
+	mdp->name = xstrdup(name);
+	mdp->filename = NULL;
+	mdp->identifier = NULL;
+	mdp->client_id = 0;
+	mdp->in_use = 0;
+	mdp->handle = -1;
+	mdp->SetupProc = NULL;
+	mdp->TearDownProc = NULL;
+	mdp->TearDownData = NULL;
     }
 
-    submod = doLoadModule(module, NULL, subdirlist, patternlist, options,
-			  modreq, errmaj, errmin, 0);
-    if (submod && submod != (ModuleDescPtr) 1) {
-	parent->child = AddSibling(parent->child, submod);
-	submod->parent = parent;
-    }
-    return submod;
+    return (mdp);
 }
 
 _X_EXPORT ModuleDescPtr
@@ -1099,26 +1099,12 @@ LoadModule(const char *module, const cha
 		      modreq, errmaj, errmin, LD_FLAG_GLOBAL);
 }
 
-ModuleDescPtr
-LoadDriver(const char *module, const char *path, int handle, pointer options,
-	   int *errmaj, int *errmin)
-{
-    return LoadModule(module, path, NULL, NULL, options, NULL, errmaj,
-		      errmin);
-}
-
 void
 UnloadModule(ModuleDescPtr mod)
 {
     UnloadModuleOrDriver(mod);
 }
 
-void
-UnloadDriver(ModuleDescPtr mod)
-{
-    UnloadModuleOrDriver(mod);
-}
-
 static void
 UnloadModuleOrDriver(ModuleDescPtr mod)
 {
@@ -1168,7 +1154,7 @@ UnloadSubModule(ModuleDescPtr mod)
     xfree(mod);
 }
 
-void
+static void
 FreeModuleDesc(ModuleDescPtr head)
 {
     ModuleDescPtr sibs, prev;
@@ -1177,7 +1163,7 @@ FreeModuleDesc(ModuleDescPtr head)
 	return;
     /*
      * only free it if it's not marked as in use. In use means that it may
-     * be unloaded someday, and UnloadModule or UnloadDriver will free it
+     * be unloaded someday, and UnloadModule will free it
      */
     if (head->in_use)
 	return;
@@ -1192,38 +1178,6 @@ FreeModuleDesc(ModuleDescPtr head)
     }
 }
 
-ModuleDescPtr
-NewModuleDesc(const char *name)
-{
-    ModuleDescPtr mdp = xalloc(sizeof(ModuleDesc));
-
-    if (mdp) {
-	mdp->child = NULL;
-	mdp->sib = NULL;
-	mdp->parent = NULL;
-	mdp->demand_next = NULL;
-	mdp->name = xstrdup(name);
-	mdp->filename = NULL;
-	mdp->identifier = NULL;
-	mdp->client_id = 0;
-	mdp->in_use = 0;
-	mdp->handle = -1;
-	mdp->SetupProc = NULL;
-	mdp->TearDownProc = NULL;
-	mdp->TearDownData = NULL;
-    }
-
-    return (mdp);
-}
-
-ModuleDescPtr
-AddSibling(ModuleDescPtr head, ModuleDescPtr new)
-{
-    new->sib = head;
-    return (new);
-
-}
-
 static void
 RemoveChild(ModuleDescPtr child)
 {
diff --git a/hw/xfree86/parser/DRI.c b/hw/xfree86/parser/DRI.c
index dc75cd2..18644bc 100644
--- a/hw/xfree86/parser/DRI.c
+++ b/hw/xfree86/parser/DRI.c
@@ -48,7 +48,21 @@ static xf86ConfigSymTabRec DRITab[] =
 
 #define CLEANUP xf86freeBuffersList
 
-XF86ConfBuffersPtr
+static void
+xf86freeBuffersList (XF86ConfBuffersPtr ptr)
+{
+    XF86ConfBuffersPtr prev;
+
+    while (ptr) {
+	TestFree (ptr->buf_flags);
+	TestFree (ptr->buf_comment);
+	prev = ptr;
+	ptr  = ptr->list.next;
+	xf86conffree (prev);
+    }
+}
+
+static XF86ConfBuffersPtr
 xf86parseBuffers (void)
 {
     int token;
@@ -169,18 +183,3 @@ xf86freeDRI (XF86ConfDRIPtr ptr)
     TestFree (ptr->dri_comment);
     xf86conffree (ptr);
 }
-
-void
-xf86freeBuffersList (XF86ConfBuffersPtr ptr)
-{
-    XF86ConfBuffersPtr prev;
-
-    while (ptr) {
-	TestFree (ptr->buf_flags);
-	TestFree (ptr->buf_comment);
-	prev = ptr;
-	ptr  = ptr->list.next;
-	xf86conffree (prev);
-    }
-}
-
diff --git a/hw/xfree86/parser/Flags.c b/hw/xfree86/parser/Flags.c
index 7ab70d1..4adea1a 100644
--- a/hw/xfree86/parser/Flags.c
+++ b/hw/xfree86/parser/Flags.c
@@ -441,15 +441,6 @@ xf86uLongToString(unsigned long i)
 	return s;
 }
 
-void
-xf86debugListOptions(XF86OptionPtr Options)
-{
-	while (Options) {
-		ErrorF("Option: %s Value: %s\n",Options->opt_name,Options->opt_val);
-		Options = Options->list.next;
-	}
-}
-
 XF86OptionPtr
 xf86parseOption(XF86OptionPtr head)
 {
diff --git a/hw/xfree86/parser/Layout.c b/hw/xfree86/parser/Layout.c
index b9f4e9e..5d1348a 100644
--- a/hw/xfree86/parser/Layout.c
+++ b/hw/xfree86/parser/Layout.c
@@ -382,24 +382,7 @@ xf86printLayoutSection (FILE * cf, XF86C
 	}
 }
 
-void
-xf86freeLayoutList (XF86ConfLayoutPtr ptr)
-{
-	XF86ConfLayoutPtr prev;
-
-	while (ptr)
-	{
-		TestFree (ptr->lay_identifier);
-		TestFree (ptr->lay_comment);
-		xf86freeAdjacencyList (ptr->lay_adjacency_lst);
-		xf86freeInputrefList (ptr->lay_input_lst);
-		prev = ptr;
-		ptr = ptr->list.next;
-		xf86conffree (prev);
-	}
-}
-
-void
+static void
 xf86freeAdjacencyList (XF86ConfAdjacencyPtr ptr)
 {
 	XF86ConfAdjacencyPtr prev;
@@ -419,7 +402,7 @@ xf86freeAdjacencyList (XF86ConfAdjacency
 
 }
 
-void
+static void
 xf86freeInputrefList (XF86ConfInputrefPtr ptr)
 {
 	XF86ConfInputrefPtr prev;
@@ -435,6 +418,23 @@ xf86freeInputrefList (XF86ConfInputrefPt
 
 }
 
+void
+xf86freeLayoutList (XF86ConfLayoutPtr ptr)
+{
+	XF86ConfLayoutPtr prev;
+
+	while (ptr)
+	{
+		TestFree (ptr->lay_identifier);
+		TestFree (ptr->lay_comment);
+		xf86freeAdjacencyList (ptr->lay_adjacency_lst);
+		xf86freeInputrefList (ptr->lay_input_lst);
+		prev = ptr;
+		ptr = ptr->list.next;
+		xf86conffree (prev);
+	}
+}
+
 #define CheckScreen(str, ptr)\
 if (str[0] != '\0') \
 { \
diff --git a/hw/xfree86/parser/Module.c b/hw/xfree86/parser/Module.c
index f3ed9d1..81eff18 100644
--- a/hw/xfree86/parser/Module.c
+++ b/hw/xfree86/parser/Module.c
@@ -83,7 +83,7 @@ static xf86ConfigSymTabRec ModuleTab[] =
 
 #define CLEANUP xf86freeModules
 
-XF86LoadPtr
+static XF86LoadPtr
 xf86parseModuleSubSection (XF86LoadPtr head, char *name)
 {
 	int token;
diff --git a/hw/xfree86/parser/Monitor.c b/hw/xfree86/parser/Monitor.c
index 9dd0b1b..4bff4b2 100644
--- a/hw/xfree86/parser/Monitor.c
+++ b/hw/xfree86/parser/Monitor.c
@@ -124,7 +124,21 @@ static xf86ConfigSymTabRec ModeTab[] =
 
 #define CLEANUP xf86freeModeLineList
 
-XF86ConfModeLinePtr
+static void
+xf86freeModeLineList (XF86ConfModeLinePtr ptr)
+{
+	XF86ConfModeLinePtr prev;
+	while (ptr)
+	{
+		TestFree (ptr->ml_identifier);
+		TestFree (ptr->ml_comment);
+		prev = ptr;
+		ptr = ptr->list.next;
+		xf86conffree (prev);
+	}
+}
+
+static XF86ConfModeLinePtr
 xf86parseModeLine (void)
 {
 	int token;
@@ -253,7 +267,7 @@ xf86parseModeLine (void)
 	return (ptr);
 }
 
-XF86ConfModeLinePtr
+static XF86ConfModeLinePtr
 xf86parseVerboseMode (void)
 {
 	int token, token2;
@@ -830,20 +844,6 @@ xf86freeModesList (XF86ConfModesPtr ptr)
 	}
 }
 
-void
-xf86freeModeLineList (XF86ConfModeLinePtr ptr)
-{
-	XF86ConfModeLinePtr prev;
-	while (ptr)
-	{
-		TestFree (ptr->ml_identifier);
-		TestFree (ptr->ml_comment);
-		prev = ptr;
-		ptr = ptr->list.next;
-		xf86conffree (prev);
-	}
-}
-
 XF86ConfMonitorPtr
 xf86findMonitor (const char *ident, XF86ConfMonitorPtr p)
 {
diff --git a/hw/xfree86/parser/configProcs.h b/hw/xfree86/parser/configProcs.h
index 0b98905..e3961a9 100644
--- a/hw/xfree86/parser/configProcs.h
+++ b/hw/xfree86/parser/configProcs.h
@@ -49,25 +49,19 @@ int xf86validateInput (XF86ConfigPtr p);
 XF86ConfLayoutPtr xf86parseLayoutSection(void);
 void xf86printLayoutSection(FILE *cf, XF86ConfLayoutPtr ptr);
 void xf86freeLayoutList(XF86ConfLayoutPtr ptr);
-void xf86freeAdjacencyList(XF86ConfAdjacencyPtr ptr);
-void xf86freeInputrefList(XF86ConfInputrefPtr ptr);
 int xf86validateLayout(XF86ConfigPtr p);
 /* Module.c */
-XF86LoadPtr xf86parseModuleSubSection(XF86LoadPtr head, char *name);
 XF86ConfModulePtr xf86parseModuleSection(void);
 void xf86printModuleSection(FILE *cf, XF86ConfModulePtr ptr);
 XF86LoadPtr xf86addNewLoadDirective(XF86LoadPtr head, char *name, int type, XF86OptionPtr opts);
 void xf86freeModules(XF86ConfModulePtr ptr);
 /* Monitor.c */
-XF86ConfModeLinePtr xf86parseModeLine(void);
-XF86ConfModeLinePtr xf86parseVerboseMode(void);
 XF86ConfMonitorPtr xf86parseMonitorSection(void);
 XF86ConfModesPtr xf86parseModesSection(void);
 void xf86printMonitorSection(FILE *cf, XF86ConfMonitorPtr ptr);
 void xf86printModesSection(FILE *cf, XF86ConfModesPtr ptr);
 void xf86freeMonitorList(XF86ConfMonitorPtr ptr);
 void xf86freeModesList(XF86ConfModesPtr ptr);
-void xf86freeModeLineList(XF86ConfModeLinePtr ptr);
 int xf86validateMonitor(XF86ConfigPtr p, XF86ConfScreenPtr screen);
 /* Pointer.c */
 XF86ConfInputPtr xf86parsePointerSection(void);
@@ -92,24 +86,18 @@ XF86ConfVideoAdaptorPtr xf86parseVideoAd
 void xf86printVideoAdaptorSection(FILE *cf, XF86ConfVideoAdaptorPtr ptr);
 void xf86freeVideoAdaptorList(XF86ConfVideoAdaptorPtr ptr);
 void xf86freeVideoPortList(XF86ConfVideoPortPtr ptr);
-/* read.c */
-int xf86validateConfig(XF86ConfigPtr p);
 /* scan.c */
-unsigned int xf86strToUL(char *str);
 int xf86getToken(xf86ConfigSymTabRec *tab);
 int xf86getSubToken(char **comment);
 int xf86getSubTokenWithTab(char **comment, xf86ConfigSymTabRec *tab);
 void xf86unGetToken(int token);
 char *xf86tokenString(void);
 void xf86parseError(char *format, ...);
-void xf86parseWarning(char *format, ...);
 void xf86validationError(char *format, ...);
 void xf86setSection(char *section);
 int xf86getStringToken(xf86ConfigSymTabRec *tab);
 /* write.c */
 /* DRI.c */
-XF86ConfBuffersPtr xf86parseBuffers (void);
-void xf86freeBuffersList (XF86ConfBuffersPtr ptr);
 XF86ConfDRIPtr xf86parseDRISection (void);
 void xf86printDRISection (FILE * cf, XF86ConfDRIPtr ptr);
 void xf86freeDRI (XF86ConfDRIPtr ptr);
diff --git a/hw/xfree86/parser/read.c b/hw/xfree86/parser/read.c
index b6b3bc3..9f79696 100644
--- a/hw/xfree86/parser/read.c
+++ b/hw/xfree86/parser/read.c
@@ -73,6 +73,25 @@ static xf86ConfigSymTabRec TopLevelTab[]
 
 #define CLEANUP xf86freeConfig
 
+/* 
+ * This function resolves name references and reports errors if the named
+ * objects cannot be found.
+ */
+static int
+xf86validateConfig (XF86ConfigPtr p)
+{
+	if (!xf86validateDevice (p))
+		return FALSE;
+	if (!xf86validateScreen (p))
+		return FALSE;
+	if (!xf86validateInput (p))
+		return FALSE;
+	if (!xf86validateLayout (p))
+		return FALSE;
+
+	return (TRUE);
+}
+
 XF86ConfigPtr
 xf86readConfigFile (void)
 {
@@ -219,25 +238,6 @@ xf86readConfigFile (void)
 #undef CLEANUP
 
 /* 
- * This function resolves name references and reports errors if the named
- * objects cannot be found.
- */
-int
-xf86validateConfig (XF86ConfigPtr p)
-{
-	if (!xf86validateDevice (p))
-		return FALSE;
-	if (!xf86validateScreen (p))
-		return FALSE;
-	if (!xf86validateInput (p))
-		return FALSE;
-	if (!xf86validateLayout (p))
-		return FALSE;
-
-	return (TRUE);
-}
-
-/* 
  * adds an item to the end of the linked list. Any record whose first field
  * is a GenericListRec can be cast to this type and used with this function.
  * A pointer to the head of the list is returned to handle the addition of
diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index f81c45a..68e7ec6 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -116,7 +116,7 @@ extern char *__XOS2RedirRoot(char *path)
  *  A portable, but restricted, version of strtoul().  It only understands
  *  hex, octal, and decimal.  But it's good enough for our needs.
  */
-unsigned int
+static unsigned int
 xf86strToUL (char *str)
 {
 	int base = 10;
@@ -922,20 +922,6 @@ xf86parseError (char *format,...)
 }
 
 void
-xf86parseWarning (char *format,...)
-{
-	va_list ap;
-
-	ErrorF ("Parse warning on line %d of section %s in file %s\n\t",
-		 configLineNo, configSection, configPath);
-	va_start (ap, format);
-	VErrorF (format, ap);
-	va_end (ap);
-
-	ErrorF ("\n");
-}
-
-void
 xf86validationError (char *format,...)
 {
 	va_list ap;
diff --git a/hw/xfree86/xf4bpp/Makefile.am b/hw/xfree86/xf4bpp/Makefile.am
index 8fddb6b..5eab92f 100644
--- a/hw/xfree86/xf4bpp/Makefile.am
+++ b/hw/xfree86/xf4bpp/Makefile.am
@@ -20,7 +20,6 @@ libxf4bpp_la_SOURCES = \
         ppcPixmap.c \
         ppcPntWin.c \
         ppcPolyPnt.c \
-        ppcPolyRec.c \
         ppcQuery.c \
         ppcRslvC.c \
         ppcSetSp.c \
diff --git a/hw/xfree86/xf4bpp/offscreen.c b/hw/xfree86/xf4bpp/offscreen.c
index f35bde7..654be82 100644
--- a/hw/xfree86/xf4bpp/offscreen.c
+++ b/hw/xfree86/xf4bpp/offscreen.c
@@ -301,25 +301,6 @@ DoMono
 }
 
 void
-xf4bppOffDrawMonoImage( pWin, data, x, y, w, h, fg, alu, planes )
-WindowPtr pWin; /* GJA */
-unsigned char *data;
-int x, y, w, h ;
-unsigned long int fg ;
-int alu ;
-unsigned long int planes;
-{
-
-	if ( ( alu == GXnoop ) || !( planes &= VGA_ALLPLANES ) )
-		return ;
-
-	DoMono( pWin, w, x, y, (const unsigned char *) data, h,
-		      w, ( ( w + 31 ) & ~31 ) >> 3, h, 0, 0, alu,
-		      (int)planes, (int)fg) ;
-
-}
-
-void
 xf4bppOffFillStipple( pWin, pStipple, fg, alu, planes, x, y, w, h, xSrc, ySrc )
 WindowPtr pWin; /* GJA */
 register PixmapPtr const pStipple ;
diff --git a/hw/xfree86/xf4bpp/ppcGC.c b/hw/xfree86/xf4bpp/ppcGC.c
index 8153051..81441ef 100644
--- a/hw/xfree86/xf4bpp/ppcGC.c
+++ b/hw/xfree86/xf4bpp/ppcGC.c
@@ -90,10 +90,9 @@ SOFTWARE.
 | GCFunction | GCPlaneMask | GCFillStyle | GC_CALL_VALIDATE_BIT         \
 | GCClipXOrigin | GCClipYOrigin | GCClipMask | GCSubwindowMode )
 
+static void xf4bppValidateGC(GCPtr, unsigned long, DrawablePtr);
+static void xf4bppDestroyGC(GC *);
 
-/* GJA -- we modified the following function to get rid of
- * the records in file vgaData.c
- */
 static GCFuncs vgaGCFuncs = {
 	xf4bppValidateGC,
 	(void (*)(GCPtr, unsigned long))NoopDDA,
@@ -196,7 +195,7 @@ register GCPtr pGC ;
 	return TRUE ;
 }
 
-void
+static void
 xf4bppDestroyGC( pGC )
     register GC	*pGC ;
 
@@ -292,7 +291,7 @@ return 0 ;
 	    CT_other ==> pCompositeClip is the pixmap bounding box
 */
 
-void
+static void
 xf4bppValidateGC( pGC, changes, pDrawable )
     GCPtr         pGC;
     unsigned long changes;
diff --git a/hw/xfree86/xf4bpp/xf4bpp.h b/hw/xfree86/xf4bpp/xf4bpp.h
index 8d2da35..01512a8 100644
--- a/hw/xfree86/xf4bpp/xf4bpp.h
+++ b/hw/xfree86/xf4bpp/xf4bpp.h
@@ -149,14 +149,6 @@ void xf4bppTilePixmapFS(
 Bool xf4bppCreateGC(
     GCPtr
 );
-void xf4bppDestroyGC(
-    GC *
-);
-void xf4bppValidateGC(
-    GCPtr,
-    unsigned long,
-    DrawablePtr
-);
 
 /* ppcGetSp.c */
 void xf4bppGetSpans(
diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c
index 57f3a68..1ec0609 100644
--- a/hw/xnest/Display.c
+++ b/hw/xnest/Display.c
@@ -39,7 +39,7 @@ XVisualInfo *xnestVisuals;
 int xnestNumVisuals;
 int xnestDefaultVisualIndex;
 Colormap *xnestDefaultColormaps;
-int xnestNumDefaultColormaps;
+static int xnestNumDefaultColormaps;
 int *xnestDepths;
 int xnestNumDepths;
 XPixmapFormatValues *xnestPixmapFormats;
diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c
index e6870e7..e66b4f7 100644
--- a/hw/xnest/Screen.c
+++ b/hw/xnest/Screen.c
@@ -49,7 +49,7 @@ Window xnestScreenSaverWindows[MAXSCREEN
 extern void GlxWrapInitVisuals(miInitVisualsProcPtr *);
 #endif
 
-int xnestScreenGeneration = -1;
+static int xnestScreenGeneration = -1;
 
 ScreenPtr
 xnestScreen(Window window)
diff --git a/include/globals.h b/include/globals.h
index 821b12b..e23ce77 100644
--- a/include/globals.h
+++ b/include/globals.h
@@ -44,10 +44,6 @@ extern Bool DPMSCapableFlag;
 #endif
 
 #ifdef PANORAMIX
-extern Bool PanoramiXMapped;
-extern Bool PanoramiXVisibilityNotifySent;
-extern Bool PanoramiXWindowExposureSent;
-extern Bool PanoramiXOneExposeRequest;
 extern Bool PanoramiXExtensionDisabledHack;
 #endif
 
diff --git a/include/inputstr.h b/include/inputstr.h
index ada94e6..8f4e9b9 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -62,7 +62,7 @@ SOFTWARE.
 
 #define EMASKSIZE	MAX_DEVICES
 
-extern int CoreDevicePrivatesIndex, CoreDevicePrivatesGeneration;
+extern int CoreDevicePrivatesIndex;
 
 /* Kludge: OtherClients and InputClients must be compatible, see code */
 
diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index 5724a6f..9701001 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -54,8 +54,8 @@ typedef struct {
 } miOverlayScreenRec, *miOverlayScreenPtr;
 
 static unsigned long miOverlayGeneration = 0;
-int miOverlayWindowIndex = -1;
-int miOverlayScreenIndex = -1;
+static int miOverlayWindowIndex = -1;
+static int miOverlayScreenIndex = -1;
 
 static void RebuildTree(WindowPtr);
 static Bool HasUnderlayChildren(WindowPtr);
diff --git a/mi/miscrinit.c b/mi/miscrinit.c
index 7922cb6..08cc3f6 100644
--- a/mi/miscrinit.c
+++ b/mi/miscrinit.c
@@ -312,7 +312,7 @@ miAllocateGCPrivateIndex()
 }
 
 _X_EXPORT int miZeroLineScreenIndex;
-unsigned int miZeroLineGeneration = 0;
+static unsigned int miZeroLineGeneration = 0;
 
 _X_EXPORT void
 miSetZeroLineBias(pScreen, bias)
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index cd66b54..6f1ee28 100755
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -72,6 +72,12 @@
 
 #define pixmapDamage(pPixmap)		damagePixPriv(pPixmap)
 
+static int damageScrPrivateIndex;
+static int damagePixPrivateIndex;
+static int damageGCPrivateIndex;
+static int damageWinPrivateIndex;
+static int damageGeneration;
+
 static DamagePtr *
 getDrawableDamageRef (DrawablePtr pDrawable)
 {
@@ -368,12 +374,12 @@ static void damageChangeClip(GCPtr, int,
 static void damageDestroyClip(GCPtr);
 static void damageCopyClip(GCPtr, GCPtr);
 
-GCFuncs damageGCFuncs = {
+static GCFuncs damageGCFuncs = {
     damageValidateGC, damageChangeGC, damageCopyGC, damageDestroyGC,
     damageChangeClip, damageDestroyClip, damageCopyClip
 };
 
-extern GCOps damageGCOps;
+static GCOps damageGCOps;
 
 static Bool
 damageCreateGC(GCPtr pGC)
@@ -1686,7 +1692,7 @@ damageCopyWindow(WindowPtr	pWindow,
     wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow);
 }
 
-GCOps damageGCOps = {
+static GCOps damageGCOps = {
     damageFillSpans, damageSetSpans,
     damagePutImage, damageCopyArea,
     damageCopyPlane, damagePolyPoint,
@@ -1787,12 +1793,6 @@ damageCloseScreen (int i, ScreenPtr pScr
     return (*pScreen->CloseScreen) (i, pScreen);
 }
 
-int damageScrPrivateIndex;
-int damagePixPrivateIndex;
-int damageGCPrivateIndex;
-int damageWinPrivateIndex;
-int damageGeneration;
-
 Bool
 DamageSetup (ScreenPtr pScreen)
 {
diff --git a/miext/damage/damagestr.h b/miext/damage/damagestr.h
index 93e213f..83a202b 100755
--- a/miext/damage/damagestr.h
+++ b/miext/damage/damagestr.h
@@ -82,11 +82,7 @@ typedef struct _damageGCPriv {
     GCFuncs *funcs;
 } DamageGCPrivRec, *DamageGCPrivPtr;
 
-extern int damageScrPrivateIndex;
-extern int damagePixPrivateIndex;
-extern int damageGCPrivateIndex;
-extern int damageWinPrivateIndex;
-
+/* XXX should move these into damage.c, damageScrPrivateIndex is static */
 #define damageGetScrPriv(pScr) \
     ((DamageScrPrivPtr) (pScr)->devPrivates[damageScrPrivateIndex].ptr)
 
diff --git a/os/connection.c b/os/connection.c
index d0ffb81..cb3443c 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -175,7 +175,7 @@ typedef const char *string;
 # include <ucred.h>
 #endif
 
-int lastfdesc;			/* maximum file descriptor */
+static int lastfdesc;		/* maximum file descriptor */
 
 fd_set WellKnownConnections;	/* Listener mask */
 fd_set EnabledDevices;		/* mask for input devices that are on */
@@ -189,7 +189,7 @@ int MaxClients = 0;
 Bool NewOutputPending;		/* not yet attempted to write some new output */
 Bool AnyClientsWriteBlocked;	/* true if some client blocked on write */
 
-Bool RunFromSmartParent;	/* send SIGUSR1 to parent process */
+static Bool RunFromSmartParent;	/* send SIGUSR1 to parent process */
 Bool PartialNetwork;		/* continue even if unable to bind all addrs */
 static Pid_t ParentProcess;
 #ifdef __UNIXOS2__
@@ -298,9 +298,9 @@ void ClearConnectionTranslation(void)
 }
 #endif
 
-XtransConnInfo 	*ListenTransConns = NULL;
-int	       	*ListenTransFds = NULL;
-int		ListenTransCount;
+static XtransConnInfo 	*ListenTransConns = NULL;
+static int	       	*ListenTransFds = NULL;
+static int		ListenTransCount;
 
 static void ErrorConnMax(XtransConnInfo /* trans_conn */);
 
diff --git a/os/io.c b/os/io.c
index f6c666c..80a151f 100644
--- a/os/io.c
+++ b/os/io.c
@@ -111,11 +111,11 @@ _X_EXPORT CallbackListPtr       FlushCal
 #define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK || err == ENOSPC)
 #endif
 
-Bool CriticalOutputPending;
-int timesThisConnection = 0;
-ConnectionInputPtr FreeInputs = (ConnectionInputPtr)NULL;
-ConnectionOutputPtr FreeOutputs = (ConnectionOutputPtr)NULL;
-OsCommPtr AvailableInput = (OsCommPtr)NULL;
+static Bool CriticalOutputPending;
+static int timesThisConnection = 0;
+static ConnectionInputPtr FreeInputs = (ConnectionInputPtr)NULL;
+static ConnectionOutputPtr FreeOutputs = (ConnectionOutputPtr)NULL;
+static OsCommPtr AvailableInput = (OsCommPtr)NULL;
 
 #define get_req_len(req,cli) ((cli)->swapped ? \
 			      lswaps((req)->length) : (req)->length)
diff --git a/os/osdep.h b/os/osdep.h
index 5fa1e39..3d303f9 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -234,12 +234,6 @@ extern void ClearConnectionTranslation()
  
 extern Bool NewOutputPending;
 extern Bool AnyClientsWriteBlocked;
-extern Bool CriticalOutputPending;
-
-extern int timesThisConnection;
-extern ConnectionInputPtr FreeInputs;
-extern ConnectionOutputPtr FreeOutputs;
-extern OsCommPtr AvailableInput;
 
 extern WorkQueuePtr workQueue;
 
diff --git a/os/utils.c b/os/utils.c
index 06c9b88..2fc5cbb 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -245,10 +245,6 @@ _X_EXPORT Bool noXvExtension = FALSE;
 Bool CoreDump;
 
 #ifdef PANORAMIX
-Bool PanoramiXVisibilityNotifySent = FALSE;
-Bool PanoramiXMapped = FALSE;
-Bool PanoramiXWindowExposureSent = FALSE;
-Bool PanoramiXOneExposeRequest = FALSE;
 Bool PanoramiXExtensionDisabledHack = FALSE;
 #endif
 
@@ -271,7 +267,7 @@ long Memory_fail = 0;
 #include <stdlib.h>  /* for random() */
 #endif
 
-char *dev_tty_from_init = NULL;		/* since we need to parse it anyway */
+static char *dev_tty_from_init = NULL;	/* since we need to parse it anyway */
 
 OsSigHandlerPtr
 OsSignal(sig, handler)
diff --git a/os/xdmcp.c b/os/xdmcp.c
index fd4be5e..cfc1005 100644
--- a/os/xdmcp.c
+++ b/os/xdmcp.c
@@ -411,11 +411,11 @@ XdmcpRegisterAuthentication (
  * set by the manager of the host to be connected to.
  */
 
-ARRAY8		noAuthenticationName = {(CARD16) 0, (CARD8Ptr) 0};
-ARRAY8		noAuthenticationData = {(CARD16) 0, (CARD8Ptr) 0};
-ARRAY8Ptr	AuthenticationName = &noAuthenticationName;
-ARRAY8Ptr	AuthenticationData = &noAuthenticationData;
-AuthenticationFuncsPtr	AuthenticationFuncs;
+static ARRAY8		noAuthenticationName = {(CARD16) 0, (CARD8Ptr) 0};
+static ARRAY8		noAuthenticationData = {(CARD16) 0, (CARD8Ptr) 0};
+static ARRAY8Ptr	AuthenticationName = &noAuthenticationName;
+static ARRAY8Ptr	AuthenticationData = &noAuthenticationData;
+static AuthenticationFuncsPtr	AuthenticationFuncs;
 
 void
 XdmcpSetAuthentication (ARRAY8Ptr name)
@@ -547,7 +547,7 @@ XdmcpRegisterAuthorization (char *name, 
  * Register the DisplayClass string
  */
 
-ARRAY8	DisplayClass;
+static ARRAY8	DisplayClass;
 
 void
 XdmcpRegisterDisplayClass (char *name, int length)
@@ -565,7 +565,7 @@ XdmcpRegisterDisplayClass (char *name, i
  * Register the Manufacturer display ID
  */
 
-ARRAY8 ManufacturerDisplayID;
+static ARRAY8 ManufacturerDisplayID;
 
 void
 XdmcpRegisterManufacturerDisplayID (char *name, int length)
@@ -776,7 +776,7 @@ XdmcpAddHost(
  * do the appropriate thing
  */
 
-ARRAY8	UnwillingMessage = { (CARD8) 14, (CARD8 *) "Host unwilling" };
+static ARRAY8	UnwillingMessage = { (CARD8) 14, (CARD8 *) "Host unwilling" };
 
 static void
 receive_packet(int socketfd)
diff --git a/render/animcur.c b/render/animcur.c
index 8e4f59d..1f25e79 100644
--- a/render/animcur.c
+++ b/render/animcur.c
@@ -87,8 +87,8 @@ static CursorBits   animCursorBits = {
     empty, empty, 2, 1, 1, 0, 0, 1
 };
 
-int	AnimCurScreenPrivateIndex = -1;
-int	AnimCurGeneration;
+static int AnimCurScreenPrivateIndex = -1;
+static int AnimCurGeneration;
 
 #define IsAnimCur(c)	    ((c)->bits == &animCursorBits)
 #define GetAnimCur(c)	    ((AnimCurPtr) ((c) + 1))
diff --git a/render/glyph.c b/render/glyph.c
index 6d09a0e..5987cbc 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -77,11 +77,11 @@ static GlyphHashSetRec glyphHashSets[] =
 
 #define NGLYPHHASHSETS	(sizeof(glyphHashSets)/sizeof(glyphHashSets[0]))
 
-const CARD8	glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 };
+static const CARD8	glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 };
 
-GlyphHashRec	globalGlyphs[GlyphFormatNum];
+static GlyphHashRec	globalGlyphs[GlyphFormatNum];
 
-int		globalTotalGlyphPrivateSize = 0;
+static int	globalTotalGlyphPrivateSize = 0;
 
 static int	glyphPrivateCount = 0;
 
diff --git a/render/glyphstr.h b/render/glyphstr.h
index 64cedfa..22150de 100644
--- a/render/glyphstr.h
+++ b/render/glyphstr.h
@@ -91,8 +91,6 @@ typedef struct _GlyphList {
     PictFormatPtr   format;
 } GlyphListRec, *GlyphListPtr;
 
-extern GlyphHashRec	globalGlyphs[GlyphFormatNum];
-
 GlyphHashSetPtr
 FindGlyphHashSet (CARD32 filled);
 
diff --git a/render/picture.c b/render/picture.c
index e7901e8..c30649c 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -43,7 +43,7 @@
 
 _X_EXPORT int	PictureScreenPrivateIndex = -1;
 int		PictureWindowPrivateIndex;
-int		PictureGeneration;
+static int	PictureGeneration;
 RESTYPE		PictureType;
 RESTYPE		PictFormatType;
 RESTYPE		GlyphSetType;
diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c
index cee9e09..32dee8a 100755
--- a/xfixes/xfixes.c
+++ b/xfixes/xfixes.c
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * Copyright © 2006 Sun Microsystems
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
@@ -55,10 +53,10 @@
 #define SERVER_XFIXES_MAJOR 4
 #define SERVER_XFIXES_MINOR 0
 
-unsigned char	XFixesReqCode;
+static unsigned char	XFixesReqCode;
 int		XFixesEventBase;
 int		XFixesErrorBase;
-int		XFixesClientPrivateIndex;
+static int	XFixesClientPrivateIndex;
 
 static int
 ProcXFixesQueryVersion(ClientPtr client)
@@ -169,7 +167,7 @@ SProcXFixesQueryVersion(ClientPtr client
     return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
 }
 
-int	(*SProcXFixesVector[XFixesNumberRequests])(ClientPtr) = {
+static int (*SProcXFixesVector[XFixesNumberRequests])(ClientPtr) = {
 /*************** Version 1 ******************/
     SProcXFixesQueryVersion,
     SProcXFixesChangeSaveSet,
diff --git a/xfixes/xfixesint.h b/xfixes/xfixesint.h
index 5f08807..7f3b119 100755
--- a/xfixes/xfixesint.h
+++ b/xfixes/xfixesint.h
@@ -61,9 +61,7 @@
 #include "selection.h"
 #include "xfixes.h"
 
-extern unsigned char	XFixesReqCode;
 extern int		XFixesEventBase;
-extern int		XFixesClientPrivateIndex;
 
 typedef struct _XFixesClient {
     CARD32	major_version;
@@ -73,7 +71,6 @@ typedef struct _XFixesClient {
 #define GetXFixesClient(pClient)    ((XFixesClientPtr) (pClient)->devPrivates[XFixesClientPrivateIndex].ptr)
 
 extern int	(*ProcXFixesVector[XFixesNumberRequests])(ClientPtr);
-extern int	(*SProcXFixesVector[XFixesNumberRequests])(ClientPtr);
 
 /* Initialize extension at server startup time */
 
diff-tree ac2356843e38b3400142bc54b65393c12976fc07 (from 1072b88a8f352484e70bc749e300c936e5600480)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Sun Mar 25 09:41:33 2007 +0930

    dix: Increase allocation size for core keyboard keymap to avoid buffer overrun when copying keymap from extension devices.

diff --git a/dix/devices.c b/dix/devices.c
index f738419..5996b75 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -238,7 +238,7 @@ CoreKeyboardProc(DeviceIntPtr pDev, int 
         keySyms.mapWidth = 4;
         keySyms.map = (KeySym *)xcalloc(sizeof(KeySym),
                                         (keySyms.maxKeyCode -
-                                         keySyms.minKeyCode) *
+                                         keySyms.minKeyCode + 1) *
                                         keySyms.mapWidth);
         if (!keySyms.map) {
             ErrorF("Couldn't allocate core keymap\n");
diff-tree 1072b88a8f352484e70bc749e300c936e5600480 (from 804080a7096347d48c686f2c8fbfd06326bce400)
Author: Dave Airlie <airlied at linux.ie>
Date:   Sun Mar 25 10:06:00 2007 +1000

    loader: fix already built-in message

diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index c220d8a..a83b889 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 alread ybuilt-in");
+	    xf86MsgVerb(X_INFO, 3, "Module already built-in\n");
 	    return (ModuleDescPtr) 1;
 	}
 
diff-tree 804080a7096347d48c686f2c8fbfd06326bce400 (from 1f77120775dc05fc84a00dd55190af2fa50ae509)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Fri Mar 23 23:41:36 2007 -0700

    Make pending properties force mode set. And, remove AttachScreen calls.
    
    Yes, two changes in one commit. Sorry 'bout that.
    
    The first change ensures that when pending property values have been
    changed, a mode set to the current mode will actually do something, rather
    than being identified as a no-op. In addition, the driver no longer needs to
    manage the migration of pending to current values, that is handled both
    within the xf86 mode setting code (to deal with non-RandR changes) as well
    as within the RandR extension itself.
    
    The second change eliminates the two-call Create/AttachScreen stuff that was
    done in a failed attempt to create RandR resources before the screen
    structures were allocated. Merging these back into the Create function is
    cleaner.
    (cherry picked from commit 57e87e0d006cbf1f5b175fe02eeb981f741d92f0)
    
    Conflicts:
    
    	randr/randrstr.h
    	randr/rrcrtc.c
    
    I think master and server-1.3-branch are more in sync now.

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index b9895d9..7d86b66 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -312,7 +312,13 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, Displ
     {
 	xf86OutputPtr output = xf86_config->output[i];
 	if (output->crtc == crtc)
+	{
 	    output->funcs->commit(output);
+#ifdef RANDR_12_INTERFACE
+	    if (output->randr_output)
+		RRPostPendingProperties (output->randr_output);
+#endif
+	}
     }
 
     /* XXX free adjustedmode */
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 4213fea..6f52ee2 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -1011,8 +1011,7 @@ xf86RandR12CreateObjects12 (ScreenPtr pS
     {
 	xf86CrtcPtr    crtc = config->crtc[c];
 	
-	crtc->randr_crtc = RRCrtcCreate (crtc);
-	RRCrtcAttachScreen (crtc->randr_crtc, pScreen);
+	crtc->randr_crtc = RRCrtcCreate (pScreen, crtc);
 	RRCrtcGammaSetSize (crtc->randr_crtc, 256);
     }
     /*
@@ -1022,13 +1021,13 @@ xf86RandR12CreateObjects12 (ScreenPtr pS
     {
 	xf86OutputPtr	output = config->output[o];
 
-	output->randr_output = RROutputCreate (output->name, 
+	output->randr_output = RROutputCreate (pScreen, output->name, 
 					       strlen (output->name),
 					       output);
-	RROutputAttachScreen (output->randr_output, pScreen);
 
 	if (output->funcs->create_resources != NULL)
 	    output->funcs->create_resources(output);
+	RRPostPendingProperties (output->randr_output);
     }
     return TRUE;
 }
diff --git a/randr/mirandr.c b/randr/mirandr.c
index 47136fb..3c4991e 100644
--- a/randr/mirandr.c
+++ b/randr/mirandr.c
@@ -133,20 +133,13 @@ miRandRInit (ScreenPtr pScreen)
     if (!mode)
 	return FALSE;
     
-    crtc = RRCrtcCreate (NULL);
+    crtc = RRCrtcCreate (pScreen, NULL);
     if (!crtc)
 	return FALSE;
-    if (!RRCrtcAttachScreen (crtc, pScreen))
-    {
-	RRCrtcDestroy (crtc);
-	return FALSE;
-    }
     
-    output = RROutputCreate ("screen", 6, NULL);
+    output = RROutputCreate (pScreen, "screen", 6, NULL);
     if (!output)
 	return FALSE;
-    if (!RROutputAttachScreen (output, pScreen))
-	return FALSE;
     if (!RROutputSetClones (output, NULL, 0))
 	return FALSE;
     if (!RROutputSetModes (output, &mode, 1, 0))
diff --git a/randr/randrstr.h b/randr/randrstr.h
index 9f039f7..4cc3a46 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -138,6 +138,7 @@ struct _rrOutput {
     RRModePtr	    *userModes;
     Bool	    changed;
     RRPropertyPtr   properties;
+    Bool	    pendingProperties;
     void	    *devPrivate;
 };
 
@@ -496,16 +497,14 @@ RRCrtcChanged (RRCrtcPtr crtc, Bool layo
  * Create a CRTC
  */
 RRCrtcPtr
-RRCrtcCreate (void	*devPrivate);
+RRCrtcCreate (ScreenPtr pScreen, void	*devPrivate);
 
 /*
- * Attach a CRTC to a screen. Once done, this cannot be
- * undone without destroying the CRTC; it is separate from Create
- * only to allow an xf86-based driver to create objects in preinit
+ * Set the allowed rotations on a CRTC
  */
-Bool
-RRCrtcAttachScreen (RRCrtcPtr crtc, ScreenPtr pScreen);
-    
+void
+RRCrtcSetRotations (RRCrtcPtr crtc, Rotation rotations);
+
 /*
  * Notify the extension that the Crtc has been reconfigured,
  * the driver calls this whenever it has updated the mode
@@ -562,13 +561,6 @@ RRCrtcGammaSetSize (RRCrtcPtr	crtc,
 		    int		size);
 
 /*
- * Set the allowable rotations of the CRTC.
- */
-Bool
-RRCrtcSetRotations (RRCrtcPtr crtc,
-		    Rotation rotations);
-
-/*
  * Return the area of the frame buffer scanned out by the crtc,
  * taking into account the current mode and rotation
  */
@@ -670,19 +662,12 @@ RROutputChanged (RROutputPtr output, Boo
  */
 
 RROutputPtr
-RROutputCreate (const char  *name,
+RROutputCreate (ScreenPtr   pScreen,
+		const char  *name,
 		int	    nameLength,
 		void	    *devPrivate);
 
 /*
- * Attach an output to a screen, again split from creation so
- * xf86 DDXen can create randr resources before the ScreenRec
- * exists
- */
-Bool
-RROutputAttachScreen (RROutputPtr output, ScreenPtr pScreen);
-
-/*
  * Notify extension that output parameters have been changed
  */
 Bool
@@ -762,7 +747,7 @@ void
 RRDeleteOutputProperty (RROutputPtr output, Atom property);
 
 Bool
-RRPostPendingProperty (RROutputPtr output, Atom property);
+RRPostPendingProperties (RROutputPtr output);
     
 int
 RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 7131dfb..1dfc3bb 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -51,17 +51,32 @@ RRCrtcChanged (RRCrtcPtr crtc, Bool layo
  * Create a CRTC
  */
 RRCrtcPtr
-RRCrtcCreate (void	*devPrivate)
+RRCrtcCreate (ScreenPtr pScreen, void *devPrivate)
 {
-    RRCrtcPtr	crtc;
-    
+    RRCrtcPtr	    crtc;
+    RRCrtcPtr	    *crtcs;
+    rrScrPrivPtr    pScrPriv;
+
     if (!RRInit())
 	return NULL;
+    
+    pScrPriv = rrGetScrPriv(pScreen);
+
+    /* make space for the crtc pointer */
+    if (pScrPriv->numCrtcs)
+	crtcs = xrealloc (pScrPriv->crtcs, 
+			  (pScrPriv->numCrtcs + 1) * sizeof (RRCrtcPtr));
+    else
+	crtcs = xalloc (sizeof (RRCrtcPtr));
+    if (!crtcs)
+	return FALSE;
+    pScrPriv->crtcs = crtcs;
+    
     crtc = xalloc (sizeof (RRCrtcRec));
     if (!crtc)
 	return NULL;
     crtc->id = FakeClientID (0);
-    crtc->pScreen = NULL;
+    crtc->pScreen = pScreen;
     crtc->mode = NULL;
     crtc->x = 0;
     crtc->y = 0;
@@ -77,37 +92,20 @@ RRCrtcCreate (void	*devPrivate)
     if (!AddResource (crtc->id, RRCrtcType, (pointer) crtc))
 	return NULL;
 
+    /* attach the screen and crtc together */
+    crtc->pScreen = pScreen;
+    pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc;
+    
     return crtc;
 }
 
 /*
- * Attach a Crtc to a screen. This is done as a separate step
- * so that an xf86-based driver can create CRTCs in PreInit
- * before the Screen has been created
+ * Set the allowed rotations on a CRTC
  */
-
-Bool
-RRCrtcAttachScreen (RRCrtcPtr crtc, ScreenPtr pScreen)
+void
+RRCrtcSetRotations (RRCrtcPtr crtc, Rotation rotations)
 {
-    rrScrPriv (pScreen);
-    RRCrtcPtr	*crtcs;
-
-    /* make space for the crtc pointer */
-    if (pScrPriv->numCrtcs)
-	crtcs = xrealloc (pScrPriv->crtcs, 
-			  (pScrPriv->numCrtcs + 1) * sizeof (RRCrtcPtr));
-    else
-	crtcs = xalloc (sizeof (RRCrtcPtr));
-    if (!crtcs)
-	return FALSE;
-    
-    /* attach the screen and crtc together */
-    crtc->pScreen = pScreen;
-    pScrPriv->crtcs = crtcs;
-    pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc;
-
-    RRCrtcChanged (crtc, TRUE);
-    return TRUE;
+    crtc->rotations = rotations;
 }
 
 /*
@@ -249,6 +247,22 @@ RRDeliverCrtcEvent (ClientPtr client, Wi
     WriteEventsToClient (client, 1, (xEvent *) &ce);
 }
 
+static Bool
+RRCrtcPendingProperties (RRCrtcPtr crtc)
+{
+    ScreenPtr	pScreen = crtc->pScreen;
+    rrScrPriv(pScreen);
+    int		o;
+
+    for (o = 0; o < pScrPriv->numOutputs; o++)
+    {
+	RROutputPtr output = pScrPriv->outputs[o];
+	if (output->crtc == crtc && output->pendingProperties)
+	    return TRUE;
+    }
+    return FALSE;
+}
+
 /*
  * Request that the Crtc be reconfigured
  */
@@ -271,7 +285,8 @@ RRCrtcSet (RRCrtcPtr    crtc,
 	crtc->y == y &&
 	crtc->rotation == rotation &&
 	crtc->numOutputs == numOutputs &&
-	!memcmp (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr)))
+	!memcmp (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr)) &&
+	!RRCrtcPendingProperties (crtc))
     {
 	ret = TRUE;
     }
@@ -328,7 +343,13 @@ RRCrtcSet (RRCrtcPtr    crtc,
 #endif
 	}
 	if (ret)
+	{
+	    int	o;
 	    RRTellChanged (pScreen);
+
+	    for (o = 0; o < numOutputs; o++)
+		RRPostPendingProperties (outputs[o]);
+	}
     }
     return ret;
 }
@@ -469,17 +490,6 @@ RRCrtcGammaSetSize (RRCrtcPtr	crtc,
 }
 
 /*
- * Set the allowable rotations of the CRTC.
- */
-Bool
-RRCrtcSetRotations (RRCrtcPtr crtc,
-		    Rotation rotations)
-{
-    crtc->rotations = rotations;
-    return TRUE;
-}
-
-/*
  * Initialize crtc type
  */
 Bool
diff --git a/randr/rrinfo.c b/randr/rrinfo.c
index 549d501..5ef1a6b 100644
--- a/randr/rrinfo.c
+++ b/randr/rrinfo.c
@@ -91,19 +91,12 @@ RRScanOldConfig (ScreenPtr pScreen, Rota
     if (pScrPriv->numOutputs == 0 &&
 	pScrPriv->numCrtcs == 0)
     {
-	crtc = RRCrtcCreate (NULL);
+	crtc = RRCrtcCreate (pScreen, NULL);
 	if (!crtc)
 	    return;
-	if (!RRCrtcAttachScreen (crtc, pScreen))
-	{
-	    RRCrtcDestroy (crtc);
-	    return;
-	}
-	output = RROutputCreate ("default", 7, NULL);
+	output = RROutputCreate (pScreen, "default", 7, NULL);
 	if (!output)
 	    return;
-	if (!RROutputAttachScreen (output, pScreen))
-	    return;
 	RROutputSetCrtcs (output, &crtc, 1);
 	RROutputSetCrtc (output, crtc);
 	RROutputSetConnection (output, RR_Connected);
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 160071b..e001162 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -47,19 +47,35 @@ RROutputChanged (RROutputPtr output, Boo
  */
 
 RROutputPtr
-RROutputCreate (const char  *name,
+RROutputCreate (ScreenPtr   pScreen,
+		const char  *name,
 		int	    nameLength,
 		void	    *devPrivate)
 {
-    RROutputPtr	output;
+    RROutputPtr	    output;
+    RROutputPtr	    *outputs;
+    rrScrPrivPtr    pScrPriv;
 
     if (!RRInit())
 	return NULL;
+    
+    pScrPriv = rrGetScrPriv(pScreen);
+
+    if (pScrPriv->numOutputs)
+	outputs = xrealloc (pScrPriv->outputs, 
+			    (pScrPriv->numOutputs + 1) * sizeof (RROutputPtr));
+    else
+	outputs = xalloc (sizeof (RROutputPtr));
+    if (!outputs)
+	return FALSE;
+
+    pScrPriv->outputs = outputs;
+    
     output = xalloc (sizeof (RROutputRec) + nameLength + 1);
     if (!output)
 	return NULL;
     output->id = FakeClientID (0);
-    output->pScreen = NULL;
+    output->pScreen = pScreen;
     output->name = (char *) (output + 1);
     output->nameLength = nameLength;
     memcpy (output->name, name, nameLength);
@@ -85,36 +101,11 @@ RROutputCreate (const char  *name,
     if (!AddResource (output->id, RROutputType, (pointer) output))
 	return NULL;
 
+    pScrPriv->outputs[pScrPriv->numOutputs++] = output;
     return output;
 }
 
 /*
- * Attach an Output to a screen. This is done as a separate step
- * so that an xf86-based driver can create Outputs in PreInit
- * before the Screen has been created
- */
-
-Bool
-RROutputAttachScreen (RROutputPtr output, ScreenPtr pScreen)
-{
-    rrScrPriv (pScreen);
-    RROutputPtr	*outputs;
-    
-    if (pScrPriv->numOutputs)
-	outputs = xrealloc (pScrPriv->outputs, 
-			    (pScrPriv->numOutputs + 1) * sizeof (RROutputPtr));
-    else
-	outputs = xalloc (sizeof (RROutputPtr));
-    if (!outputs)
-	return FALSE;
-    output->pScreen = pScreen;
-    pScrPriv->outputs = outputs;
-    pScrPriv->outputs[pScrPriv->numOutputs++] = output;
-    RROutputChanged (output, FALSE);
-    return TRUE;
-}
-		      
-/*
  * Notify extension that output parameters have been changed
  */
 Bool
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index 148e4a2..5ac073f 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -27,7 +27,7 @@
 static void
 RRDeliverEvent (ScreenPtr pScreen, xEvent *event, CARD32 mask)
 {
-    
+
 }
 
 void
@@ -50,7 +50,7 @@ RRDeleteAllOutputProperties (RROutputPtr
 	    xfree(prop->current.data);
 	if (prop->pending.data)
 	    xfree(prop->pending.data);
-        xfree(prop);
+	xfree(prop);
     }
 }
 
@@ -67,7 +67,7 @@ static RRPropertyPtr
 RRCreateOutputProperty (Atom property)
 {
     RRPropertyPtr   prop;
-    
+
     prop = (RRPropertyPtr)xalloc(sizeof(RRPropertyRec));
     if (!prop)
 	return NULL;
@@ -139,7 +139,7 @@ RRChangeOutputProperty (RROutputPtr outp
     prop = RRQueryOutputProperty (output, property);
     if (!prop)   /* just add to list */
     {
-        prop = RRCreateOutputProperty (property);
+	prop = RRCreateOutputProperty (property);
 	if (!prop)
 	    return(BadAlloc);
 	add = TRUE;
@@ -149,11 +149,11 @@ RRChangeOutputProperty (RROutputPtr outp
 	prop_value = &prop->pending;
     else
 	prop_value = &prop->current;
-    
+
     /* To append or prepend to a property the request format and type
-	    must match those of the already defined property.  The
-	    existing format and type are irrelevant when using the mode
-	    "PropModeReplace" since they will be written over. */
+     must match those of the already defined property.  The
+     existing format and type are irrelevant when using the mode
+     "PropModeReplace" since they will be written over. */
 
     if ((format != prop_value->format) && (mode != PropModeReplace))
 	return(BadMatch);
@@ -167,8 +167,8 @@ RRChangeOutputProperty (RROutputPtr outp
 
     if (mode == PropModeReplace || len > 0)
     {
-	pointer	    new_data, old_data;
-	
+	pointer	    new_data = NULL, old_data = NULL;
+
 	total_size = total_len * size_in_bytes;
 	new_value.data = (pointer)xalloc (total_size);
 	if (!new_value.data && total_size)
@@ -197,11 +197,12 @@ RRChangeOutputProperty (RROutputPtr outp
 				  (prop_value->size * size_in_bytes));
 	    break;
 	}
-	memcpy ((char *) new_data, (char *) value, len * size_in_bytes);
+	if (new_data)
+	    memcpy ((char *) new_data, (char *) value, len * size_in_bytes);
 	if (old_data)
 	    memcpy ((char *) old_data, (char *) prop_value->data, 
 		    prop_value->size * size_in_bytes);
-	
+
 	if (pending && pScrPriv->rrOutputSetProperty &&
 	    !pScrPriv->rrOutputSetProperty(output->pScreen, output,
 					   prop->propertyName, &new_value))
@@ -214,18 +215,21 @@ RRChangeOutputProperty (RROutputPtr outp
 	    xfree (prop_value->data);
 	*prop_value = new_value;
     }
-    
+
     else if (len == 0)
     {
 	/* do nothing */
     }
-    
+
     if (add)
     {
 	prop->next = output->properties;
 	output->properties = prop;
     }
 
+    if (pending && prop->is_pending)
+	output->pendingProperties = TRUE;
+
     if (sendevent)
     {
 	event.type = RREventBase + RRNotify;
@@ -240,30 +244,45 @@ RRChangeOutputProperty (RROutputPtr outp
 }
 
 Bool
-RRPostPendingProperty (RROutputPtr output, Atom property)
+RRPostPendingProperties (RROutputPtr output)
 {
-    RRPropertyPtr		    prop = RRQueryOutputProperty (output, property);
-    RRPropertyValuePtr		    pending_value;
-    RRPropertyValuePtr		    current_value;
-    
-    if (!prop)
-	return FALSE;
-    if (!prop->is_pending)
-	return FALSE;
-    pending_value = &prop->pending;
-    current_value = &prop->current;
-
-    if (pending_value->type == current_value->type &&
-	pending_value->format == current_value->format &&
-	pending_value->size == current_value->size &&
-	!memcmp (pending_value->data, current_value->data, pending_value->size))
+    RRPropertyValuePtr	pending_value;
+    RRPropertyValuePtr	current_value;
+    RRPropertyPtr	property;
+    Bool		ret = TRUE;
+
+    if (!output->pendingProperties)
 	return TRUE;
     
-    if (RRChangeOutputProperty (output, property, 
-				pending_value->type, pending_value->format, PropModeReplace,
-				pending_value->size, pending_value->data, TRUE, FALSE) != Success)
-	return FALSE;
-    return TRUE;
+    output->pendingProperties = FALSE;
+    for (property = output->properties; property; property = property->next)
+    {
+	/* Skip non-pending properties */
+	if (!property->is_pending)
+	    continue;
+	
+	pending_value = &property->pending;
+	current_value = &property->current;
+
+	/*
+	 * If the pending and current values are equal, don't mark it
+	 * as changed (which would deliver an event)
+	 */
+	if (pending_value->type == current_value->type &&
+	    pending_value->format == current_value->format &&
+	    pending_value->size == current_value->size &&
+	    !memcmp (pending_value->data, current_value->data,
+		     pending_value->size))
+	    continue;
+
+	if (RRChangeOutputProperty (output, property->propertyName,
+				    pending_value->type, pending_value->format,
+				    PropModeReplace, pending_value->size,
+				    pending_value->data, TRUE,
+				    FALSE) != Success)
+	    ret = FALSE;
+    }
+    return ret;
 }
 
 RRPropertyPtr
diff-tree 1f77120775dc05fc84a00dd55190af2fa50ae509 (from 476f2b5aefa518262b69e487555e6094818d857a)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Fri Mar 23 14:39:10 2007 -0700

    Ensure that crtc desired values track most recent mode.
    
    desiredX and desiredY were not recorded during xf86InitialConfiguration.
    desiredX, desiredY and desiredRotation were not recorded during
    xf86SetSingleMode.
    (cherry picked from commit 36e5227215e0912ddf8a010db042467f00efe0fc)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 2341715..b9895d9 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1589,6 +1589,8 @@ xf86InitialConfiguration (ScrnInfoPtr sc
 	{
 	    crtc->desiredMode = *mode;
 	    crtc->desiredRotation = output->initial_rotation;
+	    crtc->desiredX = output->initial_x;
+	    crtc->desiredY = output->initial_y;
 	    crtc->enabled = TRUE;
 	    crtc->x = output->initial_x;
 	    crtc->y = output->initial_y;
@@ -1813,7 +1815,12 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, Di
 	if (!xf86CrtcSetMode (crtc, crtc_mode, rotation, 0, 0))
 	    ok = FALSE;
 	else
+	{
 	    crtc->desiredMode = *crtc_mode;
+	    crtc->desiredRotation = rotation;
+	    crtc->desiredX = 0;
+	    crtc->desiredY = 0;
+	}
     }
     xf86DisableUnusedFunctions(pScrn);
     return ok;
diff-tree 476f2b5aefa518262b69e487555e6094818d857a (from 7093367c3976bef5b9d219d9f2a7dc7dd3eeb091)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Fri Mar 23 01:17:14 2007 -0700

    Incorrect extra memory copy in RRChangeOutputProperty.
    
    Left over from previous version of the code, this memmove will break when
    the mode is not Replace.
    (cherry picked from commit 945aa0aa556429b50dea8e8ebc0008304b093eb7)

diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index b0182da..148e4a2 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -177,8 +177,6 @@ RRChangeOutputProperty (RROutputPtr outp
 		RRDestroyOutputProperty (prop);
 	    return BadAlloc;
 	}
-	if (len)
-	    memmove((char *)new_value.data, (char *)value, total_size);
 	new_value.size = len;
 	new_value.type = type;
 	new_value.format = format;
diff-tree 7093367c3976bef5b9d219d9f2a7dc7dd3eeb091 (from 86d76390eb182f271f5fa5dc19205e97a867f7e7)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Fri Mar 23 01:05:55 2007 -0700

    Fix Pending property API, adding RRPostPendingProperty.
    
    Pending Properties take effect when the driver says they do, so provide an
    API to tell DIX when a property effect is made. Also, allow driver
    to reject property values in RRChangeOutputProperty.
    (cherry picked from commit 8eb288fbd69e2ffd02521d2c6a964c8180d08ec8)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index fad0752..2341715 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1923,7 +1923,7 @@ xf86OutputSetEDIDProperty (xf86OutputPtr
 
     if (data_len != 0) {
 	RRChangeOutputProperty(output->randr_output, edid_atom, XA_INTEGER, 8,
-			       PropModeReplace, data_len, data, FALSE);
+			       PropModeReplace, data_len, data, FALSE, TRUE);
     } else {
 	RRDeleteOutputProperty(output->randr_output, edid_atom);
     }
diff --git a/randr/randrstr.h b/randr/randrstr.h
index 0dee999..9f039f7 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -761,10 +761,13 @@ RRQueryOutputProperty (RROutputPtr outpu
 void
 RRDeleteOutputProperty (RROutputPtr output, Atom property);
 
+Bool
+RRPostPendingProperty (RROutputPtr output, Atom property);
+    
 int
 RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
 			int format, int mode, unsigned long len,
-			pointer value, Bool sendevent);
+			pointer value, Bool sendevent, Bool pending);
 
 int
 RRConfigureOutputProperty (RROutputPtr output, Atom property,
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index edfed1f..b0182da 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -121,19 +121,19 @@ RRDeleteOutputProperty (RROutputPtr outp
 int
 RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
 			int format, int mode, unsigned long len,
-			pointer value, Bool sendevent)
+			pointer value, Bool sendevent, Bool pending)
 {
     RRPropertyPtr		    prop;
     xRROutputPropertyNotifyEvent    event;
     rrScrPrivPtr		    pScrPriv = rrGetScrPriv(output->pScreen);
-    int				    sizeInBytes;
-    int				    totalSize;
-    pointer			    data;
+    int				    size_in_bytes;
+    int				    total_size;
+    unsigned long		    total_len;
     RRPropertyValuePtr		    prop_value;
+    RRPropertyValueRec		    new_value;
     Bool			    add = FALSE;
 
-    sizeInBytes = format >> 3;
-    totalSize = len * sizeInBytes;
+    size_in_bytes = format >> 3;
 
     /* first see if property already exists */
     prop = RRQueryOutputProperty (output, property);
@@ -145,7 +145,7 @@ RRChangeOutputProperty (RROutputPtr outp
 	add = TRUE;
 	mode = PropModeReplace;
     }
-    if (prop->is_pending)
+    if (pending && prop->is_pending)
 	prop_value = &prop->pending;
     else
 	prop_value = &prop->current;
@@ -159,68 +159,75 @@ RRChangeOutputProperty (RROutputPtr outp
 	return(BadMatch);
     if ((prop_value->type != type) && (mode != PropModeReplace))
 	return(BadMatch);
+    new_value = *prop_value;
     if (mode == PropModeReplace)
+	total_len = len;
+    else
+	total_len = prop_value->size + len;
+
+    if (mode == PropModeReplace || len > 0)
     {
-	if (totalSize != prop_value->size * (prop_value->format >> 3))
+	pointer	    new_data, old_data;
+	
+	total_size = total_len * size_in_bytes;
+	new_value.data = (pointer)xalloc (total_size);
+	if (!new_value.data && total_size)
 	{
-	    if (prop_value->data)
-		data = (pointer)xrealloc(prop_value->data, totalSize);
-	    else
-		data = (pointer)xalloc (totalSize);
-	    if (!data && len)
-	    {
-		if (add)
-		    RRDestroyOutputProperty (prop);
-		return(BadAlloc);
-	    }
-	    prop_value->data = data;
+	    if (add)
+		RRDestroyOutputProperty (prop);
+	    return BadAlloc;
 	}
 	if (len)
-	    memmove((char *)prop_value->data, (char *)value, totalSize);
-	prop_value->size = len;
-	prop_value->type = type;
-	prop_value->format = format;
+	    memmove((char *)new_value.data, (char *)value, total_size);
+	new_value.size = len;
+	new_value.type = type;
+	new_value.format = format;
+
+	switch (mode) {
+	case PropModeReplace:
+	    new_data = new_value.data;
+	    old_data = NULL;
+	    break;
+	case PropModeAppend:
+	    new_data = (pointer) (((char *) new_value.data) + 
+				  (prop_value->size * size_in_bytes));
+	    old_data = new_value.data;
+	    break;
+	case PropModePrepend:
+	    new_data = new_value.data;
+	    old_data = (pointer) (((char *) new_value.data) + 
+				  (prop_value->size * size_in_bytes));
+	    break;
+	}
+	memcpy ((char *) new_data, (char *) value, len * size_in_bytes);
+	if (old_data)
+	    memcpy ((char *) old_data, (char *) prop_value->data, 
+		    prop_value->size * size_in_bytes);
+	
+	if (pending && pScrPriv->rrOutputSetProperty &&
+	    !pScrPriv->rrOutputSetProperty(output->pScreen, output,
+					   prop->propertyName, &new_value))
+	{
+	    if (new_value.data)
+		xfree (new_value.data);
+	    return (BadValue);
+	}
+	if (prop_value->data)
+	    xfree (prop_value->data);
+	*prop_value = new_value;
     }
+    
     else if (len == 0)
     {
 	/* do nothing */
     }
-    else if (mode == PropModeAppend)
-    {
-	data = (pointer)xrealloc(prop_value->data,
-				 sizeInBytes * (len + prop_value->size));
-	if (!data)
-	    return(BadAlloc);
-	prop_value->data = data;
-	memmove(&((char *)data)[prop_value->size * sizeInBytes], 
-		(char *)value,
-	      totalSize);
-	prop_value->size += len;
-    }
-    else if (mode == PropModePrepend)
-    {
-	data = (pointer)xalloc(sizeInBytes * (len + prop_value->size));
-	if (!data)
-	    return(BadAlloc);
-	memmove(&((char *)data)[totalSize], (char *)prop_value->data, 
-	      (int)(prop_value->size * sizeInBytes));
-	memmove((char *)data, (char *)value, totalSize);
-	xfree(prop_value->data);
-	prop_value->data = data;
-	prop_value->size += len;
-    }
+    
     if (add)
     {
 	prop->next = output->properties;
 	output->properties = prop;
     }
 
-    if (!prop->is_pending) {
-	/* What should we do in case of failure? */
-	pScrPriv->rrOutputSetProperty(output->pScreen, output,
-				      prop->propertyName, prop_value);
-    }
-
     if (sendevent)
     {
 	event.type = RREventBase + RRNotify;
@@ -234,6 +241,33 @@ RRChangeOutputProperty (RROutputPtr outp
     return(Success);
 }
 
+Bool
+RRPostPendingProperty (RROutputPtr output, Atom property)
+{
+    RRPropertyPtr		    prop = RRQueryOutputProperty (output, property);
+    RRPropertyValuePtr		    pending_value;
+    RRPropertyValuePtr		    current_value;
+    
+    if (!prop)
+	return FALSE;
+    if (!prop->is_pending)
+	return FALSE;
+    pending_value = &prop->pending;
+    current_value = &prop->current;
+
+    if (pending_value->type == current_value->type &&
+	pending_value->format == current_value->format &&
+	pending_value->size == current_value->size &&
+	!memcmp (pending_value->data, current_value->data, pending_value->size))
+	return TRUE;
+    
+    if (RRChangeOutputProperty (output, property, 
+				pending_value->type, pending_value->format, PropModeReplace,
+				pending_value->size, pending_value->data, TRUE, FALSE) != Success)
+	return FALSE;
+    return TRUE;
+}
+
 RRPropertyPtr
 RRQueryOutputProperty (RROutputPtr output, Atom property)
 {
@@ -474,7 +508,7 @@ ProcRRChangeOutputProperty (ClientPtr cl
 
     err = RRChangeOutputProperty(output, stuff->property,
 				 stuff->type, (int)format,
-				 (int)mode, len, (pointer)&stuff[1], TRUE);
+				 (int)mode, len, (pointer)&stuff[1], TRUE, TRUE);
     if (err != Success)
 	return err;
     else
@@ -508,8 +542,8 @@ int
 ProcRRGetOutputProperty (ClientPtr client)
 {
     REQUEST(xRRGetOutputPropertyReq);
-    RRPropertyPtr			prop, *prev;
-    RRPropertyValuePtr			prop_value;
+    RRPropertyPtr		prop, *prev;
+    RRPropertyValuePtr		prop_value;
     unsigned long		n, len, ind;
     RROutputPtr			output;
     xRRGetOutputPropertyReply	reply;
@@ -600,7 +634,10 @@ ProcRRGetOutputProperty (ClientPtr clien
     reply.bytesAfter = n - (ind + len);
     reply.format = prop_value->format;
     reply.length = (len + 3) >> 2;
-    reply.nItems = len / (prop_value->format / 8 );
+    if (prop_value->format)
+	reply.nItems = len / (prop_value->format / 8);
+    else
+	reply.nItems = 0;
     reply.propertyType = prop_value->type;
 
     if (stuff->delete && (reply.bytesAfter == 0))
diff-tree 86d76390eb182f271f5fa5dc19205e97a867f7e7 (from 510eaa346e68fd82c852c7b41fb0e2c5be12da78)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Fri Mar 23 01:03:40 2007 -0700

    Make sure RandR events are delivered from RRCrtcSet.
    
    Some paths were skipping the event delivery stage.
    (cherry picked from commit 9ca7ba5d6012295a77ed773c656e786440da973d)

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index ecf5bb2..7131dfb 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -262,6 +262,8 @@ RRCrtcSet (RRCrtcPtr    crtc,
 	   RROutputPtr  *outputs)
 {
     ScreenPtr	pScreen = crtc->pScreen;
+    Bool	ret = FALSE;
+    rrScrPriv(pScreen);
 
     /* See if nothing changed */
     if (crtc->mode == mode &&
@@ -271,61 +273,64 @@ RRCrtcSet (RRCrtcPtr    crtc,
 	crtc->numOutputs == numOutputs &&
 	!memcmp (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr)))
     {
-	return TRUE;
+	ret = TRUE;
     }
-    if (pScreen)
+    else
     {
 #if RANDR_12_INTERFACE
-	rrScrPriv(pScreen);
 	if (pScrPriv->rrCrtcSet)
 	{
-	    return (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y, 
-					   rotation, numOutputs, outputs);
+	    ret = (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y, 
+					  rotation, numOutputs, outputs);
 	}
+	else
 #endif
-#if RANDR_10_INTERFACE
-	if (pScrPriv->rrSetConfig)
 	{
-	    RRScreenSize	    size;
-	    RRScreenRate	    rate;
-	    Bool		    ret;
-
-	    if (!mode)
+#if RANDR_10_INTERFACE
+	    if (pScrPriv->rrSetConfig)
 	    {
-		RRCrtcNotify (crtc, NULL, x, y, rotation, 0, NULL);
-		return TRUE;
-	    }
+		RRScreenSize	    size;
+		RRScreenRate	    rate;
 
-	    size.width = mode->mode.width;
-	    size.height = mode->mode.height;
-	    if (outputs[0]->mmWidth && outputs[0]->mmHeight)
-	    {
-		size.mmWidth = outputs[0]->mmWidth;
-		size.mmHeight = outputs[0]->mmHeight;
+		if (!mode)
+		{
+		    RRCrtcNotify (crtc, NULL, x, y, rotation, 0, NULL);
+		    ret = TRUE;
+		}
+		else
+		{
+		    size.width = mode->mode.width;
+		    size.height = mode->mode.height;
+		    if (outputs[0]->mmWidth && outputs[0]->mmHeight)
+		    {
+			size.mmWidth = outputs[0]->mmWidth;
+			size.mmHeight = outputs[0]->mmHeight;
+		    }
+		    else
+		    {
+			size.mmWidth = pScreen->mmWidth;
+			size.mmHeight = pScreen->mmHeight;
+		    }
+		    size.nRates = 1;
+		    rate.rate = RRVerticalRefresh (&mode->mode);
+		    size.pRates = &rate;
+		    ret = (*pScrPriv->rrSetConfig) (pScreen, rotation, rate.rate, &size);
+		    /*
+		     * Old 1.0 interface tied screen size to mode size
+		     */
+		    if (ret)
+		    {
+			RRCrtcNotify (crtc, mode, x, y, rotation, 1, outputs);
+			RRScreenSizeNotify (pScreen);
+		    }
+		}
 	    }
-	    else
-	    {
-		size.mmWidth = pScreen->mmWidth;
-		size.mmHeight = pScreen->mmHeight;
-	    }
-	    size.nRates = 1;
-	    rate.rate = RRVerticalRefresh (&mode->mode);
-	    size.pRates = &rate;
-	    ret = (*pScrPriv->rrSetConfig) (pScreen, rotation, rate.rate, &size);
-	    /*
-	     * Old 1.0 interface tied screen size to mode size
-	     */
-	    if (ret)
-	    {
-		RRCrtcNotify (crtc, mode, x, y, rotation, 1, outputs);
-		RRScreenSizeNotify (pScreen);
-	    }
-	    return ret;
-	}
 #endif
-	RRTellChanged (pScreen);
+	}
+	if (ret)
+	    RRTellChanged (pScreen);
     }
-    return FALSE;
+    return ret;
 }
 
 /*
@@ -718,6 +723,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
 	goto sendReply;
     }
     
+#if 0
     /*
      * if the client's config timestamp is not the same as the last config
      * timestamp, then the config information isn't up-to-date and
@@ -728,6 +734,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
 	rep.status = RRSetConfigInvalidConfigTime;
 	goto sendReply;
     }
+#endif
     
     /*
      * Validate requested rotation
diff-tree 510eaa346e68fd82c852c7b41fb0e2c5be12da78 (from 479b2be4badab0a67b1f091feb83c1364e27d783)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Fri Mar 23 00:59:11 2007 -0700

    Clean up xf86CrtcRec and xf86OutputRec objects at CloseScreen.
    
    Erase pointers to structures which are freed at server reset time.
    (cherry picked from commit 492c768065f49306a2194a88edf96b85de0ff4ff)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index a875cdf..fad0752 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -573,11 +573,25 @@ xf86CrtcCloseScreen (int index, ScreenPt
 {
     ScrnInfoPtr		scrn = xf86Screens[screen->myNum];
     xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(scrn);
+    int			o, c;
     
     screen->CloseScreen = config->CloseScreen;
 
     xf86RotateCloseScreen (screen);
 
+    for (o = 0; o < config->num_output; o++)
+    {
+	xf86OutputPtr	output = config->output[o];
+
+	output->crtc = NULL;
+	output->randr_output = NULL;
+    }
+    for (c = 0; c < config->num_crtc; c++)
+    {
+	xf86CrtcPtr	crtc = config->crtc[c];
+
+	crtc->randr_crtc = NULL;
+    }
     return screen->CloseScreen (index, screen);
 }
 
diff-tree 479b2be4badab0a67b1f091feb83c1364e27d783 (from b63e0d2545bb75e14d9de019a88f31e20a2f7377)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Fri Mar 23 00:57:18 2007 -0700

    Clear allocated RandR screen private structure.
    
    Use xcalloc instead of xalloc when allocating this structure to ensure
    consistent contents at startup.
    (cherry picked from commit 16f4c0c1750824f2e5a001cef82a4122a7a2beb0)

diff --git a/randr/randr.c b/randr/randr.c
index 5fa9baf..4dd0ee5 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -230,7 +230,7 @@ Bool RRScreenInit(ScreenPtr pScreen)
 	RRScreenGeneration = serverGeneration;
     }
 
-    pScrPriv = (rrScrPrivPtr) xalloc (sizeof (rrScrPrivRec));
+    pScrPriv = (rrScrPrivPtr) xcalloc (1, sizeof (rrScrPrivRec));
     if (!pScrPriv)
 	return FALSE;
 
diff-tree b63e0d2545bb75e14d9de019a88f31e20a2f7377 (from 3e9f7a5504ab41d845e88f293d8498c963d8a7d8)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Tue Mar 20 07:17:27 2007 -0700

    Clean up Rotate state on server reset.
    
    The rotation state is stored in the xf86_config structure which is not
    re-initialized at server reset time. Clean it up at CloseScreen time.
    (cherry picked from commit f8db7665dcd7af78ca4db2461e0bf787ec662cb1)

diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index bc7c814..5175f01 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -1170,6 +1170,7 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMVAR(pciNumBuses)
 
     /* modes */
+    SYMVAR(xf86CrtcConfigPrivateIndex)
     SYMFUNC(xf86CrtcConfigInit)
     SYMFUNC(xf86CrtcConfigPrivateIndex)
     SYMFUNC(xf86CrtcCreate)
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 1a42920..a875cdf 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -566,6 +566,22 @@ xf86CrtcCreateScreenResources (ScreenPtr
 }
 
 /*
+ * Clean up config on server reset
+ */
+static Bool
+xf86CrtcCloseScreen (int index, ScreenPtr screen)
+{
+    ScrnInfoPtr		scrn = xf86Screens[screen->myNum];
+    xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(scrn);
+    
+    screen->CloseScreen = config->CloseScreen;
+
+    xf86RotateCloseScreen (screen);
+
+    return screen->CloseScreen (index, screen);
+}
+
+/*
  * Called at ScreenInit time to set up
  */
 Bool
@@ -596,6 +612,10 @@ xf86CrtcScreenInit (ScreenPtr screen)
     /* Wrap CreateScreenResources so we can initialize the RandR code */
     config->CreateScreenResources = screen->CreateScreenResources;
     screen->CreateScreenResources = xf86CrtcCreateScreenResources;
+
+    config->CloseScreen = screen->CloseScreen;
+    screen->CloseScreen = xf86CrtcCloseScreen;
+    
     return TRUE;
 }
 
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index b751592..42daf60 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -544,6 +544,8 @@ typedef struct _xf86CrtcConfig {
 
     CreateScreenResourcesProcPtr    CreateScreenResources;
 
+    CloseScreenProcPtr		    CloseScreen;
+
     /* Cursor information */
     xf86CursorInfoPtr	cursor_info;
     CursorPtr		cursor;
@@ -593,6 +595,12 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, Displ
 Bool
 xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation);
 
+/*
+ * Clean up rotation during CloseScreen
+ */
+void
+xf86RotateCloseScreen (ScreenPtr pScreen);
+
 /**
  * Return whether any output is assigned to the crtc
  */
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index e82b69e..e8fafd0 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -321,36 +321,68 @@ xf86RotateWakeupHandler(pointer data, in
 {
 }
 
-Bool
-xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation)
+static void
+xf86RotateDestroy (xf86CrtcPtr crtc)
 {
     ScrnInfoPtr		pScrn = crtc->scrn;
-    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     ScreenPtr		pScreen = pScrn->pScreen;
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+    int			c;
     
-    if (rotation == RR_Rotate_0)
+    /* Free memory from rotation */
+    if (crtc->rotatedPixmap || crtc->rotatedData)
     {
-	/* Free memory from rotation */
+	crtc->funcs->shadow_destroy (crtc, crtc->rotatedPixmap, crtc->rotatedData);
+	crtc->rotatedPixmap = NULL;
+	crtc->rotatedData = NULL;
+    }
+
+    for (c = 0; c < xf86_config->num_crtc; c++)
 	if (crtc->rotatedPixmap || crtc->rotatedData)
-	{
-	    crtc->funcs->shadow_destroy (crtc, crtc->rotatedPixmap, crtc->rotatedData);
-	    crtc->rotatedPixmap = NULL;
-	    crtc->rotatedData = NULL;
-	}
+	    return;
 
-	if (xf86_config->rotation_damage)
+    /*
+     * Clean up damage structures when no crtcs are rotated
+     */
+    if (xf86_config->rotation_damage)
+    {
+	/* Free damage structure */
+	if (xf86_config->rotation_damage_registered)
 	{
-	    /* Free damage structure */
 	    DamageUnregister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
 			      xf86_config->rotation_damage);
 	    xf86_config->rotation_damage_registered = FALSE;
-	    DamageDestroy (xf86_config->rotation_damage);
-	    xf86_config->rotation_damage = NULL;
-	    /* Free block/wakeup handler */
-	    RemoveBlockAndWakeupHandlers (xf86RotateBlockHandler,
-					  xf86RotateWakeupHandler,
-					  (pointer) pScreen);
 	}
+	DamageDestroy (xf86_config->rotation_damage);
+	xf86_config->rotation_damage = NULL;
+	/* Free block/wakeup handler */
+	RemoveBlockAndWakeupHandlers (xf86RotateBlockHandler,
+				      xf86RotateWakeupHandler,
+				      (pointer) pScreen);
+    }
+}
+
+void
+xf86RotateCloseScreen (ScreenPtr screen)
+{
+    ScrnInfoPtr		scrn = xf86Screens[screen->myNum];
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    int			c;
+
+    for (c = 0; c < xf86_config->num_crtc; c++)
+	xf86RotateDestroy (xf86_config->crtc[c]);
+}
+
+Bool
+xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation)
+{
+    ScrnInfoPtr		pScrn = crtc->scrn;
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+    ScreenPtr		pScreen = pScrn->pScreen;
+    
+    if (rotation == RR_Rotate_0)
+    {
+	xf86RotateDestroy (crtc);
     }
     else
     {
diff-tree 3e9f7a5504ab41d845e88f293d8498c963d8a7d8 (from f292de2ef13dc994a38029cee9e2642576893332)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Mar 21 02:35:31 2007 +0200

    XFree86 DGA: Guard against NULL pointer dereferences.
    Ass, u, me ...

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index c9c8059..17ffed8 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -423,17 +423,19 @@ xf86PostMotionEvent(DeviceIntPtr	device,
 
 #if XFreeXDGA
     if (first_valuator == 0 && num_valuators >= 2) {
-        index = miPointerGetScreen(inputInfo.pointer)->myNum;
-        if (is_absolute) {
-            dx = valuators[0] - device->valuator->lastx;
-            dy = valuators[1] - device->valuator->lasty;
-        }
-        else {
-            dx = valuators[0];
-            dy = valuators[1];
+        if (miPointerGetScreen(inputInfo.pointer)) {
+            index = miPointerGetScreen(inputInfo.pointer)->myNum;
+            if (is_absolute) {
+                dx = valuators[0] - device->valuator->lastx;
+                dy = valuators[1] - device->valuator->lasty;
+            }
+            else {
+                dx = valuators[0];
+                dy = valuators[1];
+            }
+            if (DGAStealMotionEvent(index, dx, dy))
+                goto out;
         }
-        if (DGAStealMotionEvent(index, dx, dy))
-            goto out;
     }
 #endif
 
@@ -505,9 +507,11 @@ xf86PostButtonEvent(DeviceIntPtr	device,
     int index;
 
 #if XFreeXDGA
-    index = miPointerGetScreen(inputInfo.pointer)->myNum;
-    if (DGAStealButtonEvent(index, button, is_down))
-        return;
+    if (miPointerGetScreen(inputInfo.pointer)) {
+        index = miPointerGetScreen(inputInfo.pointer)->myNum;
+        if (DGAStealButtonEvent(index, button, is_down))
+            return;
+    }
 #endif
     
     valuators = xcalloc(sizeof(int), num_valuators);
@@ -588,9 +592,11 @@ xf86PostKeyboardEvent(DeviceIntPtr      
     int index;
 
 #if XFreeXDGA
-    index = miPointerGetScreen(inputInfo.pointer)->myNum;
-    if (DGAStealKeyEvent(index, key_code, is_down))
-        return;
+    if (miPointerGetScreen(inputInfo.pointer)) {
+        index = miPointerGetScreen(inputInfo.pointer)->myNum;
+        if (DGAStealKeyEvent(index, key_code, is_down))
+            return;
+    }
 #endif
 
     if (!xf86Events)
diff-tree f292de2ef13dc994a38029cee9e2642576893332 (from f34b9a20b0181d3c2641c305e91180711afbd4b9)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Mar 21 02:04:12 2007 +0200

    XKB: Fix size_syms calculation bug
    
    Apparently it needed to be nSyms*15/10, not *12/10; make it match the
    other allocation code.

diff --git a/xkb/XKBMAlloc.c b/xkb/XKBMAlloc.c
index 4b7428b..9feaf8e 100644
--- a/xkb/XKBMAlloc.c
+++ b/xkb/XKBMAlloc.c
@@ -399,7 +399,7 @@ KeyCode		matchingKeys[XkbMaxKeyCount],nM
 	}
 	if (nResize>0) {
 	    int nextMatch;
-	    xkb->map->size_syms= (nTotal*12)/10;
+	    xkb->map->size_syms= (nTotal*15)/10;
 	    newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym);
 	    if (newSyms==NULL)
 		return BadAlloc;
diff-tree f34b9a20b0181d3c2641c305e91180711afbd4b9 (from 021fc5cb2cb4a7972b4a6fcb570c1da92787d68d)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Mar 21 02:03:37 2007 +0200

    XKB: Be a tiny bit more conservative with type allocation
    
    Make sure size_types will _always_ be 0 if we don't have any types.

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 1d23667..bb6d8a0 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1140,6 +1140,9 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
                     dtype->preserve = NULL;
                 }
             }
+
+            dst->map->size_types = src->map->num_types;
+            dst->map->num_types = src->map->num_types;
         }
         else {
             if (dst->map->types) {
@@ -1155,9 +1158,9 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
                 xfree(dst->map->types);
                 dst->map->types = NULL;
             }
+            dst->map->num_types = 0;
+            dst->map->size_types = 0;
         }
-        dst->map->size_types = src->map->num_types;
-        dst->map->num_types = src->map->num_types;
 
         if (src->map->modmap) {
             if (src->max_key_code != dst->max_key_code) {
diff-tree 021fc5cb2cb4a7972b4a6fcb570c1da92787d68d (from 9398d62f27ee1b287e4458fd8b011c10f7b59efd)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Sun Mar 18 16:31:19 2007 -0400

    Static markup and dead code cull over xkb/.
    
    The former <X11/extensions/XKBsrv.h> has been pulled into the server now as
    include/xkbsrv.h, and the world updated to look for it in the new place,
    since it made no sense to define server API in an extension header.  Any
    further work along this line will need to do similar things with XKBgeom.h
    and friends.

diff --git a/Xext/xevie.c b/Xext/xevie.c
index e979e7e..2fd68f8 100644
--- a/Xext/xevie.c
+++ b/Xext/xevie.c
@@ -52,7 +52,7 @@ of the copyright holder.
 #include "inputstr.h"
 #include "windowstr.h"
 #include "cursorstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 
 #include "../os/osdep.h"
 
diff --git a/dix/devices.c b/dix/devices.c
index 8eb54f7..f738419 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -67,7 +67,7 @@ SOFTWARE.
 #define	XKB_IN_SERVER
 #endif
 #ifdef XKB
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #endif
 #include "xace.h"
 
diff --git a/dix/dispatch.c b/dix/dispatch.c
index b258aa6..32f6788 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -143,7 +143,7 @@ int ProcInitialConnection();
 #define XKB_IN_SERVER
 #endif
 #include "inputstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #endif
 
 #ifdef XSERVER_DTRACE
diff --git a/dix/events.c b/dix/events.c
index c0b62b8..02598a3 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -133,7 +133,7 @@ of the copyright holder.
 
 #ifdef XKB
 #include <X11/extensions/XKBproto.h>
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 extern Bool XkbFilterEvents(ClientPtr, int, xEvent *);
 #endif
 
diff --git a/dix/getevents.c b/dix/getevents.c
index 935112d..3f636bc 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -44,7 +44,7 @@
 
 #ifdef XKB
 #include <X11/extensions/XKBproto.h>
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 extern Bool XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies);
 #endif
 
diff --git a/hw/dmx/dmxclient.h b/hw/dmx/dmxclient.h
index 586b829..657a127 100644
--- a/hw/dmx/dmxclient.h
+++ b/hw/dmx/dmxclient.h
@@ -126,7 +126,7 @@ typedef XID           KeySym64;
 #undef KeySym
 #endif
 
-/* These are in exglobals.h, but that conflicts with X11/extensions/XKBsrv.h */
+/* These are in exglobals.h, but that conflicts with xkbsrv.h */
 extern int ProximityIn;
 extern int ProximityOut;
 extern int DeviceValuator;
@@ -144,7 +144,7 @@ extern int ChangeDeviceNotify;
 #ifndef XKB_IN_SERVER
 #define XKB_IN_SERVER
 #endif
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #undef XPointer
 #endif
 #include <X11/extensions/XIproto.h>
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 3bf6bad..857f04f 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -42,7 +42,7 @@
 #endif
 
 #ifdef XKB
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #endif
 
 #include <X11/extensions/XI.h>
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index c0e21dd..1bd3c62 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -75,7 +75,7 @@ extern DeviceAssocRec mouse_assoc;
 #ifdef XKB
 #undef XKB_IN_SERVER
 #define XKB_IN_SERVER
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #endif
 
 #ifdef RENDER
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 28058b5..43db1ee 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -43,7 +43,7 @@
 #include "servermd.h"
 #include "micmap.h"
 #ifdef XKB
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #endif
 #include "xf86Xinput.h"
 
diff --git a/hw/xfree86/common/xf86XKB.c b/hw/xfree86/common/xf86XKB.c
index 399eb02..b805885 100644
--- a/hw/xfree86/common/xf86XKB.c
+++ b/hw/xfree86/common/xf86XKB.c
@@ -73,7 +73,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #define XF86_OS_PRIVS
 #include "xf86_OSlib.h"
 
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 
 void
 xf86InitXkb(void)
diff --git a/hw/xfree86/dixmods/xkbKillSrv.c b/hw/xfree86/dixmods/xkbKillSrv.c
index 415873a..b3399db 100644
--- a/hw/xfree86/dixmods/xkbKillSrv.c
+++ b/hw/xfree86/dixmods/xkbKillSrv.c
@@ -40,7 +40,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include "windowstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XI.h>
 
 #include "xf86.h"
diff --git a/hw/xfree86/dixmods/xkbPrivate.c b/hw/xfree86/dixmods/xkbPrivate.c
index e6d4f0f..e0cd217 100644
--- a/hw/xfree86/dixmods/xkbPrivate.c
+++ b/hw/xfree86/dixmods/xkbPrivate.c
@@ -12,7 +12,7 @@
 #include <X11/X.h>
 #include "windowstr.h"
 #define XKBSRV_NEED_FILE_FUNCS
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 
 #include "xf86.h"
 
diff --git a/hw/xfree86/dixmods/xkbVT.c b/hw/xfree86/dixmods/xkbVT.c
index a1cdc70..e6d69e2 100644
--- a/hw/xfree86/dixmods/xkbVT.c
+++ b/hw/xfree86/dixmods/xkbVT.c
@@ -40,7 +40,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include "windowstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XI.h>
 
 #include "xf86.h"
diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c
index 594bf43..5d06b05 100644
--- a/hw/xfree86/loader/dixsym.c
+++ b/hw/xfree86/loader/dixsym.c
@@ -86,7 +86,7 @@
 #endif
 #include "selection.h"
 #ifdef XKB
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 extern int XkbDfltRepeatDelay, XkbDfltRepeatInterval;
 #endif
 
diff --git a/hw/xgl/egl/kinput.c b/hw/xgl/egl/kinput.c
index b374bf5..5fd23f5 100644
--- a/hw/xgl/egl/kinput.c
+++ b/hw/xgl/egl/kinput.c
@@ -41,7 +41,7 @@
 
 #ifdef XKB
 #define XKB_IN_SERVER
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #endif
 
 static DeviceIntPtr	pKdKeyboard, pKdPointer;
diff --git a/hw/xgl/glx/xglx.c b/hw/xgl/glx/xglx.c
index 57cb847..92974f0 100644
--- a/hw/xgl/glx/xglx.c
+++ b/hw/xgl/glx/xglx.c
@@ -50,7 +50,7 @@
 
 #ifdef XKB
 #include <X11/extensions/XKB.h>
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XKBconfig.h>
 
 extern Bool
diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c
index 0dacae7..bb3cb13 100644
--- a/hw/xnest/Keyboard.c
+++ b/hw/xnest/Keyboard.c
@@ -36,7 +36,7 @@ is" without express or implied warranty.
 
 #ifdef XKB
 #include <X11/extensions/XKB.h>
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XKBconfig.h>
 
 extern Bool
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 39a5eda..9457c9c 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -44,7 +44,7 @@ from The Open Group.
 #include <mntent.h>
 #endif
 #if defined(XKB) && defined(WIN32)
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #endif
 #ifdef RELOCATE_PROJECTROOT
 #include <shlobj.h>
diff --git a/hw/xwin/winconfig.c b/hw/xwin/winconfig.c
index e3d1808..2c18771 100644
--- a/hw/xwin/winconfig.c
+++ b/hw/xwin/winconfig.c
@@ -40,7 +40,7 @@
 #ifndef XKB_IN_SERVER
 #define XKB_IN_SERVER
 #endif
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #endif
 
 #ifdef XWIN_XF86CONFIG
diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c
index 164e391..d574f20 100644
--- a/hw/xwin/winkeybd.c
+++ b/hw/xwin/winkeybd.c
@@ -44,7 +44,7 @@
 #ifndef XKB_IN_SERVER
 #define XKB_IN_SERVER
 #endif
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #endif
 
 static Bool g_winKeyState[NUM_KEYCODES];
diff --git a/include/xkbsrv.h b/include/xkbsrv.h
new file mode 100644
index 0000000..5edee53
--- /dev/null
+++ b/include/xkbsrv.h
@@ -0,0 +1,1022 @@
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be 
+used in advertising or publicity pertaining to distribution 
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability 
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifndef _XKBSRV_H_
+#define	_XKBSRV_H_
+
+#ifdef XKB_IN_SERVER
+#define XkbAllocClientMap		SrvXkbAllocClientMap
+#define XkbAllocServerMap		SrvXkbAllocServerMap
+#define XkbChangeTypesOfKey		SrvXkbChangeTypesOfKey
+#define XkbCopyKeyTypes			SrvXkbCopyKeyTypes
+#define XkbFreeClientMap		SrvXkbFreeClientMap
+#define XkbFreeServerMap		SrvXkbFreeServerMap
+#define	XkbKeyTypesForCoreSymbols	SrvXkbKeyTypesForCoreSymbols
+#define	XkbApplyCompatMapToKey		SrvXkbApplyCompatMapToKey
+#define XkbResizeKeyActions		SrvXkbResizeKeyActions
+#define XkbResizeKeySyms		SrvXkbResizeKeySyms
+#define XkbResizeKeyType		SrvXkbResizeKeyType
+#define XkbAllocCompatMap		SrvXkbAllocCompatMap
+#define XkbAllocControls		SrvXkbAllocControls
+#define XkbAllocIndicatorMaps		SrvXkbAllocIndicatorMaps
+#define XkbAllocKeyboard		SrvXkbAllocKeyboard
+#define XkbAllocNames			SrvXkbAllocNames
+#define XkbFreeCompatMap		SrvXkbFreeCompatMap
+#define XkbFreeKeyboard			SrvXkbFreeKeyboard
+#define XkbFreeNames			SrvXkbFreeNames
+#define XkbLatchModifiers		SrvXkbLatchModifiers
+#define XkbLatchGroup			SrvXkbLatchGroup
+#define XkbVirtualModsToReal		SrvXkbVirtualModsToReal
+#define	XkbChangeKeycodeRange		SrvXkbChangeKeycodeRange
+#define	XkbApplyVirtualModChanges	SrvXkbApplyVirtualModChanges
+#endif
+
+#include <X11/extensions/XKBstr.h>
+#include <X11/extensions/XKBproto.h>
+#include "inputstr.h"
+
+typedef struct _XkbInterest {
+	DeviceIntPtr		dev;
+	ClientPtr		client;
+	XID			resource;
+	struct _XkbInterest *	next;
+	CARD16			extDevNotifyMask;
+	CARD16			stateNotifyMask;
+	CARD16			namesNotifyMask;
+	CARD32 			ctrlsNotifyMask;
+	CARD8			compatNotifyMask;
+	BOOL			bellNotifyMask;
+	BOOL			actionMessageMask;
+	CARD16			accessXNotifyMask;
+	CARD32			iStateNotifyMask;
+	CARD32			iMapNotifyMask;
+	CARD16			altSymsNotifyMask;
+	CARD32			autoCtrls;
+	CARD32			autoCtrlValues;
+} XkbInterestRec,*XkbInterestPtr;
+
+typedef struct _XkbRadioGroup {
+	CARD8		flags;
+	CARD8		nMembers;
+	CARD8		dfltDown;
+	CARD8		currentDown;
+	CARD8		members[XkbRGMaxMembers];
+} XkbRadioGroupRec, *XkbRadioGroupPtr;
+
+typedef struct	_XkbEventCause {
+	CARD8		kc;
+	CARD8		event;
+	CARD8		mjr;
+	CARD8		mnr;
+	ClientPtr	client;
+} XkbEventCauseRec,*XkbEventCausePtr;
+#define	XkbSetCauseKey(c,k,e)	{ (c)->kc= (k),(c)->event= (e),\
+				  (c)->mjr= (c)->mnr= 0; \
+				  (c)->client= NULL; }
+#define	XkbSetCauseReq(c,j,n,cl) { (c)->kc= (c)->event= 0,\
+				  (c)->mjr= (j),(c)->mnr= (n);\
+				  (c)->client= (cl); }
+#define	XkbSetCauseCoreReq(c,e,cl) XkbSetCauseReq(c,e,0,cl)
+#define	XkbSetCauseXkbReq(c,e,cl)  XkbSetCauseReq(c,XkbReqCode,e,cl)
+#define	XkbSetCauseUnknown(c)	   XkbSetCauseKey(c,0,0)
+
+#define	_OFF_TIMER		0
+#define	_KRG_WARN_TIMER		1
+#define	_KRG_TIMER		2
+#define	_SK_TIMEOUT_TIMER	3
+#define	_ALL_TIMEOUT_TIMER	4
+
+#define	_BEEP_NONE		0
+#define	_BEEP_FEATURE_ON	1
+#define	_BEEP_FEATURE_OFF	2
+#define	_BEEP_FEATURE_CHANGE	3
+#define	_BEEP_SLOW_WARN		4
+#define	_BEEP_SLOW_PRESS	5
+#define	_BEEP_SLOW_ACCEPT	6
+#define	_BEEP_SLOW_REJECT	7
+#define	_BEEP_SLOW_RELEASE	8
+#define	_BEEP_STICKY_LATCH	9
+#define	_BEEP_STICKY_LOCK	10
+#define	_BEEP_STICKY_UNLOCK	11
+#define	_BEEP_LED_ON		12
+#define	_BEEP_LED_OFF		13
+#define	_BEEP_LED_CHANGE	14
+#define	_BEEP_BOUNCE_REJECT	15
+
+typedef struct _XkbSrvInfo {
+	XkbStateRec	 prev_state;
+	XkbStateRec	 state;
+	XkbDescPtr	 desc;
+
+	DeviceIntPtr	 device;
+	KbdCtrlProcPtr	 kbdProc;
+
+	XkbRadioGroupPtr radioGroups;
+	CARD8		 nRadioGroups;
+	CARD8		 clearMods;
+	CARD8		 setMods;
+	INT16		 groupChange;
+
+	CARD16		 dfltPtrDelta;
+
+	double		 mouseKeysCurve;
+	double		 mouseKeysCurveFactor;
+	INT16		 mouseKeysDX;
+	INT16		 mouseKeysDY;
+	CARD8		 mouseKeysFlags;
+	Bool		 mouseKeysAccel;
+	CARD8		 mouseKeysCounter;
+
+	CARD8		 lockedPtrButtons;
+	CARD8		 shiftKeyCount;
+	KeyCode		 mouseKey;
+	KeyCode		 inactiveKey;
+	KeyCode		 slowKey;
+	KeyCode		 repeatKey;
+	CARD8		 krgTimerActive;
+	CARD8		 beepType;
+	CARD8		 beepCount;
+
+	CARD32		 flags;
+	CARD32		 lastPtrEventTime;
+	CARD32		 lastShiftEventTime;
+	OsTimerPtr	 beepTimer;
+	OsTimerPtr	 mouseKeyTimer;
+	OsTimerPtr	 slowKeysTimer;
+	OsTimerPtr	 bounceKeysTimer;
+	OsTimerPtr	 repeatKeyTimer;
+	OsTimerPtr	 krgTimer;
+} XkbSrvInfoRec, *XkbSrvInfoPtr;
+
+#define	XkbSLI_IsDefault	(1L<<0)
+#define	XkbSLI_HasOwnState	(1L<<1)
+
+typedef struct	_XkbSrvLedInfo {
+	CARD16			flags;
+	CARD16			class;
+	CARD16			id;
+	union {
+	    KbdFeedbackPtr	kf;
+	    LedFeedbackPtr	lf;
+	} 			fb;
+
+	CARD32			physIndicators;
+	CARD32			autoState;
+	CARD32			explicitState;
+	CARD32			effectiveState;
+
+	CARD32			mapsPresent;
+	CARD32			namesPresent;
+	XkbIndicatorMapPtr	maps;
+	Atom *			names;
+
+	CARD32			usesBase;
+	CARD32			usesLatched;
+	CARD32			usesLocked;
+	CARD32			usesEffective;
+	CARD32			usesCompat;
+	CARD32			usesControls;
+
+	CARD32			usedComponents;
+} XkbSrvLedInfoRec, *XkbSrvLedInfoPtr;
+
+/*
+ * Settings for xkbClientFlags field (used by DIX)
+ * These flags _must_ not overlap with XkbPCF_*
+ */
+#define	_XkbClientInitialized		(1<<15)
+
+#define	_XkbWantsDetectableAutoRepeat(c)\
+	((c)->xkbClientFlags&XkbPCF_DetectableAutoRepeatMask)
+
+/*
+ * Settings for flags field
+ */
+#define	_XkbStateNotifyInProgress	(1<<0)
+
+typedef struct
+{
+    ProcessInputProc processInputProc;
+    ProcessInputProc realInputProc;
+    DeviceUnwrapProc unwrapProc;
+} xkbDeviceInfoRec, *xkbDeviceInfoPtr;
+
+#define WRAP_PROCESS_INPUT_PROC(device, oldprocs, proc, unwrapproc) \
+	device->public.processInputProc = proc; \
+	oldprocs->processInputProc = \
+	oldprocs->realInputProc = device->public.realInputProc; \
+	device->public.realInputProc = proc; \
+	oldprocs->unwrapProc = device->unwrapProc; \
+	device->unwrapProc = unwrapproc;
+
+#define COND_WRAP_PROCESS_INPUT_PROC(device, oldprocs, proc, unwrapproc) \
+	if (device->public.processInputProc == device->public.realInputProc)\
+	    device->public.processInputProc = proc; \
+	oldprocs->processInputProc = \
+	oldprocs->realInputProc = device->public.realInputProc; \
+	device->public.realInputProc = proc; \
+	oldprocs->unwrapProc = device->unwrapProc; \
+	device->unwrapProc = unwrapproc;
+
+#define UNWRAP_PROCESS_INPUT_PROC(device, oldprocs) \
+	device->public.processInputProc = oldprocs->processInputProc; \
+	device->public.realInputProc = oldprocs->realInputProc; \
+	device->unwrapProc = oldprocs->unwrapProc;
+
+#define XKBDEVICEINFO(dev) ((xkbDeviceInfoPtr) (dev)->devPrivates[xkbDevicePrivateIndex].ptr)
+
+/***====================================================================***/
+
+
+/***====================================================================***/
+
+#define XkbAX_KRGMask	 (XkbSlowKeysMask|XkbBounceKeysMask)
+#define	XkbAllFilteredEventsMask \
+	(XkbAccessXKeysMask|XkbRepeatKeysMask|XkbMouseKeysAccelMask|XkbAX_KRGMask)
+
+/***====================================================================***/
+
+extern int	XkbReqCode;
+extern int	XkbEventBase;
+extern int	XkbDisableLockActions;
+extern char *	XkbBaseDirectory;
+extern char *	XkbBinDirectory;
+extern char *	XkbInitialMap;
+extern unsigned	int XkbXIUnsupported;
+
+extern Bool	noXkbExtension;
+
+extern pointer	XkbLastRepeatEvent;
+
+extern CARD32	xkbDebugFlags;
+
+#define	_XkbAlloc(s)		xalloc((s))
+#define	_XkbCalloc(n,s)		Xcalloc((n)*(s))
+#define	_XkbRealloc(o,s)	Xrealloc((o),(s))
+#define	_XkbTypedAlloc(t)	((t *)xalloc(sizeof(t)))
+#define	_XkbTypedCalloc(n,t)	((t *)Xcalloc((n)*sizeof(t)))
+#define	_XkbTypedRealloc(o,n,t) \
+	((o)?(t *)Xrealloc((o),(n)*sizeof(t)):_XkbTypedCalloc(n,t))
+#define	_XkbClearElems(a,f,l,t)	bzero(&(a)[f],((l)-(f)+1)*sizeof(t))
+#define	_XkbFree(p)		Xfree(p)
+
+#define	_XkbLibError(c,l,d) \
+	{ _XkbErrCode= (c); _XkbErrLocation= (l); _XkbErrData= (d); }
+#define	_XkbErrCode2(a,b) ((XID)((((unsigned int)(a))<<24)|((b)&0xffffff)))
+#define	_XkbErrCode3(a,b,c)	_XkbErrCode2(a,(((unsigned int)(b))<<16)|(c))
+#define	_XkbErrCode4(a,b,c,d) _XkbErrCode3(a,b,((((unsigned int)(c))<<8)|(d)))
+
+extern	int	DeviceKeyPress,DeviceKeyRelease;
+extern	int	DeviceButtonPress,DeviceButtonRelease;
+
+#ifdef XINPUT
+#define	_XkbIsPressEvent(t)	(((t)==KeyPress)||((t)==DeviceKeyPress))
+#define	_XkbIsReleaseEvent(t)	(((t)==KeyRelease)||((t)==DeviceKeyRelease))
+#else
+#define	_XkbIsPressEvent(t)	((t)==KeyPress)
+#define	_XkbIsReleaseEvent(t)	((t)==KeyRelease)
+#endif
+
+#define	_XkbCoreKeycodeInRange(c,k)	(((k)>=(c)->curKeySyms.minKeyCode)&&\
+					 ((k)<=(c)->curKeySyms.maxKeyCode))
+#define	_XkbCoreNumKeys(c)	((c)->curKeySyms.maxKeyCode-\
+				 (c)->curKeySyms.minKeyCode+1)
+
+#define	XConvertCase(s,l,u)	XkbConvertCase(s,l,u)
+#undef	IsKeypadKey
+#define	IsKeypadKey(s)		XkbKSIsKeypad(s)
+
+#define	Status		int
+#define	XPointer	pointer
+#define	Display		struct _XDisplay
+
+#ifndef True
+#define	True	1
+#define	False	0
+#endif
+
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define	PATH_MAX MAXPATHLEN
+#else
+#define	PATH_MAX 1024
+#endif
+#endif
+
+_XFUNCPROTOBEGIN
+
+extern void XkbUseMsg(
+    void
+);
+
+extern int XkbProcessArguments(
+    int				/* argc */,
+    char **			/* argv */,
+    int				/* i */
+);
+
+extern	void	XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc);
+
+extern	void	XkbFreeCompatMap(
+    XkbDescPtr			/* xkb */,
+    unsigned int		/* which */,
+    Bool			/* freeMap */
+);
+
+extern	void XkbFreeNames(
+	XkbDescPtr		/* xkb */,
+	unsigned int		/* which */,
+	Bool			/* freeMap */
+);
+
+extern DeviceIntPtr _XkbLookupAnyDevice(
+    int			/* id */,
+    int *		/* why_rtrn */
+);
+
+extern DeviceIntPtr _XkbLookupKeyboard(
+    int			/* id */,
+    int *		/* why_rtrn */
+);
+
+extern DeviceIntPtr _XkbLookupBellDevice(
+    int			/* id */,
+    int *		/* why_rtrn */
+);
+
+extern DeviceIntPtr _XkbLookupLedDevice(
+    int			/* id */,
+    int *		/* why_rtrn */
+);
+
+extern DeviceIntPtr _XkbLookupButtonDevice(
+    int			/* id */,
+    int *		/* why_rtrn */
+);
+
+extern	XkbDescPtr XkbAllocKeyboard(
+	void
+);
+
+extern	Status XkbAllocClientMap(
+	XkbDescPtr		/* xkb */,
+	unsigned int		/* which */,
+	unsigned int		/* nTypes */
+);
+
+extern	Status XkbAllocServerMap(
+	XkbDescPtr		/* xkb */,
+	unsigned int		/* which */,
+	unsigned int		/* nNewActions */
+);
+
+extern	void	XkbFreeClientMap(
+    XkbDescPtr			/* xkb */,
+    unsigned int		/* what */,
+    Bool			/* freeMap */
+);
+
+extern	void	XkbFreeServerMap(
+    XkbDescPtr			/* xkb */,
+    unsigned int		/* what */,
+    Bool			/* freeMap */
+);
+
+extern	Status XkbAllocIndicatorMaps(
+	XkbDescPtr		/* xkb */
+);
+
+extern	Status	XkbAllocCompatMap(
+    XkbDescPtr			/* xkb */,
+    unsigned int		/* which */,
+    unsigned int		/* nInterpret */
+);
+
+extern	Status XkbAllocNames(
+	XkbDescPtr		/* xkb */,
+	unsigned int		/* which */,
+	int			/* nTotalRG */,
+	int			/* nTotalAliases */
+);
+
+extern	Status	XkbAllocControls(
+	XkbDescPtr		/* xkb */,
+	unsigned int		/* which*/
+);
+
+extern	Status	XkbCopyKeyTypes(
+    XkbKeyTypePtr		/* from */,
+    XkbKeyTypePtr		/* into */,
+    int				/* num_types */
+);
+
+extern	Status	XkbResizeKeyType(
+    XkbDescPtr		/* xkb */,
+    int			/* type_ndx */,
+    int			/* map_count */,
+    Bool		/* want_preserve */,
+    int			/* new_num_lvls */
+);
+
+extern	void	XkbFreeKeyboard(
+	XkbDescPtr		/* xkb */,
+	unsigned int		/* which */,
+	Bool			/* freeDesc */
+);
+
+extern  void XkbSetActionKeyMods(
+	XkbDescPtr		/* xkb */,
+	XkbAction *		/* act */,
+	unsigned int 		/* mods */
+);
+
+extern Bool XkbCheckActionVMods(
+	XkbDescPtr		/* xkb */,
+	XkbAction *		/* act */,
+	unsigned int 		/* changed */
+);
+
+extern	unsigned int XkbMaskForVMask(
+    XkbDescPtr		/* xkb */,
+    unsigned int	/* vmask */
+);
+
+extern Bool XkbVirtualModsToReal(
+	XkbDescPtr	/* xkb */,
+	unsigned int	/* virtua_mask */,
+	unsigned int *	/* mask_rtrn */
+);
+
+extern	unsigned int	XkbAdjustGroup(
+    int			/* group */,
+    XkbControlsPtr	/* ctrls */
+);
+
+extern KeySym *XkbResizeKeySyms(
+    XkbDescPtr		/* xkb */,
+    int 		/* key */,
+    int 		/* needed */
+);
+
+extern XkbAction *XkbResizeKeyActions(
+    XkbDescPtr		/* xkb */,
+    int 		/* key */,
+    int 		/* needed */
+);
+
+extern void XkbUpdateKeyTypesFromCore(
+    DeviceIntPtr	/* pXDev */,
+    KeyCode 		/* first */,
+    CARD8 		/* num */,
+    XkbChangesPtr	/* pChanges */
+);
+
+extern	void XkbUpdateDescActions(	
+    XkbDescPtr		/* xkb */,
+    KeyCode		/* first */,
+    CARD8		/* num */,
+    XkbChangesPtr	/* changes */
+);
+
+extern void XkbUpdateActions(
+    DeviceIntPtr	/* pXDev */,
+    KeyCode 		/* first */,
+    CARD8 		/* num */,
+    XkbChangesPtr  	/* pChanges */,
+    unsigned int *	/* needChecksRtrn */,
+    XkbEventCausePtr	/* cause */
+);
+
+extern void XkbUpdateCoreDescription(
+    DeviceIntPtr	/* keybd */,
+    Bool		/* resize */
+);
+
+extern void XkbApplyMappingChange(
+    DeviceIntPtr	/* pXDev */,
+    CARD8 		/* request */,
+    KeyCode 		/* firstKey */,
+    CARD8 		/* num */,
+    ClientPtr		/* client */
+);
+
+extern void XkbSetIndicators(
+    DeviceIntPtr		/* pXDev */,
+    CARD32			/* affect */,
+    CARD32			/* values */,
+    XkbEventCausePtr		/* cause */
+);
+
+extern void XkbUpdateIndicators(
+    DeviceIntPtr		/* keybd */,
+    CARD32		 	/* changed */,
+    Bool			/* check_edevs */,
+    XkbChangesPtr		/* pChanges */,
+    XkbEventCausePtr		/* cause */
+);
+
+extern XkbSrvLedInfoPtr XkbAllocSrvLedInfo(
+    DeviceIntPtr		/* dev */,
+    KbdFeedbackPtr		/* kf */,
+    LedFeedbackPtr		/* lf */,
+    unsigned int		/* needed_parts */
+);
+
+extern XkbSrvLedInfoPtr XkbFindSrvLedInfo(
+    DeviceIntPtr		/* dev */,
+    unsigned int		/* class */,
+    unsigned int		/* id */,
+    unsigned int		/* needed_parts */
+);
+
+extern void XkbApplyLedNameChanges(
+    DeviceIntPtr		/* dev */,
+    XkbSrvLedInfoPtr		/* sli */,
+    unsigned int		/* changed_names */,
+    xkbExtensionDeviceNotify *	/* ed */,
+    XkbChangesPtr		/* changes */,
+    XkbEventCausePtr		/* cause */
+);
+
+extern void XkbApplyLedMapChanges(
+    DeviceIntPtr		/* dev */,
+    XkbSrvLedInfoPtr		/* sli */,
+    unsigned int		/* changed_maps */,
+    xkbExtensionDeviceNotify *	/* ed */,
+    XkbChangesPtr		/* changes */,
+    XkbEventCausePtr		/* cause */
+);
+
+extern void XkbApplyLedStateChanges(
+    DeviceIntPtr		/* dev */,
+    XkbSrvLedInfoPtr		/* sli */,
+    unsigned int		/* changed_leds */,
+    xkbExtensionDeviceNotify *	/* ed */,
+    XkbChangesPtr		/* changes */,
+    XkbEventCausePtr		/* cause */
+);
+
+extern void XkbFlushLedEvents(	
+    DeviceIntPtr		/* dev */,
+    DeviceIntPtr		/* kbd */,
+    XkbSrvLedInfoPtr		/* sli */,
+    xkbExtensionDeviceNotify *	/* ed */,
+    XkbChangesPtr		/* changes */,
+    XkbEventCausePtr		/* cause */
+);
+
+extern unsigned int XkbIndicatorsToUpdate(
+    DeviceIntPtr		/* dev */,
+    unsigned long		/* state_changes */,
+    Bool			/* enabled_ctrl_changes */
+);
+
+extern void XkbComputeDerivedState(
+    XkbSrvInfoPtr		/* xkbi */
+);
+
+extern void XkbCheckSecondaryEffects(
+    XkbSrvInfoPtr		/* xkbi */,
+    unsigned int		/* which */,
+    XkbChangesPtr		/* changes */,
+    XkbEventCausePtr		/* cause */
+);
+
+extern void XkbCheckIndicatorMaps(
+    DeviceIntPtr		/* dev */,
+    XkbSrvLedInfoPtr		/* sli */,
+    unsigned int		/* which */
+);
+
+extern unsigned int XkbStateChangedFlags(
+    XkbStatePtr			/* old */,
+    XkbStatePtr			/* new */
+);
+
+extern	void XkbSendStateNotify(
+       DeviceIntPtr	/* kbd */,
+       xkbStateNotify *	/* pSN */
+);
+
+extern	void XkbSendMapNotify(
+       DeviceIntPtr	/* kbd */,
+       xkbMapNotify *	/* ev */
+);
+
+extern	int  XkbComputeControlsNotify(
+	DeviceIntPtr		/* kbd */,
+	XkbControlsPtr		/* old */,
+	XkbControlsPtr		/* new */,
+	xkbControlsNotify *	/* pCN */,
+	Bool			/* forceCtrlProc */
+);
+
+extern	void XkbSendControlsNotify(
+       DeviceIntPtr		/* kbd */,
+       xkbControlsNotify *	/* ev */
+);
+
+extern	void XkbSendCompatMapNotify(
+	DeviceIntPtr		/* kbd */,
+	xkbCompatMapNotify *	/* ev */
+);
+
+extern	void XkbHandleBell(
+       BOOL		/* force */,
+       BOOL		/* eventOnly */,
+       DeviceIntPtr	/* kbd */,
+       CARD8		/* percent */,
+       pointer 		/* ctrl */,
+       CARD8		/* class */,
+       Atom		/* name */,
+       WindowPtr	/* pWin */,
+       ClientPtr	/* pClient */
+);
+
+extern	void XkbSendAccessXNotify(
+       DeviceIntPtr		/* kbd */,
+       xkbAccessXNotify *	/* pEv */
+);
+
+extern	void XkbSendNamesNotify(
+       DeviceIntPtr	/* kbd */,
+       xkbNamesNotify *	/* ev */
+);
+
+extern	void XkbSendCompatNotify(
+       DeviceIntPtr		/* kbd */,
+       xkbCompatMapNotify *	/* ev */
+);
+
+extern	void XkbSendActionMessage(
+       DeviceIntPtr		/* kbd */,
+       xkbActionMessage *	/* ev */
+);
+
+extern	void XkbSendExtensionDeviceNotify(
+       DeviceIntPtr			/* kbd */,
+       ClientPtr			/* client */,
+       xkbExtensionDeviceNotify *	/* ev */
+);
+
+extern void XkbSendNotification(
+    DeviceIntPtr		/* kbd */,
+    XkbChangesPtr		/* pChanges */,
+    XkbEventCausePtr		/* cause */
+);
+
+extern void XkbProcessKeyboardEvent(
+    struct _xEvent * 		/* xE */,
+    DeviceIntPtr		/* keybd */,
+    int 			/* count */
+);
+
+extern void XkbHandleActions(
+    DeviceIntPtr		/* dev */,
+    DeviceIntPtr		/* kbd */,
+    struct _xEvent * 		/* xE */,
+    int 			/* count */
+);
+
+extern Bool XkbEnableDisableControls(
+    XkbSrvInfoPtr	/* xkbi */,
+    unsigned long	/* change */,
+    unsigned long	/* newValues */,
+    XkbChangesPtr	/* changes */,
+    XkbEventCausePtr	/* cause */
+);
+
+extern void AccessXInit(
+    DeviceIntPtr        /* dev */
+);
+
+extern Bool AccessXFilterPressEvent(
+    register struct _xEvent *	/* xE */,
+    register DeviceIntPtr	/* keybd */,
+    int				/* count */
+);
+
+extern Bool AccessXFilterReleaseEvent(
+    register struct _xEvent *	/* xE */,
+    register DeviceIntPtr	/* keybd */,
+    int				/* count */
+);
+
+extern void AccessXCancelRepeatKey(
+    XkbSrvInfoPtr	/* xkbi */,
+    KeyCode		/* key */
+);
+
+extern void AccessXComputeCurveFactor(
+    XkbSrvInfoPtr	/* xkbi */,
+    XkbControlsPtr	/* ctrls */
+);
+
+extern	XkbInterestPtr XkbFindClientResource(
+       DevicePtr	/* inDev */,
+       ClientPtr	/* client */
+);
+
+extern	XkbInterestPtr XkbAddClientResource(
+       DevicePtr	/* inDev */,
+       ClientPtr	/* client */,
+       XID		/* id */
+);
+
+extern	int XkbRemoveResourceClient(
+       DevicePtr	/* inDev */,
+       XID		/* id */
+);
+
+extern int XkbDDXInitDevice(
+    DeviceIntPtr        /* dev */
+);
+
+extern	int XkbDDXAccessXBeep(
+    DeviceIntPtr        /* dev */,
+    unsigned int	/* what */,
+    unsigned int	/* which */
+);
+
+extern	void XkbDDXKeyClick(
+    DeviceIntPtr	/* dev */,
+    int			/* keycode */,
+    int			/* synthetic */
+);
+
+extern 	int XkbDDXUsesSoftRepeat(
+    DeviceIntPtr	/* dev */
+);
+
+extern	void XkbDDXKeybdCtrlProc(
+	DeviceIntPtr	/* dev */,
+	KeybdCtrl *	/* ctrl */
+);
+
+extern void XkbDDXChangeControls(
+	DeviceIntPtr	/* dev */,
+	XkbControlsPtr 	/* old */,
+	XkbControlsPtr 	/* new */
+);
+
+extern void XkbDDXUpdateDeviceIndicators(
+	DeviceIntPtr		/* dev */,
+	XkbSrvLedInfoPtr	/* sli */,
+	CARD32			/* newState */
+);
+
+extern void XkbDDXFakePointerButton(
+	int 		/* event */,
+	int		/* button */
+);
+
+extern void XkbDDXFakePointerMotion(
+ 	unsigned int	/* flags */,
+	int		/* x */,
+	int		/* y */
+);
+
+extern void XkbDDXFakeDeviceButton(
+	DeviceIntPtr	/* dev */,
+	Bool		/* press */,
+	int		/* button */
+);
+
+extern int XkbDDXTerminateServer(
+	DeviceIntPtr	/* dev */,
+	KeyCode		/* key */,
+	XkbAction *	/* act */
+);
+
+extern int XkbDDXSwitchScreen(
+	DeviceIntPtr	/* dev */,
+	KeyCode		/* key */,
+	XkbAction *	/* act */
+);
+
+extern int XkbDDXPrivate(
+	DeviceIntPtr	/* dev */,
+	KeyCode		/* key */,
+	XkbAction *	/* act */
+);
+
+extern void XkbDisableComputedAutoRepeats(
+	DeviceIntPtr 	/* pXDev */,
+	unsigned int	/* key */
+);
+
+extern void XkbSetRepeatKeys(
+	DeviceIntPtr 	/* pXDev */,
+	int		/* key */,
+	int	 	/* onoff */
+);
+
+extern	int XkbLatchModifiers(
+	DeviceIntPtr 	/* pXDev */,
+	CARD8 		/* mask */,
+	CARD8 		/* latches */
+);
+
+extern	int XkbLatchGroup(
+	DeviceIntPtr  	/* pXDev */,
+	int	  	/* group */
+);
+
+extern	void XkbClearAllLatchesAndLocks(
+	DeviceIntPtr		/* dev */,
+	XkbSrvInfoPtr		/* xkbi */,
+	Bool			/* genEv */,
+	XkbEventCausePtr	/* cause */
+);
+
+extern	void	XkbSetRulesDflts(
+	char *			/* rulesFile */,
+	char *			/* model */,
+	char *			/* layout */,
+	char *			/* variant */,
+	char *			/* options */
+);
+
+extern	void	XkbInitDevice(
+	DeviceIntPtr 	/* pXDev */
+);
+
+extern	Bool	XkbInitKeyboardDeviceStruct(
+	DeviceIntPtr 		/* pXDev */,
+	XkbComponentNamesPtr	/* pNames */,
+	KeySymsPtr		/* pSyms */,
+	CARD8 			/* pMods */[],
+	BellProcPtr		/* bellProc */,
+	KbdCtrlProcPtr		/* ctrlProc */
+);
+
+extern	int SProcXkbDispatch(
+	ClientPtr		/* client */
+);
+
+extern XkbGeometryPtr XkbLookupNamedGeometry(
+	DeviceIntPtr		/* dev */,
+	Atom			/* name */,
+	Bool *			/* shouldFree */
+);
+
+extern char *	_XkbDupString(
+	char *			/* str */
+);
+
+extern void	XkbConvertCase(
+	KeySym 			/* sym */,
+	KeySym *		/* lower */,
+	KeySym *		/* upper */
+);
+
+extern	Status	 XkbChangeKeycodeRange(	
+	XkbDescPtr		/* xkb */,
+	int 			/* minKC */,
+	int 			/* maxKC */,
+	XkbChangesPtr		/* changes */
+);
+
+extern int XkbFinishDeviceInit(
+	DeviceIntPtr		/* pXDev */
+);
+
+extern void XkbFreeSrvLedInfo(
+	XkbSrvLedInfoPtr	/* sli */
+);
+
+extern void XkbFreeInfo(
+	XkbSrvInfoPtr		/* xkbi */
+);
+
+extern Status XkbChangeTypesOfKey(
+	XkbDescPtr		/* xkb */,
+	int			/* key */,
+	int			/* nGroups */,
+	unsigned int		/* groups */,
+	int *			/* newTypesIn */,
+	XkbMapChangesPtr	/* changes */
+);
+
+extern int XkbKeyTypesForCoreSymbols(
+	XkbDescPtr		/* xkb */,
+	int			/* map_width */,
+	KeySym *		/* core_syms */,
+	unsigned int		/* protected */,
+	int *			/* types_inout */,
+	KeySym *		/* xkb_syms_rtrn */
+);
+
+extern Bool XkbApplyCompatMapToKey(
+	XkbDescPtr		/* xkb */,
+	KeyCode			/* key */,
+	XkbChangesPtr		/* changes */
+);
+
+extern Bool XkbApplyVirtualModChanges(
+	XkbDescPtr		/* xkb */,
+	unsigned int		/* changed */,
+	XkbChangesPtr		/* changes */
+);
+
+extern void XkbSendNewKeyboardNotify(
+	DeviceIntPtr		/* kbd */,
+	xkbNewKeyboardNotify *	/* pNKN */
+);
+
+#ifdef XKBSRV_NEED_FILE_FUNCS
+
+#include <X11/extensions/XKMformat.h>
+#include <X11/extensions/XKBfile.h>
+#include <X11/extensions/XKBrules.h>
+
+#define	_XkbListKeymaps		0
+#define	_XkbListKeycodes	1
+#define	_XkbListTypes		2
+#define	_XkbListCompat		3
+#define	_XkbListSymbols		4
+#define	_XkbListGeometry	5
+#define	_XkbListNumComponents	6
+
+typedef struct _XkbSrvListInfo {
+	int		szPool;
+	int		nPool;
+	char *		pool;
+
+	int		maxRtrn;
+	int		nTotal;
+
+	char *		pattern[_XkbListNumComponents];
+	int		nFound[_XkbListNumComponents];
+} XkbSrvListInfoRec,*XkbSrvListInfoPtr;
+
+extern	Status	XkbDDXList(
+	DeviceIntPtr		/* dev */,
+	XkbSrvListInfoPtr	/* listing */,
+	ClientPtr		/* client */
+);
+
+extern	unsigned int XkbDDXLoadKeymapByNames(
+	DeviceIntPtr		/* keybd */,
+	XkbComponentNamesPtr	/* names */,
+	unsigned int		/* want */,
+	unsigned int		/* need */,
+	XkbFileInfoPtr		/* finfoRtrn */,
+	char *			/* keymapNameRtrn */,
+	int 			/* keymapNameRtrnLen */
+);
+
+extern	Bool XkbDDXNamesFromRules(
+	DeviceIntPtr		/* keybd */,
+	char *			/* rules */,
+	XkbRF_VarDefsPtr	/* defs */,
+	XkbComponentNamesPtr	/* names */
+);
+
+extern	Bool XkbDDXApplyConfig(
+	XPointer	/* cfg_in */,
+	XkbSrvInfoPtr	/* xkbi */
+);
+
+extern XPointer XkbDDXPreloadConfig(
+	char **			/* rulesFileRtrn */,
+	XkbRF_VarDefsPtr	/* defs */,
+	XkbComponentNamesPtr	/* names */,
+	DeviceIntPtr		/* dev */
+);
+
+extern	int _XkbStrCaseCmp(
+	char *			/* str1 */,
+	char *			/* str2 */
+);
+
+#endif /* XKBSRV_NEED_FILE_FUNCS */
+
+_XFUNCPROTOEND
+
+#define	XkbAtomGetString(d,s)	NameForAtom(s)
+
+#endif /* _XKBSRV_H_ */
diff --git a/os/utils.c b/os/utils.c
index 612c264..06c9b88 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -117,7 +117,7 @@ OR PERFORMANCE OF THIS SOFTWARE.
 #endif
 
 #ifdef XKB
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #endif
 #ifdef XCSECURITY
 #include "securitysrv.h"
diff --git a/xkb/Makefile.am b/xkb/Makefile.am
index 996d527..78cdf71 100644
--- a/xkb/Makefile.am
+++ b/xkb/Makefile.am
@@ -41,7 +41,8 @@ X11_SRCS = \
         XKBGAlloc.c \
         XKBMAlloc.c
 
-XI_SRCS = xkbPrOtherEv.c
+# ends up unused...
+# XI_SRCS = xkbPrOtherEv.c
 
 libxkb_la_SOURCES = $(DDX_SRCS) $(DIX_SRCS) $(XI_SRCS) $(XKBFILE_SRCS) \
                     $(X11_SRCS)
diff --git a/xkb/XKBAlloc.c b/xkb/XKBAlloc.c
index c474733..f0a1f89 100644
--- a/xkb/XKBAlloc.c
+++ b/xkb/XKBAlloc.c
@@ -35,7 +35,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/Xproto.h>
 #include "misc.h"
 #include "inputstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XKBgeom.h>
 
 /***===================================================================***/
@@ -259,7 +259,7 @@ XkbAllocControls(XkbDescPtr xkb,unsigned
 }
 
 /*ARGSUSED*/
-void
+static void
 XkbFreeControls(XkbDescPtr xkb,unsigned which,Bool freeMap)
 {
     if (freeMap && (xkb!=NULL) && (xkb->ctrls!=NULL)) {
@@ -284,7 +284,7 @@ XkbAllocIndicatorMaps(XkbDescPtr xkb)
     return Success;
 }
 
-void
+static void
 XkbFreeIndicatorMaps(XkbDescPtr xkb)
 {
     if ((xkb!=NULL)&&(xkb->indicators!=NULL)) {
@@ -335,154 +335,3 @@ XkbFreeKeyboard(XkbDescPtr xkb,unsigned 
 	_XkbFree(xkb);
     return;
 }
-
-/***====================================================================***/
-
-XkbDeviceLedInfoPtr
-XkbAddDeviceLedInfo(XkbDeviceInfoPtr devi,unsigned ledClass,unsigned ledId)
-{
-XkbDeviceLedInfoPtr	devli;
-register int		i;
-
-    if ((!devi)||(!XkbSingleXIClass(ledClass))||(!XkbSingleXIId(ledId)))
-	return NULL;
-    for (i=0,devli=devi->leds;i<devi->num_leds;i++,devli++) {
-	if ((devli->led_class==ledClass)&&(devli->led_id==ledId))
-	    return devli;
-    }
-    if (devi->num_leds>=devi->sz_leds) {
-	XkbDeviceLedInfoRec *prev_leds = devi->leds;
-	
-	if (devi->sz_leds>0)	devi->sz_leds*= 2;
-	else			devi->sz_leds= 1;
-	devi->leds= _XkbTypedRealloc(devi->leds,devi->sz_leds,
-							XkbDeviceLedInfoRec);
-	if (!devi->leds) {
-	    _XkbFree(prev_leds);
-	    devi->sz_leds= devi->num_leds= 0;
-	    return NULL;
-	}
-	i= devi->num_leds;
-	for (devli=&devi->leds[i];i<devi->sz_leds;i++,devli++) {
-	    bzero(devli,sizeof(XkbDeviceLedInfoRec));
-	    devli->led_class= XkbXINone;
-	    devli->led_id= XkbXINone;
-	}
-    }
-    devli= &devi->leds[devi->num_leds++];
-    bzero(devli,sizeof(XkbDeviceLedInfoRec));
-    devli->led_class= ledClass;
-    devli->led_id= ledId;
-    return devli;
-}
-
-Status
-XkbResizeDeviceButtonActions(XkbDeviceInfoPtr devi,unsigned newTotal)
-{
-    XkbAction *prev_btn_acts;
-
-    if ((!devi)||(newTotal>255))
-	return BadValue;
-    if ((devi->btn_acts!=NULL)&&(newTotal==devi->num_btns))
-	return Success;
-    if (newTotal==0) {
-	if (devi->btn_acts!=NULL) {
-	    _XkbFree(devi->btn_acts);
-	    devi->btn_acts= NULL;
-	}
-	devi->num_btns= 0;
-	return Success;
-    }
-    prev_btn_acts = devi->btn_acts;
-    devi->btn_acts= _XkbTypedRealloc(devi->btn_acts,newTotal,XkbAction);
-    if (devi->btn_acts==NULL) {
-	_XkbFree(prev_btn_acts);
-	devi->num_btns= 0;
-	return BadAlloc;
-    }
-    if (newTotal>devi->num_btns) {
-	XkbAction *act;
-	act= &devi->btn_acts[devi->num_btns];
-	bzero((char *)act,(newTotal-devi->num_btns)*sizeof(XkbAction));
-    }
-    devi->num_btns= newTotal;
-    return Success;
-}
-
-/*ARGSUSED*/
-XkbDeviceInfoPtr
-XkbAllocDeviceInfo(unsigned deviceSpec,unsigned nButtons,unsigned szLeds)
-{
-XkbDeviceInfoPtr	devi;
-
-    devi= _XkbTypedCalloc(1,XkbDeviceInfoRec);
-    if (devi!=NULL) {
-	devi->device_spec= deviceSpec;
-	devi->has_own_state= False;
-	devi->num_btns= 0;
-	devi->btn_acts= NULL;
-	if (nButtons>0) {
-	    devi->num_btns= nButtons;
-	    devi->btn_acts= _XkbTypedCalloc(nButtons,XkbAction);
-	    if (!devi->btn_acts) {
-		_XkbFree(devi);
-		return NULL;
-	    }
-	}
-	devi->dflt_kbd_fb= XkbXINone;
-	devi->dflt_led_fb= XkbXINone;
-	devi->num_leds= 0;
-	devi->sz_leds= 0;
-	devi->leds= NULL;
-	if (szLeds>0) {
-	    devi->sz_leds= szLeds;
-	    devi->leds= _XkbTypedCalloc(szLeds,XkbDeviceLedInfoRec);
-	    if (!devi->leds) {
-		if (devi->btn_acts)
-		    _XkbFree(devi->btn_acts);
-		_XkbFree(devi);
-		return NULL;
-	    }
-	}
-    }
-    return devi;
-}
-
-
-void 
-XkbFreeDeviceInfo(XkbDeviceInfoPtr devi,unsigned which,Bool freeDevI)
-{
-    if (devi) {
-	if (freeDevI) {
-	    which= XkbXI_AllDeviceFeaturesMask;
-	    if (devi->name) {
-		_XkbFree(devi->name);
-		devi->name= NULL;
-	    }
-	}
-	if ((which&XkbXI_ButtonActionsMask)&&(devi->btn_acts)) {
-	    _XkbFree(devi->btn_acts);
-	    devi->num_btns= 0;
-	    devi->btn_acts= NULL;
-	}
-	if ((which&XkbXI_IndicatorsMask)&&(devi->leds)) {
-	    register int i;
-	    if ((which&XkbXI_IndicatorsMask)==XkbXI_IndicatorsMask) {
-		_XkbFree(devi->leds);
-		devi->sz_leds= devi->num_leds= 0;
-		devi->leds= NULL;
-	    }
-	    else {
-		XkbDeviceLedInfoPtr	devli;
-		for (i=0,devli=devi->leds;i<devi->num_leds;i++,devli++) {
-		    if (which&XkbXI_IndicatorMapsMask)
-			 bzero((char *)&devli->maps[0],sizeof(devli->maps));
-		    else bzero((char *)&devli->names[0],sizeof(devli->names));
-		}
-	    }
-	}
-	if (freeDevI)
-	    _XkbFree(devi);
-    }
-    return;
-}
diff --git a/xkb/XKBGAlloc.c b/xkb/XKBGAlloc.c
index edaed10..815cc95 100644
--- a/xkb/XKBGAlloc.c
+++ b/xkb/XKBGAlloc.c
@@ -36,7 +36,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/Xproto.h>
 #include "misc.h"
 #include "inputstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XKBgeom.h>
 
 #ifdef X_NOT_POSIX
diff --git a/xkb/XKBMAlloc.c b/xkb/XKBMAlloc.c
index ef4097d..4b7428b 100644
--- a/xkb/XKBMAlloc.c
+++ b/xkb/XKBMAlloc.c
@@ -39,7 +39,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include <X11/keysym.h>
 #define	XKBSRV_NEED_FILE_FUNCS
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 
 /***====================================================================***/
 
@@ -220,7 +220,7 @@ XkbServerMapPtr map;
 
 /***====================================================================***/
 
-Status
+static Status
 XkbCopyKeyType(XkbKeyTypePtr from,XkbKeyTypePtr into)
 {
     if ((!from)||(!into))
@@ -275,82 +275,6 @@ register int i,rtrn;
     return Success;
 }
 
-XkbKeyTypePtr
-XkbAddKeyType(	XkbDescPtr	xkb,
-		Atom 		name,
-		int 		map_count,
-		Bool 		want_preserve,
-		int		num_lvls)
-{
-register int 	i;
-unsigned	tmp;
-XkbKeyTypePtr	type;
-XkbClientMapPtr	map;
-
-    if ((!xkb)||(num_lvls<1))
-	return NULL;
-    map= xkb->map;
-    if ((map)&&(map->types)) {
-	for (i=0;i<map->num_types;i++) {
-	    if (map->types[i].name==name) {
-		Status status;
-		status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls);
-		return (status==Success?&map->types[i]:NULL);
-	    }
-	}
-    }
-    if ((!map)||(!map->types)||(!map->num_types<XkbNumRequiredTypes)) {
-	tmp= XkbNumRequiredTypes+1;
-	if (XkbAllocClientMap(xkb,XkbKeyTypesMask,tmp)!=Success)
-	    return NULL;
-        map = xkb->map;
-	tmp= 0;
-	if (map->num_types<=XkbKeypadIndex)
-	    tmp|= XkbKeypadMask;
-	if (map->num_types<=XkbAlphabeticIndex)
-	    tmp|= XkbAlphabeticMask;
-	if (map->num_types<=XkbTwoLevelIndex)
-	    tmp|= XkbTwoLevelMask;
-	if (map->num_types<=XkbOneLevelIndex)
-	    tmp|= XkbOneLevelMask;
-	if (XkbInitCanonicalKeyTypes(xkb,tmp,XkbNoModifier)==Success) {
-	    for (i=0;i<map->num_types;i++) {
-		Status status;
-		if (map->types[i].name!=name)
-		    continue;
-		status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls);
-		return (status==Success?&map->types[i]:NULL);
-	    }
-	}
-    }
-    if ((map->num_types<=map->size_types)&&
-	(XkbAllocClientMap(xkb,XkbKeyTypesMask,map->num_types+1)!=Success)) {
-	return NULL;
-    }
-    type= &map->types[map->num_types];
-    map->num_types++;
-    bzero((char *)type,sizeof(XkbKeyTypeRec));
-    type->num_levels=	num_lvls;
-    type->map_count=	map_count;
-    type->name=		name;
-    if (map_count>0) {
-	type->map=	_XkbTypedCalloc(map_count,XkbKTMapEntryRec);
-	if (!type->map) {
-	    map->num_types--;
-	    return NULL;
-	}
-	if (want_preserve) {
-	    type->preserve=	_XkbTypedCalloc(map_count,XkbModsRec);
-	    if (!type->preserve) {
-		_XkbFree(type->map);
-		map->num_types--;
-		return NULL;
-	    }
-	}
-    }
-    return type;
-}
-
 Status
 XkbResizeKeyType(	XkbDescPtr	xkb,
 			int		type_ndx,
diff --git a/xkb/XKBMisc.c b/xkb/XKBMisc.c
index 7ed4769..0404108 100644
--- a/xkb/XKBMisc.c
+++ b/xkb/XKBMisc.c
@@ -39,102 +39,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include <X11/keysym.h>
 #define	XKBSRV_NEED_FILE_FUNCS
-#include <X11/extensions/XKBsrv.h>
-
-/***====================================================================***/
-
-#define	mapSize(m)	(sizeof(m)/sizeof(XkbKTMapEntryRec))
-static  XkbKTMapEntryRec map2Level[]= { 
-  { True, ShiftMask, {1, ShiftMask, 0} }
-};
-
-static  XkbKTMapEntryRec mapAlpha[]= { 
-  { True, ShiftMask, { 1, ShiftMask, 0 } },
-  { True, LockMask,  { 0,  LockMask, 0 } }
-};
-
-static	XkbModsRec preAlpha[]= {
-	{        0,        0, 0 },
-	{ LockMask, LockMask, 0 }
-};
-
-#define	NL_VMOD_MASK	0
-static  XkbKTMapEntryRec mapKeypad[]= { 
-	{ True,	ShiftMask, { 1, ShiftMask,            0 } },
-	{ False,        0, { 1,         0, NL_VMOD_MASK } }
-};
-
-static	XkbKeyTypeRec	canonicalTypes[XkbNumRequiredTypes] = {
-	{ { 0, 0, 0 }, 
-	  1,	/* num_levels */
-	  0,	/* map_count */
-	  NULL,		NULL,
-	  None,		NULL
-	},
-	{ { ShiftMask, ShiftMask, 0 }, 
-	  2,	/* num_levels */
-	  mapSize(map2Level),	/* map_count */
-	  map2Level,	NULL,
-	  None,		NULL
-	},
-	{ { ShiftMask|LockMask, ShiftMask|LockMask, 0 }, 
-	  2,				/* num_levels */
-	  mapSize(mapAlpha),		/* map_count */
-	  mapAlpha,	preAlpha,
-	  None,		NULL
-	},
-	{ { ShiftMask, ShiftMask, NL_VMOD_MASK },
-	  2,				/* num_levels */
-	  mapSize(mapKeypad),		/* map_count */
-	  mapKeypad,	NULL,
-	  None,		NULL
-	}
-};
-
-Status
-XkbInitCanonicalKeyTypes(XkbDescPtr xkb,unsigned which,int keypadVMod)
-{
-XkbClientMapPtr	map;
-XkbKeyTypePtr	from,to;
-Status		rtrn;
-
-    if (!xkb)
-	return BadMatch;
-    rtrn= XkbAllocClientMap(xkb,XkbKeyTypesMask,XkbNumRequiredTypes);
-    if (rtrn!=Success)
-	return rtrn;
-    map= xkb->map;
-    if ((which&XkbAllRequiredTypes)==0)
-	return Success;
-    rtrn= Success;
-    from= canonicalTypes;
-    to= map->types;
-    if (which&XkbOneLevelMask)
-	rtrn= XkbCopyKeyType(&from[XkbOneLevelIndex],&to[XkbOneLevelIndex]);
-    if ((which&XkbTwoLevelMask)&&(rtrn==Success))
-	rtrn= XkbCopyKeyType(&from[XkbTwoLevelIndex],&to[XkbTwoLevelIndex]);
-    if ((which&XkbAlphabeticMask)&&(rtrn==Success))
-	rtrn= XkbCopyKeyType(&from[XkbAlphabeticIndex],&to[XkbAlphabeticIndex]);
-    if ((which&XkbKeypadMask)&&(rtrn==Success)) {
-	XkbKeyTypePtr type;
-	rtrn= XkbCopyKeyType(&from[XkbKeypadIndex],&to[XkbKeypadIndex]);
-	type= &to[XkbKeypadIndex];
-	if ((keypadVMod>=0)&&(keypadVMod<XkbNumVirtualMods)&&(rtrn==Success)) {
-	    type->mods.vmods= (1<<keypadVMod);
-	    type->map[0].active= True;
-	    type->map[0].mods.mask= ShiftMask;
-	    type->map[0].mods.real_mods= ShiftMask;
-	    type->map[0].mods.vmods= 0;
-	    type->map[0].level= 1;
-	    type->map[1].active= False;
-	    type->map[1].mods.mask= 0;
-	    type->map[1].mods.real_mods= 0;
-	    type->map[1].mods.vmods= (1<<keypadVMod);
-	    type->map[1].level= 1;
-	}
-    }
-    return Success;
-}
+#include <xkbsrv.h>
 
 /***====================================================================***/
 
@@ -558,88 +463,6 @@ unsigned		changed,tmp;
     return True;
 }
 
-Bool
-XkbUpdateMapFromCore(	XkbDescPtr	xkb,
-			KeyCode		first_key,
-			int		num_keys,
-			int		map_width,
-			KeySym *	core_keysyms,
-			XkbChangesPtr	changes)
-{
-register int	key,last_key;
-KeySym *	syms;
-
-    syms= &core_keysyms[(first_key-xkb->min_key_code)*map_width];
-    if (changes) {
-	if (changes->map.changed&XkbKeySymsMask) {
-	    _XkbAddKeyChange(&changes->map.first_key_sym,
-	    			&changes->map.num_key_syms,first_key);
-	    if (num_keys>1) {
-		_XkbAddKeyChange(&changes->map.first_key_sym,
-						&changes->map.num_key_syms,
-						first_key+num_keys-1);
-	    }
-	}
-	else {
-	    changes->map.changed|= XkbKeySymsMask;
-	    changes->map.first_key_sym= first_key;
-	    changes->map.num_key_syms= num_keys;
-	}
-    }
-    last_key= first_key+num_keys-1;
-    for (key=first_key;key<=last_key;key++,syms+= map_width) {
-	XkbMapChangesPtr	mc;
-	unsigned		explicit;
-	KeySym			tsyms[XkbMaxSymsPerKey];
-	int	 		types[XkbNumKbdGroups];
-	int			nG;
-
-	explicit= xkb->server->explicit[key]&XkbExplicitKeyTypesMask;
-	types[XkbGroup1Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup1Index);
-	types[XkbGroup2Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup2Index);
-	types[XkbGroup3Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup3Index);
-	types[XkbGroup4Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup4Index);
-	nG= XkbKeyTypesForCoreSymbols(xkb,map_width,syms,explicit,types,tsyms);
-	if (changes)
-	     mc= &changes->map;
-	else mc= NULL;
-	XkbChangeTypesOfKey(xkb,key,nG,XkbAllGroupsMask,types,mc);
-	memcpy((char *)XkbKeySymsPtr(xkb,key),(char *)tsyms,
-					XkbKeyNumSyms(xkb,key)*sizeof(KeySym));
-	XkbApplyCompatMapToKey(xkb,key,changes);
-    }
-
-    if ((xkb->server->vmods!=NULL)&&(xkb->map->modmap!=NULL)&&(changes)&&
-	(changes->map.changed&(XkbVirtualModMapMask|XkbModifierMapMask))) {
-	unsigned char		newVMods[XkbNumVirtualMods];
-	register  unsigned 	bit,i;
-	unsigned		present;
-
-	bzero(newVMods,XkbNumVirtualMods);
-	present= 0;
-	for (key=xkb->min_key_code;key<=xkb->max_key_code;key++) {
-	    if (xkb->server->vmodmap[key]==0)
-		continue;
-	    for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
-		if (bit&xkb->server->vmodmap[key]) {
-		    present|= bit;
-		    newVMods[i]|= xkb->map->modmap[key];
-		}
-	    }
-	}
-	for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
-	    if ((bit&present)&&(newVMods[i]!=xkb->server->vmods[i])) {
-		changes->map.changed|= XkbVirtualModsMask;
-		changes->map.vmods|= bit;
-		xkb->server->vmods[i]= newVMods[i];
-	    }
-	}
-    }
-    if (changes && (changes->map.changed&XkbVirtualModsMask))
-	XkbApplyVirtualModChanges(xkb,changes->map.vmods,changes);
-    return True;
-}
-
 Status
 XkbChangeTypesOfKey(	XkbDescPtr		 xkb,
 			int		 	 key,
@@ -788,7 +611,7 @@ register unsigned mask;
 
 /***====================================================================***/
 
-Bool
+static Bool
 XkbUpdateActionVirtualMods(XkbDescPtr xkb,XkbAction *act,unsigned changed)
 {
 unsigned int	tmp;
@@ -814,7 +637,7 @@ unsigned int	tmp;
     return False;
 }
 
-void
+static void
 XkbUpdateKeyTypeVirtualMods(	XkbDescPtr	xkb,
 				XkbKeyTypePtr	type,
 				unsigned int	changed,
diff --git a/xkb/ddxBeep.c b/xkb/ddxBeep.c
index 53f3a6f..331357d 100644
--- a/xkb/ddxBeep.c
+++ b/xkb/ddxBeep.c
@@ -36,7 +36,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include "windowstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XI.h>
 
 /*#define FALLING_TONE	1*/
diff --git a/xkb/ddxCtrls.c b/xkb/ddxCtrls.c
index 5a9ad40..0f7f918 100644
--- a/xkb/ddxCtrls.c
+++ b/xkb/ddxCtrls.c
@@ -36,7 +36,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include "windowstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XI.h>
 
 void
diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c
index 3de8f87..7e27c51 100644
--- a/xkb/ddxDevBtn.c
+++ b/xkb/ddxDevBtn.c
@@ -36,7 +36,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include "windowstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XI.h>
 #include <X11/extensions/XIproto.h>
 
diff --git a/xkb/ddxFakeBtn.c b/xkb/ddxFakeBtn.c
index f7b746b..7722223 100644
--- a/xkb/ddxFakeBtn.c
+++ b/xkb/ddxFakeBtn.c
@@ -37,7 +37,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include "windowstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XI.h>
 
 void
diff --git a/xkb/ddxFakeMtn.c b/xkb/ddxFakeMtn.c
index a19819f..1060afe 100644
--- a/xkb/ddxFakeMtn.c
+++ b/xkb/ddxFakeMtn.c
@@ -36,7 +36,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include "windowstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XI.h>
 
 #ifdef PANORAMIX
diff --git a/xkb/ddxInit.c b/xkb/ddxInit.c
index 88c488c..3bcf9d6 100644
--- a/xkb/ddxInit.c
+++ b/xkb/ddxInit.c
@@ -37,7 +37,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include "windowstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XI.h>
 
 int
diff --git a/xkb/ddxKeyClick.c b/xkb/ddxKeyClick.c
index 528b202..685ae1b 100644
--- a/xkb/ddxKeyClick.c
+++ b/xkb/ddxKeyClick.c
@@ -37,7 +37,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include "windowstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XI.h>
 
 void
diff --git a/xkb/ddxKillSrv.c b/xkb/ddxKillSrv.c
index 95d7589..a573ecb 100644
--- a/xkb/ddxKillSrv.c
+++ b/xkb/ddxKillSrv.c
@@ -36,7 +36,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include "windowstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 
 int
 XkbDDXTerminateServer(DeviceIntPtr dev,KeyCode key,XkbAction *act)
diff --git a/xkb/ddxLEDs.c b/xkb/ddxLEDs.c
index fd01958..22899d7 100644
--- a/xkb/ddxLEDs.c
+++ b/xkb/ddxLEDs.c
@@ -37,10 +37,10 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include "windowstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XI.h>
 
-void
+static void
 XkbDDXUpdateIndicators(DeviceIntPtr dev,CARD32 new)
 {
     dev->kbdfeed->ctrl.leds= new;
diff --git a/xkb/ddxList.c b/xkb/ddxList.c
index 034f694..a91a9ba 100644
--- a/xkb/ddxList.c
+++ b/xkb/ddxList.c
@@ -40,7 +40,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "scrnintstr.h"
 #include "windowstr.h"
 #define	XKBSRV_NEED_FILE_FUNCS
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XI.h>
 
 #ifndef PATH_MAX
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index 6e8f892..c24c56c 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -44,7 +44,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "scrnintstr.h"
 #include "windowstr.h"
 #define	XKBSRV_NEED_FILE_FUNCS
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XI.h>
 #include "xkb.h"
 
@@ -211,7 +211,7 @@ OutputDirectory(
     }
 }
 
-Bool
+static Bool
 XkbDDXCompileNamedKeymap(	XkbDescPtr		xkb,
 				XkbComponentNamesPtr	names,
 				char *			nameRtrn,
@@ -298,7 +298,7 @@ char 	*cmd = NULL,file[PATH_MAX],xkm_out
     return False;
 }
 
-Bool    	
+static Bool    	
 XkbDDXCompileKeymapByNames(	XkbDescPtr		xkb,
 				XkbComponentNamesPtr	names,
 				unsigned		want,
@@ -432,7 +432,7 @@ char tmpname[PATH_MAX];
     return False;
 }
 
-FILE *
+static FILE *
 XkbDDXOpenConfigFile(char *mapName,char *fileNameRtrn,int fileNameRtrnLen)
 {
 char	buf[PATH_MAX],xkm_output_dir[PATH_MAX];
diff --git a/xkb/ddxPrivate.c b/xkb/ddxPrivate.c
index 7450b47..f67e20c 100644
--- a/xkb/ddxPrivate.c
+++ b/xkb/ddxPrivate.c
@@ -6,7 +6,7 @@
 #define NEED_EVENTS
 #include <X11/X.h>
 #include "windowstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 
 int
 XkbDDXPrivate(DeviceIntPtr dev,KeyCode key,XkbAction *act)
diff --git a/xkb/ddxVT.c b/xkb/ddxVT.c
index f56f079..55c82a8 100644
--- a/xkb/ddxVT.c
+++ b/xkb/ddxVT.c
@@ -36,7 +36,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include "windowstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 
 int
 XkbDDXSwitchScreen(DeviceIntPtr dev,KeyCode key,XkbAction *act)
diff --git a/xkb/maprules.c b/xkb/maprules.c
index b0a2225..0fa356e 100644
--- a/xkb/maprules.c
+++ b/xkb/maprules.c
@@ -48,7 +48,7 @@
 #include "dix.h"
 #include <X11/extensions/XKBstr.h>
 #define XKBSRV_NEED_FILE_FUNCS
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 
 #ifdef DEBUG
 #define PR_DEBUG(s)		fprintf(stderr,s)
diff --git a/xkb/xkb.c b/xkb/xkb.c
index 2c97e05..cf42430 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -36,23 +36,20 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "misc.h"
 #include "inputstr.h"
 #define	XKBSRV_NEED_FILE_FUNCS
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include "extnsionst.h"
 #include "xkb.h"
 
 #include <X11/extensions/XI.h>
 
 	int	XkbEventBase;
-	int	XkbErrorBase;
+static	int	XkbErrorBase;
 	int	XkbReqCode;
-	int	XkbKeyboardErrorCode;
-Atom	xkbONE_LEVEL;
-Atom	xkbTWO_LEVEL;
-Atom	xkbKEYPAD;
+static  int	XkbKeyboardErrorCode;
 CARD32	xkbDebugFlags = 0;
-CARD32	xkbDebugCtrls = 0;
+static CARD32	xkbDebugCtrls = 0;
 
-RESTYPE	RT_XKBCLIENT;
+static RESTYPE	RT_XKBCLIENT;
 
 /***====================================================================***/
 
@@ -895,52 +892,6 @@ ProcXkbSetControls(ClientPtr client)
     return client->noClientException;
 }
 
-/* FIXME: Needs to set rate on all core-sending devices. */
-int
-XkbSetRepeatRate(DeviceIntPtr dev,int timeout,int interval,int major,int minor)
-{
-int	changed= 0;
-XkbControlsRec old,*xkb;
-
-    if ((!dev)||(!dev->key)||(!dev->key->xkbInfo))
-	return 0;
-    xkb= dev->key->xkbInfo->desc->ctrls;
-    old= *xkb;
-    if ((timeout!=0) && (xkb->repeat_delay!=timeout)) {
-	xkb->repeat_delay= timeout;
-	changed++;
-    }
-    if ((interval!=0) && (xkb->repeat_interval!=interval)) {
-	xkb->repeat_interval= interval;
-	changed++;
-    }
-    if (changed) {
-	xkbControlsNotify	cn;
-	XkbDDXChangeControls(dev,&old,xkb);
-	if (XkbComputeControlsNotify(dev,&old,xkb,&cn,False)) {
-	    cn.keycode= 0;
-	    cn.eventType = 0;
-	    cn.requestMajor = major;
-	    cn.requestMinor = minor;
-	    XkbSendControlsNotify(dev,&cn);
-	}
-    }
-    return 1;
-}
-
-int
-XkbGetRepeatRate(DeviceIntPtr dev,int *timeout,int *interval)
-{
-XkbControlsPtr	xkb;
-
-    if ((!dev)||(!dev->key)||(!dev->key->xkbInfo))
-	return 0;
-    xkb= dev->key->xkbInfo->desc->ctrls;
-    if (timeout)	*timeout= xkb->repeat_delay;
-    if (interval)	*interval= xkb->repeat_interval;
-    return 1;
-}
-
 /***====================================================================***/
 
 static int
@@ -2820,7 +2771,7 @@ ProcXkbGetIndicatorState(ClientPtr clien
 
 /***====================================================================***/
 
-Status
+static Status
 XkbComputeGetIndicatorMapReplySize(
     XkbIndicatorPtr		indicators,
     xkbGetIndicatorMapReply	*rep)
@@ -2837,7 +2788,7 @@ int		nIndicators;
     return Success;
 }
 
-int
+static int
 XkbSendIndicatorMap(	ClientPtr			client,
 			XkbIndicatorPtr			indicators,
 			xkbGetIndicatorMapReply *	rep)
diff --git a/xkb/xkb.h b/xkb/xkb.h
index 2be4258..99b60bf 100644
--- a/xkb/xkb.h
+++ b/xkb/xkb.h
@@ -1,5 +1,3 @@
-/* $XFree86$ */
-
 /* #include "XKBfile.h" */
 
 extern int ProcXkbUseExtension(ClientPtr client);
@@ -29,50 +27,10 @@ extern int ProcXkbGetDeviceInfo(ClientPt
 extern int ProcXkbSetDeviceInfo(ClientPtr client);
 extern int ProcXkbSetDebuggingFlags(ClientPtr client);
 
-extern int XkbSetRepeatRate(DeviceIntPtr dev, int timeout, int interval, int major, int minor);
-extern int XkbGetRepeatRate(DeviceIntPtr dev, int *timeout, int *interval);
-
 extern void XkbExtensionInit(void);
 
-extern Status XkbComputeGetIndicatorMapReplySize(
-    XkbIndicatorPtr             indicators,
-    xkbGetIndicatorMapReply     *rep);
-extern int XkbSendIndicatorMap(
-    ClientPtr                   client,
-    XkbIndicatorPtr             indicators,
-    xkbGetIndicatorMapReply     *rep);
-
-extern void XkbComputeCompatState(XkbSrvInfoPtr xkbi);
-extern void XkbSetPhysicalLockingKey(DeviceIntPtr dev, unsigned key);
-
 extern Bool XkbFilterEvents(ClientPtr pClient, int nEvents, xEvent *xE);
 
-extern Bool XkbApplyLEDChangeToKeyboard(
-    XkbSrvInfoPtr           xkbi,
-    XkbIndicatorMapPtr      map,
-    Bool                    on,
-    XkbChangesPtr           change);
-
-extern Bool XkbWriteRulesProp(ClientPtr client, pointer closure);
-
-extern XkbAction XkbGetButtonAction(DeviceIntPtr kbd, DeviceIntPtr dev, int button);
-
-/* extern Status XkbMergeFile(XkbDescPtr xkb, XkbFileInfo finfo); */
-
-extern Bool XkbDDXCompileNamedKeymap(
-    XkbDescPtr              xkb,
-    XkbComponentNamesPtr    names,
-    char *                  nameRtrn,
-    int                     nameRtrnLen);
-
-extern Bool XkbDDXCompileKeymapByNames(
-    XkbDescPtr              xkb,
-    XkbComponentNamesPtr    names,
-    unsigned                want,
-    unsigned                need,
-    char *                  nameRtrn,
-    int                     nameRtrnLen);
-
 extern Bool XkbCopyKeymap(
     XkbDescPtr              src,
     XkbDescPtr              dst,
diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index 0ab3dad..2954a0c 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -38,7 +38,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/Xproto.h>
 #include <X11/keysym.h>
 #include "inputstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #if !defined(WIN32) && !defined(Lynx)
 #include <sys/time.h>
 #endif
@@ -52,9 +52,9 @@ pointer	XkbLastRepeatEvent=	NULL;
 
 unsigned short	XkbDfltAccessXTimeout= 	120;
 unsigned int	XkbDfltAccessXTimeoutMask= DFLT_TIMEOUT_CTRLS;
-unsigned int	XkbDfltAccessXTimeoutValues= 0;
-unsigned int	XkbDfltAccessXTimeoutOptionsMask= DFLT_TIMEOUT_OPTS;
-unsigned int	XkbDfltAccessXTimeoutOptionsValues= 0;
+static unsigned int XkbDfltAccessXTimeoutValues= 0;
+static unsigned int XkbDfltAccessXTimeoutOptionsMask= DFLT_TIMEOUT_OPTS;
+static unsigned int XkbDfltAccessXTimeoutOptionsValues= 0;
 unsigned int	XkbDfltAccessXFeedback= XkbAccessXFeedbackMask;
 unsigned short	XkbDfltAccessXOptions=  XkbAX_AllOptionsMask & ~(XkbAX_IndicatorFBMask|XkbAX_SKReleaseFBMask|XkbAX_SKRejectFBMask);
 
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index e0bf89c..2e0c89f 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -36,14 +36,14 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/keysym.h>
 #include "misc.h"
 #include "inputstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include "xkb.h"
 #include <ctype.h>
 
 static unsigned int _xkbServerGeneration;
-int xkbDevicePrivateIndex = -1;
+static int xkbDevicePrivateIndex = -1;
 
-void
+static void
 xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc,
                    pointer data)
 {
@@ -216,7 +216,7 @@ static XkbAction 	fake;
     return fake;
 }
 
-XkbAction
+static XkbAction
 XkbGetButtonAction(DeviceIntPtr kbd,DeviceIntPtr dev,int button)
 {
 XkbAction fake;
diff --git a/xkb/xkbDflts.h b/xkb/xkbDflts.h
index e31568a..5d86906 100644
--- a/xkb/xkbDflts.h
+++ b/xkb/xkbDflts.h
@@ -456,43 +456,6 @@ static XkbCompatMapRec compatMap= {
     num_dfltSI, num_dfltSI
 };
 
-static XkbIndicatorRec indicators= {
-    0x0,
-    {
-        { 0x80, 0, 0x00, XkbIM_UseEffective, { LockMask,  LockMask, 0 }, 0 },
-        { 0x80, 0, 0x00, XkbIM_UseEffective, { 0,  0, vmod_NumLockMask }, 0 },
-        { 0x80, 0, 0x00, XkbIM_UseLocked, { ShiftMask,  ShiftMask, 0 }, 0 },
-        { 0x80, 0, 0x00, 0, { 0,  0, 0 }, XkbMouseKeysMask },
-        { 0x80, 0, 0x00, XkbIM_UseLocked, { 0,  0, vmod_ScrollLockMask }, 0 },
-        { 0x80, XkbIM_UseEffective, 0xfe, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 },
-        { 0x00, 0, 0x00, 0, { 0,  0, 0 }, 0 }
-    }
-};
 static void
 initIndicatorNames(DPYTYPE dpy,XkbDescPtr xkb)
 {
diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index 139221f..11dc17a 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -36,7 +36,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/extensions/XI.h>
 #include "inputstr.h"
 #include "windowstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include "xkb.h"
 
 /***====================================================================***/
@@ -331,7 +331,7 @@ Time 		 	time = 0;
     return;
 }
 
-void
+static void
 XkbSendIndicatorNotify(DeviceIntPtr kbd,int xkbType,xkbIndicatorNotify *pEv)
 {
 int		initialized;
@@ -972,48 +972,6 @@ XkbInterestPtr	interest;
 }
 
 int
-XkbRemoveClient(DevicePtr inDev,ClientPtr client)
-{
-XkbSrvInfoPtr	xkbi;
-DeviceIntPtr	dev = (DeviceIntPtr)inDev;
-XkbInterestPtr	interest;
-unsigned long	autoCtrls,autoValues;
-Bool		found;
-
-    found= False;
-    autoCtrls= autoValues= 0;
-    if ( dev->xkb_interest ) {
-	interest = dev->xkb_interest;
-	if (interest && (interest->client==client)){
-	    dev->xkb_interest = interest->next;
-	    autoCtrls= interest->autoCtrls;
-	    autoValues= interest->autoCtrlValues;
-	    _XkbFree(interest);
-	    found= True;
-	}
-	while ((!found)&&(interest->next)) {
-	    if (interest->next->client==client) {
-		XkbInterestPtr	victim = interest->next;
-		interest->next = victim->next;
-		autoCtrls= victim->autoCtrls;
-		autoValues= victim->autoCtrlValues;
-		_XkbFree(victim);
-		found= True;
-	    }
-	    interest = interest->next;
-	}
-    }
-    if (found && autoCtrls && dev->key && dev->key->xkbInfo ) {
-	XkbEventCauseRec cause;
-
-	xkbi= dev->key->xkbInfo;
-	XkbSetCauseXkbReq(&cause,X_kbPerClientFlags,client);
-	XkbEnableDisableControls(xkbi,autoCtrls,autoValues,NULL,&cause);
-    }
-    return found;
-}
-
-int
 XkbRemoveResourceClient(DevicePtr inDev,XID id) 
 {
 XkbSrvInfoPtr	xkbi;
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index 5aa121d..716bc26 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -47,7 +47,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "opaque.h"
 #include "property.h"
 #define	XKBSRV_NEED_FILE_FUNCS
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XKBgeom.h>
 #include <X11/extensions/XKMformat.h>
 #include <X11/extensions/XKBfile.h>
@@ -124,7 +124,7 @@ typedef struct	_SrvXkmInfo {
 
 char	*		XkbBaseDirectory=	XKB_BASE_DIRECTORY;
 char	*		XkbBinDirectory=	XKB_BIN_DIRECTORY;
-int	 		XkbWantAccessX=		0;	
+static int	 	XkbWantAccessX=		0;	
 static XkbFileInfo *	_XkbInitFileInfo=	NULL;
 
 static Bool		rulesDefined=		False;
@@ -134,20 +134,17 @@ static char *		XkbLayoutDflt=		NULL;
 static char *		XkbVariantDflt=		NULL;
 static char *		XkbOptionsDflt=		NULL;
 
-char *			XkbModelUsed=	NULL;
-char *			XkbLayoutUsed=	NULL;
-char *			XkbVariantUsed=	NULL;
-char *			XkbOptionsUsed=	NULL;
-
-int			_XkbClientMajor=	XkbMajorVersion;
-int			_XkbClientMinor=	XkbMinorVersion;
+static char *		XkbModelUsed=	NULL;
+static char *		XkbLayoutUsed=	NULL;
+static char *		XkbVariantUsed=	NULL;
+static char *		XkbOptionsUsed=	NULL;
 
 _X_EXPORT Bool		noXkbExtension=		XKB_DFLT_DISABLED;
-Bool			XkbWantRulesProp=	XKB_DFLT_RULES_PROP;
+static Bool		XkbWantRulesProp=	XKB_DFLT_RULES_PROP;
 
 /***====================================================================***/
 
-char *
+static char *
 XkbGetRulesDflts(XkbRF_VarDefsPtr defs)
 {
     if (XkbModelDflt)	defs->model= XkbModelDflt;
@@ -161,7 +158,7 @@ XkbGetRulesDflts(XkbRF_VarDefsPtr defs)
     return (rulesDefined?XkbRulesFile:XKB_DFLT_RULES_FILE);
 }
 
-Bool
+static Bool
 XkbWriteRulesProp(ClientPtr client, pointer closure)
 {
 int 			len,out;
@@ -230,7 +227,7 @@ char *			pval;
     return True;
 }
 
-void
+static void
 XkbSetRulesUsed(XkbRF_VarDefsPtr defs)
 {
     if (XkbModelUsed)
@@ -289,9 +286,6 @@ XkbSetRulesDflts(char *rulesFile,char *m
 
 #include "xkbDflts.h"
 
-/* A dummy to keep the compiler quiet */
-pointer xkbBogus = &indicators;
-
 static Bool
 XkbInitKeyTypes(XkbDescPtr xkb,SrvXkmInfo *file)
 {
diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c
index e94e0bf..d607d90 100644
--- a/xkb/xkbLEDs.c
+++ b/xkb/xkbLEDs.c
@@ -38,7 +38,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 
 #include <X11/extensions/XI.h>
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include "xkb.h"
 
 /***====================================================================***/
@@ -82,7 +82,7 @@ XkbSrvLedInfoPtr	sli;
 
 	/*
 	 * Bool
-	 * XkbApplyLEDChangeToKeyboard(xkbi,map,on,change)
+	 *XkbApplyLEDChangeToKeyboard(xkbi,map,on,change)
 	 *
 	 * Some indicators "drive" the keyboard when their state is explicitly 
 	 * changed, as described in section 9.2.1 of the XKB protocol spec.
@@ -91,7 +91,7 @@ XkbSrvLedInfoPtr	sli;
 	 * when the indicator described by 'map' is turned on or off.  The
 	 * extent of the changes is reported in change, which must be defined.
 	 */
-Bool
+static Bool
 XkbApplyLEDChangeToKeyboard(	XkbSrvInfoPtr		xkbi,
 				XkbIndicatorMapPtr	map,
 				Bool			on,
@@ -166,6 +166,164 @@ XkbStatePtr	state;
     }
     return (stateChange || ctrlChange);
 }
+	
+	/*
+	 * Bool
+	 * ComputeAutoState(map,state,ctrls)
+	 *
+	 * This function reports the effect of applying the specified
+	 * indicator map given the specified state and controls, as
+	 * described in section 9.2 of the XKB protocol specification.
+	 */
+
+static Bool
+ComputeAutoState(	XkbIndicatorMapPtr	map,
+			XkbStatePtr 		state,
+			XkbControlsPtr 		ctrls)
+{
+Bool 			on;
+CARD8 			mods,group;
+
+    on= False;
+    mods= group= 0;
+    if (map->which_mods&XkbIM_UseAnyMods) {
+	if (map->which_mods&XkbIM_UseBase)
+	    mods|= state->base_mods;
+	if (map->which_mods&XkbIM_UseLatched)
+	    mods|= state->latched_mods;
+	if (map->which_mods&XkbIM_UseLocked)
+	    mods|= state->locked_mods;
+	if (map->which_mods&XkbIM_UseEffective)
+	    mods|= state->mods;
+	if (map->which_mods&XkbIM_UseCompat)
+	    mods|= state->compat_state;
+	on = ((map->mods.mask&mods)!=0);
+	on = on||((mods==0)&&(map->mods.mask==0)&&(map->mods.vmods==0));
+    }
+    if (map->which_groups&XkbIM_UseAnyGroup) {
+	if (map->which_groups&XkbIM_UseBase)
+	    group|= (1L << state->base_group);
+	if (map->which_groups&XkbIM_UseLatched)
+	    group|= (1L << state->latched_group);
+	if (map->which_groups&XkbIM_UseLocked)
+	    group|= (1L << state->locked_group);
+	if (map->which_groups&XkbIM_UseEffective)
+	    group|= (1L << state->group);
+	on = on||(((map->groups&group)!=0)||(map->groups==0));
+    }
+    if (map->ctrls)
+	on = on||(ctrls->enabled_ctrls&map->ctrls);
+    return on;
+}
+
+
+static void
+XkbUpdateLedAutoState(	DeviceIntPtr			dev,
+			XkbSrvLedInfoPtr		sli,
+			unsigned			maps_to_check,
+			xkbExtensionDeviceNotify *	ed,
+			XkbChangesPtr			changes,
+			XkbEventCausePtr		cause)
+{
+DeviceIntPtr			kbd;
+XkbStatePtr			state;
+XkbControlsPtr			ctrls;
+XkbChangesRec			my_changes;
+xkbExtensionDeviceNotify	my_ed;
+register unsigned		i,bit,affected;
+register XkbIndicatorMapPtr	map;
+unsigned			oldState;
+
+    if ((maps_to_check==0)||(sli->maps==NULL)||(sli->mapsPresent==0))
+	return;
+
+    if (dev->key && dev->key->xkbInfo)
+	 kbd= dev;
+    else kbd= (DeviceIntPtr)LookupKeyboardDevice();
+
+    state= &kbd->key->xkbInfo->state;
+    ctrls= kbd->key->xkbInfo->desc->ctrls;
+    affected= maps_to_check;
+    oldState= sli->effectiveState;
+    sli->autoState&= ~affected;
+    for (i=0,bit=1;(i<XkbNumIndicators)&&(affected);i++,bit<<=1) {
+	if ((affected&bit)==0)
+	    continue;
+	affected&= ~bit;
+	map= &sli->maps[i];
+	if((!(map->flags&XkbIM_NoAutomatic))&&ComputeAutoState(map,state,ctrls))
+	    sli->autoState|= bit;
+    }
+    sli->effectiveState= (sli->autoState|sli->explicitState);
+    affected= sli->effectiveState^oldState;
+    if (affected==0)
+	return;
+
+    if (ed==NULL) {
+	ed= &my_ed;
+	bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
+    }
+    else if ((ed->reason&XkbXI_IndicatorsMask)&&
+	     ((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
+	XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
+    }
+
+    if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
+	if (changes==NULL) {
+	    changes= &my_changes;
+	    bzero((char *)changes,sizeof(XkbChangesRec));
+	}
+	changes->indicators.state_changes|= affected;
+    }
+
+    ed->reason|=	XkbXI_IndicatorStateMask;
+    ed->ledClass= 	sli->class;
+    ed->ledID=		sli->id;
+    ed->ledsDefined=	sli->namesPresent|sli->mapsPresent;
+    ed->ledState=	sli->effectiveState;
+    ed->unsupported|=	XkbXI_IndicatorStateMask;
+    ed->supported=	XkbXI_AllFeaturesMask;
+
+    if (changes!=&my_changes)	changes= NULL;
+    if (ed!=&my_ed)		ed= NULL;
+    if (changes || ed)
+	XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
+    return;
+}
+
+static void
+XkbUpdateAllDeviceIndicators(XkbChangesPtr changes,XkbEventCausePtr cause)
+{
+DeviceIntPtr		edev;
+XkbSrvLedInfoPtr	sli;
+
+    for (edev=inputInfo.devices;edev!=NULL;edev=edev->next) {
+	if (edev->kbdfeed) {
+	    KbdFeedbackPtr	kf;
+	    for (kf=edev->kbdfeed;kf!=NULL;kf=kf->next) {
+		if ((kf->xkb_sli==NULL)||(kf->xkb_sli->maps==NULL))
+		    continue;
+		sli= kf->xkb_sli;
+		XkbUpdateLedAutoState(edev,sli,sli->mapsPresent,NULL,
+								changes,cause);
+			
+	    }
+	}
+	if (edev->leds) {
+	    LedFeedbackPtr	lf;
+	    for (lf=edev->leds;lf!=NULL;lf=lf->next) {
+		if ((lf->xkb_sli==NULL)||(lf->xkb_sli->maps==NULL))
+		    continue;
+		sli= lf->xkb_sli;
+		XkbUpdateLedAutoState(edev,sli,sli->mapsPresent,NULL,
+								changes,cause);
+			
+	    }
+	}
+    }
+    return;
+}
+
 
 /***====================================================================***/
 
@@ -228,55 +386,6 @@ unsigned 			side_affected;
 
 /***====================================================================***/
 
-	/*
-	 * Bool
-	 * ComputeAutoState(map,state,ctrls)
-	 *
-	 * This function reports the effect of applying the specified
-	 * indicator map given the specified state and controls, as
-	 * described in section 9.2 of the XKB protocol specification.
-	 */
-
-static Bool
-ComputeAutoState(	XkbIndicatorMapPtr	map,
-			XkbStatePtr 		state,
-			XkbControlsPtr 		ctrls)
-{
-Bool 			on;
-CARD8 			mods,group;
-
-    on= False;
-    mods= group= 0;
-    if (map->which_mods&XkbIM_UseAnyMods) {
-	if (map->which_mods&XkbIM_UseBase)
-	    mods|= state->base_mods;
-	if (map->which_mods&XkbIM_UseLatched)
-	    mods|= state->latched_mods;
-	if (map->which_mods&XkbIM_UseLocked)
-	    mods|= state->locked_mods;
-	if (map->which_mods&XkbIM_UseEffective)
-	    mods|= state->mods;
-	if (map->which_mods&XkbIM_UseCompat)
-	    mods|= state->compat_state;
-	on = ((map->mods.mask&mods)!=0);
-	on = on||((mods==0)&&(map->mods.mask==0)&&(map->mods.vmods==0));
-    }
-    if (map->which_groups&XkbIM_UseAnyGroup) {
-	if (map->which_groups&XkbIM_UseBase)
-	    group|= (1L << state->base_group);
-	if (map->which_groups&XkbIM_UseLatched)
-	    group|= (1L << state->latched_group);
-	if (map->which_groups&XkbIM_UseLocked)
-	    group|= (1L << state->locked_group);
-	if (map->which_groups&XkbIM_UseEffective)
-	    group|= (1L << state->group);
-	on = on||(((map->groups&group)!=0)||(map->groups==0));
-    }
-    if (map->ctrls)
-	on = on||(ctrls->enabled_ctrls&map->ctrls);
-    return on;
-}
-
 /***====================================================================***/
 
 	/*
@@ -314,39 +423,6 @@ XkbSrvLedInfoPtr	sli;
 
 /***====================================================================***/
 
-void
-XkbUpdateAllDeviceIndicators(XkbChangesPtr changes,XkbEventCausePtr cause)
-{
-DeviceIntPtr		edev;
-XkbSrvLedInfoPtr	sli;
-
-    for (edev=inputInfo.devices;edev!=NULL;edev=edev->next) {
-	if (edev->kbdfeed) {
-	    KbdFeedbackPtr	kf;
-	    for (kf=edev->kbdfeed;kf!=NULL;kf=kf->next) {
-		if ((kf->xkb_sli==NULL)||(kf->xkb_sli->maps==NULL))
-		    continue;
-		sli= kf->xkb_sli;
-		XkbUpdateLedAutoState(edev,sli,sli->mapsPresent,NULL,
-								changes,cause);
-			
-	    }
-	}
-	if (edev->leds) {
-	    LedFeedbackPtr	lf;
-	    for (lf=edev->leds;lf!=NULL;lf=lf->next) {
-		if ((lf->xkb_sli==NULL)||(lf->xkb_sli->maps==NULL))
-		    continue;
-		sli= lf->xkb_sli;
-		XkbUpdateLedAutoState(edev,sli,sli->mapsPresent,NULL,
-								changes,cause);
-			
-	    }
-	}
-    }
-    return;
-}
-
 /***====================================================================***/
 
 	/*
@@ -856,210 +932,3 @@ Bool				kb_changed;
 	XkbUpdateAllDeviceIndicators(NULL,cause);
     return;
 }
-
-/***====================================================================***/
-
-void
-XkbUpdateLedAutoState(	DeviceIntPtr			dev,
-			XkbSrvLedInfoPtr		sli,
-			unsigned			maps_to_check,
-			xkbExtensionDeviceNotify *	ed,
-			XkbChangesPtr			changes,
-			XkbEventCausePtr		cause)
-{
-DeviceIntPtr			kbd;
-XkbStatePtr			state;
-XkbControlsPtr			ctrls;
-XkbChangesRec			my_changes;
-xkbExtensionDeviceNotify	my_ed;
-register unsigned		i,bit,affected;
-register XkbIndicatorMapPtr	map;
-unsigned			oldState;
-
-    if ((maps_to_check==0)||(sli->maps==NULL)||(sli->mapsPresent==0))
-	return;
-
-    if (dev->key && dev->key->xkbInfo)
-	 kbd= dev;
-    else kbd= (DeviceIntPtr)LookupKeyboardDevice();
-
-    state= &kbd->key->xkbInfo->state;
-    ctrls= kbd->key->xkbInfo->desc->ctrls;
-    affected= maps_to_check;
-    oldState= sli->effectiveState;
-    sli->autoState&= ~affected;
-    for (i=0,bit=1;(i<XkbNumIndicators)&&(affected);i++,bit<<=1) {
-	if ((affected&bit)==0)
-	    continue;
-	affected&= ~bit;
-	map= &sli->maps[i];
-	if((!(map->flags&XkbIM_NoAutomatic))&&ComputeAutoState(map,state,ctrls))
-	    sli->autoState|= bit;
-    }
-    sli->effectiveState= (sli->autoState|sli->explicitState);
-    affected= sli->effectiveState^oldState;
-    if (affected==0)
-	return;
-
-    if (ed==NULL) {
-	ed= &my_ed;
-	bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
-    }
-    else if ((ed->reason&XkbXI_IndicatorsMask)&&
-	     ((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
-	XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
-    }
-
-    if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
-	if (changes==NULL) {
-	    changes= &my_changes;
-	    bzero((char *)changes,sizeof(XkbChangesRec));
-	}
-	changes->indicators.state_changes|= affected;
-    }
-
-    ed->reason|=	XkbXI_IndicatorStateMask;
-    ed->ledClass= 	sli->class;
-    ed->ledID=		sli->id;
-    ed->ledsDefined=	sli->namesPresent|sli->mapsPresent;
-    ed->ledState=	sli->effectiveState;
-    ed->unsupported|=	XkbXI_IndicatorStateMask;
-    ed->supported=	XkbXI_AllFeaturesMask;
-
-    if (changes!=&my_changes)	changes= NULL;
-    if (ed!=&my_ed)		ed= NULL;
-    if (changes || ed)
-	XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
-    return;
-}
-
-/***====================================================================***/
-
-static void
-_UpdateButtonVMods(	XkbDescPtr			xkb,
-			unsigned			num_btns,
-			XkbAction *			acts,
-			unsigned			changed,
-			xkbExtensionDeviceNotify *	ed_inout)
-{
-register int i;
-
-    for (i=0;i<num_btns;i++,acts++) {
-	if ((acts->any.type!=XkbSA_NoAction)&&
-				XkbUpdateActionVirtualMods(xkb,acts,changed)) {
-	    if ((ed_inout->reason&XkbXI_ButtonActionsMask)==0) {
-		ed_inout->reason|= XkbXI_ButtonActionsMask;
-		ed_inout->firstBtn= i;
-		ed_inout->nBtns= 1;
-	    }
-	    else {
-		ed_inout->nBtns= (i-ed_inout->firstBtn)+1;
-	    }
-	}
-    }
-    return;
-}
-
-static void
-_UpdateMapVMods(	XkbDescPtr	xkb,
-			register	XkbIndicatorMapPtr map,
-			unsigned	changed_vmods,
-			unsigned *	changed_maps_rtrn)
-{
-register int i;
-
-    *changed_maps_rtrn= 0;
-    for (i=0;i<XkbNumIndicators;i++,map++) {
-	if (map->mods.vmods&changed_vmods) {
-	    map->mods.mask= map->mods.real_mods;
-	    map->mods.mask|= XkbMaskForVMask(xkb,map->mods.vmods);
-	    *changed_maps_rtrn|= (1L<<i);
-	}	
-    }
-    return;
-}
-
-static void
-_UpdateDeviceVMods(	DeviceIntPtr		dev,
-			XkbDescPtr		xkb,
-			unsigned		changed,
-			XkbEventCausePtr	cause)
-{
-xkbExtensionDeviceNotify	ed;
-XkbSrvLedInfoPtr		sli;
-unsigned			changed_maps;
-
-    bzero((char *)&ed,sizeof(xkbExtensionDeviceNotify));
-    ed.deviceID= dev->id;
-    if ((dev->button)&&(dev->button->xkb_acts)) {
-	_UpdateButtonVMods(xkb,dev->button->numButtons,
-					dev->button->xkb_acts,changed,&ed);
-    }
-    if (dev->kbdfeed) {
-	KbdFeedbackPtr	kf;
-	for (kf=dev->kbdfeed;kf!=NULL;kf=kf->next) {
-	    if ((kf->xkb_sli==NULL)||(kf->xkb_sli->maps==NULL))
-		continue;
-	    sli= kf->xkb_sli;
-	    _UpdateMapVMods(xkb,sli->maps,changed,&changed_maps);
-	    if (changed_maps) {
-		if (ed.reason&XkbXI_IndicatorsMask) {
-		    XkbSendExtensionDeviceNotify(dev,NULL,&ed);
-		    ed.reason= 0;
-		    ed.firstBtn= ed.nBtns;
-		}
-		ed.ledClass= 	sli->class;
-		ed.ledID=	sli->id;
-		ed.ledsDefined= sli->namesPresent|sli->mapsPresent;
-		ed.reason|= 	XkbXI_IndicatorMapsMask;
-		XkbUpdateLedAutoState(dev,sli,changed_maps,&ed,NULL,cause);
-	    }
-	}
-    }
-    if (dev->leds) {
-	LedFeedbackPtr	lf;
-	for (lf=dev->leds;lf!=NULL;lf=lf->next) {
-	    if ((lf->xkb_sli==NULL)||(lf->xkb_sli->maps==NULL))
-		continue;
-	    sli= lf->xkb_sli;
-	    _UpdateMapVMods(xkb,sli->maps,changed,&changed_maps);
-	    if (changed_maps) {
-		if (ed.reason&XkbXI_IndicatorsMask) {
-		    XkbSendExtensionDeviceNotify(dev,NULL,&ed);
-		    ed.reason= 0;
-		    ed.firstBtn= ed.nBtns;
-		}
-		ed.ledClass= 	sli->class;
-		ed.ledID=	sli->id;
-		ed.ledsDefined= sli->namesPresent|sli->mapsPresent;
-		ed.reason|= 	XkbXI_IndicatorMapsMask;
-		XkbUpdateLedAutoState(dev,sli,changed_maps,&ed,NULL,cause);
-	    }
-	}
-    }
-    if (ed.reason!=0)
-	XkbSendExtensionDeviceNotify(dev,NULL,&ed);
-    return;
-}
-
-void
-XkbApplyVModChangesToAllDevices(	DeviceIntPtr		dev,
-					XkbDescPtr 		xkb,
-					unsigned 		changed,
-					XkbEventCausePtr	cause)
-{
-DeviceIntPtr			edev;
-    if (dev!=(DeviceIntPtr)LookupKeyboardDevice())
-	return;
-    for (edev=inputInfo.devices;edev!=NULL;edev=edev->next) {
-	if (edev->key)
-	    continue;
-	_UpdateDeviceVMods(edev,xkb,changed,cause);
-    }
-    for (edev=inputInfo.off_devices;edev!=NULL;edev=edev->next) {
-	if (edev->key)
-	    continue;
-	_UpdateDeviceVMods(edev,xkb,changed,cause);
-    }
-    return;
-}
diff --git a/xkb/xkbPrKeyEv.c b/xkb/xkbPrKeyEv.c
index 9944c88..81124bc 100644
--- a/xkb/xkbPrKeyEv.c
+++ b/xkb/xkbPrKeyEv.c
@@ -36,7 +36,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/keysym.h>
 #include "misc.h"
 #include "inputstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <ctype.h>
 
 
diff --git a/xkb/xkbSwap.c b/xkb/xkbSwap.c
index 9a04b77..da4c905 100644
--- a/xkb/xkbSwap.c
+++ b/xkb/xkbSwap.c
@@ -35,7 +35,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/Xproto.h>
 #include "misc.h"
 #include "inputstr.h"
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XKBstr.h>
 #include "extnsionst.h"
 #include "xkb.h"
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 062159e..1d23667 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -41,7 +41,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 
 #define	XKBSRV_NEED_FILE_FUNCS
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XKBgeom.h>
 #include "xkb.h"
 
@@ -172,44 +172,6 @@ register unsigned mask;
     return mask;
 }
 
-
-Bool
-XkbApplyVModChanges(	XkbSrvInfoPtr		xkbi,
-			unsigned		changed,
-			XkbChangesPtr		changes,
-			unsigned *		needChecksRtrn,
-			XkbEventCausePtr	cause)
-{
-XkbDescPtr		xkb;
-Bool			check;
-
-    xkb= xkbi->desc;
-#ifdef DEBUG
-{
-register unsigned i,bit;
-    for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
-	if ((changed&bit)==0)
-	    continue;
-	if (xkbDebugFlags)
-	    ErrorF("Should be applying: change vmod %d to 0x%x\n",i,
-					xkb->server->vmods[i]);
-    }
-}
-#endif
-    check= XkbApplyVirtualModChanges(xkb,changed,changes);
-    XkbApplyVModChangesToAllDevices(xkbi->device,xkb,changed,cause);
-
-    if (needChecksRtrn!=NULL)  {
-	if (check)
-	     *needChecksRtrn= XkbStateNotifyMask|XkbIndicatorStateNotifyMask;
-	else *needChecksRtrn= 0;
-    }
-    else if (check) {
-	/* 7/12/95 (ef) -- XXX check compatibility and/or indicator state */
-    }
-    return 1;
-}
-
 /***====================================================================***/
 
 void
@@ -658,7 +620,7 @@ int		changed;
     return changed;
 }
 
-void
+static void
 XkbComputeCompatState(XkbSrvInfoPtr xkbi)
 {
 CARD16 		grp_mask;
@@ -772,21 +734,6 @@ XkbCheckSecondaryEffects(	XkbSrvInfoPtr	
 
 /***====================================================================***/
 
-void
-XkbSetPhysicalLockingKey(DeviceIntPtr dev,unsigned key)
-{
-XkbDescPtr	xkb;
-
-    xkb= dev->key->xkbInfo->desc;
-    if ((key>=xkb->min_key_code) && (key<=xkb->max_key_code)) {
-	xkb->server->behaviors[key].type= XkbKB_Lock|XkbKB_Permanent;
-    }
-    else ErrorF("Internal Error!  Bad XKB info in SetPhysicalLockingKey\n");
-    return;
-}
-
-/***====================================================================***/
-
 Bool
 XkbEnableDisableControls(	XkbSrvInfoPtr		xkbi,
 				unsigned long		change,
diff --git a/xkb/xkberrs.c b/xkb/xkberrs.c
index 095d573..3534356 100644
--- a/xkb/xkberrs.c
+++ b/xkb/xkberrs.c
@@ -32,37 +32,6 @@
 #include <ctype.h>
 #include <stdlib.h>
 
-char *		_XkbErrMessages[] = {
-	"success",				/* _XkbSuccess		     */
-	"key names not defined",		/* _XkbErrMissingNames	     */
-	"key types not defined",		/* _XkbErrMissingTypes	     */
-	"required key types not present",	/* _XkbErrMissingReqTypes    */
-	"symbols not defined",			/* _XkbErrMissingSymbols     */
-	"virtual modifier bindings not defined",/* _XkbErrMissingVMods	     */
-	"indicators not defined",		/* _XkbErrMissingIndicators  */
-	"compatibility map not defined",	/* _XkbErrMissingCompatMap   */
-	"symbol interpretations not defined",	/* _XkbErrMissingSymInterps  */
-	"geometry not defined",			/* _XkbErrMissingGeometry    */
-	"illegal doodad type",			/* _XkbErrIllegalDoodad	     */
-	"illegal TOC type",			/* _XkbErrIllegalTOCType     */
-	"illegal contents",			/* _XkbErrIllegalContents    */
-	"empty file",				/* _XkbErrEmptyFile	     */
-	"file not found",			/* _XkbErrFileNotFound       */
-	"cannot open",				/* _XkbErrFileCannotOpen     */
-	"bad value",				/* _XkbErrBadValue           */
-	"bad match",				/* _XkbErrBadMatch           */
-	"illegal name for type",		/* _XkbErrBadTypeName        */
-	"illegal width for type",		/* _XkbErrBadTypeWidth       */
-	"bad file type",			/* _XkbErrBadFileType        */
-	"bad file version",			/* _XkbErrBadFileVersion     */
-	"error in Xkm file",			/* _XkbErrBadFileFormat      */
-	"allocation failed",			/* _XkbErrBadAlloc           */
-	"bad length",                           /* _XkbErrBadLength          */
-	"X request failed",			/* _XkbErrXReqFailure        */
-	"not implemented"                       /* _XkbErrBadImplementation  */
-};
-
 unsigned	_XkbErrCode;
 char *		_XkbErrLocation= NULL;
 unsigned	_XkbErrData;
-
diff --git a/xkb/xkbfmisc.c b/xkb/xkbfmisc.c
index 4130bd9..05344b4 100644
--- a/xkb/xkbfmisc.c
+++ b/xkb/xkbfmisc.c
@@ -44,7 +44,7 @@
 #include "dix.h"
 #include <X11/extensions/XKBstr.h>
 #define XKBSRV_NEED_FILE_FUNCS	1
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XKBgeom.h>
 #include "xkb.h"
 
@@ -133,76 +133,6 @@ unsigned	set,rtrn;
 
 /***===================================================================***/
 
-Bool
-XkbLookupGroupAndLevel(	XkbDescPtr 	xkb,
-			int 		key,
-			int *		mods_inout,
-			int *		grp_inout,
-			int *		lvl_rtrn)
-{
-int		nG,eG;
-
-    if ((!xkb)||(!XkbKeycodeInRange(xkb,key))||(!grp_inout))
-	return False;
-
-    nG= XkbKeyNumGroups(xkb,key);
-    eG= *grp_inout;
-
-    if ( nG==0 ) {
-	*grp_inout= 0;
-	if (lvl_rtrn!=NULL)
-	    *lvl_rtrn= 0;
-	return False;
-    }
-    else if ( nG==1 ) {
-	eG= 0;
-    }
-    else if ( eG>=nG ) {
-	unsigned gI= XkbKeyGroupInfo(xkb,key);
-	switch (XkbOutOfRangeGroupAction(gI)) {
-	    default:
-		eG %= nG;
-		break;
-	    case XkbClampIntoRange:
-		eG = nG-1;
-		break;
-	    case XkbRedirectIntoRange:
-		eG = XkbOutOfRangeGroupNumber(gI);
-		if (eG>=nG)
-		    eG= 0;
-		break;
-	}
-    }
-    *grp_inout= eG;
-    if (mods_inout!=NULL) {
-	XkbKeyTypePtr	type;
-	int		preserve;
-
-	type = XkbKeyKeyType(xkb,key,eG);
-	if (lvl_rtrn!=NULL)
-	    *lvl_rtrn= 0;
-	preserve= 0;
-	if (type->map) { /* find the shift level */
-	    register int i;
-	    register XkbKTMapEntryPtr entry;
-	    for (i=0,entry=type->map;i<type->map_count;i++,entry++) {
-		if ((entry->active)&&
-			(((*mods_inout)&type->mods.mask)==entry->mods.mask)){
-		    if (lvl_rtrn!=NULL)
-			*lvl_rtrn= entry->level;
-		    if (type->preserve)
-			preserve= type->preserve[i].mask;
-		    break;
-		}
-	    }
-	}
-	(*mods_inout)&= ~(type->mods.mask&(~preserve));
-    }
-    return True;
-}
-
-/***===================================================================***/
-
 static Bool
 XkbWriteSectionFromName(FILE *file,char *sectionName,char *name)
 {
@@ -416,15 +346,6 @@ XkbFileInfo	finfo;
 
 /***====================================================================***/
 
-/*ARGSUSED*/
-Status
-XkbMergeFile(XkbDescPtr xkb,XkbFileInfo finfo)
-{
-    return BadImplementation;
-}
-
-/***====================================================================***/
-
 int
 XkbFindKeycodeByName(XkbDescPtr xkb,char *name,Bool use_aliases)
 {
@@ -484,34 +405,6 @@ unsigned	rtrn;
     return rtrn;
 }
 
-unsigned
-XkbConvertXkbComponents(Bool toXkm,unsigned orig)
-{
-unsigned	rtrn;
-
-    rtrn= 0;
-    if (toXkm) {
-	if (orig&XkbClientMapMask)	rtrn|= XkmTypesMask|XkmSymbolsMask;
-	if (orig&XkbServerMapMask)	rtrn|= XkmTypesMask|XkmSymbolsMask;
-	if (orig&XkbCompatMapMask)	rtrn|= XkmCompatMapMask;
-	if (orig&XkbIndicatorMapMask)	rtrn|= XkmIndicatorsMask;
-	if (orig&XkbNamesMask)		rtrn|= XkmKeyNamesMask;
-	if (orig&XkbGeometryMask)	rtrn|= XkmGeometryMask;
-    }
-    else {
-	if (orig!=0)			rtrn|= XkbNamesMask;
-	if (orig&XkmTypesMask)		rtrn|= XkbClientMapMask;
-	if (orig&XkmCompatMapMask)
-		rtrn|= XkbCompatMapMask|XkbIndicatorMapMask;
-	if (orig&XkmSymbolsMask)	rtrn|=XkbClientMapMask|XkbServerMapMask;
-	if (orig&XkmIndicatorsMask)	rtrn|= XkbIndicatorMapMask;
-	if (orig&XkmKeyNamesMask)	
-		rtrn|= XkbNamesMask|XkbIndicatorMapMask;
-	if (orig&XkmGeometryMask)	rtrn|= XkbGeometryMask;
-    }
-    return rtrn;
-}
-
 Bool
 XkbDetermineFileType(XkbFileInfoPtr finfo,int format,int *opts_missing)
 {
diff --git a/xkb/xkbout.c b/xkb/xkbout.c
index 31cd4fa..bdec8e7 100644
--- a/xkb/xkbout.c
+++ b/xkb/xkbout.c
@@ -44,7 +44,7 @@
 #include "dix.h"
 #include <X11/extensions/XKBstr.h>
 #define XKBSRV_NEED_FILE_FUNCS	1
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 
 #include <X11/extensions/XKBgeom.h>
 #include <X11/extensions/XKBfile.h>
@@ -925,127 +925,3 @@ XkbGeometryPtr		geom;
     fprintf(file,"};\n\n");
     return True;
 }
-
-/*ARGSUSED*/
-Bool
-XkbWriteXKBSemantics(	FILE *			file,
-			XkbFileInfo *		result,
-			Bool			topLevel,
-			Bool			showImplicit,
-			XkbFileAddOnFunc	addOn,
-			void *			priv)
-{
-Bool		ok;
-
-    fprintf(file,"xkb_semantics {\n");
-    ok= XkbWriteXKBKeyTypes(file,result,False,False,addOn,priv);
-    ok= ok&&XkbWriteXKBCompatMap(file,result,False,False,addOn,priv);
-    fprintf(file,"};\n");
-    return ok;
-}
-
-/*ARGSUSED*/
-Bool
-XkbWriteXKBLayout(	FILE *			file,
-			XkbFileInfo *		result,
-			Bool			topLevel,
-			Bool			showImplicit,
-			XkbFileAddOnFunc	addOn,
-			void *			priv)
-{
-Bool		ok;
-XkbDescPtr	xkb;
-
-    xkb= result->xkb;
-    fprintf(file,"xkb_layout {\n");
-    ok= XkbWriteXKBKeycodes(file,result,False,showImplicit,addOn,priv);
-    ok= ok&&XkbWriteXKBKeyTypes(file,result,False,showImplicit,addOn,priv);
-    ok= ok&&XkbWriteXKBSymbols(file,result,False,showImplicit,addOn,priv);
-    if (xkb->geom)
-	ok= ok&&XkbWriteXKBGeometry(file,result,False,showImplicit,addOn,priv);
-    fprintf(file,"};\n");
-    return ok;
-}
-
-/*ARGSUSED*/
-Bool
-XkbWriteXKBKeymap(	FILE *			file,
-			XkbFileInfo *		result,
-			Bool			topLevel,
-			Bool			showImplicit,
-			XkbFileAddOnFunc	addOn,
-			void *			priv)
-{
-Bool		ok;
-XkbDescPtr	xkb;
-
-    xkb= result->xkb;
-    fprintf(file,"xkb_keymap {\n");
-    ok= XkbWriteXKBKeycodes(file,result,False,showImplicit,addOn,priv);
-    ok= ok&&XkbWriteXKBKeyTypes(file,result,False,showImplicit,addOn,priv);
-    ok= ok&&XkbWriteXKBCompatMap(file,result,False,showImplicit,addOn,priv);
-    ok= ok&&XkbWriteXKBSymbols(file,result,False,showImplicit,addOn,priv);
-    if (xkb->geom)
-	ok= ok&&XkbWriteXKBGeometry(file,result,False,showImplicit,addOn,priv);
-    fprintf(file,"};\n");
-    return ok;
-}
-
-Bool
-XkbWriteXKBFile(	FILE *			out,
-			XkbFileInfo *		result,
-			Bool			showImplicit,
-			XkbFileAddOnFunc	addOn,
-			void *			priv)
-{
-Bool	 		ok = False;
-Bool			(*func)(
-    FILE *		/* file */,
-    XkbFileInfo *	/* result */,
-    Bool		/* topLevel */,
-    Bool		/* showImplicit */,
-    XkbFileAddOnFunc	/* addOn */,
-    void *		/* priv */
-) = NULL;
-
-    switch (result->type) {
-	case XkmSemanticsFile:
-	    func= XkbWriteXKBSemantics;
-	    break;
-	case XkmLayoutFile:
-	    func= XkbWriteXKBLayout;
-	    break;
-	case XkmKeymapFile:
-	    func= XkbWriteXKBKeymap;
-	    break;
-	case XkmTypesIndex:
-	    func= XkbWriteXKBKeyTypes;
-	    break;
-	case XkmCompatMapIndex:
-	    func= XkbWriteXKBCompatMap;
-	    break;
-	case XkmSymbolsIndex:
-	    func= XkbWriteXKBSymbols;
-	    break;
-	case XkmKeyNamesIndex:
-	    func= XkbWriteXKBKeycodes;
-	    break;
-	case XkmGeometryFile:
-	case XkmGeometryIndex:
-	    func= XkbWriteXKBGeometry;
-	    break;
-	case XkmVirtualModsIndex:
-	case XkmIndicatorsIndex:
-	    _XkbLibError(_XkbErrBadImplementation,
-	    		XkbConfigText(result->type,XkbMessage),0);
-	    return False;
-    }
-    if (out==NULL) {
-	_XkbLibError(_XkbErrFileCannotOpen,"XkbWriteXkbFile",0);
-	ok= False;
-    }
-    else if (func) {
-	ok= (*func)(out,result,True,showImplicit,addOn,priv);
-    }
-    return ok;
-}
diff --git a/xkb/xkbtext.c b/xkb/xkbtext.c
index defd45a..3a50371 100644
--- a/xkb/xkbtext.c
+++ b/xkb/xkbtext.c
@@ -44,7 +44,7 @@
 #include "dix.h"
 #include <X11/extensions/XKBstr.h>
 #define XKBSRV_NEED_FILE_FUNCS	1
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XKBgeom.h>
 
 /***====================================================================***/
@@ -448,100 +448,6 @@ char *		buf;
     return buf;
 }
 
-char *
-XkbAccessXDetailText(unsigned state,unsigned format)
-{
-char *buf,*prefix;
-
-    buf= tbGetBuffer(32);
-    if (format==XkbMessage)	prefix= "";
-    else			prefix= "XkbAXN_";
-    switch (state){
-	case XkbAXN_SKPress:	sprintf(buf,"%sSKPress",prefix); break;
-	case XkbAXN_SKAccept:	sprintf(buf,"%sSKAccept",prefix); break;
-	case XkbAXN_SKRelease:	sprintf(buf,"%sSKRelease",prefix); break;
-	case XkbAXN_SKReject:	sprintf(buf,"%sSKReject",prefix); break;
-	case XkbAXN_BKAccept:	sprintf(buf,"%sBKAccept",prefix); break;
-	case XkbAXN_BKReject:	sprintf(buf,"%sBKReject",prefix); break;
-	case XkbAXN_AXKWarning:	sprintf(buf,"%sAXKWarning",prefix); break;
-	default:		sprintf(buf,"ILLEGAL"); break;
-    }
-    return buf;
-}
-
-static char *nknNames[] = {
-	"keycodes", "geometry", "deviceID"
-};
-#define	NUM_NKN	(sizeof(nknNames)/sizeof(char *))
-
-char *
-XkbNKNDetailMaskText(unsigned detail,unsigned format)
-{
-char *buf,*prefix,*suffix;
-register int 		i;
-register unsigned	bit;
-int			len,plen,slen;
-
-
-    if ((detail&XkbAllNewKeyboardEventsMask)==0) {
-	char *tmp = "";
-	if (format==XkbCFile)			tmp= "0";
-	else if (format==XkbMessage)		tmp= "none";
-	buf=  tbGetBuffer(strlen(tmp)+1);
-	strcpy(buf,tmp);
-	return buf;
-    }
-    else if ((detail&XkbAllNewKeyboardEventsMask)==XkbAllNewKeyboardEventsMask){
-	char *	tmp;
-	if (format==XkbCFile)		tmp= "XkbAllNewKeyboardEventsMask";
-	else 				tmp= "all";
-	buf=  tbGetBuffer(strlen(tmp)+1);
-	strcpy(buf,tmp);
-	return buf;
-    }
-    if (format==XkbMessage) {
-	prefix= "";
-	suffix= "";
-	slen= plen= 0;
-    }
-    else {
-	prefix= "XkbNKN_";
-	plen= 7;
-	if (format==XkbCFile)
-	     suffix= "Mask";
-	else suffix= "";
-	slen= strlen(suffix);
-    }
-    for (len=0,i=0,bit=1;i<NUM_NKN;i++,bit<<=1) {
-	if (detail&bit) {
-	    if (len!=0)	len+= 1;	/* room for '+' or '|' */
-	    len+= plen+slen+strlen(nknNames[i]);
-	}
-    }
-    buf= tbGetBuffer(len+1);
-    buf[0]= '\0';
-    for (len=0,i=0,bit=1;i<NUM_NKN;i++,bit<<=1) {
-	if (detail&bit) {
-	    if (len!=0) {
-		if (format==XkbCFile)	buf[len++]= '|';
-		else			buf[len++]= '+';
-	    }
-	    if (plen) {
-		strcpy(&buf[len],prefix);
-		len+= plen;
-	    }
-	    strcpy(&buf[len],nknNames[i]);
-	    len+= strlen(nknNames[i]);
-	    if (slen) {
-		strcpy(&buf[len],suffix);
-		len+= slen;
-	    }
-	}
-    }
-    buf[len++]= '\0';
-    return buf;
-}
-
 static char *ctrlNames[] = {
 	"repeatKeys",
 	"slowKeys",
diff --git a/xkb/xkmread.c b/xkb/xkmread.c
index fec8687..c6c1842 100644
--- a/xkb/xkmread.c
+++ b/xkb/xkmread.c
@@ -41,7 +41,7 @@
 #include "inputstr.h"
 #include <X11/extensions/XKBstr.h>
 #define	 XKBSRV_NEED_FILE_FUNCS
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
 #include <X11/extensions/XKBgeom.h>
 
 Atom
@@ -1098,18 +1098,6 @@ unsigned i,size_toc;
     return 1;
 }
 
-xkmSectionInfo *
-XkmFindTOCEntry(xkmFileInfo *finfo,xkmSectionInfo *toc,unsigned type)
-{
-register int i;
-
-    for (i=0;i<finfo->num_toc;i++) {
-	if (toc[i].type==type)
-	    return &toc[i];
-    }
-    return NULL;
-}
-
 Bool
 XkmReadFileSection(	FILE *			file,
 			xkmSectionInfo *	toc,
diff-tree 9398d62f27ee1b287e4458fd8b011c10f7b59efd (from 0f75c47e0c5f4b2778930a6fabf894fc1dffd9d3)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Mar 21 00:18:24 2007 +0200

    XFree86 input: Add backwards compatibility for motion history
    Add the old motion history API back, as a shim around the new mi API.

diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 93c89fd..913735b 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -2981,3 +2981,16 @@ xf86IsUnblank(int mode)
 	return TRUE;
     }
 }
+
+_X_EXPORT void
+xf86MotionHistoryAllocate(LocalDevicePtr local)
+{
+    AllocateMotionHistory(local->dev);
+}
+
+_X_EXPORT int
+xf86GetMotionEvents(DeviceIntPtr pDev, xTimecoord *buff, unsigned long start,
+                    unsigned long stop, ScreenPtr pScreen)
+{
+    return GetMotionHistory(pDev, buff, start, stop, pScreen);
+}
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index b8f4b69..c9c8059 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -132,6 +132,9 @@ xf86ProcessCommonOptions(LocalDevicePtr 
     } else {
         xf86Msg(X_CONFIG, "%s: doesn't report drag events\n", local->name);
     }
+
+    /* Backwards compatibility. */
+    local->history_size = GetMotionHistorySize();
 }
 
 /***********************************************************************
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 47dbc70..b2bc8de 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -86,6 +86,9 @@
 #define XI_PRIVATE(dev) \
 	(((LocalDevicePtr)((dev)->public.devicePrivate))->private)
 
+/* Stupid API backwards-compatibility. */
+#define TS_Raw 60
+#define TS_Scaled 61
 
 #ifdef XINPUT
 /* This holds the input driver entry and module information. */
@@ -144,6 +147,7 @@ typedef struct _LocalDeviceRec {
     InputDriverPtr	    drv;
     pointer		    module;
     pointer		    options;
+    unsigned int            history_size;
 } LocalDeviceRec, *LocalDevicePtr, InputInfoRec, *InputInfoPtr;
 
 typedef struct _DeviceAssocRec 
diff-tree 0f75c47e0c5f4b2778930a6fabf894fc1dffd9d3 (from 80d29475b9a2ebbb303a8e324e09a15c528d5556)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Mar 21 00:12:02 2007 +0200

    xfree86 input: Re-enable DGA support
    Re-enable DGA support for relative mouse motion.

diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 204457f..28058b5 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -51,11 +51,14 @@
 
 static unsigned long DGAGeneration = 0;
 static int DGAScreenIndex = -1;
+static int mieq_installed = 0;
 
 static Bool DGACloseScreen(int i, ScreenPtr pScreen);
 static void DGADestroyColormap(ColormapPtr pmap);
 static void DGAInstallColormap(ColormapPtr pmap);
 static void DGAUninstallColormap(ColormapPtr pmap);
+static void DGAHandleEvent(int screen_num, xEvent *event,
+                           DeviceIntPtr device, int nevents);
 
 static void
 DGACopyModeInfo(
@@ -96,7 +99,6 @@ typedef struct {
    Bool			grabKeyboard;
 } DGAScreenRec, *DGAScreenPtr;
 
-
 _X_EXPORT Bool
 DGAInit(
    ScreenPtr pScreen,
@@ -146,7 +148,6 @@ DGAInit(
 	    modes[i].flags &= ~DGA_PIXMAP_AVAILABLE;
 #endif
 
-
     pScreen->devPrivates[DGAScreenIndex].ptr = (pointer)pScreenPriv;
     pScreenPriv->CloseScreen = pScreen->CloseScreen;
     pScreen->CloseScreen = DGACloseScreen;
@@ -157,11 +158,6 @@ DGAInit(
     pScreenPriv->UninstallColormap = pScreen->UninstallColormap;
     pScreen->UninstallColormap = DGAUninstallColormap;
 
-    /*
-     * This is now set in InitOutput().
-     *
-    pScrn->SetDGAMode = xf86SetDGAMode;
-     */
 
     return TRUE;
 }
@@ -247,12 +243,22 @@ FreeMarkedVisuals(ScreenPtr pScreen)
     }
 }
 
-
 static Bool 
 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);
 
    pScreen->CloseScreen = pScreenPriv->CloseScreen;
@@ -462,6 +468,15 @@ DGASetInputMode(int index, Bool keyboard
    {
       pScreenPriv->grabMouse = mouse;
       pScreenPriv->grabKeyboard = keyboard;
+
+      if (!mieq_installed) {
+          mieqSetHandler(*XDGAEventBase + MotionNotify, DGAHandleEvent);
+          mieqSetHandler(*XDGAEventBase + ButtonPress, DGAHandleEvent);
+          mieqSetHandler(*XDGAEventBase + ButtonRelease, DGAHandleEvent);
+          mieqSetHandler(*XDGAEventBase + KeyPress, DGAHandleEvent);
+          mieqSetHandler(*XDGAEventBase + KeyRelease, DGAHandleEvent);
+          mieq_installed = 1;
+      }
    }
 }
 
@@ -903,21 +918,93 @@ DGAVTSwitch(void)
    return TRUE;
 }
 
+Bool
+DGAStealKeyEvent(int index, int key_code, int is_down)
+{
+   DGAScreenPtr pScreenPriv;
+   dgaEvent    de;
+    
+   if(DGAScreenIndex < 0) /* no DGA */
+        return FALSE;
+
+   pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
 
-/* We have the power to steal or modify events that are about to get queued */
+   if(!pScreenPriv || !pScreenPriv->grabKeyboard) /* no direct mode */
+        return FALSE; 
+
+    de.u.u.type = *XDGAEventBase + (is_down ? KeyPress : KeyRelease);
+    de.u.u.detail = key_code;
+    de.u.event.time = GetTimeInMillis();
+    mieqEnqueue (inputInfo.keyboard, (xEvent *) &de);
+
+   return TRUE;
+}  
+
+static int  DGAMouseX, DGAMouseY;
 
 Bool
-DGAStealKeyEvent(int index, xEvent *e)
+DGAStealMotionEvent(int index, int dx, int dy)
 {
-}
+   DGAScreenPtr pScreenPriv;
+    dgaEvent    de;
 
-static int  DGAMouseX, DGAMouseY;
+   if(DGAScreenIndex < 0) /* no DGA */
+        return FALSE;
+    
+   pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+   if(!pScreenPriv || !pScreenPriv->grabMouse) /* no direct mode */
+        return FALSE;
+
+    DGAMouseX += dx;
+    if (DGAMouseX < 0)
+        DGAMouseX = 0;
+    else if (DGAMouseX > screenInfo.screens[index]->width)
+        DGAMouseX = screenInfo.screens[index]->width;
+    DGAMouseY += dy;
+    if (DGAMouseY < 0)
+        DGAMouseY = 0;
+    else if (DGAMouseY > screenInfo.screens[index]->height)
+        DGAMouseY = screenInfo.screens[index]->height;
+    de.u.u.type = *XDGAEventBase + MotionNotify;
+    de.u.u.detail = 0;
+    de.u.event.time = GetTimeInMillis();
+    de.u.event.dx = dx;
+    de.u.event.dy = dy;
+    de.u.event.pad1 = DGAMouseX;
+    de.u.event.pad2 = DGAMouseY;
+    mieqEnqueue (inputInfo.pointer, (xEvent *) &de);
+    return TRUE;
+}
 
 Bool
-DGAStealMouseEvent(int index, xEvent *e, int dx, int dy)
+DGAStealButtonEvent(int index, int button, int is_down)
 {
+    DGAScreenPtr pScreenPriv;
+    dgaEvent de;
+
+    if (DGAScreenIndex < 0)
+        return FALSE;
+    
+    pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
+
+    if (!pScreenPriv || !pScreenPriv->grabMouse)
+        return FALSE;
+
+    de.u.u.type = *XDGAEventBase + (is_down ? ButtonPress : ButtonRelease);
+    de.u.u.detail = button;
+    de.u.event.time = GetTimeInMillis();
+    de.u.event.dx = 0;
+    de.u.event.dy = 0;
+    de.u.event.pad1 = DGAMouseX;
+    de.u.event.pad2 = DGAMouseY;
+    mieqEnqueue (inputInfo.pointer, (xEvent *) &de);
+
+    return TRUE;
 }
 
+/* We have the power to steal or modify events that are about to get queued */
+
 Bool
 DGAIsDgaEvent (xEvent *e)
 {
@@ -1124,39 +1211,6 @@ DGAProcessPointerEvent (ScreenPtr pScree
     }
 }
 
-Bool
-DGADeliverEvent (ScreenPtr pScreen, xEvent *e)
-{
-    dgaEvent	    *de = (dgaEvent *) e;
-    DGAScreenPtr    pScreenPriv;
-    int		    coreEquiv;
-
-    /* no DGA */
-    if (DGAScreenIndex < 0 || XDGAEventBase == 0)
-	return FALSE;
-    pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
-    
-    /* DGA not initialized on this screen */
-    if (!pScreenPriv)
-	return FALSE;
-    
-    coreEquiv = de->u.u.type - *XDGAEventBase;
-    /* Not a DGA event */
-    if (coreEquiv < KeyPress || coreEquiv > MotionNotify)
-	return FALSE;
-    
-    switch (coreEquiv) {
-    case KeyPress:
-    case KeyRelease:
-	DGAProcessKeyboardEvent (pScreen, de, inputInfo.keyboard);
-	break;
-    default:
-	DGAProcessPointerEvent (pScreen, de, inputInfo.pointer);
-	break;
-    }
-    return TRUE;
-}
-
 _X_EXPORT Bool 
 DGAOpenFramebuffer(
    int index,
@@ -1215,3 +1269,35 @@ DGAGetOldDGAMode(int index)
    return 0;
 }
 
+static void
+DGAHandleEvent(int screen_num, xEvent *event, DeviceIntPtr device, int nevents)
+{
+    dgaEvent	    *de = (dgaEvent *) event;
+    ScreenPtr       pScreen = screenInfo.screens[screen_num];
+    DGAScreenPtr    pScreenPriv;
+    int		    coreEquiv;
+
+    /* no DGA */
+    if (DGAScreenIndex < 0 || XDGAEventBase == 0)
+	return;
+    pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
+    
+    /* DGA not initialized on this screen */
+    if (!pScreenPriv)
+	return;
+    
+    coreEquiv = de->u.u.type - *XDGAEventBase;
+    /* Not a DGA event; shouldn't happen, but you never know. */
+    if (coreEquiv < KeyPress || coreEquiv > MotionNotify)
+	return;
+    
+    switch (coreEquiv) {
+    case KeyPress:
+    case KeyRelease:
+	DGAProcessKeyboardEvent (pScreen, de, inputInfo.keyboard);
+	break;
+    default:
+	DGAProcessPointerEvent (pScreen, de, inputInfo.pointer);
+	break;
+    }
+}
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 16e330d..b8f4b69 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -90,6 +90,10 @@
 
 #include "mi.h"
 
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
 xEvent *xf86Events = NULL;
 
 static Bool
@@ -395,10 +399,12 @@ xf86PostMotionEvent(DeviceIntPtr	device,
 {
     va_list var;
     int i = 0, nevents = 0;
+    int dx, dy;
     Bool drag = xf86SendDragEvents(device);
     int *valuators = NULL;
     int flags = 0;
     xEvent *xE = NULL;
+    int index;
 
     if (is_absolute)
         flags = POINTER_ABSOLUTE;
@@ -412,6 +418,22 @@ xf86PostMotionEvent(DeviceIntPtr	device,
         valuators[i] = va_arg(var, int);
     va_end(var);
 
+#if XFreeXDGA
+    if (first_valuator == 0 && num_valuators >= 2) {
+        index = miPointerGetScreen(inputInfo.pointer)->myNum;
+        if (is_absolute) {
+            dx = valuators[0] - device->valuator->lastx;
+            dy = valuators[1] - device->valuator->lasty;
+        }
+        else {
+            dx = valuators[0];
+            dy = valuators[1];
+        }
+        if (DGAStealMotionEvent(index, dx, dy))
+            goto out;
+    }
+#endif
+
     if (!xf86Events)
         xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
     if (!xf86Events)
@@ -430,6 +452,7 @@ xf86PostMotionEvent(DeviceIntPtr	device,
         }
     }
 
+out:
     xfree(valuators);
 }
 
@@ -476,6 +499,13 @@ xf86PostButtonEvent(DeviceIntPtr	device,
     va_list var;
     int *valuators = NULL;
     int i = 0, nevents = 0;
+    int index;
+
+#if XFreeXDGA
+    index = miPointerGetScreen(inputInfo.pointer)->myNum;
+    if (DGAStealButtonEvent(index, button, is_down))
+        return;
+#endif
     
     valuators = xcalloc(sizeof(int), num_valuators);
 
@@ -552,6 +582,13 @@ xf86PostKeyboardEvent(DeviceIntPtr      
                       int               is_down)
 {
     int nevents = 0, i = 0;
+    int index;
+
+#if XFreeXDGA
+    index = miPointerGetScreen(inputInfo.pointer)->myNum;
+    if (DGAStealKeyEvent(index, key_code, is_down))
+        return;
+#endif
 
     if (!xf86Events)
         xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index fe65643..47dbc70 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -191,6 +191,10 @@ InputInfoPtr xf86AllocateInput(InputDriv
 InputDriverPtr xf86LookupInputDriver(const char *name);
 InputInfoPtr xf86LookupInput(const char *name);
 void xf86DeleteInput(InputInfoPtr pInp, int flags);
+void xf86MotionHistoryAllocate(LocalDevicePtr local);
+int xf86GetMotionEvents(DeviceIntPtr dev, xTimecoord *buff,
+                        unsigned long start, unsigned long stop,
+                        ScreenPtr pScreen);
 
 /* xf86Option.c */
 void xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts,
diff --git a/hw/xfree86/dixmods/extmod/dgaproc.h b/hw/xfree86/dixmods/extmod/dgaproc.h
index 5e424af..aaea4e2 100644
--- a/hw/xfree86/dixmods/extmod/dgaproc.h
+++ b/hw/xfree86/dixmods/extmod/dgaproc.h
@@ -120,8 +120,9 @@ int DGAGetOldDGAMode(int Index);
 int DGAGetModeInfo(int Index, XDGAModePtr mode, int num);
 
 Bool DGAVTSwitch(void);
-Bool DGAStealMouseEvent(int Index, xEvent *e, int dx, int dy);
-Bool DGAStealKeyEvent(int Index, xEvent *e);
+Bool DGAStealButtonEvent(int Index, int button, int is_down);
+Bool DGAStealMotionEvent(int Index, int dx, int dy);
+Bool DGAStealKeyEvent(int Index, int key_code, int is_down);
 Bool DGAIsDgaEvent (xEvent *e);
 
 Bool DGADeliverEvent (ScreenPtr pScreen, xEvent *e);
diff-tree 80d29475b9a2ebbb303a8e324e09a15c528d5556 (from b8df961843a95b29258ae9c5d46ccfc620d8de1c)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Mar 21 00:10:38 2007 +0200

    mieq: Allow event handlers for arbitrary events to be set
    Allow arbitrary events to use mieq by letting custom handlers be set.

diff --git a/mi/mi.h b/mi/mi.h
index 8d9d120..53b5c44 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -186,6 +186,9 @@ extern void mieqProcessInputEvents(
     void
 );
 
+typedef void (*mieqHandler)(int, xEventPtr, DeviceIntPtr, int);
+void mieqSetHandler(int event, mieqHandler handler);
+
 /* miexpose.c */
 
 extern RegionPtr miHandleExposures(
diff --git a/mi/mieq.c b/mi/mieq.c
index 507cdd3..5bd87eb 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -74,6 +74,7 @@ typedef struct _EventQueue {
     EventRec         events[QUEUE_SIZE]; /* static allocation for signals */
     ScreenPtr        pEnqueueScreen;     /* screen events are being delivered to */
     ScreenPtr        pDequeueScreen;     /* screen events are being dispatched to */
+    mieqHandler      handlers[128];      /* custom event handler */
 } EventQueueRec, *EventQueuePtr;
 
 static EventQueueRec miEventQueue;
@@ -81,11 +82,15 @@ static EventQueueRec miEventQueue;
 Bool
 mieqInit()
 {
+    int i;
+
     miEventQueue.head = miEventQueue.tail = 0;
     miEventQueue.lastEventTime = GetTimeInMillis ();
     miEventQueue.lastMotion = FALSE;
     miEventQueue.pEnqueueScreen = screenInfo.screens[0];
     miEventQueue.pDequeueScreen = miEventQueue.pEnqueueScreen;
+    for (i = 0; i < 128; i++)
+        miEventQueue.handlers[i] = NULL;
     SetInputCheck(&miEventQueue.head, &miEventQueue.tail);
     return TRUE;
 }
@@ -178,6 +183,16 @@ mieqSwitchScreen(ScreenPtr pScreen, Bool
 	miEventQueue.pDequeueScreen = pScreen;
 }
 
+void
+mieqSetHandler(int event, mieqHandler handler)
+{
+    if (handler && miEventQueue.handlers[event])
+        ErrorF("mieq: warning: overriding existing handler %p with %p for "
+               "event %d\n", miEventQueue.handlers[event], handler, event);
+
+    miEventQueue.handlers[event] = handler;
+}
+
 /* Call this from ProcessInputEvents(). */
 void
 mieqProcessInputEvents()
@@ -215,6 +230,15 @@ mieqProcessInputEvents()
             else
                 ++miEventQueue.head;
 
+            /* If someone's registered a custom event handler, let them
+             * steal it. */
+            if (miEventQueue.handlers[e->event->u.u.type]) {
+                miEventQueue.handlers[e->event->u.u.type](miEventQueue.pDequeueScreen->myNum,
+                                                          e->event, dev,
+                                                          e->nevents);
+                return;
+            }
+
             /* If this is a core event, make sure our keymap, et al, is
              * changed to suit. */
             if (e->event[0].u.u.type == KeyPress ||
diff-tree b8df961843a95b29258ae9c5d46ccfc620d8de1c (from 720f302d241e88e6e9f2962207da1aa9a79728b7)
Author: Alan Coopersmith <alan.coopersmith at sun.com>
Date:   Mon Mar 19 18:03:26 2007 -0700

    Define XF86PM on Solaris x86 builds now that we have sun_apm.c

diff --git a/configure.ac b/configure.ac
index fe77709..14c4ccb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1413,6 +1413,8 @@ return 0;}
 			fi
 			if test "${OS_MINOR}" -lt 8 ; then
 				solaris_usl_console="yes"
+			else
+				XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
 			fi
 			;;
 		  *)
diff-tree 720f302d241e88e6e9f2962207da1aa9a79728b7 (from b5a8a71e64c76b8dd42962cbd7984215c6ce4aa8)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Sat Mar 17 20:14:05 2007 -0700

    Slow down DDC I2C bus using a RiseFallTime of 20us for old monitors.
    
    This time value makes the bus run slowly enough for even the least reliable
    of monitors. Thanks to Pavel Troller for finding the necessary change.

diff --git a/hw/xfree86/ddc/xf86DDC.c b/hw/xfree86/ddc/xf86DDC.c
index 0f24c52..8080c8d 100644
--- a/hw/xfree86/ddc/xf86DDC.c
+++ b/hw/xfree86/ddc/xf86DDC.c
@@ -337,6 +337,12 @@ DDCRead_DDC2(int scrnIndex, I2CBusPtr pB
     unsigned char *R_Buffer;
     int i;
     
+    /*
+     * Slow down the bus so that older monitors don't 
+     * miss things.
+     */
+    pBus->RiseFallTime = 20;
+    
     if (!(dev = xf86I2CFindDev(pBus, 0x00A0))) {
 	dev = xf86CreateI2CDevRec();
 	dev->DevName = "ddc2";
diff-tree b5a8a71e64c76b8dd42962cbd7984215c6ce4aa8 (from 2489dae9f7def788910eee5733931392df83a0d6)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Sat Mar 17 17:26:11 2007 -0700

    Remove extra (and wrong) I2C ByteTimeout setting in DDC code.
    
    The DDC code sets the I2C timeouts to VESA standards, except that it had an
    extra setting of the ByteTimeout value which was wrong (off by a factor of
    50). Removing this should help DDC work on many more monitors. Note that the
    Intel driver duplicated these settings, along with the error. Yay for cult
    and paste coding.

diff --git a/hw/xfree86/ddc/xf86DDC.c b/hw/xfree86/ddc/xf86DDC.c
index 4ce585c..0f24c52 100644
--- a/hw/xfree86/ddc/xf86DDC.c
+++ b/hw/xfree86/ddc/xf86DDC.c
@@ -344,7 +344,6 @@ DDCRead_DDC2(int scrnIndex, I2CBusPtr pB
 	dev->ByteTimeout = 2200; /* VESA DDC spec 3 p. 43 (+10 %) */
 	dev->StartTimeout = 550;
 	dev->BitTimeout = 40;
-	dev->ByteTimeout = 40;
 	dev->AcknTimeout = 40;
 
 	dev->pI2CBus = pBus;
diff-tree 2489dae9f7def788910eee5733931392df83a0d6 (from 9d0c3b52f25df89738fb1a62ccffda8c8cbb4689)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Thu Mar 15 20:26:07 2007 -0700

    Correct ref counting of RRMode structures
    
    RRModes are referenced by the resource db, RROutput and RRCrtc structures.
    Ensure that the mode reference count is decremented each time a reference is
    lost from one of these sources. The missing destroys were in
    RRCrtcDestroyResource and RROutputDestroyResource, which only happen at
    server reset time, so modes would be unavailable in subsequent server
    generations.

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 315dd6c..ecf5bb2 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -361,6 +361,8 @@ RRCrtcDestroyResource (pointer value, XI
     }
     if (crtc->gammaRed)
 	xfree (crtc->gammaRed);
+    if (crtc->mode)
+	RRModeDestroy (crtc->mode);
     xfree (crtc);
     return 1;
 }
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 6e95c95..160071b 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -406,9 +406,12 @@ RROutputDestroyResource (pointer value, 
 	    }
 	}
     }
-    /* XXX destroy all modes? */
     if (output->modes)
+    {
+	for (m = 0; m < output->numModes; m++)
+	    RRModeDestroy (output->modes[m]);
 	xfree (output->modes);
+    }
     
     for (m = 0; m < output->numUserModes; m++)
 	RRModeDestroy (output->userModes[m]);
diff-tree 9d0c3b52f25df89738fb1a62ccffda8c8cbb4689 (from 2c93083edd29a65e73bb2e8eff9d353e92845c9b)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Tue Feb 20 23:04:26 2007 -0800

    Eliminate RRModeRec devPrivate field.
    
    The xf86 mode setting code was mis-using this field to try and store a
    pointer to a DisplayModeRec, however, each output has its own copy of every
    DisplayModeRec leaving the one in in the RRModeRec devPrivate field pointing
    at a random DisplayModeRec.
    
    Instead of attempting to rectify this, eliminating the devPrivate entirely
    turned out to be very easy; the DDX code now accepts an arbitrary RRModeRec
    structure and set that to the hardware, converting it on the fly to a
    DisplayModeRec as needed.
    (cherry picked from commit 3506b9376c2b0db09bfff58d64e07af88a6e8195)

diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 73647a6..4213fea 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -556,6 +556,56 @@ xf86RandR12GetOriginalVirtualSize(ScrnIn
 }
 
 #if RANDR_12_INTERFACE
+
+#define FLAG_BITS (RR_HSyncPositive | \
+		   RR_HSyncNegative | \
+		   RR_VSyncPositive | \
+		   RR_VSyncNegative | \
+		   RR_Interlace | \
+		   RR_DoubleScan | \
+		   RR_CSync | \
+		   RR_CSyncPositive | \
+		   RR_CSyncNegative | \
+		   RR_HSkewPresent | \
+		   RR_BCast | \
+		   RR_PixelMultiplex | \
+		   RR_DoubleClock | \
+		   RR_ClockDivideBy2)
+
+static Bool
+xf86RandRModeMatches (RRModePtr		randr_mode,
+		      DisplayModePtr	mode)
+{
+#if 0
+    if (match_name)
+    {
+	/* check for same name */
+	int	len = strlen (mode->name);
+	if (randr_mode->mode.nameLength != len)			return FALSE;
+	if (memcmp (randr_mode->name, mode->name, len) != 0)	return FALSE;
+    }
+#endif
+    
+    /* check for same timings */
+    if (randr_mode->mode.dotClock / 1000 != mode->Clock)    return FALSE;
+    if (randr_mode->mode.width        != mode->HDisplay)    return FALSE;
+    if (randr_mode->mode.hSyncStart   != mode->HSyncStart)  return FALSE;
+    if (randr_mode->mode.hSyncEnd     != mode->HSyncEnd)    return FALSE;
+    if (randr_mode->mode.hTotal       != mode->HTotal)	    return FALSE;
+    if (randr_mode->mode.hSkew        != mode->HSkew)	    return FALSE;
+    if (randr_mode->mode.height       != mode->VDisplay)    return FALSE;
+    if (randr_mode->mode.vSyncStart   != mode->VSyncStart)  return FALSE;
+    if (randr_mode->mode.vSyncEnd     != mode->VSyncEnd)    return FALSE;
+    if (randr_mode->mode.vTotal       != mode->VTotal)	    return FALSE;
+    
+    /* check for same flags (using only the XF86 valid flag bits) */
+    if ((randr_mode->mode.modeFlags & FLAG_BITS) != (mode->Flags & FLAG_BITS))
+	return FALSE;
+    
+    /* everything matches */
+    return TRUE;
+}
+
 static Bool
 xf86RandR12CrtcNotify (RRCrtcPtr	randr_crtc)
 {
@@ -594,12 +644,15 @@ xf86RandR12CrtcNotify (RRCrtcPtr	randr_c
 	     * We make copies of modes, so pointer equality 
 	     * isn't sufficient
 	     */
-	    for (j = 0; j < randr_output->numModes; j++)
+	    for (j = 0; j < randr_output->numModes + randr_output->numUserModes; j++)
 	    {
-		DisplayModePtr	outMode = randr_output->modes[j]->devPrivate;
-		if (xf86ModesEqual(mode, outMode))
+		RRModePtr   m = (j < randr_output->numModes ?
+				 randr_output->modes[j] :
+				 randr_output->userModes[j-randr_output->numModes]);
+					 
+		if (xf86RandRModeMatches (m, mode))
 		{
-		    randr_mode = randr_output->modes[j];
+		    randr_mode = m;
 		    break;
 		}
 	    }
@@ -611,6 +664,39 @@ xf86RandR12CrtcNotify (RRCrtcPtr	randr_c
     return ret;
 }
 
+/*
+ * Convert a RandR mode to a DisplayMode
+ */
+static void
+xf86RandRModeConvert (ScrnInfoPtr	scrn,
+		      RRModePtr		randr_mode,
+		      DisplayModePtr	mode)
+{
+    mode->prev = NULL;
+    mode->next = NULL;
+    mode->name = NULL;
+    mode->status = MODE_OK;
+    mode->type = 0;
+
+    mode->Clock = randr_mode->mode.dotClock / 1000;
+    
+    mode->HDisplay = randr_mode->mode.width;
+    mode->HSyncStart = randr_mode->mode.hSyncStart;
+    mode->HSyncEnd = randr_mode->mode.hSyncEnd;
+    mode->HTotal = randr_mode->mode.hTotal;
+    mode->HSkew = randr_mode->mode.hSkew;
+    
+    mode->VDisplay = randr_mode->mode.height;
+    mode->VSyncStart = randr_mode->mode.vSyncStart;
+    mode->VSyncEnd = randr_mode->mode.vSyncEnd;
+    mode->VTotal = randr_mode->mode.vTotal;
+    mode->VScan = 0;
+
+    mode->Flags = randr_mode->mode.modeFlags & FLAG_BITS;
+
+    xf86SetModeCrtc (mode, scrn->adjustFlags);
+}
+
 static Bool
 xf86RandR12CrtcSet (ScreenPtr	pScreen,
 		  RRCrtcPtr	randr_crtc,
@@ -624,16 +710,15 @@ xf86RandR12CrtcSet (ScreenPtr	pScreen,
     ScrnInfoPtr		pScrn = xf86Screens[pScreen->myNum];
     xf86CrtcConfigPtr   config = XF86_CRTC_CONFIG_PTR(pScrn);
     xf86CrtcPtr		crtc = randr_crtc->devPrivate;
-    DisplayModePtr	mode = randr_mode ? randr_mode->devPrivate : NULL;
     Bool		changed = FALSE;
     int			o, ro;
     xf86CrtcPtr		*save_crtcs;
     Bool		save_enabled = crtc->enabled;
 
     save_crtcs = ALLOCATE_LOCAL(config->num_crtc * sizeof (xf86CrtcPtr));
-    if ((mode != NULL) != crtc->enabled)
+    if ((randr_mode != NULL) != crtc->enabled)
 	changed = TRUE;
-    else if (mode && !xf86ModesEqual (&crtc->mode, mode))
+    else if (randr_mode && !xf86RandRModeMatches (randr_mode, &crtc->mode))
 	changed = TRUE;
     
     if (rotation != crtc->rotation)
@@ -667,11 +752,14 @@ xf86RandR12CrtcSet (ScreenPtr	pScreen,
     /* XXX need device-independent mode setting code through an API */
     if (changed)
     {
-	crtc->enabled = mode != NULL;
+	crtc->enabled = randr_mode != NULL;
 
-	if (mode)
+	if (randr_mode)
 	{
-	    if (!xf86CrtcSetMode (crtc, mode, rotation, x, y))
+	    DisplayModeRec  mode;
+
+	    xf86RandRModeConvert (pScrn, randr_mode, &mode);
+	    if (!xf86CrtcSetMode (crtc, &mode, rotation, x, y))
 	    {
 		crtc->enabled = save_enabled;
 		for (o = 0; o < config->num_output; o++)
@@ -685,7 +773,7 @@ xf86RandR12CrtcSet (ScreenPtr	pScreen,
 	    /*
 	     * Save the last successful setting for EnterVT
 	     */
-	    crtc->desiredMode = *mode;
+	    crtc->desiredMode = mode;
 	    crtc->desiredRotation = rotation;
 	    crtc->desiredX = x;
 	    crtc->desiredY = y;
@@ -733,33 +821,12 @@ xf86RandR12OutputValidateMode (ScreenPtr
 			       RROutputPtr  randr_output,
 			       RRModePtr    randr_mode)
 {
+    ScrnInfoPtr	    pScrn = xf86Screens[pScreen->myNum];
     xf86OutputPtr   output = randr_output->devPrivate;
-    DisplayModePtr  mode = randr_mode->devPrivate;
+    DisplayModeRec  mode;
 
-    if (!mode)
-    {
-	mode = xalloc (sizeof (DisplayModeRec) + randr_mode->mode.nameLength + 1);
-	if (!mode)
-	    return FALSE;
-	mode->name = (char *) mode + 1;
-	memcpy (mode->name, randr_mode->name, randr_mode->mode.nameLength);
-	mode->name[randr_mode->mode.nameLength] = '\0';
-	mode->Clock = randr_mode->mode.dotClock / 1000;
-	mode->HDisplay = randr_mode->mode.width;
-	mode->HSyncStart = randr_mode->mode.hSyncStart;
-	mode->HSyncEnd = randr_mode->mode.hSyncEnd;
-	mode->HTotal = randr_mode->mode.hTotal;
-	mode->HSkew = randr_mode->mode.hSkew;
-	
-	mode->VDisplay = randr_mode->mode.height;
-	mode->VSyncStart = randr_mode->mode.vSyncStart;
-	mode->VSyncEnd = randr_mode->mode.vSyncEnd;
-	mode->VTotal = randr_mode->mode.vTotal;
-    
-	mode->Flags = randr_mode->mode.modeFlags;
-	randr_mode->devPrivate = mode;
-    }
-    if (!output->funcs->mode_valid (output, mode))
+    xf86RandRModeConvert (pScrn, randr_mode, &mode);
+    if (output->funcs->mode_valid (output, &mode) != MODE_OK)
 	return FALSE;
     return TRUE;
 }
@@ -767,13 +834,6 @@ xf86RandR12OutputValidateMode (ScreenPtr
 static void
 xf86RandR12ModeDestroy (ScreenPtr pScreen, RRModePtr randr_mode)
 {
-    DisplayModePtr  mode = randr_mode->devPrivate;
-
-    if (mode)
-    {
-	xfree (mode);
-	randr_mode->devPrivate = NULL;
-    }
 }
 
 /**
@@ -822,7 +882,6 @@ xf86RROutputSetModes (RROutputPtr randr_
 
 		    rrmode = RRModeGet (&modeInfo, mode->name);
 		    if (rrmode) {
-			rrmode->devPrivate = mode;
 			rrmodes[nmode++] = rrmode;
 			npreferred += pref;
 		    }
diff --git a/randr/randrstr.h b/randr/randrstr.h
index f6d35cf..0dee999 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -79,7 +79,6 @@ struct _rrMode {
     int		    refcnt;
     xRRModeInfo	    mode;
     char	    *name;
-    void	    *devPrivate;
     ScreenPtr	    userScreen;
 };
 
diff-tree 2c93083edd29a65e73bb2e8eff9d353e92845c9b (from 3bffb281260476d2f74f0bf451d85d2f7cacd6c4)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Sun Feb 18 23:49:38 2007 -0800

    Add support for user-defined modelines in RandR.
    
    The RandR protocol spec has several requests in support of user-defined
    modes, but the implementation was stubbed out inside the X server. Fill out
    the DIX portion and start on the xf86 DDX portion. It might be necessary to
    add more code to the DDX to insert the user-defined modes into the output
    mode list.
    (cherry picked from commit 63cc2a51ef87130c632a874672a8c9167f14314e)
    
    Conflicts:
    
    	randr/randrstr.h
    
    Updated code to work in master with recent security API changes.

diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index ce780b6..73647a6 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -728,6 +728,54 @@ xf86RandR12OutputSetProperty (ScreenPtr 
     return output->funcs->set_property(output, property, value);
 }
 
+static Bool
+xf86RandR12OutputValidateMode (ScreenPtr    pScreen,
+			       RROutputPtr  randr_output,
+			       RRModePtr    randr_mode)
+{
+    xf86OutputPtr   output = randr_output->devPrivate;
+    DisplayModePtr  mode = randr_mode->devPrivate;
+
+    if (!mode)
+    {
+	mode = xalloc (sizeof (DisplayModeRec) + randr_mode->mode.nameLength + 1);
+	if (!mode)
+	    return FALSE;
+	mode->name = (char *) mode + 1;
+	memcpy (mode->name, randr_mode->name, randr_mode->mode.nameLength);
+	mode->name[randr_mode->mode.nameLength] = '\0';
+	mode->Clock = randr_mode->mode.dotClock / 1000;
+	mode->HDisplay = randr_mode->mode.width;
+	mode->HSyncStart = randr_mode->mode.hSyncStart;
+	mode->HSyncEnd = randr_mode->mode.hSyncEnd;
+	mode->HTotal = randr_mode->mode.hTotal;
+	mode->HSkew = randr_mode->mode.hSkew;
+	
+	mode->VDisplay = randr_mode->mode.height;
+	mode->VSyncStart = randr_mode->mode.vSyncStart;
+	mode->VSyncEnd = randr_mode->mode.vSyncEnd;
+	mode->VTotal = randr_mode->mode.vTotal;
+    
+	mode->Flags = randr_mode->mode.modeFlags;
+	randr_mode->devPrivate = mode;
+    }
+    if (!output->funcs->mode_valid (output, mode))
+	return FALSE;
+    return TRUE;
+}
+
+static void
+xf86RandR12ModeDestroy (ScreenPtr pScreen, RRModePtr randr_mode)
+{
+    DisplayModePtr  mode = randr_mode->devPrivate;
+
+    if (mode)
+    {
+	xfree (mode);
+	randr_mode->devPrivate = NULL;
+    }
+}
+
 /**
  * Given a list of xf86 modes and a RandR Output object, construct
  * RandR modes and assign them to the output
@@ -958,6 +1006,8 @@ xf86RandR12Init12 (ScreenPtr pScreen)
     rp->rrCrtcSet = xf86RandR12CrtcSet;
     rp->rrCrtcSetGamma = xf86RandR12CrtcSetGamma;
     rp->rrOutputSetProperty = xf86RandR12OutputSetProperty;
+    rp->rrOutputValidateMode = xf86RandR12OutputValidateMode;
+    rp->rrModeDestroy = xf86RandR12ModeDestroy;
     rp->rrSetConfig = NULL;
     pScrn->PointerMoved = xf86RandR12PointerMoved;
     if (!xf86RandR12CreateObjects12 (pScreen))
diff --git a/randr/mirandr.c b/randr/mirandr.c
index 0b763e1..47136fb 100644
--- a/randr/mirandr.c
+++ b/randr/mirandr.c
@@ -73,6 +73,20 @@ miRROutputSetProperty (ScreenPtr	    pSc
     return TRUE;
 }
 
+Bool
+miRROutputValidateMode (ScreenPtr	    pScreen,
+			RROutputPtr	    output,
+			RRModePtr	    mode)
+{
+    return FALSE;
+}
+
+void
+miRRModeDestroy (ScreenPtr  pScreen,
+		 RRModePtr  mode)
+{
+}
+
 /*
  * This function assumes that only a single depth can be
  * displayed at a time, but that all visuals of that depth
@@ -102,7 +116,8 @@ miRandRInit (ScreenPtr pScreen)
     pScrPriv->rrCrtcSet = miRRCrtcSet;
     pScrPriv->rrCrtcSetGamma = miRRCrtcSetGamma;
     pScrPriv->rrOutputSetProperty = miRROutputSetProperty;
-    
+    pScrPriv->rrOutputValidateMode = miRROutputValidateMode;
+    pScrPriv->rrModeDestroy = miRRModeDestroy;
     
     RRScreenSetSizeRange (pScreen,
 			  pScreen->width, pScreen->height,
diff --git a/randr/randrstr.h b/randr/randrstr.h
index 5058212..f6d35cf 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -80,7 +80,7 @@ struct _rrMode {
     xRRModeInfo	    mode;
     char	    *name;
     void	    *devPrivate;
-    Bool	    userDefined;
+    ScreenPtr	    userScreen;
 };
 
 struct _rrPropertyValue {
@@ -135,6 +135,8 @@ struct _rrOutput {
     int		    numModes;
     int		    numPreferred;
     RRModePtr	    *modes;
+    int		    numUserModes;
+    RRModePtr	    *userModes;
     Bool	    changed;
     RRPropertyPtr   properties;
     void	    *devPrivate;
@@ -164,6 +166,13 @@ typedef Bool (*RROutputSetPropertyProcPt
 					    Atom		property,
 					    RRPropertyValuePtr	value);
 
+typedef Bool (*RROutputValidateModeProcPtr) (ScreenPtr		pScreen,
+					     RROutputPtr	output,
+					     RRModePtr		mode);
+
+typedef void (*RRModeDestroyProcPtr) (ScreenPtr	    pScreen,
+				      RRModePtr	    mode);
+
 #endif
 
 typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations);
@@ -208,6 +217,8 @@ typedef struct _rrScrPriv {
     RRCrtcSetProcPtr	    rrCrtcSet;
     RRCrtcSetGammaProcPtr   rrCrtcSetGamma;
     RROutputSetPropertyProcPtr	rrOutputSetProperty;
+    RROutputValidateModeProcPtr	rrOutputValidateMode;
+    RRModeDestroyProcPtr	rrModeDestroy;
 #endif
     
     /*
@@ -394,6 +405,15 @@ miRROutputSetProperty (ScreenPtr	    pSc
 		       Atom		    property,
 		       RRPropertyValuePtr   value);
 
+Bool
+miRROutputValidateMode (ScreenPtr	    pScreen,
+			RROutputPtr	    output,
+			RRModePtr	    mode);
+
+void
+miRRModeDestroy (ScreenPtr  pScreen,
+		 RRModePtr  mode);
+
 /* randr.c */
 /*
  * Send all pending events
@@ -549,6 +569,11 @@ Bool
 RRCrtcSetRotations (RRCrtcPtr crtc,
 		    Rotation rotations);
 
+/*
+ * Return the area of the frame buffer scanned out by the crtc,
+ * taking into account the current mode and rotation
+ */
+
 void
 RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height);
 
@@ -672,6 +697,14 @@ RROutputSetModes (RROutputPtr	output,
 		  int		numModes,
 		  int		numPreferred);
 
+int
+RROutputAddUserMode (RROutputPtr    output,
+		     RRModePtr	    mode);
+
+int
+RROutputDeleteUserMode (RROutputPtr output,
+			RRModePtr   mode);
+
 Bool
 RROutputSetCrtcs (RROutputPtr	output,
 		  RRCrtcPtr	*crtcs,
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index db506f4..315dd6c 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -666,10 +666,15 @@ ProcRRSetCrtcConfig (ClientPtr client)
 	    return BadMatch;
 	}
 	/* validate mode for this output */
-	for (j = 0; j < outputs[i]->numModes; j++)
-	    if (outputs[i]->modes[j] == mode)
+	for (j = 0; j < outputs[i]->numModes + outputs[i]->numUserModes; j++)
+	{
+	    RRModePtr	m = (j < outputs[i]->numModes ? 
+			     outputs[i]->modes[j] :
+			     outputs[i]->userModes[j - outputs[i]->numModes]);
+	    if (m == mode)
 		break;
-	if (j == outputs[i]->numModes)
+	}
+	if (j == outputs[i]->numModes + outputs[i]->numUserModes)
 	{
 	    if (outputs)
 		xfree (outputs);
diff --git a/randr/rrinfo.c b/randr/rrinfo.c
index 797cdb1..549d501 100644
--- a/randr/rrinfo.c
+++ b/randr/rrinfo.c
@@ -157,9 +157,11 @@ RRScanOldConfig (ScreenPtr pScreen, Rota
     pScrPriv->nSizes = 0;
 	    
     /* find size bounds */
-    for (i = 0; i < output->numModes; i++) 
+    for (i = 0; i < output->numModes + output->numUserModes; i++) 
     {
-	RRModePtr   mode = output->modes[i];
+	RRModePtr   mode = (i < output->numModes ? 
+			    output->modes[i] : 
+			    output->userModes[i-output->numModes]);
         CARD16	    width = mode->mode.width;
         CARD16	    height = mode->mode.height;
 	
diff --git a/randr/rrmode.c b/randr/rrmode.c
index 261e1b7..1117581 100644
--- a/randr/rrmode.c
+++ b/randr/rrmode.c
@@ -48,25 +48,13 @@ RRModeEqual (xRRModeInfo *a, xRRModeInfo
 static int	    num_modes;
 static RRModePtr    *modes;
 
-RRModePtr
-RRModeGet (xRRModeInfo	*modeInfo,
-	   const char	*name)
+static RRModePtr
+RRModeCreate (xRRModeInfo   *modeInfo,
+	      const char    *name,
+	      ScreenPtr	    userScreen)
 {
-    int	i;
-    RRModePtr	mode;
-    RRModePtr	*newModes;
-
-    for (i = 0; i < num_modes; i++)
-    {
-	mode = modes[i];
-	if (RRModeEqual (&mode->mode, modeInfo) &&
-	    !memcmp (name, mode->name, modeInfo->nameLength))
-	{
-	    ++mode->refcnt;
-	    return mode;
-	}
-    }
-
+    RRModePtr	mode, *newModes;
+    
     if (!RRInit ())
 	return NULL;
 
@@ -78,7 +66,7 @@ RRModeGet (xRRModeInfo	*modeInfo,
     mode->name = (char *) (mode + 1);
     memcpy (mode->name, name, modeInfo->nameLength);
     mode->name[modeInfo->nameLength] = '\0';
-    mode->userDefined = FALSE;
+    mode->userScreen = userScreen;
 
     if (num_modes)
 	newModes = xrealloc (modes, (num_modes + 1) * sizeof (RRModePtr));
@@ -104,11 +92,75 @@ RRModeGet (xRRModeInfo	*modeInfo,
     return mode;
 }
 
+static RRModePtr
+RRModeFindByName (const char	*name,
+		  CARD16    	nameLength)
+{
+    int		i;
+    RRModePtr	mode;
+
+    for (i = 0; i < num_modes; i++)
+    {
+	mode = modes[i];
+	if (mode->mode.nameLength == nameLength &&
+	    !memcmp (name, mode->name, nameLength))
+	{
+	    return mode;
+	}
+    }
+    return NULL;
+}
+
+RRModePtr
+RRModeGet (xRRModeInfo	*modeInfo,
+	   const char	*name)
+{
+    int	i;
+
+    for (i = 0; i < num_modes; i++)
+    {
+	RRModePtr   mode = modes[i];
+	if (RRModeEqual (&mode->mode, modeInfo) &&
+	    !memcmp (name, mode->name, modeInfo->nameLength))
+	{
+	    ++mode->refcnt;
+	    return mode;
+	}
+    }
+
+    return RRModeCreate (modeInfo, name, NULL);
+}
+
+static RRModePtr
+RRModeCreateUser (ScreenPtr	pScreen,
+		  xRRModeInfo	*modeInfo,
+		  const char	*name,
+		  int		*error)
+{
+    RRModePtr	mode;
+
+    mode = RRModeFindByName (name, modeInfo->nameLength);
+    if (mode)
+    {
+	*error = BadName;
+	return NULL;
+    }
+    
+    mode = RRModeCreate (modeInfo, name, pScreen);
+    if (!mode)
+    {
+	*error = BadAlloc;
+	return NULL;
+    }
+    *error = Success;
+    return mode;
+}
+
 RRModePtr *
 RRModesForScreen (ScreenPtr pScreen, int *num_ret)
 {
     rrScrPriv(pScreen);
-    int	o, c;
+    int		o, c, m;
     RRModePtr	*screen_modes;
     int		num_screen_modes = 0;
 
@@ -122,9 +174,11 @@ RRModesForScreen (ScreenPtr pScreen, int
 	RROutputPtr	output = pScrPriv->outputs[o];
 	int		m, n;
 
-	for (m = 0; m < output->numModes; m++)
+	for (m = 0; m < output->numModes + output->numUserModes; m++)
 	{
-	    RRModePtr	mode = output->modes[m];
+	    RRModePtr   mode = (m < output->numModes ? 
+				output->modes[m] : 
+				output->userModes[m-output->numModes]);
 	    for (n = 0; n < num_screen_modes; n++)
 		if (screen_modes[n] == mode)
 		    break;
@@ -150,6 +204,23 @@ RRModesForScreen (ScreenPtr pScreen, int
 	if (n == num_screen_modes)
 	    screen_modes[num_screen_modes++] = mode;
     }
+    /*
+     * Add all user modes for this screen
+     */
+    for (m = 0; m < num_modes; m++)
+    {
+	RRModePtr	mode = modes[m];
+	int		n;
+
+	if (mode->userScreen != pScreen)
+	    continue;
+	for (n = 0; n < num_screen_modes; n++)
+	    if (screen_modes[n] == mode)
+		break;
+	if (n == num_screen_modes)
+	    screen_modes[num_screen_modes++] = mode;
+    }
+    
     *num_ret = num_screen_modes;
     return screen_modes;
 }
@@ -205,38 +276,122 @@ int
 ProcRRCreateMode (ClientPtr client)
 {
     REQUEST(xRRCreateModeReq);
+    xRRCreateModeReply	rep;
+    WindowPtr		pWin;
+    ScreenPtr		pScreen;
+    rrScrPrivPtr	pScrPriv;
+    xRRModeInfo		*modeInfo;
+    long		units_after;
+    char		*name;
+    int			error, rc;
+    RRModePtr		mode;
+    
+    REQUEST_AT_LEAST_SIZE (xRRCreateModeReq);
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+    if (rc != Success)
+	return rc;
+
+    pScreen = pWin->drawable.pScreen;
+    pScrPriv = rrGetScrPriv(pScreen);
+    
+    modeInfo = &stuff->modeInfo;
+    name = (char *) (stuff + 1);
+    units_after = (stuff->length - (sizeof (xRRCreateModeReq) >> 2));
+
+    /* check to make sure requested name fits within the data provided */
+    if ((int) (modeInfo->nameLength + 3) >> 2 > units_after)
+	return BadLength;
+
+    mode = RRModeCreateUser (pScreen, modeInfo, name, &error);
+    if (!mode)
+	return error;
+
+    rep.type = X_Reply;
+    rep.pad0 = 0;
+    rep.sequenceNumber = client->sequence;
+    rep.length = 0;
+    rep.mode = mode->mode.id;
+    if (client->swapped)
+    {
+	int n;
+    	swaps(&rep.sequenceNumber, n);
+    	swapl(&rep.length, n);
+	swapl(&rep.mode, n);
+    }
+    WriteToClient(client, sizeof(xRRCreateModeReply), (char *)&rep);
     
-    REQUEST_SIZE_MATCH(xRRCreateModeReq);
-    (void) stuff;
-    return BadImplementation; 
+    return client->noClientException;
 }
 
 int
 ProcRRDestroyMode (ClientPtr client)
 {
     REQUEST(xRRDestroyModeReq);
+    RRModePtr	mode;
     
     REQUEST_SIZE_MATCH(xRRDestroyModeReq);
-    (void) stuff;
-    return BadImplementation; 
+    mode = LookupIDByType (stuff->mode, RRModeType);
+    if (!mode)
+    {
+	client->errorValue = stuff->mode;
+	return RRErrorBase + BadRRMode;
+    }
+    if (!mode->userScreen)
+	return BadMatch;
+    if (mode->refcnt > 1)
+	return BadAccess;
+    FreeResource (stuff->mode, 0);
+    return Success;
 }
 
 int
 ProcRRAddOutputMode (ClientPtr client)
 {
     REQUEST(xRRAddOutputModeReq);
+    RRModePtr	mode;
+    RROutputPtr	output;
     
     REQUEST_SIZE_MATCH(xRRAddOutputModeReq);
-    (void) stuff;
-    return BadImplementation; 
+    output = LookupOutput(client, stuff->output, DixReadAccess);
+
+    if (!output)
+    {
+	client->errorValue = stuff->output;
+	return RRErrorBase + BadRROutput;
+    }
+    
+    mode = LookupIDByType (stuff->mode, RRModeType);
+    if (!mode)
+    {
+	client->errorValue = stuff->mode;
+	return RRErrorBase + BadRRMode;
+    }
+    
+    return RROutputAddUserMode (output, mode);
 }
 
 int
 ProcRRDeleteOutputMode (ClientPtr client)
 {
     REQUEST(xRRDeleteOutputModeReq);
+    RRModePtr	mode;
+    RROutputPtr	output;
     
     REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq);
-    (void) stuff;
-    return BadImplementation; 
+    output = LookupOutput(client, stuff->output, DixReadAccess);
+
+    if (!output)
+    {
+	client->errorValue = stuff->output;
+	return RRErrorBase + BadRROutput;
+    }
+    
+    mode = LookupIDByType (stuff->mode, RRModeType);
+    if (!mode)
+    {
+	client->errorValue = stuff->mode;
+	return RRErrorBase + BadRRMode;
+    }
+    
+    return RROutputDeleteUserMode (output, mode);
 }
diff --git a/randr/rroutput.c b/randr/rroutput.c
index df1741f..6e95c95 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -76,6 +76,8 @@ RROutputCreate (const char  *name,
     output->numModes = 0;
     output->numPreferred = 0;
     output->modes = NULL;
+    output->numUserModes = 0;
+    output->userModes = NULL;
     output->properties = NULL;
     output->changed = FALSE;
     output->devPrivate = devPrivate;
@@ -192,6 +194,74 @@ RROutputSetModes (RROutputPtr	output,
     return TRUE;
 }
 
+int
+RROutputAddUserMode (RROutputPtr    output,
+		     RRModePtr	    mode)
+{
+    int		m;
+    ScreenPtr	pScreen = output->pScreen;
+    rrScrPriv(pScreen);
+    RRModePtr	*newModes;
+
+    /* Check to see if this mode is already listed for this output */
+    for (m = 0; m < output->numModes + output->numUserModes; m++)
+    {
+	RRModePtr   e = (m < output->numModes ?
+			 output->modes[m] :
+			 output->userModes[m - output->numModes]);
+	if (mode == e)
+	    return Success;
+    }
+
+    /* Check with the DDX to see if this mode is OK */
+    if (pScrPriv->rrOutputValidateMode)
+	if (!pScrPriv->rrOutputValidateMode (pScreen, output, mode))
+	    return BadMatch;
+
+    if (output->userModes)
+	newModes = xrealloc (output->userModes,
+			     (output->numUserModes + 1) * sizeof (RRModePtr));
+    else
+	newModes = xalloc (sizeof (RRModePtr));
+    if (!newModes)
+	return BadAlloc;
+
+    output->userModes = newModes;
+    output->userModes[output->numUserModes++] = mode;
+    ++mode->refcnt;
+    RROutputChanged (output, TRUE);
+    RRTellChanged (pScreen);
+    return Success;
+}
+
+int
+RROutputDeleteUserMode (RROutputPtr output,
+			RRModePtr   mode)
+{
+    int		m;
+    
+    /* Find this mode in the user mode list */
+    for (m = 0; m < output->numUserModes; m++)
+    {
+	RRModePtr   e = output->userModes[m];
+
+	if (mode == e)
+	    break;
+    }
+    /* Not there, access error */
+    if (m == output->numUserModes)
+	return BadAccess;
+
+    /* make sure the mode isn't active for this output */
+    if (output->crtc && output->crtc->mode == mode)
+	return BadMatch;
+
+    memmove (output->userModes + m, output->userModes + m + 1,
+	     (output->numUserModes - m - 1) * sizeof (RRModePtr));
+    RRModeDestroy (mode);
+    return Success;
+}
+
 Bool
 RROutputSetCrtcs (RROutputPtr	output,
 		  RRCrtcPtr	*crtcs,
@@ -308,9 +378,9 @@ RRDeliverOutputEvent(ClientPtr client, W
  * Destroy a Output at shutdown
  */
 void
-RROutputDestroy (RROutputPtr crtc)
+RROutputDestroy (RROutputPtr output)
 {
-    FreeResource (crtc->id, 0);
+    FreeResource (output->id, 0);
 }
 
 static int
@@ -318,6 +388,7 @@ RROutputDestroyResource (pointer value, 
 {
     RROutputPtr	output = (RROutputPtr) value;
     ScreenPtr	pScreen = output->pScreen;
+    int		m;
 
     if (pScreen)
     {
@@ -335,8 +406,15 @@ RROutputDestroyResource (pointer value, 
 	    }
 	}
     }
+    /* XXX destroy all modes? */
     if (output->modes)
 	xfree (output->modes);
+    
+    for (m = 0; m < output->numUserModes; m++)
+	RRModeDestroy (output->userModes[m]);
+    if (output->userModes)
+	xfree (output->userModes);
+
     if (output->crtcs)
 	xfree (output->crtcs);
     if (output->clones)
@@ -383,7 +461,10 @@ ProcRRGetOutputInfo (ClientPtr client)
     output = LookupOutput(client, stuff->output, DixReadAccess);
 
     if (!output)
+    {
+	client->errorValue = stuff->output;
 	return RRErrorBase + BadRROutput;
+    }
 
     pScreen = output->pScreen;
     pScrPriv = rrGetScrPriv(pScreen);
@@ -398,13 +479,13 @@ ProcRRGetOutputInfo (ClientPtr client)
     rep.connection = output->connection;
     rep.subpixelOrder = output->subpixelOrder;
     rep.nCrtcs = output->numCrtcs;
-    rep.nModes = output->numModes;
+    rep.nModes = output->numModes + output->numUserModes;
     rep.nPreferred = output->numPreferred;
     rep.nClones = output->numClones;
     rep.nameLength = output->nameLength;
     
     extraLen = ((output->numCrtcs + 
-		 output->numModes + 
+		 output->numModes + output->numUserModes +
 		 output->numClones +
 		 ((rep.nameLength + 3) >> 2)) << 2);
 
@@ -420,7 +501,7 @@ ProcRRGetOutputInfo (ClientPtr client)
 
     crtcs = (RRCrtc *) extra;
     modes = (RRMode *) (crtcs + output->numCrtcs);
-    clones = (RROutput *) (modes + output->numModes);
+    clones = (RROutput *) (modes + output->numModes + output->numUserModes);
     name = (char *) (clones + output->numClones);
     
     for (i = 0; i < output->numCrtcs; i++)
@@ -429,9 +510,12 @@ ProcRRGetOutputInfo (ClientPtr client)
 	if (client->swapped)
 	    swapl (&crtcs[i], n);
     }
-    for (i = 0; i < output->numModes; i++)
+    for (i = 0; i < output->numModes + output->numUserModes; i++)
     {
-	modes[i] = output->modes[i]->mode.id;
+	if (i < output->numModes)
+	    modes[i] = output->modes[i]->mode.id;
+	else
+	    modes[i] = output->userModes[i - output->numModes]->mode.id;
 	if (client->swapped)
 	    swapl (&modes[i], n);
     }
diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index 1680003..ad74ac3 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -473,7 +473,7 @@ RR10GetData (ScreenPtr pScreen, RROutput
 {
     RR10DataPtr	    data;
     RRScreenSizePtr size;
-    int		    nmode = output->numModes;
+    int		    nmode = output->numModes + output->numUserModes;
     int		    o, os, l, r;
     RRScreenRatePtr refresh;
     CARD16	    vRefresh;
@@ -500,11 +500,14 @@ RR10GetData (ScreenPtr pScreen, RROutput
     /*
      * find modes not yet listed
      */
-    for (o = 0; o < output->numModes; o++)
+    for (o = 0; o < output->numModes + output->numUserModes; o++)
     {
 	if (used[o]) continue;
 	
-	mode = output->modes[o];
+	if (o < output->numModes)
+	    mode = output->modes[o];
+	else
+	    mode = output->userModes[o - output->numModes];
 	
 	l = data->nsize;
 	size[l].id = data->nsize;
@@ -524,9 +527,12 @@ RR10GetData (ScreenPtr pScreen, RROutput
 	/*
 	 * Find all modes with matching size
 	 */
-	for (os = o; os < output->numModes; os++)
+	for (os = o; os < output->numModes + output->numUserModes; os++)
 	{
-	    mode = output->modes[os];
+	    if (os < output->numModes)
+		mode = output->modes[os];
+	    else
+		mode = output->userModes[os - output->numModes];
 	    if (mode->mode.width == size[l].width &&
 		mode->mode.height == size[l].height)
 	    {
diff-tree 3bffb281260476d2f74f0bf451d85d2f7cacd6c4 (from 9562b6abe1da566cf73a08c4f4c4339fb67fbc71)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Thu Mar 15 16:16:16 2007 -0700

    Don't wedge when rotating more than one CRTC.
    
    Rotation block handler was re-registering the rotation damage structure,
    creating an infinite loop in the damage code. Track registration of the
    damage structure to avoid this.
    (cherry picked from commit b14f003b0ed1252766c9e3b1c086ea2809521047)

diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index df8a8aa..b751592 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -529,7 +529,8 @@ typedef struct _xf86CrtcConfig {
     int			maxWidth, maxHeight;
     
     /* For crtc-based rotation */
-    DamagePtr   rotationDamage;
+    DamagePtr		rotation_damage;
+    Bool		rotation_damage_registered;
 
     /* DGA */
     unsigned int	dga_flags;
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 6826b62..e82b69e 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -251,9 +251,13 @@ xf86RotatePrepare (ScreenPtr pScreen)
 							     crtc->rotatedData,
 							     crtc->mode.HDisplay,
 							     crtc->mode.VDisplay);
-	    /* Hook damage to screen pixmap */
-	    DamageRegister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
-			    xf86_config->rotationDamage);
+	    if (!xf86_config->rotation_damage_registered)
+	    {
+		/* Hook damage to screen pixmap */
+		DamageRegister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
+				xf86_config->rotation_damage);
+		xf86_config->rotation_damage_registered = TRUE;
+	    }
 	    
 	    xf86CrtcDamageShadow (crtc);
 	}
@@ -265,7 +269,7 @@ xf86RotateRedisplay(ScreenPtr pScreen)
 {
     ScrnInfoPtr		pScrn = xf86Screens[pScreen->myNum];
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-    DamagePtr		damage = xf86_config->rotationDamage;
+    DamagePtr		damage = xf86_config->rotation_damage;
     RegionPtr		region;
 
     if (!damage)
@@ -334,13 +338,14 @@ xf86CrtcRotate (xf86CrtcPtr crtc, Displa
 	    crtc->rotatedData = NULL;
 	}
 
-	if (xf86_config->rotationDamage)
+	if (xf86_config->rotation_damage)
 	{
 	    /* Free damage structure */
 	    DamageUnregister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
-			      xf86_config->rotationDamage);
-	    DamageDestroy (xf86_config->rotationDamage);
-	    xf86_config->rotationDamage = NULL;
+			      xf86_config->rotation_damage);
+	    xf86_config->rotation_damage_registered = FALSE;
+	    DamageDestroy (xf86_config->rotation_damage);
+	    xf86_config->rotation_damage = NULL;
 	    /* Free block/wakeup handler */
 	    RemoveBlockAndWakeupHandlers (xf86RotateBlockHandler,
 					  xf86RotateWakeupHandler,
@@ -382,13 +387,13 @@ xf86CrtcRotate (xf86CrtcPtr crtc, Displa
 	    xf86CrtcDamageShadow (crtc);
 	}
 	
-	if (!xf86_config->rotationDamage)
+	if (!xf86_config->rotation_damage)
 	{
 	    /* Create damage structure */
-	    xf86_config->rotationDamage = DamageCreate (NULL, NULL,
+	    xf86_config->rotation_damage = DamageCreate (NULL, NULL,
 						DamageReportNone,
 						TRUE, pScreen, pScreen);
-	    if (!xf86_config->rotationDamage)
+	    if (!xf86_config->rotation_damage)
 		goto bail2;
 	    
 	    /* Assign block/wakeup handler */
@@ -402,8 +407,8 @@ xf86CrtcRotate (xf86CrtcPtr crtc, Displa
 	if (0)
 	{
 bail3:
-	    DamageDestroy (xf86_config->rotationDamage);
-	    xf86_config->rotationDamage = NULL;
+	    DamageDestroy (xf86_config->rotation_damage);
+	    xf86_config->rotation_damage = NULL;
 	    
 bail2:
 	    if (shadow || shadowData)
diff-tree 9562b6abe1da566cf73a08c4f4c4339fb67fbc71 (from 3b71b0f89f1db837da91650baa0ef4bb7ef2e98f)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Thu Mar 15 10:50:45 2007 -0700

    Allow xf86_reload_cursors during server init.
    
    xf86_reload_cursors is supposed to be called from the crtc mode setting
    commit hook; as that happens during server initialization, check for this
    case.
    (cherry picked from commit 5b77bf2d020b1ee56c1c5f2db089a8f7f64a76a6)

diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index 095df48..009cccf 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -548,12 +548,24 @@ xf86_cursors_init (ScreenPtr screen, int
 void
 xf86_reload_cursors (ScreenPtr screen)
 {
-    ScrnInfoPtr		scrn = xf86Screens[screen->myNum];
-    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-    xf86CursorInfoPtr	cursor_info = xf86_config->cursor_info;
-    CursorPtr		cursor = xf86_config->cursor;
+    ScrnInfoPtr		scrn;
+    xf86CrtcConfigPtr   xf86_config;
+    xf86CursorInfoPtr   cursor_info;
+    CursorPtr		cursor;
     int			x, y;
     
+    /* initial mode setting will not have set a screen yet */
+    if (!screen)
+	return;
+    scrn = xf86Screens[screen->myNum];
+    xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+
+    /* make sure the cursor code has been initialized */
+    cursor_info = xf86_config->cursor_info;
+    if (!cursor_info)
+	return;
+    
+    cursor = xf86_config->cursor;
     GetSpritePosition (&x, &y);
     if (!(cursor_info->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
 	(*cursor_info->HideCursor)(scrn);
diff-tree 3b71b0f89f1db837da91650baa0ef4bb7ef2e98f (from 2fe74ef339c3a4902ae8214f5a0454662895422c)
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Mar 15 13:21:00 2007 -0700

    Set the RandR version returned, rather than just passing the proto's version.

diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c
index 7f98965..5525427 100644
--- a/randr/rrdispatch.c
+++ b/randr/rrdispatch.c
@@ -22,6 +22,9 @@
 
 #include "randrstr.h"
 
+#define SERVER_RANDR_MAJOR	1
+#define SERVER_RANDR_MINOR	2
+
 Bool
 RRClientKnowsRates (ClientPtr	pClient)
 {
@@ -49,8 +52,8 @@ ProcRRQueryVersion (ClientPtr client)
      * Report the current version; the current
      * spec says they're all compatible after 1.0
      */
-    rep.majorVersion = RANDR_MAJOR;
-    rep.minorVersion = RANDR_MINOR;
+    rep.majorVersion = SERVER_RANDR_MAJOR;
+    rep.minorVersion = SERVER_RANDR_MINOR;
     if (client->swapped) {
     	swaps(&rep.sequenceNumber, n);
     	swapl(&rep.length, n);
diff-tree 2fe74ef339c3a4902ae8214f5a0454662895422c (from ae75019ccf1edac9e8be31b6a96293624f672ccb)
Author: Matthias Hopf <mhopf at suse.de>
Date:   Thu Mar 15 16:56:01 2007 +0100

    Fix calculations in x86 emulator for the long long case (Andreas Schwab).

diff --git a/hw/xfree86/x86emu/prim_ops.c b/hw/xfree86/x86emu/prim_ops.c
index 461e09e..b9e7257 100644
--- a/hw/xfree86/x86emu/prim_ops.c
+++ b/hw/xfree86/x86emu/prim_ops.c
@@ -2082,7 +2082,7 @@ Implements the IMUL instruction and side
 void imul_long_direct(u32 *res_lo, u32* res_hi,u32 d, u32 s)
 {
 #ifdef	__HAS_LONG_LONG__
-	s64 res = (s32)d * (s32)s;
+	s64 res = (s64)(s32)d * (s32)s;
 
 	*res_lo = (u32)res;
 	*res_hi = (u32)(res >> 32);
@@ -2174,7 +2174,7 @@ Implements the MUL instruction and side 
 void mul_long(u32 s)
 {
 #ifdef	__HAS_LONG_LONG__
-	u64 res = (u32)M.x86.R_EAX * (u32)s;
+	u64 res = (u64)M.x86.R_EAX * s;
 
 	M.x86.R_EAX = (u32)res;
 	M.x86.R_EDX = (u32)(res >> 32);
diff-tree ae75019ccf1edac9e8be31b6a96293624f672ccb (from 4bf1b280f7cb676ec2b172f26dd2ad9bac2eb2ca)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Wed Mar 14 23:59:29 2007 -0700

    Create driver-independent CRTC-based cursor layer.
    
    This moves most of the cursor management code out of the intel driver and
    into the general server code. Of course, the hope is that this code will be
    useful for other driver writers as well.
    
    Check out xf86Crtc.h for the usage information, making sure you add the
    needed hooks to the crtc funcs structure for your driver.
    (cherry picked from commit 4d81c99a4660a0bf9014f789de55edabd185bd14)

diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index b669063..50aa673 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -56,6 +56,7 @@ XORG_LIBS = \
             parser/libxf86config.a \
 	    dixmods/libdixmods.la \
 	    modes/libxf86modes.a \
+	    ramdac/libramdac.a \
 	    ddc/libddc.a \
 	    i2c/libi2c.a \
             @XORG_LIBS@
diff --git a/hw/xfree86/loader/Makefile.am b/hw/xfree86/loader/Makefile.am
index ceb66a2..ef9ab9a 100644
--- a/hw/xfree86/loader/Makefile.am
+++ b/hw/xfree86/loader/Makefile.am
@@ -2,7 +2,8 @@ noinst_LIBRARIES = libloader.a
 
 INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(srcdir)/../dixmods/extmod \
 	   -I$(srcdir)/../vbe -I$(top_srcdir)/miext/cw -I$(srcdir)/../int10 \
-	   -I$(srcdir)/../ddc -I$(srcdir)/../i2c -I$(srcdir)/../modes
+	   -I$(srcdir)/../ddc -I$(srcdir)/../i2c -I$(srcdir)/../modes \
+	   -I$(srcdir)/../ramdac
 
 #AM_LDFLAGS = -r
 AM_CFLAGS = -DIN_LOADER $(DIX_CFLAGS) $(XORG_CFLAGS)
diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index e489212..c220d8a 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -841,6 +841,7 @@ DuplicateModule(ModuleDescPtr mod, Modul
 static const char *compiled_in_modules[] = {
     "ddc",
     "i2c",
+    "ramdac",
     NULL
 };
 
@@ -861,7 +862,7 @@ doLoadModule(const char *module, const c
     PatternPtr patterns = NULL;
     int noncanonical = 0;
     char *m = NULL;
-    char **cim;
+    const char **cim;
 
     xf86MsgVerb(X_INFO, 3, "LoadModule: \"%s\"", module);
 
diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index 6337265..bc7c814 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -1220,6 +1220,11 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86RandR12SetConfig)
     SYMFUNC(xf86RandR12SetRotations)
 #endif
+    SYMFUNC(xf86_cursors_init)
+    SYMFUNC(xf86_reload_cursors)
+    SYMFUNC(xf86_show_cursors)
+    SYMFUNC(xf86_hide_cursors)
+    SYMFUNC(xf86_cursors_fini)
 
     SYMFUNC(xf86DoEDID_DDC1)
     SYMFUNC(xf86DoEDID_DDC2)
diff --git a/hw/xfree86/modes/Makefile.am b/hw/xfree86/modes/Makefile.am
index e0b6136..1f82068 100644
--- a/hw/xfree86/modes/Makefile.am
+++ b/hw/xfree86/modes/Makefile.am
@@ -3,6 +3,7 @@ noinst_LIBRARIES = libxf86modes.a
 libxf86modes_a_SOURCES = \
 	xf86Crtc.c \
 	xf86Crtc.h \
+	xf86Cursors.c \
 	xf86cvt.c \
 	xf86DiDGA.c \
 	xf86EdidModes.c \
@@ -16,7 +17,8 @@ libxf86modes_a_SOURCES = \
 INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \
 	   -I$(srcdir)/../loader -I$(srcdir)/../rac -I$(srcdir)/../parser \
            -I$(srcdir)/../scanpci -I$(srcdir)/../vbe -I$(srcdir)/../int10 \
-	   -I$(srcdir)/../vgahw -I$(srcdir)/../dixmods/extmod
+	   -I$(srcdir)/../vgahw -I$(srcdir)/../ramdac \
+	   -I$(srcdir)/../dixmods/extmod
 
 sdk_HEADERS = \
 	xf86Crtc.h \
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 6152ae4..df8a8aa 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -28,6 +28,7 @@
 #include "xf86Rename.h"
 #endif
 #include "xf86Modes.h"
+#include "xf86Cursor.h"
 #include "damage.h"
 
 /* Compat definitions for older X Servers. */
@@ -37,6 +38,9 @@
 #ifndef M_T_DRIVER
 #define M_T_DRIVER	0x40
 #endif
+#ifndef HARDWARE_CURSOR_ARGB
+#define HARDWARE_CURSOR_ARGB				0x00004000
+#endif
 
 typedef struct _xf86Crtc xf86CrtcRec, *xf86CrtcPtr;
 typedef struct _xf86Output xf86OutputRec, *xf86OutputPtr;
@@ -155,6 +159,42 @@ typedef struct _xf86CrtcFuncs {
     (*shadow_destroy) (xf86CrtcPtr crtc, PixmapPtr pPixmap, void *data);
 
     /**
+     * Set cursor colors
+     */
+    void
+    (*set_cursor_colors) (xf86CrtcPtr crtc, int bg, int fg);
+
+    /**
+     * Set cursor position
+     */
+    void
+    (*set_cursor_position) (xf86CrtcPtr crtc, int x, int y);
+
+    /**
+     * Show cursor
+     */
+    void
+    (*show_cursor) (xf86CrtcPtr crtc);
+
+    /**
+     * Hide cursor
+     */
+    void
+    (*hide_cursor) (xf86CrtcPtr crtc);
+
+    /**
+     * Load monochrome image
+     */
+    void
+    (*load_cursor_image) (xf86CrtcPtr crtc, CARD8 *image);
+
+    /**
+     * Load ARGB image
+     */
+     void
+     (*load_cursor_argb) (xf86CrtcPtr crtc, CARD32 *image);
+     
+    /**
      * Clean up driver-specific bits of the crtc
      */
     void
@@ -174,12 +214,6 @@ struct _xf86Crtc {
      */
     Bool	    enabled;
     
-    /** Track whether cursor is within CRTC range  */
-    Bool	    cursorInRange;
-    
-    /** Track state of cursor associated with this CRTC */
-    Bool	    cursorShown;
-    
     /**
      * Active mode
      *
@@ -232,6 +266,19 @@ struct _xf86Crtc {
 #else
     void	    *randr_crtc;
 #endif
+
+    /**
+     * Current cursor is ARGB
+     */
+    Bool	    cursor_argb;
+    /**
+     * Track whether cursor is within CRTC range 
+     */
+    Bool	    cursor_in_range;
+    /**
+     * Track state of cursor associated with this CRTC
+     */
+    Bool	    cursor_shown;
 };
 
 typedef struct _xf86OutputFuncs {
@@ -495,6 +542,13 @@ typedef struct _xf86CrtcConfig {
     const xf86CrtcConfigFuncsRec *funcs;
 
     CreateScreenResourcesProcPtr    CreateScreenResources;
+
+    /* Cursor information */
+    xf86CursorInfoPtr	cursor_info;
+    CursorPtr		cursor;
+    CARD8		*cursor_image;
+    Bool		cursor_on;
+    CARD32		cursor_fg, cursor_bg;
 } xf86CrtcConfigRec, *xf86CrtcConfigPtr;
 
 extern int xf86CrtcConfigPrivateIndex;
@@ -637,4 +691,41 @@ xf86ConnectorGetName(xf86ConnectorType c
 Bool
 xf86SetDesiredModes (ScrnInfoPtr pScrn);
 
+/**
+ * Initialize the CRTC-based cursor code. CRTC function vectors must
+ * contain relevant cursor setting functions.
+ *
+ * Driver should call this from ScreenInit function
+ */
+Bool
+xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags);
+
+/**
+ * Called when anything on the screen is reconfigured.
+ *
+ * Reloads cursor images as needed, then adjusts cursor positions.
+ * 
+ * Driver should call this from crtc commit function.
+ */
+void
+xf86_reload_cursors (ScreenPtr screen);
+
+/**
+ * Called from EnterVT to turn the cursors back on
+ */
+void
+xf86_show_cursors (ScrnInfoPtr scrn);
+
+/**
+ * Called by the driver to turn cursors off
+ */
+void
+xf86_hide_cursors (ScrnInfoPtr scrn);
+
+/**
+ * Clean up CRTC-based cursor code. Driver must call this at CloseScreen time.
+ */
+void
+xf86_cursors_fini (ScreenPtr screen);
+    
 #endif /* _XF86CRTC_H_ */
diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
new file mode 100644
index 0000000..095df48
--- /dev/null
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -0,0 +1,595 @@
+/*
+ * Copyright © 2007 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#else
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#endif
+
+#include <stddef.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "xf86.h"
+#include "xf86DDC.h"
+#include "xf86Crtc.h"
+#include "xf86Modes.h"
+#include "xf86RandR12.h"
+#include "X11/extensions/render.h"
+#define DPMS_SERVER
+#include "X11/extensions/dpms.h"
+#include "X11/Xatom.h"
+#ifdef RENDER
+#include "picturestr.h"
+#endif
+#include "cursorstr.h"
+
+/*
+ * Given a screen coordinate, rotate back to a cursor source coordinate
+ */
+static void
+xf86_crtc_rotate_coord (Rotation    rotation,
+			int	    width,
+			int	    height,
+			int	    x_dst,
+			int	    y_dst,
+			int	    *x_src,
+			int	    *y_src)
+{
+    if (rotation & RR_Reflect_X)
+	x_dst = width - x_dst - 1;
+    if (rotation & RR_Reflect_Y)
+	y_dst = height - y_dst - 1;
+    
+    switch (rotation & 0xf) {
+    case RR_Rotate_0:
+	*x_src = x_dst;
+	*y_src = y_dst;
+	break;
+    case RR_Rotate_90:
+	*x_src = height - y_dst - 1;
+	*y_src = x_dst;
+	break;
+    case RR_Rotate_180:
+	*x_src = width - x_dst - 1;
+	*y_src = height - y_dst - 1;
+	break;
+    case RR_Rotate_270:
+	*x_src = y_dst;
+	*y_src = width - x_dst - 1;
+	break;
+    }
+}
+
+/*
+ * Convert an x coordinate to a position within the cursor bitmap
+ */
+static int
+cursor_bitpos (int flags, int x, Bool mask)
+{
+    if (flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK)
+	mask = !mask;
+    if (flags & HARDWARE_CURSOR_NIBBLE_SWAPPED)
+	x = (x & ~3) | (3 - (x & 3));
+    if (flags & HARDWARE_CURSOR_BIT_ORDER_MSBFIRST)
+	x = (x & ~7) | (7 - (x & 7));
+    if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1)
+	x = (x << 1) + mask;
+    else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8)
+	x = ((x & ~7) << 1) | (mask << 3) | (x & 7);
+    else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16)
+	x = ((x & ~15) << 1) | (mask << 4) | (x & 15);
+    else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32)
+	x = ((x & ~31) << 1) | (mask << 5) | (x & 31);
+    else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64)
+	x = ((x & ~63) << 1) | (mask << 6) | (x & 63);
+    return x;
+}
+
+/*
+ * Fetch one bit from a cursor bitmap
+ */
+static CARD8
+get_bit (CARD8 *image, int stride, int flags, int x, int y, Bool mask)
+{
+    x = cursor_bitpos (flags, x, mask);
+    image += y * stride;
+    return (image[(x >> 3)] >> (x & 7)) & 1;
+}
+
+/*
+ * Set one bit in a cursor bitmap
+ */
+static void
+set_bit (CARD8 *image, int stride, int flags, int x, int y, Bool mask)
+{
+    x = cursor_bitpos (flags, x, mask);
+    image += y * stride;
+    image[(x >> 3)] |= 1 << (x & 7);
+}
+    
+/*
+ * Load a two color cursor into a driver that supports only ARGB cursors
+ */
+static void
+xf86_crtc_convert_cursor_to_argb (xf86CrtcPtr crtc, unsigned char *src)
+{
+    ScrnInfoPtr		scrn = crtc->scrn;
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    xf86CursorInfoPtr	cursor_info = xf86_config->cursor_info;
+    CARD32		*cursor_image = (CARD32 *) xf86_config->cursor_image;
+    int			x, y;
+    int			xin, yin;
+    int			stride = cursor_info->MaxWidth >> 2;
+    int			flags = cursor_info->Flags;
+    CARD32		bits;
+
+#ifdef ARGB_CURSOR
+    crtc->cursor_argb = FALSE;
+#endif
+
+    for (y = 0; y < cursor_info->MaxHeight; y++)
+	for (x = 0; x < cursor_info->MaxWidth; x++) 
+	{
+	    xf86_crtc_rotate_coord (crtc->rotation,
+				    cursor_info->MaxWidth,
+				    cursor_info->MaxHeight,
+				    x, y, &xin, &yin);
+	    if (get_bit (src, stride, flags, xin, yin, TRUE) ==
+		((flags & HARDWARE_CURSOR_INVERT_MASK) == 0))
+	    {
+		if (get_bit (src, stride, flags, xin, yin, FALSE))
+		    bits = xf86_config->cursor_fg;
+		else
+		    bits = xf86_config->cursor_bg;
+	    }
+	    else
+		bits = 0;
+	    cursor_image[y * cursor_info->MaxWidth + x] = bits;
+	}
+    crtc->funcs->load_cursor_argb (crtc, cursor_image);
+}
+
+/*
+ * Set the colors for a two-color cursor (ignore for ARGB cursors)
+ */
+static void
+xf86_set_cursor_colors (ScrnInfoPtr scrn, int bg, int fg)
+{
+    ScreenPtr		screen = scrn->pScreen;
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    CursorPtr		cursor = xf86_config->cursor;
+    int			c;
+    CARD8		*bits = cursor ? cursor->devPriv[screen->myNum] : NULL;
+
+    /* Save ARGB versions of these colors */
+    xf86_config->cursor_fg = (CARD32) fg | 0xff000000;
+    xf86_config->cursor_bg = (CARD32) bg | 0xff000000;
+    
+    for (c = 0; c < xf86_config->num_crtc; c++)
+    {
+	xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+	if (crtc->enabled && !crtc->cursor_argb)
+	{
+	    if (crtc->funcs->load_cursor_image)
+		crtc->funcs->set_cursor_colors (crtc, bg, fg);
+	    else if (bits)
+		xf86_crtc_convert_cursor_to_argb (crtc, bits);
+	}
+    }
+}
+
+static void
+xf86_crtc_hide_cursor (xf86CrtcPtr crtc)
+{
+    if (crtc->cursor_shown)
+    {
+	crtc->funcs->hide_cursor (crtc);
+	crtc->cursor_shown = FALSE;
+    }
+}
+
+void
+xf86_hide_cursors (ScrnInfoPtr scrn)
+{
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    int			c;
+
+    xf86_config->cursor_on = FALSE;
+    for (c = 0; c < xf86_config->num_crtc; c++)
+    {
+	xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+	if (crtc->enabled)
+	    xf86_crtc_hide_cursor (crtc);
+    }
+}
+    
+static void
+xf86_crtc_show_cursor (xf86CrtcPtr crtc)
+{
+    if (!crtc->cursor_shown && crtc->cursor_in_range)
+    {
+	crtc->funcs->show_cursor (crtc);
+	crtc->cursor_shown = TRUE;
+    }
+}
+
+void
+xf86_show_cursors (ScrnInfoPtr scrn)
+{
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    int			c;
+
+    xf86_config->cursor_on = TRUE;
+    for (c = 0; c < xf86_config->num_crtc; c++)
+    {
+	xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+	if (crtc->enabled)
+	    xf86_crtc_show_cursor (crtc);
+    }
+}
+    
+static void
+xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
+{
+    ScrnInfoPtr		scrn = crtc->scrn;
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    xf86CursorInfoPtr	cursor_info = xf86_config->cursor_info;
+    DisplayModePtr	mode = &crtc->mode;
+    int			x_temp;
+    int			y_temp;
+    Bool		in_range;
+
+    /* 
+     * Move to crtc coordinate space
+     */
+    x -= crtc->x;
+    y -= crtc->y;
+    
+    /*
+     * Rotate
+     */
+    switch ((crtc->rotation) & 0xf) {
+    case RR_Rotate_0:
+	break;
+    case RR_Rotate_90:
+	x_temp = y;
+	y_temp = mode->VDisplay - cursor_info->MaxWidth - x;
+	x = x_temp;
+	y = y_temp;
+	break;
+    case RR_Rotate_180:
+	x_temp = mode->HDisplay - cursor_info->MaxWidth - x;
+	y_temp = mode->VDisplay - cursor_info->MaxHeight - y;
+	x = x_temp;
+	y = y_temp;
+	break;
+    case RR_Rotate_270:
+	x_temp = mode->HDisplay - cursor_info->MaxHeight -  y;
+	y_temp = x;
+	x = x_temp;
+	y = y_temp;
+	break;
+    }
+    
+    /*
+     * Reflect
+     */
+    if (crtc->rotation & RR_Reflect_X)
+	x = mode->HDisplay - cursor_info->MaxWidth - x;
+    if (crtc->rotation & RR_Reflect_Y)
+	y = mode->VDisplay - cursor_info->MaxHeight - y;
+
+    /*
+     * Disable the cursor when it is outside the viewport
+     */
+    in_range = TRUE;
+    if (x >= mode->HDisplay || y >= mode->VDisplay ||
+	x <= -cursor_info->MaxWidth || y <= -cursor_info->MaxHeight) 
+    {
+	in_range = FALSE;
+	x = 0;
+	y = 0;
+    }
+
+    crtc->cursor_in_range = in_range;
+    
+    if (in_range)
+    {
+	crtc->funcs->set_cursor_position (crtc, x, y);
+	xf86_crtc_show_cursor (crtc);
+    }
+    else
+	xf86_crtc_hide_cursor (crtc);
+}
+
+static void
+xf86_set_cursor_position (ScrnInfoPtr scrn, int x, int y)
+{
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    int			c;
+
+    /* undo what xf86HWCurs did to the coordinates */
+    x += scrn->frameX0;
+    y += scrn->frameY0;
+    for (c = 0; c < xf86_config->num_crtc; c++)
+    {
+	xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+	if (crtc->enabled)
+	    xf86_crtc_set_cursor_position (crtc, x, y);
+    }
+}
+    
+/*
+ * Load a two-color cursor into a crtc, performing rotation as needed
+ */
+static void
+xf86_crtc_load_cursor_image (xf86CrtcPtr crtc, CARD8 *src)
+{
+    ScrnInfoPtr		scrn = crtc->scrn;
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    xf86CursorInfoPtr	cursor_info = xf86_config->cursor_info;
+    CARD8		*cursor_image;
+
+#ifdef ARGB_CURSOR
+    crtc->cursor_argb = FALSE;
+#endif
+
+    if (crtc->rotation == RR_Rotate_0)
+	cursor_image = src;
+    else
+    {
+        int x, y;
+    	int xin, yin;
+	int stride = cursor_info->MaxWidth >> 2;
+	int flags = cursor_info->Flags;
+	
+	cursor_image = xf86_config->cursor_image;
+	memset(cursor_image, 0, cursor_info->MaxWidth * stride);
+	
+        for (y = 0; y < cursor_info->MaxHeight; y++)
+	    for (x = 0; x < cursor_info->MaxWidth; x++) 
+	    {
+		xf86_crtc_rotate_coord (crtc->rotation,
+					cursor_info->MaxWidth,
+					cursor_info->MaxHeight,
+					x, y, &xin, &yin);
+		if (get_bit(src, stride, flags, xin, yin, FALSE))
+		    set_bit(cursor_image, stride, flags, x, y, FALSE);
+		if (get_bit(src, stride, flags, xin, yin, TRUE))
+		    set_bit(cursor_image, stride, flags, x, y, TRUE);
+	    }
+    }
+    crtc->funcs->load_cursor_image (crtc, cursor_image);
+}
+    
+/*
+ * Load a cursor image into all active CRTCs
+ */
+static void
+xf86_load_cursor_image (ScrnInfoPtr scrn, unsigned char *src)
+{
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    int			c;
+
+    for (c = 0; c < xf86_config->num_crtc; c++)
+    {
+	xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+	if (crtc->enabled)
+	{
+	    if (crtc->funcs->load_cursor_image)
+		xf86_crtc_load_cursor_image (crtc, src);
+	    else if (crtc->funcs->load_cursor_argb)
+		xf86_crtc_convert_cursor_to_argb (crtc, src);
+	}
+    }
+}
+
+static Bool
+xf86_use_hw_cursor (ScreenPtr screen, CursorPtr cursor)
+{
+    ScrnInfoPtr		scrn = xf86Screens[screen->myNum];
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    xf86CursorInfoPtr	cursor_info = xf86_config->cursor_info;
+
+    xf86_config->cursor = cursor;
+    
+    if (cursor->bits->width > cursor_info->MaxWidth ||
+	cursor->bits->height> cursor_info->MaxHeight)
+	return FALSE;
+
+    return TRUE;
+}
+
+static Bool
+xf86_use_hw_cursor_argb (ScreenPtr screen, CursorPtr cursor)
+{
+    ScrnInfoPtr		scrn = xf86Screens[screen->myNum];
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    xf86CursorInfoPtr	cursor_info = xf86_config->cursor_info;
+    
+    xf86_config->cursor = cursor;
+    
+    /* Make sure ARGB support is available */
+    if ((cursor_info->Flags & HARDWARE_CURSOR_ARGB) == 0)
+	return FALSE;
+    
+    if (cursor->bits->width > cursor_info->MaxWidth ||
+	cursor->bits->height> cursor_info->MaxHeight)
+	return FALSE;
+
+    return TRUE;
+}
+
+static void
+xf86_crtc_load_cursor_argb (xf86CrtcPtr crtc, CursorPtr cursor)
+{
+    ScrnInfoPtr		scrn = crtc->scrn;
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    xf86CursorInfoPtr	cursor_info = xf86_config->cursor_info;
+    CARD32		*cursor_image = (CARD32 *) xf86_config->cursor_image;
+    CARD32		*cursor_source = (CARD32 *) cursor->bits->argb;
+    int			x, y;
+    int			xin, yin;
+    CARD32		bits;
+    int			source_width = cursor->bits->width;
+    int			source_height = cursor->bits->height;
+    int			image_width = cursor_info->MaxWidth;
+    int			image_height = cursor_info->MaxHeight;
+    
+    for (y = 0; y < image_height; y++)
+	for (x = 0; x < image_width; x++)
+	{
+	    xf86_crtc_rotate_coord (crtc->rotation, image_width, image_height,
+				    x, y, &xin, &yin);
+	    if (xin < source_width && yin < source_height)
+		bits = cursor_source[yin * source_width + xin];
+	    else
+		bits = 0;
+	    cursor_image[y * image_width + x] = bits;
+	}
+    
+    crtc->funcs->load_cursor_argb (crtc, cursor_image);
+}
+
+static void
+xf86_load_cursor_argb (ScrnInfoPtr scrn, CursorPtr cursor)
+{
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    int			c;
+
+    for (c = 0; c < xf86_config->num_crtc; c++)
+    {
+	xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+	if (crtc->enabled)
+	    xf86_crtc_load_cursor_argb (crtc, cursor);
+    }
+}
+
+Bool
+xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags)
+{
+    ScrnInfoPtr		scrn = xf86Screens[screen->myNum];
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    xf86CursorInfoPtr	cursor_info;
+
+    cursor_info = xf86CreateCursorInfoRec();
+    if (!cursor_info)
+	return FALSE;
+
+    xf86_config->cursor_image = xalloc (max_width * max_height * 4);
+
+    if (!xf86_config->cursor_image)
+    {
+	xf86DestroyCursorInfoRec (cursor_info);
+	return FALSE;
+    }
+	
+    xf86_config->cursor_info = cursor_info;
+
+    cursor_info->MaxWidth = max_width;
+    cursor_info->MaxHeight = max_height;
+    cursor_info->Flags = flags;
+
+    cursor_info->SetCursorColors = xf86_set_cursor_colors;
+    cursor_info->SetCursorPosition = xf86_set_cursor_position;
+    cursor_info->LoadCursorImage = xf86_load_cursor_image;
+    cursor_info->HideCursor = xf86_hide_cursors;
+    cursor_info->ShowCursor = xf86_show_cursors;
+    cursor_info->UseHWCursor = xf86_use_hw_cursor;
+#ifdef ARGB_CURSOR
+    if (flags & HARDWARE_CURSOR_ARGB)
+    {
+	cursor_info->UseHWCursorARGB = xf86_use_hw_cursor_argb;
+	cursor_info->LoadCursorARGB = xf86_load_cursor_argb;
+    }
+#endif
+    
+    xf86_config->cursor = NULL;
+    xf86_hide_cursors (scrn);
+    
+    return xf86InitCursor (screen, cursor_info);
+}
+
+/**
+ * Called when anything on the screen is reconfigured.
+ *
+ * Reloads cursor images as needed, then adjusts cursor positions
+ */
+
+void
+xf86_reload_cursors (ScreenPtr screen)
+{
+    ScrnInfoPtr		scrn = xf86Screens[screen->myNum];
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    xf86CursorInfoPtr	cursor_info = xf86_config->cursor_info;
+    CursorPtr		cursor = xf86_config->cursor;
+    int			x, y;
+    
+    GetSpritePosition (&x, &y);
+    if (!(cursor_info->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
+	(*cursor_info->HideCursor)(scrn);
+
+    if (cursor)
+    {
+#ifdef ARGB_CURSOR
+	if (cursor->bits->argb && cursor_info->LoadCursorARGB)
+	    (*cursor_info->LoadCursorARGB) (scrn, cursor);
+	else
+#endif
+	    (*cursor_info->LoadCursorImage)(cursor_info->pScrn,
+					    cursor->devPriv[screen->myNum]);
+
+	(*cursor_info->SetCursorPosition)(cursor_info->pScrn, x, y);
+	(*cursor_info->ShowCursor)(cursor_info->pScrn);
+    }
+}
+
+/**
+ * Clean up CRTC-based cursor code
+ */
+void
+xf86_cursors_fini (ScreenPtr screen)
+{
+    ScrnInfoPtr		scrn = xf86Screens[screen->myNum];
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    
+    if (xf86_config->cursor_info)
+    {
+	xf86DestroyCursorInfoRec (xf86_config->cursor_info);
+	xf86_config->cursor_info = NULL;
+    }
+    if (xf86_config->cursor_image)
+    {
+	xfree (xf86_config->cursor_image);
+	xf86_config->cursor_image = NULL;
+    }
+}
diff --git a/hw/xfree86/ramdac/Makefile.am b/hw/xfree86/ramdac/Makefile.am
index 8d94445..2b84cb4 100644
--- a/hw/xfree86/ramdac/Makefile.am
+++ b/hw/xfree86/ramdac/Makefile.am
@@ -1,8 +1,6 @@
-module_LTLIBRARIES = libramdac.la
+noinst_LIBRARIES = libramdac.a
 
-libramdac_la_LDFLAGS = -avoid-version
-
-libramdac_la_SOURCES = xf86RamDacMod.c xf86RamDac.c xf86RamDacCmap.c \
+libramdac_a_SOURCES = xf86RamDac.c xf86RamDacCmap.c \
                       xf86Cursor.c xf86HWCurs.c IBM.c BT.c TI.c \
 		      xf86BitOrder.c
 
diff --git a/hw/xfree86/ramdac/xf86Cursor.h b/hw/xfree86/ramdac/xf86Cursor.h
index 08cca6b..469f48f 100644
--- a/hw/xfree86/ramdac/xf86Cursor.h
+++ b/hw/xfree86/ramdac/xf86Cursor.h
@@ -44,5 +44,8 @@ void xf86ForceHWCursor (ScreenPtr pScree
 #define HARDWARE_CURSOR_NIBBLE_SWAPPED			0x00000800
 #define HARDWARE_CURSOR_SHOW_TRANSPARENT		0x00001000
 #define HARDWARE_CURSOR_UPDATE_UNHIDDEN			0x00002000
+#ifdef ARGB_CURSOR
+#define HARDWARE_CURSOR_ARGB				0x00004000
+#endif
 
 #endif /* _XF86CURSOR_H */
diff-tree 4bf1b280f7cb676ec2b172f26dd2ad9bac2eb2ca (from c366b82bd50066019cf82b3464445d5bc27d6f9f)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Fri Mar 9 14:18:14 2007 +0000

    Set pScreen on context

diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c
index e035704..5e683a8 100644
--- a/GL/glx/glxdri.c
+++ b/GL/glx/glxdri.c
@@ -495,6 +495,7 @@ __glXDRIscreenCreateContext(__GLXscreen 
     context->base.loseCurrent       = __glXDRIcontextLoseCurrent;
     context->base.copy              = __glXDRIcontextCopy;
     context->base.forceCurrent      = __glXDRIcontextForceCurrent;
+    context->base.pScreen           = screen->base.pScreen;
 
     context->base.textureFromPixmap = &__glXDRItextureFromPixmap;
 
diff-tree c366b82bd50066019cf82b3464445d5bc27d6f9f (from 405483496538f1c82cbd7fe1e76c5d94e1a90525)
Author: Jay Estabrook <Jay.Estabrook at hp.com>
Date:   Fri Mar 9 12:26:55 2007 +0000

    Ensure domain is stripped from the bus ID.

diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index c183e2a..7bd07c0 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -71,6 +71,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 #include "mipointer.h"
 #include "xf86_OSproc.h"
 
+#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
+
 #if !defined(PANORAMIX)
 extern Bool noPanoramiXExtension;
 #endif
@@ -2202,8 +2204,8 @@ DRICreatePCIBusID(pciVideoPtr PciInfo)
 
     tag = pciTag(PciInfo->bus, PciInfo->device, PciInfo->func);
     domain = xf86GetPciDomain(tag);
-    snprintf(busID, 20, "pci:%04x:%02x:%02x.%d", domain, PciInfo->bus,
-	PciInfo->device, PciInfo->func);
+    snprintf(busID, 20, "pci:%04x:%02x:%02x.%d", domain,
+	PCI_BUS_NO_DOMAIN(PciInfo->bus), PciInfo->device, PciInfo->func);
     return busID;
 }
 



More information about the xorg-commit mailing list