winex11: Use our own structure for mode information.

This commit is contained in:
Henri Verbeet 2012-07-03 12:59:43 +02:00 committed by Alexandre Julliard
parent 3509c89194
commit 3ea8de2637
6 changed files with 73 additions and 80 deletions

View File

@ -26,13 +26,12 @@
/* avoid conflict with field names in included win32 headers */ /* avoid conflict with field names in included win32 headers */
#undef Status #undef Status
#include "ddrawi.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(x11drv); WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
/* data for resolution changing */ /* data for resolution changing */
static LPDDHALMODEINFO dd_modes; static struct x11drv_mode_info *dd_modes;
static unsigned int dd_mode_count; static unsigned int dd_mode_count;
static unsigned int max_width; static unsigned int max_width;
@ -76,9 +75,9 @@ static int X11DRV_desktop_GetCurrentMode(void)
DWORD dwBpp = screen_bpp; DWORD dwBpp = screen_bpp;
for (i=0; i<dd_mode_count; i++) for (i=0; i<dd_mode_count; i++)
{ {
if ( (screen_width == dd_modes[i].dwWidth) && if ( (screen_width == dd_modes[i].width) &&
(screen_height == dd_modes[i].dwHeight) && (screen_height == dd_modes[i].height) &&
(dwBpp == dd_modes[i].dwBPP)) (dwBpp == dd_modes[i].bpp))
return i; return i;
} }
ERR("In unknown mode, returning default\n"); ERR("In unknown mode, returning default\n");
@ -88,17 +87,17 @@ static int X11DRV_desktop_GetCurrentMode(void)
static LONG X11DRV_desktop_SetCurrentMode(int mode) static LONG X11DRV_desktop_SetCurrentMode(int mode)
{ {
DWORD dwBpp = screen_bpp; DWORD dwBpp = screen_bpp;
if (dwBpp != dd_modes[mode].dwBPP) if (dwBpp != dd_modes[mode].bpp)
{ {
FIXME("Cannot change screen BPP from %d to %d\n", dwBpp, dd_modes[mode].dwBPP); FIXME("Cannot change screen BPP from %d to %d\n", dwBpp, dd_modes[mode].bpp);
/* Ignore the depth mismatch /* Ignore the depth mismatch
* *
* Some (older) applications require a specific bit depth, this will allow them * Some (older) applications require a specific bit depth, this will allow them
* to run. X11drv performs a color depth conversion if needed. * to run. X11drv performs a color depth conversion if needed.
*/ */
} }
TRACE("Resizing Wine desktop window to %dx%d\n", dd_modes[mode].dwWidth, dd_modes[mode].dwHeight); TRACE("Resizing Wine desktop window to %dx%d\n", dd_modes[mode].width, dd_modes[mode].height);
X11DRV_resize_desktop(dd_modes[mode].dwWidth, dd_modes[mode].dwHeight); X11DRV_resize_desktop(dd_modes[mode].width, dd_modes[mode].height);
return DISP_CHANGE_SUCCESSFUL; return DISP_CHANGE_SUCCESSFUL;
} }

View File

@ -40,7 +40,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(x11settings);
* This is done because the array of DDHALMODEINFO structures must be * This is done because the array of DDHALMODEINFO structures must be
* created for use by DirectDraw anyway. * created for use by DirectDraw anyway.
*/ */
static LPDDHALMODEINFO dd_modes = NULL; static struct x11drv_mode_info *dd_modes = NULL;
static unsigned int dd_mode_count = 0; static unsigned int dd_mode_count = 0;
static unsigned int dd_max_modes = 0; static unsigned int dd_max_modes = 0;
/* All Windows drivers seen so far either support 32 bit depths, or 24 bit depths, but never both. So if we have /* All Windows drivers seen so far either support 32 bit depths, or 24 bit depths, but never both. So if we have
@ -58,11 +58,11 @@ static const char *handler_name;
* Set the handlers for resolution changing functions * Set the handlers for resolution changing functions
* and initialize the master list of modes * and initialize the master list of modes
*/ */
LPDDHALMODEINFO X11DRV_Settings_SetHandlers(const char *name, struct x11drv_mode_info *X11DRV_Settings_SetHandlers(const char *name,
int (*pNewGCM)(void), int (*pNewGCM)(void),
LONG (*pNewSCM)(int), LONG (*pNewSCM)(int),
unsigned int nmodes, unsigned int nmodes,
int reserve_depths) int reserve_depths)
{ {
handler_name = name; handler_name = name;
pGetCurrentMode = pNewGCM; pGetCurrentMode = pNewGCM;
@ -79,7 +79,7 @@ LPDDHALMODEINFO X11DRV_Settings_SetHandlers(const char *name,
TRACE("Destroying old display modes array\n"); TRACE("Destroying old display modes array\n");
HeapFree(GetProcessHeap(), 0, dd_modes); HeapFree(GetProcessHeap(), 0, dd_modes);
} }
dd_modes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDHALMODEINFO) * dd_max_modes); dd_modes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dd_modes) * dd_max_modes);
dd_mode_count = 0; dd_mode_count = 0;
TRACE("Initialized new display modes array\n"); TRACE("Initialized new display modes array\n");
return dd_modes; return dd_modes;
@ -88,7 +88,7 @@ LPDDHALMODEINFO X11DRV_Settings_SetHandlers(const char *name,
/* Add one mode to the master list */ /* Add one mode to the master list */
void X11DRV_Settings_AddOneMode(unsigned int width, unsigned int height, unsigned int bpp, unsigned int freq) void X11DRV_Settings_AddOneMode(unsigned int width, unsigned int height, unsigned int bpp, unsigned int freq)
{ {
LPDDHALMODEINFO info = &(dd_modes[dd_mode_count]); struct x11drv_mode_info *info = &dd_modes[dd_mode_count];
DWORD dwBpp = screen_bpp; DWORD dwBpp = screen_bpp;
if (dd_mode_count >= dd_max_modes) if (dd_mode_count >= dd_max_modes)
{ {
@ -96,16 +96,10 @@ void X11DRV_Settings_AddOneMode(unsigned int width, unsigned int height, unsigne
return; return;
} }
if (bpp == 0) bpp = dwBpp; if (bpp == 0) bpp = dwBpp;
info->dwWidth = width; info->width = width;
info->dwHeight = height; info->height = height;
info->wRefreshRate = freq; info->refresh_rate = freq;
info->lPitch = 0; info->bpp = bpp;
info->dwBPP = bpp;
info->wFlags = 0;
info->dwRBitMask = 0;
info->dwGBitMask = 0;
info->dwBBitMask = 0;
info->dwAlphaBitMask = 0;
TRACE("initialized mode %d: %dx%dx%d @%d Hz (%s)\n", TRACE("initialized mode %d: %dx%dx%d @%d Hz (%s)\n",
dd_mode_count, width, height, bpp, freq, handler_name); dd_mode_count, width, height, bpp, freq, handler_name);
dd_mode_count++; dd_mode_count++;
@ -125,8 +119,8 @@ void X11DRV_Settings_AddDepthModes(void)
{ {
for (i=0; i < existing_modes; i++) for (i=0; i < existing_modes; i++)
{ {
X11DRV_Settings_AddOneMode(dd_modes[i].dwWidth, dd_modes[i].dwHeight, X11DRV_Settings_AddOneMode(dd_modes[i].width, dd_modes[i].height,
depths[j], dd_modes[i].wRefreshRate); depths[j], dd_modes[i].refresh_rate);
} }
} }
} }
@ -295,10 +289,10 @@ BOOL CDECL X11DRV_EnumDisplaySettingsEx( LPCWSTR name, DWORD n, LPDEVMODEW devmo
} }
if (n < dd_mode_count) if (n < dd_mode_count)
{ {
devmode->dmPelsWidth = dd_modes[n].dwWidth; devmode->dmPelsWidth = dd_modes[n].width;
devmode->dmPelsHeight = dd_modes[n].dwHeight; devmode->dmPelsHeight = dd_modes[n].height;
devmode->dmBitsPerPel = dd_modes[n].dwBPP; devmode->dmBitsPerPel = dd_modes[n].bpp;
devmode->dmDisplayFrequency = dd_modes[n].wRefreshRate; devmode->dmDisplayFrequency = dd_modes[n].refresh_rate;
devmode->dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | devmode->dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL |
DM_DISPLAYFLAGS; DM_DISPLAYFLAGS;
if (devmode->dmDisplayFrequency) if (devmode->dmDisplayFrequency)
@ -401,23 +395,23 @@ LONG CDECL X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode,
{ {
if (devmode->dmFields & DM_BITSPERPEL) if (devmode->dmFields & DM_BITSPERPEL)
{ {
if (dwBpp != dd_modes[i].dwBPP) if (dwBpp != dd_modes[i].bpp)
continue; continue;
} }
if (devmode->dmFields & DM_PELSWIDTH) if (devmode->dmFields & DM_PELSWIDTH)
{ {
if (devmode->dmPelsWidth != dd_modes[i].dwWidth) if (devmode->dmPelsWidth != dd_modes[i].width)
continue; continue;
} }
if (devmode->dmFields & DM_PELSHEIGHT) if (devmode->dmFields & DM_PELSHEIGHT)
{ {
if (devmode->dmPelsHeight != dd_modes[i].dwHeight) if (devmode->dmPelsHeight != dd_modes[i].height)
continue; continue;
} }
if ((devmode->dmFields & DM_DISPLAYFREQUENCY) && (dd_modes[i].wRefreshRate != 0) && if ((devmode->dmFields & DM_DISPLAYFREQUENCY) && (dd_modes[i].refresh_rate != 0) &&
devmode->dmDisplayFrequency != 0) devmode->dmDisplayFrequency != 0)
{ {
if (devmode->dmDisplayFrequency != dd_modes[i].wRefreshRate) if (devmode->dmDisplayFrequency != dd_modes[i].refresh_rate)
continue; continue;
} }
/* we have a valid mode */ /* we have a valid mode */

View File

@ -56,7 +56,6 @@ typedef int Status;
#include "winbase.h" #include "winbase.h"
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "ddrawi.h"
#include "wine/gdi_driver.h" #include "wine/gdi_driver.h"
#include "wine/list.h" #include "wine/list.h"
@ -643,17 +642,25 @@ extern int X11DRV_check_error(void) DECLSPEC_HIDDEN;
extern void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect ) DECLSPEC_HIDDEN; extern void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect ) DECLSPEC_HIDDEN;
extern void xinerama_init( unsigned int width, unsigned int height ) DECLSPEC_HIDDEN; extern void xinerama_init( unsigned int width, unsigned int height ) DECLSPEC_HIDDEN;
struct x11drv_mode_info
{
unsigned int width;
unsigned int height;
unsigned int bpp;
unsigned int refresh_rate;
};
extern void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height ) DECLSPEC_HIDDEN; extern void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height ) DECLSPEC_HIDDEN;
extern void X11DRV_resize_desktop(unsigned int width, unsigned int height) DECLSPEC_HIDDEN; extern void X11DRV_resize_desktop(unsigned int width, unsigned int height) DECLSPEC_HIDDEN;
extern void X11DRV_Settings_AddDepthModes(void) DECLSPEC_HIDDEN; extern void X11DRV_Settings_AddDepthModes(void) DECLSPEC_HIDDEN;
extern void X11DRV_Settings_AddOneMode(unsigned int width, unsigned int height, unsigned int bpp, unsigned int freq) DECLSPEC_HIDDEN; extern void X11DRV_Settings_AddOneMode(unsigned int width, unsigned int height, unsigned int bpp, unsigned int freq) DECLSPEC_HIDDEN;
unsigned int X11DRV_Settings_GetModeCount(void) DECLSPEC_HIDDEN; unsigned int X11DRV_Settings_GetModeCount(void) DECLSPEC_HIDDEN;
void X11DRV_Settings_Init(void) DECLSPEC_HIDDEN; void X11DRV_Settings_Init(void) DECLSPEC_HIDDEN;
LPDDHALMODEINFO X11DRV_Settings_SetHandlers(const char *name, struct x11drv_mode_info *X11DRV_Settings_SetHandlers(const char *name,
int (*pNewGCM)(void), int (*pNewGCM)(void),
LONG (*pNewSCM)(int), LONG (*pNewSCM)(int),
unsigned int nmodes, unsigned int nmodes,
int reserve_depths) DECLSPEC_HIDDEN; int reserve_depths) DECLSPEC_HIDDEN;
/* XIM support */ /* XIM support */
extern BOOL X11DRV_InitXIM( const char *input_style ) DECLSPEC_HIDDEN; extern BOOL X11DRV_InitXIM( const char *input_style ) DECLSPEC_HIDDEN;

View File

@ -34,7 +34,6 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "wingdi.h" #include "wingdi.h"
#include "ddrawi.h"
#include "wine/library.h" #include "wine/library.h"
#include "wine/debug.h" #include "wine/debug.h"
@ -59,7 +58,7 @@ extern int usexrandr;
static int xrandr_event, xrandr_error, xrandr_major, xrandr_minor; static int xrandr_event, xrandr_error, xrandr_major, xrandr_minor;
static LPDDHALMODEINFO dd_modes; static struct x11drv_mode_info *dd_modes;
static unsigned int dd_mode_count; static unsigned int dd_mode_count;
static XRRScreenSize *real_xrandr_sizes; static XRRScreenSize *real_xrandr_sizes;
static short **real_xrandr_rates; static short **real_xrandr_rates;
@ -150,9 +149,9 @@ static int X11DRV_XRandR_GetCurrentMode(void)
wine_tsx11_unlock(); wine_tsx11_unlock();
for (i = 0; i < real_xrandr_modes_count; i++) for (i = 0; i < real_xrandr_modes_count; i++)
{ {
if ( (dd_modes[i].dwWidth == real_xrandr_sizes[size].width ) && if ( (dd_modes[i].width == real_xrandr_sizes[size].width ) &&
(dd_modes[i].dwHeight == real_xrandr_sizes[size].height) && (dd_modes[i].height == real_xrandr_sizes[size].height) &&
(dd_modes[i].wRefreshRate == rate ) ) (dd_modes[i].refresh_rate == rate ) )
{ {
res = i; res = i;
break; break;
@ -183,26 +182,26 @@ static LONG X11DRV_XRandR_SetCurrentMode(int mode)
size = pXRRConfigCurrentConfiguration (sc, &rot); size = pXRRConfigCurrentConfiguration (sc, &rot);
mode = mode%real_xrandr_modes_count; mode = mode%real_xrandr_modes_count;
TRACE("Changing Resolution to %dx%d @%d Hz\n", TRACE("Changing Resolution to %dx%d @%d Hz\n",
dd_modes[mode].dwWidth, dd_modes[mode].width,
dd_modes[mode].dwHeight, dd_modes[mode].height,
dd_modes[mode].wRefreshRate); dd_modes[mode].refresh_rate);
for (i = 0; i < real_xrandr_sizes_count; i++) for (i = 0; i < real_xrandr_sizes_count; i++)
{ {
if ( (dd_modes[mode].dwWidth == real_xrandr_sizes[i].width ) && if ( (dd_modes[mode].width == real_xrandr_sizes[i].width ) &&
(dd_modes[mode].dwHeight == real_xrandr_sizes[i].height) ) (dd_modes[mode].height == real_xrandr_sizes[i].height) )
{ {
size = i; size = i;
if (real_xrandr_rates_count[i]) if (real_xrandr_rates_count[i])
{ {
for (j=0; j < real_xrandr_rates_count[i]; j++) for (j=0; j < real_xrandr_rates_count[i]; j++)
{ {
if (dd_modes[mode].wRefreshRate == real_xrandr_rates[i][j]) if (dd_modes[mode].refresh_rate == real_xrandr_rates[i][j])
{ {
rate = real_xrandr_rates[i][j]; rate = real_xrandr_rates[i][j];
TRACE("Resizing X display to %dx%d @%d Hz\n", TRACE("Resizing X display to %dx%d @%d Hz\n",
dd_modes[mode].dwWidth, dd_modes[mode].dwHeight, rate); dd_modes[mode].width, dd_modes[mode].height, rate);
stat = pXRRSetScreenConfigAndRate (gdi_display, sc, root, stat = pXRRSetScreenConfigAndRate (gdi_display, sc, root,
size, rot, rate, CurrentTime); size, rot, rate, CurrentTime);
break; break;
@ -211,8 +210,8 @@ static LONG X11DRV_XRandR_SetCurrentMode(int mode)
} }
else else
{ {
TRACE("Resizing X display to %dx%d <default Hz>\n", TRACE("Resizing X display to %dx%d <default Hz>\n",
dd_modes[mode].dwWidth, dd_modes[mode].dwHeight); dd_modes[mode].width, dd_modes[mode].height);
stat = pXRRSetScreenConfig (gdi_display, sc, root, size, rot, CurrentTime); stat = pXRRSetScreenConfig (gdi_display, sc, root, size, rot, CurrentTime);
} }
break; break;
@ -222,7 +221,7 @@ static LONG X11DRV_XRandR_SetCurrentMode(int mode)
wine_tsx11_unlock(); wine_tsx11_unlock();
if (stat == RRSetConfigSuccess) if (stat == RRSetConfigSuccess)
{ {
X11DRV_resize_desktop( dd_modes[mode].dwWidth, dd_modes[mode].dwHeight ); X11DRV_resize_desktop( dd_modes[mode].width, dd_modes[mode].height );
return DISP_CHANGE_SUCCESSFUL; return DISP_CHANGE_SUCCESSFUL;
} }

View File

@ -55,7 +55,7 @@ static int xf86vm_gammaramp_size;
static BOOL xf86vm_use_gammaramp; static BOOL xf86vm_use_gammaramp;
#endif /* X_XF86VidModeSetGammaRamp */ #endif /* X_XF86VidModeSetGammaRamp */
static LPDDHALMODEINFO dd_modes; static struct x11drv_mode_info *dd_modes;
static unsigned int dd_mode_count; static unsigned int dd_mode_count;
static XF86VidModeModeInfo** real_xf86vm_modes; static XF86VidModeModeInfo** real_xf86vm_modes;
static unsigned int real_xf86vm_mode_count; static unsigned int real_xf86vm_mode_count;
@ -90,23 +90,18 @@ static void convert_modeinfo( const XF86VidModeModeInfo *mode)
X11DRV_Settings_AddOneMode(mode->hdisplay, mode->vdisplay, 0, rate); X11DRV_Settings_AddOneMode(mode->hdisplay, mode->vdisplay, 0, rate);
} }
static void convert_modeline(int dotclock, const XF86VidModeModeLine *mode, LPDDHALMODEINFO info, unsigned int bpp) static void convert_modeline(int dotclock, const XF86VidModeModeLine *mode,
struct x11drv_mode_info *info, unsigned int bpp)
{ {
info->dwWidth = mode->hdisplay; info->width = mode->hdisplay;
info->dwHeight = mode->vdisplay; info->height = mode->vdisplay;
if (mode->htotal!=0 && mode->vtotal!=0) if (mode->htotal!=0 && mode->vtotal!=0)
info->wRefreshRate = dotclock * 1000 / (mode->htotal * mode->vtotal); info->refresh_rate = dotclock * 1000 / (mode->htotal * mode->vtotal);
else else
info->wRefreshRate = 0; info->refresh_rate = 0;
TRACE(" width=%d, height=%d, refresh=%d\n", TRACE(" width=%d, height=%d, refresh=%d\n",
info->dwWidth, info->dwHeight, info->wRefreshRate); info->width, info->height, info->refresh_rate);
info->lPitch = 0; info->bpp = bpp;
info->dwBPP = bpp;
info->wFlags = 0;
info->dwRBitMask = 0;
info->dwGBitMask = 0;
info->dwBBitMask = 0;
info->dwAlphaBitMask = 0;
} }
static int XVidModeErrorHandler(Display *dpy, XErrorEvent *event, void *arg) static int XVidModeErrorHandler(Display *dpy, XErrorEvent *event, void *arg)
@ -119,7 +114,7 @@ static int X11DRV_XF86VM_GetCurrentMode(void)
XF86VidModeModeLine line; XF86VidModeModeLine line;
int dotclock; int dotclock;
unsigned int i; unsigned int i;
DDHALMODEINFO cmode; struct x11drv_mode_info cmode;
DWORD dwBpp = screen_bpp; DWORD dwBpp = screen_bpp;
TRACE("Querying XVidMode current mode\n"); TRACE("Querying XVidMode current mode\n");
@ -140,9 +135,9 @@ static LONG X11DRV_XF86VM_SetCurrentMode(int mode)
{ {
DWORD dwBpp = screen_bpp; DWORD dwBpp = screen_bpp;
/* only set modes from the original color depth */ /* only set modes from the original color depth */
if (dwBpp != dd_modes[mode].dwBPP) if (dwBpp != dd_modes[mode].bpp)
{ {
FIXME("Cannot change screen BPP from %d to %d\n", dwBpp, dd_modes[mode].dwBPP); FIXME("Cannot change screen BPP from %d to %d\n", dwBpp, dd_modes[mode].bpp);
} }
mode = mode % real_xf86vm_mode_count; mode = mode % real_xf86vm_mode_count;
@ -240,7 +235,7 @@ void X11DRV_XF86VM_Init(void)
X11DRV_XF86VM_SetCurrentMode, X11DRV_XF86VM_SetCurrentMode,
nmodes, 1); nmodes, 1);
/* convert modes to DDHALMODEINFO format */ /* convert modes to x11drv_mode_info format */
for (i=0; i<real_xf86vm_mode_count; i++) for (i=0; i<real_xf86vm_mode_count; i++)
{ {
convert_modeinfo(real_xf86vm_modes[i]); convert_modeinfo(real_xf86vm_modes[i]);

View File

@ -29,7 +29,6 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "wingdi.h" #include "wingdi.h"
#include "ddrawi.h"
void X11DRV_XF86VM_Init(void) DECLSPEC_HIDDEN; void X11DRV_XF86VM_Init(void) DECLSPEC_HIDDEN;
void X11DRV_XF86VM_Cleanup(void) DECLSPEC_HIDDEN; void X11DRV_XF86VM_Cleanup(void) DECLSPEC_HIDDEN;