From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/display.c | 39 ++++++------ dlls/winex11.drv/x11drv.h | 31 +++++++-- dlls/winex11.drv/xrandr.c | 121 +++++++++++++++--------------------- dlls/winex11.drv/xvidmode.c | 54 ++++++++-------- 4 files changed, 122 insertions(+), 123 deletions(-)
diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index f063dabcbb5..8634d99ed8e 100644 --- a/dlls/winex11.drv/display.c +++ b/dlls/winex11.drv/display.c @@ -62,10 +62,10 @@ static BOOL nores_get_id(const WCHAR *device_name, BOOL is_primary, x11drv_setti return TRUE; }
-static BOOL nores_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **new_modes, UINT *mode_count ) +static BOOL nores_get_modes( x11drv_settings_id id, DWORD flags, struct x11drv_mode **new_modes, UINT *mode_count ) { RECT primary = get_host_primary_monitor_rect(); - DEVMODEW *modes; + struct x11drv_mode *modes;
modes = calloc(1, sizeof(*modes)); if (!modes) @@ -74,16 +74,16 @@ static BOOL nores_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **new_ return FALSE; }
- modes[0].dmSize = sizeof(*modes); - modes[0].dmDriverExtra = 0; - modes[0].dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | - DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY; - modes[0].dmDisplayOrientation = DMDO_DEFAULT; - modes[0].dmBitsPerPel = screen_bpp; - modes[0].dmPelsWidth = primary.right; - modes[0].dmPelsHeight = primary.bottom; - modes[0].dmDisplayFlags = 0; - modes[0].dmDisplayFrequency = 60; + modes[0].mode.dmSize = sizeof(*modes); + modes[0].mode.dmDriverExtra = 0; + modes[0].mode.dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | + DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY; + modes[0].mode.dmDisplayOrientation = DMDO_DEFAULT; + modes[0].mode.dmBitsPerPel = screen_bpp; + modes[0].mode.dmPelsWidth = primary.right; + modes[0].mode.dmPelsHeight = primary.bottom; + modes[0].mode.dmDisplayFlags = 0; + modes[0].mode.dmDisplayFrequency = 60;
*new_modes = modes; *mode_count = 1; @@ -118,7 +118,7 @@ static BOOL nores_get_current_mode(x11drv_settings_id id, DEVMODEW *mode) return TRUE; }
-static LONG nores_set_current_mode(x11drv_settings_id id, const DEVMODEW *mode) +static LONG nores_set_current_mode( x11drv_settings_id id, const struct x11drv_mode *mode ) { WARN("NoRes settings handler, ignoring mode change request.\n"); return DISP_CHANGE_SUCCESSFUL; @@ -175,8 +175,9 @@ static BOOL is_same_devmode( const DEVMODEW *a, const DEVMODEW *b ) * Return NULL on failure. Caller should call free_full_mode() to free the returned mode. */ static DEVMODEW *get_full_mode(x11drv_settings_id id, DEVMODEW *dev_mode) { - DEVMODEW *modes, *full_mode, *found_mode = NULL; + DEVMODEW *full_mode, *found_mode = NULL; UINT mode_count, mode_idx; + struct x11drv_mode *modes;
if (is_detached_mode(dev_mode)) return dev_mode; @@ -185,7 +186,7 @@ static DEVMODEW *get_full_mode(x11drv_settings_id id, DEVMODEW *dev_mode)
for (mode_idx = 0; mode_idx < mode_count; ++mode_idx) { - found_mode = (DEVMODEW *)((BYTE *)modes + (sizeof(*modes) + modes[0].dmDriverExtra) * mode_idx); + found_mode = &modes[mode_idx].mode; if (is_same_devmode( found_mode, dev_mode )) break; }
@@ -242,7 +243,7 @@ static LONG apply_display_settings( DEVMODEW *displays, x11drv_settings_id *ids, full_mode->dmPelsHeight, full_mode->dmDisplayFrequency, full_mode->dmBitsPerPel, full_mode->dmDisplayOrientation);
- ret = settings_handler.set_current_mode(*id, full_mode); + ret = settings_handler.set_current_mode(*id, (struct x11drv_mode *)full_mode); free_full_mode(full_mode); if (ret != DISP_CHANGE_SUCCESSFUL) return ret; @@ -416,7 +417,7 @@ UINT X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage struct gdi_monitor *monitors; struct x11drv_gpu *gpus; INT gpu, adapter, monitor; - DEVMODEW *modes; + struct x11drv_mode *modes; UINT mode_count;
TRACE( "via %s\n", debugstr_a(host_handler.name) ); @@ -462,8 +463,8 @@ UINT X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage settings_handler.get_current_mode( settings_id, ¤t_mode ); if (settings_handler.get_modes( settings_id, EDS_ROTATEDMODE, &modes, &mode_count )) { - strip_driver_extra( modes, mode_count ); - device_manager->add_modes( ¤t_mode, mode_count, modes, param ); + strip_driver_extra( &modes->mode, mode_count ); + device_manager->add_modes( ¤t_mode, mode_count, &modes->mode, param ); free( modes ); } } diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index a92ffb6428e..c73c7ef5e41 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -38,6 +38,9 @@ #include <X11/extensions/XInput2.h> #endif
+#undef Status /* avoid conflict with wintrnl.h */ +typedef int Status; + #define BOOL X_BOOL #define BYTE X_BYTE #define INT8 X_INT8 @@ -46,6 +49,12 @@ #define INT64 X_INT64 #include <X11/Xmd.h> #include <X11/Xproto.h> +#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H +#include <X11/extensions/xf86vmode.h> +#endif +#ifdef HAVE_X11_EXTENSIONS_XRANDR_H +#include <X11/extensions/Xrandr.h> +#endif #undef BOOL #undef BYTE #undef INT8 @@ -54,9 +63,6 @@ #undef INT64 #undef LONG64
-#undef Status /* avoid conflict with wintrnl.h */ -typedef int Status; - /* avoid conflict with processthreadsapi.h */ #undef ControlMask
@@ -757,6 +763,21 @@ extern const unsigned int *depths; /* Use a distinct type for the settings id, to avoid mixups other types of ids */ typedef struct { ULONG_PTR id; } x11drv_settings_id;
+struct x11drv_mode +{ + DEVMODEW mode; + union + { +#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H + XF86VidModeModeInfo mode_info; +#endif +#ifdef HAVE_X11_EXTENSIONS_XRANDR_H + SizeID size_id; + RRMode rr_mode; +#endif + }; +}; + /* Required functions for changing and enumerating display settings */ struct x11drv_settings_handler { @@ -781,7 +802,7 @@ struct x11drv_settings_handler * dmDisplayFlags and dmDisplayFrequency * * Return FALSE on failure with parameters unchanged and error code set. Return TRUE on success */ - BOOL (*get_modes)(x11drv_settings_id id, DWORD flags, DEVMODEW **modes, UINT *mode_count); + BOOL (*get_modes)(x11drv_settings_id id, DWORD flags, struct x11drv_mode **modes, UINT *mode_count);
/* get_current_mode() will be called to get the current display mode of the device of id * @@ -796,7 +817,7 @@ struct x11drv_settings_handler * mode must be a valid mode from get_modes() with optional fields, such as dmPosition set. * * Return DISP_CHANGE_*, same as ChangeDisplaySettingsExW() return values */ - LONG (*set_current_mode)(x11drv_settings_id id, const DEVMODEW *mode); + LONG (*set_current_mode)(x11drv_settings_id id, const struct x11drv_mode *mode); };
#define NEXT_DEVMODEW(mode) ((DEVMODEW *)((char *)((mode) + 1) + (mode)->dmDriverExtra)) diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index 8b675ec355b..058bde94701 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -238,31 +238,30 @@ static BOOL xrandr10_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s return TRUE; }
-static void add_xrandr10_mode( DEVMODEW *mode, DWORD depth, DWORD width, DWORD height, +static void add_xrandr10_mode( struct x11drv_mode *mode, DWORD depth, DWORD width, DWORD height, DWORD frequency, SizeID size_id ) { - mode->dmSize = sizeof(*mode); - mode->dmDriverExtra = sizeof(SizeID); - mode->dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | + mode->mode.dmSize = sizeof(*mode); + mode->mode.dmDriverExtra = sizeof(*mode) - sizeof(mode->mode); + mode->mode.dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS; if (frequency) { - mode->dmFields |= DM_DISPLAYFREQUENCY; - mode->dmDisplayFrequency = frequency; + mode->mode.dmFields |= DM_DISPLAYFREQUENCY; + mode->mode.dmDisplayFrequency = frequency; } - mode->dmDisplayOrientation = DMDO_DEFAULT; - mode->dmBitsPerPel = depth; - mode->dmPelsWidth = width; - mode->dmPelsHeight = height; - mode->dmDisplayFlags = 0; - memcpy( mode + 1, &size_id, sizeof(size_id) ); + mode->mode.dmDisplayOrientation = DMDO_DEFAULT; + mode->mode.dmBitsPerPel = depth; + mode->mode.dmPelsWidth = width; + mode->mode.dmPelsHeight = height; + mode->mode.dmDisplayFlags = 0; + mode->size_id = size_id; }
-static BOOL xrandr10_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **new_modes, UINT *new_mode_count ) +static BOOL xrandr10_get_modes( x11drv_settings_id id, DWORD flags, struct x11drv_mode **new_modes, UINT *new_mode_count ) { - INT size_idx, depth_idx, rate_idx, mode_idx = 0; - INT size_count, rate_count, mode_count = 0; - DEVMODEW *modes, *mode; + INT size_idx, depth_idx, rate_idx, size_count, rate_count, mode_count = 0; + struct x11drv_mode *modes, *mode; XRRScreenSize *sizes; short *rates;
@@ -279,10 +278,7 @@ static BOOL xrandr10_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **n ++mode_count; }
- /* Allocate space for reported modes in three depths, and put an SizeID at the end of DEVMODEW as - * driver private data */ - modes = calloc( mode_count * DEPTH_COUNT, sizeof(*modes) + sizeof(SizeID) ); - if (!modes) + if (!(modes = calloc( mode_count * DEPTH_COUNT, sizeof(*modes) ))) { RtlSetLastWin32Error( ERROR_NOT_ENOUGH_MEMORY ); return FALSE; @@ -295,25 +291,21 @@ static BOOL xrandr10_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **n rates = pXRRRates( gdi_display, DefaultScreen( gdi_display ), size_idx, &rate_count ); if (!rate_count) { - add_xrandr10_mode( mode, depths[depth_idx], sizes[size_idx].width, + add_xrandr10_mode( mode++, depths[depth_idx], sizes[size_idx].width, sizes[size_idx].height, 0, size_idx ); - mode = NEXT_DEVMODEW( mode ); - mode_idx++; continue; }
for (rate_idx = 0; rate_idx < rate_count; ++rate_idx) { - add_xrandr10_mode( mode, depths[depth_idx], sizes[size_idx].width, + add_xrandr10_mode( mode++, depths[depth_idx], sizes[size_idx].width, sizes[size_idx].height, rates[rate_idx], size_idx ); - mode = NEXT_DEVMODEW( mode ); - mode_idx++; } } }
*new_modes = modes; - *new_mode_count = mode_idx; + *new_mode_count = mode - modes; return TRUE; }
@@ -359,14 +351,16 @@ static BOOL xrandr10_get_current_mode( x11drv_settings_id id, DEVMODEW *mode ) return TRUE; }
-static LONG xrandr10_set_current_mode( x11drv_settings_id id, const DEVMODEW *mode ) +static LONG xrandr10_set_current_mode( x11drv_settings_id id, const struct x11drv_mode *full_mode ) { + const DEVMODEW *mode = &full_mode->mode; XRRScreenConfiguration *screen_config; Rotation rotation; - SizeID size_id; Window root; Status stat;
+ assert( sizeof(*full_mode) == sizeof(full_mode->mode) + full_mode->mode.dmDriverExtra ); + if (id.id != 1) { FIXME("Non-primary adapters are unsupported.\n"); @@ -387,14 +381,11 @@ static LONG xrandr10_set_current_mode( x11drv_settings_id id, const DEVMODEW *mo screen_config = pXRRGetScreenInfo( gdi_display, root ); pXRRConfigCurrentConfiguration( screen_config, &rotation );
- assert( mode->dmDriverExtra == sizeof(SizeID) ); - memcpy( &size_id, (BYTE *)mode + sizeof(*mode), sizeof(size_id) ); - if (mode->dmFields & DM_DISPLAYFREQUENCY && mode->dmDisplayFrequency) - stat = pXRRSetScreenConfigAndRate( gdi_display, screen_config, root, size_id, rotation, + stat = pXRRSetScreenConfigAndRate( gdi_display, screen_config, root, full_mode->size_id, rotation, mode->dmDisplayFrequency, CurrentTime ); else - stat = pXRRSetScreenConfig( gdi_display, screen_config, root, size_id, rotation, CurrentTime ); + stat = pXRRSetScreenConfig( gdi_display, screen_config, root, full_mode->size_id, rotation, CurrentTime ); pXRRFreeScreenConfigInfo( screen_config );
if (stat != RRSetConfigSuccess) @@ -1330,46 +1321,46 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s return TRUE; }
-static void add_xrandr14_mode( DEVMODEW *mode, XRRModeInfo *info, DWORD depth, DWORD frequency, +static void add_xrandr14_mode( struct x11drv_mode *mode, XRRModeInfo *info, DWORD depth, DWORD frequency, DWORD orientation ) { - mode->dmSize = sizeof(*mode); - mode->dmDriverExtra = sizeof(RRMode); - mode->dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | + mode->mode.dmSize = sizeof(*mode); + mode->mode.dmDriverExtra = sizeof(*mode) - sizeof(mode->mode); + mode->mode.dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS; if (frequency) { - mode->dmFields |= DM_DISPLAYFREQUENCY; - mode->dmDisplayFrequency = frequency; + mode->mode.dmFields |= DM_DISPLAYFREQUENCY; + mode->mode.dmDisplayFrequency = frequency; } if (orientation == DMDO_DEFAULT || orientation == DMDO_180) { - mode->dmPelsWidth = info->width; - mode->dmPelsHeight = info->height; + mode->mode.dmPelsWidth = info->width; + mode->mode.dmPelsHeight = info->height; } else { - mode->dmPelsWidth = info->height; - mode->dmPelsHeight = info->width; + mode->mode.dmPelsWidth = info->height; + mode->mode.dmPelsHeight = info->width; } - mode->dmDisplayOrientation = orientation; - mode->dmBitsPerPel = depth; - mode->dmDisplayFlags = 0; - memcpy( mode + 1, &info->id, sizeof(info->id) ); + mode->mode.dmDisplayOrientation = orientation; + mode->mode.dmBitsPerPel = depth; + mode->mode.dmDisplayFlags = 0; + mode->rr_mode = info->id; }
-static BOOL xrandr14_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **new_modes, UINT *mode_count ) +static BOOL xrandr14_get_modes( x11drv_settings_id id, DWORD flags, struct x11drv_mode **new_modes, UINT *mode_count ) { DWORD frequency, orientation, orientation_count; XRRScreenResources *screen_resources; XRROutputInfo *output_info = NULL; RROutput output = (RROutput)id.id; + struct x11drv_mode *mode, *modes; XRRCrtcInfo *crtc_info = NULL; - UINT depth_idx, mode_idx = 0; XRRModeInfo *mode_info; - DEVMODEW *mode, *modes; Rotation rotations; BOOL ret = FALSE; + UINT depth_idx; RRCrtc crtc; INT i, j;
@@ -1423,12 +1414,7 @@ static BOOL xrandr14_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **n } orientation_count = get_orientation_count( rotations );
- /* Allocate space for display modes in different color depths and orientations. - * Store a RRMode at the end of each DEVMODEW as private driver data */ - modes = calloc( output_info->nmode * DEPTH_COUNT * orientation_count, - sizeof(*modes) + sizeof(RRMode) ); - if (!modes) - goto done; + if (!(modes = calloc( output_info->nmode * DEPTH_COUNT * orientation_count, sizeof(*modes) ))) goto done;
for (i = 0, mode = modes; i < output_info->nmode; ++i) { @@ -1444,12 +1430,8 @@ static BOOL xrandr14_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **n { for (orientation = DMDO_DEFAULT; orientation <= DMDO_270; ++orientation) { - if (!((1 << orientation) & rotations)) - continue; - - add_xrandr14_mode( mode, mode_info, depths[depth_idx], frequency, orientation ); - mode = NEXT_DEVMODEW( mode ); - ++mode_idx; + if (!((1 << orientation) & rotations)) continue; + add_xrandr14_mode( mode++, mode_info, depths[depth_idx], frequency, orientation ); } }
@@ -1459,7 +1441,7 @@ static BOOL xrandr14_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **n
ret = TRUE; *new_modes = modes; - *mode_count = mode_idx; + *mode_count = mode - modes; done: if (crtc_info) pXRRFreeCrtcInfo( crtc_info ); @@ -1576,8 +1558,9 @@ done: return ret; }
-static LONG xrandr14_set_current_mode( x11drv_settings_id id, const DEVMODEW *mode ) +static LONG xrandr14_set_current_mode( x11drv_settings_id id, const struct x11drv_mode *full_mode ) { + const DEVMODEW *mode = &full_mode->mode; unsigned int screen_width, screen_height; RROutput output = (RROutput)id.id, *outputs; XRRScreenResources *screen_resources; @@ -1588,7 +1571,8 @@ static LONG xrandr14_set_current_mode( x11drv_settings_id id, const DEVMODEW *mo INT output_count; RRCrtc crtc = 0; Status status; - RRMode rrmode; + + assert( sizeof(*full_mode) == sizeof(full_mode->mode) + full_mode->mode.dmDriverExtra );
if (mode->dmFields & DM_BITSPERPEL && mode->dmBitsPerPel != screen_bpp) WARN("Cannot change screen color depth from %ubits to %ubits!\n", @@ -1641,9 +1625,6 @@ static LONG xrandr14_set_current_mode( x11drv_settings_id id, const DEVMODEW *mo if (!crtc_info) goto done;
- assert( mode->dmDriverExtra == sizeof(RRMode) ); - memcpy( &rrmode, (BYTE *)mode + sizeof(*mode), sizeof(rrmode) ); - if (crtc_info->noutput) { outputs = crtc_info->outputs; @@ -1671,7 +1652,7 @@ static LONG xrandr14_set_current_mode( x11drv_settings_id id, const DEVMODEW *mo set_screen_size( screen_width, screen_height );
status = pXRRSetCrtcConfig( gdi_display, screen_resources, crtc, CurrentTime, - mode->dmPosition.x, mode->dmPosition.y, rrmode, + mode->dmPosition.x, mode->dmPosition.y, full_mode->rr_mode, rotation, outputs, output_count ); if (status == RRSetConfigSuccess) ret = DISP_CHANGE_SUCCESSFUL; diff --git a/dlls/winex11.drv/xvidmode.c b/dlls/winex11.drv/xvidmode.c index 7af34689dda..d39116c48ff 100644 --- a/dlls/winex11.drv/xvidmode.c +++ b/dlls/winex11.drv/xvidmode.c @@ -91,35 +91,32 @@ static BOOL xf86vm_get_id(const WCHAR *device_name, BOOL is_primary, x11drv_sett return TRUE; }
-static void add_xf86vm_mode( DEVMODEW *mode, DWORD depth, const XF86VidModeModeInfo *mode_info ) +static void add_xf86vm_mode( struct x11drv_mode *mode, DWORD depth, const XF86VidModeModeInfo *mode_info ) { - XF86VidModeModeInfo extra = *mode_info; - - mode->dmSize = sizeof(*mode); - mode->dmDriverExtra = sizeof(*mode_info); - mode->dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS; + mode->mode.dmSize = sizeof(*mode); + mode->mode.dmDriverExtra = sizeof(*mode) - sizeof(mode->mode); + mode->mode.dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS; if (mode_info->htotal && mode_info->vtotal) { - mode->dmFields |= DM_DISPLAYFREQUENCY; - mode->dmDisplayFrequency = mode_info->dotclock * 1000 / (mode_info->htotal * mode_info->vtotal); + mode->mode.dmFields |= DM_DISPLAYFREQUENCY; + mode->mode.dmDisplayFrequency = mode_info->dotclock * 1000 / (mode_info->htotal * mode_info->vtotal); } - mode->dmDisplayOrientation = DMDO_DEFAULT; - mode->dmBitsPerPel = depth; - mode->dmPelsWidth = mode_info->hdisplay; - mode->dmPelsHeight = mode_info->vdisplay; - mode->dmDisplayFlags = 0; - - extra.private = NULL; - extra.privsize = 0; - memcpy( mode + 1, &extra, sizeof(extra) ); + mode->mode.dmDisplayOrientation = DMDO_DEFAULT; + mode->mode.dmBitsPerPel = depth; + mode->mode.dmPelsWidth = mode_info->hdisplay; + mode->mode.dmPelsHeight = mode_info->vdisplay; + mode->mode.dmDisplayFlags = 0; + mode->mode_info = *mode_info; + mode->mode_info.privsize = 0; + mode->mode_info.private = NULL; }
-static BOOL xf86vm_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **new_modes, UINT *mode_count ) +static BOOL xf86vm_get_modes( x11drv_settings_id id, DWORD flags, struct x11drv_mode **new_modes, UINT *mode_count ) { INT xf86vm_mode_idx, xf86vm_mode_count; XF86VidModeModeInfo **xf86vm_modes; - UINT depth_idx, mode_idx = 0; - DEVMODEW *modes, *mode; + struct x11drv_mode *modes, *mode; + UINT depth_idx; Bool ret;
X11DRV_expect_error(gdi_display, XVidModeErrorHandler, NULL); @@ -129,7 +126,7 @@ static BOOL xf86vm_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **new
/* Display modes in different color depth, with a XF86VidModeModeInfo * at the end of each * DEVMODEW as driver private data */ - if (!(modes = calloc( 1, (xf86vm_mode_count * DEPTH_COUNT) * (sizeof(DEVMODEW) + sizeof(XF86VidModeModeInfo)) ))) + if (!(modes = calloc( xf86vm_mode_count * DEPTH_COUNT, sizeof(*modes) ))) { RtlSetLastWin32Error( ERROR_NOT_ENOUGH_MEMORY ); XFree( xf86vm_modes ); @@ -140,14 +137,12 @@ static BOOL xf86vm_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **new { for (xf86vm_mode_idx = 0; xf86vm_mode_idx < xf86vm_mode_count; ++xf86vm_mode_idx) { - add_xf86vm_mode( mode, depths[depth_idx], xf86vm_modes[xf86vm_mode_idx] ); - mode = NEXT_DEVMODEW( mode ); - mode_idx++; + add_xf86vm_mode( mode++, depths[depth_idx], xf86vm_modes[xf86vm_mode_idx] ); } }
*new_modes = modes; - *mode_count = mode_idx; + *mode_count = mode - modes;
XFree( xf86vm_modes ); return TRUE; @@ -194,11 +189,14 @@ static BOOL xf86vm_get_current_mode(x11drv_settings_id id, DEVMODEW *mode) return TRUE; }
-static LONG xf86vm_set_current_mode(x11drv_settings_id id, const DEVMODEW *mode) +static LONG xf86vm_set_current_mode( x11drv_settings_id id, const struct x11drv_mode *full_mode ) { + const DEVMODEW *mode = &full_mode->mode; XF86VidModeModeInfo xf86vm_mode; Bool ret;
+ assert( sizeof(*full_mode) == sizeof(full_mode->mode) + full_mode->mode.dmDriverExtra ); + if (id.id != 1) { FIXME("Non-primary adapters are unsupported.\n"); @@ -215,9 +213,7 @@ static LONG xf86vm_set_current_mode(x11drv_settings_id id, const DEVMODEW *mode) WARN("Cannot change screen bit depth from %dbits to %dbits!\n", screen_bpp, mode->dmBitsPerPel);
- assert( mode->dmDriverExtra == sizeof(XF86VidModeModeInfo) ); - memcpy( &xf86vm_mode, (BYTE *)mode + sizeof(*mode), sizeof(xf86vm_mode) ); - + xf86vm_mode = full_mode->mode_info; X11DRV_expect_error(gdi_display, XVidModeErrorHandler, NULL); ret = pXF86VidModeSwitchToMode( gdi_display, DefaultScreen(gdi_display), &xf86vm_mode ); if (X11DRV_check_error() || !ret)