From 21a2df9f359584e634dc12d8602401d54defd7db Mon Sep 17 00:00:00 2001 From: Colin Harrison Date: Sun, 2 Nov 2008 20:46:44 +0000 Subject: [PATCH] Xming,Cygwin/X: Fix crashes when using the DirectDraw '-refresh rate-in-Hz' option in -fullscreen (#11128) fd.o bugzilla #11128 Fix crashes when using the '-refresh rate-in-Hz' option in -fullscreen mode and using a DirectDraw engine. On failure (typically 0x80004001 DDERR_UNSUPPORTED), use the default refresh rate for the driver, instead of the entered value. Also fix some nearby error reporting Copyright (C) Colin Harrison 2005-2008 http://www.straightrunning.com/XmingNotes/ http://sourceforge.net/projects/xming/ Signed-off-by: Jon TURNEY --- hw/xwin/winshaddd.c | 28 +++++++++++++++++++++------- hw/xwin/winshadddnl.c | 19 ++++++++++++++++--- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/hw/xwin/winshaddd.c b/hw/xwin/winshaddd.c index 5f5daeb18..6e1f973a8 100644 --- a/hw/xwin/winshaddd.c +++ b/hw/xwin/winshaddd.c @@ -361,7 +361,7 @@ winAllocateFBShadowDD (ScreenPtr pScreen) { ErrorF ("winAllocateFBShadowDD - Changing video mode\n"); - /* Change the video mode to the mode requested */ + /* 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, @@ -373,7 +373,20 @@ winAllocateFBShadowDD (ScreenPtr pScreen) ErrorF ("winAllocateFBShadowDD - Could not set "\ "full screen display mode: %08x\n", (unsigned int) ddrval); - return FALSE; + 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 @@ -534,7 +547,7 @@ winShadowUpdateDD (ScreenPtr pScreen, ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL); if (FAILED (ddrval)) { - ErrorF ("winShadowUpdateProcDD - Unlock failed\n"); + ErrorF ("winShadowUpdateDD - Unlock failed\n"); return; } @@ -626,19 +639,20 @@ winShadowUpdateDD (ScreenPtr pScreen, NULL); if (FAILED (ddrval)) { - ErrorF ("winShadowUpdateProcDD - Lock failed\n"); + ErrorF ("winShadowUpdateDD - Lock failed\n"); return; } /* Has our memory pointer changed? */ if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface) { - ErrorF ("winShadowUpdateProcDD - Memory location of the shadow " + extern char *g_pszLogFile; + 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 " - "/tmp/XWin.log file to cygwin-xfree@cygwin.com\n"); + "%s file to " BUILDERADDR, g_pszLogFile); /* Location of shadow framebuffer has changed */ pScreenInfo->pfb = pScreenPriv->pddsdShadow->lpSurface; @@ -653,7 +667,7 @@ winShadowUpdateDD (ScreenPtr pScreen, pScreenInfo->dwBPP), pScreenInfo->pfb)) { - ErrorF ("winShadowUpdateProcDD - Bits changed, could not " + ErrorF ("winShadowUpdateDD - Bits changed, could not " "notify fb.\n"); return; } diff --git a/hw/xwin/winshadddnl.c b/hw/xwin/winshadddnl.c index 630c720ec..ef5c21469 100644 --- a/hw/xwin/winshadddnl.c +++ b/hw/xwin/winshadddnl.c @@ -391,7 +391,7 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen) { winDebug ("winAllocateFBShadowDDNL - Changing video mode\n"); - /* Change the video mode to the mode requested */ + /* Change the video mode to the mode requested, and use the driver default refresh rate on failure */ ddrval = IDirectDraw4_SetDisplayMode (pScreenPriv->pdd4, pScreenInfo->dwWidth, pScreenInfo->dwHeight, @@ -403,7 +403,20 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen) ErrorF ("winAllocateFBShadowDDNL - Could not set " "full screen display mode: %08x\n", (unsigned int) ddrval); - return FALSE; + ErrorF ("winAllocateFBShadowDDNL - Using default driver refresh rate\n"); + ddrval = IDirectDraw4_SetDisplayMode (pScreenPriv->pdd4, + pScreenInfo->dwWidth, + pScreenInfo->dwHeight, + pScreenInfo->dwBPP, + 0, + 0); + if (FAILED(ddrval)) + { + ErrorF ("winAllocateFBShadowDDNL - Could not set default refresh rate " + "full screen display mode: %08x\n", + (unsigned int) ddrval); + return FALSE; + } } } else @@ -1310,7 +1323,7 @@ winStoreColorsShadowDDNL (ColormapPtr pColormap, + pdefs[0].pixel); if (FAILED (ddrval)) { - ErrorF ("winStoreColorsShadowDDNL - SetEntries () failed: %08x\n", ddrval); + ErrorF ("winStoreColorsShadowDDNL - SetEntries () failed: %08x\n", (unsigned int) ddrval); return FALSE; }