[Xquartz-changes] xserver: Branch 'server-1.12-apple' - 21 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Thu May 17 09:58:31 PDT 2012


Rebased ref, commits from common ancestor:
commit 80cc7f5248daae5bb0ddf218c23bf08e6cd6b7da
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Feb 12 19:48:52 2010 -0800

    fb: Revert fb changes that broke XQuartz
    
    http://bugs.freedesktop.org/show_bug.cgi?id=26124
    
    Revert "Fix source pictures getting random transforms after 2d6a8f668342a5190cdf43b5."
    Revert "fb: Adjust transform or composite coordinates for pixman operations"
    
    http://bugs.freedesktop.org/26124
    
    This reverts commit a72c65e9176c51de95db2fdbf4c5d946a4911695.
    This reverts commit a6bd5d2e482a5aa84acb3d4932e2a166d8670ef1.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit e6fa592a74104aa9d0081387823314833526f306)

diff --git a/fb/fb.h b/fb/fb.h
index b327ce6..53a6c1a 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1683,8 +1683,7 @@ fbFillRegionSolid(DrawablePtr pDrawable,
                   RegionPtr pRegion, FbBits and, FbBits xor);
 
 extern _X_EXPORT pixman_image_t *image_from_pict(PicturePtr pict,
-                                                 Bool has_clip,
-                                                 int *xoff, int *yoff);
+                                                 Bool has_clip);
 
 extern _X_EXPORT void free_pixman_pict(PicturePtr, pixman_image_t *);
 
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 097a1a6..dc0ca3c 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -46,23 +46,18 @@ fbComposite(CARD8 op,
             INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
 {
     pixman_image_t *src, *mask, *dest;
-    int src_xoff, src_yoff;
-    int msk_xoff, msk_yoff;
-    int dst_xoff, dst_yoff;
-
     miCompositeSourceValidate(pSrc);
     if (pMask)
         miCompositeSourceValidate(pMask);
 
-    src = image_from_pict(pSrc, FALSE, &src_xoff, &src_yoff);
-    mask = image_from_pict(pMask, FALSE, &msk_xoff, &msk_yoff);
-    dest = image_from_pict(pDst, TRUE, &dst_xoff, &dst_yoff);
+    src = image_from_pict(pSrc, TRUE);
+    mask = image_from_pict(pMask, TRUE);
+    dest = image_from_pict(pDst, TRUE);
 
     if (src && dest && !(pMask && !mask)) {
         pixman_image_composite(op, src, mask, dest,
-                               xSrc + src_xoff, ySrc + src_yoff,
-                               xMask + msk_xoff, yMask + msk_yoff,
-                               xDst + dst_xoff, yDst + dst_yoff, width, height);
+                               xSrc, ySrc, xMask, yMask, xDst, yDst,
+                               width, height);
     }
 
     free_pixman_pict(pSrc, src);
@@ -143,20 +138,22 @@ create_conical_gradient_image(PictGradient * gradient)
 }
 
 static pixman_image_t *
-create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
+create_bits_picture(PicturePtr pict, Bool has_clip)
 {
-    PixmapPtr pixmap;
     FbBits *bits;
     FbStride stride;
-    int bpp;
+    int bpp, xoff, yoff;
     pixman_image_t *image;
 
-    fbGetDrawablePixmap(pict->pDrawable, pixmap, *xoff, *yoff);
-    fbGetPixmapBitsData(pixmap, bits, stride, bpp);
+    fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
+
+    bits = (FbBits*)((CARD8*)bits +
+                     (pict->pDrawable->y + yoff) * stride * sizeof(FbBits) +
+                     (pict->pDrawable->x + xoff) * (bpp / 8));
 
     image = pixman_image_create_bits((pixman_format_code_t) pict->format,
-                                     pixmap->drawable.width,
-                                     pixmap->drawable.height, (uint32_t *) bits,
+                                     pict->pDrawable->width,
+                                     pict->pDrawable->height, (uint32_t *) bits,
                                      stride * sizeof(FbStride));
 
     if (!image)
@@ -183,57 +180,31 @@ create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
         if (pict->clientClipType != CT_NONE)
             pixman_image_set_has_client_clip(image, TRUE);
 
-        if (*xoff || *yoff)
-            pixman_region_translate(pict->pCompositeClip, *xoff, *yoff);
+        pixman_region_translate (pict->pCompositeClip, - pict->pDrawable->x, - pict->pDrawable->y);
 
         pixman_image_set_clip_region(image, pict->pCompositeClip);
 
-        if (*xoff || *yoff)
-            pixman_region_translate(pict->pCompositeClip, -*xoff, -*yoff);
+        pixman_region_translate (pict->pCompositeClip, pict->pDrawable->x, pict->pDrawable->y);
     }
 
     /* Indexed table */
     if (pict->pFormat->index.devPrivate)
         pixman_image_set_indexed(image, pict->pFormat->index.devPrivate);
 
-    /* Add in drawable origin to position within the image */
-    *xoff += pict->pDrawable->x;
-    *yoff += pict->pDrawable->y;
-
     return image;
 }
 
 static pixman_image_t *image_from_pict_internal(PicturePtr pict, Bool has_clip,
-                                                int *xoff, int *yoff,
                                                 Bool is_alpha_map);
 
 static void
-set_image_properties(pixman_image_t * image, PicturePtr pict, Bool has_clip,
-                     int *xoff, int *yoff, Bool is_alpha_map)
+set_image_properties(pixman_image_t * image, PicturePtr pict, Bool is_alpha_map)
 {
     pixman_repeat_t repeat;
     pixman_filter_t filter;
 
     if (pict->transform) {
-        /* For source images, adjust the transform to account
-         * for the drawable offset within the pixman image,
-         * then set the offset to 0 as it will be used
-         * to compute positions within the transformed image.
-         */
-        if (!has_clip) {
-            struct pixman_transform adjusted;
-
-            adjusted = *pict->transform;
-            pixman_transform_translate(&adjusted,
-                                       NULL,
-                                       pixman_int_to_fixed(*xoff),
-                                       pixman_int_to_fixed(*yoff));
-            pixman_image_set_transform(image, &adjusted);
-            *xoff = 0;
-            *yoff = 0;
-        }
-        else
-            pixman_image_set_transform(image, pict->transform);
+        pixman_image_set_transform(image, pict->transform);
     }
 
     switch (pict->repeatType) {
@@ -261,10 +232,8 @@ set_image_properties(pixman_image_t * image, PicturePtr pict, Bool has_clip,
      * as the alpha map for this operation
      */
     if (pict->alphaMap && !is_alpha_map) {
-        int alpha_xoff, alpha_yoff;
         pixman_image_t *alpha_map =
-            image_from_pict_internal(pict->alphaMap, FALSE, &alpha_xoff,
-                                     &alpha_yoff, TRUE);
+            image_from_pict_internal(pict->alphaMap, TRUE, TRUE);
 
         pixman_image_set_alpha_map(image, alpha_map, pict->alphaOrigin.x,
                                    pict->alphaOrigin.y);
@@ -298,8 +267,7 @@ set_image_properties(pixman_image_t * image, PicturePtr pict, Bool has_clip,
 }
 
 static pixman_image_t *
-image_from_pict_internal(PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
-                         Bool is_alpha_map)
+image_from_pict_internal(PicturePtr pict, Bool has_clip, Bool is_alpha_map)
 {
     pixman_image_t *image = NULL;
 
@@ -307,7 +275,7 @@ image_from_pict_internal(PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
         return NULL;
 
     if (pict->pDrawable) {
-        image = create_bits_picture(pict, has_clip, xoff, yoff);
+        image = create_bits_picture(pict, has_clip);
     }
     else if (pict->pSourcePict) {
         SourcePict *sp = pict->pSourcePict;
@@ -325,19 +293,17 @@ image_from_pict_internal(PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
             else if (sp->type == SourcePictTypeConical)
                 image = create_conical_gradient_image(gradient);
         }
-        *xoff = *yoff = 0;
     }
 
     if (image)
-        set_image_properties(image, pict, has_clip, xoff, yoff, is_alpha_map);
-
+        set_image_properties (image, pict, is_alpha_map);
     return image;
 }
 
 pixman_image_t *
-image_from_pict(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
+image_from_pict (PicturePtr pict, Bool has_clip)
 {
-    return image_from_pict_internal(pict, has_clip, xoff, yoff, FALSE);
+    return image_from_pict_internal (pict, has_clip, FALSE);
 }
 
 void
diff --git a/fb/fbtrap.c b/fb/fbtrap.c
index bf82f8f..0145ce9 100644
--- a/fb/fbtrap.c
+++ b/fb/fbtrap.c
@@ -36,13 +36,12 @@ fbAddTraps(PicturePtr pPicture,
            INT16 x_off, INT16 y_off, int ntrap, xTrap * traps)
 {
     pixman_image_t *image;
-    int dst_xoff, dst_yoff;
 
-    if (!(image = image_from_pict(pPicture, FALSE, &dst_xoff, &dst_yoff)))
-        return;
-
-    pixman_add_traps(image, x_off + dst_xoff, y_off + dst_yoff,
-                     ntrap, (pixman_trap_t *) traps);
+    if (!(image = image_from_pict (pPicture, FALSE)))
+	return;
+    
+    pixman_add_traps(image, x_off, y_off,
+                     ntrap, (pixman_trap_t *)traps);
 
     free_pixman_pict(pPicture, image);
 }
@@ -52,13 +51,12 @@ fbRasterizeTrapezoid(PicturePtr pPicture,
                      xTrapezoid * trap, int x_off, int y_off)
 {
     pixman_image_t *image;
-    int dst_xoff, dst_yoff;
 
-    if (!(image = image_from_pict(pPicture, FALSE, &dst_xoff, &dst_yoff)))
+    if (!(image = image_from_pict (pPicture, FALSE)))
         return;
 
-    pixman_rasterize_trapezoid(image, (pixman_trapezoid_t *) trap,
-                               x_off + dst_xoff, y_off + dst_yoff);
+    pixman_rasterize_trapezoid(image, (pixman_trapezoid_t *)trap,
+                               x_off, y_off);
 
     free_pixman_pict(pPicture, image);
 }
@@ -68,14 +66,12 @@ fbAddTriangles(PicturePtr pPicture,
                INT16 x_off, INT16 y_off, int ntri, xTriangle * tris)
 {
     pixman_image_t *image;
-    int dst_xoff, dst_yoff;
 
-    if (!(image = image_from_pict(pPicture, FALSE, &dst_xoff, &dst_yoff)))
+    if (!(image = image_from_pict (pPicture, FALSE)))
         return;
-
-    pixman_add_triangles(image,
-                         dst_xoff + x_off, dst_yoff + y_off,
-                         ntri, (pixman_triangle_t *) tris);
+    
+    pixman_add_triangles(image, x_off, y_off, ntri,
+                         (pixman_triangle_t *)tris);
 
     free_pixman_pict(pPicture, image);
 }
@@ -98,13 +94,11 @@ fbShapes(CompositeShapesFunc composite,
          int16_t ySrc, int nshapes, int shape_size, const uint8_t * shapes)
 {
     pixman_image_t *src, *dst;
-    int src_xoff, src_yoff;
-    int dst_xoff, dst_yoff;
 
     miCompositeSourceValidate(pSrc);
 
-    src = image_from_pict(pSrc, FALSE, &src_xoff, &src_yoff);
-    dst = image_from_pict(pDst, TRUE, &dst_xoff, &dst_yoff);
+    src = image_from_pict(pSrc, FALSE);
+    dst = image_from_pict(pDst, TRUE);
 
     if (src && dst) {
         pixman_format_code_t format;
@@ -121,9 +115,8 @@ fbShapes(CompositeShapesFunc composite,
 
             for (i = 0; i < nshapes; ++i) {
                 composite(op, src, dst, format,
-                          xSrc + src_xoff,
-                          ySrc + src_yoff,
-                          dst_xoff, dst_yoff, 1, shapes + i * shape_size);
+                          xSrc, ySrc, 0, 0, 
+                          1, shapes + i * shape_size);
             }
         }
         else {
@@ -143,8 +136,8 @@ fbShapes(CompositeShapesFunc composite,
             }
 
             composite(op, src, dst, format,
-                      xSrc + src_xoff,
-                      ySrc + src_yoff, dst_xoff, dst_yoff, nshapes, shapes);
+                      xSrc, ySrc, 0, 0,
+                      nshapes, shapes);
         }
 
         DamageRegionProcessPending(pDst->pDrawable);
commit c6cc48bd0f956d9531b9aea4c8ecd2ecdc900d77
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Apr 30 13:08:25 2010 -0700

    Workaround the GC clipping problem in miPaintWindow and add some debugging output.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit d7e56959401ce32120af67b01632442c52f2cf85)

diff --git a/mi/miexpose.c b/mi/miexpose.c
index dbb29ca..93fd8a1 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -490,7 +490,8 @@ void RootlessSetPixmapOfAncestors(WindowPtr pWin);
 void RootlessStartDrawing(WindowPtr pWin);
 void RootlessDamageRegion(WindowPtr pWin, RegionPtr prgn);
 Bool IsFramedWindow(WindowPtr pWin);
-#endif
+#include "../fb/fb.h"
+#endif 
 
 void
 miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
@@ -519,23 +520,37 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     Bool solid = TRUE;
     DrawablePtr drawable = &pWin->drawable;
 
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("START %d BS %d (pR = %ld)\n", what, pWin->backgroundState, ParentRelative);
+    ErrorF("      Rgn: %d %d %d %d\n", prgn->extents.x1, prgn->extents.y1,
+	                               prgn->extents.x2 - prgn->extents.x1,
+	                               prgn->extents.y2 - prgn->extents.y1);
+    ErrorF("      Win: %d %d (%d %d) %d %d\n", pWin->origin.x, pWin->origin.y,
+	                                       pWin->winSize.extents.x1, pWin->winSize.extents.y1,
+	                                       pWin->winSize.extents.x2 - pWin->winSize.extents.x1,
+					       pWin->winSize.extents.y2 - pWin->winSize.extents.y1);
+    ErrorF("     Draw: %d %d %d %d\n", pWin->drawable.x, pWin->drawable.y,
+				       pWin->drawable.width, pWin->drawable.height);
+#endif
+
 #ifdef ROOTLESS
     if (!drawable || drawable->type == UNDRAWABLE_WINDOW)
         return;
+#endif
+    
+    if (what == PW_BACKGROUND)
+    {
+#ifdef ROOTLESS
+        if(IsFramedWindow(pWin)) {
+            RootlessStartDrawing(pWin);
+            RootlessDamageRegion(pWin, prgn);
 
-    if (IsFramedWindow(pWin)) {
-        RootlessStartDrawing(pWin);
-        RootlessDamageRegion(pWin, prgn);
-
-        if (pWin->backgroundState == ParentRelative) {
-            if ((what == PW_BACKGROUND) ||
-                (what == PW_BORDER && !pWin->borderIsPixel))
+            if(pWin->backgroundState == ParentRelative) {
                 RootlessSetPixmapOfAncestors(pWin);
+            }
         }
-    }
 #endif
 
-    if (what == PW_BACKGROUND) {
         while (pWin->backgroundState == ParentRelative)
             pWin = pWin->parent;
 
@@ -560,6 +575,18 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     else {
         PixmapPtr pixmap;
 
+#ifdef ROOTLESS
+	if(IsFramedWindow(pWin)) {
+	    RootlessStartDrawing(pWin);
+	    RootlessDamageRegion(pWin, prgn);
+	    
+	    if(!pWin->borderIsPixel &&
+		pWin->backgroundState == ParentRelative) {
+		RootlessSetPixmapOfAncestors(pWin);
+	    }
+	}
+#endif
+
         tile_x_off = drawable->x;
         tile_y_off = drawable->y;
 
@@ -568,6 +595,12 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
             return;
         pixmap = (*pScreen->GetWindowPixmap) ((WindowPtr) drawable);
         drawable = &pixmap->drawable;
+
+#ifdef XQUARTZ_CLIP_DEBUG
+        ErrorF("     Draw: %d %d %d %d\n",
+               drawable->x, drawable->y, drawable->width, drawable->height);    
+#endif
+	
 #ifdef COMPOSITE
         draw_x_off = pixmap->screen_x;
         draw_y_off = pixmap->screen_y;
@@ -630,6 +663,57 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     ChangeGC(NullClient, pGC, gcmask, gcval);
     ValidateGC(drawable, pGC);
 
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("       GC: %d %d %d %d\n",
+	   pGC->pCompositeClip->extents.x1, pGC->pCompositeClip->extents.y1,
+	   pGC->pCompositeClip->extents.x2 - pGC->pCompositeClip->extents.x1,
+	   pGC->pCompositeClip->extents.y2 - pGC->pCompositeClip->extents.y1);
+#endif
+    
+#ifdef XQUARTZ
+    /* Looks like our clipping isn't set right for some reason:
+     * http://xquartz.macosforge.org/trac/ticket/290
+     */
+    if(what == PW_BORDER) {
+
+#if 0
+	if(solid) {
+#if 1
+	    fbFillRegionSolid(&pWin->drawable,
+			      prgn,
+			      0,
+			      fbReplicatePixel(fill.pixel,
+					       pWin->drawable.bitsPerPixel));
+#else
+	    fbFillRegionSolid(drawable,
+			      prgn,
+			      0,
+			      fbReplicatePixel(fill.pixel,
+					       drawable->bitsPerPixel));
+#endif
+	    return;
+	}
+#endif
+    
+	pGC->pCompositeClip->extents.x1 += prgn->extents.x1;
+	pGC->pCompositeClip->extents.y1 += prgn->extents.y1;
+	pGC->pCompositeClip->extents.x2 += prgn->extents.x1;
+	pGC->pCompositeClip->extents.y2 += prgn->extents.y1;
+	
+	if(pGC->pCompositeClip->extents.x2 > drawable->pScreen->width)
+	    pGC->pCompositeClip->extents.x2 = drawable->pScreen->width;
+	if(pGC->pCompositeClip->extents.y2 > drawable->pScreen->height)
+	    pGC->pCompositeClip->extents.y2 = drawable->pScreen->height;
+    }
+#endif
+
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("       GC: %d %d %d %d\n",
+	   pGC->pCompositeClip->extents.x1, pGC->pCompositeClip->extents.y1,
+	   pGC->pCompositeClip->extents.x2 - pGC->pCompositeClip->extents.x1,
+	   pGC->pCompositeClip->extents.y2 - pGC->pCompositeClip->extents.y1);    
+#endif
+
     numRects = RegionNumRects(prgn);
     pbox = RegionRects(prgn);
     for (i = numRects; --i >= 0; pbox++, prect++) {
commit 083704972f053b921986fef43673c360b232c10d
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Jan 13 12:00:57 2012 -0800

    sdksyms.sh: Use CPPFLAGS, not CFLAGS
    
    CFLAGS can include flags which are not useful to the preprocessor
    or can even cause it to fail.  This fixes a build issue on darwin
    when building for more than one architecture.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 290d366d4c6b6e051f0e337a1a6ee76f42d28003)

diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index 72be889..c0b81c3 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -38,7 +38,7 @@ DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \
 bin_PROGRAMS = Xorg
 nodist_Xorg_SOURCES = sdksyms.c
 
-AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
+AM_CPPFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
 INCLUDES = $(XORG_INCS) -I$(srcdir)/parser -I$(top_srcdir)/miext/cw \
 	-I$(srcdir)/ddc -I$(srcdir)/i2c -I$(srcdir)/modes -I$(srcdir)/ramdac
 
@@ -109,7 +109,7 @@ CLEANFILES = sdksyms.c sdksyms.dep
 EXTRA_DIST += sdksyms.sh
 
 sdksyms.dep sdksyms.c: sdksyms.sh
-	CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $(srcdir)/sdksyms.sh $(top_srcdir) $(CFLAGS) $(AM_CFLAGS) $(INCLUDES)
+	CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $(srcdir)/sdksyms.sh $(top_srcdir) $(CPPFLAGS) $(AM_CPPFLAGS) $(INCLUDES)
 
 SDKSYMS_DEP = sdksyms.dep
 include $(SDKSYMS_DEP)
commit 29cf853d82f033bbba86e218bb148d55af989c73
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Feb 17 13:15:12 2012 -0800

    XQuartz: Detect FatalErrors on startup to prevent tight crash loops
    
    If a FatalError occurs before the server finishes launching, it will
    not have drained the launchd-owned DISPLAY socket, so launchd will
    just relaunch it.  This can cause the server to crash in a tight loop
    which will spam the user with CrashReporter windows that claim focus on
    appearance.
    
    This allows users stuck in this loop to "deal" with the problem without
    popping up a crash report every 10 seconds.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 3505e1faadddeeec85a0d3f823c877ea33f86e00)
    
    Conflicts:
    
    	hw/xquartz/X11Application.h

diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
index 740a807..5ea6129 100644
--- a/hw/xquartz/X11Application.h
+++ b/hw/xquartz/X11Application.h
@@ -89,6 +89,9 @@ X11ApplicationCanEnterRandR(void);
 void
 X11ApplicationMain(int argc, char **argv, char **envp);
 
+void
+X11ApplicationFatalError(const char *f, va_list args) __printflike(1, 0);
+
 #define PREFS_APPSMENU                "apps_menu"
 #define PREFS_FAKEBUTTONS             "enable_fake_buttons"
 #define PREFS_KEYEQUIVS               "enable_key_equivalents"
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index b686b00..c77b724 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -72,6 +72,7 @@ static dispatch_queue_t eventTranslationQueue;
 
 extern Bool noTestExtensions;
 extern Bool noRenderExtension;
+extern BOOL serverRunning;
 
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
 static TISInputSourceRef last_key_layout;
@@ -1073,6 +1074,50 @@ X11ApplicationCanEnterRandR(void)
     }
 }
 
+void
+X11ApplicationFatalError(const char *f, va_list args)
+{
+#ifdef HAVE_LIBDISPATCH
+    NSString *title, *msg;
+    char *error_msg;
+
+    /* This is called by FatalError() in the server thread just before
+     * we would abort.  If the server never got off the ground, We should
+     * inform the user of the error rather than letting the ever-so-friendly
+     * CrashReporter do it for us.
+     *
+     * This also has the benefit of forcing user interaction rather than
+     * allowing an infinite throttled-restart if the crash occurs before
+     * we can drain the launchd socket.
+     */
+
+    if (serverRunning) {
+        return;
+    }
+
+    title = NSLocalizedString(@"The application X11 could not be opened.",
+                              @"Dialog title when encountering a fatal error");
+    msg = NSLocalizedString(@"An error occurred while starting the X11 server: \"%s\"\n\nClick Quit to quit X11. Click Report to see more details or send a report to Apple.",
+                            @"Dialog when encountering a fatal error");
+
+    vasprintf(&error_msg, f, args);
+    msg = [NSString stringWithFormat:msg, error_msg];
+
+    /* We want the AppKit thread to actually service the alert or we will race [NSApp run] and create an
+     * 'NSInternalInconsistencyException', reason: 'NSApp with wrong _running count'
+     */
+    dispatch_sync(dispatch_get_main_queue(), ^{
+        if (NSAlertDefaultReturn == NSRunAlertPanel(title, msg, NSLocalizedString(@"Quit", @""),
+                                                    NSLocalizedString (@"Report...", @""), nil)) {
+            exit(EXIT_FAILURE);
+        }
+    });
+
+    /* fall back to caller to do the abort() in the DIX */
+#endif
+}
+
+
 static void
 check_xinitrc(void)
 {
diff --git a/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings b/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings
index bf2089c..36ae0ff 100644
Binary files a/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings and b/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings differ
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index e2ab057..41db72a 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -78,6 +78,8 @@
 #include "quartzKeyboard.h"
 #include "quartz.h"
 
+#include "X11Application.h"
+
 aslclient aslc;
 
 void
@@ -672,7 +674,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
 void
 OsVendorFatalError(const char *f, va_list args)
 {
-    ErrorF("   OsVendorFatalError\n");
+    X11ApplicationFatalError(f, args);
 }
 
 /*
commit 3026611095844db24798fc5aa0ab1f21e916e181
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Thu Apr 19 16:39:23 2012 -0700

    os: Annotate OsVendorFatalError as _X_ATTRIBUTE_PRINTF
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Tested-By: Michal Suchanek <hramrach at gmail.com>
    (cherry picked from commit d97868d934fd1a00f9e9ef23a1154a70c7bc0464)

diff --git a/include/os.h b/include/os.h
index 970ff02..8b58d7a 100644
--- a/include/os.h
+++ b/include/os.h
@@ -321,7 +321,8 @@ extern _X_EXPORT void
 OsCleanup(Bool);
 
 extern _X_EXPORT void
-OsVendorFatalError(const char *f, va_list args);
+OsVendorFatalError(const char *f, va_list args)
+_X_ATTRIBUTE_PRINTF(1, 0);
 
 extern _X_EXPORT void
 OsVendorInit(void);
commit 614ce629157008eb90a4e504ae5965df216a1e8e
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Wed Mar 28 15:07:51 2012 -0700

    os: Fix regression with FatalError not calling va_start
    
    Regression From: a818b305989bbcde4e585112a7ee70cbc0b14a92
    
    Found-by: Colin Harrison <colin.harrison at virgin.net>
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 817cec8ffd6cdb1abbcc00decd43569d44801764)

diff --git a/os/log.c b/os/log.c
index 315ba1e..e8dcf02 100644
--- a/os/log.c
+++ b/os/log.c
@@ -591,6 +591,8 @@ FatalError(const char *f, ...)
     else
         ErrorF("\nFatal server error:\n");
 
+    va_start(args, f);
+
     /* Make a copy for OsVendorFatalError */
     va_copy(args2, args);
 
commit 55bff811f9a0c5e3c1ac527780868baee4bd6e37
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Feb 17 12:35:02 2012 -0800

    os: Pass the FatalError message to OsVendorFatalError
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    (cherry picked from commit a818b305989bbcde4e585112a7ee70cbc0b14a92)

diff --git a/hw/dmx/dmxinit.c b/hw/dmx/dmxinit.c
index 09e3d74..5804353 100644
--- a/hw/dmx/dmxinit.c
+++ b/hw/dmx/dmxinit.c
@@ -905,7 +905,7 @@ OsVendorInit(void)
  * two routines mentioned here, as well as by others) to use the
  * referenced routine instead of \a vfprintf().) */
 void
-OsVendorFatalError(void)
+OsVendorFatalError(const char *f, va_list args)
 {
 }
 
diff --git a/hw/dmx/dmxlog.c b/hw/dmx/dmxlog.c
index 151f672..3249c48 100644
--- a/hw/dmx/dmxlog.c
+++ b/hw/dmx/dmxlog.c
@@ -114,9 +114,6 @@ VFatalError(const char *format, va_list args)
 {
     VErrorF(format, args);
     ErrorF("\n");
-#ifdef DDXOSFATALERROR
-    OsVendorFatalError();
-#endif
     AbortServer();
  /*NOTREACHED*/}
 #endif
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index f65ab96..ecdae19 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -1104,7 +1104,7 @@ KdInitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
 }
 
 void
-OsVendorFatalError(void)
+OsVendorFatalError(const char *f, va_list args)
 {
 }
 
diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index 2d679a5..e2cd96c 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -219,7 +219,7 @@ OsVendorInit(void)
 }
 
 void
-OsVendorFatalError(void)
+OsVendorFatalError(const char *f, va_list args)
 {
 }
 
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 0974893..2a7d0a3 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1053,7 +1053,7 @@ AbortDDX(enum ExitCode error)
 }
 
 void
-OsVendorFatalError(void)
+OsVendorFatalError(const char *f, va_list args)
 {
 #ifdef VENDORSUPPORT
     ErrorF("\nPlease refer to your Operating System Vendor support pages\n"
diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c
index 0909826..330b8ca 100644
--- a/hw/xnest/Init.c
+++ b/hw/xnest/Init.c
@@ -142,7 +142,7 @@ OsVendorInit(void)
 }
 
 void
-OsVendorFatalError(void)
+OsVendorFatalError(const char *f, va_list args)
 {
     return;
 }
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 74e11fe..e2ab057 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -670,7 +670,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
  * OsVendorFatalError
  */
 void
-OsVendorFatalError(void)
+OsVendorFatalError(const char *f, va_list args)
 {
     ErrorF("   OsVendorFatalError\n");
 }
diff --git a/hw/xwin/winerror.c b/hw/xwin/winerror.c
index 4049e97..a25307c 100644
--- a/hw/xwin/winerror.c
+++ b/hw/xwin/winerror.c
@@ -70,7 +70,7 @@ OsVendorVErrorF(const char *pszFormat, va_list va_args)
  * Attempt to do last-ditch, safe, important cleanup here.
  */
 void
-OsVendorFatalError(void)
+OsVendorFatalError(const char *f, va_list args)
 {
     /* Don't give duplicate warning if UseMsg was called */
     if (g_fSilentFatalError)
diff --git a/include/os.h b/include/os.h
index 4b5b440..970ff02 100644
--- a/include/os.h
+++ b/include/os.h
@@ -321,7 +321,7 @@ extern _X_EXPORT void
 OsCleanup(Bool);
 
 extern _X_EXPORT void
-OsVendorFatalError(void);
+OsVendorFatalError(const char *f, va_list args);
 
 extern _X_EXPORT void
 OsVendorInit(void);
diff --git a/os/log.c b/os/log.c
index 0e49572..315ba1e 100644
--- a/os/log.c
+++ b/os/log.c
@@ -583,6 +583,7 @@ void
 FatalError(const char *f, ...)
 {
     va_list args;
+    va_list args2;
     static Bool beenhere = FALSE;
 
     if (beenhere)
@@ -590,22 +591,25 @@ FatalError(const char *f, ...)
     else
         ErrorF("\nFatal server error:\n");
 
-    va_start(args, f);
+    /* Make a copy for OsVendorFatalError */
+    va_copy(args2, args);
+
 #ifdef __APPLE__
     {
-        va_list args2;
+        va_list apple_args;
 
-        va_copy(args2, args);
-        (void) vsnprintf(__crashreporter_info_buff__,
-                         sizeof(__crashreporter_info_buff__), f, args2);
-        va_end(args2);
+        va_copy(apple_args, args);
+        (void)vsnprintf(__crashreporter_info_buff__,
+                        sizeof(__crashreporter_info_buff__), f, apple_args);
+        va_end(apple_args);
     }
 #endif
     VErrorF(f, args);
     va_end(args);
     ErrorF("\n");
     if (!beenhere)
-        OsVendorFatalError();
+        OsVendorFatalError(f, args2);
+    va_end(args2);
     if (!beenhere) {
         beenhere = TRUE;
         AbortServer();
diff --git a/test/ddxstubs.c b/test/ddxstubs.c
index a214b96..3647dc5 100644
--- a/test/ddxstubs.c
+++ b/test/ddxstubs.c
@@ -50,7 +50,7 @@ OsVendorInit(void)
 }
 
 void
-OsVendorFatalError(void)
+OsVendorFatalError(const char *f, va_list args)
 {
 }
 
commit 32235e978685d3ebe9c418fecfe3ec584c402008
Merge: 58dfb13 dab90b6
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Thu May 17 09:56:29 2012 -0700

    Merge remote-tracking branch 'whot/server-1.12-branch' into server-1.12-branch

commit dab90b60f3b2ebfd8df4fa761f3f34859250f4db
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Tue May 1 10:21:12 2012 -0700

    Report touch emulated buttons in XIQueryPointer for XI 2.1 and earlier
    
    XInput 2.1 and earlier clients do not know about touches. We must report
    touch emulated button presses for these clients. For later clients, we
    only report true pointer button presses.
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit ee542b85590814ee25369babce1ad14feeb137af)

diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
index ba99752..169436e 100644
--- a/Xi/xiquerypointer.c
+++ b/Xi/xiquerypointer.c
@@ -79,10 +79,21 @@ ProcXIQueryPointer(ClientPtr client)
     XkbStatePtr state;
     char *buttons = NULL;
     int buttons_size = 0;       /* size of buttons array */
+    XIClientPtr xi_client;
+    Bool have_xi22 = FALSE;
 
     REQUEST(xXIQueryPointerReq);
     REQUEST_SIZE_MATCH(xXIQueryPointerReq);
 
+    /* Check if client is compliant with XInput 2.2 or later. Earlier clients
+     * do not know about touches, so we must report emulated button presses. 2.2
+     * and later clients are aware of touches, so we don't include emulated
+     * button presses in the reply. */
+    xi_client = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
+    if (version_compare(xi_client->major_version,
+                        xi_client->minor_version, 2, 2) >= 0)
+        have_xi22 = TRUE;
+
     rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixReadAccess);
     if (rc != Success) {
         client->errorValue = stuff->deviceid;
@@ -145,6 +156,9 @@ ProcXIQueryPointer(ClientPtr client)
         for (i = 1; i < pDev->button->numButtons; i++)
             if (BitIsOn(pDev->button->down, i))
                 SetBit(buttons, pDev->button->map[i]);
+
+        if (!have_xi22 && pDev->touch && pDev->touch->buttonsDown > 0)
+            SetBit(buttons, pDev->button->map[1]);
     }
     else
         rep.buttons_len = 0;
commit 04474fc6a4c21a06c1a65c7afcbc4e0a27e3d0f7
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Tue May 1 10:21:11 2012 -0700

    Report logical button state in ProcXIQueryPointer
    
    Physical button state is usually meaningless to an X client.
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit 1e7b500a8e1d79b91a4e857a2da06194efe8cf69)

diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
index a2e7442..ba99752 100644
--- a/Xi/xiquerypointer.c
+++ b/Xi/xiquerypointer.c
@@ -132,7 +132,7 @@ ProcXIQueryPointer(ClientPtr client)
     }
 
     if (pDev->button) {
-        int i, down;
+        int i;
 
         rep.buttons_len =
             bytes_to_int32(bits_to_bytes(pDev->button->numButtons));
@@ -142,14 +142,9 @@ ProcXIQueryPointer(ClientPtr client)
         if (!buttons)
             return BadAlloc;
 
-        down = pDev->button->buttonsDown;
-
-        for (i = 0; i < pDev->button->numButtons && down; i++) {
-            if (BitIsOn(pDev->button->down, i)) {
-                SetBit(buttons, i);
-                down--;
-            }
-        }
+        for (i = 1; i < pDev->button->numButtons; i++)
+            if (BitIsOn(pDev->button->down, i))
+                SetBit(buttons, pDev->button->map[i]);
     }
     else
         rep.buttons_len = 0;
commit 3b25ed442ca9152841fa821ac3b01c2c9cb4e0d1
Author: Daniel Kurtz <djkurtz at chromium.org>
Date:   Wed Apr 18 17:51:53 2012 +0800

    os/log: refactor logging
    
    It is not safe to ever use an arbitrary (possibly user supplied) string as
    part of the format for a *sprintf() call.
    
    For example:
      1. Name a Bluetooth keyboard "%n%n%n%n%n%n%n%n"
      2. Pair it with a computer running X and try to use it
      3. X is not happy when trying to do the following in xf86-input-evdev:
         xf86IDrvMsg(pInfo, X_CONFIG, "Device: \"%s\"\n", device);
         because LogVHdrMessageVerb() has put the %n from the device name
         into a format string of the form:
            "evdev: %n%n%n%n%n%n%n%n: Device: \"%s\"\n"
    
    Instead, build up a log message in place by appending successive formatted
    strings by sncprintf'ing to the end of the previous.
    
    Signed-off-by: Daniel Kurtz <djkurtz at chromium.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit c91d00e0f330b9de604068e1bfcb0a307096434f)

diff --git a/os/log.c b/os/log.c
index b790306..0e49572 100644
--- a/os/log.c
+++ b/os/log.c
@@ -265,36 +265,19 @@ LogSetParameter(LogParameter param, int value)
 }
 
 /* This function does the actual log message writes. */
-
-void
-LogVWrite(int verb, const char *f, va_list args)
+static void
+LogSWrite(int verb, const char *buf, size_t len, Bool end_line)
 {
-    static char tmpBuffer[1024];
-    int len = 0;
     static Bool newline = TRUE;
 
-    if (verb > logFileVerbosity && verb > logVerbosity)
-        return;
-
-    /*
-     * Since a va_list can only be processed once, write the string to a
-     * buffer, and then write the buffer out to the appropriate output
-     * stream(s).
-     */
-    if (verb < 0 || logFileVerbosity >= verb || logVerbosity >= verb) {
-        len = Xvscnprintf(tmpBuffer, sizeof(tmpBuffer), f, args);
-        /* If message is truncated, terminate with '\n' */
-        if (sizeof(tmpBuffer) - len == 1)
-            tmpBuffer[len - 1] = '\n';
-    }
-    if ((verb < 0 || logVerbosity >= verb) && len > 0)
-        fwrite(tmpBuffer, len, 1, stderr);
-    if ((verb < 0 || logFileVerbosity >= verb) && len > 0) {
+    if (verb < 0 || logVerbosity >= verb)
+        fwrite(buf, len, 1, stderr);
+    if (verb < 0 || logFileVerbosity >= verb) {
         if (logFile) {
             if (newline)
                 fprintf(logFile, "[%10.3f] ", GetTimeInMillis() / 1000.0);
-            newline = (tmpBuffer[len - 1] == '\n');
-            fwrite(tmpBuffer, len, 1, logFile);
+            newline = end_line;
+            fwrite(buf, len, 1, logFile);
             if (logFlush) {
                 fflush(logFile);
 #ifndef WIN32
@@ -312,13 +295,19 @@ LogVWrite(int verb, const char *f, va_list args)
                     FatalError("realloc() failed while saving log messages\n");
             }
             bufferUnused -= len;
-            memcpy(saveBuffer + bufferPos, tmpBuffer, len);
+            memcpy(saveBuffer + bufferPos, buf, len);
             bufferPos += len;
         }
     }
 }
 
 void
+LogVWrite(int verb, const char *f, va_list args)
+{
+    return LogVMessageVerb(X_NONE, verb, f, args);
+}
+
+void
 LogWrite(int verb, const char *f, ...)
 {
     va_list args;
@@ -371,22 +360,28 @@ void
 LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
 {
     const char *type_str;
-    char tmpFormat[1024];
-    const char *new_format;
+    char buf[1024];
+    const size_t size = sizeof(buf);
+    Bool newline;
+    size_t len = 0;
 
     type_str = LogMessageTypeVerbString(type, verb);
     if (!type_str)
         return;
 
-    /* if type_str is not "", prepend it and ' ', to format */
-    if (type_str[0] == '\0')
-        new_format = format;
-    else {
-        new_format = tmpFormat;
-        snprintf(tmpFormat, sizeof(tmpFormat), "%s %s", type_str, format);
-    }
+    /* if type_str is not "", prepend it and ' ', to message */
+    if (type_str[0] != '\0')
+        len += Xscnprintf(&buf[len], size - len, "%s ", type_str);
+
+    if (size - len > 1)
+        len += Xvscnprintf(&buf[len], size - len, format, args);
+
+    /* Force '\n' at end of truncated line */
+    if (size - len == 1)
+        buf[len - 1] = '\n';
 
-    LogVWrite(verb, new_format, args);
+    newline = (buf[len - 1] == '\n');
+    LogSWrite(verb, buf, len, newline);
 }
 
 /* Log message with verbosity level specified. */
@@ -416,31 +411,31 @@ LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format,
                    va_list msg_args, const char *hdr_format, va_list hdr_args)
 {
     const char *type_str;
-    char tmpFormat[1024];
-    char *tmpFormat_end = &tmpFormat[sizeof(tmpFormat)];
-    char *p;
-    int left;
+    char buf[1024];
+    const size_t size = sizeof(buf);
+    Bool newline;
+    size_t len = 0;
 
     type_str = LogMessageTypeVerbString(type, verb);
     if (!type_str)
         return;
 
-    /* if type_str != "", copy it and ' ' to tmpFormat; set p after ' ' */
-    p = tmpFormat;
+    /* if type_str is not "", prepend it and ' ', to message */
     if (type_str[0] != '\0')
-        p += snprintf(tmpFormat, sizeof(tmpFormat), "%s ", type_str);
+        len += Xscnprintf(&buf[len], size - len, "%s ", type_str);
+
+    if (hdr_format && size - len > 1)
+        len += Xvscnprintf(&buf[len], size - len, hdr_format, hdr_args);
 
-    /* append as much of hdr as fits after type_str (if there was one) */
-    left = tmpFormat_end - p;
-    if (left > 1)
-        p += vsnprintf(p, left, hdr_format, hdr_args);
+    if (msg_format && size - len > 1)
+        len += Xvscnprintf(&buf[len], size - len, msg_format, msg_args);
 
-    /* append as much of msg_format as will fit after hdr */
-    left = tmpFormat_end - p;
-    if (left > 1)
-        snprintf(p, left, "%s", msg_format);
+    /* Force '\n' at end of truncated line */
+    if (size - len == 1)
+        buf[len - 1] = '\n';
 
-    LogVWrite(verb, tmpFormat, msg_args);
+    newline = (buf[len - 1] == '\n');
+    LogSWrite(verb, buf, len, newline);
 }
 
 void
commit 34a82b393a037788fbebbc423bfdcdd6f94f3577
Author: Daniel Kurtz <djkurtz at chromium.org>
Date:   Wed Apr 18 17:51:52 2012 +0800

    os/log: only write timestamp if a message is actually written to logfile
    
    The current code will write a timestamps into the logFile whenever
    the last message ended with a '\n' - even if the verb for that timestamp
    is at too high a level.  This timestamp will sit there with no matching
    message until the next call to LogVWrite with a valid verb.
    
    In other words, in some cases, timestamps in the X.org.log are for some
    completely unrelated message that was previously ignored due to
    insufficient verbosity, and not for the message that appears next to it
    in the log file.
    
    We keep the current policy which appears to be to only apply timestamps if
    a message is actually written to a log file.  That is, no timestamps on
    stderr, or in the mem buffer.  Therefore, the timestamp stringification
    is moved to the conditional where it is used.
    
    Since logging uses a fixed length buffer, this patch also forces a '\n'
    whenever a buffer is terminated due to a too-long write request.  This
    allows the newline detection to work even on overflow, and also cleans up
    the log a bit in the overflow case.
    
    Signed-off-by: Daniel Kurtz <djkurtz at chromium.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit 6ce0eac4f8a05f6d7401445cab95027709d3a479)

diff --git a/os/log.c b/os/log.c
index 297b46a..b790306 100644
--- a/os/log.c
+++ b/os/log.c
@@ -273,12 +273,8 @@ LogVWrite(int verb, const char *f, va_list args)
     int len = 0;
     static Bool newline = TRUE;
 
-    if (newline) {
-        sprintf(tmpBuffer, "[%10.3f] ", GetTimeInMillis() / 1000.0);
-        len = strlen(tmpBuffer);
-        if (logFile)
-            fwrite(tmpBuffer, len, 1, logFile);
-    }
+    if (verb > logFileVerbosity && verb > logVerbosity)
+        return;
 
     /*
      * Since a va_list can only be processed once, write the string to a
@@ -286,14 +282,18 @@ LogVWrite(int verb, const char *f, va_list args)
      * stream(s).
      */
     if (verb < 0 || logFileVerbosity >= verb || logVerbosity >= verb) {
-        vsnprintf(tmpBuffer, sizeof(tmpBuffer), f, args);
-        len = strlen(tmpBuffer);
+        len = Xvscnprintf(tmpBuffer, sizeof(tmpBuffer), f, args);
+        /* If message is truncated, terminate with '\n' */
+        if (sizeof(tmpBuffer) - len == 1)
+            tmpBuffer[len - 1] = '\n';
     }
-    newline = (tmpBuffer[len - 1] == '\n');
     if ((verb < 0 || logVerbosity >= verb) && len > 0)
         fwrite(tmpBuffer, len, 1, stderr);
     if ((verb < 0 || logFileVerbosity >= verb) && len > 0) {
         if (logFile) {
+            if (newline)
+                fprintf(logFile, "[%10.3f] ", GetTimeInMillis() / 1000.0);
+            newline = (tmpBuffer[len - 1] == '\n');
             fwrite(tmpBuffer, len, 1, logFile);
             if (logFlush) {
                 fflush(logFile);
commit 8998037f183fd1f73fe0d272b4e072e53c7f3bcc
Author: Daniel Kurtz <djkurtz at chromium.org>
Date:   Wed Apr 18 09:51:51 2012 +0000

    os/xprintf: add Xvscnprintf and Xscnprintf
    
    Normal snprintf() usually returns the number of bytes that would have been
    written into a buffer had the buffer been long enough.
    
    The scnprintf() variants return the actual number of bytes written,
    excluding the trailing '\0'.
    
    Signed-off-by: Daniel Kurtz <djkurtz at chromium.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit 5c2e2a164d615ab06be28a663734e782614b5cc7)

diff --git a/include/Xprintf.h b/include/Xprintf.h
index 414fd46..9e8cdc5 100644
--- a/include/Xprintf.h
+++ b/include/Xprintf.h
@@ -66,4 +66,16 @@ _X_ATTRIBUTE_PRINTF(2, 0);
 #define vasprintf Xvasprintf
 #endif
 
+/*
+ * These functions provide a portable implementation of the linux kernel
+ * scnprintf & vscnprintf routines that return the number of bytes actually
+ * copied during a snprintf, (excluding the final '\0').
+ */
+extern _X_EXPORT int
+Xscnprintf(char *s, int n, const char * _X_RESTRICT_KYWD fmt, ...)
+_X_ATTRIBUTE_PRINTF(3,4);
+extern _X_EXPORT int
+Xvscnprintf(char *s, int n, const char * _X_RESTRICT_KYWD fmt, va_list va)
+_X_ATTRIBUTE_PRINTF(3,0);
+
 #endif                          /* XPRINTF_H */
diff --git a/os/xprintf.c b/os/xprintf.c
index 17fea2e..80caa57 100644
--- a/os/xprintf.c
+++ b/os/xprintf.c
@@ -186,6 +186,50 @@ XNFasprintf(char **ret, const char *_X_RESTRICT_KYWD format, ...)
     return size;
 }
 
+/**
+ * Varargs snprintf that returns the actual number of bytes (excluding final
+ * '\0') that were copied into the buffer.
+ * This is opposed to the normal sprintf() usually returns the number of bytes
+ * that would have been written.
+ *
+ * @param s       buffer to copy into
+ * @param n       size of buffer s
+ * @param format  printf style format string
+ * @param va      variable argument list
+ * @return        number of bytes actually copied, excluding final '\0'
+ */
+int
+Xvscnprintf(char *s, int n, const char *format, va_list args)
+{
+    int x;
+    if (n == 0)
+        return 0;
+    x = vsnprintf(s, n , format, args);
+    return (x >= n) ? (n - 1) : x;
+}
+
+/**
+ * snprintf that returns the actual number of bytes (excluding final '\0') that
+ * were copied into the buffer.
+ * This is opposed to the normal sprintf() usually returns the number of bytes
+ * that would have been written.
+ *
+ * @param s       buffer to copy into
+ * @param n       size of buffer s
+ * @param format  printf style format string
+ * @param ...     arguments for specified format
+ * @return        number of bytes actually copied, excluding final '\0'
+ */
+int Xscnprintf(char *s, int n, const char *format, ...)
+{
+    int x;
+    va_list ap;
+    va_start(ap, format);
+    x = Xvscnprintf(s, n, format, ap);
+    va_end(ap);
+    return x;
+}
+
 /* Old api, now deprecated, may be removed in the future */
 char *
 Xvprintf(const char *format, va_list va)
commit 9a2030ea26a2a0821d87afea502f5446ae002a6d
Author: Daniel Kurtz <djkurtz at chromium.org>
Date:   Wed Apr 18 17:51:50 2012 +0800

    os/log: trivial cleanups
    
     * space->tab
     * remove comment that doesn't make any sense
    
    Signed-off-by: Daniel Kurtz <djkurtz at chromium.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit c30862879d2c766519780bb7f353f35edf0daa9b)

diff --git a/os/log.c b/os/log.c
index 0ccd126..297b46a 100644
--- a/os/log.c
+++ b/os/log.c
@@ -165,7 +165,7 @@ asm(".desc ___crashreporter_info__, 0x10");
 #define X_NOT_IMPLEMENTED_STRING	"(NI)"
 #endif
 #ifndef X_NONE_STRING
-#define X_NONE_STRING                   ""
+#define X_NONE_STRING			""
 #endif
 
 /*
@@ -223,7 +223,7 @@ LogInit(const char *fname, const char *backup)
      * needed.
      */
     if (saveBuffer && bufferSize > 0) {
-        free(saveBuffer);       /* Must be free(), not free() */
+        free(saveBuffer);
         saveBuffer = NULL;
         bufferSize = 0;
     }
commit 58dfb13953af71021317b9d85230b1163198f031
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Thu May 10 00:53:20 2012 -0700

    Revert "dix: when disabling a device, release all buttons and keys"
    
    This reverts commit 90299556db24543bb7365e8c2897deca3aa219e7.
    
    The commit being reverted triggered a segfault on server shutdown when a
    device posts raw events after the root windows are forced to NULL.
    
    https://lists.debian.org/debian-x/2012/05/msg00240.html
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/dix/devices.c b/dix/devices.c
index d0e99bd..0125504 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -432,8 +432,6 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
     if (*prev != dev)
         return FALSE;
 
-    ReleaseButtonsAndKeys(dev);
-
     /* float attached devices */
     if (IsMaster(dev)) {
         for (other = inputInfo.devices; other; other = other->next) {
commit f012f0c48dedba4df69cc1a1ecdf8ee5d37daca9
Author: Michal Suchanek <hramrach at gmail.com>
Date:   Thu Apr 26 15:11:20 2012 +0200

    dmx: Annotate dmxlog.c with _X_ATTRIBUTE_PRINTF and _X_NORETURN
    
    and fix resulting printf warning in dmxLogVisual
    
    Signed-off-by: Michal Suchanek <hramrach at gmail.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit d662fa2450856777b59c4b62b912395a8bfd52fd)

diff --git a/hw/dmx/dmxlog.c b/hw/dmx/dmxlog.c
index b56bb93..151f672 100644
--- a/hw/dmx/dmxlog.c
+++ b/hw/dmx/dmxlog.c
@@ -86,6 +86,8 @@ ErrorF(const char *format, ...)
 
 /** Provide an VFatalError function when used stand-alone. */
 static void
+VFatalError(const char *format, va_list args) _X_ATTRIBUTE_PRINTF(1, 0) _X_NORETURN;
+static void
 VFatalError(const char *format, va_list args)
 {
     vfprintf(stderr, format, args);     /* RATS: We assume the format string
@@ -104,7 +106,9 @@ VErrorF(const char *format, va_list args)
 }
 #else
 /** This function was removed between XFree86 4.3.0 and XFree86 4.4.0. */
-extern void AbortServer(void);
+extern void AbortServer(void) _X_NORETURN;
+static void
+VFatalError(const char *format, va_list args) _X_ATTRIBUTE_PRINTF(1, 0) _X_NORETURN;
 static void
 VFatalError(const char *format, va_list args)
 {
@@ -166,6 +170,8 @@ dmxHeader(dmxLogLevel logLevel, DMXInputInfo * dmxInput,
 /* Prints the error message with the appropriate low-level X output
  * routine. */
 static void
+dmxMessage(dmxLogLevel logLevel, const char *format, va_list args) _X_ATTRIBUTE_PRINTF(2, 0);
+static void
 dmxMessage(dmxLogLevel logLevel, const char *format, va_list args)
 {
     if (logLevel == dmxFatal || logLevel >= dmxCurrentLogLevel) {
@@ -303,10 +309,11 @@ dmxLogVisual(DMXScreenInfo * dmxScreen, XVisualInfo * vi, int defaultVisual)
         class = "DirectColor";
         break;
     }
+#define VisualLogFormat "0x%02lx %s %2db %db/rgb %3d 0x%04lx 0x%04lx 0x%04lx%s\n"
 
     if (dmxScreen) {
         dmxLogOutput(dmxScreen,
-                     "0x%02x %s %2db %db/rgb %3d 0x%04x 0x%04x 0x%04x%s\n",
+                     VisualLogFormat,
                      vi->visualid, class, vi->depth, vi->bits_per_rgb,
                      vi->colormap_size,
                      vi->red_mask, vi->green_mask, vi->blue_mask,
@@ -314,7 +321,7 @@ dmxLogVisual(DMXScreenInfo * dmxScreen, XVisualInfo * vi, int defaultVisual)
     }
     else {
         dmxLog(dmxInfo,
-               "  0x%02x %s %2db %db/rgb %3d 0x%04x 0x%04x 0x%04x%s\n",
+               "  " VisualLogFormat,
                vi->visualid, class, vi->depth, vi->bits_per_rgb,
                vi->colormap_size,
                vi->red_mask, vi->green_mask, vi->blue_mask,
diff --git a/hw/dmx/dmxlog.h b/hw/dmx/dmxlog.h
index 4d4cd26..162484b 100644
--- a/hw/dmx/dmxlog.h
+++ b/hw/dmx/dmxlog.h
@@ -55,18 +55,23 @@ typedef enum {
 /* Logging functions used by Xserver/hw/dmx routines. */
 extern dmxLogLevel dmxSetLogLevel(dmxLogLevel newLevel);
 extern dmxLogLevel dmxGetLogLevel(void);
-extern void dmxLog(dmxLogLevel logLevel, const char *format, ...);
-extern void dmxLogCont(dmxLogLevel logLevel, const char *format, ...);
+extern void dmxLog(dmxLogLevel logLevel, const char *format,
+                             ...) _X_ATTRIBUTE_PRINTF(2, 3);
+extern void dmxLogCont(dmxLogLevel logLevel, const char *format,
+                             ...) _X_ATTRIBUTE_PRINTF(2, 3);
 extern const char *dmxEventName(int type);
 
 #ifndef DMX_LOG_STANDALONE
-extern void dmxLogOutput(DMXScreenInfo * dmxScreen, const char *format, ...);
+extern void dmxLogOutput(DMXScreenInfo * dmxScreen, const char *format,
+                             ...) _X_ATTRIBUTE_PRINTF(2, 3);
 extern void dmxLogOutputCont(DMXScreenInfo * dmxScreen, const char *format,
-                             ...);
+                             ...) _X_ATTRIBUTE_PRINTF(2, 3);
 extern void dmxLogOutputWarning(DMXScreenInfo * dmxScreen, const char *format,
-                                ...);
-extern void dmxLogInput(DMXInputInfo * dmxInput, const char *format, ...);
-extern void dmxLogInputCont(DMXInputInfo * dmxInput, const char *format, ...);
+                             ...) _X_ATTRIBUTE_PRINTF(2, 3);
+extern void dmxLogInput(DMXInputInfo * dmxInput, const char *format,
+                             ...) _X_ATTRIBUTE_PRINTF(2, 3);
+extern void dmxLogInputCont(DMXInputInfo * dmxInput, const char *format,
+                             ...) _X_ATTRIBUTE_PRINTF(2, 3);
 extern void dmxLogArgs(dmxLogLevel logLevel, int argc, char **argv);
 extern void dmxLogVisual(DMXScreenInfo * dmxScreen, XVisualInfo * vi,
                          int defaultVisual);
commit f8d2ca759ad37d5e99d462f21a2259ce17bb1a00
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Apr 18 15:56:37 2012 +1000

    dix: indentation fix
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit ebf214876a4885a98ded4f5525925b69005fae05)

diff --git a/dix/dispatch.c b/dix/dispatch.c
index 9a2e22f..d971805 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -416,8 +416,8 @@ Dispatch(void)
                 if (XSERVER_REQUEST_START_ENABLED())
                     XSERVER_REQUEST_START(LookupMajorName(client->majorOp),
                                           client->majorOp,
-                                          ((xReq *) client->requestBuffer)->
-                                          length, client->index,
+                                          ((xReq *) client->requestBuffer)->length,
+                                          client->index,
                                           client->requestBuffer);
 #endif
                 if (result > (maxBigRequestSize << 2))
commit 15607cf2dc87405606b20113011f1ebd97637d32
Author: Daniel Kurtz <djkurtz at chromium.org>
Date:   Thu Apr 12 10:11:10 2012 +1000

    dix: don't BUG_WARN for button events from button-only device
    
    Events from button-only devices still need coordinates, and they get them
    from scale_to_desktop().  Therefore, a dev without valuators is not a bug.
    However, a dev with valuators, but less than two of them still is a bug.
    
    This was noticed when unplugging a "Creative Technology SB Arena Headset",
    which has some BTNs and some KEYs, but no REL or ABS valuators.
    It emits [BTN_3] = 0 on unplug, which would trigger the BUG_WARN.
    
    Signed-off-by: Daniel Kurtz <djkurtz at chromium.org>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit c5a45b0f7658c77725adce2b64a0fbd62f208328)

diff --git a/dix/getevents.c b/dix/getevents.c
index 4e0af45..9dc9617 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -842,7 +842,7 @@ scale_to_desktop(DeviceIntPtr dev, ValuatorMask *mask,
     ScreenPtr scr = miPointerGetScreen(dev);
     double x, y;
 
-    BUG_WARN(!dev->valuator || dev->valuator->numAxes < 2);
+    BUG_WARN(dev->valuator && dev->valuator->numAxes < 2);
     if (!dev->valuator || dev->valuator->numAxes < 2) {
         /* if we have no axes, last.valuators must be in screen coords
          * anyway */
commit 3ad72a80088fe3236f38bd0696b04f399e24fe3d
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Apr 11 09:33:54 2012 -0700

    hw/xfree86: Re-indent xf86vmode.c
    
    This is the result of re-running the 'x-indent.sh' script over
    xf86vmode.c to clean up the disaster caused by broken syntax in the
    file.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 9779b904c7c0b49c74054c22c420012c40595cdc)

diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c
index 9f64f8e..68c4b58 100644
--- a/hw/xfree86/dixmods/extmod/xf86vmode.c
+++ b/hw/xfree86/dixmods/extmod/xf86vmode.c
@@ -75,8 +75,7 @@ static unsigned char XF86VidModeReqCode = 0;
 #ifdef XF86VIDMODE_EVENTS
 static int XF86VidModeEventBase = 0;
 
-static void SXF86VidModeNotifyEvent(
-xXF86VidModeNotifyEvent * /* from */ , xXF86VidModeNotifyEvent *        /* to */
+static void SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent * /* from */ , xXF86VidModeNotifyEvent *    /* to */
     );
 
 static RESTYPE EventType;       /* resource type for event masks */
@@ -117,20 +116,22 @@ static DevPrivateKeyRec ScreenPrivateKeyRec;
 #define DEBUG_P(x) /**/
 #endif
     static int
- ClientMajorVersion(ClientPtr client) {
+ClientMajorVersion(ClientPtr client)
+{
     VidModePrivPtr pPriv;
 
-     pPriv = VM_GETPRIV(client);
+    pPriv = VM_GETPRIV(client);
     if (!pPriv)
-         return 0;
+        return 0;
     else
-         return pPriv->major;
+        return pPriv->major;
 }
+
 #ifdef XF86VIDMODE_EVENTS
 static void
- CheckScreenPrivate(pScreen)
+CheckScreenPrivate(pScreen)
 ScreenPtr
-    pScreen;
+ pScreen;
 {
     SetupScreen(pScreen);
 
@@ -142,9 +143,10 @@ ScreenPtr
     }
 }
 
-static XF86VidModeScreenPrivatePtr MakeScreenPrivate(pScreen)
+static XF86VidModeScreenPrivatePtr
+MakeScreenPrivate(pScreen)
 ScreenPtr
-    pScreen;
+ pScreen;
 {
     SetupScreen(pScreen);
 
@@ -160,18 +162,22 @@ ScreenPtr
 }
 
 static unsigned long
- getEventMask(ScreenPtr pScreen, ClientPtr client) {
+getEventMask(ScreenPtr pScreen, ClientPtr client)
+{
     SetupScreen(pScreen);
     XF86VidModeEventPtr pEv;
 
     if (!pPriv)
-         return 0;
+        return 0;
     for (pEv = pPriv->events; pEv; pEv = pEv->next)
         if (pEv->client == client)
             return pEv->mask;
-     return 0;
-} static Bool
- setEventMask(ScreenPtr pScreen, ClientPtr client, unsigned long mask) {
+    return 0;
+}
+
+static Bool
+setEventMask(ScreenPtr pScreen, ClientPtr client, unsigned long mask)
+{
     SetupScreen(pScreen);
     XF86VidModeEventPtr pEv, *pPrev;
 
@@ -181,7 +187,8 @@ static unsigned long
         pPriv = MakeScreenPrivate(pScreen);
         if (!pPriv)
             return FALSE;
-    } for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next)
+    }
+    for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next)
         if (pEv->client == client)
             break;
     if (mask == 0) {
@@ -208,38 +215,43 @@ static unsigned long
 }
 
 static int
- XF86VidModeFreeEvents(pointer value, XID id) {
+XF86VidModeFreeEvents(pointer value, XID id)
+{
     XF86VidModeEventPtr pOld = (XF86VidModeEventPtr) value;
     ScreenPtr pScreen = pOld->screen;
-     SetupScreen(pScreen);
+
+    SetupScreen(pScreen);
     XF86VidModeEventPtr pEv, *pPrev;
 
     if (!pPriv)
-         return TRUE;
+        return TRUE;
     for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next)
         if (pEv == pOld)
             break;
     if (!pEv)
-         return TRUE;
+        return TRUE;
     *pPrev = pEv->next;
-     free(pEv);
-     CheckScreenPrivate(pScreen);
-     return TRUE;
-} static void
- SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced) {
+    free(pEv);
+    CheckScreenPrivate(pScreen);
+    return TRUE;
+}
+
+static void
+SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced)
+{
     XF86VidModeScreenPrivatePtr pPriv;
     XF86VidModeEventPtr pEv;
     unsigned long mask;
     xXF86VidModeNotifyEvent ev;
     int kind;
 
-     UpdateCurrentTimeIf();
-     mask = XF86VidModeNotifyMask;
-     pScreen = screenInfo.screens[pScreen->myNum];
-     pPriv = GetScreenPrivate(pScreen);
+    UpdateCurrentTimeIf();
+    mask = XF86VidModeNotifyMask;
+    pScreen = screenInfo.screens[pScreen->myNum];
+    pPriv = GetScreenPrivate(pScreen);
     if (!pPriv)
-         return;
-     kind = XF86VidModeModeChange;
+        return;
+    kind = XF86VidModeModeChange;
     for (pEv = pPriv->events; pEv; pEv = pEv->next) {
         if (!(pEv->mask & mask))
             continue;
@@ -251,8 +263,10 @@ static int
         ev.forced = forced;
         WriteEventsToClient(pEv->client, 1, (xEvent *) &ev);
 }} static void
- SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent * from,
-                         xXF86VidModeNotifyEvent * to) {
+
+SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent * from,
+                        xXF86VidModeNotifyEvent * to)
+{
     to->type = from->type;
     to->state = from->state;
     cpswaps(from->sequenceNumber, to->sequenceNumber);
@@ -264,29 +278,31 @@ static int
 #endif
 
 static int
- ProcXF86VidModeQueryVersion(ClientPtr client) {
+ProcXF86VidModeQueryVersion(ClientPtr client)
+{
     xXF86VidModeQueryVersionReply rep;
 
-     DEBUG_P("XF86VidModeQueryVersion");
+    DEBUG_P("XF86VidModeQueryVersion");
 
-     REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq);
-     rep.type = X_Reply;
-     rep.length = 0;
-     rep.sequenceNumber = client->sequence;
-     rep.majorVersion = SERVER_XF86VIDMODE_MAJOR_VERSION;
-     rep.minorVersion = SERVER_XF86VIDMODE_MINOR_VERSION;
+    REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq);
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    rep.majorVersion = SERVER_XF86VIDMODE_MAJOR_VERSION;
+    rep.minorVersion = SERVER_XF86VIDMODE_MINOR_VERSION;
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
         swapl(&rep.length);
         swaps(&rep.majorVersion);
         swaps(&rep.minorVersion);
-    } WriteToClient(client, sizeof(xXF86VidModeQueryVersionReply),
-                    (char *) &rep);
+    }
+    WriteToClient(client, sizeof(xXF86VidModeQueryVersionReply), (char *) &rep);
     return Success;
 }
 
 static int
- ProcXF86VidModeGetModeLine(ClientPtr client) {
+ProcXF86VidModeGetModeLine(ClientPtr client)
+{
     REQUEST(xXF86VidModeGetModeLineReq);
     xXF86VidModeGetModeLineReply rep;
     xXF86OldVidModeGetModeLineReply oldrep;
@@ -294,11 +310,11 @@ static int
     int dotClock;
     int ver;
 
-     DEBUG_P("XF86VidModeGetModeline");
+    DEBUG_P("XF86VidModeGetModeline");
 
-     ver = ClientMajorVersion(client);
-     REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
-     rep.type = X_Reply;
+    ver = ClientMajorVersion(client);
+    REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
+    rep.type = X_Reply;
     if (ver < 2) {
         rep.length = bytes_to_int32(SIZEOF(xXF86OldVidModeGetModeLineReply) -
                                     SIZEOF(xGenericReply));
@@ -386,7 +402,8 @@ static int
 }
 
 static int
- ProcXF86VidModeGetAllModeLines(ClientPtr client) {
+ProcXF86VidModeGetAllModeLines(ClientPtr client)
+{
     REQUEST(xXF86VidModeGetAllModeLinesReq);
     xXF86VidModeGetAllModeLinesReply rep;
     xXF86VidModeModeInfo mdinf;
@@ -395,38 +412,39 @@ static int
     int modecount, dotClock;
     int ver;
 
-     DEBUG_P("XF86VidModeGetAllModelines");
+    DEBUG_P("XF86VidModeGetAllModelines");
 
-     REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
+    REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
 
     if (stuff->screen >= screenInfo.numScreens)
-         return BadValue;
+        return BadValue;
 
-     ver = ClientMajorVersion(client);
+    ver = ClientMajorVersion(client);
 
-     modecount = VidModeGetNumOfModes(stuff->screen);
+    modecount = VidModeGetNumOfModes(stuff->screen);
     if (modecount < 1)
-         return VidModeErrorBase + XF86VidModeExtensionDisabled;
+        return VidModeErrorBase + XF86VidModeExtensionDisabled;
 
     if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
-         return BadValue;
+        return BadValue;
 
-     rep.type = X_Reply;
-     rep.length = SIZEOF(xXF86VidModeGetAllModeLinesReply) -
+    rep.type = X_Reply;
+    rep.length = SIZEOF(xXF86VidModeGetAllModeLinesReply) -
         SIZEOF(xGenericReply);
     if (ver < 2)
-         rep.length += modecount * sizeof(xXF86OldVidModeModeInfo);
+        rep.length += modecount * sizeof(xXF86OldVidModeModeInfo);
     else
-         rep.length += modecount * sizeof(xXF86VidModeModeInfo);
-     rep.length >>= 2;
-     rep.sequenceNumber = client->sequence;
-     rep.modecount = modecount;
+        rep.length += modecount * sizeof(xXF86VidModeModeInfo);
+    rep.length >>= 2;
+    rep.sequenceNumber = client->sequence;
+    rep.modecount = modecount;
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
         swapl(&rep.length);
         swapl(&rep.modecount);
-    } WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply),
-                    (char *) &rep);
+    }
+    WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply),
+                  (char *) &rep);
 
     do {
         mdinf.dotclock = dotClock;
@@ -492,7 +510,8 @@ static int
      && VidModeGetModeValue(mode, VIDMODE_FLAGS)  == stuff->flags )
 
 static int
- ProcXF86VidModeAddModeLine(ClientPtr client) {
+ProcXF86VidModeAddModeLine(ClientPtr client)
+{
     REQUEST(xXF86VidModeAddModeLineReq);
     xXF86OldVidModeAddModeLineReq *oldstuff =
         (xXF86OldVidModeAddModeLineReq *) client->requestBuffer;
@@ -502,9 +521,9 @@ static int
     int dotClock;
     int ver;
 
-     DEBUG_P("XF86VidModeAddModeline");
+    DEBUG_P("XF86VidModeAddModeline");
 
-     ver = ClientMajorVersion(client);
+    ver = ClientMajorVersion(client);
     if (ver < 2) {
         /* convert from old format */
         stuff = &newstuff;
@@ -533,7 +552,8 @@ static int
         stuff->after_vsyncend = oldstuff->after_vsyncend;
         stuff->after_vtotal = oldstuff->after_vtotal;
         stuff->after_flags = oldstuff->after_flags;
-    } if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+    }
+    if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
         ErrorF("AddModeLine - scrn: %d clock: %ld\n",
                (int) stuff->screen, (unsigned long) stuff->dotclock);
         ErrorF("AddModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n",
@@ -654,7 +674,8 @@ static int
 }
 
 static int
- ProcXF86VidModeDeleteModeLine(ClientPtr client) {
+ProcXF86VidModeDeleteModeLine(ClientPtr client)
+{
     REQUEST(xXF86VidModeDeleteModeLineReq);
     xXF86OldVidModeDeleteModeLineReq *oldstuff =
         (xXF86OldVidModeDeleteModeLineReq *) client->requestBuffer;
@@ -663,9 +684,9 @@ static int
     int len, dotClock;
     int ver;
 
-     DEBUG_P("XF86VidModeDeleteModeline");
+    DEBUG_P("XF86VidModeDeleteModeline");
 
-     ver = ClientMajorVersion(client);
+    ver = ClientMajorVersion(client);
     if (ver < 2) {
         /* convert from old format */
         stuff = &newstuff;
@@ -683,7 +704,8 @@ static int
         stuff->vtotal = oldstuff->vtotal;
         stuff->flags = oldstuff->flags;
         stuff->privsize = oldstuff->privsize;
-    } if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+    }
+    if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
         ErrorF("DeleteModeLine - scrn: %d clock: %ld\n",
                (int) stuff->screen, (unsigned long) stuff->dotclock);
         ErrorF("                 hdsp: %d hbeg: %d hend: %d httl: %d\n",
@@ -777,7 +799,8 @@ static int
 }
 
 static int
- ProcXF86VidModeModModeLine(ClientPtr client) {
+ProcXF86VidModeModModeLine(ClientPtr client)
+{
     REQUEST(xXF86VidModeModModeLineReq);
     xXF86OldVidModeModModeLineReq *oldstuff =
         (xXF86OldVidModeModModeLineReq *) client->requestBuffer;
@@ -786,9 +809,9 @@ static int
     int len, dotClock;
     int ver;
 
-     DEBUG_P("XF86VidModeModModeline");
+    DEBUG_P("XF86VidModeModModeline");
 
-     ver = ClientMajorVersion(client);
+    ver = ClientMajorVersion(client);
     if (ver < 2) {
         /* convert from old format */
         stuff = &newstuff;
@@ -805,7 +828,8 @@ static int
         stuff->vtotal = oldstuff->vtotal;
         stuff->flags = oldstuff->flags;
         stuff->privsize = oldstuff->privsize;
-    } if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+    }
+    if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
         ErrorF("ModModeLine - scrn: %d hdsp: %d hbeg: %d hend: %d httl: %d\n",
                (int) stuff->screen, stuff->hdisplay, stuff->hsyncstart,
                stuff->hsyncend, stuff->htotal);
@@ -903,7 +927,8 @@ static int
 }
 
 static int
- ProcXF86VidModeValidateModeLine(ClientPtr client) {
+ProcXF86VidModeValidateModeLine(ClientPtr client)
+{
     REQUEST(xXF86VidModeValidateModeLineReq);
     xXF86OldVidModeValidateModeLineReq *oldstuff =
         (xXF86OldVidModeValidateModeLineReq *) client->requestBuffer;
@@ -913,9 +938,9 @@ static int
     int len, status, dotClock;
     int ver;
 
-     DEBUG_P("XF86VidModeValidateModeline");
+    DEBUG_P("XF86VidModeValidateModeline");
 
-     ver = ClientMajorVersion(client);
+    ver = ClientMajorVersion(client);
     if (ver < 2) {
         /* convert from old format */
         stuff = &newstuff;
@@ -933,7 +958,8 @@ static int
         stuff->vtotal = oldstuff->vtotal;
         stuff->flags = oldstuff->flags;
         stuff->privsize = oldstuff->privsize;
-    } if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+    }
+    if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
         ErrorF("ValidateModeLine - scrn: %d clock: %ld\n",
                (int) stuff->screen, (unsigned long) stuff->dotclock);
         ErrorF("                   hdsp: %d hbeg: %d hend: %d httl: %d\n",
@@ -1022,7 +1048,8 @@ static int
 }
 
 static int
- ProcXF86VidModeSwitchMode(ClientPtr client) {
+ProcXF86VidModeSwitchMode(ClientPtr client)
+{
     REQUEST(xXF86VidModeSwitchModeReq);
 
     DEBUG_P("XF86VidModeSwitchMode");
@@ -1035,8 +1062,11 @@ static int
     VidModeZoomViewport(stuff->screen, (short) stuff->zoom);
 
     return Success;
-} static int
- ProcXF86VidModeSwitchToMode(ClientPtr client) {
+}
+
+static int
+ProcXF86VidModeSwitchToMode(ClientPtr client)
+{
     REQUEST(xXF86VidModeSwitchToModeReq);
     xXF86OldVidModeSwitchToModeReq *oldstuff =
         (xXF86OldVidModeSwitchToModeReq *) client->requestBuffer;
@@ -1045,9 +1075,9 @@ static int
     int len, dotClock;
     int ver;
 
-     DEBUG_P("XF86VidModeSwitchToMode");
+    DEBUG_P("XF86VidModeSwitchToMode");
 
-     ver = ClientMajorVersion(client);
+    ver = ClientMajorVersion(client);
     if (ver < 2) {
         /* convert from old format */
         stuff = &newstuff;
@@ -1065,7 +1095,8 @@ static int
         stuff->vtotal = oldstuff->vtotal;
         stuff->flags = oldstuff->flags;
         stuff->privsize = oldstuff->privsize;
-    } if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
+    }
+    if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
         ErrorF("SwitchToMode - scrn: %d clock: %ld\n",
                (int) stuff->screen, (unsigned long) stuff->dotclock);
         ErrorF("               hdsp: %d hbeg: %d hend: %d httl: %d\n",
@@ -1138,7 +1169,8 @@ static int
 }
 
 static int
- ProcXF86VidModeLockModeSwitch(ClientPtr client) {
+ProcXF86VidModeLockModeSwitch(ClientPtr client)
+{
     REQUEST(xXF86VidModeLockModeSwitchReq);
 
     REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
@@ -1152,53 +1184,57 @@ static int
         return VidModeErrorBase + XF86VidModeZoomLocked;
 
     return Success;
-} static int
- ProcXF86VidModeGetMonitor(ClientPtr client) {
+}
+
+static int
+ProcXF86VidModeGetMonitor(ClientPtr client)
+{
     REQUEST(xXF86VidModeGetMonitorReq);
     xXF86VidModeGetMonitorReply rep;
     CARD32 *hsyncdata, *vsyncdata;
     int i, nHsync, nVrefresh;
     pointer monitor;
 
-     DEBUG_P("XF86VidModeGetMonitor");
+    DEBUG_P("XF86VidModeGetMonitor");
 
-     REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
+    REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
 
     if (stuff->screen >= screenInfo.numScreens)
-         return BadValue;
+        return BadValue;
 
     if (!VidModeGetMonitor(stuff->screen, &monitor))
-         return BadValue;
+        return BadValue;
 
-     nHsync = VidModeGetMonitorValue(monitor, VIDMODE_MON_NHSYNC, 0).i;
-     nVrefresh = VidModeGetMonitorValue(monitor, VIDMODE_MON_NVREFRESH, 0).i;
+    nHsync = VidModeGetMonitorValue(monitor, VIDMODE_MON_NHSYNC, 0).i;
+    nVrefresh = VidModeGetMonitorValue(monitor, VIDMODE_MON_NVREFRESH, 0).i;
 
-     rep.type = X_Reply;
+    rep.type = X_Reply;
     if ((char *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr)
-         rep.vendorLength = strlen((char *) (VidModeGetMonitorValue(monitor,
-                                                                    VIDMODE_MON_VENDOR,
-                                                                    0)).ptr);
+        rep.vendorLength = strlen((char *) (VidModeGetMonitorValue(monitor,
+                                                                   VIDMODE_MON_VENDOR,
+                                                                   0)).ptr);
     else
-         rep.vendorLength = 0;
+        rep.vendorLength = 0;
     if ((char *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_MODEL, 0)).ptr)
-         rep.modelLength = strlen((char *) (VidModeGetMonitorValue(monitor,
-                                                                   VIDMODE_MON_MODEL,
-                                                                   0)).ptr);
+        rep.modelLength = strlen((char *) (VidModeGetMonitorValue(monitor,
+                                                                  VIDMODE_MON_MODEL,
+                                                                  0)).ptr);
     else
-         rep.modelLength = 0;
-     rep.length =
+        rep.modelLength = 0;
+    rep.length =
         bytes_to_int32(SIZEOF(xXF86VidModeGetMonitorReply) -
                        SIZEOF(xGenericReply) + (nHsync +
                                                 nVrefresh) * sizeof(CARD32) +
                        pad_to_int32(rep.vendorLength) +
                        pad_to_int32(rep.modelLength));
-     rep.sequenceNumber = client->sequence;
-     rep.nhsync = nHsync;
-     rep.nvsync = nVrefresh;
-     hsyncdata = malloc(nHsync * sizeof(CARD32));
+    rep.sequenceNumber = client->sequence;
+    rep.nhsync = nHsync;
+    rep.nvsync = nVrefresh;
+    hsyncdata = malloc(nHsync * sizeof(CARD32));
     if (!hsyncdata) {
         return BadAlloc;
-    } vsyncdata = malloc(nVrefresh * sizeof(CARD32));
+    }
+    vsyncdata = malloc(nVrefresh * sizeof(CARD32));
 
     if (!vsyncdata) {
         free(hsyncdata);
@@ -1208,19 +1244,18 @@ static int
     for (i = 0; i < nHsync; i++) {
         hsyncdata[i] = (unsigned short) (VidModeGetMonitorValue(monitor,
                                                                 VIDMODE_MON_HSYNC_LO,
-                                                                i)).
-            f | (unsigned
-                 short) (VidModeGetMonitorValue(monitor, VIDMODE_MON_HSYNC_HI,
-                                                i)).f << 16;
+                                                                i)).f |
+            (unsigned
+             short) (VidModeGetMonitorValue(monitor, VIDMODE_MON_HSYNC_HI,
+                                            i)).f << 16;
     }
     for (i = 0; i < nVrefresh; i++) {
         vsyncdata[i] = (unsigned short) (VidModeGetMonitorValue(monitor,
                                                                 VIDMODE_MON_VREFRESH_LO,
-                                                                i)).
-            f | (unsigned
-                 short) (VidModeGetMonitorValue(monitor,
-                                                VIDMODE_MON_VREFRESH_HI,
-                                                i)).f << 16;
+                                                                i)).f |
+            (unsigned
+             short) (VidModeGetMonitorValue(monitor, VIDMODE_MON_VREFRESH_HI,
+                                            i)).f << 16;
     }
 
     if (client->swapped) {
@@ -1249,38 +1284,40 @@ static int
 }
 
 static int
- ProcXF86VidModeGetViewPort(ClientPtr client) {
+ProcXF86VidModeGetViewPort(ClientPtr client)
+{
     REQUEST(xXF86VidModeGetViewPortReq);
     xXF86VidModeGetViewPortReply rep;
     int x, y;
 
-     DEBUG_P("XF86VidModeGetViewPort");
+    DEBUG_P("XF86VidModeGetViewPort");
 
-     REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
+    REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
 
     if (stuff->screen >= screenInfo.numScreens)
-         return BadValue;
+        return BadValue;
 
-     rep.type = X_Reply;
-     rep.length = 0;
-     rep.sequenceNumber = client->sequence;
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
 
-     VidModeGetViewPort(stuff->screen, &x, &y);
-     rep.x = x;
-     rep.y = y;
+    VidModeGetViewPort(stuff->screen, &x, &y);
+    rep.x = x;
+    rep.y = y;
 
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
         swapl(&rep.length);
         swapl(&rep.x);
         swapl(&rep.y);
-    } WriteToClient(client, SIZEOF(xXF86VidModeGetViewPortReply),
-                    (char *) &rep);
+    }
+    WriteToClient(client, SIZEOF(xXF86VidModeGetViewPortReply), (char *) &rep);
     return Success;
 }
 
 static int
- ProcXF86VidModeSetViewPort(ClientPtr client) {
+ProcXF86VidModeSetViewPort(ClientPtr client)
+{
     REQUEST(xXF86VidModeSetViewPortReq);
 
     DEBUG_P("XF86VidModeSetViewPort");
@@ -1294,8 +1331,11 @@ static int
         return BadValue;
 
     return Success;
-} static int
- ProcXF86VidModeGetDotClocks(ClientPtr client) {
+}
+
+static int
+ProcXF86VidModeGetDotClocks(ClientPtr client)
+{
     REQUEST(xXF86VidModeGetDotClocksReq);
     xXF86VidModeGetDotClocksReply rep;
     int n;
@@ -1304,31 +1344,33 @@ static int
     int *Clocks = NULL;
     Bool ClockProg;
 
-     DEBUG_P("XF86VidModeGetDotClocks");
+    DEBUG_P("XF86VidModeGetDotClocks");
 
-     REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
+    REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
 
     if (stuff->screen >= screenInfo.numScreens)
-         return BadValue;
+        return BadValue;
 
-     numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg);
+    numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg);
 
-     rep.type = X_Reply;
-     rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetDotClocksReply)
-                                 - SIZEOF(xGenericReply) + numClocks);
-     rep.sequenceNumber = client->sequence;
-     rep.clocks = numClocks;
-     rep.maxclocks = MAXCLOCKS;
-     rep.flags = 0;
+    rep.type = X_Reply;
+    rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetDotClocksReply)
+                                - SIZEOF(xGenericReply) + numClocks);
+    rep.sequenceNumber = client->sequence;
+    rep.clocks = numClocks;
+    rep.maxclocks = MAXCLOCKS;
+    rep.flags = 0;
 
     if (!ClockProg) {
         Clocks = malloc(numClocks * sizeof(int));
         if (!Clocks)
-             return BadValue;
+            return BadValue;
         if (!VidModeGetClocks(stuff->screen, Clocks)) {
             free(Clocks);
             return BadValue;
-    }} if (ClockProg) {
+        }
+    }
+    if (ClockProg) {
         rep.flags |= CLKFLAG_PROGRAMABLE;
     }
     if (client->swapped) {
@@ -1356,7 +1398,8 @@ static int
 }
 
 static int
- ProcXF86VidModeSetGamma(ClientPtr client) {
+ProcXF86VidModeSetGamma(ClientPtr client)
+{
     REQUEST(xXF86VidModeSetGammaReq);
 
     DEBUG_P("XF86VidModeSetGamma");
@@ -1372,79 +1415,89 @@ static int
         return BadValue;
 
     return Success;
-} static int
- ProcXF86VidModeGetGamma(ClientPtr client) {
+}
+
+static int
+ProcXF86VidModeGetGamma(ClientPtr client)
+{
     REQUEST(xXF86VidModeGetGammaReq);
     xXF86VidModeGetGammaReply rep;
     float red, green, blue;
 
-     DEBUG_P("XF86VidModeGetGamma");
+    DEBUG_P("XF86VidModeGetGamma");
 
-     REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
+    REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
 
     if (stuff->screen >= screenInfo.numScreens)
-         return BadValue;
+        return BadValue;
 
-     rep.type = X_Reply;
-     rep.length = 0;
-     rep.sequenceNumber = client->sequence;
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
     if (!VidModeGetGamma(stuff->screen, &red, &green, &blue))
-         return BadValue;
-     rep.red = (CARD32) (red * 10000.);
-     rep.green = (CARD32) (green * 10000.);
-     rep.blue = (CARD32) (blue * 10000.);
+        return BadValue;
+    rep.red = (CARD32) (red * 10000.);
+    rep.green = (CARD32) (green * 10000.);
+    rep.blue = (CARD32) (blue * 10000.);
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
         swapl(&rep.length);
         swapl(&rep.red);
         swapl(&rep.green);
         swapl(&rep.blue);
-    } WriteToClient(client, sizeof(xXF86VidModeGetGammaReply), (char *) &rep);
+    }
+    WriteToClient(client, sizeof(xXF86VidModeGetGammaReply), (char *) &rep);
 
     return Success;
 }
 
 static int
- ProcXF86VidModeSetGammaRamp(ClientPtr client) {
+ProcXF86VidModeSetGammaRamp(ClientPtr client)
+{
     CARD16 *r, *g, *b;
     int length;
-     REQUEST(xXF86VidModeSetGammaRampReq);
+
+    REQUEST(xXF86VidModeSetGammaRampReq);
 
     if (stuff->screen >= screenInfo.numScreens)
-         return BadValue;
+        return BadValue;
 
     if (stuff->size != VidModeGetGammaRampSize(stuff->screen))
-         return BadValue;
+        return BadValue;
 
-     length = (stuff->size + 1) & ~1;
+    length = (stuff->size + 1) & ~1;
 
-     REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length * 6);
+    REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length * 6);
 
-     r = (CARD16 *) &stuff[1];
-     g = r + length;
-     b = g + length;
+    r = (CARD16 *) &stuff[1];
+    g = r + length;
+    b = g + length;
 
     if (!VidModeSetGammaRamp(stuff->screen, stuff->size, r, g, b))
-         return BadValue;
+        return BadValue;
 
-     return Success;
-} static int
- ProcXF86VidModeGetGammaRamp(ClientPtr client) {
+    return Success;
+}
+
+static int
+ProcXF86VidModeGetGammaRamp(ClientPtr client)
+{
     CARD16 *ramp = NULL;
     int length;
     size_t ramplen = 0;
     xXF86VidModeGetGammaRampReply rep;
-     REQUEST(xXF86VidModeGetGammaRampReq);
+
+    REQUEST(xXF86VidModeGetGammaRampReq);
 
     if (stuff->screen >= screenInfo.numScreens)
-         return BadValue;
+        return BadValue;
 
     if (stuff->size != VidModeGetGammaRampSize(stuff->screen))
-         return BadValue;
+        return BadValue;
 
-     REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
+    REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
 
-     length = (stuff->size + 1) & ~1;
+    length = (stuff->size + 1) & ~1;
 
     if (stuff->size) {
         ramplen = length * 3 * sizeof(CARD16);
@@ -1455,7 +1508,9 @@ static int
                                  ramp, ramp + length, ramp + (length * 2))) {
             free(ramp);
             return BadValue;
-    }} rep.type = X_Reply;
+        }
+    }
+    rep.type = X_Reply;
     rep.length = (length >> 1) * 3;
     rep.sequenceNumber = client->sequence;
     rep.size = stuff->size;
@@ -1476,47 +1531,53 @@ static int
 }
 
 static int
- ProcXF86VidModeGetGammaRampSize(ClientPtr client) {
+ProcXF86VidModeGetGammaRampSize(ClientPtr client)
+{
     xXF86VidModeGetGammaRampSizeReply rep;
-     REQUEST(xXF86VidModeGetGammaRampSizeReq);
+
+    REQUEST(xXF86VidModeGetGammaRampSizeReq);
 
     if (stuff->screen >= screenInfo.numScreens)
-         return BadValue;
+        return BadValue;
 
-     REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
+    REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
 
-     rep.type = X_Reply;
-     rep.length = 0;
-     rep.sequenceNumber = client->sequence;
-     rep.size = VidModeGetGammaRampSize(stuff->screen);
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    rep.size = VidModeGetGammaRampSize(stuff->screen);
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
         swapl(&rep.length);
         swaps(&rep.size);
-    } WriteToClient(client, sizeof(xXF86VidModeGetGammaRampSizeReply),
-                    (char *) &rep);
+    }
+    WriteToClient(client, sizeof(xXF86VidModeGetGammaRampSizeReply),
+                  (char *) &rep);
 
     return Success;
 }
 
 static int
- ProcXF86VidModeGetPermissions(ClientPtr client) {
+ProcXF86VidModeGetPermissions(ClientPtr client)
+{
     xXF86VidModeGetPermissionsReply rep;
-     REQUEST(xXF86VidModeGetPermissionsReq);
+
+    REQUEST(xXF86VidModeGetPermissionsReq);
 
     if (stuff->screen >= screenInfo.numScreens)
-         return BadValue;
+        return BadValue;
 
-     REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
+    REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
 
-     rep.type = X_Reply;
-     rep.length = 0;
-     rep.sequenceNumber = client->sequence;
-     rep.permissions = XF86VM_READ_PERMISSION;
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    rep.permissions = XF86VM_READ_PERMISSION;
     if (xf86GetVidModeEnabled() &&
         (xf86GetVidModeAllowNonLocal() || LocalClient(client))) {
         rep.permissions |= XF86VM_WRITE_PERMISSION;
-    } if (client->swapped) {
+    }
+    if (client->swapped) {
         swaps(&rep.sequenceNumber);
         swapl(&rep.length);
         swapl(&rep.permissions);
@@ -1528,21 +1589,23 @@ static int
 }
 
 static int
- ProcXF86VidModeSetClientVersion(ClientPtr client) {
+ProcXF86VidModeSetClientVersion(ClientPtr client)
+{
     REQUEST(xXF86VidModeSetClientVersionReq);
 
     VidModePrivPtr pPriv;
 
-     DEBUG_P("XF86VidModeSetClientVersion");
+    DEBUG_P("XF86VidModeSetClientVersion");
 
-     REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
+    REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
 
     if ((pPriv = VM_GETPRIV(client)) == NULL) {
         pPriv = malloc(sizeof(VidModePrivRec));
         if (!pPriv)
             return BadAlloc;
         VM_SETPRIV(client, pPriv);
-    } pPriv->major = stuff->major;
+    }
+    pPriv->major = stuff->major;
 
     pPriv->minor = stuff->minor;
 
@@ -1550,85 +1613,103 @@ static int
 }
 
 static int
- ProcXF86VidModeDispatch(ClientPtr client) {
+ProcXF86VidModeDispatch(ClientPtr client)
+{
     REQUEST(xReq);
     switch (stuff->data) {
     case X_XF86VidModeQueryVersion:
         return ProcXF86VidModeQueryVersion(client);
-        case X_XF86VidModeGetModeLine:return ProcXF86VidModeGetModeLine(client);
-        case X_XF86VidModeGetMonitor:return ProcXF86VidModeGetMonitor(client);
-        case X_XF86VidModeGetAllModeLines:return
-            ProcXF86VidModeGetAllModeLines(client);
-        case X_XF86VidModeValidateModeLine:return
-            ProcXF86VidModeValidateModeLine(client);
-        case X_XF86VidModeGetViewPort:return ProcXF86VidModeGetViewPort(client);
-        case X_XF86VidModeGetDotClocks:return
-            ProcXF86VidModeGetDotClocks(client);
-        case X_XF86VidModeSetClientVersion:return
-            ProcXF86VidModeSetClientVersion(client);
-        case X_XF86VidModeGetGamma:return ProcXF86VidModeGetGamma(client);
-        case X_XF86VidModeGetGammaRamp:return
-            ProcXF86VidModeGetGammaRamp(client);
-        case X_XF86VidModeGetGammaRampSize:return
-            ProcXF86VidModeGetGammaRampSize(client);
-        case X_XF86VidModeGetPermissions:return
-            ProcXF86VidModeGetPermissions(client);
-        default:if (!xf86GetVidModeEnabled())
+    case X_XF86VidModeGetModeLine:
+        return ProcXF86VidModeGetModeLine(client);
+    case X_XF86VidModeGetMonitor:
+        return ProcXF86VidModeGetMonitor(client);
+    case X_XF86VidModeGetAllModeLines:
+        return ProcXF86VidModeGetAllModeLines(client);
+    case X_XF86VidModeValidateModeLine:
+        return ProcXF86VidModeValidateModeLine(client);
+    case X_XF86VidModeGetViewPort:
+        return ProcXF86VidModeGetViewPort(client);
+    case X_XF86VidModeGetDotClocks:
+        return ProcXF86VidModeGetDotClocks(client);
+    case X_XF86VidModeSetClientVersion:
+        return ProcXF86VidModeSetClientVersion(client);
+    case X_XF86VidModeGetGamma:
+        return ProcXF86VidModeGetGamma(client);
+    case X_XF86VidModeGetGammaRamp:
+        return ProcXF86VidModeGetGammaRamp(client);
+    case X_XF86VidModeGetGammaRampSize:
+        return ProcXF86VidModeGetGammaRampSize(client);
+    case X_XF86VidModeGetPermissions:
+        return ProcXF86VidModeGetPermissions(client);
+    default:
+        if (!xf86GetVidModeEnabled())
             return VidModeErrorBase + XF86VidModeExtensionDisabled;
         if (xf86GetVidModeAllowNonLocal() || LocalClient(client)) {
             switch (stuff->data) {
             case X_XF86VidModeAddModeLine:
                 return ProcXF86VidModeAddModeLine(client);
-                case X_XF86VidModeDeleteModeLine:return
-                    ProcXF86VidModeDeleteModeLine(client);
-                case X_XF86VidModeModModeLine:return
-                    ProcXF86VidModeModModeLine(client);
-                case X_XF86VidModeSwitchMode:return
-                    ProcXF86VidModeSwitchMode(client);
-                case X_XF86VidModeSwitchToMode:return
-                    ProcXF86VidModeSwitchToMode(client);
-                case X_XF86VidModeLockModeSwitch:return
-                    ProcXF86VidModeLockModeSwitch(client);
-                case X_XF86VidModeSetViewPort:return
-                    ProcXF86VidModeSetViewPort(client);
-                case X_XF86VidModeSetGamma:return
-                    ProcXF86VidModeSetGamma(client);
-                case X_XF86VidModeSetGammaRamp:return
-                    ProcXF86VidModeSetGammaRamp(client);
-                default:return BadRequest;
-        }}
+            case X_XF86VidModeDeleteModeLine:
+                return ProcXF86VidModeDeleteModeLine(client);
+            case X_XF86VidModeModModeLine:
+                return ProcXF86VidModeModModeLine(client);
+            case X_XF86VidModeSwitchMode:
+                return ProcXF86VidModeSwitchMode(client);
+            case X_XF86VidModeSwitchToMode:
+                return ProcXF86VidModeSwitchToMode(client);
+            case X_XF86VidModeLockModeSwitch:
+                return ProcXF86VidModeLockModeSwitch(client);
+            case X_XF86VidModeSetViewPort:
+                return ProcXF86VidModeSetViewPort(client);
+            case X_XF86VidModeSetGamma:
+                return ProcXF86VidModeSetGamma(client);
+            case X_XF86VidModeSetGammaRamp:
+                return ProcXF86VidModeSetGammaRamp(client);
+            default:
+                return BadRequest;
+            }
+        }
         else
-             return VidModeErrorBase + XF86VidModeClientNotLocal;
+            return VidModeErrorBase + XF86VidModeClientNotLocal;
     }
 }
 
 static int
- SProcXF86VidModeQueryVersion(ClientPtr client) {
+SProcXF86VidModeQueryVersion(ClientPtr client)
+{
     REQUEST(xXF86VidModeQueryVersionReq);
     swaps(&stuff->length);
     return ProcXF86VidModeQueryVersion(client);
-} static int
- SProcXF86VidModeGetModeLine(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeGetModeLine(ClientPtr client)
+{
     REQUEST(xXF86VidModeGetModeLineReq);
     swaps(&stuff->length);
     REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
     swaps(&stuff->screen);
     return ProcXF86VidModeGetModeLine(client);
-} static int
- SProcXF86VidModeGetAllModeLines(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeGetAllModeLines(ClientPtr client)
+{
     REQUEST(xXF86VidModeGetAllModeLinesReq);
     swaps(&stuff->length);
     REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq);
     swaps(&stuff->screen);
     return ProcXF86VidModeGetAllModeLines(client);
-} static int
- SProcXF86VidModeAddModeLine(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeAddModeLine(ClientPtr client)
+{
     xXF86OldVidModeAddModeLineReq *oldstuff =
         (xXF86OldVidModeAddModeLineReq *) client->requestBuffer;
     int ver;
 
-     REQUEST(xXF86VidModeAddModeLineReq);
-     ver = ClientMajorVersion(client);
+    REQUEST(xXF86VidModeAddModeLineReq);
+    ver = ClientMajorVersion(client);
     if (ver < 2) {
         swaps(&oldstuff->length);
         REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
@@ -1666,13 +1747,14 @@ static int
 }
 
 static int
- SProcXF86VidModeDeleteModeLine(ClientPtr client) {
+SProcXF86VidModeDeleteModeLine(ClientPtr client)
+{
     xXF86OldVidModeDeleteModeLineReq *oldstuff =
         (xXF86OldVidModeDeleteModeLineReq *) client->requestBuffer;
     int ver;
 
-     REQUEST(xXF86VidModeDeleteModeLineReq);
-     ver = ClientMajorVersion(client);
+    REQUEST(xXF86VidModeDeleteModeLineReq);
+    ver = ClientMajorVersion(client);
     if (ver < 2) {
         swaps(&oldstuff->length);
         REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
@@ -1710,13 +1792,14 @@ static int
 }
 
 static int
- SProcXF86VidModeModModeLine(ClientPtr client) {
+SProcXF86VidModeModModeLine(ClientPtr client)
+{
     xXF86OldVidModeModModeLineReq *oldstuff =
         (xXF86OldVidModeModModeLineReq *) client->requestBuffer;
     int ver;
 
-     REQUEST(xXF86VidModeModModeLineReq);
-     ver = ClientMajorVersion(client);
+    REQUEST(xXF86VidModeModModeLineReq);
+    ver = ClientMajorVersion(client);
     if (ver < 2) {
         swaps(&oldstuff->length);
         REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
@@ -1754,13 +1837,14 @@ static int
 }
 
 static int
- SProcXF86VidModeValidateModeLine(ClientPtr client) {
+SProcXF86VidModeValidateModeLine(ClientPtr client)
+{
     xXF86OldVidModeValidateModeLineReq *oldstuff =
         (xXF86OldVidModeValidateModeLineReq *) client->requestBuffer;
     int ver;
 
-     REQUEST(xXF86VidModeValidateModeLineReq);
-     ver = ClientMajorVersion(client);
+    REQUEST(xXF86VidModeValidateModeLineReq);
+    ver = ClientMajorVersion(client);
     if (ver < 2) {
         swaps(&oldstuff->length);
         REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
@@ -1798,44 +1882,60 @@ static int
 }
 
 static int
- SProcXF86VidModeSwitchMode(ClientPtr client) {
+SProcXF86VidModeSwitchMode(ClientPtr client)
+{
     REQUEST(xXF86VidModeSwitchModeReq);
     swaps(&stuff->length);
     REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq);
     swaps(&stuff->screen);
     swaps(&stuff->zoom);
     return ProcXF86VidModeSwitchMode(client);
-} static int
- SProcXF86VidModeSwitchToMode(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeSwitchToMode(ClientPtr client)
+{
     REQUEST(xXF86VidModeSwitchToModeReq);
     swaps(&stuff->length);
     REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq);
     swapl(&stuff->screen);
     return ProcXF86VidModeSwitchToMode(client);
-} static int
- SProcXF86VidModeLockModeSwitch(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeLockModeSwitch(ClientPtr client)
+{
     REQUEST(xXF86VidModeLockModeSwitchReq);
     swaps(&stuff->length);
     REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq);
     swaps(&stuff->screen);
     swaps(&stuff->lock);
     return ProcXF86VidModeLockModeSwitch(client);
-} static int
- SProcXF86VidModeGetMonitor(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeGetMonitor(ClientPtr client)
+{
     REQUEST(xXF86VidModeGetMonitorReq);
     swaps(&stuff->length);
     REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq);
     swaps(&stuff->screen);
     return ProcXF86VidModeGetMonitor(client);
-} static int
- SProcXF86VidModeGetViewPort(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeGetViewPort(ClientPtr client)
+{
     REQUEST(xXF86VidModeGetViewPortReq);
     swaps(&stuff->length);
     REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq);
     swaps(&stuff->screen);
     return ProcXF86VidModeGetViewPort(client);
-} static int
- SProcXF86VidModeSetViewPort(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeSetViewPort(ClientPtr client)
+{
     REQUEST(xXF86VidModeSetViewPortReq);
     swaps(&stuff->length);
     REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
@@ -1843,23 +1943,32 @@ static int
     swapl(&stuff->x);
     swapl(&stuff->y);
     return ProcXF86VidModeSetViewPort(client);
-} static int
- SProcXF86VidModeGetDotClocks(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeGetDotClocks(ClientPtr client)
+{
     REQUEST(xXF86VidModeGetDotClocksReq);
     swaps(&stuff->length);
     REQUEST_SIZE_MATCH(xXF86VidModeGetDotClocksReq);
     swaps(&stuff->screen);
     return ProcXF86VidModeGetDotClocks(client);
-} static int
- SProcXF86VidModeSetClientVersion(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeSetClientVersion(ClientPtr client)
+{
     REQUEST(xXF86VidModeSetClientVersionReq);
     swaps(&stuff->length);
     REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
     swaps(&stuff->major);
     swaps(&stuff->minor);
     return ProcXF86VidModeSetClientVersion(client);
-} static int
- SProcXF86VidModeSetGamma(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeSetGamma(ClientPtr client)
+{
     REQUEST(xXF86VidModeSetGammaReq);
     swaps(&stuff->length);
     REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq);
@@ -1868,120 +1977,145 @@ static int
     swapl(&stuff->green);
     swapl(&stuff->blue);
     return ProcXF86VidModeSetGamma(client);
-} static int
- SProcXF86VidModeGetGamma(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeGetGamma(ClientPtr client)
+{
     REQUEST(xXF86VidModeGetGammaReq);
     swaps(&stuff->length);
     REQUEST_SIZE_MATCH(xXF86VidModeGetGammaReq);
     swaps(&stuff->screen);
     return ProcXF86VidModeGetGamma(client);
-} static int
- SProcXF86VidModeSetGammaRamp(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeSetGammaRamp(ClientPtr client)
+{
     int length;
-     REQUEST(xXF86VidModeSetGammaRampReq);
-     swaps(&stuff->length);
-     REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq);
-     swaps(&stuff->size);
-     swaps(&stuff->screen);
-     length = ((stuff->size + 1) & ~1) * 6;
-     REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length);
-     SwapRestS(stuff);
-     return ProcXF86VidModeSetGammaRamp(client);
-} static int
- SProcXF86VidModeGetGammaRamp(ClientPtr client) {
+
+    REQUEST(xXF86VidModeSetGammaRampReq);
+    swaps(&stuff->length);
+    REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq);
+    swaps(&stuff->size);
+    swaps(&stuff->screen);
+    length = ((stuff->size + 1) & ~1) * 6;
+    REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length);
+    SwapRestS(stuff);
+    return ProcXF86VidModeSetGammaRamp(client);
+}
+
+static int
+SProcXF86VidModeGetGammaRamp(ClientPtr client)
+{
     REQUEST(xXF86VidModeGetGammaRampReq);
     swaps(&stuff->length);
     REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampReq);
     swaps(&stuff->size);
     swaps(&stuff->screen);
     return ProcXF86VidModeGetGammaRamp(client);
-} static int
- SProcXF86VidModeGetGammaRampSize(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeGetGammaRampSize(ClientPtr client)
+{
     REQUEST(xXF86VidModeGetGammaRampSizeReq);
     swaps(&stuff->length);
     REQUEST_SIZE_MATCH(xXF86VidModeGetGammaRampSizeReq);
     swaps(&stuff->screen);
     return ProcXF86VidModeGetGammaRampSize(client);
-} static int
- SProcXF86VidModeGetPermissions(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeGetPermissions(ClientPtr client)
+{
     REQUEST(xXF86VidModeGetPermissionsReq);
     swaps(&stuff->length);
     REQUEST_SIZE_MATCH(xXF86VidModeGetPermissionsReq);
     swaps(&stuff->screen);
     return ProcXF86VidModeGetPermissions(client);
-} static int
- SProcXF86VidModeDispatch(ClientPtr client) {
+}
+
+static int
+SProcXF86VidModeDispatch(ClientPtr client)
+{
     REQUEST(xReq);
     switch (stuff->data) {
     case X_XF86VidModeQueryVersion:
         return SProcXF86VidModeQueryVersion(client);
-        case X_XF86VidModeGetModeLine:return
-            SProcXF86VidModeGetModeLine(client);
-        case X_XF86VidModeGetMonitor:return SProcXF86VidModeGetMonitor(client);
-        case X_XF86VidModeGetAllModeLines:return
-            SProcXF86VidModeGetAllModeLines(client);
-        case X_XF86VidModeGetViewPort:return
-            SProcXF86VidModeGetViewPort(client);
-        case X_XF86VidModeValidateModeLine:return
-            SProcXF86VidModeValidateModeLine(client);
-        case X_XF86VidModeGetDotClocks:return
-            SProcXF86VidModeGetDotClocks(client);
-        case X_XF86VidModeSetClientVersion:return
-            SProcXF86VidModeSetClientVersion(client);
-        case X_XF86VidModeGetGamma:return SProcXF86VidModeGetGamma(client);
-        case X_XF86VidModeGetGammaRamp:return
-            SProcXF86VidModeGetGammaRamp(client);
-        case X_XF86VidModeGetGammaRampSize:return
-            SProcXF86VidModeGetGammaRampSize(client);
-        case X_XF86VidModeGetPermissions:return
-            SProcXF86VidModeGetPermissions(client);
-        default:if (!xf86GetVidModeEnabled())
+    case X_XF86VidModeGetModeLine:
+        return SProcXF86VidModeGetModeLine(client);
+    case X_XF86VidModeGetMonitor:
+        return SProcXF86VidModeGetMonitor(client);
+    case X_XF86VidModeGetAllModeLines:
+        return SProcXF86VidModeGetAllModeLines(client);
+    case X_XF86VidModeGetViewPort:
+        return SProcXF86VidModeGetViewPort(client);
+    case X_XF86VidModeValidateModeLine:
+        return SProcXF86VidModeValidateModeLine(client);
+    case X_XF86VidModeGetDotClocks:
+        return SProcXF86VidModeGetDotClocks(client);
+    case X_XF86VidModeSetClientVersion:
+        return SProcXF86VidModeSetClientVersion(client);
+    case X_XF86VidModeGetGamma:
+        return SProcXF86VidModeGetGamma(client);
+    case X_XF86VidModeGetGammaRamp:
+        return SProcXF86VidModeGetGammaRamp(client);
+    case X_XF86VidModeGetGammaRampSize:
+        return SProcXF86VidModeGetGammaRampSize(client);
+    case X_XF86VidModeGetPermissions:
+        return SProcXF86VidModeGetPermissions(client);
+    default:
+        if (!xf86GetVidModeEnabled())
             return VidModeErrorBase + XF86VidModeExtensionDisabled;
         if (xf86GetVidModeAllowNonLocal() || LocalClient(client)) {
             switch (stuff->data) {
             case X_XF86VidModeAddModeLine:
                 return SProcXF86VidModeAddModeLine(client);
-                case X_XF86VidModeDeleteModeLine:return
-                    SProcXF86VidModeDeleteModeLine(client);
-                case X_XF86VidModeModModeLine:return
-                    SProcXF86VidModeModModeLine(client);
-                case X_XF86VidModeSwitchMode:return
-                    SProcXF86VidModeSwitchMode(client);
-                case X_XF86VidModeSwitchToMode:return
-                    SProcXF86VidModeSwitchToMode(client);
-                case X_XF86VidModeLockModeSwitch:return
-                    SProcXF86VidModeLockModeSwitch(client);
-                case X_XF86VidModeSetViewPort:return
-                    SProcXF86VidModeSetViewPort(client);
-                case X_XF86VidModeSetGamma:return
-                    SProcXF86VidModeSetGamma(client);
-                case X_XF86VidModeSetGammaRamp:return
-                    SProcXF86VidModeSetGammaRamp(client);
-                default:return BadRequest;
-        }}
+            case X_XF86VidModeDeleteModeLine:
+                return SProcXF86VidModeDeleteModeLine(client);
+            case X_XF86VidModeModModeLine:
+                return SProcXF86VidModeModModeLine(client);
+            case X_XF86VidModeSwitchMode:
+                return SProcXF86VidModeSwitchMode(client);
+            case X_XF86VidModeSwitchToMode:
+                return SProcXF86VidModeSwitchToMode(client);
+            case X_XF86VidModeLockModeSwitch:
+                return SProcXF86VidModeLockModeSwitch(client);
+            case X_XF86VidModeSetViewPort:
+                return SProcXF86VidModeSetViewPort(client);
+            case X_XF86VidModeSetGamma:
+                return SProcXF86VidModeSetGamma(client);
+            case X_XF86VidModeSetGammaRamp:
+                return SProcXF86VidModeSetGammaRamp(client);
+            default:
+                return BadRequest;
+            }
+        }
         else
-             return VidModeErrorBase + XF86VidModeClientNotLocal;
+            return VidModeErrorBase + XF86VidModeClientNotLocal;
     }
 }
 
 void
- XFree86VidModeExtensionInit(void) {
+XFree86VidModeExtensionInit(void)
+{
     ExtensionEntry *extEntry;
     ScreenPtr pScreen;
     int i;
     Bool enabled = FALSE;
 
-     DEBUG_P("XFree86VidModeExtensionInit");
+    DEBUG_P("XFree86VidModeExtensionInit");
 
     if (!dixRegisterPrivateKey(&VidModeClientPrivateKeyRec, PRIVATE_CLIENT, 0))
-         return;
+        return;
 #ifdef XF86VIDMODE_EVENTS
     if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
-         return;
+        return;
 #endif
 
 #ifdef XF86VIDMODE_EVENTS
-     EventType = CreateNewResourceType(XF86VidModeFreeEvents, "VidModeEvent");
+    EventType = CreateNewResourceType(XF86VidModeFreeEvents, "VidModeEvent");
 #endif
 
     for (i = 0; i < screenInfo.numScreens; i++) {
@@ -1990,8 +2124,8 @@ void
             enabled = TRUE;
     }
     /* This means that the DDX doesn't want the vidmode extension enabled */
-        if (!enabled)
-         return;
+    if (!enabled)
+        return;
 
     if (
 #ifdef XF86VIDMODE_EVENTS
commit b5bf0ac5405eab77f26bb2f8726644232af17178
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Apr 11 09:28:21 2012 -0700

    hw/xfree86: Spurious ');' in xf86vmode.c messed up indentation badly
    
    Inside the unfinished XF86VIDMODE_EVENTS #ifdef block the
    function definition for xf86VidModeNotifyEvent had an extra ');'
    before the prototype argument declarations. This was harmless for the
    compiler as the code never gets used, but completely messed up the
    file re-indentation. This patch removes the spurious characters in
    preparation for re-indenting the file.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 592bd0ae2b60cd6f6afd3efc40f5f659b12900b4)

diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c
index 6e2a8e9..9f64f8e 100644
--- a/hw/xfree86/dixmods/extmod/xf86vmode.c
+++ b/hw/xfree86/dixmods/extmod/xf86vmode.c
@@ -75,7 +75,7 @@ static unsigned char XF86VidModeReqCode = 0;
 #ifdef XF86VIDMODE_EVENTS
 static int XF86VidModeEventBase = 0;
 
-static void SXF86VidModeNotifyEvent();
+static void SXF86VidModeNotifyEvent(
 xXF86VidModeNotifyEvent * /* from */ , xXF86VidModeNotifyEvent *        /* to */
     );
 
commit 943cac51e4cb79dcbd143d4bd6b22ca9327e7703
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Mon May 7 00:03:01 2012 -0700

    configure.ac: Bump to 1.12.1.901 (1.12.2 RC1)
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/configure.ac b/configure.ac
index a12783c..e6c434e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,8 +26,8 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.12.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2012-04-13"
+AC_INIT([xorg-server], 1.12.1.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2012-05-06"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE


More information about the Xquartz-changes mailing list