Commit f74900ad authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winex11: Only request display modes driver data when needed.

parent 6b4ab3be
...@@ -71,7 +71,7 @@ static BOOL nores_get_id(const WCHAR *device_name, BOOL is_primary, x11drv_setti ...@@ -71,7 +71,7 @@ static BOOL nores_get_id(const WCHAR *device_name, BOOL is_primary, x11drv_setti
return TRUE; 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, DEVMODEW **new_modes, UINT *mode_count, BOOL full )
{ {
RECT primary = get_host_primary_monitor_rect(); RECT primary = get_host_primary_monitor_rect();
DEVMODEW *modes; DEVMODEW *modes;
...@@ -261,8 +261,7 @@ static DEVMODEW *get_full_mode(x11drv_settings_id id, DEVMODEW *dev_mode) ...@@ -261,8 +261,7 @@ static DEVMODEW *get_full_mode(x11drv_settings_id id, DEVMODEW *dev_mode)
if (is_detached_mode(dev_mode)) if (is_detached_mode(dev_mode))
return dev_mode; return dev_mode;
if (!settings_handler.get_modes(id, EDS_ROTATEDMODE, &modes, &mode_count)) if (!settings_handler.get_modes( id, EDS_ROTATEDMODE, &modes, &mode_count, TRUE )) return NULL;
return NULL;
for (mode_idx = 0; mode_idx < mode_count; ++mode_idx) for (mode_idx = 0; mode_idx < mode_count; ++mode_idx)
{ {
...@@ -547,7 +546,7 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage ...@@ -547,7 +546,7 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
if (!settings_handler.get_id( devname, is_primary, &settings_id )) break; if (!settings_handler.get_id( devname, is_primary, &settings_id )) break;
settings_handler.get_current_mode( settings_id, &current_mode ); settings_handler.get_current_mode( settings_id, &current_mode );
if (settings_handler.get_modes( settings_id, EDS_ROTATEDMODE, &modes, &mode_count )) if (settings_handler.get_modes( settings_id, EDS_ROTATEDMODE, &modes, &mode_count, FALSE ))
{ {
device_manager->add_modes( &current_mode, mode_count, modes, param ); device_manager->add_modes( &current_mode, mode_count, modes, param );
settings_handler.free_modes( modes ); settings_handler.free_modes( modes );
......
...@@ -726,7 +726,7 @@ struct x11drv_settings_handler ...@@ -726,7 +726,7 @@ struct x11drv_settings_handler
* dmDisplayFlags and dmDisplayFrequency * dmDisplayFlags and dmDisplayFrequency
* *
* Return FALSE on failure with parameters unchanged and error code set. Return TRUE on success */ * 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, DEVMODEW **modes, UINT *mode_count, BOOL full);
/* free_modes() will be called to free the mode list returned from get_modes() */ /* free_modes() will be called to free the mode list returned from get_modes() */
void (*free_modes)(DEVMODEW *modes); void (*free_modes)(DEVMODEW *modes);
...@@ -747,6 +747,8 @@ struct x11drv_settings_handler ...@@ -747,6 +747,8 @@ struct x11drv_settings_handler
LONG (*set_current_mode)(x11drv_settings_id id, const DEVMODEW *mode); LONG (*set_current_mode)(x11drv_settings_id id, const DEVMODEW *mode);
}; };
#define NEXT_DEVMODEW(mode) ((DEVMODEW *)((char *)((mode) + 1) + (mode)->dmDriverExtra))
extern void X11DRV_Settings_SetHandler(const struct x11drv_settings_handler *handler); extern void X11DRV_Settings_SetHandler(const struct x11drv_settings_handler *handler);
extern void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height ); extern void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height );
......
...@@ -152,10 +152,10 @@ static BOOL xrandr10_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s ...@@ -152,10 +152,10 @@ static BOOL xrandr10_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s
} }
static void add_xrandr10_mode( DEVMODEW *mode, DWORD depth, DWORD width, DWORD height, static void add_xrandr10_mode( DEVMODEW *mode, DWORD depth, DWORD width, DWORD height,
DWORD frequency, SizeID size_id ) DWORD frequency, SizeID size_id, BOOL full )
{ {
mode->dmSize = sizeof(*mode); mode->dmSize = sizeof(*mode);
mode->dmDriverExtra = sizeof(SizeID); mode->dmDriverExtra = full ? sizeof(SizeID) : 0;
mode->dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | mode->dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH |
DM_PELSHEIGHT | DM_DISPLAYFLAGS; DM_PELSHEIGHT | DM_DISPLAYFLAGS;
if (frequency) if (frequency)
...@@ -168,10 +168,10 @@ static void add_xrandr10_mode( DEVMODEW *mode, DWORD depth, DWORD width, DWORD h ...@@ -168,10 +168,10 @@ static void add_xrandr10_mode( DEVMODEW *mode, DWORD depth, DWORD width, DWORD h
mode->dmPelsWidth = width; mode->dmPelsWidth = width;
mode->dmPelsHeight = height; mode->dmPelsHeight = height;
mode->dmDisplayFlags = 0; mode->dmDisplayFlags = 0;
memcpy( (BYTE *)mode + sizeof(*mode), &size_id, sizeof(size_id) ); if (full) memcpy( mode + 1, &size_id, sizeof(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, DEVMODEW **new_modes, UINT *new_mode_count, BOOL full )
{ {
INT size_idx, depth_idx, rate_idx, mode_idx = 0; INT size_idx, depth_idx, rate_idx, mode_idx = 0;
INT size_count, rate_count, mode_count = 0; INT size_count, rate_count, mode_count = 0;
...@@ -201,24 +201,24 @@ static BOOL xrandr10_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **n ...@@ -201,24 +201,24 @@ static BOOL xrandr10_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **n
return FALSE; return FALSE;
} }
for (size_idx = 0; size_idx < size_count; ++size_idx) for (size_idx = 0, mode = modes; size_idx < size_count; ++size_idx)
{ {
for (depth_idx = 0; depth_idx < DEPTH_COUNT; ++depth_idx) for (depth_idx = 0; depth_idx < DEPTH_COUNT; ++depth_idx)
{ {
rates = pXRRRates( gdi_display, DefaultScreen( gdi_display ), size_idx, &rate_count ); rates = pXRRRates( gdi_display, DefaultScreen( gdi_display ), size_idx, &rate_count );
if (!rate_count) if (!rate_count)
{ {
mode = (DEVMODEW *)((BYTE *)modes + (sizeof(*mode) + sizeof(SizeID)) * mode_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, 0, size_idx ); sizes[size_idx].height, 0, size_idx, full );
mode = NEXT_DEVMODEW( mode );
continue; continue;
} }
for (rate_idx = 0; rate_idx < rate_count; ++rate_idx) for (rate_idx = 0; rate_idx < rate_count; ++rate_idx)
{ {
mode = (DEVMODEW *)((BYTE *)modes + (sizeof(*mode) + sizeof(SizeID)) * mode_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 ); sizes[size_idx].height, rates[rate_idx], size_idx, full );
mode = NEXT_DEVMODEW( mode );
} }
} }
} }
...@@ -1316,10 +1316,10 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s ...@@ -1316,10 +1316,10 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s
} }
static void add_xrandr14_mode( DEVMODEW *mode, XRRModeInfo *info, DWORD depth, DWORD frequency, static void add_xrandr14_mode( DEVMODEW *mode, XRRModeInfo *info, DWORD depth, DWORD frequency,
DWORD orientation ) DWORD orientation, BOOL full )
{ {
mode->dmSize = sizeof(*mode); mode->dmSize = sizeof(*mode);
mode->dmDriverExtra = sizeof(RRMode); mode->dmDriverExtra = full ? sizeof(RRMode) : 0;
mode->dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | mode->dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH |
DM_PELSHEIGHT | DM_DISPLAYFLAGS; DM_PELSHEIGHT | DM_DISPLAYFLAGS;
if (frequency) if (frequency)
...@@ -1340,10 +1340,10 @@ static void add_xrandr14_mode( DEVMODEW *mode, XRRModeInfo *info, DWORD depth, D ...@@ -1340,10 +1340,10 @@ static void add_xrandr14_mode( DEVMODEW *mode, XRRModeInfo *info, DWORD depth, D
mode->dmDisplayOrientation = orientation; mode->dmDisplayOrientation = orientation;
mode->dmBitsPerPel = depth; mode->dmBitsPerPel = depth;
mode->dmDisplayFlags = 0; mode->dmDisplayFlags = 0;
memcpy( (BYTE *)mode + sizeof(*mode), &info->id, sizeof(info->id) ); if (full) memcpy( mode + 1, &info->id, sizeof(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, DEVMODEW **new_modes, UINT *mode_count, BOOL full )
{ {
DWORD frequency, orientation, orientation_count; DWORD frequency, orientation, orientation_count;
XRRScreenResources *screen_resources; XRRScreenResources *screen_resources;
...@@ -1415,7 +1415,7 @@ static BOOL xrandr14_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **n ...@@ -1415,7 +1415,7 @@ static BOOL xrandr14_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **n
if (!modes) if (!modes)
goto done; goto done;
for (i = 0; i < output_info->nmode; ++i) for (i = 0, mode = modes; i < output_info->nmode; ++i)
{ {
for (j = 0; j < screen_resources->nmode; ++j) for (j = 0; j < screen_resources->nmode; ++j)
{ {
...@@ -1432,8 +1432,8 @@ static BOOL xrandr14_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **n ...@@ -1432,8 +1432,8 @@ static BOOL xrandr14_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **n
if (!((1 << orientation) & rotations)) if (!((1 << orientation) & rotations))
continue; continue;
mode = (DEVMODEW *)((BYTE *)modes + (sizeof(*modes) + sizeof(RRMode)) * mode_idx); add_xrandr14_mode( mode, mode_info, depths[depth_idx], frequency, orientation, full );
add_xrandr14_mode( mode, mode_info, depths[depth_idx], frequency, orientation ); mode = NEXT_DEVMODEW( mode );
++mode_idx; ++mode_idx;
} }
} }
......
...@@ -91,10 +91,10 @@ static BOOL xf86vm_get_id(const WCHAR *device_name, BOOL is_primary, x11drv_sett ...@@ -91,10 +91,10 @@ static BOOL xf86vm_get_id(const WCHAR *device_name, BOOL is_primary, x11drv_sett
return TRUE; return TRUE;
} }
static void add_xf86vm_mode(DEVMODEW *mode, DWORD depth, const XF86VidModeModeInfo *mode_info) static void add_xf86vm_mode( DEVMODEW *mode, DWORD depth, const XF86VidModeModeInfo *mode_info, BOOL full )
{ {
mode->dmSize = sizeof(*mode); mode->dmSize = sizeof(*mode);
mode->dmDriverExtra = sizeof(mode_info); mode->dmDriverExtra = full ? sizeof(mode_info) : 0;
mode->dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS; mode->dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS;
if (mode_info->htotal && mode_info->vtotal) if (mode_info->htotal && mode_info->vtotal)
{ {
...@@ -106,10 +106,10 @@ static void add_xf86vm_mode(DEVMODEW *mode, DWORD depth, const XF86VidModeModeIn ...@@ -106,10 +106,10 @@ static void add_xf86vm_mode(DEVMODEW *mode, DWORD depth, const XF86VidModeModeIn
mode->dmPelsWidth = mode_info->hdisplay; mode->dmPelsWidth = mode_info->hdisplay;
mode->dmPelsHeight = mode_info->vdisplay; mode->dmPelsHeight = mode_info->vdisplay;
mode->dmDisplayFlags = 0; mode->dmDisplayFlags = 0;
memcpy((BYTE *)mode + sizeof(*mode), &mode_info, sizeof(mode_info)); if (full) memcpy( mode + 1, &mode_info, sizeof(mode_info) );
} }
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, DEVMODEW **new_modes, UINT *mode_count, BOOL full )
{ {
INT xf86vm_mode_idx, xf86vm_mode_count; INT xf86vm_mode_idx, xf86vm_mode_count;
XF86VidModeModeInfo **xf86vm_modes; XF86VidModeModeInfo **xf86vm_modes;
...@@ -139,12 +139,12 @@ static BOOL xf86vm_get_modes(x11drv_settings_id id, DWORD flags, DEVMODEW **new_ ...@@ -139,12 +139,12 @@ static BOOL xf86vm_get_modes(x11drv_settings_id id, DWORD flags, DEVMODEW **new_
memcpy(ptr, &xf86vm_modes, sizeof(xf86vm_modes)); memcpy(ptr, &xf86vm_modes, sizeof(xf86vm_modes));
modes = (DEVMODEW *)(ptr + sizeof(xf86vm_modes)); modes = (DEVMODEW *)(ptr + sizeof(xf86vm_modes));
for (depth_idx = 0; depth_idx < DEPTH_COUNT; ++depth_idx) for (depth_idx = 0, mode = modes; depth_idx < DEPTH_COUNT; ++depth_idx)
{ {
for (xf86vm_mode_idx = 0; xf86vm_mode_idx < xf86vm_mode_count; ++xf86vm_mode_idx) for (xf86vm_mode_idx = 0; xf86vm_mode_idx < xf86vm_mode_count; ++xf86vm_mode_idx)
{ {
mode = (DEVMODEW *)((BYTE *)modes + (sizeof(DEVMODEW) + sizeof(XF86VidModeModeInfo *)) * mode_idx++); add_xf86vm_mode( mode, depths[depth_idx], xf86vm_modes[xf86vm_mode_idx], full );
add_xf86vm_mode(mode, depths[depth_idx], xf86vm_modes[xf86vm_mode_idx]); mode = NEXT_DEVMODEW( mode );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment