[PATCH] Define server-supported protocol versions in one single file.

Peter Hutterer peter.hutterer at who-t.net
Sun Sep 20 05:22:55 PDT 2009


include/protocol-versions.h specifies each extension version as supported by
the server and sent back on the wire to the client.

This fixes up several issues with the server potentially reporting a higher
version of the protocol if recompiled against a newer version of the
protocol.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 Xext/geext.c                          |    9 +--
 Xext/panoramiX.c                      |    4 +-
 Xext/saver.c                          |    5 +-
 Xext/security.c                       |    4 +-
 Xext/shape.c                          |    5 +-
 Xext/shm.c                            |    5 +-
 Xext/xcalibrate.c                     |    5 +-
 Xext/xf86bigfont.c                    |    5 +-
 Xext/xres.c                           |    5 +-
 Xext/xvmc.c                           |    5 +-
 Xi/extinit.c                          |   10 +-
 composite/compext.c                   |   10 +--
 damageext/damageext.c                 |   18 ++---
 glx/glxcmds.c                         |    5 +-
 glx/glxserver.h                       |    4 -
 hw/dmx/dmx.c                          |    7 +-
 hw/kdrive/ephyr/ephyrdriext.c         |    8 +-
 hw/xfree86/dixmods/extmod/xf86dga2.c  |    5 +-
 hw/xfree86/dixmods/extmod/xf86vmode.c |    5 +-
 hw/xfree86/dri/xf86dri.c              |    7 +-
 hw/xfree86/dri2/dri2ext.c             |    5 +-
 hw/xquartz/applewm.c                  |    7 +-
 hw/xquartz/xpr/appledri.c             |    7 +-
 hw/xwin/winwindowswm.c                |    7 +-
 include/Makefile.am                   |    3 +-
 include/protocol-versions.h           |  148 +++++++++++++++++++++++++++++++++
 randr/rrdispatch.c                    |    8 +-
 randr/rrxinerama.c                    |    8 +-
 record/record.c                       |    6 +-
 render/render.c                       |    5 +-
 xfixes/xfixes.c                       |   14 ++--
 xkb/xkb.c                             |   11 ++-
 32 files changed, 253 insertions(+), 107 deletions(-)
 create mode 100644 include/protocol-versions.h

diff --git a/Xext/geext.c b/Xext/geext.c
index 1ddcbb1..6fad4ae 100644
--- a/Xext/geext.c
+++ b/Xext/geext.c
@@ -32,10 +32,7 @@
 
 #include "geint.h"
 #include "geext.h"
-
-/* Currently supported XGE version */
-#define SERVER_GE_MAJOR 1
-#define SERVER_GE_MINOR 0
+#include "protocol-versions.h"
 
 #define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
 
@@ -81,8 +78,8 @@ ProcGEQueryVersion(ClientPtr client)
     rep.sequenceNumber = client->sequence;
 
     /* return the supported version by the server */
-    rep.majorVersion = SERVER_GE_MAJOR;
-    rep.minorVersion = SERVER_GE_MINOR;
+    rep.majorVersion = SERVER_GE_MAJOR_VERSION;
+    rep.minorVersion = SERVER_GE_MINOR_VERSION;
 
     /* Remember version the client requested */
     pGEClient->major_version = stuff->majorVersion;
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index c5fb700..4b7b07e 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -56,9 +56,7 @@ Equipment Corporation.
 #include "picturestr.h"
 #endif
 #include "modinit.h"
-
-#define SERVER_PANORAMIX_MAJOR_VERSION	1
-#define SERVER_PANORAMIX_MINOR_VERSION	1
+#include "protocol-versions.h"
 
 #ifdef GLXPROXY
 extern VisualPtr glxMatchVisual(ScreenPtr pScreen,
diff --git a/Xext/saver.c b/Xext/saver.c
index 18de4b5..04e6497 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -54,6 +54,7 @@ in this Software without prior written authorization from the X Consortium.
 #ifdef DPMSExtension
 #include <X11/extensions/dpmsconst.h>
 #endif
+#include "protocol-versions.h"
 
 #include <stdio.h>
 
@@ -727,8 +728,8 @@ ProcScreenSaverQueryVersion (ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.majorVersion = ScreenSaverMajorVersion;
-    rep.minorVersion = ScreenSaverMinorVersion;
+    rep.majorVersion = SERVER_SAVER_MAJOR_VERSION;
+    rep.minorVersion = SERVER_SAVER_MINOR_VERSION;
     if (client->swapped) {
     	swaps(&rep.sequenceNumber, n);
     	swapl(&rep.length, n);
diff --git a/Xext/security.c b/Xext/security.c
index 42eb9f0..b43e419 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -371,8 +371,8 @@ ProcSecurityQueryVersion(
     rep.type        	= X_Reply;
     rep.sequenceNumber 	= client->sequence;
     rep.length         	= 0;
-    rep.majorVersion  	= SECURITY_MAJOR_VERSION;
-    rep.minorVersion  	= SECURITY_MINOR_VERSION;
+    rep.majorVersion  	= SERVER_SECURITY_MAJOR_VERSION;
+    rep.minorVersion  	= SERVER_SECURITY_MINOR_VERSION;
     if(client->swapped)
     {
 	char n;
diff --git a/Xext/shape.c b/Xext/shape.c
index 53167d1..700fe76 100644
--- a/Xext/shape.c
+++ b/Xext/shape.c
@@ -45,6 +45,7 @@ in this Software without prior written authorization from The Open Group.
 #include "regionstr.h"
 #include "gcstruct.h"
 #include "modinit.h"
+#include "protocol-versions.h"
 
 typedef	RegionPtr (*CreateDftPtr)(
 	WindowPtr /* pWin */
@@ -259,8 +260,8 @@ ProcShapeQueryVersion (ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.majorVersion = SHAPE_MAJOR_VERSION;
-    rep.minorVersion = SHAPE_MINOR_VERSION;
+    rep.majorVersion = SERVER_SHAPE_MAJOR_VERSION;
+    rep.minorVersion = SERVER_SHAPE_MINOR_VERSION;
     if (client->swapped) {
     	swaps(&rep.sequenceNumber, n);
     	swapl(&rep.length, n);
diff --git a/Xext/shm.c b/Xext/shm.c
index dd097e6..e4f08e2 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -54,6 +54,7 @@ in this Software without prior written authorization from The Open Group.
 #include "xace.h"
 #include <X11/extensions/shmproto.h>
 #include <X11/Xfuncproto.h>
+#include "protocol-versions.h"
 
 /* Needed for Solaris cross-zone shared memory extension */
 #ifdef HAVE_SHMCTL64
@@ -313,8 +314,8 @@ ProcShmQueryVersion(ClientPtr client)
     rep.sequenceNumber = client->sequence;
     rep.sharedPixmaps = sharedPixmaps;
     rep.pixmapFormat = sharedPixmaps ? ZPixmap : 0;
-    rep.majorVersion = SHM_MAJOR_VERSION;
-    rep.minorVersion = SHM_MINOR_VERSION;
+    rep.majorVersion = SERVER_SHM_MAJOR_VERSION;
+    rep.minorVersion = SERVER_SHM_MINOR_VERSION;
     rep.uid = geteuid();
     rep.gid = getegid();
     if (client->swapped) {
diff --git a/Xext/xcalibrate.c b/Xext/xcalibrate.c
index f923c17..6e6461a 100644
--- a/Xext/xcalibrate.c
+++ b/Xext/xcalibrate.c
@@ -32,6 +32,7 @@
 #include "dixstruct.h"
 #include "extnsionst.h"
 #include "swaprep.h"
+#include "protocol-versions.h"
 
 #include <X11/extensions/xcalibrateproto.h>
 #include <X11/extensions/xcalibratewire.h>
@@ -79,8 +80,8 @@ ProcXCalibrateQueryVersion (ClientPtr client)
   rep.type = X_Reply;
   rep.length = 0;
   rep.sequenceNumber = client->sequence;
-  rep.majorVersion = XCALIBRATE_MAJOR_VERSION;
-  rep.minorVersion = XCALIBRATE_MINOR_VERSION;   
+  rep.majorVersion = SERVER_XCALIBRATE_MAJOR_VERSION;
+  rep.minorVersion = SERVER_XCALIBRATE_MINOR_VERSION;
   if (client->swapped) { 
     int n;
     swaps(&rep.sequenceNumber, n);
diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c
index aeea233..ba8b603 100644
--- a/Xext/xf86bigfont.c
+++ b/Xext/xf86bigfont.c
@@ -71,6 +71,7 @@
 #include "gcstruct.h"
 #include "dixfontstr.h"
 #include "extnsionst.h"
+#include "protocol-versions.h"
 
 #include <X11/extensions/xf86bigfproto.h>
 
@@ -338,8 +339,8 @@ ProcXF86BigfontQueryVersion(
     reply.type = X_Reply;
     reply.length = 0;
     reply.sequenceNumber = client->sequence;
-    reply.majorVersion = XF86BIGFONT_MAJOR_VERSION;
-    reply.minorVersion = XF86BIGFONT_MINOR_VERSION;
+    reply.majorVersion = SERVER_XF86BIGFONT_MAJOR_VERSION;
+    reply.minorVersion = SERVER_XF86BIGFONT_MINOR_VERSION;
     reply.uid = geteuid();
     reply.gid = getegid();
 #ifdef HAS_SHM
diff --git a/Xext/xres.c b/Xext/xres.c
index 9dd08b1..109aa63 100644
--- a/Xext/xres.c
+++ b/Xext/xres.c
@@ -21,6 +21,7 @@
 #include "windowstr.h"
 #include "gcstruct.h"
 #include "modinit.h"
+#include "protocol-versions.h"
 
 static int
 ProcXResQueryVersion (ClientPtr client)
@@ -39,8 +40,8 @@ ProcXResQueryVersion (ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.server_major = XRES_MAJOR_VERSION;
-    rep.server_minor = XRES_MINOR_VERSION;   
+    rep.server_major = SERVER_XRES_MAJOR_VERSION;
+    rep.server_minor = SERVER_XRES_MINOR_VERSION;
     if (client->swapped) { 
         int n;
         swaps(&rep.sequenceNumber, n);
diff --git a/Xext/xvmc.c b/Xext/xvmc.c
index b7bb0fc..c17a4b1 100644
--- a/Xext/xvmc.c
+++ b/Xext/xvmc.c
@@ -20,6 +20,7 @@
 #include <X11/extensions/Xvproto.h>
 #include <X11/extensions/XvMCproto.h>
 #include "xvmcext.h"
+#include "protocol-versions.h"
 
 #ifdef HAS_XVMCSHM
 #include <sys/ipc.h>
@@ -116,8 +117,8 @@ ProcXvMCQueryVersion(ClientPtr client)
     rep.type = X_Reply;
     rep.sequenceNumber = client->sequence;
     rep.length = 0;
-    rep.major = XvMCVersion;
-    rep.minor = XvMCRevision;
+    rep.major = SERVER_XVMC_MAJOR_VERSION;
+    rep.minor = SERVER_XVMC_MINOR_VERSION;
     WriteToClient(client, sizeof(xvmcQueryVersionReply), (char*)&rep);
     return Success;
 }
diff --git a/Xi/extinit.c b/Xi/extinit.c
index 84b999c..0c12919 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -72,6 +72,7 @@ SOFTWARE.
 #include "swaprep.h"
 #include "registry.h"
 #include "privates.h"
+#include "protocol-versions.h"
 
 /* modules local to Xi */
 #include "allowev.h"
@@ -380,11 +381,6 @@ Mask PropagateMask[MAXDEVICES];
 static int XIClientPrivateKeyIndex;
 DevPrivateKey XIClientPrivateKey = &XIClientPrivateKeyIndex;
 
-static XExtensionVersion thisversion = { XI_Present,
-    XI_2_Major,
-    XI_2_Minor
-};
-
 
 /*****************************************************************
  *
@@ -1255,6 +1251,10 @@ void
 XInputExtensionInit(void)
 {
     ExtensionEntry *extEntry;
+    XExtensionVersion thisversion = { XI_Present,
+        SERVER_XI_MAJOR_VERSION,
+        SERVER_XI_MINOR_VERSION,
+    };
 
     if (!dixRequestPrivate(XIClientPrivateKey, sizeof(XIClientRec)))
         FatalError("Cannot request private for XI.\n");
diff --git a/composite/compext.c b/composite/compext.c
index 56b4f27..976d002 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -53,9 +53,7 @@
 
 #include "compint.h"
 #include "xace.h"
-
-#define SERVER_COMPOSITE_MAJOR	0
-#define SERVER_COMPOSITE_MINOR	4
+#include "protocol-versions.h"
 
 static CARD8	CompositeReqCode;
 static int CompositeClientPrivateKeyIndex;
@@ -124,12 +122,12 @@ ProcCompositeQueryVersion (ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    if (stuff->majorVersion < SERVER_COMPOSITE_MAJOR) {
+    if (stuff->majorVersion < SERVER_COMPOSITE_MAJOR_VERSION) {
 	rep.majorVersion = stuff->majorVersion;
 	rep.minorVersion = stuff->minorVersion;
     } else {
-	rep.majorVersion = SERVER_COMPOSITE_MAJOR;
-        rep.minorVersion = SERVER_COMPOSITE_MINOR;
+	rep.majorVersion = SERVER_COMPOSITE_MAJOR_VERSION;
+        rep.minorVersion = SERVER_COMPOSITE_MINOR_VERSION;
     }
     pCompositeClient->major_version = rep.majorVersion;
     pCompositeClient->minor_version = rep.minorVersion;
diff --git a/damageext/damageext.c b/damageext/damageext.c
index 8fa1c53..449c2fd 100644
--- a/damageext/damageext.c
+++ b/damageext/damageext.c
@@ -25,6 +25,7 @@
 #endif
 
 #include "damageextint.h"
+#include "protocol-versions.h"
 
 static unsigned char	DamageReqCode;
 static int		DamageEventBase;
@@ -35,13 +36,6 @@ static RESTYPE		DamageExtWinType;
 static int DamageClientPrivateKeyIndex;
 static DevPrivateKey DamageClientPrivateKey = &DamageClientPrivateKeyIndex;
 
-/* Version of the damage extension supported by the server, as opposed to the
- * DAMAGE_* defines from damageproto for what version the proto header
- * supports.
- */
-#define SERVER_DAMAGE_MAJOR	1
-#define SERVER_DAMAGE_MINOR	1
-
 #define prScreen	screenInfo.screens[0]
 
 static void
@@ -148,16 +142,16 @@ ProcDamageQueryVersion(ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    if (stuff->majorVersion < SERVER_DAMAGE_MAJOR) {
+    if (stuff->majorVersion < SERVER_DAMAGE_MAJOR_VERSION) {
 	rep.majorVersion = stuff->majorVersion;
 	rep.minorVersion = stuff->minorVersion;
     } else {
-	rep.majorVersion = SERVER_DAMAGE_MAJOR;
-	if (stuff->majorVersion == SERVER_DAMAGE_MAJOR && 
-	    stuff->minorVersion < SERVER_DAMAGE_MINOR)
+	rep.majorVersion = SERVER_DAMAGE_MAJOR_VERSION;
+	if (stuff->majorVersion == SERVER_DAMAGE_MAJOR_VERSION &&
+	    stuff->minorVersion < SERVER_DAMAGE_MINOR_VERSION)
 	    rep.minorVersion = stuff->minorVersion;
 	else
-	    rep.minorVersion = SERVER_DAMAGE_MINOR;
+	    rep.minorVersion = SERVER_DAMAGE_MINOR_VERSION;
     }
     pDamageClient->major_version = rep.majorVersion;
     pDamageClient->minor_version = rep.minorVersion;
diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index f5632d1..b1061a8 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -50,6 +50,7 @@
 #include "indirect_dispatch.h"
 #include "indirect_table.h"
 #include "indirect_util.h"
+#include "protocol-versions.h"
 
 static int
 validGlxScreen(ClientPtr client, int screen, __GLXscreen **pGlxScreen, int *err)
@@ -738,8 +739,8 @@ int __glXDisp_QueryVersion(__GLXclientState *cl, GLbyte *pc)
     ** client if it wants to work with older clients; however, in this
     ** implementation the server just returns its version number.
     */
-    reply.majorVersion = GLX_SERVER_MAJOR_VERSION;
-    reply.minorVersion = GLX_SERVER_MINOR_VERSION;
+    reply.majorVersion = SERVER_GLX_MAJOR_VERSION;
+    reply.minorVersion = SERVER_GLX_MINOR_VERSION;
     reply.length = 0;
     reply.type = X_Reply;
     reply.sequenceNumber = client->sequence;
diff --git a/glx/glxserver.h b/glx/glxserver.h
index 46c9382..4aa8c2e 100644
--- a/glx/glxserver.h
+++ b/glx/glxserver.h
@@ -64,10 +64,6 @@ typedef struct __GLXcontext __GLXcontext;
 #include "glxdrawable.h"
 #include "glxcontext.h"
 
-
-#define GLX_SERVER_MAJOR_VERSION 1
-#define GLX_SERVER_MINOR_VERSION 2
-
 #ifndef True
 #define True 1
 #endif
diff --git a/hw/dmx/dmx.c b/hw/dmx/dmx.c
index 82f95c9..1a0c3fe 100644
--- a/hw/dmx/dmx.c
+++ b/hw/dmx/dmx.c
@@ -57,6 +57,7 @@
 #include "dmxextension.h"
 #include <X11/extensions/dmxproto.h>
 #include <X11/extensions/dmx.h>
+#include "protocol-versions.h"
 
 #ifdef PANORAMIX
 #include "panoramiX.h"
@@ -223,9 +224,9 @@ static int ProcDMXQueryVersion(ClientPtr client)
     rep.type           = X_Reply;
     rep.sequenceNumber = client->sequence;
     rep.length         = 0;
-    rep.majorVersion   = DMX_EXTENSION_MAJOR;
-    rep.minorVersion   = DMX_EXTENSION_MINOR;
-    rep.patchVersion   = DMX_EXTENSION_PATCH;
+    rep.majorVersion   = SERVER_DMX_MAJOR_VERSION;
+    rep.minorVersion   = SERVER_DMX_MINOR_VERSION;
+    rep.patchVersion   = SERVER_DMX_PATCH_VERSION;
     if (client->swapped) {
     	swaps(&rep.sequenceNumber, n);
         swapl(&rep.length, n);
diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c
index 323ebef..e5a765e 100644
--- a/hw/kdrive/ephyr/ephyrdriext.c
+++ b/hw/kdrive/ephyr/ephyrdriext.c
@@ -54,7 +54,7 @@
 #include "hostx.h"
 #define _HAVE_XALLOC_DECLS
 #include "ephyrlog.h"
-
+#include "protocol-version.h"
 
 typedef struct {
     int foo;
@@ -622,9 +622,9 @@ ProcXF86DRIQueryVersion (register ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.majorVersion = XF86DRI_MAJOR_VERSION;
-    rep.minorVersion = XF86DRI_MINOR_VERSION;
-    rep.patchVersion = XF86DRI_PATCH_VERSION;
+    rep.majorVersion = SERVER_XF86DRI_MAJOR_VERSION;
+    rep.minorVersion = SERVER_XF86DRI_MINOR_VERSION;
+    rep.patchVersion = SERVER_XF86DRI_PATCH_VERSION;
     if (client->swapped) {
     	swaps(&rep.sequenceNumber, n);
     	swapl(&rep.length, n);
diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c
index 7579f7d..5367bcc 100644
--- a/hw/xfree86/dixmods/extmod/xf86dga2.c
+++ b/hw/xfree86/dixmods/extmod/xf86dga2.c
@@ -26,6 +26,7 @@
 #include "swaprep.h"
 #include "dgaproc.h"
 #include "xf86dgaext.h"
+#include "protocol-versions.h"
 
 #include <string.h>
 
@@ -122,8 +123,8 @@ ProcXDGAQueryVersion(ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.majorVersion = XDGA_MAJOR_VERSION;
-    rep.minorVersion = XDGA_MINOR_VERSION;
+    rep.majorVersion = SERVER_XDGA_MAJOR_VERSION;
+    rep.minorVersion = SERVER_XDGA_MINOR_VERSION;
 
     WriteToClient(client, sizeof(xXDGAQueryVersionReply), (char *)&rep);
     return (client->noClientException);
diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c
index 1cfb5cc..4920115 100644
--- a/hw/xfree86/dixmods/extmod/xf86vmode.c
+++ b/hw/xfree86/dixmods/extmod/xf86vmode.c
@@ -46,6 +46,7 @@ from Kaleb S. KEITHLEY
 #include "xf86.h"
 #include "vidmodeproc.h"
 #include "globals.h"
+#include "protocol-versions.h"
 
 #define DEFAULT_XF86VIDMODE_VERBOSITY	3
 
@@ -384,8 +385,8 @@ ProcXF86VidModeQueryVersion(ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.majorVersion = XF86VIDMODE_MAJOR_VERSION;
-    rep.minorVersion = XF86VIDMODE_MINOR_VERSION;
+    rep.majorVersion = SERVER_XF86VIDMODE_MAJOR_VERSION;
+    rep.minorVersion = SERVER_XF86VIDMODE_MINOR_VERSION;
     if (client->swapped) {
     	swaps(&rep.sequenceNumber, n);
     	swapl(&rep.length, n);
diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c
index 75344b7..035057b 100644
--- a/hw/xfree86/dri/xf86dri.c
+++ b/hw/xfree86/dri/xf86dri.c
@@ -60,6 +60,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "dristruct.h"
 #include "xf86.h"
 #include "xf86drm.h"
+#include "protocol-versions.h"
 
 static int DRIErrorBase;
 
@@ -134,9 +135,9 @@ ProcXF86DRIQueryVersion(
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.majorVersion = XF86DRI_MAJOR_VERSION;
-    rep.minorVersion = XF86DRI_MINOR_VERSION;
-    rep.patchVersion = XF86DRI_PATCH_VERSION;
+    rep.majorVersion = SERVER_XF86DRI_MAJOR_VERSION;
+    rep.minorVersion = SERVER_XF86DRI_MINOR_VERSION;
+    rep.patchVersion = SERVER_XF86DRI_PATCH_VERSION;
     if (client->swapped) {
     	swaps(&rep.sequenceNumber, n);
     	swapl(&rep.length, n);
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index 72f9a44..6c14578 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -45,6 +45,7 @@
 #include "xf86drm.h"
 #include "xfixes.h"
 #include "dri2.h"
+#include "protocol-versions.h"
 
 /* The only xf86 include */
 #include "xf86Module.h"
@@ -79,8 +80,8 @@ ProcDRI2QueryVersion(ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.majorVersion = 1;
-    rep.minorVersion = 1;
+    rep.majorVersion = SERVER_DRI2_MAJOR_VERSION;
+    rep.minorVersion = SERVER_DRI2_MAJOR_VERSION;
 
     if (client->swapped) {
     	swaps(&rep.sequenceNumber, n);
diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c
index 330bac4..14be180 100644
--- a/hw/xquartz/applewm.c
+++ b/hw/xquartz/applewm.c
@@ -50,6 +50,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <X11/extensions/applewmproto.h>
 #include "applewmExt.h"
 #include "X11Application.h"
+#include "protocol-versions.h"
 
 #define DEFINE_ATOM_HELPER(func,atom_name)                      \
 static Atom func (void) {                                       \
@@ -183,9 +184,9 @@ ProcAppleWMQueryVersion(
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.majorVersion = APPLE_WM_MAJOR_VERSION;
-    rep.minorVersion = APPLE_WM_MINOR_VERSION;
-    rep.patchVersion = APPLE_WM_PATCH_VERSION;
+    rep.majorVersion = SERVER_APPLEWM_MAJOR_VERSION;
+    rep.minorVersion = SERVER_APPLEWM_MINOR_VERSION;
+    rep.patchVersion = SERVER_APPLEWM_PATCH_VERSION;
     if (client->swapped) {
         swaps(&rep.sequenceNumber, n);
         swapl(&rep.length, n);
diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c
index 4d1a82f..835ccab 100644
--- a/hw/xquartz/xpr/appledri.c
+++ b/hw/xquartz/xpr/appledri.c
@@ -55,6 +55,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "dristruct.h"
 #include "xpr.h"
 #include "x-hash.h"
+#include "protocol-versions.h"
 
 static int DRIErrorBase = 0;
 
@@ -119,9 +120,9 @@ ProcAppleDRIQueryVersion(
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.majorVersion = APPLE_DRI_MAJOR_VERSION;
-    rep.minorVersion = APPLE_DRI_MINOR_VERSION;
-    rep.patchVersion = APPLE_DRI_PATCH_VERSION;
+    rep.majorVersion = SERVER_APPLEDRI_MAJOR_VERSION;
+    rep.minorVersion = SERVER_APPLEDRI_MINOR_VERSION;
+    rep.patchVersion = SERVER_APPLEDRI_PATCH_VERSION;
     if (client->swapped) {
         swaps(&rep.sequenceNumber, n);
         swapl(&rep.length, n);
diff --git a/hw/xwin/winwindowswm.c b/hw/xwin/winwindowswm.c
index 61972c9..5b164ea 100755
--- a/hw/xwin/winwindowswm.c
+++ b/hw/xwin/winwindowswm.c
@@ -41,6 +41,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "swaprep.h"
 #define _WINDOWSWM_SERVER_
 #include <X11/extensions/windowswmstr.h>
+#include "protocol-versions.h"
 
 static int WMErrorBase;
 
@@ -114,9 +115,9 @@ ProcWindowsWMQueryVersion(register ClientPtr client)
   rep.type = X_Reply;
   rep.length = 0;
   rep.sequenceNumber = client->sequence;
-  rep.majorVersion = WINDOWS_WM_MAJOR_VERSION;
-  rep.minorVersion = WINDOWS_WM_MINOR_VERSION;
-  rep.patchVersion = WINDOWS_WM_PATCH_VERSION;
+  rep.majorVersion = SERVER_WINDOWSWM_MAJOR_VERSION;
+  rep.minorVersion = SERVER_WINDOWSWM_MINOR_VERSION;
+  rep.patchVersion = SERVER_WINDOWSWM_PATCH_VERSION;
   if (client->swapped)
     {
       swaps(&rep.sequenceNumber, n);
diff --git a/include/Makefile.am b/include/Makefile.am
index f8eef53..057c2f2 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -65,4 +65,5 @@ AM_CFLAGS = $(DIX_CFLAGS)
 
 EXTRA_DIST = 	\
 	dix-config-apple-verbatim.h \
-	eventconvert.h eventstr.h
+	eventconvert.h eventstr.h \
+        protocol-versions.h
diff --git a/include/protocol-versions.h b/include/protocol-versions.h
new file mode 100644
index 0000000..da9770c
--- /dev/null
+++ b/include/protocol-versions.h
@@ -0,0 +1,148 @@
+/*
+ * Copyright © 2009 Red Hat, Inc.
+ *
+ * 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ */
+
+/**
+ * This file specifies the server-supported protocol versions.
+ */
+#ifndef _PROTOCOL_VERSIONS_
+#define _PROTOCOL_VERSIONS_
+
+/* Apple DRI */
+#define SERVER_APPLEDRI_MAJOR_VERSION		1
+#define SERVER_APPLEDRI_MINOR_VERSION		0
+#define SERVER_APPLEDRI_PATCH_VERSION		0
+
+/* AppleWM */
+#define SERVER_APPLEWM_MAJOR_VERSION		1
+#define SERVER_APPLEWM_MINOR_VERSION		3
+#define SERVER_APPLEWM_PATCH_VERSION		0
+
+/* Composite */
+#define SERVER_COMPOSITE_MAJOR_VERSION		0
+#define SERVER_COMPOSITE_MINOR_VERSION		4
+
+/* Damage */
+#define SERVER_DAMAGE_MAJOR_VERSION		1
+#define SERVER_DAMAGE_MINOR_VERSION		1
+
+/* DMX */
+#define SERVER_DMX_MAJOR_VERSION		2
+#define SERVER_DMX_MINOR_VERSION		2
+#define SERVER_DMX_PATCH_VERSION		20040604
+
+/* DRI2 */
+#define SERVER_DRI2_MAJOR_VERSION		1
+#define SERVER_DRI2_MINOR_VERSION		1
+
+/* Generic event extension */
+#define SERVER_GE_MAJOR_VERSION                 1
+#define SERVER_GE_MINOR_VERSION                 0
+
+/* GLX */
+#define SERVER_GLX_MAJOR_VERSION		1
+#define SERVER_GLX_MINOR_VERSION		2
+
+/* Xinerama */
+#define SERVER_PANORAMIX_MAJOR_VERSION          1
+#define SERVER_PANORAMIX_MINOR_VERSION		1
+
+/* RandR */
+#define SERVER_RANDR_MAJOR_VERSION		1
+#define SERVER_RANDR_MINOR_VERSION		3
+
+/* Record */
+#define SERVER_RECORD_MAJOR_VERSION		1
+#define SERVER_RECORD_MINOR_VERSION		13
+
+/* Render */
+#define SERVER_RENDER_MAJOR_VERSION		0
+#define SERVER_RENDER_MINOR_VERSION		10
+
+/* RandR Xinerama */
+#define SERVER_RRXINERAMA_MAJOR_VERSION		1
+#define SERVER_RRXINERAMA_MINOR_VERSION		1
+
+/* Screensaver */
+#define SERVER_SAVER_MAJOR_VERSION		1
+#define SERVER_SAVER_MINOR_VERSION		1
+
+/* Security */
+#define SERVER_SECURITY_MAJOR_VERSION		1
+#define SERVER_SECURITY_MINOR_VERSION		0
+
+/* Shape */
+#define SERVER_SHAPE_MAJOR_VERSION		1
+#define SERVER_SHAPE_MINOR_VERSION		1
+
+/* SHM */
+#define SERVER_SHM_MAJOR_VERSION		1
+#define SERVER_SHM_MINOR_VERSION		1
+
+/* Windows WM */
+#define SERVER_WINDOWSWM_MAJOR_VERSION		1
+#define SERVER_WINDOWSWM_MINOR_VERSION		0
+#define SERVER_WINDOWSWM_PATCH_VERSION		0
+
+/* Xcalibrate */
+#define SERVER_XCALIBRATE_MAJOR_VERSION		0
+#define SERVER_XCALIBRATE_MINOR_VERSION		1
+
+/* DGA */
+#define SERVER_XDGA_MAJOR_VERSION		2
+#define SERVER_XDGA_MINOR_VERSION		0
+
+/* Big Font */
+#define SERVER_XF86BIGFONT_MAJOR_VERSION	1
+#define SERVER_XF86BIGFONT_MINOR_VERSION	1
+
+/* DRI */
+#define SERVER_XF86DRI_MAJOR_VERSION		4
+#define SERVER_XF86DRI_MINOR_VERSION		1
+#define SERVER_XF86DRI_PATCH_VERSION		20040604
+
+/* Vidmode */
+#define SERVER_XF86VIDMODE_MAJOR_VERSION	2
+#define SERVER_XF86VIDMODE_MINOR_VERSION	2
+
+/* Fixes */
+#define SERVER_XFIXES_MAJOR_VERSION		4
+#define SERVER_XFIXES_MINOR_VERSION		0
+
+/* X Input */
+#define SERVER_XI_MAJOR_VERSION			2
+#define SERVER_XI_MINOR_VERSION			0
+
+/* XKB */
+#define SERVER_XKB_MAJOR_VERSION		1
+#define SERVER_XKB_MINOR_VERSION		0
+
+/* Resource */
+#define SERVER_XRES_MAJOR_VERSION		1
+#define SERVER_XRES_MINOR_VERSION		0
+
+/* XvMC */
+#define SERVER_XVMC_MAJOR_VERSION		1
+#define SERVER_XVMC_MINOR_VERSION		1
+
+#endif
diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c
index bec5b08..f145e98 100644
--- a/randr/rrdispatch.c
+++ b/randr/rrdispatch.c
@@ -21,9 +21,7 @@
  */
 
 #include "randrstr.h"
-
-#define SERVER_RANDR_MAJOR	1
-#define SERVER_RANDR_MINOR	3
+#include "protocol-versions.h"
 
 Bool
 RRClientKnowsRates (ClientPtr	pClient)
@@ -52,8 +50,8 @@ ProcRRQueryVersion (ClientPtr client)
      * Report the current version; the current
      * spec says they're all compatible after 1.0
      */
-    rep.majorVersion = SERVER_RANDR_MAJOR;
-    rep.minorVersion = SERVER_RANDR_MINOR;
+    rep.majorVersion = SERVER_RANDR_MAJOR_VERSION;
+    rep.minorVersion = SERVER_RANDR_MINOR_VERSION;
     if (client->swapped) {
     	swaps(&rep.sequenceNumber, n);
     	swapl(&rep.length, n);
diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c
index 97be7c1..94c8e54 100644
--- a/randr/rrxinerama.c
+++ b/randr/rrxinerama.c
@@ -71,9 +71,7 @@
 #include "randrstr.h"
 #include "swaprep.h"
 #include <X11/extensions/panoramiXproto.h>
-
-#define RR_XINERAMA_MAJOR_VERSION   1
-#define RR_XINERAMA_MINOR_VERSION   1
+#include "protocol-versions.h"
 
 /* Xinerama is not multi-screen capable; just report about screen 0 */
 #define RR_XINERAMA_SCREEN  0
@@ -98,8 +96,8 @@ ProcRRXineramaQueryVersion(ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.majorVersion = RR_XINERAMA_MAJOR_VERSION;
-    rep.minorVersion = RR_XINERAMA_MINOR_VERSION;
+    rep.majorVersion = SERVER_RRXINERAMA_MAJOR_VERSION;
+    rep.minorVersion = SERVER_RRXINERAMA_MINOR_VERSION;
     if(client->swapped) {
         swaps(&rep.sequenceNumber, n);
         swapl(&rep.length, n);
diff --git a/record/record.c b/record/record.c
index 84a9618..b94b4ae 100644
--- a/record/record.c
+++ b/record/record.c
@@ -53,6 +53,8 @@ and Jim Haggerty of Metheus.
 #include "cursor.h"
 #endif
 
+#include "protocol-versions.h"
+
 static RESTYPE RTContext;   /* internal resource type for Record contexts */
 static int RecordErrorBase; /* first Record error number */
 
@@ -1866,8 +1868,8 @@ ProcRecordQueryVersion(ClientPtr client)
     rep.type        	= X_Reply;
     rep.sequenceNumber 	= client->sequence;
     rep.length         	= 0;
-    rep.majorVersion  	= RECORD_MAJOR_VERSION;
-    rep.minorVersion  	= RECORD_MINOR_VERSION;
+    rep.majorVersion  	= SERVER_RECORD_MAJOR_VERSION;
+    rep.minorVersion  	= SERVER_RECORD_MINOR_VERSION;
     if(client->swapped)
     {
     	swaps(&rep.sequenceNumber, n);
diff --git a/render/render.c b/render/render.c
index 995ebd9..55845b0 100644
--- a/render/render.c
+++ b/render/render.c
@@ -45,6 +45,7 @@
 #include <X11/Xfuncproto.h>
 #include "cursorstr.h"
 #include "xace.h"
+#include "protocol-versions.h"
 
 #if HAVE_STDINT_H
 #include <stdint.h>
@@ -270,8 +271,8 @@ ProcRenderQueryVersion (ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.majorVersion = RENDER_MAJOR;
-    rep.minorVersion = RENDER_MINOR;
+    rep.majorVersion = SERVER_RENDER_MAJOR_VERSION;
+    rep.minorVersion = SERVER_RENDER_MINOR_VERSION;
     if (client->swapped) {
     	swaps(&rep.sequenceNumber, n);
     	swapl(&rep.length, n);
diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c
index 25c92ea..fa360b8 100644
--- a/xfixes/xfixes.c
+++ b/xfixes/xfixes.c
@@ -52,13 +52,11 @@
 #endif
 
 #include "xfixesint.h"
-
+#include "protocol-versions.h"
 /*
  * Must use these instead of the constants from xfixeswire.h.  They advertise
  * what we implement, not what the protocol headers define.
  */
-#define SERVER_XFIXES_MAJOR 4
-#define SERVER_XFIXES_MINOR 0
 
 static unsigned char	XFixesReqCode;
 int		XFixesEventBase;
@@ -80,16 +78,16 @@ ProcXFixesQueryVersion(ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    if (stuff->majorVersion < SERVER_XFIXES_MAJOR) {
+    if (stuff->majorVersion < SERVER_XFIXES_MAJOR_VERSION) {
 	rep.majorVersion = stuff->majorVersion;
 	rep.minorVersion = stuff->minorVersion;
     } else {
-	rep.majorVersion = SERVER_XFIXES_MAJOR;
-	if (stuff->majorVersion == SERVER_XFIXES_MAJOR && 
-	    stuff->minorVersion < SERVER_XFIXES_MINOR)
+	rep.majorVersion = SERVER_XFIXES_MAJOR_VERSION;
+	if (stuff->majorVersion == SERVER_XFIXES_MAJOR_VERSION &&
+	    stuff->minorVersion < SERVER_XFIXES_MINOR_VERSION)
 	    rep.minorVersion = stuff->minorVersion;
 	else
-	    rep.minorVersion = SERVER_XFIXES_MINOR;
+	    rep.minorVersion = SERVER_XFIXES_MINOR_VERSION;
     }
     pXFixesClient->major_version = rep.majorVersion;
     pXFixesClient->minor_version = rep.minorVersion;
diff --git a/xkb/xkb.c b/xkb/xkb.c
index 0b54a2e..7abbeaa 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -38,6 +38,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "extnsionst.h"
 #include "xace.h"
 #include "xkb.h"
+#include "protocol-versions.h"
 
 #include <X11/extensions/XI.h>
 #include <X11/extensions/XKMformat.h>
@@ -161,9 +162,9 @@ ProcXkbUseExtension(ClientPtr client)
     int	supported;
 
     REQUEST_SIZE_MATCH(xkbUseExtensionReq);
-    if (stuff->wantedMajor != XkbMajorVersion) {
+    if (stuff->wantedMajor != SERVER_XKB_MAJOR_VERSION) {
 	/* pre-release version 0.65 is compatible with 1.00 */
-	supported= ((XkbMajorVersion==1)&&
+	supported= ((SERVER_XKB_MAJOR_VERSION==1)&&
 		    (stuff->wantedMajor==0)&&(stuff->wantedMinor==65));
     }
     else supported = 1;
@@ -178,15 +179,15 @@ ProcXkbUseExtension(ClientPtr client)
 					client->index,
 					(long)client->clientAsMask,
 					stuff->wantedMajor,stuff->wantedMinor,
-					XkbMajorVersion,XkbMinorVersion);
+					SERVER_XKB_MAJOR_VERSION,SERVER_XKB_MINOR_VERSION);
     }
     memset(&rep, 0, sizeof(xkbUseExtensionReply));
     rep.type = X_Reply;
     rep.supported = supported;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.serverMajor = XkbMajorVersion;
-    rep.serverMinor = XkbMinorVersion;
+    rep.serverMajor = SERVER_XKB_MAJOR_VERSION;
+    rep.serverMinor = SERVER_XKB_MINOR_VERSION;
     if ( client->swapped ) {
 	swaps(&rep.sequenceNumber, n);
 	swaps(&rep.serverMajor, n);
-- 
1.6.3.rc1.2.g0164.dirty


More information about the xorg-devel mailing list