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 <jon.turney@dronecode.org.uk>
This commit is contained in:
Colin Harrison 2008-11-02 20:46:44 +00:00 committed by Jon TURNEY
parent b0ed1567c1
commit 21a2df9f35
2 changed files with 37 additions and 10 deletions

View File

@ -361,7 +361,7 @@ winAllocateFBShadowDD (ScreenPtr pScreen)
{ {
ErrorF ("winAllocateFBShadowDD - Changing video mode\n"); 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, ddrval = IDirectDraw2_SetDisplayMode (pScreenPriv->pdd2,
pScreenInfo->dwWidth, pScreenInfo->dwWidth,
pScreenInfo->dwHeight, pScreenInfo->dwHeight,
@ -373,9 +373,22 @@ winAllocateFBShadowDD (ScreenPtr pScreen)
ErrorF ("winAllocateFBShadowDD - Could not set "\ ErrorF ("winAllocateFBShadowDD - Could not set "\
"full screen display mode: %08x\n", "full screen display mode: %08x\n",
(unsigned int) ddrval); (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; return FALSE;
} }
} }
}
else else
{ {
ErrorF ("winAllocateFBShadowDD - Not changing video mode\n"); ErrorF ("winAllocateFBShadowDD - Not changing video mode\n");
@ -534,7 +547,7 @@ winShadowUpdateDD (ScreenPtr pScreen,
ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL); ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
if (FAILED (ddrval)) if (FAILED (ddrval))
{ {
ErrorF ("winShadowUpdateProcDD - Unlock failed\n"); ErrorF ("winShadowUpdateDD - Unlock failed\n");
return; return;
} }
@ -626,19 +639,20 @@ winShadowUpdateDD (ScreenPtr pScreen,
NULL); NULL);
if (FAILED (ddrval)) if (FAILED (ddrval))
{ {
ErrorF ("winShadowUpdateProcDD - Lock failed\n"); ErrorF ("winShadowUpdateDD - Lock failed\n");
return; return;
} }
/* Has our memory pointer changed? */ /* Has our memory pointer changed? */
if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface) 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 " "surface has changed, trying to update the root window "
"pixmap header to point to the new address. If you get " "pixmap header to point to the new address. If you get "
"this message and "PROJECT_NAME" freezes or crashes " "this message and "PROJECT_NAME" freezes or crashes "
"after this message then send a problem report and your " "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 */ /* Location of shadow framebuffer has changed */
pScreenInfo->pfb = pScreenPriv->pddsdShadow->lpSurface; pScreenInfo->pfb = pScreenPriv->pddsdShadow->lpSurface;
@ -653,7 +667,7 @@ winShadowUpdateDD (ScreenPtr pScreen,
pScreenInfo->dwBPP), pScreenInfo->dwBPP),
pScreenInfo->pfb)) pScreenInfo->pfb))
{ {
ErrorF ("winShadowUpdateProcDD - Bits changed, could not " ErrorF ("winShadowUpdateDD - Bits changed, could not "
"notify fb.\n"); "notify fb.\n");
return; return;
} }

View File

@ -391,7 +391,7 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
{ {
winDebug ("winAllocateFBShadowDDNL - Changing video mode\n"); 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, ddrval = IDirectDraw4_SetDisplayMode (pScreenPriv->pdd4,
pScreenInfo->dwWidth, pScreenInfo->dwWidth,
pScreenInfo->dwHeight, pScreenInfo->dwHeight,
@ -403,9 +403,22 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
ErrorF ("winAllocateFBShadowDDNL - Could not set " ErrorF ("winAllocateFBShadowDDNL - Could not set "
"full screen display mode: %08x\n", "full screen display mode: %08x\n",
(unsigned int) ddrval); (unsigned int) ddrval);
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; return FALSE;
} }
} }
}
else else
{ {
winDebug ("winAllocateFBShadowDDNL - Not changing video mode\n"); winDebug ("winAllocateFBShadowDDNL - Not changing video mode\n");
@ -1310,7 +1323,7 @@ winStoreColorsShadowDDNL (ColormapPtr pColormap,
+ pdefs[0].pixel); + pdefs[0].pixel);
if (FAILED (ddrval)) if (FAILED (ddrval))
{ {
ErrorF ("winStoreColorsShadowDDNL - SetEntries () failed: %08x\n", ddrval); ErrorF ("winStoreColorsShadowDDNL - SetEntries () failed: %08x\n", (unsigned int) ddrval);
return FALSE; return FALSE;
} }