xserver: Branch 'XACE-SELINUX' - 25 commits

Eamon Walsh ewalsh at kemper.freedesktop.org
Mon Mar 19 21:16:08 EET 2007


 GL/glx/glxcmdsswap.c                                            |    4 
 Xext/shm.c                                                      |   23 
 Xext/xselinux.c                                                 |   36 
 afb/afbpixmap.c                                                 |    4 
 cfb/cfbpixmap.c                                                 |    4 
 dix/devices.c                                                   |   11 
 dix/main.c                                                      |   46 
 dix/pixmap.c                                                    |    4 
 dix/privates.c                                                  |  194 +---
 dix/resource.c                                                  |   24 
 fb/fbpixmap.c                                                   |    4 
 hw/darwin/Makefile.am                                           |    4 
 hw/darwin/README.apple                                          |    8 
 hw/darwin/apple/X11Application.m                                |   48 -
 hw/darwin/darwinEvents.c                                        |  283 ++---
 hw/dmx/dmxpixmap.c                                              |    4 
 hw/dmx/dmxscrinit.c                                             |    6 
 hw/xfree86/common/xf86fbman.c                                   |    2 
 hw/xfree86/doc/README.modes                                     |  474 ++++++++++
 hw/xfree86/loader/dixsym.c                                      |    4 
 hw/xfree86/modes/xf86Crtc.c                                     |  251 +++++
 hw/xfree86/modes/xf86Crtc.h                                     |   37 
 hw/xfree86/modes/xf86RandR12.c                                  |   24 
 hw/xfree86/modes/xf86Rename.h                                   |    4 
 hw/xfree86/xf4bpp/ppcPixmap.c                                   |    4 
 hw/xnest/Pixmap.c                                               |    6 
 hw/xnest/Screen.c                                               |    4 
 hw/xnest/XNPixmap.h                                             |    7 
 hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am |    8 
 hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am   |    8 
 hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am     |    8 
 include/dix.h                                                   |    2 
 include/extension.h                                             |    2 
 include/input.h                                                 |    1 
 include/pixmapstr.h                                             |    2 
 include/privates.h                                              |   35 
 include/resource.h                                              |   20 
 include/screenint.h                                             |   14 
 include/scrnintstr.h                                            |    2 
 mfb/mfbpixmap.c                                                 |    4 
 randr/rrcrtc.c                                                  |    2 
 randr/rroutput.c                                                |    2 
 randr/rrpointer.c                                               |    2 
 43 files changed, 1081 insertions(+), 555 deletions(-)

New commits:
diff-tree fe05ba75a10ec080e7ec34bff6936103185586b3 (from 18339375cd332f0ab1cbdade3dcd9140212ce1ca)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Thu Mar 8 12:14:30 2007 -0500

    devPrivates rework: pass address of pointer to private callbacks instead of
    the pointer itself.

diff --git a/dix/privates.c b/dix/privates.c
index 29e261f..8aab32d 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -117,7 +117,7 @@ dixAllocatePrivate(PrivateRec **privates
 
     /* call any init funcs and return */
     if (item) {
-	PrivateCallbackRec calldata = { key, ptr->value };
+	PrivateCallbackRec calldata = { key, &ptr->value };
 	CallCallbacks(&item->initfuncs, &calldata);
     }
     return &ptr->value;
@@ -138,7 +138,7 @@ dixFreePrivates(PrivateRec *privates)
 	item = findItem(ptr->key);
 	if (item) {
 	    calldata.key = ptr->key;
-	    calldata.value = ptr->value;
+	    calldata.value = &ptr->value;
 	    CallCallbacks(&item->deletefuncs, &calldata);
 	}
     }
diff --git a/include/privates.h b/include/privates.h
index 6071e39..e57f167 100644
--- a/include/privates.h
+++ b/include/privates.h
@@ -112,7 +112,7 @@ dixSetPrivate(PrivateRec **privates, dev
  */
 typedef struct _PrivateCallback {
     devprivate_key_t *key;	/* private registration key */
-    pointer value;		/* pointer to private */
+    pointer *value;		/* address of private pointer */
 } PrivateCallbackRec;
 
 extern int
diff-tree 18339375cd332f0ab1cbdade3dcd9140212ce1ca (from b9cff1670f29949a5bc41afc19aca443f434febb)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Thu Mar 8 12:14:06 2007 -0500

    xselinux: remove context validation function for now.

diff --git a/Xext/xselinux.c b/Xext/xselinux.c
index 5b77269..ab4827e 100644
--- a/Xext/xselinux.c
+++ b/Xext/xselinux.c
@@ -57,42 +57,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE 
 #define XSELINUXCONFIGFILE  NULL
 #endif
 
-
-/* Make sure a locally connecting client has a valid context.  The context
- * for this client is retrieved again later on in AssignClientState(), but
- * by that point it's too late to reject the client.
- */
-static char *
-XSELinuxValidContext (ClientPtr client)
-{
-    security_context_t ctx = NULL;
-    XtransConnInfo ci = ((OsCommPtr)client->osPrivate)->trans_conn;
-    char reason[256];
-    char *ret = (char *)NULL;
-
-    if (_XSERVTransIsLocal(ci))
-    {
-        int fd = _XSERVTransGetConnectionNumber(ci);
-        if (getpeercon(fd, &ctx) < 0)
-        {
-            snprintf(reason, sizeof(reason), "Failed to retrieve SELinux context from socket");
-            ret = reason;
-            goto out;
-        }
-        if (security_check_context(ctx))
-        {
-            snprintf(reason, sizeof(reason), "Client's SELinux context is invalid: %s", ctx);
-            ret = reason;
-        }
-
-        freecon(ctx);
-    }
-
-out:
-    return ret;
-}
-
-
 /* devPrivates in client and extension */
 static int clientPrivateIndex;
 static int extnsnPrivateIndex;
diff-tree b9cff1670f29949a5bc41afc19aca443f434febb (from 2fcb45eb5dc1803b372df8b5765f6a43bea83611)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Thu Mar 8 12:13:52 2007 -0500

    Add ResourceStateCallback similar in function to ClientStateCallback.

diff --git a/dix/resource.c b/dix/resource.c
index 2cad7c0..edf32ff 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -193,6 +193,17 @@ _X_EXPORT RESTYPE TypeMask;
 
 static DeleteType *DeleteFuncs = (DeleteType *)NULL;
 
+_X_EXPORT CallbackListPtr ResourceStateCallback;
+
+static _X_INLINE void
+CallResourceStateCallback(ResourceState state, ResourceRec *res)
+{
+    if (ResourceStateCallback) {
+	ResourceStateInfoRec rsi = { state, res->id, res->type, res->value };
+	CallCallbacks(&ResourceStateCallback, &rsi);
+    }
+}
+
 #ifdef XResExtension
 
 _X_EXPORT Atom * ResourceNames = NULL;
@@ -492,6 +503,7 @@ AddResource(XID id, RESTYPE type, pointe
     rrec->elements++;
     if (!(id & SERVER_BIT) && (id >= rrec->expectID))
 	rrec->expectID = id + 1;
+    CallResourceStateCallback(ResourceStateAdding, res);
     return TRUE;
 }
 
@@ -572,6 +584,9 @@ FreeResource(XID id, RESTYPE skipDeleteF
 #endif		    
 		*prev = res->next;
 		elements = --*eltptr;
+
+		CallResourceStateCallback(ResourceStateFreeing, res);
+
 		if (rtype & RC_CACHED)
 		    FlushClientCaches(res->id);
 		if (rtype != skipDeleteFuncType)
@@ -616,6 +631,9 @@ FreeResourceByType(XID id, RESTYPE type,
 			      res->value, TypeNameString(res->type));
 #endif		    		    
 		*prev = res->next;
+
+		CallResourceStateCallback(ResourceStateFreeing, res);
+
 		if (type & RC_CACHED)
 		    FlushClientCaches(res->id);
 		if (!skipFree)
@@ -782,6 +800,9 @@ FreeClientNeverRetainResources(ClientPtr
 			      this->value, TypeNameString(this->type));
 #endif		    
 		*prev = this->next;
+
+		CallResourceStateCallback(ResourceStateFreeing, this);
+
 		if (rtype & RC_CACHED)
 		    FlushClientCaches(this->id);
 		(*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
@@ -832,6 +853,9 @@ FreeClientResources(ClientPtr client)
 			  this->value, TypeNameString(this->type));
 #endif		    
 	    *head = this->next;
+
+	    CallResourceStateCallback(ResourceStateFreeing, this);
+
 	    if (rtype & RC_CACHED)
 		FlushClientCaches(this->id);
 	    (*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c
index e6c2baa..1732d1f 100644
--- a/hw/xfree86/loader/dixsym.c
+++ b/hw/xfree86/loader/dixsym.c
@@ -300,6 +300,7 @@ _X_HIDDEN void *dixLookupTab[] = {
     SYMFUNC(FindAllClientResources)
     SYMVAR(lastResourceType)
     SYMVAR(TypeMask)
+    SYMVAR(ResourceStateCallback)
 #ifdef RES
     SYMFUNC(RegisterResourceName)
     SYMVAR(ResourceNames)
diff --git a/include/resource.h b/include/resource.h
index 3231e8c..9949dd2 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -120,6 +120,19 @@ typedef unsigned long RESTYPE;
 
 #define BAD_RESOURCE 0xe0000000
 
+/* Resource state callback */
+extern CallbackListPtr ResourceStateCallback;
+
+typedef enum {ResourceStateAdding,
+	      ResourceStateFreeing} ResourceState;
+
+typedef struct {
+    ResourceState state;
+    XID id;
+    RESTYPE type;
+    pointer value;
+} ResourceStateInfoRec;
+
 typedef int (*DeleteType)(
     pointer /*value*/,
     XID /*id*/);
diff-tree 2fcb45eb5dc1803b372df8b5765f6a43bea83611 (from 947f8d249bac61beb10669d935888c4c280b5062)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Thu Mar 8 12:13:36 2007 -0500

    devPrivates rework: redo field offset registration, drop RC_PRIVATES class.

diff --git a/dix/privates.c b/dix/privates.c
index 01d327b..29e261f 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -195,12 +195,14 @@ dixRegisterPrivateOffset(RESTYPE type, u
 
     /* resize offsets table if necessary */
     while (type >= offsetsSize) {
-	offsets = (unsigned *)xrealloc(offsets,
-				       offsetsSize * 2 * sizeof(unsigned));
+	unsigned i = offsetsSize * 2 * sizeof(int);
+	offsets = (unsigned *)xrealloc(offsets, i);
 	if (!offsets) {
 	    offsetsSize = 0;
 	    return FALSE;
 	}
+	for (i=offsetsSize; i < 2*offsetsSize; i++)
+	    offsets[i] = -1;
 	offsetsSize *= 2;
     }
 
@@ -208,10 +210,9 @@ dixRegisterPrivateOffset(RESTYPE type, u
     return TRUE;
 }
 
-_X_EXPORT unsigned
+_X_EXPORT int
 dixLookupPrivateOffset(RESTYPE type)
 {
-    assert(type & RC_PRIVATES);
     type = type & TypeMask;
     assert(type < offsetsSize);
     return offsets[type];
@@ -233,19 +234,22 @@ int
 dixResetPrivates(void)
 {
     PrivateDescRec *next;
+    unsigned i;
+
+    /* reset internal structures */
     while (items) {
 	next = items->next;
 	xfree(items);
 	items = next;
     }
-
     if (offsets)
 	xfree(offsets);
-
     offsetsSize = 16;
     offsets = (unsigned *)xalloc(offsetsSize * sizeof(unsigned));
     if (!offsets)
 	return FALSE;
+    for (i=0; i < offsetsSize; i++)
+	offsets[i] = -1;
 
     /* reset legacy devPrivates support */
     if (!ResetExtensionPrivates() || !ResetClientPrivates())
diff --git a/include/privates.h b/include/privates.h
index d1e269b..6071e39 100644
--- a/include/privates.h
+++ b/include/privates.h
@@ -142,9 +142,10 @@ dixResetPrivates(void);
  */
 
 /*
- * Looks up the offset where the devPrivates field is located by type.
+ * Looks up the offset where the devPrivates field is located.
+ * Returns -1 if no offset has been registered for the resource type.
  */
-extern unsigned
+extern int
 dixLookupPrivateOffset(RESTYPE type);
 
 /*
diff --git a/include/resource.h b/include/resource.h
index 40259ac..3231e8c 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -66,12 +66,7 @@ typedef unsigned long RESTYPE;
  *  Extensions can use this too!
  */
 #define RC_NEVERRETAIN	((RESTYPE)1<<29)
-/*  Use class RC_PRIVATES for resources that support extra private data.
- *  Resources having this class must provide a field of type PrivateRec *.
- *  Refer to the X server documentation on devPrivates for the details.
- */
-#define RC_PRIVATES	((RESTYPE)1<<28)
-#define RC_LASTPREDEF	RC_PRIVATES
+#define RC_LASTPREDEF	RC_NEVERRETAIN
 #define RC_ANY		(~(RESTYPE)0)
 
 /* types for Resource routines */
diff-tree 947f8d249bac61beb10669d935888c4c280b5062 (from c45f6762080ef00b41d9f73441a9f0e605253008)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Thu Mar 8 12:13:18 2007 -0500

    devPrivates rework: redo interface again, dropping parent and type parameters
    as well as preallocation routine.

diff --git a/dix/privates.c b/dix/privates.c
index 57da0fa..01d327b 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -48,8 +48,6 @@ from The Open Group.
 
 typedef struct _PrivateDesc {
     devprivate_key_t *key;
-    RESTYPE type;
-    pointer parent;
     unsigned size;
     CallbackListPtr initfuncs;
     CallbackListPtr deletefuncs;
@@ -72,15 +70,13 @@ findItem(devprivate_key_t *const key)
 }
 
 /*
- * Request pre-allocated space in resources of a given type.
+ * Request pre-allocated space.
  */
 _X_EXPORT int
-dixRequestPrivate(RESTYPE type, devprivate_key_t *const key,
-		  unsigned size, pointer parent)
+dixRequestPrivate(devprivate_key_t *const key, unsigned size)
 {
     PrivateDescRec *item = findItem(key);
     if (item) {
-	assert(item->type == type);
 	if (size > item->size)
 	    item->size = size;
     } else {
@@ -91,8 +87,6 @@ dixRequestPrivate(RESTYPE type, devpriva
 
 	/* add privates descriptor */
 	item->key = key;
-	item->type = type;
-	item->parent = parent;
 	item->size = size;
 	item->next = items;
 	items = item;
@@ -116,7 +110,6 @@ dixAllocatePrivate(PrivateRec **privates
     ptr = (PrivateRec *)xalloc(size);
     if (!ptr)
 	return NULL;
-    memset(ptr, 0, size);
     ptr->key = key;
     ptr->value = (size > sizeof(PrivateRec)) ? (ptr + 1) : NULL;
     ptr->next = *privates;
@@ -131,57 +124,6 @@ dixAllocatePrivate(PrivateRec **privates
 }
 
 /*
- * Allocates pre-requested privates in a single chunk.
- */
-_X_EXPORT PrivateRec *
-dixAllocatePrivates(RESTYPE type, pointer parent)
-{
-    unsigned count = 0, size = 0;
-    PrivateCallbackRec calldata;
-    PrivateDescRec *item;
-    PrivateRec *ptr;
-    char *value;
-
-    /* first pass figures out total size */
-    for (item = items; item; item = item->next)
-	if ((item->type == type || item->type == RC_ANY) &&
-	    (item->parent == NULL || item->parent == parent)) {
-
-	    size += sizeof(PrivateRec) + item->size;
-	    count++;
-	}
-
-    /* allocate one chunk of memory for everything */
-    ptr = (PrivateRec *)xalloc(size);
-    if (!ptr)
-	return NULL;
-    memset(ptr, 0, size);
-    value = (char *)(ptr + count);
-
-    /* second pass sets up records and calls init funcs */
-    count = 0;
-    for (item = items; item; item = item->next)
-	if ((item->type == type || item->type == RC_ANY) &&
-	    (item->parent == NULL || item->parent == parent)) {
-
-	    ptr[count].key = calldata.key = item->key;
-	    ptr[count].dontfree = (count > 0);
-	    ptr[count].value = calldata.value = (items->size ? value : NULL);
-	    ptr[count].next = ptr + (count + 1);
-
-	    CallCallbacks(&item->initfuncs, &calldata);
-
-	    count++;
-	    value += item->size;
-	}
-
-    if (count > 0)
-	ptr[count-1].next = NULL;
-
-    return ptr;
-}
-
-/*
  * Called to free privates at object deletion time.
  */
 _X_EXPORT void
@@ -204,16 +146,9 @@ dixFreePrivates(PrivateRec *privates)
     /* second pass frees the memory */
     ptr = privates;
     while (ptr) {
-	if (ptr->dontfree)
-	    ptr = ptr->next;
-	else {
-	    next = ptr->next;
-	    while (next && next->dontfree)
-		next = next->next;
-
-	    xfree(ptr);
-	    ptr = next;
-	}
+	next = ptr->next;
+	xfree(ptr);
+	ptr = next;
     }
 }
 
@@ -225,8 +160,11 @@ dixRegisterPrivateInitFunc(devprivate_ke
 			   CallbackProcPtr callback, pointer data)
 {
     PrivateDescRec *item = findItem(key);
-    if (!item)
-	return FALSE;
+    if (!item) {
+	if (!dixRequestPrivate(key, 0))
+	    return FALSE;
+	item = findItem(key);
+    }
     return AddCallback(&item->initfuncs, callback, data);
 }
 
@@ -235,8 +173,11 @@ dixRegisterPrivateDeleteFunc(devprivate_
 			     CallbackProcPtr callback, pointer data)
 {
     PrivateDescRec *item = findItem(key);
-    if (!item)
-	return FALSE;
+    if (!item) {
+	if (!dixRequestPrivate(key, 0))
+	    return FALSE;
+	item = findItem(key);
+    }
     return AddCallback(&item->deletefuncs, callback, data);
 }
 
diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c
index 6b52aea..e6c2baa 100644
--- a/hw/xfree86/loader/dixsym.c
+++ b/hw/xfree86/loader/dixsym.c
@@ -264,7 +264,6 @@ _X_HIDDEN void *dixLookupTab[] = {
     SYMFUNC(dixRegisterPrivateInitFunc)
     SYMFUNC(dixRegisterPrivateDeleteFunc)
     SYMFUNC(dixAllocatePrivate)
-    SYMFUNC(dixAllocatePrivates)
     SYMFUNC(dixFreePrivates)
     SYMFUNC(dixRegisterPrivateOffset)
     SYMFUNC(dixLookupPrivateOffset)
diff --git a/include/privates.h b/include/privates.h
index 9c95350..d1e269b 100644
--- a/include/privates.h
+++ b/include/privates.h
@@ -19,13 +19,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE 
  * STUFF FOR PRIVATES
  *****************************************************************/
 
-typedef struct _PrivateKey {
-    int unused;
-} devprivate_key_t;
+typedef char devprivate_key_t;
 
 typedef struct _Private {
     devprivate_key_t	*key;
-    int			dontfree;
     pointer		value;
     struct _Private	*next;
 } PrivateRec;
@@ -39,11 +36,10 @@ typedef struct _Private {
 
 /*
  * Request pre-allocated private space for your driver/module.
- * A non-null pScreen argument restricts to objects on a given screen.
+ * Calling this is not necessary if only a pointer by itself is needed.
  */
 extern int
-dixRequestPrivate(RESTYPE type, devprivate_key_t *const key,
-		  unsigned size, pointer pScreen);
+dixRequestPrivate(devprivate_key_t *const key, unsigned size);
 
 /*
  * Allocates a new private and attaches it to an existing object.
@@ -128,13 +124,7 @@ dixRegisterPrivateDeleteFunc(devprivate_
 			     CallbackProcPtr callback, pointer userdata);
 
 /*
- * Allocates all pre-requested private space in one chunk.
- */
-extern PrivateRec *
-dixAllocatePrivates(RESTYPE type, pointer parent);
-
-/*
- * Frees any private space that is not part of an object.
+ * Frees private data.
  */
 extern void
 dixFreePrivates(PrivateRec *privates);
diff-tree c45f6762080ef00b41d9f73441a9f0e605253008 (from aaef4d6a4121d9341b670a0ce8fabc3b491049cf)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Wed Mar 7 11:22:42 2007 -0500

    devPrivates rework: hook up new mechanism in backwards-compatibility mode
    on existing structures that support devPrivates.

diff --git a/dix/devices.c b/dix/devices.c
index 9f42184..2e04403 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -124,8 +124,15 @@ AddInputDevice(DeviceProc deviceProc, Bo
 #ifdef XKB
     dev->xkb_interest = NULL;
 #endif
-    dev->nPrivates = 0;
-    dev->devPrivates = NULL;
+    /* must pre-allocate one private for the new devPrivates support */
+    dev->nPrivates = 1;
+    dev->devPrivates = (DevUnion *)xalloc(sizeof(DevUnion));
+    if (!dev->devPrivates) {
+	xfree(dev);
+	return NULL;
+    }
+    dev->devPrivates[0].ptr = NULL;
+
     dev->unwrapProc = NULL;
     dev->coreEvents = TRUE;
     dev->inited = FALSE;
diff --git a/dix/main.c b/dix/main.c
index c40dfdd..852cbcb 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -715,18 +715,28 @@ AddScreen(
 	xfree(pScreen);
 	return -1;
     }
+
+    /* must pre-allocate one private for the new devPrivates support */
+    pScreen->WindowPrivateLen = 1;
+    pScreen->WindowPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
+    pScreen->totalWindowSize = PadToLong(sizeof(WindowRec)) + sizeof(DevUnion);
+    pScreen->GCPrivateLen = 1;
+    pScreen->GCPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
+    pScreen->totalGCSize = PadToLong(sizeof(GC)) + sizeof(DevUnion);
+    pScreen->PixmapPrivateLen = 1;
+    pScreen->PixmapPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
+    pScreen->totalPixmapSize = BitmapBytePad(8 * (sizeof(PixmapRec) +
+						  sizeof(DevUnion)));
+    if (pScreen->WindowPrivateSizes && pScreen->GCPrivateSizes &&
+	pScreen->PixmapPrivateSizes)
+	*pScreen->WindowPrivateSizes = *pScreen->GCPrivateSizes =
+	    *pScreen->PixmapPrivateSizes = 0;
+    else {
+	xfree(pScreen);
+	return -1;
+    }
+
     pScreen->myNum = i;
-    pScreen->WindowPrivateLen = 0;
-    pScreen->WindowPrivateSizes = (unsigned *)NULL;
-    pScreen->totalWindowSize =
-        ((sizeof(WindowRec) + sizeof(long) - 1) / sizeof(long)) * sizeof(long);
-    pScreen->GCPrivateLen = 0;
-    pScreen->GCPrivateSizes = (unsigned *)NULL;
-    pScreen->totalGCSize =
-        ((sizeof(GC) + sizeof(long) - 1) / sizeof(long)) * sizeof(long);
-    pScreen->PixmapPrivateLen = 0;
-    pScreen->PixmapPrivateSizes = (unsigned *)NULL;
-    pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8);
     pScreen->ClipNotify = 0;	/* for R4 ddx compatibility */
     pScreen->CreateScreenResources = 0;
     
diff --git a/dix/privates.c b/dix/privates.c
index 48ba675..57da0fa 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -279,8 +279,8 @@ dixLookupPrivateOffset(RESTYPE type)
 /*
  * Called from the main loop to reset the subsystem.
  */
-static void ResetExtensionPrivates(void);
-static void ResetClientPrivates(void);
+static int ResetExtensionPrivates(void);
+static int ResetClientPrivates(void);
 static void ResetScreenPrivates(void);
 static void ResetWindowPrivates(void);
 static void ResetGCPrivates(void);
@@ -307,8 +307,8 @@ dixResetPrivates(void)
 	return FALSE;
 
     /* reset legacy devPrivates support */
-    ResetExtensionPrivates();
-    ResetClientPrivates();
+    if (!ResetExtensionPrivates() || !ResetClientPrivates())
+	return FALSE;
     ResetScreenPrivates();
     ResetWindowPrivates();
     ResetGCPrivates();
@@ -317,10 +317,14 @@ dixResetPrivates(void)
     ResetDevicePrivateIndex();
 
     /* register basic resource offsets */
-    if (!dixRegisterPrivateOffset(RT_WINDOW, offsetof(WindowRec,devPrivates)))
-	return FALSE;
-
-    return TRUE;
+    return dixRegisterPrivateOffset(RT_WINDOW,
+				    offsetof(WindowRec, devPrivates)) &&
+	dixRegisterPrivateOffset(RT_PIXMAP,
+				 offsetof(PixmapRec, devPrivates)) &&
+	dixRegisterPrivateOffset(RT_GC,
+				 offsetof(GC, devPrivates)) &&
+	dixRegisterPrivateOffset(RT_COLORMAP,
+				 offsetof(ColormapRec, devPrivates));
 }
 
 /*
@@ -343,15 +347,18 @@ int extensionPrivateLen;
 unsigned *extensionPrivateSizes;
 unsigned totalExtensionSize;
 
-static void
+static int
 ResetExtensionPrivates()
 {
-    extensionPrivateCount = 0;
-    extensionPrivateLen = 0;
+    extensionPrivateCount = 1;
+    extensionPrivateLen = 1;
     xfree(extensionPrivateSizes);
-    extensionPrivateSizes = (unsigned *)NULL;
-    totalExtensionSize =
-	((sizeof(ExtensionEntry) + sizeof(long) - 1) / sizeof(long)) * sizeof(long);
+    extensionPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
+    if (!extensionPrivateSizes)
+	return FALSE;
+    *extensionPrivateSizes = 0;
+    totalExtensionSize = PadToLong(sizeof(ExtensionEntry)) + sizeof(DevUnion);
+    return TRUE;
 }
 
 _X_EXPORT int
@@ -400,15 +407,18 @@ int clientPrivateLen;
 unsigned *clientPrivateSizes;
 unsigned totalClientSize;
 
-static void
+static int
 ResetClientPrivates()
 {
-    clientPrivateCount = 0;
-    clientPrivateLen = 0;
+    clientPrivateCount = 1;
+    clientPrivateLen = 1;
     xfree(clientPrivateSizes);
-    clientPrivateSizes = (unsigned *)NULL;
-    totalClientSize =
-	((sizeof(ClientRec) + sizeof(long) - 1) / sizeof(long)) * sizeof(long);
+    clientPrivateSizes = (unsigned *)xalloc(sizeof(unsigned));
+    if (!clientPrivateSizes)
+	return FALSE;
+    *clientPrivateSizes = 0;
+    totalClientSize = PadToLong(sizeof(ClientRec)) + sizeof(DevUnion);
+    return TRUE;
 }
 
 _X_EXPORT int
@@ -457,7 +467,7 @@ int  screenPrivateCount;
 static void
 ResetScreenPrivates()
 {
-    screenPrivateCount = 0;
+    screenPrivateCount = 1;
 }
 
 /* this can be called after some screens have been created,
@@ -499,7 +509,7 @@ static int  windowPrivateCount;
 static void
 ResetWindowPrivates()
 {
-    windowPrivateCount = 0;
+    windowPrivateCount = 1;
 }
 
 _X_EXPORT int
@@ -549,7 +559,7 @@ static int  gcPrivateCount;
 static void
 ResetGCPrivates()
 {
-    gcPrivateCount = 0;
+    gcPrivateCount = 1;
 }
 
 _X_EXPORT int
@@ -598,7 +608,7 @@ static int  pixmapPrivateCount;
 static void
 ResetPixmapPrivates()
 {
-    pixmapPrivateCount = 0;
+    pixmapPrivateCount = 1;
 }
 
 _X_EXPORT int
@@ -649,7 +659,7 @@ int  colormapPrivateCount;
 static void
 ResetColormapPrivates()
 {
-    colormapPrivateCount = 0;
+    colormapPrivateCount = 1;
 }
 
 
@@ -734,5 +744,5 @@ AllocateDevicePrivate(DeviceIntPtr devic
 static void
 ResetDevicePrivateIndex(void)
 {
-    devicePrivateIndex = 0;
+    devicePrivateIndex = 1;
 }
diff --git a/include/privates.h b/include/privates.h
index 898fdd9..9c95350 100644
--- a/include/privates.h
+++ b/include/privates.h
@@ -31,6 +31,13 @@ typedef struct _Private {
 } PrivateRec;
 
 /*
+ * Backwards compatibility macro.  Use to get the proper PrivateRec
+ * reference from any of the structure types that supported the old
+ * devPrivates mechanism.
+ */
+#define DEVPRIV_PTR(foo) ((PrivateRec **)(&(foo)->devPrivates[0].ptr))
+
+/*
  * Request pre-allocated private space for your driver/module.
  * A non-null pScreen argument restricts to objects on a given screen.
  */
@@ -156,4 +163,7 @@ dixLookupPrivateOffset(RESTYPE type);
 extern int
 dixRegisterPrivateOffset(RESTYPE type, unsigned offset);
 
+/* Used by the legacy support, don't rely on this being here */
+#define PadToLong(w) ((((w) + sizeof(long)-1) / sizeof(long)) * sizeof(long))
+
 #endif /* PRIVATES_H */
diff-tree aaef4d6a4121d9341b670a0ce8fabc3b491049cf (from bb111291d854b4329e47367ce3c67e8a2785e6e9)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Wed Mar 7 09:57:02 2007 -0500

    devPrivates rework: move reset functions into a single call.

diff --git a/dix/main.c b/dix/main.c
index eb75cf5..c40dfdd 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -359,15 +359,7 @@ main(int argc, char *argv[], char *envp[
 	InitGlyphCaching();
 	if (!dixResetPrivates())
 	    FatalError("couldn't init private data storage");
-	ResetExtensionPrivates();
-	ResetClientPrivates();
-	ResetScreenPrivates();
-	ResetWindowPrivates();
-	ResetGCPrivates();
-	ResetPixmapPrivates();
-	ResetColormapPrivates();
 	ResetFontPrivateIndex();
-	ResetDevicePrivateIndex();
 	InitCallbackManager();
 	InitVisualWrap();
 	InitOutput(&screenInfo, argc, argv);
diff --git a/dix/privates.c b/dix/privates.c
index 0722d9f..48ba675 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -279,6 +279,15 @@ dixLookupPrivateOffset(RESTYPE type)
 /*
  * Called from the main loop to reset the subsystem.
  */
+static void ResetExtensionPrivates(void);
+static void ResetClientPrivates(void);
+static void ResetScreenPrivates(void);
+static void ResetWindowPrivates(void);
+static void ResetGCPrivates(void);
+static void ResetPixmapPrivates(void);
+static void ResetColormapPrivates(void);
+static void ResetDevicePrivateIndex(void);
+
 int
 dixResetPrivates(void)
 {
@@ -297,6 +306,16 @@ dixResetPrivates(void)
     if (!offsets)
 	return FALSE;
 
+    /* reset legacy devPrivates support */
+    ResetExtensionPrivates();
+    ResetClientPrivates();
+    ResetScreenPrivates();
+    ResetWindowPrivates();
+    ResetGCPrivates();
+    ResetPixmapPrivates();
+    ResetColormapPrivates();
+    ResetDevicePrivateIndex();
+
     /* register basic resource offsets */
     if (!dixRegisterPrivateOffset(RT_WINDOW, offsetof(WindowRec,devPrivates)))
 	return FALSE;
@@ -324,7 +343,7 @@ int extensionPrivateLen;
 unsigned *extensionPrivateSizes;
 unsigned totalExtensionSize;
 
-void
+static void
 ResetExtensionPrivates()
 {
     extensionPrivateCount = 0;
@@ -381,7 +400,7 @@ int clientPrivateLen;
 unsigned *clientPrivateSizes;
 unsigned totalClientSize;
 
-void
+static void
 ResetClientPrivates()
 {
     clientPrivateCount = 0;
@@ -435,7 +454,7 @@ AllocateClientPrivate(int index2, unsign
 
 int  screenPrivateCount;
 
-void
+static void
 ResetScreenPrivates()
 {
     screenPrivateCount = 0;
@@ -477,7 +496,7 @@ AllocateScreenPrivateIndex()
 
 static int  windowPrivateCount;
 
-void
+static void
 ResetWindowPrivates()
 {
     windowPrivateCount = 0;
@@ -527,7 +546,7 @@ AllocateWindowPrivate(register ScreenPtr
 
 static int  gcPrivateCount;
 
-void
+static void
 ResetGCPrivates()
 {
     gcPrivateCount = 0;
@@ -576,7 +595,7 @@ AllocateGCPrivate(register ScreenPtr pSc
  */
 static int  pixmapPrivateCount;
 
-void
+static void
 ResetPixmapPrivates()
 {
     pixmapPrivateCount = 0;
@@ -627,7 +646,7 @@ AllocatePixmapPrivate(register ScreenPtr
 
 int  colormapPrivateCount;
 
-void
+static void
 ResetColormapPrivates()
 {
     colormapPrivateCount = 0;
@@ -712,7 +731,7 @@ AllocateDevicePrivate(DeviceIntPtr devic
     }
 }
 
-void
+static void
 ResetDevicePrivateIndex(void)
 {
     devicePrivateIndex = 0;
diff --git a/include/dix.h b/include/dix.h
index 5c2c5b8..13f3c05 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -591,8 +591,6 @@ void
 ScreenRestructured (ScreenPtr pScreen);
 #endif
 
-extern void ResetClientPrivates(void);
-
 extern int AllocateClientPrivateIndex(void);
 
 extern Bool AllocateClientPrivate(
diff --git a/include/extension.h b/include/extension.h
index 74975c5..27decc1 100644
--- a/include/extension.h
+++ b/include/extension.h
@@ -58,8 +58,6 @@ extern Bool EnableDisableExtension(char 
 
 extern void EnableDisableExtensionError(char *name, Bool enable);
 
-extern void ResetExtensionPrivates(void);
-
 extern int AllocateExtensionPrivateIndex(void);
 
 extern Bool AllocateExtensionPrivate(
diff --git a/include/input.h b/include/input.h
index fc607d3..2350a24 100644
--- a/include/input.h
+++ b/include/input.h
@@ -160,7 +160,6 @@ typedef struct {
 
 extern int AllocateDevicePrivateIndex(void);
 extern Bool AllocateDevicePrivate(DeviceIntPtr device, int index);
-extern void ResetDevicePrivateIndex(void);
 
 extern KeybdCtrl	defaultKeyboardControl;
 extern PtrCtrl		defaultPointerControl;
diff --git a/include/screenint.h b/include/screenint.h
index 1f1434a..bf8da44 100644
--- a/include/screenint.h
+++ b/include/screenint.h
@@ -55,12 +55,8 @@ typedef struct _Visual *VisualPtr;
 typedef struct _Depth  *DepthPtr;
 typedef struct _Screen *ScreenPtr;
 
-extern void ResetScreenPrivates(void);
-
 extern int AllocateScreenPrivateIndex(void);
 
-extern void ResetWindowPrivates(void);
-
 extern int AllocateWindowPrivateIndex(void);
 
 extern Bool AllocateWindowPrivate(
@@ -68,8 +64,6 @@ extern Bool AllocateWindowPrivate(
     int /* index */,
     unsigned /* amount */);
 
-extern void ResetGCPrivates(void);
-
 extern int AllocateGCPrivateIndex(void);
 
 extern Bool AllocateGCPrivate(
@@ -86,8 +80,6 @@ extern int AddScreen(
     int /*argc*/,
     char** /*argv*/);
 
-extern void ResetPixmapPrivates(void);
-
 extern int AllocatePixmapPrivateIndex(void);
 
 extern Bool AllocatePixmapPrivate(
@@ -95,8 +87,6 @@ extern Bool AllocatePixmapPrivate(
     int /* index */,
     unsigned /* amount */);
 
-extern void ResetColormapPrivates(void);
-
 
 typedef struct _ColormapRec *ColormapPtr;
 typedef int (*InitCmapPrivFunc)(ColormapPtr, int);
diff-tree bb111291d854b4329e47367ce3c67e8a2785e6e9 (from parents)
Merge: 74175e0af74c530cb712a6772d3c5d61d1be9748 e9bfb2b3d7dfaafd90d2ad0fa3d0e1acced4380b
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Wed Mar 7 09:03:46 2007 -0500

    Merge branch 'master' into XACE-SELINUX

diff-tree e9bfb2b3d7dfaafd90d2ad0fa3d0e1acced4380b (from 72a23d88d73a8c72ed18847b004db05092d3e7be)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Tue Mar 6 23:19:30 2007 -0800

    Add hw/xfree86/docs/README.modes, documenting new mode setting APIs.
    
    This document covers both API and xorg.conf usage of the new mode setting
    APIs.
    (cherry picked from commit a59c31b0f7b94ed1f395c7586c37ef5fe7ba2a25)

diff --git a/hw/xfree86/doc/README.modes b/hw/xfree86/doc/README.modes
new file mode 100644
index 0000000..894e213
--- /dev/null
+++ b/hw/xfree86/doc/README.modes
@@ -0,0 +1,474 @@
+		    Multi-monitor Mode Setting APIs
+	           Keith Packard, <keithp at keithp.com
+		   	   6 March 2007
+
+1. Introduction
+
+This document describes a set of mode setting APIs added in X server version
+1.3 that support multiple monitors per card. These interfaces expose the
+underlying hardware CRTC and output concepts to the xf86 DDX layer so that
+the implementation of initial server setup and mode changes through
+extensions can be shared across drivers. In addition, these new interfaces
+support a new configuration mechanism as well which allows each monitor to
+be customized separately providing a consistent cross-driver configuration
+mechanism that supports the full range of output features.
+
+All of the code implementing this interface can be found in hw/xfree86/modes
+in the X server sources.
+
+2. Overview
+
+This document describes both the driver API and the configuration data
+placed in xorg.conf; these are entirely separate as the driver has no
+interaction with the configuration information at all. Much of the structure
+here is cloned from the RandR extension version 1.2 additions which deal
+with the same kinds of information.
+
+2.1 API overview
+
+The mode setting API is expressed through two new driver-visible objects,
+the 'CRTC' (xf86CrtcRec) and the 'Output' (xf86OutputRec). A CRTC refers to
+hardware within the video system that can scan a subset of the framebuffer
+and generate a video signal. An Output receives that signal and transmits it
+to a monitor, projector or other device.
+
+The xf86CrtcRec and xf86OutputRec contain a small amount of state data
+related to the object along with a pointer to a set of functions provided by
+the driver that manipulate the object in fairly simple ways.
+
+To emulate older behaviour, one of the outputs is picked as the 'compat'
+output; this output changes over time as outputs are detected and used, the
+goal is to always have one 'special' output which is used for operations
+which need a single defined monitor (like XFree86-VidModeExtension mode
+setting, RandR 1.1 mode setting, DDC property setting, etc.).
+
+2.1.1 Output overview 
+
+As outputs are connected to monitors, they hold a list of modes supported by
+the monitor. If the monitor and output support DDC, then the list of modes
+generally comes from the EDID data in the monitor. Otherwise, the server
+uses the standard VESA modes, pruned by monitor timing. If the configuration
+file doesn't contain monitor timing data, the server uses default timing
+information which supports 640x480, 800x600 and 1024x768 all with a 60Hz
+refresh rate.
+
+As hardware often limits possible configuration combinations, each output
+knows the set of CRTCs that it can be connected to as well as the set of
+other outputs which can be simutaneously connected to a CRTC.
+
+2.1.2 CRTC overview
+
+CRTCs serve only to stream frame buffer data to outputs using a mode line.
+Ideally, they would not be presented to the user at all, and in fact the
+configuration file doesn't expose them. The RandR 1.2 protocol does, but the
+hope there is that client-side applications will hide them carefully away.
+
+Each crtc has an associated cursor, along with the current configuration.
+All of the data needed to determine valid configurations is contained within
+the Outputs.
+
+2.2 Configuration overview
+
+As outputs drive monitors, the "Monitor" section has been repurposed to
+define their configuration. This provides for a bit more syntax than
+the large list of driver-specific options that were used in the past for
+similar configuration.
+
+However, the existing "Monitor" section referenced by the active "Screen"
+section no longer has any use at all; some sensible meaning for this
+parameter is needed now that a Screen can have multiple Monitors.
+
+3. Public Functions
+
+3.1 PreInit functions
+
+These functions should be used during the driver PreInit phase, they are
+arranged in the order they should be invoked.
+
+    void
+    xf86CrtcConfigInit (ScrnInfoPtr			scrn
+			const xf86CrtcConfigFuncsRec	*funcs)
+
+This function allocates and initializes structures needed to track CRTC and
+Output state.
+
+    void
+    xf86CrtcSetSizeRange (ScrnInfoPtr scrn,
+			  int minWidth, int minHeight,
+			  int maxWidth, int maxHeight)
+
+This sets the range of screen sizes supported by the driver.
+
+    xf86CrtcPtr
+    xf86CrtcCreate (ScrnInfoPtr             scrn,
+		    const xf86CrtcFuncsRec  *funcs)
+    
+Create one CRTC object. See the discussion below for a description of the
+contents of the xf86CrtcFuncsRec. Note that this is done in PreInit, so it
+should not be re-invoked at each server generation. Create one of these for
+each CRTC present in the hardware.
+    
+    xf86OutputPtr
+    xf86OutputCreate (ScrnInfoPtr              scrn,
+		      const xf86OutputFuncsRec *funcs,
+		      const char	       *name)
+
+Create one Output object. See the discussion below for a description of the
+contents of the xf86OutputFuncsRec. This is also called from PreInit and
+need not be re-invoked at each ScreenInit time. An Output should be created
+for every Output present in the hardware, not just for outputs which have
+detected monitors.
+    
+    Bool
+    xf86OutputRename (xf86OutputPtr output, const char *name)
+
+If necessary, the name of an output can be changed after it is created using
+this function.
+    
+    Bool
+    xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
+
+Using the resources provided, and the configuration specified by the user,
+this function computes an initial configuration for the server. It tries to
+enable as much hardware as possible using some fairly simple heuristics. 
+
+The 'canGrow' parameter indicates that the frame buffer does not have a fixed
+size (fixed size frame buffers are required by XAA). When the frame buffer
+has a fixed size, the configuration selects a 'reasonablely large' frame
+buffer so that common reconfiguration options are possible. For resizable
+frame buffers, the frame buffer is set to the smallest size that encloses
+the desired configuration.
+    
+3.2 ScreenInit functions
+
+These functions should be used during the driver ScreenInit phase.
+
+    Bool
+    xf86DiDGAInit (ScreenPtr screen, unsigned long dga_address)
+
+This function provides driver-independent accelerated DGA support for some
+of the DGA operations; using this, the driver can avoid needing to implement
+any of the rest of DGA.
+
+    Bool
+    xf86SaveScreen(ScreenPtr pScreen, int mode)
+
+Stick this in pScreen->SaveScreen and the core X screen saver will be
+implemented by disabling outputs and crtcs using their dpms functions.
+
+    void
+    xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags)
+
+Pass this function to xf86DPMSInit and all DPMS mode switching will be
+managed by using the dpms functions provided by the Outputs and CRTCs.
+
+    Bool
+    xf86CrtcScreenInit (ScreenPtr screen)
+
+This function completes the screen initialization process for the crtc and
+output objects. Call it near the end of the ScreenInit function, after the
+frame buffer and acceleration layers have been added.
+
+3.3 EnterVT functions
+
+Functions used during EnterVT, or whenever the current configuration needs
+to be applied to the hardware.
+
+    Bool
+    xf86SetDesiredModes (ScrnInfoPtr scrn)
+
+xf86InitialConfiguration selects the desired configuration at PreInit time;
+when the server finally hits ScreenInit, xf86SetDesiredModes is used by the
+driver to take that configuration and apply it to the hardware. In addition,
+successful mode selection at other times updates the configuration that will
+be used by this function, so LeaveVT/EnterVT pairs can simply invoke this
+and return to the previous configuration.
+
+3.4 SwitchMode functions
+
+Functions called from the pScrn->SwitchMode hook, which is used by the
+XFree86-VidModeExtension and the keypad mode switch commands.
+
+    Bool
+    xf86SetSingleMode (ScrnInfoPtr	scrn, 
+		       DisplayModePtr   desired,
+		       Rotation		rotation)
+
+This function applies the specified mode to all active outputs. Which is to
+say, it picks reasonable modes for all active outputs, attempting to get the
+screen to the specified size while not breaking anything that is currently
+working.
+
+3.7 get_modes functions
+
+Functions called during output->get_modes to help build lists of modes
+
+    xf86MonPtr
+    xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus)
+
+This returns the EDID data structure for the 'output' using the I2C bus
+'pDDCBus'. This has no effect on 'output' itself.
+
+    void
+    xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon)
+
+Once the EDID data has been fetched, this call applies the EDID data to the
+output object, setting the physical size and also various properties, like
+the DDC root window property (when output is the 'compat' output), and the
+RandR 1.2 EDID output properties.
+
+    DisplayModePtr
+    xf86OutputGetEDIDModes (xf86OutputPtr output)
+
+Given an EDID data structure, this function computes a list of suitable
+modes. This function also applies a sequence of 'quirks' during this process
+so that the returned modes may not actually match the mode data present in
+the EDID data.
+
+3.6 Other functions
+
+These remaining functions in the API can be used by the driver as needed.
+
+    Bool
+    xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
+		     int x, int y)
+
+Applies a mode to a CRTC. All of the outputs which are currently using the
+specified CRTC are included in the mode setting process. 'x' and 'y' are the
+offset within the frame buffer that the crtc is placed at. No checking is
+done in this function to ensure that the mode is usable by the active
+outputs.
+    
+    void
+    xf86ProbeOutputModes (ScrnInfoPtr pScrn, int maxX, int maxY)
+
+This discards the mode lists for all outputs, re-detects monitor presence
+and then acquires new mode lists for all monitors which are not disconnected.
+Monitor configuration data is used to modify the mode lists returned by the
+outputs. 'maxX' and 'maxY' limit the maximum size modes that will be
+returned.
+    
+    void
+    xf86SetScrnInfoModes (ScrnInfoPtr pScrn)
+
+This copies the 'compat' output mode list into the pScrn modes list which is
+used by the XFree86-VidModeExtension and the keypad mode switching
+operations. The current 'desired' mode for the CRTC associated with the
+'compat' output is placed first in this list to indicate the current mode.
+Usually, the driver won't need to call this function as
+xf86InitialConfiguration will do so automatically, as well as any RandR
+functions which reprobe for modes. However, if the driver reprobes for modes
+at other times using xf86ProbeOutputModes, this function needs to be called.
+    
+    Bool
+    xf86DiDGAReInit (ScreenPtr pScreen)
+
+This is similar to xf86SetScrnInfoModes, but it applies the 'compat' output
+mode list to the set of modes advertised by the DGA extension; it needs to
+be called whenever xf86ProbeOutputModes is invoked.
+
+    void
+    xf86DisableUnusedFunctions(ScrnInfoPtr pScrn)
+
+After any sequence of calls using xf86CrtcSetMode, this function cleans up
+any leftover Output and CRTC objects by disabling them, saving power. It is
+safe to call this whenever the server is running as it only disables objects
+which are not currently in use.
+    
+4. CRTC operations
+
+4.1 CRTC functions
+
+These functions provide an abstract interface for the CRTC object; most
+manipulation of the CRTC object is done through these functions.
+
+    void
+    crtc->funcs->dpms (xf86CrtcPtr crtc, int mode)
+
+Where 'mode' is one of DPMSModeOff, DPMSModeSuspend, DPMSModeStandby or
+DPMSModeOn. This requests that the crtc go to the specified power state.
+When changing power states, the output dpms functions are invoked before the
+crtc dpms functions.
+
+    void
+    crtc->funcs->save (xf86CrtcPtr crtc)
+	
+    void
+    crtc->funcs->restore (xf86CrtcPtr crtc)
+
+Preserve/restore any register contents related to the CRTC. These are
+strictly a convenience for the driver writer; if the existing driver has
+fully operation save/restore functions, you need not place any additional
+code here. In particular, the server itself never uses this function.
+
+    Bool
+    crtc->funcs->lock (xf86CrtcPtr crtc)
+	
+    void
+    crtc->funcs->unlock (xf86CrtcPtr crtc)
+
+These functions are invoked around mode setting operations; the intent is
+that DRI locking be done here to prevent DRI applications from manipulating
+the hardware while the server is busy changing the output configuration. If
+the lock function returns FALSE, the unlock function will not be invoked.
+
+    Bool
+    crtc->funcs->mode_fixup (xf86CrtcPtr crtc, 
+			     DisplayModePtr mode,
+			     DisplayModePtr adjusted_mode)
+
+This call gives the CRTC a chance to see what mode will be set and to
+comment on the mode by changing 'adjusted_mode' as needed. This function
+shall not modify the state of the crtc hardware at all. If the CRTC cannot
+accept this mode, this function may return FALSE.
+
+    void
+    crtc->funcs->prepare (xf86CrtcPtr crtc)
+
+This call is made just before the mode is set to make the hardware ready for
+the operation. A usual function to perform here is to disable the crtc so
+that mode setting can occur with clocks turned off and outputs deactivated.
+
+    void
+    crtc->funcs->mode_set (xf86CrtcPtr crtc,
+			   DisplayModePtr mode,
+			   DisplayModePtr adjusted_mode)
+
+This function applies the specified mode (possibly adjusted by the CRTC
+and/or Outputs).
+
+    void
+    crtc->funcs->commit (xf86CrtcPtr crtc)
+
+Once the mode has been applied to the CRTC and Outputs, this function is
+invoked to let the hardware turn things back on.
+
+    void
+    crtc->funcs->gamma_set (xf86CrtcPtr crtc, CARD16 *red,
+			    CARD16 *green, CARD16 *blue, int size)
+
+This function adjusts the gamma ramps for the specified crtc.
+
+    void *
+    crtc->funcs->shadow_allocate (xf86CrtcPtr crtc, int width, int height)
+
+This function allocates frame buffer space for a shadow frame buffer. When
+allocated, the crtc must scan from the shadow instead of the main frame
+buffer. This is used for rotation. The address returned is passed to the
+shadow_create function. This function should return NULL on failure.
+
+    PixmapPtr
+    crtc->funcs->shadow_create (xf86CrtcPtr crtc, void *data,
+				int width, int height)
+
+This function creates a pixmap object that will be used as a shadow of the
+main frame buffer for CRTCs which are rotated or reflected. 'data' is the
+value returned by shadow_allocate.
+
+    void
+    crtc->funcs->shadow_destroy (xf86CrtcPtr crtc, PixmapPtr pPixmap,
+				 void *data)
+
+Destroys any associated shadow objects. If pPixmap is NULL, then a pixmap
+was not created, but 'data' may still be non-NULL indicating that the shadow
+had been allocated.
+
+    void
+    crtc->funcs->destroy (xf86CrtcPtr crtc)
+
+When a CRTC is destroyed (which only happens in error cases), this function
+can clean up any driver-specific data.
+
+4.2 CRTC fields
+
+The CRTC object is not opaque; there are several fields of interest to the
+driver writer.
+
+    struct _xf86Crtc {
+	/**
+	 * Associated ScrnInfo
+	 */
+	ScrnInfoPtr     scrn;
+    
+	/**
+	 * Active state of this CRTC
+	 *
+	 * Set when this CRTC is driving one or more outputs
+	 */
+	Bool            enabled;
+    
+	/** Track whether cursor is within CRTC range  */
+	Bool            cursorInRange;
+    
+	/** Track state of cursor associated with this CRTC */
+	Bool            cursorShown;
+    
+	/**
+	 * Active mode
+	 *
+	 * This reflects the mode as set in the CRTC currently
+	 * It will be cleared when the VT is not active or
+	 * during server startup
+	 */
+	DisplayModeRec  mode;
+	Rotation        rotation;
+	PixmapPtr       rotatedPixmap;
+	void            *rotatedData;
+    
+	/**
+	 * Position on screen
+	 *
+	 * Locates this CRTC within the frame buffer
+	 */
+	int             x, y;
+    
+	/**
+	 * Desired mode
+	 *
+	 * This is set to the requested mode, independent of
+	 * whether the VT is active. In particular, it receives
+	 * the startup configured mode and saves the active mode
+	 * on VT switch.
+	 */
+	DisplayModeRec  desiredMode;
+	Rotation        desiredRotation;
+	int             desiredX, desiredY;
+    
+	/** crtc-specific functions */
+	const xf86CrtcFuncsRec *funcs;
+    
+	/**
+	 * Driver private
+	 *
+	 * Holds driver-private information
+	 */
+	void            *driver_private;
+    #ifdef RANDR_12_INTERFACE
+	/**
+	 * RandR crtc
+	 *
+	 * When RandR 1.2 is available, this
+	 * points at the associated crtc object
+	 */
+	RRCrtcPtr       randr_crtc;
+    #else
+	void            *randr_crtc;
+    #endif
+    };
+
+    
+5. Output functions.
+
+6. Configuration
+
+Because the configuration file syntax is fixed,
+this was done by creating new "Driver" section options that hook specific
+outputs to specific "Monitor" sections in the file. The option:
+section of the form:
+
+	Option	"monitor-VGA" "My VGA Monitor"
+
+connects the VGA output of this driver to the "Monitor" section with
+Identifier "My VGA Monitor". All of the usual monitor options can now be
+placed in that "Monitor" section and will be applied to the VGA output
+configuration.
diff-tree 72a23d88d73a8c72ed18847b004db05092d3e7be (from 81526232bc0119d2ec7b8590be4f78cf066ae359)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Tue Mar 6 23:15:34 2007 -0800

    Add xf86CrtcScreenInit to share initialization across drivers.
    
    xf86CrtcScreenInit performs initialization that needs to happen at
    ScreenInit time.
    (cherry picked from commit 558a4f5588ad2ec11254e0b5d6ce9515b137369e)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 46515fd..2794496 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -545,6 +545,60 @@ xf86OutputDestroy (xf86OutputPtr output)
     xfree (output);
 }
 
+/*
+ * Called during CreateScreenResources to hook up RandR
+ */
+static Bool
+xf86CrtcCreateScreenResources (ScreenPtr screen)
+{
+    ScrnInfoPtr		scrn = xf86Screens[screen->myNum];
+    xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(scrn);
+
+    screen->CreateScreenResources = config->CreateScreenResources;
+    
+    if (!(*screen->CreateScreenResources)(screen))
+	return FALSE;
+
+    if (!xf86RandR12CreateScreenResources (screen))
+	return FALSE;
+
+    return TRUE;
+}
+
+/*
+ * Called at ScreenInit time to set up
+ */
+Bool
+xf86CrtcScreenInit (ScreenPtr screen)
+{
+    ScrnInfoPtr		scrn = xf86Screens[screen->myNum];
+    xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(scrn);
+    int			c;
+
+    /* Rotation */
+    xf86DrvMsg(scrn->scrnIndex, X_INFO, "RandR 1.2 enabled, ignore the following RandR disabled message.\n");
+    xf86DisableRandR(); /* Disable old RandR extension support */
+    xf86RandR12Init (screen);
+
+    /* support all rotations if every crtc has the shadow alloc funcs */
+    for (c = 0; c < config->num_crtc; c++)
+    {
+	xf86CrtcPtr crtc = config->crtc[c];
+	if (!crtc->funcs->shadow_allocate || !crtc->funcs->shadow_create)
+	    break;
+    }
+    if (c == config->num_crtc)
+	xf86RandR12SetRotations (screen, RR_Rotate_0 | RR_Rotate_90 |
+				 RR_Rotate_180 | RR_Rotate_270);
+    else
+	xf86RandR12SetRotations (screen, RR_Rotate_0);
+    
+    /* Wrap CreateScreenResources so we can initialize the RandR code */
+    config->CreateScreenResources = screen->CreateScreenResources;
+    screen->CreateScreenResources = xf86CrtcCreateScreenResources;
+    return TRUE;
+}
+
 static DisplayModePtr
 xf86DefaultMode (xf86OutputPtr output, int width, int height)
 {
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 062a2db..6152ae4 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -494,6 +494,7 @@ typedef struct _xf86CrtcConfig {
 
     const xf86CrtcConfigFuncsRec *funcs;
 
+    CreateScreenResourcesProcPtr    CreateScreenResources;
 } xf86CrtcConfigRec, *xf86CrtcConfigPtr;
 
 extern int xf86CrtcConfigPrivateIndex;
@@ -525,25 +526,6 @@ xf86CrtcDestroy (xf86CrtcPtr		crtc);
 
 
 /**
- * Allocate a crtc for the specified output
- *
- * Find a currently unused CRTC which is suitable for
- * the specified output
- */
-
-xf86CrtcPtr 
-xf86AllocCrtc (xf86OutputPtr		output);
-
-/**
- * Free a crtc
- *
- * Mark the crtc as unused by any outputs
- */
-
-void
-xf86FreeCrtc (xf86CrtcPtr		crtc);
-
-/**
  * Sets the given video mode on the given crtc
  */
 Bool
@@ -583,6 +565,9 @@ void
 xf86SetScrnInfoModes (ScrnInfoPtr pScrn);
 
 Bool
+xf86CrtcScreenInit (ScreenPtr pScreen);
+
+Bool
 xf86InitialConfiguration (ScrnInfoPtr pScrn, Bool canGrow);
 
 void
diff --git a/hw/xfree86/modes/xf86Rename.h b/hw/xfree86/modes/xf86Rename.h
index eae6d64..9dcfef5 100644
--- a/hw/xfree86/modes/xf86Rename.h
+++ b/hw/xfree86/modes/xf86Rename.h
@@ -31,6 +31,7 @@
 #define xf86CrtcDestroy XF86NAME(xf86CrtcDestroy)
 #define xf86CrtcInUse XF86NAME(xf86CrtcInUse)
 #define xf86CrtcRotate XF86NAME(xf86CrtcRotate)
+#define xf86CrtcScreenInit XF86NAME(xf86CrtcScreenInit)
 #define xf86CrtcSetMode XF86NAME(xf86CrtcSetMode)
 #define xf86CrtcSetSizeRange XF86NAME(xf86CrtcSetSizeRange)
 #define xf86CVTMode XF86NAME(xf86CVTMode)
diff-tree 81526232bc0119d2ec7b8590be4f78cf066ae359 (from a7cd53deb99957dec27a55ffd75e548b322ae0ce)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Tue Mar 6 17:19:11 2007 -0500

    remove PIXPRIV check as this flag is always set.

diff --git a/dix/pixmap.c b/dix/pixmap.c
index a5b7b06..c280a3b 100644
--- a/dix/pixmap.c
+++ b/dix/pixmap.c
@@ -109,7 +109,6 @@ _X_EXPORT PixmapPtr
 AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
 {
     PixmapPtr pPixmap;
-#ifdef PIXPRIV
     char *ptr;
     DevUnion *ppriv;
     unsigned *sizes;
@@ -136,9 +135,6 @@ AllocatePixmap(ScreenPtr pScreen, int pi
         else
 	    ppriv->ptr = (pointer)NULL;
     }
-#else
-    pPixmap = (PixmapPtr)xalloc(sizeof(PixmapRec) + pixDataSize);
-#endif
 
 #ifdef _XSERVER64
     if (pPixmap) {
diff-tree a7cd53deb99957dec27a55ffd75e548b322ae0ce (from 024bbc7cbb924daaf3e305ddfc8e74509acd1e15)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Tue Mar 6 15:32:13 2007 -0500

    remove PIXPRIV checks as this flag is always set.

diff --git a/Xext/shm.c b/Xext/shm.c
index 7cfaa68..ac587be 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -119,9 +119,7 @@ static int pixmapFormat;
 static int shmPixFormat[MAXSCREENS];
 static ShmFuncsPtr shmFuncs[MAXSCREENS];
 static DestroyPixmapProcPtr destroyPixmap[MAXSCREENS];
-#ifdef PIXPRIV
 static int  shmPixmapPrivate;
-#endif
 static ShmFuncs miFuncs = {NULL, miShmPutImage};
 static ShmFuncs fbFuncs = {fbShmCreatePixmap, fbShmPutImage};
 
@@ -237,7 +235,6 @@ ShmExtensionInit(INITARGS)
 	    destroyPixmap[i] = screenInfo.screens[i]->DestroyPixmap;
 	    screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap;
 	}
-#ifdef PIXPRIV
 	shmPixmapPrivate = AllocatePixmapPrivateIndex();
 	for (i = 0; i < screenInfo.numScreens; i++)
 	{
@@ -245,7 +242,6 @@ ShmExtensionInit(INITARGS)
 				       shmPixmapPrivate, 0))
 		return;
 	}
-#endif
       }
     }
     ShmSegType = CreateNewResourceType(ShmDetachSegment);
@@ -299,22 +295,7 @@ ShmDestroyPixmap (PixmapPtr pPixmap)
     if (pPixmap->refcnt == 1)
     {
 	ShmDescPtr  shmdesc;
-#ifdef PIXPRIV
 	shmdesc = (ShmDescPtr) pPixmap->devPrivates[shmPixmapPrivate].ptr;
-#else
-	char	*base = (char *) pPixmap->devPrivate.ptr;
-	
-	if (base != (pointer) (pPixmap + 1))
-	{
-	    for (shmdesc = Shmsegs; shmdesc; shmdesc = shmdesc->next)
-	    {
-		if (shmdesc->addr <= base && base <= shmdesc->addr + shmdesc->size)
-		    break;
-	    }
-	}
-	else
-	    shmdesc = 0;
-#endif
 	if (shmdesc)
 	    ShmDetachSegment ((pointer) shmdesc, pPixmap->drawable.id);
     }
@@ -781,9 +762,7 @@ CreatePmap:
 				shmdesc->addr + stuff->offset);
 
 	if (pMap) {
-#ifdef PIXPRIV
             pMap->devPrivates[shmPixmapPrivate].ptr = (pointer) shmdesc;
-#endif
             shmdesc->refcnt++;
 	    pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 	    pMap->drawable.id = newPix->info[j].id;
@@ -1097,9 +1076,7 @@ CreatePmap:
 			    shmdesc->addr + stuff->offset);
     if (pMap)
     {
-#ifdef PIXPRIV
 	pMap->devPrivates[shmPixmapPrivate].ptr = (pointer) shmdesc;
-#endif
 	shmdesc->refcnt++;
 	pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 	pMap->drawable.id = stuff->pid;
diff --git a/afb/afbpixmap.c b/afb/afbpixmap.c
index 6801960..6a3a485 100644
--- a/afb/afbpixmap.c
+++ b/afb/afbpixmap.c
@@ -102,12 +102,8 @@ afbCreatePixmap(pScreen, width, height, 
 	pPixmap->drawable.height = height;
 	pPixmap->devKind = paddedWidth;
 	pPixmap->refcnt = 1;
-#ifdef PIXPRIV
 	pPixmap->devPrivate.ptr =  datasize ?
 				(pointer)((char *)pPixmap + pScreen->totalPixmapSize) : NULL;
-#else
-	pPixmap->devPrivate.ptr = (pointer)(pPixmap + 1);
-#endif
 	return(pPixmap);
 }
 
diff --git a/cfb/cfbpixmap.c b/cfb/cfbpixmap.c
index d51c518..6fdf3ea 100644
--- a/cfb/cfbpixmap.c
+++ b/cfb/cfbpixmap.c
@@ -96,12 +96,8 @@ cfbCreatePixmap (pScreen, width, height,
     pPixmap->drawable.height = height;
     pPixmap->devKind = paddedWidth;
     pPixmap->refcnt = 1;
-#ifdef PIXPRIV
     pPixmap->devPrivate.ptr = datasize ?
 		(pointer)((char *)pPixmap + pScreen->totalPixmapSize) : NULL;
-#else
-    pPixmap->devPrivate.ptr = (pointer)(pPixmap + 1);
-#endif
     return pPixmap;
 }
 
diff --git a/dix/main.c b/dix/main.c
index 3a77533..92c30b6 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -361,9 +361,7 @@ main(int argc, char *argv[], char *envp[
 	ResetScreenPrivates();
 	ResetWindowPrivates();
 	ResetGCPrivates();
-#ifdef PIXPRIV
 	ResetPixmapPrivates();
-#endif
 	ResetColormapPrivates();
 	ResetFontPrivateIndex();
 	ResetDevicePrivateIndex();
@@ -731,11 +729,9 @@ AddScreen(
     pScreen->GCPrivateSizes = (unsigned *)NULL;
     pScreen->totalGCSize =
         ((sizeof(GC) + sizeof(long) - 1) / sizeof(long)) * sizeof(long);
-#ifdef PIXPRIV
     pScreen->PixmapPrivateLen = 0;
     pScreen->PixmapPrivateSizes = (unsigned *)NULL;
     pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8);
-#endif
     pScreen->ClipNotify = 0;	/* for R4 ddx compatibility */
     pScreen->CreateScreenResources = 0;
     
@@ -799,9 +795,7 @@ FreeScreen(ScreenPtr pScreen)
 {
     xfree(pScreen->WindowPrivateSizes);
     xfree(pScreen->GCPrivateSizes);
-#ifdef PIXPRIV
     xfree(pScreen->PixmapPrivateSizes);
-#endif
     xfree(pScreen->devPrivates);
     xfree(pScreen);
 }
diff --git a/dix/privates.c b/dix/privates.c
index b20a1db..a61c3cb 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -309,7 +309,6 @@ AllocateGCPrivate(register ScreenPtr pSc
 /*
  *  pixmap private machinery
  */
-#ifdef PIXPRIV
 static int  pixmapPrivateCount;
 
 void
@@ -355,7 +354,6 @@ AllocatePixmapPrivate(register ScreenPtr
     pScreen->totalPixmapSize = BitmapBytePad(pScreen->totalPixmapSize * 8);
     return TRUE;
 }
-#endif
 
 
 /*
diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c
index c2ddcb0..18c1204 100644
--- a/fb/fbpixmap.c
+++ b/fb/fbpixmap.c
@@ -43,11 +43,7 @@ fbCreatePixmapBpp (ScreenPtr pScreen, in
     if (paddedWidth / 4 > 32767 || height > 32767)
 	return NullPixmap;
     datasize = height * paddedWidth;
-#ifdef PIXPRIV
     base = pScreen->totalPixmapSize;
-#else
-    base = sizeof (PixmapRec);
-#endif
     adjust = 0;
     if (base & 7)
 	adjust = 8 - (base & 7);
diff --git a/hw/dmx/dmxpixmap.c b/hw/dmx/dmxpixmap.c
index 4a669fd..9340606 100644
--- a/hw/dmx/dmxpixmap.c
+++ b/hw/dmx/dmxpixmap.c
@@ -49,15 +49,11 @@
 /** Initialize a private area in \a pScreen for pixmap information. */
 Bool dmxInitPixmap(ScreenPtr pScreen)
 {
-#ifdef PIXPRIV
     if (!AllocatePixmapPrivate(pScreen, dmxPixPrivateIndex,
 			       sizeof(dmxPixPrivRec)))
 	return FALSE;
 
     return TRUE;
-#else
-#error Must define PIXPRIV to compile DMX X server
-#endif
 }
 
 /** Create a pixmap on the back-end server. */
diff --git a/hw/dmx/dmxscrinit.c b/hw/dmx/dmxscrinit.c
index 5bfb4df..7c315d8 100644
--- a/hw/dmx/dmxscrinit.c
+++ b/hw/dmx/dmxscrinit.c
@@ -70,9 +70,7 @@ static unsigned long *dmxCursorGeneratio
 
 int dmxGCPrivateIndex;          /**< Private index for GCs       */
 int dmxWinPrivateIndex;         /**< Private index for Windows   */
-#ifdef PIXPRIV
 int dmxPixPrivateIndex;         /**< Private index for Pixmaps   */
-#endif
 int dmxFontPrivateIndex;        /**< Private index for Fonts     */
 int dmxScreenPrivateIndex;      /**< Private index for Screens   */
 int dmxColormapPrivateIndex;    /**< Private index for Colormaps */
@@ -233,14 +231,10 @@ Bool dmxScreenInit(int idx, ScreenPtr pS
 	if (dmxWinPrivateIndex == -1)
 	    return FALSE;
 
-#ifdef PIXPRIV
 	/* Allocate pixmap private index */
 	dmxPixPrivateIndex = AllocatePixmapPrivateIndex();
 	if (dmxPixPrivateIndex == -1)
 	    return FALSE;
-#else
-#error Must define PIXPRIV to compile DMX X server
-#endif
 
 	/* Allocate font private index */
 	dmxFontPrivateIndex = AllocateFontPrivateIndex();
diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c
index 32e0e4f..594bf43 100644
--- a/hw/xfree86/loader/dixsym.c
+++ b/hw/xfree86/loader/dixsym.c
@@ -271,10 +271,8 @@ _X_HIDDEN void *dixLookupTab[] = {
     SYMFUNC(AllocateColormapPrivateIndex)
     SYMFUNC(AllocateDevicePrivateIndex)
     SYMFUNC(AllocateDevicePrivate)
-#ifdef PIXPRIV
     SYMFUNC(AllocatePixmapPrivateIndex)
     SYMFUNC(AllocatePixmapPrivate)
-#endif
     /* resource.c */
     SYMFUNC(AddResource)
     SYMFUNC(ChangeResourceValue)
diff --git a/hw/xfree86/xf4bpp/ppcPixmap.c b/hw/xfree86/xf4bpp/ppcPixmap.c
index 9f4cdc9..9b2defd 100644
--- a/hw/xfree86/xf4bpp/ppcPixmap.c
+++ b/hw/xfree86/xf4bpp/ppcPixmap.c
@@ -120,12 +120,8 @@ xf4bppCreatePixmap( pScreen, width, heig
     pPixmap->devKind = size;
     pPixmap->refcnt = 1 ;
     size = height * pPixmap->devKind ;
-#ifdef PIXPRIV
     pPixmap->devPrivate.ptr = (pointer) (((CARD8*)pPixmap)
 					 + pScreen->totalPixmapSize);
-#else
-    pPixmap->devPrivate.ptr = (pointer) (pPixmap + 1);
-#endif
     bzero( (char *) pPixmap->devPrivate.ptr, size ) ;
     return pPixmap ;
 }
diff --git a/hw/xnest/Pixmap.c b/hw/xnest/Pixmap.c
index aa8bed9..612df8d 100644
--- a/hw/xnest/Pixmap.c
+++ b/hw/xnest/Pixmap.c
@@ -32,9 +32,7 @@ is" without express or implied warranty.
 #include "Screen.h"
 #include "XNPixmap.h"
 
-#ifdef PIXPRIV
 int xnestPixmapPrivateIndex;	    
-#endif
 
 PixmapPtr
 xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth)
@@ -57,12 +55,8 @@ xnestCreatePixmap(ScreenPtr pScreen, int
   pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
   pPixmap->refcnt = 1;
   pPixmap->devKind = PixmapBytePad(width, depth);
-#ifdef PIXPRIV
   pPixmap->devPrivates[xnestPixmapPrivateIndex].ptr =
       (pointer)((char *)pPixmap + pScreen->totalPixmapSize);
-#else
-  pPixmap->devPrivate.ptr = (pointer)(pPixmap + 1);
-#endif
   if (width && height)
       xnestPixmapPriv(pPixmap)->pixmap = 
 	  XCreatePixmap(xnestDisplay, 
diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c
index 8e86efb..e6870e7 100644
--- a/hw/xnest/Screen.c
+++ b/hw/xnest/Screen.c
@@ -49,9 +49,7 @@ Window xnestScreenSaverWindows[MAXSCREEN
 extern void GlxWrapInitVisuals(miInitVisualsProcPtr *);
 #endif
 
-#ifdef PIXPRIV
 int xnestScreenGeneration = -1;
-#endif
 
 ScreenPtr
 xnestScreen(Window window)
@@ -154,7 +152,6 @@ xnestOpenScreen(int index, ScreenPtr pSc
 			    sizeof(xnestPrivGC)))) 
     return False;
 
-#ifdef PIXPRIV
   if (xnestScreenGeneration != serverGeneration) {
       if ((xnestPixmapPrivateIndex = AllocatePixmapPrivateIndex()) < 0)
 	  return False;
@@ -164,7 +161,6 @@ xnestOpenScreen(int index, ScreenPtr pSc
   if (!AllocatePixmapPrivate(pScreen,xnestPixmapPrivateIndex,
 			     sizeof (xnestPrivPixmap)))
       return False;
-#endif
   visuals = (VisualPtr)xalloc(xnestNumVisuals * sizeof(VisualRec));
   numVisuals = 0;
 
diff --git a/hw/xnest/XNPixmap.h b/hw/xnest/XNPixmap.h
index 77cba24..6971b11 100644
--- a/hw/xnest/XNPixmap.h
+++ b/hw/xnest/XNPixmap.h
@@ -15,21 +15,14 @@ is" without express or implied warranty.
 #ifndef XNESTPIXMAP_H
 #define XNESTPIXMAP_H
 
-#ifdef PIXPRIV
 extern int xnestPixmapPrivateIndex;
-#endif
 
 typedef struct {
   Pixmap pixmap;
 } xnestPrivPixmap;
 
-#ifdef PIXPRIV
 #define xnestPixmapPriv(pPixmap) \
   ((xnestPrivPixmap *)((pPixmap)->devPrivates[xnestPixmapPrivateIndex].ptr))
-#else
-#define xnestPixmapPriv(pPixmap) \
-  ((xnestPrivPixmap *)((pPixmap)->devPrivate.ptr))
-#endif
 
 #define xnestPixmap(pPixmap) (xnestPixmapPriv(pPixmap)->pixmap)
 
diff --git a/include/pixmapstr.h b/include/pixmapstr.h
index 628465b..93bd45d 100644
--- a/include/pixmapstr.h
+++ b/include/pixmapstr.h
@@ -86,9 +86,7 @@ typedef struct _Pixmap {
     int			refcnt;
     int			devKind;
     DevUnion		devPrivate;
-#ifdef PIXPRIV
     DevUnion		*devPrivates; /* real devPrivates like gcs & windows */
-#endif
 #ifdef COMPOSITE
     short		screen_x;
     short		screen_y;
diff --git a/include/screenint.h b/include/screenint.h
index e60c248..1f1434a 100644
--- a/include/screenint.h
+++ b/include/screenint.h
@@ -86,8 +86,6 @@ extern int AddScreen(
     int /*argc*/,
     char** /*argv*/);
 
-#ifdef PIXPRIV
-
 extern void ResetPixmapPrivates(void);
 
 extern int AllocatePixmapPrivateIndex(void);
@@ -97,8 +95,6 @@ extern Bool AllocatePixmapPrivate(
     int /* index */,
     unsigned /* amount */);
 
-#endif /* PIXPRIV */
-
 extern void ResetColormapPrivates(void);
 
 
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 3613515..110f4dc 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -558,11 +558,9 @@ typedef struct _Screen {
 
     PixmapPtr pScratchPixmap;		/* scratch pixmap "pool" */
 
-#ifdef PIXPRIV
     int			PixmapPrivateLen;
     unsigned int		*PixmapPrivateSizes;
     unsigned int		totalPixmapSize;
-#endif
 
     MarkWindowProcPtr		MarkWindow;
     MarkOverlappedWindowsProcPtr MarkOverlappedWindows;
diff --git a/mfb/mfbpixmap.c b/mfb/mfbpixmap.c
index 5ec8502..e349724 100644
--- a/mfb/mfbpixmap.c
+++ b/mfb/mfbpixmap.c
@@ -101,12 +101,8 @@ mfbCreatePixmap (pScreen, width, height,
     pPixmap->drawable.height = height;
     pPixmap->devKind = paddedWidth;
     pPixmap->refcnt = 1;
-#ifdef PIXPRIV
     pPixmap->devPrivate.ptr =  datasize ?
 		(pointer)((char *)pPixmap + pScreen->totalPixmapSize) : NULL;
-#else
-    pPixmap->devPrivate.ptr = (pointer)(pPixmap + 1);
-#endif
     return pPixmap;
 }
 
diff-tree 024bbc7cbb924daaf3e305ddfc8e74509acd1e15 (from 9d94c137596d3f9d9118ec70455b7a30b3582046)
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Mar 6 16:18:59 2007 -0800

    Bug #9931: Fix linear allocations with a non-1-byte granularity.
    
    This was introduced in 83080809f9a1c1d24b0318e54632f25f5940da25.  Instead of
    aligning the offset, it doubled it.  Results were appropriately spectacular.

diff --git a/hw/xfree86/common/xf86fbman.c b/hw/xfree86/common/xf86fbman.c
index d64cfae..537d53d 100644
--- a/hw/xfree86/common/xf86fbman.c
+++ b/hw/xfree86/common/xf86fbman.c
@@ -968,7 +968,7 @@ localAllocateOffscreenLinear(
 	linear->size = h * w;
 	linear->offset = (pitch * area->box.y1) + area->box.x1;
 	if (gran > 1)
-            linear->offset += ((linear->offset + gran - 1) / gran) * gran;
+            linear->offset = ((linear->offset + gran - 1) / gran) * gran;
 	linear->granularity = gran;
 	linear->MoveLinearCallback = moveCB;
 	linear->RemoveLinearCallback = removeCB;
diff-tree 9d94c137596d3f9d9118ec70455b7a30b3582046 (from 81d581e655fc989da3be4256b83849a63b8607b7)
Author: Ben Byer <bbyer at apple.com>
Date:   Tue Mar 6 11:09:30 2007 -0800

    updated todo list

diff --git a/hw/darwin/README.apple b/hw/darwin/README.apple
index 68bc692..229ab17 100644
--- a/hw/darwin/README.apple
+++ b/hw/darwin/README.apple
@@ -22,20 +22,14 @@ The server builds 4 targets:
 Known issues:
 
 * AGL and CGL support for 3D indirect acceleration does not work;
-  indirect.c needs to be rewritten.
+  indirect.c has been rewritten, but not yet integrated into this source tree.
 
 * Fullscreen mode does not work; I don't know why.
 
-* The keyboard and mouse do not work at all; they worked in X11R7.1,
-  and I believe that they were broken by the events changes in dix/.
-
 * Some features in X11.app are not yet implemented; these are marked
   with #ifdef DARWIN_DDX_MISSING in the code.
 
 * The build system code could probably be cleaned up slightly.
 
-* Most testing of this code has occurred under 10.5, but it should
-  also work under 10.4.
-
 Any patches or code contributions would be most welcome and may be
 sent to me at bbyer at apple.com.
diff-tree 81d581e655fc989da3be4256b83849a63b8607b7 (from parents)
Merge: a05ffca8dd0da9bdb5c1bf4c481028aeabf21e34 d5aba03feff41722c72b4c6193f09d141cbf1678
Author: Ben Byer <bbyer at bbyer.(none)>
Date:   Tue Mar 6 10:37:29 2007 -0800

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

diff-tree a05ffca8dd0da9bdb5c1bf4c481028aeabf21e34 (from 3206e9225897989638ad553e1f392b918ac4d21f)
Author: Ben Byer <bbyer at bbyer.(none)>
Date:   Tue Mar 6 10:36:51 2007 -0800

    rewrote event handling, Xquartz now has working mouse and keyboard. use it\!

diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index 34c0307..57795f4 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -919,11 +919,7 @@ static void send_nsevent (NSEventType ty
       break;
 
     case NSFlagsChanged:
-      bzero(&xe, sizeof(xe));
-      xe.u.u.type = kXDarwinUpdateModifiers;
-      xe.u.clientMessage.u.l.longs0 = [e modifierFlags];
-      DarwinEQEnqueue (&xe);
-      DarwinPokeEQ();
+      DarwinUpdateModKeys([e modifierFlags]);
       break;
     default: break; /* for gcc */
     }	
diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c
index cb30a90..3d7f268 100644
--- a/hw/darwin/darwinEvents.c
+++ b/hw/darwin/darwinEvents.c
@@ -63,6 +63,8 @@ typedef struct _Event {
 
 int input_check_zero, input_check_flag;
 
+static int old_flags = 0;  // last known modifier state
+
 typedef struct _EventQueue {
     HWEventQueueType    head, tail; /* long for SetInputCheck */
     CARD32      lastEventTime;      /* to avoid time running backwards */
@@ -81,18 +83,15 @@ xEvent *darwinEvents;
  *  Press or release the given modifier key, specified by its mask.
  */
 static void DarwinPressModifierMask(
-    xEvent *xe,     // must already have type, time and mouse location
+    int pressed,				    
     int mask)       // one of NX_*MASK constants
 {
     int key = DarwinModifierNXMaskToNXKey(mask);
 
     if (key != -1) {
         int keycode = DarwinModifierNXKeyToNXKeycode(key, 0);
-        if (keycode != 0) {
-            xe->u.u.detail = keycode + MIN_KEYCODE;
-            (*darwinEventQueue.pKbd->processInputProc)(xe,
-                            (DeviceIntPtr)darwinEventQueue.pKbd, 1);
-        }
+        if (keycode != 0)
+	  DarwinSendKeyboardEvents(pressed, keycode);
     }
 }
 
@@ -125,28 +124,26 @@ static void DarwinPressModifierMask(
  *  Send events to update the modifier state.
  */
 static void DarwinUpdateModifiers(
-    xEvent *xe,         // event template with time and mouse position set
     int pressed,        // KeyPress or KeyRelease
     int flags )         // modifier flags that have changed
 {
-    xe->u.u.type = pressed;
     if (flags & NX_ALPHASHIFTMASK) {
-        DarwinPressModifierMask(xe, NX_ALPHASHIFTMASK);
+        DarwinPressModifierMask(pressed, NX_ALPHASHIFTMASK);
     }
     if (flags & NX_COMMANDMASK) {
-        DarwinPressModifierMask(xe, COMMAND_MASK(flags));
+        DarwinPressModifierMask(pressed, COMMAND_MASK(flags));
     }
     if (flags & NX_CONTROLMASK) {
-        DarwinPressModifierMask(xe, CONTROL_MASK(flags));
+        DarwinPressModifierMask(pressed, CONTROL_MASK(flags));
     }
     if (flags & NX_ALTERNATEMASK) {
-        DarwinPressModifierMask(xe, ALTERNATE_MASK(flags));
+        DarwinPressModifierMask(pressed, ALTERNATE_MASK(flags));
     }
     if (flags & NX_SHIFTMASK) {
-        DarwinPressModifierMask(xe, SHIFT_MASK(flags));
+        DarwinPressModifierMask(pressed, SHIFT_MASK(flags));
     }
     if (flags & NX_SECONDARYFNMASK) {
-        DarwinPressModifierMask(xe, NX_SECONDARYFNMASK);
+        DarwinPressModifierMask(pressed, NX_SECONDARYFNMASK);
     }
 }
 
@@ -163,19 +160,20 @@ static void DarwinUpdateModifiers(
  *  simulate a button 2 press instead of Command-button 2.
  */
 static void DarwinSimulateMouseClick(
-    xEvent *xe,         // event template with time and
-                        // mouse position filled in
+    int pointer_x,
+    int pointer_y,
     int whichButton,    // mouse button to be pressed
     int modifierMask)   // modifiers used for the fake click
 {
     // first fool X into forgetting about the keys
-    DarwinUpdateModifiers(xe, KeyRelease, modifierMask);
+    DarwinUpdateModifiers(KeyRelease, modifierMask);
 
     // push the mouse button
-    xe->u.u.type = ButtonPress;
-    xe->u.u.detail = whichButton;
-    (*darwinEventQueue.pPtr->processInputProc)
-            (xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+    DarwinSendPointerEvents(ButtonPress, whichButton, pointer_x, pointer_y);
+    DarwinSendPointerEvents(ButtonRelease, whichButton, pointer_x, pointer_y);
+
+    // restore old modifiers
+    DarwinUpdateModifiers(KeyPress, modifierMask);
 }
 
 
@@ -234,7 +232,7 @@ void DarwinEQEnqueue(const xEvent *e) {
     darwinEventQueue.tail = newtail;
 
     // Signal there is an event ready to handle
-    write(darwinEventWriteFD, &byte, 1);
+    DarwinPokeEQ();
 }
 
 
@@ -265,8 +263,6 @@ void ProcessInputEvents(void) {
     xEvent  xe;
     static int  old_flags = 0;  // last known modifier state
     // button number and modifier mask of currently pressed fake button
-    static int darwinFakeMouseButtonDown = 0;
-    static int darwinFakeMouseButtonMask = 0;
     input_check_flag=0;
 
     //    ErrorF("calling mieqProcessInputEvents\n");
@@ -318,155 +314,35 @@ void ProcessInputEvents(void) {
                 darwinEventQueue.head = 0;
             else
                 ++darwinEventQueue.head;
-            switch (xe.u.u.type)
-            {
+            switch (xe.u.u.type) {
             case KeyPress:
-                if (old_flags == 0
-                    && darwinSyncKeymap && darwinKeymapFile == NULL)
-                {
-                    /* See if keymap has changed. */
-
-                    static unsigned int last_seed;
-                    unsigned int this_seed;
-
-                    this_seed = DarwinModeSystemKeymapSeed();
-                    if (this_seed != last_seed)
-                    {
-                        last_seed = this_seed;
-                        DarwinKeyboardReload(darwinKeyboard);
-                    }
-                }
-                /* fall through */
-
             case KeyRelease:
-                xe.u.u.detail += MIN_KEYCODE;
-                (*darwinEventQueue.pKbd->processInputProc)
-                    (&xe, (DeviceIntPtr)darwinEventQueue.pKbd, 1);
-                break;
+	      ErrorF("Unexpected Keyboard event in DarwinProcessInputEvents\n");
+	      break;
 
             case ButtonPress:
-                miPointerAbsoluteCursor(xe.u.keyButtonPointer.rootX,
-                                        xe.u.keyButtonPointer.rootY,
-                                        xe.u.keyButtonPointer.time);
-                if (darwinFakeButtons && xe.u.u.detail == 1) {
-                    // Mimic multi-button mouse with modifier-clicks
-                    // If both sets of modifiers are pressed,
-                    // button 2 is clicked.
-                    if ((old_flags & darwinFakeMouse2Mask) ==
-                        darwinFakeMouse2Mask)
-                    {
-                        DarwinSimulateMouseClick(&xe, 2, darwinFakeMouse2Mask);
-                        darwinFakeMouseButtonDown = 2;
-                        darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
-                        break;
-                    }
-                    else if ((old_flags & darwinFakeMouse3Mask) ==
-                             darwinFakeMouse3Mask)
-                    {
-                        DarwinSimulateMouseClick(&xe, 3, darwinFakeMouse3Mask);
-                        darwinFakeMouseButtonDown = 3;
-                        darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
-                        break;
-                    }
-                }
-                (*darwinEventQueue.pPtr->processInputProc)
-                        (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+	      ErrorF("Unexpected ButtonPress event in DarwinProcessInputEvents\n");
                 break;
 
             case ButtonRelease:
-                miPointerAbsoluteCursor(xe.u.keyButtonPointer.rootX,
-                                        xe.u.keyButtonPointer.rootY,
-                                        xe.u.keyButtonPointer.time);
-                if (darwinFakeButtons && xe.u.u.detail == 1 &&
-                    darwinFakeMouseButtonDown)
-                {
-                    // If last mousedown was a fake click, don't check for
-                    // mouse modifiers here. The user may have released the
-                    // modifiers before the mouse button.
-                    xe.u.u.detail = darwinFakeMouseButtonDown;
-                    darwinFakeMouseButtonDown = 0;
-                    (*darwinEventQueue.pPtr->processInputProc)
-                            (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
-
-                    // Bring modifiers back up to date
-                    DarwinUpdateModifiers(&xe, KeyPress,
-                            darwinFakeMouseButtonMask & old_flags);
-                    darwinFakeMouseButtonMask = 0;
-                } else {
-                    (*darwinEventQueue.pPtr->processInputProc)
-                            (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
-                }
+	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
                 break;
 
             case MotionNotify:
-                miPointerAbsoluteCursor(xe.u.keyButtonPointer.rootX,
-                                        xe.u.keyButtonPointer.rootY,
-                                        xe.u.keyButtonPointer.time);
+	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
                 break;
 
             case kXDarwinUpdateModifiers:
-            {
-                // Update modifier state.
-                // Any amount of modifiers may have changed.
-                int flags = xe.u.clientMessage.u.l.longs0;
-                DarwinUpdateModifiers(&xe, KeyRelease,
-                                      old_flags & ~flags);
-                DarwinUpdateModifiers(&xe, KeyPress,
-                                      ~old_flags & flags);
-                old_flags = flags;
-                break;
-            }
+	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
+	      break;
 
             case kXDarwinUpdateButtons:
-            {
-                long hwDelta = xe.u.clientMessage.u.l.longs0;
-                long hwButtons = xe.u.clientMessage.u.l.longs1;
-                int i;
-
-                for (i = 1; i < 5; i++) {
-                    if (hwDelta & (1 << i)) {
-                        // IOKit and X have different numbering for the
-                        // middle and right mouse buttons.
-                        if (i == 1) {
-                            xe.u.u.detail = 3;
-                        } else if (i == 2) {
-                            xe.u.u.detail = 2;
-                        } else {
-                            xe.u.u.detail = i + 1;
-                        }
-                        if (hwButtons & (1 << i)) {
-                            xe.u.u.type = ButtonPress;
-                        } else {
-                            xe.u.u.type = ButtonRelease;
-                        }
-                        (*darwinEventQueue.pPtr->processInputProc)
-                    (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
-                    }
-                }
-                break;
-            }
+	      ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n");
+	      break;
 
-            case kXDarwinScrollWheel:
-            {
-                short count = xe.u.clientMessage.u.s.shorts0;
-
-                if (count > 0) {
-                    xe.u.u.detail = SCROLLWHEELUPFAKE;
-                } else {
-                    xe.u.u.detail = SCROLLWHEELDOWNFAKE;
-                    count = -count;
-                }
-
-                for (; count; --count) {
-                    xe.u.u.type = ButtonPress;
-                    (*darwinEventQueue.pPtr->processInputProc)
-                            (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
-                    xe.u.u.type = ButtonRelease;
-                    (*darwinEventQueue.pPtr->processInputProc)
-                            (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
-                }
-                break;
-            }
+            case kXDarwinScrollWheel: 
+	      ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n");
+	      break;
 
             default:
                 // Check for mode specific event
@@ -475,7 +351,7 @@ void ProcessInputEvents(void) {
         }
     }
 
-    miPointerUpdate();
+    //    miPointerUpdate();
 }
 
 /* Sends a null byte down darwinEventWriteFD, which will cause the
@@ -488,18 +364,58 @@ void DarwinPokeEQ(void) {
 }
 
 void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y) {
-  int i;
+  static int darwinFakeMouseButtonDown = 0;
+  static int darwinFakeMouseButtonMask = 0;
+  int i, num_events;
   int valuators[2] = {pointer_x, pointer_y};
-  int num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, 
-				    POINTER_ABSOLUTE, 0, 2, valuators);
+  if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
+    // Mimic multi-button mouse with modifier-clicks
+    // If both sets of modifiers are pressed,
+    // button 2 is clicked.
+    if ((old_flags & darwinFakeMouse2Mask) == darwinFakeMouse2Mask) {
+      DarwinSimulateMouseClick(pointer_x, pointer_y, 2, darwinFakeMouse2Mask);
+      darwinFakeMouseButtonDown = 2;
+      darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
+    } else if ((old_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) {
+      DarwinSimulateMouseClick(pointer_x, pointer_y, 3, darwinFakeMouse3Mask);
+      darwinFakeMouseButtonDown = 3;
+      darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
+    }
+  }
+  if (ev_type == ButtonRelease && darwinFakeButtons && darwinFakeMouseButtonDown) {
+    // If last mousedown was a fake click, don't check for
+    // mouse modifiers here. The user may have released the
+    // modifiers before the mouse button.
+    ev_button = darwinFakeMouseButtonDown;
+    darwinFakeMouseButtonDown = 0;
+    // Bring modifiers back up to date
+    DarwinUpdateModifiers(KeyPress, darwinFakeMouseButtonMask & old_flags);
+    darwinFakeMouseButtonMask = 0;
+  } 
+
+  num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, 
+				POINTER_ABSOLUTE, 0, 2, valuators);
       
   for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
   DarwinPokeEQ();
 }
 
 void DarwinSendKeyboardEvents(int ev_type, int keycode) {
-  int i;
-  int num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
+  int i, num_events;
+  if (old_flags == 0 && darwinSyncKeymap && darwinKeymapFile == NULL) {
+    /* See if keymap has changed. */
+
+    static unsigned int last_seed;
+    unsigned int this_seed;
+
+    this_seed = DarwinModeSystemKeymapSeed();
+    if (this_seed != last_seed) {
+      last_seed = this_seed;
+      DarwinKeyboardReload(darwinKeyboard);
+    }
+  }
+
+  num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
   for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,&darwinEvents[i]);
   DarwinPokeEQ();
 }
@@ -520,3 +436,11 @@ void DarwinSendScrollEvents(float count,
   }
   DarwinPokeEQ();
 }
+
+/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
+   reflect changing modifier flags (alt, control, meta, etc) */
+void DarwinUpdateModKeys(int flags) {
+  DarwinUpdateModifiers(KeyRelease, old_flags & ~flags);
+  DarwinUpdateModifiers(KeyPress, ~old_flags & flags);
+  old_flags = flags;
+}
diff-tree d5aba03feff41722c72b4c6193f09d141cbf1678 (from 0ccd1443fd6db397b42e5b99ce733ce1316c785e)
Author: Drew Parsons <dparsons at debian.org>
Date:   Tue Mar 6 23:53:23 2007 +1100

    Xprint: shorten font filename to fit in tar length limit
    
    The length of the Xprint font file NewCenturySchlbk-BoldItalic.pmf
    pushes the full path over the traditional 100 character limit for
    tarballs (when module version number is included).  Shorten it to
    NewCentSchlbk-BoldItal.pmf to get back below the limit and rename
    other font files in that family to match.

diff --git a/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am b/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am
index c574c5c..7a7ecc3 100644
--- a/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am
+++ b/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am
@@ -19,10 +19,10 @@ XPFONTS = \
         LubalinGraph-BookOblique.pmf \
         LubalinGraph-Demi.pmf \
         LubalinGraph-DemiOblique.pmf \
-        NewCenturySchlbk-Bold.pmf \
-        NewCenturySchlbk-BoldItalic.pmf \
-        NewCenturySchlbk-Italic.pmf \
-        NewCenturySchlbk-Roman.pmf \
+        NewCentSchlbk-Bold.pmf \
+        NewCentSchlbk-BoldItal.pmf \
+        NewCentSchlbk-Ital.pmf \
+        NewCentSchlbk-Roman.pmf \
         Souvenir-Demi.pmf \
         Souvenir-DemiItalic.pmf \
         Souvenir-Light.pmf \
diff --git a/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am b/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am
index 634db1f..f4f4243 100644
--- a/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am
+++ b/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am
@@ -19,10 +19,10 @@ XPFONTS = \
         LubalinGraph-BookOblique.pmf \
         LubalinGraph-Demi.pmf \
         LubalinGraph-DemiOblique.pmf \
-        NewCenturySchlbk-Bold.pmf \
-        NewCenturySchlbk-BoldItalic.pmf \
-        NewCenturySchlbk-Italic.pmf \
-        NewCenturySchlbk-Roman.pmf \
+        NewCentSchlbk-Bold.pmf \
+        NewCentSchlbk-BoldItal.pmf \
+        NewCentSchlbk-Ital.pmf \
+        NewCentSchlbk-Roman.pmf \
         Souvenir-Demi.pmf \
         Souvenir-DemiItalic.pmf \
         Souvenir-Light.pmf \
diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am b/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am
index 1e8c8a7..40f1e3d 100644
--- a/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am
+++ b/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am
@@ -17,10 +17,10 @@ dist_xpc_DATA =				\
 	LubalinGraph-Book.pmf		\
 	LubalinGraph-DemiOblique.pmf	\
 	LubalinGraph-Demi.pmf		\
-	NewCenturySchlbk-Bold.pmf	\
-	NewCenturySchlbk-BoldItalic.pmf \
-	NewCenturySchlbk-Italic.pmf	\
-	NewCenturySchlbk-Roman.pmf	\
+	NewCentSchlbk-Bold.pmf		\
+	NewCentSchlbk-BoldItal.pmf 	\
+	NewCentSchlbk-Ital.pmf		\
+	NewCentSchlbk-Roman.pmf		\
 	Souvenir-DemiItalic.pmf		\
 	Souvenir-Demi.pmf		\
 	Souvenir-LightItalic.pmf	\
diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-Bold.pmf b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-Bold.pmf
new file mode 100644
index 0000000..ab22aab
Binary files /dev/null and b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-Bold.pmf differ
diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-BoldItal.pmf b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-BoldItal.pmf
new file mode 100644
index 0000000..e68811e
Binary files /dev/null and b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-BoldItal.pmf differ
diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-Ital.pmf b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-Ital.pmf
new file mode 100644
index 0000000..390f223
Binary files /dev/null and b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-Ital.pmf differ
diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-Roman.pmf b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-Roman.pmf
new file mode 100644
index 0000000..655b9b6
Binary files /dev/null and b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-Roman.pmf differ
diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-Bold.pmf b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-Bold.pmf
deleted file mode 100644
index ab22aab..0000000
Binary files a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-Bold.pmf and /dev/null differ
diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-BoldItalic.pmf b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-BoldItalic.pmf
deleted file mode 100644
index e68811e..0000000
Binary files a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-BoldItalic.pmf and /dev/null differ
diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-Italic.pmf b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-Italic.pmf
deleted file mode 100644
index 390f223..0000000
Binary files a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-Italic.pmf and /dev/null differ
diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-Roman.pmf b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-Roman.pmf
deleted file mode 100644
index 655b9b6..0000000
Binary files a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-Roman.pmf and /dev/null differ
diff-tree 3206e9225897989638ad553e1f392b918ac4d21f (from 0ccd1443fd6db397b42e5b99ce733ce1316c785e)
Author: Ben Byer <bbyer at bbyer.(none)>
Date:   Tue Mar 6 02:31:59 2007 -0800

    moved new event-handling code from X11Application.m to darwinEvents.c in preparation for making all Darwin servers use it

diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index cfc9750..34c0307 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -855,48 +855,6 @@ convert_flags (unsigned int nsflags) {
     return xflags;
 }
 
-/* Sends a null byte down darwinEventWriteFD, which will cause the
-   Dispatch() event loop to check out event queue */
-void DarwinPokeEQ(void) {
-  char nullbyte=0;
-  input_check_flag++;
-  //  <daniels> bushing: oh, i ... er ... christ.
-  write(darwinEventWriteFD, &nullbyte, 1);
-}
-
-void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y) {
-  int i;
-  int valuators[2] = {pointer_x, pointer_y};
-  int num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, 
-				    POINTER_ABSOLUTE, 0, 2, valuators);
-      
-  for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
-  DarwinPokeEQ();
-}
-
-void DarwinSendKeyboardEvents(int ev_type, int keycode) {
-  int i;
-  int num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
-  for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,&darwinEvents[i]);
-  DarwinPokeEQ();
-}
-
-/* Send the appropriate number of button 4 / 5 clicks to emulate scroll wheel */
-void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y) {
-  int i;
-  int ev_button = count > 0.0f ? 4 : 5;
-  int valuators[2] = {pointer_x, pointer_y};
-
-  for (count = fabs(count); count > 0.0; count = count - 1.0f) {
-    int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button, 
-				      POINTER_ABSOLUTE, 0, 2, valuators);
-    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
-    num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button, 
-				      POINTER_ABSOLUTE, 0, 2, valuators);
-    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
-  }
-  DarwinPokeEQ();
-}
 
 // This code should probably be merged with that in XDarwin's XServer.m - BB
 static void send_nsevent (NSEventType type, NSEvent *e) {
diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c
index ac03e5a..cb30a90 100644
--- a/hw/darwin/darwinEvents.c
+++ b/hw/darwin/darwinEvents.c
@@ -477,3 +477,46 @@ void ProcessInputEvents(void) {
 
     miPointerUpdate();
 }
+
+/* Sends a null byte down darwinEventWriteFD, which will cause the
+   Dispatch() event loop to check out event queue */
+void DarwinPokeEQ(void) {
+  char nullbyte=0;
+  input_check_flag++;
+  //  <daniels> bushing: oh, i ... er ... christ.
+  write(darwinEventWriteFD, &nullbyte, 1);
+}
+
+void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y) {
+  int i;
+  int valuators[2] = {pointer_x, pointer_y};
+  int num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, 
+				    POINTER_ABSOLUTE, 0, 2, valuators);
+      
+  for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
+  DarwinPokeEQ();
+}
+
+void DarwinSendKeyboardEvents(int ev_type, int keycode) {
+  int i;
+  int num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
+  for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,&darwinEvents[i]);
+  DarwinPokeEQ();
+}
+
+/* Send the appropriate number of button 4 / 5 clicks to emulate scroll wheel */
+void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y) {
+  int i;
+  int ev_button = count > 0.0f ? 4 : 5;
+  int valuators[2] = {pointer_x, pointer_y};
+
+  for (count = fabs(count); count > 0.0; count = count - 1.0f) {
+    int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button, 
+				      POINTER_ABSOLUTE, 0, 2, valuators);
+    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
+    num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button, 
+				      POINTER_ABSOLUTE, 0, 2, valuators);
+    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
+  }
+  DarwinPokeEQ();
+}
diff-tree 0ccd1443fd6db397b42e5b99ce733ce1316c785e (from parents)
Merge: ec1ef8a56d6217ca2b04899043874ce0bcad9784 9b6bb06f13a71f6078f762b4a78fa516faccb638
Author: Ben Byer <bbyer at bbyer.(none)>
Date:   Tue Mar 6 01:04:50 2007 -0800

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

diff-tree ec1ef8a56d6217ca2b04899043874ce0bcad9784 (from 33d2cf93fb50464941e74efe246b10aee212223a)
Author: Ben Byer <bbyer at bbyer.(none)>
Date:   Tue Mar 6 00:57:23 2007 -0800

    Fixed Darwin's Makefile.am to fix a problem building X11.app

diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 75d028e..3e28d32 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -112,7 +112,7 @@ macos_PROGRAMS = XDarwinApp
 macos_SCRIPTS = x11app
 
 x11app:
-	cd apple && xcodebuild
+	cd apple && xcodebuild CFLAGS="$(XSERVERCFLAGS_CFLAGS)" LDFLAGS="$(XSERVERCFLAGS_LIBS)"
 
 XDarwinApp_SOURCES = \
                 $(top_srcdir)/fb/fbcmap.c \
@@ -275,7 +275,7 @@ install-data-hook: $(HOOK_TARGETS)
 
 xquartz-install-hook:
 	mv $(DESTDIR)$(macosdir)/XDarwinApp $(DESTDIR)$(macosdir)/XDarwin
-        cd apple && xcodebuild CFLAGS="$(XSERVERCFLAGS_CFLAGS)" LDFLAGS="$(XSERVERCFLAGS_LIBS)"
+	cd apple && xcodebuild install
 
 EXTRA_DIST = \
 	darwin.c \
diff-tree 9b6bb06f13a71f6078f762b4a78fa516faccb638 (from bed76caa6caaea6a6598755b82a54425a9d9f73e)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Mon Mar 5 23:49:35 2007 -0800

    Allow relative positions to use output names or monitor identifiers.
    
    Previous version used monitor identifiers if present, otherwise output
    names. That caused existing working configurations to break when additional
    information was added to the configuration file.
    (cherry picked from commit 3f5cedf00a82f08a433c95ffbb7f8ac69dcf6a50)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index c38da62..46515fd 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -879,13 +879,17 @@ xf86InitialOutputPositions (ScrnInfoPtr 
 		{
 		    xf86OutputPtr	out_rel = config->output[or];
 		    XF86ConfMonitorPtr	rel_mon = out_rel->conf_monitor;
-		    char		*name;
 
 		    if (rel_mon)
-			name = rel_mon->mon_identifier;
-		    else
-			name = out_rel->name;
-		    if (!strcmp (relative_name, name))
+		    {
+			if (xf86nameCompare (rel_mon->mon_identifier,
+					      relative_name) == 0)
+			{
+			    relative = config->output[or];
+			    break;
+			}
+		    }
+		    if (strcmp (out_rel->name, relative_name) == 0)
 		    {
 			relative = config->output[or];
 			break;
diff-tree bed76caa6caaea6a6598755b82a54425a9d9f73e (from 47f8361c3a64834587e54507653d8d5b258c2530)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Mon Mar 5 23:36:00 2007 -0800

    Use EDID data to set screen physical size at server startup.
    
    Screen physical size is set to a random value before the RandR code gets
    control, override that and reset it to a value based on the compat_output
    physical size (if available). If that output has no physical size, just use
    96dpi as the default resolution and set the physical size as appropriate.
    (cherry picked from commit 843077f23a1b49bd712d931421753e3a09d4008c)

diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 052d12a..ce780b6 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -422,8 +422,28 @@ xf86RandR12CreateScreenResources (Screen
 	}
 	else
 	{
-	    mmWidth = pScreen->mmWidth;
-	    mmHeight = pScreen->mmHeight;
+	    xf86OutputPtr   output = config->output[config->compat_output];
+	    xf86CrtcPtr	    crtc = output->crtc;
+
+	    if (crtc && crtc->mode.HDisplay &&
+		output->mm_width && output->mm_height)
+	    {
+		/*
+		 * If the output has a mode and a declared size, use that
+		 * to scale the screen size
+		 */
+		DisplayModePtr	mode = &crtc->mode;
+		mmWidth = output->mm_width * width / mode->HDisplay;
+		mmHeight = output->mm_height * height / mode->VDisplay;
+	    }
+	    else
+	    {
+		/*
+		 * Otherwise, just set the screen to 96dpi
+		 */
+		mmWidth = width * 25.4 / 96;
+		mmHeight = height * 25.4 / 96;
+	    }
 	}
 	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 		   "Setting screen physical size to %d x %d\n",
diff-tree 47f8361c3a64834587e54507653d8d5b258c2530 (from 33d2cf93fb50464941e74efe246b10aee212223a)
Author: Keith Packard <keithp at guitar.keithp.com>
Date:   Mon Mar 5 22:07:01 2007 -0800

    Add xf86SetDesiredModes to apply desired modes to crtcs.
    
    xf86SetDesiredModes applies the desired modes to each crtc (as selected by
    xf86InitialConfiguration initially and modified by successful mode settings
    afterwards). For crtcs without a desired mode, pScrn->currentMode is used to
    select something workable.
    (cherry picked from commit bcade98ccaa18298d844a606cb44271f0254c185)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 3d28293..c38da62 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1542,6 +1542,63 @@ xf86InitialConfiguration (ScrnInfoPtr sc
     return TRUE;
 }
 
+/*
+ * Using the desired mode information in each crtc, set
+ * modes (used in EnterVT functions, or at server startup)
+ */
+
+Bool
+xf86SetDesiredModes (ScrnInfoPtr scrn)
+{
+    xf86CrtcConfigPtr   config = XF86_CRTC_CONFIG_PTR(scrn);
+    int			c;
+
+    for (c = 0; c < config->num_crtc; c++)
+    {
+	xf86CrtcPtr	crtc = config->crtc[c];
+	xf86OutputPtr	output = NULL;
+	int		o;
+
+	if (config->output[config->compat_output]->crtc == crtc)
+	    output = config->output[config->compat_output];
+	else
+	{
+	    for (o = 0; o < config->num_output; o++)
+		if (config->output[o]->crtc == crtc)
+		{
+		    output = config->output[o];
+		    break;
+		}
+	}
+	/*
+	 * Skip disabled crtcs
+	 */
+	if (!output)
+	    continue;
+
+	/* Mark that we'll need to re-set the mode for sure */
+	memset(&crtc->mode, 0, sizeof(crtc->mode));
+	if (!crtc->desiredMode.CrtcHDisplay)
+	{
+	    DisplayModePtr  mode = xf86OutputFindClosestMode (output, scrn->currentMode);
+
+	    if (!mode)
+		return FALSE;
+	    crtc->desiredMode = *mode;
+	    crtc->desiredRotation = RR_Rotate_0;
+	    crtc->desiredX = 0;
+	    crtc->desiredY = 0;
+	}
+
+	if (!xf86CrtcSetMode (crtc, &crtc->desiredMode, crtc->desiredRotation,
+			      crtc->desiredX, crtc->desiredY))
+	    return FALSE;
+    }
+
+    xf86DisableUnusedFunctions(scrn);
+    return TRUE;
+}
+
 /**
  * In the current world order, there are lists of modes per output, which may
  * or may not include the mode that was asked to be set by XFree86's mode
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 56c7769..062a2db 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -644,4 +644,12 @@ xf86CrtcSetScreenSubpixelOrder (ScreenPt
 char *
 xf86ConnectorGetName(xf86ConnectorType connector);
 
+/*
+ * Using the desired mode information in each crtc, set
+ * modes (used in EnterVT functions, or at server startup)
+ */
+
+Bool
+xf86SetDesiredModes (ScrnInfoPtr pScrn);
+
 #endif /* _XF86CRTC_H_ */
diff --git a/hw/xfree86/modes/xf86Rename.h b/hw/xfree86/modes/xf86Rename.h
index 6cfa5ca..eae6d64 100644
--- a/hw/xfree86/modes/xf86Rename.h
+++ b/hw/xfree86/modes/xf86Rename.h
@@ -76,5 +76,8 @@
 #define xf86CrtcSetScreenSubpixelOrder XF86NAME(xf86CrtcSetScreenSubpixelOrder)
 #define xf86ModeWidth XF86NAME(xf86ModeWidth)
 #define xf86ModeHeight XF86NAME(xf86ModeHeight)
+#define xf86OutputFindClosestMode XF86NAME(xf86OutputFindClosestMode)
+#define xf86SetSingleMode XF86NAME(xf86SetSingleMode)
+#define xf86SetDesiredModes XF86NAME(xf86SetDesiredModes)
 
 #endif /* _XF86RENAME_H_ */
diff-tree 33d2cf93fb50464941e74efe246b10aee212223a (from 689d52b6242434507a64a8fff27b01607628c393)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Sat Mar 3 23:10:31 2007 -0800

    Move xf86SetSingleMode into X server from intel driver.
    
    This function applies a single mode to the screen (as from RandR 1.1,
    XFree86-VidModeExtension or XFree86-DGA) using a policy that selects one
    output to reconfigure to the requested mode and then makes all other outputs
    fit within that size.
    (cherry picked from commit 5a595c1f767a8d666348b845d18934aee0cfe38f)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 2ffa956..3d28293 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1543,6 +1543,132 @@ xf86InitialConfiguration (ScrnInfoPtr sc
 }
 
 /**
+ * In the current world order, there are lists of modes per output, which may
+ * or may not include the mode that was asked to be set by XFree86's mode
+ * selection.  Find the closest one, in the following preference order:
+ *
+ * - Equality
+ * - Closer in size to the requested mode, but no larger
+ * - Closer in refresh rate to the requested mode.
+ */
+
+DisplayModePtr
+xf86OutputFindClosestMode (xf86OutputPtr output, DisplayModePtr desired)
+{
+    DisplayModePtr	best = NULL, scan = NULL;
+
+    for (scan = output->probed_modes; scan != NULL; scan = scan->next) 
+    {
+	/* If there's an exact match, we're done. */
+	if (xf86ModesEqual(scan, desired)) {
+	    best = desired;
+	    break;
+	}
+
+	/* Reject if it's larger than the desired mode. */
+	if (scan->HDisplay > desired->HDisplay || 
+	    scan->VDisplay > desired->VDisplay)
+	{
+	    continue;
+	}
+
+	/*
+	 * If we haven't picked a best mode yet, use the first
+	 * one in the size range
+	 */
+	if (best == NULL) 
+	{
+	    best = scan;
+	    continue;
+	}
+
+	/* Find if it's closer to the right size than the current best
+	 * option.
+	 */
+	if ((scan->HDisplay > best->HDisplay &&
+	     scan->VDisplay >= best->VDisplay) ||
+	    (scan->HDisplay >= best->HDisplay &&
+	     scan->VDisplay > best->VDisplay))
+	{
+	    best = scan;
+	    continue;
+	}
+
+	/* Find if it's still closer to the right refresh than the current
+	 * best resolution.
+	 */
+	if (scan->HDisplay == best->HDisplay &&
+	    scan->VDisplay == best->VDisplay &&
+	    (fabs(scan->VRefresh - desired->VRefresh) <
+	     fabs(best->VRefresh - desired->VRefresh))) {
+	    best = scan;
+	}
+    }
+    return best;
+}
+
+/**
+ * When setting a mode through XFree86-VidModeExtension or XFree86-DGA,
+ * take the specified mode and apply it to the crtc connected to the compat
+ * output. Then, find similar modes for the other outputs, as with the
+ * InitialConfiguration code above. The goal is to clone the desired
+ * mode across all outputs that are currently active.
+ */
+
+Bool
+xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation)
+{
+    xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(pScrn);
+    Bool		ok = TRUE;
+    xf86OutputPtr	compat_output = config->output[config->compat_output];
+    DisplayModePtr	compat_mode;
+    int			c;
+
+    /*
+     * Let the compat output drive the final mode selection
+     */
+    compat_mode = xf86OutputFindClosestMode (compat_output, desired);
+    if (compat_mode)
+	desired = compat_mode;
+    
+    for (c = 0; c < config->num_crtc; c++)
+    {
+	xf86CrtcPtr	crtc = config->crtc[c];
+	DisplayModePtr	crtc_mode = NULL;
+	int		o;
+
+	if (!crtc->enabled)
+	    continue;
+	
+	for (o = 0; o < config->num_output; o++)
+	{
+	    xf86OutputPtr   output = config->output[o];
+	    DisplayModePtr  output_mode;
+
+	    /* skip outputs not on this crtc */
+	    if (output->crtc != crtc)
+		continue;
+	    
+	    if (crtc_mode)
+	    {
+		output_mode = xf86OutputFindClosestMode (output, crtc_mode);
+		if (output_mode != crtc_mode)
+		    output->crtc = NULL;
+	    }
+	    else
+		crtc_mode = xf86OutputFindClosestMode (output, desired);
+	}
+	if (!xf86CrtcSetMode (crtc, crtc_mode, rotation, 0, 0))
+	    ok = FALSE;
+	else
+	    crtc->desiredMode = *crtc_mode;
+    }
+    xf86DisableUnusedFunctions(pScrn);
+    return ok;
+}
+
+
+/**
  * Set the DPMS power mode of all outputs and CRTCs.
  *
  * If the new mode is off, it will turn off outputs and then CRTCs.
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 537df3a..56c7769 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -594,6 +594,12 @@ xf86SaveScreen(ScreenPtr pScreen, int mo
 void
 xf86DisableUnusedFunctions(ScrnInfoPtr pScrn);
 
+DisplayModePtr
+xf86OutputFindClosestMode (xf86OutputPtr output, DisplayModePtr desired);
+    
+Bool
+xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation);
+
 /**
  * Set the EDID information for the specified output
  */
diff-tree 689d52b6242434507a64a8fff27b01607628c393 (from fe7b8f4237874e3e45fe25a6bf06faddfa1ab8e1)
Author: Jens Granseuer <jensgr at gmx.net>
Date:   Mon Mar 5 15:31:44 2007 -0800

    Bugzilla #7145: fix build with gcc 2.95
    
    Bugzilla #7145: <http://bugs.freedesktop.org/show_bug.cgi?id=7145>
    Patch #8987: <http://bugs.freedesktop.org/attachment.cgi?id=8987>

diff --git a/GL/glx/glxcmdsswap.c b/GL/glx/glxcmdsswap.c
index d59dfdb..1857bc1 100644
--- a/GL/glx/glxcmdsswap.c
+++ b/GL/glx/glxcmdsswap.c
@@ -496,11 +496,11 @@ int __glXDispSwap_CopySubBufferMESA(__GL
     GLXDrawable		 *drawId;
     int			 *buffer;
 
+    __GLX_DECLARE_SWAP_VARIABLES;
+
     (void) drawId;
     (void) buffer;
 
-    __GLX_DECLARE_SWAP_VARIABLES;
-
     pc += __GLX_VENDPRIV_HDR_SIZE;
 
     __GLX_SWAP_SHORT(&req->length);
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 1f7462f..db506f4 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -490,7 +490,7 @@ RRCrtcInit (void)
 int
 ProcRRGetCrtcInfo (ClientPtr client)
 {
-    REQUEST(xRRGetCrtcInfoReq);;
+    REQUEST(xRRGetCrtcInfoReq);
     xRRGetCrtcInfoReply	rep;
     RRCrtcPtr			crtc;
     CARD8			*extra;
diff --git a/randr/rroutput.c b/randr/rroutput.c
index a664330..df1741f 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -366,7 +366,7 @@ RROutputInit (void)
 int
 ProcRRGetOutputInfo (ClientPtr client)
 {
-    REQUEST(xRRGetOutputInfoReq);;
+    REQUEST(xRRGetOutputInfoReq);
     xRRGetOutputInfoReply	rep;
     RROutputPtr			output;
     CARD8			*extra;
diff --git a/randr/rrpointer.c b/randr/rrpointer.c
index 802dcb2..c88a0f8 100644
--- a/randr/rrpointer.c
+++ b/randr/rrpointer.c
@@ -103,7 +103,7 @@ void
 RRPointerMoved (ScreenPtr pScreen, int x, int y)
 {
     rrScrPriv (pScreen);
-    RRCrtcPtr	pointerCrtc = pScrPriv->pointerCrtc;;
+    RRCrtcPtr	pointerCrtc = pScrPriv->pointerCrtc;
     int	c;
 
     /* Check last known CRTC */



More information about the xorg-commit mailing list