This is an update to the resolution changing code for Wine desktop and XVidmode modes. This should make a lot of apps happier. More logging was added just in case, though!
ChangeLog: - Add more logging to resolution changes and queries - Always enumerate and allow 8, 16, and 32-bit modes - Add more default choices to Wine desktop sizes - Renamed some variables to make things easier to follow
Index: dlls/x11drv/desktop.c =================================================================== RCS file: /home/wine/wine/dlls/x11drv/desktop.c,v retrieving revision 1.14 diff -u -r1.14 desktop.c --- dlls/x11drv/desktop.c 26 Sep 2003 04:29:57 -0000 1.14 +++ dlls/x11drv/desktop.c 29 Sep 2003 19:01:09 -0000 @@ -120,43 +120,64 @@ static unsigned int max_width; static unsigned int max_height; -static const unsigned int widths[] = {320, 640, 800, 1024, 1280, 1600}; -static const unsigned int heights[] = {200, 480, 600, 768, 1024, 1200}; +static const unsigned int widths[] = {320, 512, 640, 800, 1024, 1152, 1280, 1600}; +static const unsigned int heights[] = {200, 384, 480, 600, 768, 864, 1024, 1200}; +static const unsigned int depths[] = {8, 16, 32}; /* fill in DD mode info for one mode*/ -static void make_one_mode (LPDDHALMODEINFO info, unsigned int width, unsigned int height) +static void make_one_mode (LPDDHALMODEINFO info, unsigned int width, unsigned int height, unsigned int bpp) { info->dwWidth = width; info->dwHeight = height; info->wRefreshRate = 0; info->lPitch = 0; - info->dwBPP = 0; + info->dwBPP = bpp; info->wFlags = 0; info->dwRBitMask = 0; info->dwGBitMask = 0; info->dwBBitMask = 0; info->dwAlphaBitMask = 0; - TRACE("initialized mode %dx%d\n", width, height); + TRACE("initialized mode %d: %dx%dx%d\n", nmodes, width, height, bpp); } /* create the mode structures */ static void make_modes(void) { - int i; - nmodes = 2; - for (i=0; i<6; i++) + int i,j; + int max_modes = (3+1)*(8+2); + DWORD dwBpp = screen_depth; + if (dwBpp == 24) dwBpp = 32; + nmodes = 0; + dd_modes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDHALMODEINFO) * max_modes); + /* original specified desktop size */ + make_one_mode(&dd_modes[nmodes++], screen_width, screen_height, dwBpp); + for (i=0; i<8; i++) { - if ( (widths[i] <= max_width) && (heights[i] <= max_height) ) nmodes++; + if ( (widths[i] <= max_width) && (heights[i] <= max_height) ) + { + if ( ( (widths[i] != max_width) || (heights[i] != max_height) ) && + ( (widths[i] != screen_width) || (heights[i] != screen_height) ) ) + { + /* only add them if they are smaller than the root window and unique */ + make_one_mode(&dd_modes[nmodes++], widths[i], heights[i], dwBpp); + } + } } - dd_modes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDHALMODEINFO) * nmodes); - /* mode 0 is the original specified desktop size */ - make_one_mode(&dd_modes[0], screen_width, screen_height); - /* mode 1 is the root window size */ - make_one_mode(&dd_modes[1], max_width, max_height); - /* these modes are all the standard modes smaller than the root window */ - for (i=2; i<nmodes; i++) + if ((max_width != screen_width) && (max_height != screen_height)) { - make_one_mode(&dd_modes[i], widths[i-2], heights[i-2]); + /* root window size (if different from desktop window) */ + make_one_mode(&dd_modes[nmodes++], max_width, max_height, dwBpp); + } + max_modes = nmodes; + for (j=0; j<3; j++) + { + if (depths[j] != dwBpp) + { + for (i=0; i < max_modes; i++) + { + make_one_mode(&dd_modes[nmodes++], dd_modes[i].dwWidth, dd_modes[i].dwHeight, depths[j]); + } + } } } @@ -191,6 +212,9 @@ #if 0 /* FIXME */ SYSMETRICS_Set( SM_CXSCREEN, width ); SYSMETRICS_Set( SM_CYSCREEN, height ); +#else + FIXME("Need to update SYSMETRICS after resizing display (now %dx%d)\n", + width, height); #endif /* clean up */ @@ -279,19 +303,29 @@ void X11DRV_desktop_SetCurrentMode(int mode) { + DWORD dwBpp = screen_depth; + if (dwBpp == 24) dwBpp = 32; if (mode < nmodes) { + TRACE("Resizing Wine desktop window to %ldx%ld\n", dd_modes[mode].dwWidth, dd_modes[mode].dwHeight); X11DRV_resize_desktop(dd_modes[mode].dwWidth, dd_modes[mode].dwHeight); + if (dwBpp != dd_modes[mode].dwBPP) + { + FIXME("Cannot change screen BPP from %ld to %ld\n", dwBpp, dd_modes[mode].dwBPP); + } } } int X11DRV_desktop_GetCurrentMode(void) { + DWORD dwBpp = screen_depth; + if (dwBpp == 24) dwBpp = 32; int i; for (i=0; i<nmodes; i++) { if ( (screen_width == dd_modes[i].dwWidth) && - (screen_height == dd_modes[i].dwHeight) ) + (screen_height == dd_modes[i].dwHeight) && + (dwBpp == dd_modes[i].dwBPP)) return i; } ERR("In unknown mode, returning default\n"); @@ -308,21 +342,31 @@ devmode->dmDisplayFlags = 0; devmode->dmDisplayFrequency = 85; devmode->dmSize = sizeof(DEVMODEW); - if (n==0 || n == (DWORD)-1 || n == (DWORD)-2) + if (n==(DWORD)-1) + { + devmode->dmBitsPerPel = dwBpp; + devmode->dmPelsHeight = screen_height; + devmode->dmPelsWidth = screen_width; + devmode->dmFields = (DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL); + TRACE("mode %ld (current) -- returning current %ldx%ldx%ldbpp\n", n, + devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel); + return TRUE; + } + else if (n==(DWORD)-2) { devmode->dmBitsPerPel = dwBpp; devmode->dmPelsHeight = dd_modes[0].dwHeight; devmode->dmPelsWidth = dd_modes[0].dwWidth; devmode->dmFields = (DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL); - TRACE("mode %ld -- returning default %ldx%ldx%ldbpp\n", n, + TRACE("mode %ld (registry) -- returning default %ldx%ldx%ldbpp\n", n, devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel); return TRUE; - } - if (n <= nmodes) + } + else if (n < nmodes) { devmode->dmPelsWidth = dd_modes[n].dwWidth; devmode->dmPelsHeight = dd_modes[n].dwHeight; - devmode->dmBitsPerPel = dwBpp; + devmode->dmBitsPerPel = dd_modes[n].dwBPP; devmode->dmFields = (DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL); TRACE("mode %ld -- %ldx%ldx%ldbpp\n", n, devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel); @@ -349,7 +393,7 @@ { if (devmode->dmFields & DM_BITSPERPEL) { - if (devmode->dmBitsPerPel != dwBpp) + if (devmode->dmBitsPerPel != dd_modes[i].dwBPP) continue; } if (devmode->dmFields & DM_PELSWIDTH) @@ -363,12 +407,8 @@ continue; } /* we have a valid mode */ - TRACE("Matches mode %ld\n", i); + TRACE("Requested display settings match mode %ld\n", i); X11DRV_desktop_SetCurrentMode(i); -#if 0 /* FIXME */ - SYSMETRICS_Set( SM_CXSCREEN, devmode->dmPelsWidth ); - SYSMETRICS_Set( SM_CYSCREEN, devmode->dmPelsHeight ); -#endif return DISP_CHANGE_SUCCESSFUL; } @@ -381,6 +421,7 @@ static DWORD PASCAL X11DRV_desktop_SetMode(LPDDHAL_SETMODEDATA data) { + TRACE("Mode %ld requested by DDHAL\n", data->dwModeIndex); X11DRV_desktop_SetCurrentMode(data->dwModeIndex); X11DRV_DDHAL_SwitchMode(data->dwModeIndex, NULL, NULL); data->ddRVal = DD_OK; @@ -391,6 +432,7 @@ { if (!nmodes) return 0; /* no desktop */ + TRACE("Setting up Desktop mode for DDRAW\n"); info->dwNumModes = nmodes; info->lpModeInfo = dd_modes; X11DRV_DDHAL_SwitchMode(X11DRV_desktop_GetCurrentMode(), NULL, NULL); Index: dlls/x11drv/xvidmode.c =================================================================== RCS file: /home/wine/wine/dlls/x11drv/xvidmode.c,v retrieving revision 1.22 diff -u -r1.22 xvidmode.c --- dlls/x11drv/xvidmode.c 16 Sep 2003 20:24:29 -0000 1.22 +++ dlls/x11drv/xvidmode.c 29 Sep 2003 19:01:09 -0000 @@ -52,12 +52,13 @@ static BOOL xf86vm_use_gammaramp; #endif -static LPDDHALMODEINFO xf86vm_modes; -static unsigned xf86vm_mode_count; -static XF86VidModeModeInfo** modes; +static LPDDHALMODEINFO dd_modes; +static unsigned int dd_mode_count; +static XF86VidModeModeInfo** real_xf86vm_modes; +static unsigned int real_xf86vm_mode_count; static unsigned int xf86vm_initial_mode; -static void convert_modeinfo( const XF86VidModeModeInfo *mode, LPDDHALMODEINFO info ) +static void convert_modeinfo( const XF86VidModeModeInfo *mode, LPDDHALMODEINFO info, unsigned int bpp) { info->dwWidth = mode->hdisplay; info->dwHeight = mode->vdisplay; @@ -67,10 +68,8 @@ info->wRefreshRate = 0; TRACE(" width=%ld, height=%ld, refresh=%d\n", info->dwWidth, info->dwHeight, info->wRefreshRate); - /* XVidMode cannot change display depths... */ - /* let's not bother with filling out these then... */ info->lPitch = 0; - info->dwBPP = 0; + info->dwBPP = bpp; info->wFlags = 0; info->dwRBitMask = 0; info->dwGBitMask = 0; @@ -78,7 +77,7 @@ info->dwAlphaBitMask = 0; } -static void convert_modeline(int dotclock, const XF86VidModeModeLine *mode, LPDDHALMODEINFO info) +static void convert_modeline(int dotclock, const XF86VidModeModeLine *mode, LPDDHALMODEINFO info, unsigned int bpp) { info->dwWidth = mode->hdisplay; info->dwHeight = mode->vdisplay; @@ -88,10 +87,8 @@ info->wRefreshRate = 0; TRACE(" width=%ld, height=%ld, refresh=%d\n", info->dwWidth, info->dwHeight, info->wRefreshRate); - /* XVidMode cannot change display depths... */ - /* let's not bother with filling out these then... */ info->lPitch = 0; - info->dwBPP = 0; + info->dwBPP = bpp; info->wFlags = 0; info->dwRBitMask = 0; info->dwGBitMask = 0; @@ -105,10 +102,14 @@ } static Bool in_desktop_mode; +static const unsigned int depths[] = {8, 16, 32}; void X11DRV_XF86VM_Init(void) { - int nmodes, i; + int nmodes, i, j; + int max_modes; + DWORD dwBpp = screen_depth; + if (dwBpp == 24) dwBpp = 32; Bool ok; in_desktop_mode = (root_window != DefaultRootWindow(gdi_display)); @@ -138,7 +139,7 @@ #endif /* retrieve modes */ - if (!in_desktop_mode) ok = XF86VidModeGetAllModeLines(gdi_display, DefaultScreen(gdi_display), &nmodes, &modes); + if (!in_desktop_mode) ok = XF86VidModeGetAllModeLines(gdi_display, DefaultScreen(gdi_display), &nmodes, &real_xf86vm_modes); } wine_tsx11_unlock(); if (!ok) return; @@ -148,12 +149,29 @@ TRACE("XVidMode modes: count=%d\n", nmodes); - xf86vm_mode_count = nmodes; - xf86vm_modes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDHALMODEINFO) * nmodes); + real_xf86vm_mode_count = nmodes; + max_modes = (3+1)*(nmodes); + + dd_modes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDHALMODEINFO) * max_modes); /* convert modes to DDHALMODEINFO format */ - for (i=0; i<nmodes; i++) - convert_modeinfo(modes[i], &xf86vm_modes[i]); + for (i=0; i<real_xf86vm_mode_count; i++) + { + convert_modeinfo(real_xf86vm_modes[i], &dd_modes[dd_mode_count++], dwBpp); + } + /* add modes for different color depths */ + for (j=0; j<3; j++) + { + if (depths[j] != dwBpp) + { + for (i=0; i < real_xf86vm_mode_count; i++) + { + convert_modeinfo(real_xf86vm_modes[i], &dd_modes[dd_mode_count++], depths[j]); + } + } + } + + TRACE("Available DD modes: count=%d\n", dd_mode_count); /* store the current mode at the time we started */ xf86vm_initial_mode = X11DRV_XF86VM_GetCurrentMode(); @@ -163,7 +181,7 @@ void X11DRV_XF86VM_Cleanup(void) { - if (modes) TSXFree(modes); + if (real_xf86vm_modes) TSXFree(real_xf86vm_modes); } int X11DRV_XF86VM_GetCurrentMode(void) @@ -171,16 +189,18 @@ XF86VidModeModeLine line; int dotclock, i; DDHALMODEINFO cmode; + DWORD dwBpp = screen_depth; + if (dwBpp == 24) dwBpp = 32; - if (!xf86vm_modes) return 0; /* no XVidMode */ + if (!dd_modes) return 0; /* no XVidMode */ TRACE("Querying XVidMode current mode\n"); wine_tsx11_lock(); XF86VidModeGetModeLine(gdi_display, DefaultScreen(gdi_display), &dotclock, &line); wine_tsx11_unlock(); - convert_modeline(dotclock, &line, &cmode); - for (i=0; i<xf86vm_mode_count; i++) - if (memcmp(&xf86vm_modes[i], &cmode, sizeof(cmode)) == 0) { + convert_modeline(dotclock, &line, &cmode, dwBpp); + for (i=0; i<dd_mode_count; i++) + if (memcmp(&dd_modes[i], &cmode, sizeof(cmode)) == 0) { TRACE("mode=%d\n", i); return i; } @@ -190,10 +210,22 @@ void X11DRV_XF86VM_SetCurrentMode(int mode) { - if (!xf86vm_modes) return; /* no XVidMode */ + if (!dd_modes) return; /* no XVidMode */ + + /* only set modes from the original color depth */ + mode = mode % real_xf86vm_mode_count; wine_tsx11_lock(); - XF86VidModeSwitchToMode(gdi_display, DefaultScreen(gdi_display), modes[mode]); + TRACE("Resizing X display to %dx%d\n", + real_xf86vm_modes[mode]->hdisplay, real_xf86vm_modes[mode]->vdisplay); + XF86VidModeSwitchToMode(gdi_display, DefaultScreen(gdi_display), real_xf86vm_modes[mode]); +#if 0 /* FIXME */ + SYSMETRICS_Set( SM_CXSCREEN, real_xf86vm_modes[mode]->hdisplay ); + SYSMETRICS_Set( SM_CYSCREEN, real_xf86vm_modes[mode]->vdisplay ); +#else + FIXME("Need to update SYSMETRICS after resizing display (now %dx%d)\n", + real_xf86vm_modes[mode]->hdisplay, real_xf86vm_modes[mode]->vdisplay); +#endif #if 0 /* it is said that SetViewPort causes problems with some X servers */ XF86VidModeSetViewPort(gdi_display, DefaultScreen(gdi_display), 0, 0); #else @@ -205,7 +237,7 @@ void X11DRV_XF86VM_SetExclusiveMode(int lock) { - if (!xf86vm_modes) return; /* no XVidMode */ + if (!dd_modes) return; /* no XVidMode */ wine_tsx11_lock(); XF86VidModeLockModeSwitch(gdi_display, DefaultScreen(gdi_display), lock); @@ -216,6 +248,7 @@ static DWORD PASCAL X11DRV_XF86VM_SetMode(LPDDHAL_SETMODEDATA data) { + TRACE("Mode %ld requested by DDHAL\n", data->dwModeIndex); X11DRV_XF86VM_SetCurrentMode(data->dwModeIndex); X11DRV_DDHAL_SwitchMode(data->dwModeIndex, NULL, NULL); data->ddRVal = DD_OK; @@ -224,10 +257,11 @@ int X11DRV_XF86VM_CreateDriver(LPDDHALINFO info) { - if (!xf86vm_mode_count) return 0; /* no XVidMode */ + if (!dd_mode_count) return 0; /* no XVidMode */ - info->dwNumModes = xf86vm_mode_count; - info->lpModeInfo = xf86vm_modes; + TRACE("Setting up XF86VM mode for DDRAW\n"); + info->dwNumModes = dd_mode_count; + info->lpModeInfo = dd_modes; X11DRV_DDHAL_SwitchMode(X11DRV_XF86VM_GetCurrentMode(), NULL, NULL); info->lpDDCallbacks->SetMode = X11DRV_XF86VM_SetMode; return TRUE; @@ -427,36 +461,38 @@ devmode->dmDisplayFlags = 0; devmode->dmDisplayFrequency = 85; devmode->dmSize = sizeof(DEVMODEW); - if (n==0 || n == (DWORD)-1 || n == (DWORD)-2) + if (n == (DWORD)-1) + { + TRACE("mode %ld (current) -- getting current mode\n", n); + n = X11DRV_XF86VM_GetCurrentMode(); + } + if (n == (DWORD)-2) { devmode->dmBitsPerPel = dwBpp; devmode->dmPelsHeight = GetSystemMetrics(SM_CYSCREEN); devmode->dmPelsWidth = GetSystemMetrics(SM_CXSCREEN); devmode->dmFields = (DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL); - TRACE("mode %ld -- returning default %ldx%ldx%ldbpp\n", n, + TRACE("mode %ld (registry) -- returning default %ldx%ldx%ldbpp\n", n, devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel); return TRUE; } -#ifdef HAVE_LIBXXF86VM - if (n <= xf86vm_mode_count) + if (n < dd_mode_count) { - XF86VidModeModeInfo *mode; - mode = modes[n-1]; - devmode->dmPelsWidth = mode->hdisplay; - devmode->dmPelsHeight = mode->vdisplay; - devmode->dmBitsPerPel = dwBpp; - devmode->dmDisplayFrequency = mode->dotclock * 1000 / (mode->htotal * mode->vtotal); + devmode->dmPelsWidth = dd_modes[n].dwWidth; + devmode->dmPelsHeight = dd_modes[n].dwHeight; + devmode->dmBitsPerPel = dd_modes[n].dwBPP; + devmode->dmDisplayFrequency = dd_modes[n].wRefreshRate; devmode->dmFields = (DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL|DM_DISPLAYFREQUENCY); - TRACE("mode %ld -- %ldx%ldx%ldbpp\n", n, - devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel); + TRACE("mode %ld -- %ldx%ldx%ldbpp %ld Hz\n", n, + devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel, + devmode->dmDisplayFrequency); return TRUE; } -#endif TRACE("mode %ld -- not present\n", n); return FALSE; } -/* implementation of ChangeDisplaySettings for desktop */ +/* implementation of ChangeDisplaySettings for XF86VM */ LONG X11DRV_XF86VM_ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode, HWND hwnd, DWORD flags, LPVOID lpvoid ) { @@ -483,31 +519,35 @@ #endif #ifdef HAVE_LIBXXF86VM - for (i = 0; i < xf86vm_mode_count; i++) + for (i = 0; i < dd_mode_count; i++) { - XF86VidModeModeInfo *mode = modes[i]; if (devmode->dmFields & DM_BITSPERPEL) { - if (devmode->dmBitsPerPel != dwBpp) + if (devmode->dmBitsPerPel != dd_modes[i].dwBPP) continue; } if (devmode->dmFields & DM_PELSWIDTH) { - if (devmode->dmPelsWidth != mode->hdisplay) + if (devmode->dmPelsWidth != dd_modes[i].dwWidth) continue; } if (devmode->dmFields & DM_PELSHEIGHT) { - if (devmode->dmPelsHeight != mode->vdisplay) + if (devmode->dmPelsHeight != dd_modes[i].dwHeight) + continue; + } + if (devmode->dmFields & DM_DISPLAYFREQUENCY) + { + if (devmode->dmDisplayFrequency != dd_modes[i].wRefreshRate) continue; } /* we have a valid mode */ - TRACE("Matches mode %ld\n", i); + TRACE("Requested display settings match mode %ld\n", i); X11DRV_XF86VM_SetCurrentMode(i); -#if 0 /* FIXME */ - SYSMETRICS_Set( SM_CXSCREEN, devmode->dmPelsWidth ); - SYSMETRICS_Set( SM_CYSCREEN, devmode->dmPelsHeight ); -#endif + if (dwBpp != dd_modes[i].dwBPP) + { + FIXME("Cannot change screen BPP from %ld to %ld\n", dwBpp, dd_modes[i].dwBPP); + } return DISP_CHANGE_SUCCESSFUL; } #endif @@ -571,7 +611,7 @@ */ BOOL X11DRV_EnumDisplaySettingsExW( LPCWSTR name, DWORD n, LPDEVMODEW devmode, DWORD flags) { - if (xf86vm_modes) + if (dd_modes) { /* XVidMode */ return X11DRV_XF86VM_EnumDisplaySettingsExW(name, n, devmode, flags); @@ -633,7 +673,7 @@ { TRACE("Return to original display mode\n"); } - if (xf86vm_modes) + if (dd_modes) { /* XVidMode */ return X11DRV_XF86VM_ChangeDisplaySettingsExW( devname, devmode, Index: dlls/d3d8/directx.c =================================================================== RCS file: /home/wine/wine/dlls/d3d8/directx.c,v retrieving revision 1.53 diff -u -r1.53 directx.c --- dlls/d3d8/directx.c 25 Sep 2003 20:22:21 -0000 1.53 +++ dlls/d3d8/directx.c 29 Sep 2003 19:01:10 -0000 @@ -160,9 +160,9 @@ int i = 0; while (EnumDisplaySettingsExW(NULL, i, &DevModeW, 0)) { - TRACE("(%p}->(Adapter: %d) => %d\n", This, Adapter, i); i++; } + TRACE("(%p}->(Adapter: %d) => %d\n", This, Adapter, i); return i; } else { FIXME("Adapter not primary display\n"); @@ -190,8 +190,12 @@ { pMode->Width = DevModeW.dmPelsWidth; pMode->Height = DevModeW.dmPelsHeight; + bpp = DevModeW.dmBitsPerPel; pMode->RefreshRate = D3DADAPTER_DEFAULT; - bpp = DevModeW.dmBitsPerPel; + if (DevModeW.dmFields&DM_DISPLAYFREQUENCY) + { + pMode->RefreshRate = DevModeW.dmDisplayFrequency; + } } else { @@ -229,16 +233,18 @@ } if (Adapter == 0) { /* Display */ - HDC hdc; int bpp = 0; + DEVMODEW DevModeW; - pMode->Width = GetSystemMetrics(SM_CXSCREEN); - pMode->Height = GetSystemMetrics(SM_CYSCREEN); - pMode->RefreshRate = 85; /*FIXME: How to identify? */ - - hdc = CreateDCA("DISPLAY", NULL, NULL, NULL); - bpp = GetDeviceCaps(hdc, BITSPIXEL); - DeleteDC(hdc); + EnumDisplaySettingsExW(NULL, (DWORD)-1, &DevModeW, 0); + pMode->Width = DevModeW.dmPelsWidth; + pMode->Height = DevModeW.dmPelsHeight; + bpp = DevModeW.dmBitsPerPel; + pMode->RefreshRate = D3DADAPTER_DEFAULT; + if (DevModeW.dmFields&DM_DISPLAYFREQUENCY) + { + pMode->RefreshRate = DevModeW.dmDisplayFrequency; + } switch (bpp) { case 8: pMode->Format = D3DFMT_R3G3B2; break; Index: dlls/ddraw/ddraw/user.c =================================================================== RCS file: /home/wine/wine/dlls/ddraw/ddraw/user.c,v retrieving revision 1.18 diff -u -r1.18 user.c --- dlls/ddraw/ddraw/user.c 16 Sep 2003 20:25:02 -0000 1.18 +++ dlls/ddraw/ddraw/user.c 29 Sep 2003 19:01:11 -0000 @@ -93,28 +93,6 @@ return TRUE; } -/* If you change this function, you probably want to change the enumeration - * code in EnumDisplayModes. */ -static BOOL -IsValidDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, - DWORD dwRefreshRate, DWORD dwFlags) -{ - switch (dwBPP) - { - case 8: - case 15: - case 16: - case 24: - case 32: - break; - - default: - return FALSE; - } - - return TRUE; -} - static const DDPIXELFORMAT* pixelformat_for_depth(DWORD depth) { switch (depth) @@ -310,13 +288,11 @@ LPDDSURFACEDESC2 pDDSD, LPVOID context, LPDDENUMMODESCALLBACK2 callback) { - static const int num_pixelformats - = sizeof(pixelformats)/sizeof(pixelformats[0]); - DDSURFACEDESC2 callback_sd; DEVMODEW DevModeW; + const DDPIXELFORMAT* pixelformat; - int i, j; + int i; TRACE("(%p)->(0x%08lx,%p,%p,%p)\n",iface,dwFlags,pDDSD,context,callback); @@ -336,33 +312,31 @@ { callback_sd.dwHeight = DevModeW.dmPelsHeight; callback_sd.dwWidth = DevModeW.dmPelsWidth; + if (DevModeW.dmFields&DM_DISPLAYFREQUENCY) + { + callback_sd.u2.dwRefreshRate = DevModeW.dmDisplayFrequency; + } TRACE("- mode: %ldx%ld\n", callback_sd.dwWidth, callback_sd.dwHeight); - for (j = 0; j < num_pixelformats; j++) - { - callback_sd.u1.lPitch - = DDRAW_width_bpp_to_pitch(DevModeW.dmPelsWidth, - pixelformats[j].u1.dwRGBBitCount); - - callback_sd.u4.ddpfPixelFormat = pixelformats[j]; - - callback_sd.ddsCaps.dwCaps = 0; - if (pixelformats[j].dwFlags & DDPF_PALETTEINDEXED8) /* ick */ - callback_sd.ddsCaps.dwCaps |= DDSCAPS_PALETTE; - - assert(IsValidDisplayMode(callback_sd.dwWidth, - callback_sd.dwHeight, - callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount, - 0, 0)); - - TRACE(" - %2ld bpp, R=%08lx G=%08lx B=%08lx\n", - callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount, - callback_sd.u4.ddpfPixelFormat.u2.dwRBitMask, - callback_sd.u4.ddpfPixelFormat.u3.dwGBitMask, - callback_sd.u4.ddpfPixelFormat.u4.dwBBitMask); - if (callback(&callback_sd, context) == DDENUMRET_CANCEL) - return DD_OK; - } + + pixelformat = pixelformat_for_depth(DevModeW.dmBitsPerPel); + callback_sd.u1.lPitch + = DDRAW_width_bpp_to_pitch(DevModeW.dmPelsWidth, + pixelformat->u1.dwRGBBitCount); + + callback_sd.u4.ddpfPixelFormat = *pixelformat; + + callback_sd.ddsCaps.dwCaps = 0; + if (pixelformat->dwFlags & DDPF_PALETTEINDEXED8) /* ick */ + callback_sd.ddsCaps.dwCaps |= DDSCAPS_PALETTE; + + TRACE(" - %2ld bpp, R=%08lx G=%08lx B=%08lx\n", + callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount, + callback_sd.u4.ddpfPixelFormat.u2.dwRBitMask, + callback_sd.u4.ddpfPixelFormat.u3.dwGBitMask, + callback_sd.u4.ddpfPixelFormat.u4.dwBBitMask); + if (callback(&callback_sd, context) == DDENUMRET_CANCEL) + return DD_OK; i++; } @@ -528,8 +502,7 @@ LONG pitch; TRACE("(%p)->(%ldx%ldx%ld,%ld Hz,%08lx)\n",This,dwWidth,dwHeight,dwBPP,dwRefreshRate,dwFlags); - devmode.dmFields = /* DM_BITSPERPEL | */ DM_PELSWIDTH | DM_PELSHEIGHT; - FIXME("Ignoring requested BPP (%ld)\n", dwBPP); + devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; devmode.dmBitsPerPel = dwBPP; devmode.dmPelsWidth = dwWidth; devmode.dmPelsHeight = dwHeight;