- 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.
This commit is contained in:
Alex Pasadyn 2003-09-30 00:31:42 +00:00 committed by Alexandre Julliard
parent 86794d25ab
commit bd554e63fc
3 changed files with 189 additions and 133 deletions

View File

@ -93,28 +93,6 @@ BOOL DDRAW_User_Init(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
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 @@ User_DirectDraw_EnumDisplayModes(LPDIRECTDRAW7 iface, DWORD dwFlags,
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 @@ User_DirectDraw_EnumDisplayModes(LPDIRECTDRAW7 iface, DWORD dwFlags,
{
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);
pixelformat = pixelformat_for_depth(DevModeW.dmBitsPerPel);
callback_sd.u1.lPitch
= DDRAW_width_bpp_to_pitch(DevModeW.dmPelsWidth,
pixelformat->u1.dwRGBBitCount);
callback_sd.u4.ddpfPixelFormat = pixelformats[j];
callback_sd.u4.ddpfPixelFormat = *pixelformat;
callback_sd.ddsCaps.dwCaps = 0;
if (pixelformats[j].dwFlags & DDPF_PALETTEINDEXED8) /* ick */
callback_sd.ddsCaps.dwCaps |= DDSCAPS_PALETTE;
callback_sd.ddsCaps.dwCaps = 0;
if (pixelformat->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;
}
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 @@ User_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth,
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;

View File

@ -120,43 +120,64 @@ static int nmodes;
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 @@ int X11DRV_resize_desktop( unsigned int width, unsigned int height )
#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 @@ Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry )
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)
{
int i;
DWORD dwBpp = screen_depth;
if (dwBpp == 24) dwBpp = 32;
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 @@ BOOL X11DRV_desktop_EnumDisplaySettingsExW( LPCWSTR name, DWORD n, LPDEVMODEW de
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 @@ LONG X11DRV_desktop_ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmod
{
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 @@ LONG X11DRV_desktop_ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmod
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 @@ LONG X11DRV_desktop_ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmod
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 @@ int X11DRV_desktop_CreateDriver(LPDDHALINFO info)
{
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);

View File

@ -52,12 +52,13 @@ static int xf86vm_gammaramp_size;
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 @@ static void convert_modeinfo( const XF86VidModeModeInfo *mode, LPDDHALMODEINFO i
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 @@ static void convert_modeinfo( const XF86VidModeModeInfo *mode, LPDDHALMODEINFO i
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 @@ static void convert_modeline(int dotclock, const XF86VidModeModeLine *mode, LPDD
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,11 +102,16 @@ static int XVidModeErrorHandler(Display *dpy, XErrorEvent *event, void *arg)
}
static Bool in_desktop_mode;
static const unsigned int depths[] = {8, 16, 32};
void X11DRV_XF86VM_Init(void)
{
int nmodes, i;
Bool ok;
int nmodes, i, j;
int max_modes;
DWORD dwBpp = screen_depth;
if (dwBpp == 24) dwBpp = 32;
in_desktop_mode = (root_window != DefaultRootWindow(gdi_display));
if (xf86vm_major) return; /* already initialized? */
@ -138,7 +140,7 @@ void X11DRV_XF86VM_Init(void)
#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 +150,29 @@ void X11DRV_XF86VM_Init(void)
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 +182,7 @@ void X11DRV_XF86VM_Init(void)
void X11DRV_XF86VM_Cleanup(void)
{
if (modes) TSXFree(modes);
if (real_xf86vm_modes) TSXFree(real_xf86vm_modes);
}
int X11DRV_XF86VM_GetCurrentMode(void)
@ -171,16 +190,18 @@ int X11DRV_XF86VM_GetCurrentMode(void)
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 +211,22 @@ int X11DRV_XF86VM_GetCurrentMode(void)
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 +238,7 @@ void X11DRV_XF86VM_SetCurrentMode(int mode)
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 +249,7 @@ void X11DRV_XF86VM_SetExclusiveMode(int lock)
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 +258,11 @@ static DWORD PASCAL X11DRV_XF86VM_SetMode(LPDDHAL_SETMODEDATA data)
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 +462,38 @@ BOOL X11DRV_XF86VM_EnumDisplaySettingsExW( LPCWSTR name, DWORD n, LPDEVMODEW dev
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 +520,35 @@ LONG X11DRV_XF86VM_ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode
#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 +612,7 @@ LONG X11DRV_nores_ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode,
*/
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 +674,7 @@ LONG X11DRV_ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode,
{
TRACE("Return to original display mode\n");
}
if (xf86vm_modes)
if (dd_modes)
{
/* XVidMode */
return X11DRV_XF86VM_ChangeDisplaySettingsExW( devname, devmode,