xserver: Branch 'master' - 13 commits

Keith Packard keithp at kemper.freedesktop.org
Fri Mar 27 06:45:13 PDT 2015


 hw/kdrive/ephyr/hostx.c        |    2 
 hw/xquartz/quartz.c            |    1 
 hw/xwin/InitOutput.c           |   61 +-
 hw/xwin/Makefile.am            |    2 
 hw/xwin/XWin.exe.manifest      |   16 
 hw/xwin/glx/gen_gl_wrappers.py |   96 +--
 hw/xwin/man/XWin.man           |   11 
 hw/xwin/win.h                  |   35 -
 hw/xwin/winengine.c            |   26 
 hw/xwin/winglobals.c           |    2 
 hw/xwin/winos.c                |   72 ++
 hw/xwin/winprocarg.c           |   20 
 hw/xwin/winscrinit.c           |   23 
 hw/xwin/winshaddd.c            | 1221 -----------------------------------------
 hw/xwin/winwndproc.c           |    6 
 include/Makefile.am            |    1 
 include/extinit.h              |    5 
 include/nonsdk_extinit.h       |   35 +
 os/log.c                       |   28 
 os/xdmcp.c                     |   17 
 pseudoramiX/pseudoramiX.c      |    6 
 pseudoramiX/pseudoramiX.h      |    2 
 randr/rrxinerama.c             |    5 
 23 files changed, 333 insertions(+), 1360 deletions(-)

New commits:
commit 95e83ff87ab0149ab01c9299524dfbe37d9b21a2
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Jul 12 02:00:43 2012 +0100

    Don't allow both RandR XINERAMA and pseudoramiX XINERAMA extensions to register
    
    Prevent RRXinerama from activating if PseudoramiX is, so we don't get XINERAMA
    listed twice in the list of extensions.  I think this is otherwise benign, as
    the PseudoramiX XINERAMA gets registered first and thus handles all requests.
    
    Perhaps AddExtension() ought to warn us if the extension name is already
    registered?
    
    This appears to be a long-standing bug seen in XQuartz, and now in XWin as well.
    
    Future work: Perhaps since RRXinerama isn't actually doing anything useful but
    faking it when we have one screen, it seems that the PseudoramiX code could be
    also used in that case.
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/pseudoramiX/pseudoramiX.c b/pseudoramiX/pseudoramiX.c
index d0e2603..e59ca13 100644
--- a/pseudoramiX/pseudoramiX.c
+++ b/pseudoramiX/pseudoramiX.c
@@ -49,6 +49,7 @@
 #define DEBUG_LOG PseudoramiXDebug
 
 Bool noPseudoramiXExtension = FALSE;
+extern Bool noRRXineramaExtension;
 
 extern int
 ProcPanoramiXQueryVersion(ClientPtr client);
@@ -190,6 +191,9 @@ PseudoramiXExtensionInit(void)
         }
     }
 
+    /* Do not allow RRXinerama to initialize if we did */
+    noRRXineramaExtension = success;
+
     if (!success) {
         ErrorF("%s Extension (PseudoramiX) failed to initialize\n",
                PANORAMIX_PROTOCOL_NAME);
diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c
index b336bd7..36632c7 100644
--- a/randr/rrxinerama.c
+++ b/randr/rrxinerama.c
@@ -84,6 +84,8 @@ static int ProcRRXineramaIsActive(ClientPtr client);
 static int ProcRRXineramaQueryScreens(ClientPtr client);
 static int SProcRRXineramaDispatch(ClientPtr client);
 
+Bool noRRXineramaExtension = FALSE;
+
 /* Proc */
 
 int
@@ -488,6 +490,9 @@ RRXineramaExtensionInit(void)
         return;
 #endif
 
+    if (noRRXineramaExtension)
+      return;
+
     /*
      * Xinerama isn't capable enough to have multiple protocol screens each
      * with their own output geometry.  So if there's more than one protocol
commit 234fe391802b114e96d60a6630f717f8e4fb726c
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Fri Nov 7 13:38:20 2014 +0000

    hw/xwin: Report OS version in log
    
    Report OS version in log
    Report if WoW64 is in use
    Manifest for compatbility with Windows versions, so we don't get lied to by GetVersionEx()
    Also, make the description in the manifest a bit more generic
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am
index 9afde7e..4da3d12 100644
--- a/hw/xwin/Makefile.am
+++ b/hw/xwin/Makefile.am
@@ -71,6 +71,7 @@ SRCS =	InitInput.c \
 	winmsgwindow.c \
 	winmultiwindowclass.c \
 	winmultiwindowicons.c \
+	winos.c \
 	winprefs.c \
 	winprefsyacc.y \
 	winprefslex.l \
diff --git a/hw/xwin/XWin.exe.manifest b/hw/xwin/XWin.exe.manifest
index 477334f..bd44b10 100755
--- a/hw/xwin/XWin.exe.manifest
+++ b/hw/xwin/XWin.exe.manifest
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-	<description>The XWin X Windows server for Cygwin.</description>
+	<description>The XWin X Windows server</description>
 	<dependency>
 	   <dependentAssembly>
 	     <assemblyIdentity
@@ -18,4 +18,18 @@
 	     <dpiAware>true</dpiAware>
 	   </asmv3:windowsSettings>
 	</asmv3:application>
+    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
+        <application>
+            <!-- Windows Vista -->
+            <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
+            <!-- Windows 7 -->
+            <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
+            <!-- Windows 8 -->
+            <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
+            <!-- Windows 8.1 -->
+            <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
+            <!-- Windows 10 -->
+            <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
+        </application>
+    </compatibility>
 </assembly>
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index d41d001..5710ea8 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -1196,6 +1196,12 @@ Bool
 winCreateMsgWindowThread(void);
 
 /*
+ * winos.c
+ */
+void
+winOS(void);
+
+/*
  * END DDX and DIX Function Prototypes
  */
 
diff --git a/hw/xwin/winos.c b/hw/xwin/winos.c
new file mode 100644
index 0000000..0d825bb
--- /dev/null
+++ b/hw/xwin/winos.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2010-2014 Colin Harrison All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ *
+ * Author: Colin Harrison
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
+
+static const char*
+IsWow64(void)
+{
+#ifdef __x86_64__
+    return " (64-bit)";
+#else
+    WINBOOL bIsWow64;
+    LPFN_ISWOW64PROCESS fnIsWow64Process =
+        (LPFN_ISWOW64PROCESS) GetProcAddress(GetModuleHandle(TEXT("kernel32")),
+                                             "IsWow64Process");
+    if (NULL != fnIsWow64Process) {
+        if (fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
+            return bIsWow64 ? " (WoW64)" : " (32-bit)";
+    }
+
+    /* OS doesn't support IsWow64Process() */
+    return "";
+#endif
+}
+
+/*
+ * Report the OS version
+ */
+
+void
+winOS(void)
+{
+    OSVERSIONINFOEX osvi = {0};
+
+    /* Get operating system version information */
+    osvi.dwOSVersionInfoSize = sizeof(osvi);
+    GetVersionEx((LPOSVERSIONINFO)&osvi);
+
+    ErrorF("OS: Windows NT %d.%d build %d%s\n",
+           (int)osvi.dwMajorVersion, (int)osvi.dwMinorVersion,
+           (int)osvi.dwBuildNumber, IsWow64());
+}
diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index 65bba81..73aa027 100644
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -1200,6 +1200,7 @@ winLogVersionInfo(void)
         }
     }
 #endif
+    winOS();
     if (strlen(BUILDERSTRING))
         ErrorF("%s\n", BUILDERSTRING);
     ErrorF("Contact: %s\n", BUILDERADDR);
commit 7a22912edbda826778463f8fefa9c8e689858bbe
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Nov 6 15:22:58 2014 +0000

    hw/xwin: Remove Shadow DirectDraw engine
    
    Maybe a long time ago this made some kind of sense, but now there's no good
    reason to ever use this, rather than the Shadow DirectDraw NonLocking engine.
    
    Also remove screen private data members used by other removed engines.
    
    Also remove no longer needed OS version check in winDetectSupportedEngines()
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 3b1ef3f..b6f2583 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -738,7 +738,6 @@ winUseMsg(void)
     ErrorF("-engine engine_type_id\n"
            "\tOverride the server's automatically selected engine type:\n"
            "\t\t1 - Shadow GDI\n"
-           "\t\t2 - Shadow DirectDraw\n"
            "\t\t4 - Shadow DirectDraw4 Non-Locking\n"
         );
 
diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am
index 0ea8ba7..9afde7e 100644
--- a/hw/xwin/Makefile.am
+++ b/hw/xwin/Makefile.am
@@ -76,7 +76,6 @@ SRCS =	InitInput.c \
 	winprefslex.l \
 	winprocarg.c \
 	winscrinit.c \
-	winshaddd.c \
 	winshadddnl.c \
 	winshadgdi.c \
 	wintaskbar.c \
diff --git a/hw/xwin/man/XWin.man b/hw/xwin/man/XWin.man
index 41019d1..d68ee2a 100644
--- a/hw/xwin/man/XWin.man
+++ b/hw/xwin/man/XWin.man
@@ -248,9 +248,6 @@ functionality does not provide a benefit at any number of boxes; we
 can only determine the usefulness of this feature through testing.
 This option probably has limited effect on current \fIWindows\fP versions
 as they already perform GDI batching.
-This parameter works in conjunction with engines 1, 2, and 4 (Shadow
-GDI, Shadow DirectDraw, and Shadow DirectDraw Non-Locking,
-respectively).
 .TP 8
 .B "\-engine \fIengine_type_id\fP"
 This option, which is intended for Cygwin/X developers,
@@ -265,8 +262,6 @@ The engine type ids are:
 .RS
 .IP 1 4
 Shadow GDI
-.IP 2 4
-Shadow DirectDraw
 .IP 4 4
 Shadow DirectDraw Non-Locking
 .RE
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index b7d20ca..d41d001 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -101,7 +101,6 @@
 
 #define WIN_SERVER_NONE		0x0L    /* 0 */
 #define WIN_SERVER_SHADOW_GDI	0x1L    /* 1 */
-#define WIN_SERVER_SHADOW_DD	0x2L    /* 2 */
 #define WIN_SERVER_SHADOW_DDNL	0x4L    /* 4 */
 
 #define AltMapIndex		Mod1MapIndex
@@ -468,35 +467,20 @@ typedef struct _winPrivScreenRec {
     int iE3BCachedPress;
     Bool fE3BFakeButton2Sent;
 
-    /* Privates used by shadow fb GDI server */
+    /* Privates used by shadow fb GDI engine */
     HBITMAP hbmpShadow;
     HDC hdcScreen;
     HDC hdcShadow;
     HWND hwndScreen;
     BITMAPINFOHEADER *pbmih;
 
-    /* Privates used by shadow fb and primary fb DirectDraw servers */
+    /* Privates used by shadow fb DirectDraw Nonlocking engine */
     LPDIRECTDRAW pdd;
-    LPDIRECTDRAWSURFACE2 pddsPrimary;
-    LPDIRECTDRAW2 pdd2;
-
-    /* Privates used by shadow fb DirectDraw server */
-    LPDIRECTDRAWSURFACE2 pddsShadow;
-    LPDDSURFACEDESC pddsdShadow;
-
-    /* Privates used by primary fb DirectDraw server */
-    LPDIRECTDRAWSURFACE2 pddsOffscreen;
-    LPDDSURFACEDESC pddsdOffscreen;
-    LPDDSURFACEDESC pddsdPrimary;
-
-    /* Privates used by shadow fb DirectDraw Nonlocking server */
     LPDIRECTDRAW4 pdd4;
     LPDIRECTDRAWSURFACE4 pddsShadow4;
     LPDIRECTDRAWSURFACE4 pddsPrimary4;
-    BOOL fRetryCreateSurface;
-
-    /* Privates used by both shadow fb DirectDraw servers */
     LPDIRECTDRAWCLIPPER pddcPrimary;
+    BOOL fRetryCreateSurface;
 
 #ifdef XWIN_MULTIWINDOWEXTWM
     /* Privates used by multi-window external window manager */
@@ -921,13 +905,6 @@ Bool
  winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv);
 
 /*
- * winshaddd.c
- */
-
-Bool
- winSetEngineFunctionsShadowDD(ScreenPtr pScreen);
-
-/*
  * winshadddnl.c
  */
 
diff --git a/hw/xwin/winengine.c b/hw/xwin/winengine.c
index b473b3a..b8f8da0 100644
--- a/hw/xwin/winengine.c
+++ b/hw/xwin/winengine.c
@@ -54,16 +54,9 @@ static HMODULE g_hmodDirectDraw = NULL;
 void
 winDetectSupportedEngines(void)
 {
-    OSVERSIONINFO osvi;
-
     /* Initialize the engine support flags */
     g_dwEnginesSupported = WIN_SERVER_SHADOW_GDI;
 
-    /* Get operating system version information */
-    ZeroMemory(&osvi, sizeof(osvi));
-    osvi.dwOSVersionInfoSize = sizeof(osvi);
-    GetVersionEx(&osvi);
-
     /* Do we have DirectDraw? */
     if (g_hmodDirectDraw != NULL) {
         LPDIRECTDRAW lpdd = NULL;
@@ -85,12 +78,6 @@ winDetectSupportedEngines(void)
                           "winDetectSupportedEngines - DirectDraw not installed\n");
             return;
         }
-        else {
-            /* We have DirectDraw */
-            winErrorFVerb(2,
-                          "winDetectSupportedEngines - DirectDraw installed, allowing ShadowDD\n");
-            g_dwEnginesSupported |= WIN_SERVER_SHADOW_DD;
-        }
 
         /* Try to query for DirectDraw4 interface */
         ddrval = IDirectDraw_QueryInterface(lpdd,
@@ -187,9 +174,6 @@ winSetEngine(ScreenPtr pScreen)
         case WIN_SERVER_SHADOW_GDI:
             winSetEngineFunctionsShadowGDI(pScreen);
             break;
-        case WIN_SERVER_SHADOW_DD:
-            winSetEngineFunctionsShadowDD(pScreen);
-            break;
         case WIN_SERVER_SHADOW_DDNL:
             winSetEngineFunctionsShadowDDNL(pScreen);
             break;
@@ -209,16 +193,6 @@ winSetEngine(ScreenPtr pScreen)
         return TRUE;
     }
 
-    /* ShadowDD is next in line */
-    if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DD) {
-        winErrorFVerb(2, "winSetEngine - Using Shadow DirectDraw\n");
-        pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DD;
-
-        /* Set engine function pointers */
-        winSetEngineFunctionsShadowDD(pScreen);
-        return TRUE;
-    }
-
     /* ShadowGDI is next in line */
     if (g_dwEnginesSupported & WIN_SERVER_SHADOW_GDI) {
         winErrorFVerb(2, "winSetEngine - Using Shadow GDI DIB\n");
diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c
index 31d5fdd..e68ee12 100644
--- a/hw/xwin/winscrinit.c
+++ b/hw/xwin/winscrinit.c
@@ -313,8 +313,6 @@ winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv)
     if (pScreenInfo->dwDepth == 8
         && (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
             || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
-                && pScreenInfo->fFullScreen)
-            || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
                 && pScreenInfo->fFullScreen))) {
         winSetColormapFunctions(pScreen);
 
@@ -388,7 +386,6 @@ winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv)
 
     /* Initialize the shadow framebuffer layer */
     if ((pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
-         || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
          || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)
 #ifdef XWIN_MULTIWINDOWEXTWM
         && !pScreenInfo->fMWExtWM
diff --git a/hw/xwin/winshaddd.c b/hw/xwin/winshaddd.c
deleted file mode 100644
index 4904eb4..0000000
--- a/hw/xwin/winshaddd.c
+++ /dev/null
@@ -1,1221 +0,0 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors:	Dakshinamurthy Karra
- *		Suhaib M Siddiqi
- *		Peter Busch
- *		Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-/*
- * Local prototypes
- */
-
-static Bool
- winAllocateFBShadowDD(ScreenPtr pScreen);
-
-static void
- winShadowUpdateDD(ScreenPtr pScreen, shadowBufPtr pBuf);
-
-static Bool
- winCloseScreenShadowDD(ScreenPtr pScreen);
-
-static Bool
- winInitVisualsShadowDD(ScreenPtr pScreen);
-
-static Bool
- winAdjustVideoModeShadowDD(ScreenPtr pScreen);
-
-static Bool
- winBltExposedRegionsShadowDD(ScreenPtr pScreen);
-
-static Bool
- winActivateAppShadowDD(ScreenPtr pScreen);
-
-static Bool
- winRedrawScreenShadowDD(ScreenPtr pScreen);
-
-static Bool
- winRealizeInstalledPaletteShadowDD(ScreenPtr pScreen);
-
-static Bool
- winInstallColormapShadowDD(ColormapPtr pColormap);
-
-static Bool
- winStoreColorsShadowDD(ColormapPtr pmap, int ndef, xColorItem * pdefs);
-
-static Bool
- winCreateColormapShadowDD(ColormapPtr pColormap);
-
-static Bool
- winDestroyColormapShadowDD(ColormapPtr pColormap);
-
-static Bool
- winCreatePrimarySurfaceShadowDD(ScreenPtr pScreen);
-
-static Bool
- winReleasePrimarySurfaceShadowDD(ScreenPtr pScreen);
-
-/*
- * Create the primary surface and attach the clipper.
- * Used for both the initial surface creation and during
- * WM_DISPLAYCHANGE messages.
- */
-
-static Bool
-winCreatePrimarySurfaceShadowDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    HRESULT ddrval = DD_OK;
-    DDSURFACEDESC ddsd;
-
-    /* Describe the primary surface */
-    ZeroMemory(&ddsd, sizeof(ddsd));
-    ddsd.dwSize = sizeof(ddsd);
-    ddsd.dwFlags = DDSD_CAPS;
-    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-
-    /* Create the primary surface */
-    ddrval = IDirectDraw2_CreateSurface(pScreenPriv->pdd2,
-                                        &ddsd, &pScreenPriv->pddsPrimary, NULL);
-    if (FAILED(ddrval)) {
-        ErrorF("winCreatePrimarySurfaceShadowDD - Could not create primary "
-               "surface: %08x\n", (unsigned int) ddrval);
-        return FALSE;
-    }
-
-#if CYGDEBUG
-    winDebug("winCreatePrimarySurfaceShadowDD - Created primary surface\n");
-#endif
-
-    /*
-     * Attach a clipper to the primary surface that will clip our blits to our
-     * display window.
-     */
-    ddrval = IDirectDrawSurface2_SetClipper(pScreenPriv->pddsPrimary,
-                                            pScreenPriv->pddcPrimary);
-    if (FAILED(ddrval)) {
-        ErrorF("winCreatePrimarySurfaceShadowDD - Primary attach clipper "
-               "failed: %08x\n", (unsigned int) ddrval);
-        return FALSE;
-    }
-
-#if CYGDEBUG
-    winDebug("winCreatePrimarySurfaceShadowDD - Attached clipper to "
-             "primary surface\n");
-#endif
-
-    /* Everything was correct */
-    return TRUE;
-}
-
-/*
- * Detach the clipper and release the primary surface.
- * Called from WM_DISPLAYCHANGE.
- */
-
-static Bool
-winReleasePrimarySurfaceShadowDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-
-    ErrorF("winReleasePrimarySurfaceShadowDD - Hello\n");
-
-    /* Release the primary surface and clipper, if they exist */
-    if (pScreenPriv->pddsPrimary) {
-        /*
-         * Detach the clipper from the primary surface.
-         * NOTE: We do this explicity for clarity.  The Clipper is not released.
-         */
-        IDirectDrawSurface2_SetClipper(pScreenPriv->pddsPrimary, NULL);
-
-        ErrorF("winReleasePrimarySurfaceShadowDD - Detached clipper\n");
-
-        /* Release the primary surface */
-        IDirectDrawSurface2_Release(pScreenPriv->pddsPrimary);
-        pScreenPriv->pddsPrimary = NULL;
-    }
-
-    ErrorF("winReleasePrimarySurfaceShadowDD - Released primary surface\n");
-
-    return TRUE;
-}
-
-/*
- * Create a DirectDraw surface for the shadow framebuffer; also create
- * a primary surface object so we can blit to the display.
- *
- * Install a DirectDraw clipper on our primary surface object
- * that clips our blits to the unobscured client area of our display window.
- */
-
-static Bool
-winAllocateFBShadowDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-    HRESULT ddrval = DD_OK;
-    DDSURFACEDESC ddsd;
-    DDSURFACEDESC *pddsdShadow = NULL;
-
-#if CYGDEBUG
-    winDebug("winAllocateFBShadowDD\n");
-#endif
-
-    /* Create a clipper */
-    ddrval = (*g_fpDirectDrawCreateClipper) (0,
-                                             &pScreenPriv->pddcPrimary, NULL);
-    if (FAILED(ddrval)) {
-        ErrorF("winAllocateFBShadowDD - Could not create clipper: %08x\n",
-               (unsigned int) ddrval);
-        return FALSE;
-    }
-
-#if CYGDEBUG
-    winDebug("winAllocateFBShadowDD - Created a clipper\n");
-#endif
-
-    /* Attach the clipper to our display window */
-    ddrval = IDirectDrawClipper_SetHWnd(pScreenPriv->pddcPrimary,
-                                        0, pScreenPriv->hwndScreen);
-    if (FAILED(ddrval)) {
-        ErrorF("winAllocateFBShadowDD - Clipper not attached to "
-               "window: %08x\n", (unsigned int) ddrval);
-        return FALSE;
-    }
-
-#if CYGDEBUG
-    winDebug("winAllocateFBShadowDD - Attached clipper to window\n");
-#endif
-
-    /* Create a DirectDraw object, store the address at lpdd */
-    ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL);
-    if (FAILED(ddrval)) {
-        ErrorF("winAllocateFBShadowDD - Could not start DirectDraw: %08x\n",
-               (unsigned int) ddrval);
-        return FALSE;
-    }
-
-#if CYGDEBUG
-    winDebug("winAllocateFBShadowDD () - Created and initialized DD\n");
-#endif
-
-    /* Get a DirectDraw2 interface pointer */
-    ddrval = IDirectDraw_QueryInterface(pScreenPriv->pdd,
-                                        &IID_IDirectDraw2,
-                                        (LPVOID *) &pScreenPriv->pdd2);
-    if (FAILED(ddrval)) {
-        ErrorF("winAllocateFBShadowDD - Failed DD2 query: %08x\n",
-               (unsigned int) ddrval);
-        return FALSE;
-    }
-
-    /* Are we full screen? */
-    if (pScreenInfo->fFullScreen) {
-        DDSURFACEDESC ddsdCurrent;
-        DWORD dwRefreshRateCurrent = 0;
-        HDC hdc = NULL;
-
-        /* Set the cooperative level to full screen */
-        ddrval = IDirectDraw2_SetCooperativeLevel(pScreenPriv->pdd2,
-                                                  pScreenPriv->hwndScreen,
-                                                  DDSCL_EXCLUSIVE
-                                                  | DDSCL_FULLSCREEN);
-        if (FAILED(ddrval)) {
-            ErrorF("winAllocateFBShadowDD - Could not set "
-                   "cooperative level: %08x\n", (unsigned int) ddrval);
-            return FALSE;
-        }
-
-        /*
-         * We only need to get the current refresh rate for comparison
-         * if a refresh rate has been passed on the command line.
-         */
-        if (pScreenInfo->dwRefreshRate != 0) {
-            ZeroMemory(&ddsdCurrent, sizeof(ddsdCurrent));
-            ddsdCurrent.dwSize = sizeof(ddsdCurrent);
-
-            /* Get information about current display settings */
-            ddrval = IDirectDraw2_GetDisplayMode(pScreenPriv->pdd2,
-                                                 &ddsdCurrent);
-            if (FAILED(ddrval)) {
-                ErrorF("winAllocateFBShadowDD - Could not get current "
-                       "refresh rate: %08x.  Continuing.\n",
-                       (unsigned int) ddrval);
-                dwRefreshRateCurrent = 0;
-            }
-            else {
-                /* Grab the current refresh rate */
-                dwRefreshRateCurrent = ddsdCurrent.u2.dwRefreshRate;
-            }
-        }
-
-        /* Clean up the refresh rate */
-        if (dwRefreshRateCurrent == pScreenInfo->dwRefreshRate) {
-            /*
-             * Refresh rate is non-specified or equal to current.
-             */
-            pScreenInfo->dwRefreshRate = 0;
-        }
-
-        /* Grab a device context for the screen */
-        hdc = GetDC(NULL);
-        if (hdc == NULL) {
-            ErrorF("winAllocateFBShadowDD - GetDC () failed\n");
-            return FALSE;
-        }
-
-        /* Only change the video mode when different than current mode */
-        if (!pScreenInfo->fMultipleMonitors
-            && (pScreenInfo->dwWidth != GetSystemMetrics(SM_CXSCREEN)
-                || pScreenInfo->dwHeight != GetSystemMetrics(SM_CYSCREEN)
-                || pScreenInfo->dwBPP != GetDeviceCaps(hdc, BITSPIXEL)
-                || pScreenInfo->dwRefreshRate != 0)) {
-            ErrorF("winAllocateFBShadowDD - Changing video mode\n");
-
-            /* Change the video mode to the mode requested, and use the driver default refresh rate on failure */
-            ddrval = IDirectDraw2_SetDisplayMode(pScreenPriv->pdd2,
-                                                 pScreenInfo->dwWidth,
-                                                 pScreenInfo->dwHeight,
-                                                 pScreenInfo->dwBPP,
-                                                 pScreenInfo->dwRefreshRate, 0);
-            if (FAILED(ddrval)) {
-                ErrorF("winAllocateFBShadowDD - Could not set "
-                       "full screen display mode: %08x\n",
-                       (unsigned int) ddrval);
-                ErrorF
-                    ("winAllocateFBShadowDD - Using default driver refresh rate\n");
-                ddrval =
-                    IDirectDraw2_SetDisplayMode(pScreenPriv->pdd2,
-                                                pScreenInfo->dwWidth,
-                                                pScreenInfo->dwHeight,
-                                                pScreenInfo->dwBPP, 0, 0);
-                if (FAILED(ddrval)) {
-                    ErrorF
-                        ("winAllocateFBShadowDD - Could not set default refresh rate "
-                         "full screen display mode: %08x\n",
-                         (unsigned int) ddrval);
-                    return FALSE;
-                }
-            }
-        }
-        else {
-            ErrorF("winAllocateFBShadowDD - Not changing video mode\n");
-        }
-
-        /* Release our DC */
-        ReleaseDC(NULL, hdc);
-        hdc = NULL;
-    }
-    else {
-        /* Set the cooperative level for windowed mode */
-        ddrval = IDirectDraw2_SetCooperativeLevel(pScreenPriv->pdd2,
-                                                  pScreenPriv->hwndScreen,
-                                                  DDSCL_NORMAL);
-        if (FAILED(ddrval)) {
-            ErrorF("winAllocateFBShadowDD - Could not set "
-                   "cooperative level: %08x\n", (unsigned int) ddrval);
-            return FALSE;
-        }
-    }
-
-    /* Create the primary surface */
-    if (!winCreatePrimarySurfaceShadowDD(pScreen)) {
-        ErrorF("winAllocateFBShadowDD - winCreatePrimarySurfaceShadowDD "
-               "failed\n");
-        return FALSE;
-    }
-
-    /* Describe the shadow surface to be created */
-    /* NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
-     * as drawing, locking, and unlocking take forever
-     * with video memory surfaces.  In addition,
-     * video memory is a somewhat scarce resource,
-     * so you shouldn't be allocating video memory when
-     * you have the option of using system memory instead.
-     */
-    ZeroMemory(&ddsd, sizeof(ddsd));
-    ddsd.dwSize = sizeof(ddsd);
-    ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
-    ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
-    ddsd.dwHeight = pScreenInfo->dwHeight;
-    ddsd.dwWidth = pScreenInfo->dwWidth;
-
-    /* Create the shadow surface */
-    ddrval = IDirectDraw2_CreateSurface(pScreenPriv->pdd2,
-                                        &ddsd, &pScreenPriv->pddsShadow, NULL);
-    if (FAILED(ddrval)) {
-        ErrorF("winAllocateFBShadowDD - Could not create shadow "
-               "surface: %08x\n", (unsigned int) ddrval);
-        return FALSE;
-    }
-
-#if CYGDEBUG
-    winDebug("winAllocateFBShadowDD - Created shadow\n");
-#endif
-
-    /* Allocate a DD surface description for our screen privates */
-    pddsdShadow = pScreenPriv->pddsdShadow = malloc(sizeof(DDSURFACEDESC));
-    if (pddsdShadow == NULL) {
-        ErrorF("winAllocateFBShadowDD - Could not allocate surface "
-               "description memory\n");
-        return FALSE;
-    }
-    ZeroMemory(pddsdShadow, sizeof(*pddsdShadow));
-    pddsdShadow->dwSize = sizeof(*pddsdShadow);
-
-#if CYGDEBUG
-    winDebug("winAllocateFBShadowDD - Locking shadow\n");
-#endif
-
-    /* Lock the shadow surface */
-    ddrval = IDirectDrawSurface2_Lock(pScreenPriv->pddsShadow,
-                                      NULL, pddsdShadow, DDLOCK_WAIT, NULL);
-    if (FAILED(ddrval) || pddsdShadow->lpSurface == NULL) {
-        ErrorF("winAllocateFBShadowDD - Could not lock shadow "
-               "surface: %08x\n", (unsigned int) ddrval);
-        return FALSE;
-    }
-
-#if CYGDEBUG
-    winDebug("winAllocateFBShadowDD - Locked shadow\n");
-#endif
-
-    /* We don't know how to deal with anything other than RGB */
-    if (!(pddsdShadow->ddpfPixelFormat.dwFlags & DDPF_RGB)) {
-        ErrorF("winAllocateFBShadowDD - Color format other than RGB\n");
-        return FALSE;
-    }
-
-    /* Grab the pitch from the surface desc */
-    pScreenInfo->dwStride = (pddsdShadow->u1.lPitch * 8)
-        / pScreenInfo->dwBPP;
-
-    /* Save the pointer to our surface memory */
-    pScreenInfo->pfb = pddsdShadow->lpSurface;
-
-    /* Grab the color depth and masks from the surface description */
-    pScreenPriv->dwRedMask = pddsdShadow->ddpfPixelFormat.u2.dwRBitMask;
-    pScreenPriv->dwGreenMask = pddsdShadow->ddpfPixelFormat.u3.dwGBitMask;
-    pScreenPriv->dwBlueMask = pddsdShadow->ddpfPixelFormat.u4.dwBBitMask;
-
-#if CYGDEBUG
-    winDebug("winAllocateFBShadowDD - Returning\n");
-#endif
-
-    return TRUE;
-}
-
-static void
-winFreeFBShadowDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
-    /* Free the shadow surface, if there is one */
-    if (pScreenPriv->pddsShadow) {
-        IDirectDrawSurface2_Unlock(pScreenPriv->pddsShadow, NULL);
-        IDirectDrawSurface2_Release(pScreenPriv->pddsShadow);
-        pScreenPriv->pddsShadow = NULL;
-    }
-
-    /* Detach the clipper from the primary surface and release the primary surface, if there is one */
-    winReleasePrimarySurfaceShadowDD(pScreen);
-
-    /* Release the clipper object */
-    if (pScreenPriv->pddcPrimary) {
-        IDirectDrawClipper_Release(pScreenPriv->pddcPrimary);
-        pScreenPriv->pddcPrimary = NULL;
-    }
-
-    /* Free the DirectDraw2 object, if there is one */
-    if (pScreenPriv->pdd2) {
-        IDirectDraw2_RestoreDisplayMode(pScreenPriv->pdd2);
-        IDirectDraw2_Release(pScreenPriv->pdd2);
-        pScreenPriv->pdd2 = NULL;
-    }
-
-    /* Free the DirectDraw object, if there is one */
-    if (pScreenPriv->pdd) {
-        IDirectDraw_Release(pScreenPriv->pdd);
-        pScreenPriv->pdd = NULL;
-    }
-
-    /* Invalidate the ScreenInfo's fb pointer */
-    pScreenInfo->pfb = NULL;
-}
-
-/*
- * Transfer the damaged regions of the shadow framebuffer to the display.
- */
-
-static void
-winShadowUpdateDD(ScreenPtr pScreen, shadowBufPtr pBuf)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-    RegionPtr damage = shadowDamage(pBuf);
-    HRESULT ddrval = DD_OK;
-    RECT rcDest, rcSrc;
-    POINT ptOrigin;
-    DWORD dwBox = RegionNumRects(damage);
-    BoxPtr pBox = RegionRects(damage);
-    HRGN hrgnCombined = NULL;
-
-    /*
-     * Return immediately if the app is not active
-     * and we are fullscreen, or if we have a bad display depth
-     */
-    if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
-        || pScreenPriv->fBadDepth)
-        return;
-
-    /* Return immediately if we didn't get needed surfaces */
-    if (!pScreenPriv->pddsPrimary || !pScreenPriv->pddsShadow)
-        return;
-
-    /* Get the origin of the window in the screen coords */
-    ptOrigin.x = pScreenInfo->dwXOffset;
-    ptOrigin.y = pScreenInfo->dwYOffset;
-    MapWindowPoints(pScreenPriv->hwndScreen,
-                    HWND_DESKTOP, (LPPOINT) &ptOrigin, 1);
-
-    /* Unlock the shadow surface, so we can blit */
-    ddrval = IDirectDrawSurface2_Unlock(pScreenPriv->pddsShadow, NULL);
-    if (FAILED(ddrval)) {
-        ErrorF("winShadowUpdateDD - Unlock failed\n");
-        return;
-    }
-
-    /*
-     * Handle small regions with multiple blits,
-     * handle large regions by creating a clipping region and
-     * doing a single blit constrained to that clipping region.
-     */
-    if (pScreenInfo->dwClipUpdatesNBoxes == 0
-        || dwBox < pScreenInfo->dwClipUpdatesNBoxes) {
-        /* Loop through all boxes in the damaged region */
-        while (dwBox--) {
-            /* Assign damage box to source rectangle */
-            rcSrc.left = pBox->x1;
-            rcSrc.top = pBox->y1;
-            rcSrc.right = pBox->x2;
-            rcSrc.bottom = pBox->y2;
-
-            /* Calculate destination rectange */
-            rcDest.left = ptOrigin.x + rcSrc.left;
-            rcDest.top = ptOrigin.y + rcSrc.top;
-            rcDest.right = ptOrigin.x + rcSrc.right;
-            rcDest.bottom = ptOrigin.y + rcSrc.bottom;
-
-            /* Blit the damaged areas */
-            ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsPrimary,
-                                             &rcDest,
-                                             pScreenPriv->pddsShadow,
-                                             &rcSrc, DDBLT_WAIT, NULL);
-
-            /* Get a pointer to the next box */
-            ++pBox;
-        }
-    }
-    else {
-        BoxPtr pBoxExtents = RegionExtents(damage);
-
-        /* Compute a GDI region from the damaged region */
-        hrgnCombined =
-            CreateRectRgn(pBoxExtents->x1, pBoxExtents->y1, pBoxExtents->x2,
-                          pBoxExtents->y2);
-
-        /* Install the GDI region as a clipping region */
-        SelectClipRgn(pScreenPriv->hdcScreen, hrgnCombined);
-        DeleteObject(hrgnCombined);
-        hrgnCombined = NULL;
-
-        /* Calculating a bounding box for the source is easy */
-        rcSrc.left = pBoxExtents->x1;
-        rcSrc.top = pBoxExtents->y1;
-        rcSrc.right = pBoxExtents->x2;
-        rcSrc.bottom = pBoxExtents->y2;
-
-        /* Calculating a bounding box for the destination is trickier */
-        rcDest.left = ptOrigin.x + rcSrc.left;
-        rcDest.top = ptOrigin.y + rcSrc.top;
-        rcDest.right = ptOrigin.x + rcSrc.right;
-        rcDest.bottom = ptOrigin.y + rcSrc.bottom;
-
-        /* Our Blt should be clipped to the invalidated region */
-        ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsPrimary,
-                                         &rcDest,
-                                         pScreenPriv->pddsShadow,
-                                         &rcSrc, DDBLT_WAIT, NULL);
-
-        /* Reset the clip region */
-        SelectClipRgn(pScreenPriv->hdcScreen, NULL);
-    }
-
-    /* Relock the shadow surface */
-    ddrval = IDirectDrawSurface2_Lock(pScreenPriv->pddsShadow,
-                                      NULL,
-                                      pScreenPriv->pddsdShadow,
-                                      DDLOCK_WAIT, NULL);
-    if (FAILED(ddrval)) {
-        ErrorF("winShadowUpdateDD - Lock failed\n");
-        return;
-    }
-
-    /* Has our memory pointer changed? */
-    if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface) {
-        ErrorF("winShadowUpdateDD - Memory location of the shadow "
-               "surface has changed, trying to update the root window "
-               "pixmap header to point to the new address.  If you get "
-               "this message and " PROJECT_NAME " freezes or crashes "
-               "after this message then send a problem report and your "
-               "%s file to " BUILDERADDR "\n", g_pszLogFile);
-
-        /* Location of shadow framebuffer has changed */
-        winUpdateFBPointer(pScreen, pScreenPriv->pddsdShadow->lpSurface);
-    }
-}
-
-static Bool
-winInitScreenShadowDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-
-    /* Get a device context for the screen  */
-    pScreenPriv->hdcScreen = GetDC(pScreenPriv->hwndScreen);
-
-    return winAllocateFBShadowDD(pScreen);
-}
-
-/*
- * Call the wrapped CloseScreen function.
- *
- * Free our resources and private structures.
- */
-
-static Bool
-winCloseScreenShadowDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-    Bool fReturn;
-
-#if CYGDEBUG
-    winDebug("winCloseScreenShadowDD - Freeing screen resources\n");
-#endif
-
-    /* Flag that the screen is closed */
-    pScreenPriv->fClosed = TRUE;
-    pScreenPriv->fActive = FALSE;
-
-    /* Call the wrapped CloseScreen procedure */
-    WIN_UNWRAP(CloseScreen);
-    if (pScreen->CloseScreen)
-        fReturn = (*pScreen->CloseScreen) (pScreen);
-
-    winFreeFBShadowDD(pScreen);
-
-    /* Free the screen DC */
-    ReleaseDC(pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
-
-    /* Delete the window property */
-    RemoveProp(pScreenPriv->hwndScreen, WIN_SCR_PROP);
-
-    /* Delete tray icon, if we have one */
-    if (!pScreenInfo->fNoTrayIcon)
-        winDeleteNotifyIcon(pScreenPriv);
-
-    /* Free the exit confirmation dialog box, if it exists */
-    if (g_hDlgExit != NULL) {
-        DestroyWindow(g_hDlgExit);
-        g_hDlgExit = NULL;
-    }
-
-    /* Kill our window */
-    if (pScreenPriv->hwndScreen) {
-        DestroyWindow(pScreenPriv->hwndScreen);
-        pScreenPriv->hwndScreen = NULL;
-    }
-
-#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
-    /* Destroy the thread startup mutex */
-    pthread_mutex_destroy(&pScreenPriv->pmServerStarted);
-#endif
-
-    /* Kill our screeninfo's pointer to the screen */
-    pScreenInfo->pScreen = NULL;
-
-    /* Free the screen privates for this screen */
-    free((void *) pScreenPriv);
-
-    return fReturn;
-}
-
-/*
- * Tell mi what sort of visuals we need.
- *
- * Generally we only need one visual, as our screen can only
- * handle one format at a time, I believe.  You may want
- * to verify that last sentence.
- */
-
-static Bool
-winInitVisualsShadowDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-    DWORD dwRedBits, dwGreenBits, dwBlueBits;
-
-    /* Count the number of ones in each color mask */
-    dwRedBits = winCountBits(pScreenPriv->dwRedMask);
-    dwGreenBits = winCountBits(pScreenPriv->dwGreenMask);
-    dwBlueBits = winCountBits(pScreenPriv->dwBlueMask);
-
-    /* Store the maximum number of ones in a color mask as the bitsPerRGB */
-    if (dwRedBits == 0 || dwGreenBits == 0 || dwBlueBits == 0)
-        pScreenPriv->dwBitsPerRGB = 8;
-    else if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
-        pScreenPriv->dwBitsPerRGB = dwRedBits;
-    else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
-        pScreenPriv->dwBitsPerRGB = dwGreenBits;
-    else
-        pScreenPriv->dwBitsPerRGB = dwBlueBits;
-
-    ErrorF("winInitVisualsShadowDD - Masks %08x %08x %08x BPRGB %d d %d "
-           "bpp %d\n",
-           (unsigned int) pScreenPriv->dwRedMask,
-           (unsigned int) pScreenPriv->dwGreenMask,
-           (unsigned int) pScreenPriv->dwBlueMask,
-           (int) pScreenPriv->dwBitsPerRGB,
-           (int) pScreenInfo->dwDepth, (int) pScreenInfo->dwBPP);
-
-    /* Create a single visual according to the Windows screen depth */
-    switch (pScreenInfo->dwDepth) {
-    case 24:
-    case 16:
-    case 15:
-        /* Create the real visual */
-        if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
-                                      TrueColorMask,
-                                      pScreenPriv->dwBitsPerRGB,
-                                      TrueColor,
-                                      pScreenPriv->dwRedMask,
-                                      pScreenPriv->dwGreenMask,
-                                      pScreenPriv->dwBlueMask)) {
-            ErrorF("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
-                   "failed for TrueColor\n");
-            return FALSE;
-        }
-
-#ifdef XWIN_EMULATEPSEUDO
-        if (!pScreenInfo->fEmulatePseudo)
-            break;
-
-        /* Setup a pseudocolor visual */
-        if (!miSetVisualTypesAndMasks(8, PseudoColorMask, 8, -1, 0, 0, 0)) {
-            ErrorF("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
-                   "failed for PseudoColor\n");
-            return FALSE;
-        }
-#endif
-        break;
-
-    case 8:
-        if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
-                                      pScreenInfo->fFullScreen
-                                      ? PseudoColorMask : StaticColorMask,
-                                      pScreenPriv->dwBitsPerRGB,
-                                      pScreenInfo->fFullScreen
-                                      ? PseudoColor : StaticColor,
-                                      pScreenPriv->dwRedMask,
-                                      pScreenPriv->dwGreenMask,
-                                      pScreenPriv->dwBlueMask)) {
-            ErrorF("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
-                   "failed\n");
-            return FALSE;
-        }
-        break;
-
-    default:
-        ErrorF("winInitVisualsShadowDD - Unknown screen depth\n");
-        return FALSE;
-    }
-
-#if CYGDEBUG
-    winDebug("winInitVisualsShadowDD - Returning\n");
-#endif
-
-    return TRUE;
-}
-
-/*
- * Adjust the user proposed video mode
- */
-
-static Bool
-winAdjustVideoModeShadowDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-    HDC hdc = NULL;
-    DWORD dwBPP;
-
-    /* We're in serious trouble if we can't get a DC */
-    hdc = GetDC(NULL);
-    if (hdc == NULL) {
-        ErrorF("winAdjustVideoModeShadowDD - GetDC () failed\n");
-        return FALSE;
-    }
-
-    /* Query GDI for current display depth */
-    dwBPP = GetDeviceCaps(hdc, BITSPIXEL);
-
-    /* DirectDraw can only change the depth in fullscreen mode */
-    if (!(pScreenInfo->fFullScreen && (pScreenInfo->dwBPP != WIN_DEFAULT_BPP))) {
-        /* Otherwise, We'll use GDI's depth */
-        pScreenInfo->dwBPP = dwBPP;
-    }
-
-    /* Release our DC */
-    ReleaseDC(NULL, hdc);
-    return TRUE;
-}
-
-/*
- * Blt exposed regions to the screen
- */
-
-static Bool
-winBltExposedRegionsShadowDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-    RECT rcSrc, rcDest;
-    POINT ptOrigin;
-    HDC hdcUpdate = NULL;
-    PAINTSTRUCT ps;
-    HRESULT ddrval = DD_OK;
-    Bool fReturn = TRUE;
-    Bool fLocked = TRUE;
-    int i;
-
-    /* BeginPaint gives us an hdc that clips to the invalidated region */
-    hdcUpdate = BeginPaint(pScreenPriv->hwndScreen, &ps);
-    if (hdcUpdate == NULL) {
-        ErrorF("winBltExposedRegionsShadowDD - BeginPaint () returned "
-               "a NULL device context handle.  Aborting blit attempt.\n");
-        return FALSE;
-    }
-
-    /* Unlock the shadow surface, so we can blit */
-    ddrval = IDirectDrawSurface2_Unlock(pScreenPriv->pddsShadow, NULL);
-    if (FAILED(ddrval)) {
-        fReturn = FALSE;
-        goto winBltExposedRegionsShadowDD_Exit;
-    }
-    else {
-        /* Flag that we have unlocked the shadow surface */
-        fLocked = FALSE;
-    }
-
-    /* Get the origin of the window in the screen coords */
-    ptOrigin.x = pScreenInfo->dwXOffset;
-    ptOrigin.y = pScreenInfo->dwYOffset;
-
-    MapWindowPoints(pScreenPriv->hwndScreen,
-                    HWND_DESKTOP, (LPPOINT) &ptOrigin, 1);
-    rcDest.left = ptOrigin.x;
-    rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
-    rcDest.top = ptOrigin.y;
-    rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
-
-    /* Source can be enter shadow surface, as Blt should clip */
-    rcSrc.left = 0;
-    rcSrc.top = 0;
-    rcSrc.right = pScreenInfo->dwWidth;
-    rcSrc.bottom = pScreenInfo->dwHeight;
-
-    /* Try to regain the primary surface and blit again if we've lost it */
-    for (i = 0; i <= WIN_REGAIN_SURFACE_RETRIES; ++i) {
-        /* Our Blt should be clipped to the invalidated region */
-        ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsPrimary,
-                                         &rcDest,
-                                         pScreenPriv->pddsShadow,
-                                         &rcSrc, DDBLT_WAIT, NULL);
-        if (ddrval == DDERR_SURFACELOST) {
-            /* Surface was lost */
-            ErrorF("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt "
-                   "reported that the primary surface was lost, "
-                   "trying to restore, retry: %d\n", i + 1);
-
-            /* Try to restore the surface, once */
-            ddrval = IDirectDrawSurface2_Restore(pScreenPriv->pddsPrimary);
-            ErrorF("winBltExposedRegionsShadowDD - "
-                   "IDirectDrawSurface2_Restore returned: ");
-            if (ddrval == DD_OK)
-                ErrorF("DD_OK\n");
-            else if (ddrval == DDERR_WRONGMODE)
-                ErrorF("DDERR_WRONGMODE\n");
-            else if (ddrval == DDERR_INCOMPATIBLEPRIMARY)
-                ErrorF("DDERR_INCOMPATIBLEPRIMARY\n");
-            else if (ddrval == DDERR_UNSUPPORTED)
-                ErrorF("DDERR_UNSUPPORTED\n");
-            else if (ddrval == DDERR_INVALIDPARAMS)
-                ErrorF("DDERR_INVALIDPARAMS\n");
-            else if (ddrval == DDERR_INVALIDOBJECT)
-                ErrorF("DDERR_INVALIDOBJECT\n");
-            else
-                ErrorF("unknown error: %08x\n", (unsigned int) ddrval);
-
-            /* Loop around to try the blit one more time */
-            continue;
-        }
-        else if (FAILED(ddrval)) {
-            fReturn = FALSE;
-            ErrorF("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt "
-                   "failed, but surface not lost: %08x %d\n",
-                   (unsigned int) ddrval, (int) ddrval);
-            goto winBltExposedRegionsShadowDD_Exit;
-        }
-        else {
-            /* Success, stop looping */
-            break;
-        }
-    }
-
-    /* Relock the shadow surface */
-    ddrval = IDirectDrawSurface2_Lock(pScreenPriv->pddsShadow,
-                                      NULL,
-                                      pScreenPriv->pddsdShadow,
-                                      DDLOCK_WAIT, NULL);
-    if (FAILED(ddrval)) {
-        fReturn = FALSE;
-        ErrorF("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Lock "
-               "failed\n");
-        goto winBltExposedRegionsShadowDD_Exit;
-    }
-    else {
-        /* Indicate that we have relocked the shadow surface */
-        fLocked = TRUE;
-    }
-
-    /* Has our memory pointer changed? */
-    if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
-        winUpdateFBPointer(pScreen, pScreenPriv->pddsdShadow->lpSurface);
-
- winBltExposedRegionsShadowDD_Exit:
-    /* EndPaint frees the DC */
-    if (hdcUpdate != NULL)
-        EndPaint(pScreenPriv->hwndScreen, &ps);
-
-    /*
-     * Relock the surface if it is not locked.  We don't care if locking fails,
-     * as it will cause the server to shutdown within a few more operations.
-     */
-    if (!fLocked) {
-        IDirectDrawSurface2_Lock(pScreenPriv->pddsShadow,
-                                 NULL,
-                                 pScreenPriv->pddsdShadow, DDLOCK_WAIT, NULL);
-
-        /* Has our memory pointer changed? */
-        if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
-            winUpdateFBPointer(pScreen, pScreenPriv->pddsdShadow->lpSurface);
-
-        fLocked = TRUE;
-    }
-    return fReturn;
-}
-
-/*
- * Do any engine-specific appliation-activation processing
- */
-
-static Bool
-winActivateAppShadowDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-
-    /*
-     * Do we have a surface?
-     * Are we active?
-     * Are we fullscreen?
-     */
-    if (pScreenPriv != NULL
-        && pScreenPriv->pddsPrimary != NULL && pScreenPriv->fActive) {
-        /* Primary surface was lost, restore it */
-        IDirectDrawSurface2_Restore(pScreenPriv->pddsPrimary);
-    }
-
-    return TRUE;
-}
-
-/*
- * Reblit the shadow framebuffer to the screen.
- */
-
-static Bool
-winRedrawScreenShadowDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-    HRESULT ddrval = DD_OK;
-    RECT rcSrc, rcDest;
-    POINT ptOrigin;
-
-    /* Get the origin of the window in the screen coords */
-    ptOrigin.x = pScreenInfo->dwXOffset;
-    ptOrigin.y = pScreenInfo->dwYOffset;
-    MapWindowPoints(pScreenPriv->hwndScreen,
-                    HWND_DESKTOP, (LPPOINT) &ptOrigin, 1);
-    rcDest.left = ptOrigin.x;
-    rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
-    rcDest.top = ptOrigin.y;
-    rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
-
-    /* Source can be entire shadow surface, as Blt should clip for us */
-    rcSrc.left = 0;
-    rcSrc.top = 0;
-    rcSrc.right = pScreenInfo->dwWidth;
-    rcSrc.bottom = pScreenInfo->dwHeight;
-
-    /* Redraw the whole window, to take account for the new colors */
-    ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsPrimary,
-                                     &rcDest,
-                                     pScreenPriv->pddsShadow,
-                                     &rcSrc, DDBLT_WAIT, NULL);
-    if (FAILED(ddrval)) {
-        ErrorF("winRedrawScreenShadowDD - IDirectDrawSurface_Blt () "
-               "failed: %08x\n", (unsigned int) ddrval);
-    }
-
-    return TRUE;
-}
-
-/*
- * Realize the currently installed colormap
- */
-
-static Bool
-winRealizeInstalledPaletteShadowDD(ScreenPtr pScreen)
-{
-    return TRUE;
-}
-
-/*
- * Install the specified colormap
- */
-
-static Bool
-winInstallColormapShadowDD(ColormapPtr pColormap)
-{
-    ScreenPtr pScreen = pColormap->pScreen;
-
-    winScreenPriv(pScreen);
-    winCmapPriv(pColormap);
-    HRESULT ddrval = DD_OK;
-
-    /* Install the DirectDraw palette on the primary surface */
-    ddrval = IDirectDrawSurface2_SetPalette(pScreenPriv->pddsPrimary,
-                                            pCmapPriv->lpDDPalette);
-    if (FAILED(ddrval)) {
-        ErrorF("winInstallColormapShadowDD - Failed installing the "
-               "DirectDraw palette.\n");
-        return FALSE;
-    }
-
-    /* Save a pointer to the newly installed colormap */
-    pScreenPriv->pcmapInstalled = pColormap;
-
-    return TRUE;
-}
-
-/*
- * Store the specified colors in the specified colormap
- */
-
-static Bool
-winStoreColorsShadowDD(ColormapPtr pColormap, int ndef, xColorItem * pdefs)
-{
-    ScreenPtr pScreen = pColormap->pScreen;
-
-    winScreenPriv(pScreen);
-    winCmapPriv(pColormap);
-    ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
-    HRESULT ddrval = DD_OK;
-
-    /* Put the X colormap entries into the Windows logical palette */
-    ddrval = IDirectDrawPalette_SetEntries(pCmapPriv->lpDDPalette,
-                                           0,
-                                           pdefs[0].pixel,
-                                           ndef,
-                                           pCmapPriv->peColors
-                                           + pdefs[0].pixel);
-    if (FAILED(ddrval)) {
-        ErrorF("winStoreColorsShadowDD - SetEntries () failed\n");
-        return FALSE;
-    }
-
-    /* Don't install the DirectDraw palette if the colormap is not installed */
-    if (pColormap != curpmap) {
-        return TRUE;
-    }
-
-    if (!winInstallColormapShadowDD(pColormap)) {
-        ErrorF("winStoreColorsShadowDD - Failed installing colormap\n");
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
-/*
- * Colormap initialization procedure
- */
-
-static Bool
-winCreateColormapShadowDD(ColormapPtr pColormap)
-{
-    HRESULT ddrval = DD_OK;
-    ScreenPtr pScreen = pColormap->pScreen;
-
-    winScreenPriv(pScreen);
-    winCmapPriv(pColormap);
-
-    /* Create a DirectDraw palette */
-    ddrval = IDirectDraw2_CreatePalette(pScreenPriv->pdd,
-                                        DDPCAPS_8BIT | DDPCAPS_ALLOW256,
-                                        pCmapPriv->peColors,
-                                        &pCmapPriv->lpDDPalette, NULL);
-    if (FAILED(ddrval)) {
-        ErrorF("winCreateColormapShadowDD - CreatePalette failed\n");
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
-/*
- * Colormap destruction procedure
- */
-
-static Bool
-winDestroyColormapShadowDD(ColormapPtr pColormap)
-{
-    winScreenPriv(pColormap->pScreen);
-    winCmapPriv(pColormap);
-    HRESULT ddrval = DD_OK;
-
-    /*
-     * Is colormap to be destroyed the default?
-     *
-     * Non-default colormaps should have had winUninstallColormap
-     * called on them before we get here.  The default colormap
-     * will not have had winUninstallColormap called on it.  Thus,
-     * we need to handle the default colormap in a special way.
-     */
-    if (pColormap->flags & IsDefault) {
-#if CYGDEBUG
-        winDebug("winDestroyColormapShadowDD - Destroying default "
-                 "colormap\n");
-#endif
-
-        /*
-         * FIXME: Walk the list of all screens, popping the default
-         * palette out of each screen device context.
-         */
-
-        /* Pop the palette out of the primary surface */
-        ddrval = IDirectDrawSurface2_SetPalette(pScreenPriv->pddsPrimary, NULL);
-        if (FAILED(ddrval)) {
-            ErrorF("winDestroyColormapShadowDD - Failed freeing the "
-                   "default colormap DirectDraw palette.\n");
-            return FALSE;
-        }
-
-        /* Clear our private installed colormap pointer */
-        pScreenPriv->pcmapInstalled = NULL;
-    }
-
-    /* Release the palette */
-    IDirectDrawPalette_Release(pCmapPriv->lpDDPalette);
-
-    /* Invalidate the colormap privates */
-    pCmapPriv->lpDDPalette = NULL;
-
-    return TRUE;
-}
-
-/*
- * Set engine specific functions
- */
-
-Bool
-winSetEngineFunctionsShadowDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
-    /* Set our pointers */
-    pScreenPriv->pwinAllocateFB = winAllocateFBShadowDD;
-    pScreenPriv->pwinFreeFB = winFreeFBShadowDD;
-    pScreenPriv->pwinShadowUpdate = winShadowUpdateDD;
-    pScreenPriv->pwinInitScreen = winInitScreenShadowDD;
-    pScreenPriv->pwinCloseScreen = winCloseScreenShadowDD;
-    pScreenPriv->pwinInitVisuals = winInitVisualsShadowDD;
-    pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowDD;
-    if (pScreenInfo->fFullScreen)
-        pScreenPriv->pwinCreateBoundingWindow =
-            winCreateBoundingWindowFullScreen;
-    else
-        pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
-    pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
-    pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDD;
-    pScreenPriv->pwinActivateApp = winActivateAppShadowDD;
-    pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowDD;
-    pScreenPriv->pwinRealizeInstalledPalette
-        = winRealizeInstalledPaletteShadowDD;
-    pScreenPriv->pwinInstallColormap = winInstallColormapShadowDD;
-    pScreenPriv->pwinStoreColors = winStoreColorsShadowDD;
-    pScreenPriv->pwinCreateColormap = winCreateColormapShadowDD;
-    pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowDD;
-    pScreenPriv->pwinHotKeyAltTab =
-        (winHotKeyAltTabProcPtr) (void (*)(void)) NoopDDA;
-    pScreenPriv->pwinCreatePrimarySurface = winCreatePrimarySurfaceShadowDD;
-    pScreenPriv->pwinReleasePrimarySurface = winReleasePrimarySurfaceShadowDD;
-#ifdef XWIN_MULTIWINDOW
-    pScreenPriv->pwinFinishCreateWindowsWindow =
-        (winFinishCreateWindowsWindowProcPtr) (void (*)(void)) NoopDDA;
-#endif
-
-    return TRUE;
-}
diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c
index 1bf3f5c..3228fa4 100644
--- a/hw/xwin/winwndproc.c
+++ b/hw/xwin/winwndproc.c
@@ -162,8 +162,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
          * their own mode when they become active.
          */
         if (s_pScreenInfo->fFullScreen
-            && (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
-                || s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)) {
+            || (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)) {
             break;
         }
 
@@ -186,8 +185,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
          */
         if (s_pScreenInfo->dwBPP !=
             GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL)) {
-            if ((s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD ||
-                 s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)) {
+            if (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL) {
                 /* Cannot display the visual until the depth is restored */
                 ErrorF("winWindowProc - Disruptive change in depth\n");
 
commit 55a84be085e9f479f7907bed5fb68fc66ce81ae8
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Sat Mar 3 20:13:19 2012 +0000

    hw/xwin: Only set native positions if XINERAMA is enabled
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c
index ce0aada..31d5fdd 100644
--- a/hw/xwin/winscrinit.c
+++ b/hw/xwin/winscrinit.c
@@ -216,15 +216,19 @@ winScreenInit(ScreenPtr pScreen, int argc, char **argv)
     else
         winErrorFVerb(2, "winScreenInit - Using software cursor\n");
 
-    /*
-       Note the screen origin in a normalized coordinate space where (0,0) is at the top left
-       of the native virtual desktop area
-     */
-    pScreen->x = pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN);
-    pScreen->y = pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN);
+    if (!noPanoramiXExtension) {
+        /*
+           Note the screen origin in a normalized coordinate space where (0,0) is at the top left
+           of the native virtual desktop area
+         */
+        pScreen->x =
+            pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN);
+        pScreen->y =
+            pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN);
 
-    ErrorF("Screen %d added at virtual desktop coordinate (%d,%d).\n",
-           pScreen->myNum, pScreen->x, pScreen->y);
+        ErrorF("Screen %d added at virtual desktop coordinate (%d,%d).\n",
+               pScreen->myNum, pScreen->x, pScreen->y);
+    }
 
 #if CYGDEBUG || YES
     winDebug("winScreenInit - returning\n");
commit 23e07d71b607c99c3a0a0ea362c70dcae73485c6
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Nov 6 14:28:17 2014 +0000

    hw/xwin: Register native screens with pseudoramiX
    
    Update man page to document pseudo-xinerama
    
    v2: Make the use of PseudoramiXExtensionInit() match the prototype
    v3: Update for nonsdk_extinit.h
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 246cd12..3b1ef3f 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -58,6 +58,11 @@ typedef WINAPI HRESULT(*SHGETFOLDERPATHPROC) (HWND hwndOwner,
                                               HANDLE hToken,
                                               DWORD dwFlags, LPTSTR pszPath);
 #endif
+
+#include "winmonitors.h"
+#include "nonsdk_extinit.h"
+#include "pseudoramiX/pseudoramiX.h"
+
 #include "glx_extinit.h"
 #ifdef XWIN_GLX_WINDOWS
 #include "glx/glwindows.h"
@@ -973,6 +978,59 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[])
         }
     }
 
+  /*
+     Unless full xinerama has been explicitly enabled, register all native screens with pseudoramiX
+  */
+  if (!noPanoramiXExtension)
+      noPseudoramiXExtension = TRUE;
+
+  if ((g_ScreenInfo[0].fMultipleMonitors) && !noPseudoramiXExtension)
+    {
+      int pass;
+
+      PseudoramiXExtensionInit();
+
+      /* Add primary monitor on pass 0, other monitors on pass 1, to ensure
+       the primary monitor is first in XINERAMA list */
+      for (pass = 0; pass < 2; pass++)
+        {
+          int iMonitor;
+
+          for (iMonitor = 1; ; iMonitor++)
+            {
+              struct GetMonitorInfoData data;
+              QueryMonitor(iMonitor, &data);
+              if (data.bMonitorSpecifiedExists)
+                {
+                  MONITORINFO mi;
+                  mi.cbSize = sizeof(MONITORINFO);
+
+                  if (GetMonitorInfo(data.monitorHandle, &mi))
+                    {
+                      /* pass == 1 XOR primary monitor flags is set */
+                      if ((!(pass == 1)) != (!(mi.dwFlags & MONITORINFOF_PRIMARY)))
+                        {
+                          /*
+                            Note the screen origin in a normalized coordinate space where (0,0) is at the top left
+                            of the native virtual desktop area
+                          */
+                          data.monitorOffsetX = data.monitorOffsetX - GetSystemMetrics(SM_XVIRTUALSCREEN);
+                          data.monitorOffsetY = data.monitorOffsetY - GetSystemMetrics(SM_YVIRTUALSCREEN);
+
+                          winDebug ("InitOutput - screen %d added at virtual desktop coordinate (%d,%d) (pseudoramiX) \n",
+                                    iMonitor-1, data.monitorOffsetX, data.monitorOffsetY);
+
+                          PseudoramiXAddScreen(data.monitorOffsetX, data.monitorOffsetY,
+                                               data.monitorWidth, data.monitorHeight);
+                        }
+                    }
+                }
+              else
+                break;
+            }
+        }
+    }
+
 #if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
 
     /* Generate a cookie used by internal clients for authorization */
diff --git a/hw/xwin/man/XWin.man b/hw/xwin/man/XWin.man
index ed93303..41019d1 100644
--- a/hw/xwin/man/XWin.man
+++ b/hw/xwin/man/XWin.man
@@ -76,6 +76,9 @@ preceeding \fB\-screen\fP parameter.
 .B \-[no]multimonitors or \-[no]multiplemonitors
 Create a screen 0 that covers all monitors [the primary monitor] on a system with
 multiple monitors.
+Fake XINERAMA data is created describing the individual monitors,
+(This is similar to the 'merged framebuffer' or 'pseudo-xinerama' mode provided by
+some drivers for the xorg X server).
 This option is currently enabled by default in \fB\-multiwindow\fP mode.
 .TP 8
 .B "\-screen \fIscreen_number\fP [\fIW\fP \fIH\fP [\fIX\fP \fIY\fP] | [[\fIW\fPx\fIH\fP[+\fIX\fP+\fIY\fP]][@\fIM\fP]] ] "
commit e036cbfccbe33775524a469082306913843c63df
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Nov 6 13:54:11 2014 +0000

    Make PseudoramiXExtensionInit() prototype more generally available
    
    Make PseudoramiXExtensionInit() prototype available to hw/xwin
    
    Rather than avoiding a reference to it being pulled in to Xorg by sdksyms by
    hiding this prototype behind the INXQUARTZ define, which is only defined when
    building Xquartz, introduce nonsdk_extinit.h and move it there.
    
    (The only remaining use of INXQUARTZ is in mi/miiniext.c, in order
    to do PseudoramiXExtensionInit() at the point apparently needed by Xquartz)
    
    Also remove duplicate declaration of noPseudoramiXExtension from pseudoramiX.h
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index d7229ce..851ce48 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -43,6 +43,7 @@
 #include "darwinEvents.h"
 #include "pseudoramiX.h"
 #include "extension.h"
+#include "nonsdk_extinit.h"
 #include "glx_extinit.h"
 #define _APPLEWM_SERVER_
 #include "applewmExt.h"
diff --git a/include/Makefile.am b/include/Makefile.am
index 168b00f..738b582 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -33,6 +33,7 @@ sdk_HEADERS =		\
 	misc.h		\
 	miscstruct.h	\
 	opaque.h	\
+	nonsdk_extinit.h	\
 	optionstr.h	\
 	os.h		\
 	pixmap.h	\
diff --git a/include/extinit.h b/include/extinit.h
index fa5f293..4ad4fca 100644
--- a/include/extinit.h
+++ b/include/extinit.h
@@ -163,11 +163,6 @@ extern void SELinuxExtensionInit(void);
 extern void XTestExtensionInit(void);
 #endif
 
-#ifdef INXQUARTZ
-extern _X_EXPORT Bool noPseudoramiXExtension;
-extern void PseudoramiXExtensionInit(void);
-#endif
-
 #if defined(XV)
 #include <X11/extensions/Xv.h>
 #include <X11/extensions/XvMC.h>
diff --git a/include/nonsdk_extinit.h b/include/nonsdk_extinit.h
new file mode 100644
index 0000000..da8d370
--- /dev/null
+++ b/include/nonsdk_extinit.h
@@ -0,0 +1,35 @@
+/***********************************************************
+
+Copyright 2014 Jon TURNEY
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#ifndef NONSDK_EXT_INIT_H
+#define NONSDK_EXT_INIT_H
+
+/* this is separate from extinit.h to avoid references to these symbols being
+   pulled in by sdksyms */
+
+extern _X_EXPORT Bool noPseudoramiXExtension;
+extern void PseudoramiXExtensionInit(void);
+
+#endif
diff --git a/pseudoramiX/pseudoramiX.c b/pseudoramiX/pseudoramiX.c
index f47c783..d0e2603 100644
--- a/pseudoramiX/pseudoramiX.c
+++ b/pseudoramiX/pseudoramiX.c
@@ -39,7 +39,7 @@
 
 #include "pseudoramiX.h"
 #include "extnsionst.h"
-#include "extinit.h"
+#include "nonsdk_extinit.h"
 #include "dixstruct.h"
 #include "window.h"
 #include <X11/extensions/panoramiXproto.h>
diff --git a/pseudoramiX/pseudoramiX.h b/pseudoramiX/pseudoramiX.h
index f063919..5393062 100644
--- a/pseudoramiX/pseudoramiX.h
+++ b/pseudoramiX/pseudoramiX.h
@@ -2,8 +2,6 @@
  * Minimal implementation of PanoramiX/Xinerama
  */
 
-extern int noPseudoramiXExtension;
-
 void
 PseudoramiXAddScreen(int x, int y, int w, int h);
 void
commit 3aad9b7556391b0f55e46ba13ced5e58d8fd47f7
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Mon Nov 7 20:54:10 2011 +0000

    hw/xwin: Turn on -hostintitle by default
    
    Turn on -hostintitle by default
    Provide -nohostintitle to disable if needed
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 654c58c..246cd12 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -739,7 +739,7 @@ winUseMsg(void)
 
     ErrorF("-fullscreen\n" "\tRun the server in fullscreen mode.\n");
 
-    ErrorF("-hostintitle\n"
+    ErrorF("-[no]hostintitle\n"
            "\tIn multiwindow mode, add remote host names to window titles.\n");
 
     ErrorF("-ignoreinput\n" "\tIgnore keyboard and mouse input.\n");
diff --git a/hw/xwin/man/XWin.man b/hw/xwin/man/XWin.man
index 15a57db..ed93303 100644
--- a/hw/xwin/man/XWin.man
+++ b/hw/xwin/man/XWin.man
@@ -167,9 +167,10 @@ on its own is equivalent to \fB\-resize=randr\fP
 
 .SH OPTIONS FOR MULTIWINDOW MODE
 .TP 8
-.B \-hostintitle
+.B \-[no]hostintitle
 Add the host name to the window title for X applications which are running
 on remote hosts, when that information is available and it's useful to do so.
+The default is enabled.
 
 .SH OPTIONS CONTROLLING WINDOWS INTEGRATION
 .TP 8
diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c
index ad82b83..1382c89 100644
--- a/hw/xwin/winglobals.c
+++ b/hw/xwin/winglobals.c
@@ -78,7 +78,7 @@ Bool g_fNoHelpMessageBox = FALSE;
 Bool g_fSoftwareCursor = FALSE;
 Bool g_fSilentDupError = FALSE;
 Bool g_fNativeGl = TRUE;
-Bool g_fHostInTitle = FALSE;
+Bool g_fHostInTitle = TRUE;
 pthread_mutex_t g_pmTerminating = PTHREAD_MUTEX_INITIALIZER;
 
 #ifdef XWIN_CLIPBOARD
diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index 837cdb2..65bba81 100644
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -1098,6 +1098,11 @@ ddxProcessArgument(int argc, char *argv[], int i)
         return 1;
     }
 
+    if (IS_OPTION("-nohostintitle")) {
+        g_fHostInTitle = FALSE;
+        return 1;
+    }
+
     return 0;
 }
 
commit b2aaf69e62f4109ffb8aaf39e9bd2571abb29dfb
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Jun 28 14:22:07 2012 +0100

    hw/xwin: Report Cygwin version information in log
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index e8cccb4..837cdb2 100644
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -31,6 +31,10 @@ from The Open Group.
 #include <xwin-config.h>
 #endif
 
+#ifdef HAVE_SYS_UTSNAME_H
+#include <sys/utsname.h>
+#endif
+
 #include <../xfree86/common/xorgVersion.h>
 #include "win.h"
 #include "winconfig.h"
@@ -1181,6 +1185,16 @@ winLogVersionInfo(void)
     ErrorF("Vendor: %s\n", XVENDORNAME);
     ErrorF("Release: %d.%d.%d.%d\n", XORG_VERSION_MAJOR,
            XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP);
+#ifdef HAVE_SYS_UTSNAME_H
+    {
+        struct utsname name;
+
+        if (uname(&name) >= 0) {
+            ErrorF("OS: %s %s %s %s %s\n", name.sysname, name.nodename,
+                   name.release, name.version, name.machine);
+        }
+    }
+#endif
     if (strlen(BUILDERSTRING))
         ErrorF("%s\n", BUILDERSTRING);
     ErrorF("Contact: %s\n", BUILDERADDR);
commit d02f9611c8d3bafca4be17c65efca3c5527f71e2
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Mon Mar 16 16:29:29 2015 +0000

    hw/xwin/glx: Improve code generator to deal with latest Khronos OpenGL registry XML
    
    Improve the parsing of the <proto> XML element
    
    Include all text from the param element, in the order it appears in the xml
    document, as part of the formal parameter declaration
    
    This is needed to correctly handle the XML description added in svn r27498 of
    glPathGlyphIndexRangeNV()'s baseAndCount parameter of type GLuint[2]
    
    This fixes the way the parameter declaration is generated so it is in the
    correct form 'GLuint baseAndCount_[2]' and not 'GLuint baseAndCount[2]_'
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/glx/gen_gl_wrappers.py b/hw/xwin/glx/gen_gl_wrappers.py
index 9627ef4..b9e8dda 100755
--- a/hw/xwin/glx/gen_gl_wrappers.py
+++ b/hw/xwin/glx/gen_gl_wrappers.py
@@ -136,9 +136,20 @@ def ParseCmdParams(cmd):
     params = cmd.elem.findall('param')
     plist=[]
     for param in params:
-        paramlist = ([t for t in param.itertext()])
-        paramtype = ''.join(paramlist[:-1])
-        paramname = paramlist[-1]
+        # construct the formal parameter definition from ptype and name
+        # elements, also using any text found around these in the
+        # param element, in the order it appears in the document
+        paramtype = ''
+        # also extract the formal parameter name from the name element
+        paramname = ''
+        for t in param.iter():
+            if t.tag == 'ptype' or t.tag == 'param':
+                paramtype = paramtype + noneStr(t.text)
+            if t.tag == 'name':
+                paramname = t.text + '_'
+                paramtype = paramtype + ' ' + paramname
+            if t.tail is not None:
+                paramtype = paramtype + t.tail.strip()
         plist.append((paramtype, paramname))
     return plist
 
@@ -206,7 +217,7 @@ class WrapperOutputGenerator(OutputGenerator):
         Comma=""
         if len(plist):
             for ptype, pname in plist:
-                self.outFile.write("%s%s%s_"%(Comma, ptype, pname))
+                self.outFile.write("%s%s"%(Comma, ptype))
                 Comma=", "
         else:
             self.outFile.write("void")
@@ -227,7 +238,7 @@ class WrapperOutputGenerator(OutputGenerator):
 
             Comma=""
             for ptype, pname in plist:
-                self.outFile.write("%s%s_"%(Comma, pname))
+                self.outFile.write("%s%s"%(Comma, pname))
                 Comma=", "
 
         # for GL 1.2+ functions, generate stdcall wrappers which use wglGetProcAddress()
@@ -253,7 +264,7 @@ class WrapperOutputGenerator(OutputGenerator):
 
             Comma=""
             for ptype, pname in plist:
-                self.outFile.write("%s%s_"%(Comma, pname))
+                self.outFile.write("%s%s"%(Comma, pname))
                 Comma=", "
         self.outFile.write(" );\n}\n\n")
 
@@ -282,10 +293,11 @@ class ThunkOutputGenerator(OutputGenerator):
         rettype=ParseCmdRettype(cmd)
         self.outFile.write("%s %sWrapper("%(rettype, name))
         plist=ParseCmdParams(cmd)
+
         Comma=""
         if len(plist):
             for ptype, pname in plist:
-                self.outFile.write("%s%s%s_"%(Comma, ptype, pname))
+                self.outFile.write("%s%s"%(Comma, ptype))
                 Comma=", "
         else:
             self.outFile.write("void")
@@ -301,7 +313,7 @@ class ThunkOutputGenerator(OutputGenerator):
 
             Comma=""
             for ptype, pname in plist:
-                self.outFile.write("%s%s_"%(Comma, pname))
+                self.outFile.write("%s%s"%(Comma, pname))
                 Comma=", "
 
         # for GL 1.2+ functions, generate wrappers which use wglGetProcAddress()
@@ -315,7 +327,7 @@ class ThunkOutputGenerator(OutputGenerator):
 
             Comma=""
             for ptype, pname in plist:
-                self.outFile.write("%s%s_"%(Comma, pname))
+                self.outFile.write("%s%s"%(Comma, pname))
                 Comma=", "
         self.outFile.write(" );\n}\n\n")
 
@@ -373,10 +385,11 @@ class ShimOutputGenerator(OutputGenerator):
         rettype=ParseCmdRettype(cmd)
         self.outFile.write("%s %s("%(rettype, name))
         plist=ParseCmdParams(cmd)
+
         Comma=""
         if len(plist):
             for ptype, pname in plist:
-                self.outFile.write("%s%s%s_"%(Comma, ptype, pname))
+                self.outFile.write("%s%s"%(Comma, ptype))
                 Comma=", "
         else:
             self.outFile.write("void")
@@ -388,7 +401,7 @@ class ShimOutputGenerator(OutputGenerator):
         if len(plist):
             Comma=""
             for ptype, pname in plist:
-                self.outFile.write("%s %s %s_"%(Comma, ptype, pname))
+                self.outFile.write("%s %s"%(Comma, ptype))
                 Comma=", "
         else:
             self.outFile.write("void")
@@ -404,7 +417,7 @@ class ShimOutputGenerator(OutputGenerator):
 
         Comma=""
         for ptype, pname in plist:
-            self.outFile.write("%s%s_"%(Comma, pname))
+            self.outFile.write("%s%s"%(Comma, pname))
             Comma=", "
 
         self.outFile.write(" );\n}\n\n")
commit 5071cb7e0ac5f17c48ed7f3f3b6f242dec802f66
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Mon Mar 16 16:14:10 2015 +0000

    hw/xwin/glx: Refactor parsing of the <proto> XML element
    
    Factor out duplicated code used in parsing of the <proto> XML element in the
    code generator
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/glx/gen_gl_wrappers.py b/hw/xwin/glx/gen_gl_wrappers.py
index 69ab1ef..9627ef4 100755
--- a/hw/xwin/glx/gen_gl_wrappers.py
+++ b/hw/xwin/glx/gen_gl_wrappers.py
@@ -123,6 +123,25 @@ else:
     errWarn = sys.stderr
 diag = open(diagFilename, 'w')
 
+def ParseCmdRettype(cmd):
+    proto=noneStr(cmd.elem.find('proto'))
+    rettype=noneStr(proto.text)
+    if rettype.lower()!="void ":
+        plist = ([t for t in proto.itertext()])
+        rettype = ''.join(plist[:-1])
+    rettype=rettype.strip()
+    return rettype
+
+def ParseCmdParams(cmd):
+    params = cmd.elem.findall('param')
+    plist=[]
+    for param in params:
+        paramlist = ([t for t in param.itertext()])
+        paramtype = ''.join(paramlist[:-1])
+        paramname = paramlist[-1]
+        plist.append((paramtype, paramname))
+    return plist
+
 class PreResolveOutputGenerator(OutputGenerator):
     def __init__(self,
                  errFile = sys.stderr,
@@ -179,21 +198,11 @@ class WrapperOutputGenerator(OutputGenerator):
         if prefix == 'wgl' and not name in used_wgl_ext_fns:
             return
 
-        proto=noneStr(cmd.elem.find('proto'))
-        rettype=noneStr(proto.text)
-        if rettype.lower()!="void ":
-            plist = ([t for t in proto.itertext()])
-            rettype = ''.join(plist[:-1])
-        rettype=rettype.strip()
+        rettype=ParseCmdRettype(cmd)
+
         if staticwrappers: self.outFile.write("static ")
         self.outFile.write("%s %sWrapper("%(rettype, name))
-        params = cmd.elem.findall('param')
-        plist=[]
-        for param in params:
-            paramlist = ([t for t in param.itertext()])
-            paramtype = ''.join(paramlist[:-1])
-            paramname = paramlist[-1]
-            plist.append((paramtype, paramname))
+        plist=ParseCmdParams(cmd)
         Comma=""
         if len(plist):
             for ptype, pname in plist:
@@ -270,20 +279,9 @@ class ThunkOutputGenerator(OutputGenerator):
     def genCmd(self, cmd, name):
         OutputGenerator.genCmd(self, cmd, name)
 
-        proto=noneStr(cmd.elem.find('proto'))
-        rettype=noneStr(proto.text)
-        if rettype.lower()!="void ":
-            plist = ([t for t in proto.itertext()])
-            rettype = ''.join(plist[:-1])
-        rettype=rettype.strip()
+        rettype=ParseCmdRettype(cmd)
         self.outFile.write("%s %sWrapper("%(rettype, name))
-        params = cmd.elem.findall('param')
-        plist=[]
-        for param in params:
-            paramlist = ([t for t in param.itertext()])
-            paramtype = ''.join(paramlist[:-1])
-            paramname = paramlist[-1]
-            plist.append((paramtype, paramname))
+        plist=ParseCmdParams(cmd)
         Comma=""
         if len(plist):
             for ptype, pname in plist:
@@ -372,20 +370,9 @@ class ShimOutputGenerator(OutputGenerator):
             return
 
         # for GL functions which are in the ABI, generate a shim which calls the function via GetProcAddress
-        proto=noneStr(cmd.elem.find('proto'))
-        rettype=noneStr(proto.text)
-        if rettype.lower()!="void ":
-            plist = ([t for t in proto.itertext()])
-            rettype = ''.join(plist[:-1])
-        rettype=rettype.strip()
+        rettype=ParseCmdRettype(cmd)
         self.outFile.write("%s %s("%(rettype, name))
-        params = cmd.elem.findall('param')
-        plist=[]
-        for param in params:
-            paramlist = ([t for t in param.itertext()])
-            paramtype = ''.join(paramlist[:-1])
-            paramname = paramlist[-1]
-            plist.append((paramtype, paramname))
+        plist=ParseCmdParams(cmd)
         Comma=""
         if len(plist):
             for ptype, pname in plist:
commit d3080d421bf0d91daea2e39bfc391c43d7fdad75
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Feb 5 20:29:48 2015 +0000

    os: Teach vpnprintf() how to handle "%*.*s"
    
    XdmcpFatal uses the format specifier %*.*s, which vpnprintf() doesn't
    understand, which causes a backtrace and prevents the reason for the XDMCP
    failure being logged.
    
    See also:
    https://bugs.freedesktop.org/show_bug.cgi?id=66862
    https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=758574
    
    "%*.*s" is also currently used in a few other places, so teach vpnprintf() how
    to handle it
    
    $ fgrep -r "%*.*s" *
    hw/dmx/config/scanner.l:    fprintf(stderr, "parse error on line %d at token \"%*.*s\"\n",
    hw/dmx/dmxlog.c:        ErrorF("(%s) dmx[i%d/%*.*s]: ", type,
    hw/dmx/input/dmxinputinit.c:                dmxLogCont(dmxInfo, "\t[i%d/%*.*s",
    os/access.c:        ErrorF("Xserver: siAddrMatch(): type = %s, value = %*.*s -- %s\n",
    os/access.c:                ("Xserver: siCheckAddr(): type = %s, value = %*.*s, len = %d -- %s\n",
    os/xdmcp.c:    FatalError("XDMCP fatal error: %s %*.*s\n", type,
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/os/log.c b/os/log.c
index 0532c2e..3db5c53 100644
--- a/os/log.c
+++ b/os/log.c
@@ -355,6 +355,7 @@ vpnprintf(char *string, int size_in, const char *f, va_list args)
     uint64_t ui;
     int64_t si;
     size_t size = size_in;
+    int precision;
 
     for (; f_idx < f_len && s_idx < size - 1; f_idx++) {
         int length_modifier = 0;
@@ -365,9 +366,29 @@ vpnprintf(char *string, int size_in, const char *f, va_list args)
 
         f_idx++;
 
-        /* silently swallow digit length modifiers */
-        while (f_idx < f_len && ((f[f_idx] >= '0' && f[f_idx] <= '9') || f[f_idx] == '.'))
+        /* silently swallow minimum field width */
+        if (f[f_idx] == '*') {
             f_idx++;
+            va_arg(args, int);
+        } else {
+            while (f_idx < f_len && ((f[f_idx] >= '0' && f[f_idx] <= '9')))
+                f_idx++;
+        }
+
+        /* is there a precision? */
+        precision = size;
+        if (f[f_idx] == '.') {
+            f_idx++;
+            if (f[f_idx] == '*') {
+                f_idx++;
+                /* precision is supplied in an int argument */
+                precision = va_arg(args, int);
+            } else {
+                /* silently swallow precision digits */
+                while (f_idx < f_len && ((f[f_idx] >= '0' && f[f_idx] <= '9')))
+                    f_idx++;
+            }
+        }
 
         /* non-digit length modifiers */
         if (f_idx < f_len) {
@@ -383,9 +404,8 @@ vpnprintf(char *string, int size_in, const char *f, va_list args)
         switch (f[f_idx]) {
         case 's':
             string_arg = va_arg(args, char*);
-            p_len = strlen_sigsafe(string_arg);
 
-            for (i = 0; i < p_len && s_idx < size - 1; i++)
+            for (i = 0; string_arg[i] != 0 && s_idx < size - 1 && s_idx < precision; i++)
                 string[s_idx++] = string_arg[i];
             break;
 
commit 491cf02e191e70c5ce24c19da880bb79bebfc03c
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Tue Feb 10 14:37:26 2015 +0000

    os: XDMCP options like -query etc. should imply -listen tcp
    
    In X server 1.17, the default configuration is now -nolisten tcp.  In this
    configuration, XDMCP options don't work usefully, as the X server is not
    listening on the port for the display that it tells the display manager to
    connect to.
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/os/xdmcp.c b/os/xdmcp.c
index b6e97c9..bc5a707 100644
--- a/os/xdmcp.c
+++ b/os/xdmcp.c
@@ -48,6 +48,11 @@
 #include <netdir.h>
 #endif
 
+#define XSERV_t
+#define TRANS_SERVER
+#define TRANS_REOPEN
+#include <X11/Xtrans/Xtrans.h>
+
 #ifdef XDMCP
 #undef REQUEST
 
@@ -242,6 +247,14 @@ XdmcpUseMsg(void)
     ErrorF("-displayID display-id  manufacturer display ID for request\n");
 }
 
+static void
+XdmcpDefaultListen(void)
+{
+    /* Even when configured --disable-listen-tcp, we should listen on tcp in
+       XDMCP modes */
+    _XSERVTransListen("tcp");
+}
+
 int
 XdmcpOptions(int argc, char **argv, int i)
 {
@@ -249,11 +262,13 @@ XdmcpOptions(int argc, char **argv, int i)
         get_manager_by_name(argc, argv, i++);
         XDM_INIT_STATE = XDM_QUERY;
         AccessUsingXdmcp();
+        XdmcpDefaultListen();
         return i + 1;
     }
     if (strcmp(argv[i], "-broadcast") == 0) {
         XDM_INIT_STATE = XDM_BROADCAST;
         AccessUsingXdmcp();
+        XdmcpDefaultListen();
         return i + 1;
     }
 #if defined(IPv6) && defined(AF_INET6)
@@ -261,6 +276,7 @@ XdmcpOptions(int argc, char **argv, int i)
         i = get_mcast_options(argc, argv, ++i);
         XDM_INIT_STATE = XDM_MULTICAST;
         AccessUsingXdmcp();
+        XdmcpDefaultListen();
         return i + 1;
     }
 #endif
@@ -268,6 +284,7 @@ XdmcpOptions(int argc, char **argv, int i)
         get_manager_by_name(argc, argv, i++);
         XDM_INIT_STATE = XDM_INDIRECT;
         AccessUsingXdmcp();
+        XdmcpDefaultListen();
         return i + 1;
     }
     if (strcmp(argv[i], "-port") == 0) {
commit f42520c5f151bda25e52ae8b0408a421c3fba7e5
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Wed Feb 4 17:04:45 2015 +0000

    ephyr: Avoid a segfault with 'DISPLAY= Xephy -glamor'
    
    ephyr_glamor_connect() returns NULL if we failed, but applying
    xcb_connection_has_error() to NULL is not permitted.
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Daniel Martin <consume.noise at gmail.com>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index f64861b..15edce8 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -443,7 +443,7 @@ hostx_init(void)
     else
 #endif
         HostX.conn = xcb_connect(NULL, &HostX.screen);
-    if (xcb_connection_has_error(HostX.conn)) {
+    if (!HostX.conn || xcb_connection_has_error(HostX.conn)) {
         fprintf(stderr, "\nXephyr cannot open host display. Is DISPLAY set?\n");
         exit(1);
     }


More information about the xorg-commit mailing list