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

win32u: Introduce a new add_virtual_modes helper.

parent b86cc9e6
...@@ -1777,7 +1777,7 @@ static BOOL default_update_display_devices( BOOL force, struct device_manager_ct ...@@ -1777,7 +1777,7 @@ static BOOL default_update_display_devices( BOOL force, struct device_manager_ct
} }
/* parse the desktop size specification */ /* parse the desktop size specification */
static BOOL parse_size( const WCHAR *size, unsigned int *width, unsigned int *height ) static BOOL parse_size( const WCHAR *size, DWORD *width, DWORD *height )
{ {
WCHAR *end; WCHAR *end;
...@@ -1790,7 +1790,7 @@ static BOOL parse_size( const WCHAR *size, unsigned int *width, unsigned int *he ...@@ -1790,7 +1790,7 @@ static BOOL parse_size( const WCHAR *size, unsigned int *width, unsigned int *he
} }
/* retrieve the default desktop size from the registry */ /* retrieve the default desktop size from the registry */
static BOOL get_default_desktop_size( unsigned int *width, unsigned int *height ) static BOOL get_default_desktop_size( DWORD *width, DWORD *height )
{ {
WCHAR buffer[4096]; WCHAR buffer[4096];
KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer; KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer;
...@@ -1808,9 +1808,9 @@ static BOOL get_default_desktop_size( unsigned int *width, unsigned int *height ...@@ -1808,9 +1808,9 @@ static BOOL get_default_desktop_size( unsigned int *width, unsigned int *height
return TRUE; return TRUE;
} }
static BOOL add_virtual_source( struct device_manager_ctx *ctx ) static void add_virtual_modes( struct device_manager_ctx *ctx, const DEVMODEW *current,
const DEVMODEW *initial, const DEVMODEW *maximum )
{ {
struct gdi_monitor monitor = {0};
static struct screen_size static struct screen_size
{ {
unsigned int width; unsigned int width;
...@@ -1848,17 +1848,57 @@ static BOOL add_virtual_source( struct device_manager_ctx *ctx ) ...@@ -1848,17 +1848,57 @@ static BOOL add_virtual_source( struct device_manager_ctx *ctx )
{1920, 1200}, {1920, 1200},
{2560, 1600} {2560, 1600}
}; };
UINT depths[] = {8, 16, initial->dmBitsPerPel}, i, j, modes_count;
DEVMODEW *modes;
if (!(modes = malloc( ARRAY_SIZE(depths) * (ARRAY_SIZE(screen_sizes) + 2) * sizeof(*modes) ))) return;
for (modes_count = i = 0; i < ARRAY_SIZE(depths); ++i)
{
DEVMODEW mode =
{
.dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY,
.dmDisplayFrequency = 60,
.dmBitsPerPel = depths[i],
};
for (j = 0; j < ARRAY_SIZE(screen_sizes); ++j)
{
mode.dmPelsWidth = screen_sizes[j].width;
mode.dmPelsHeight = screen_sizes[j].height;
if (mode.dmPelsWidth > maximum->dmPelsWidth || mode.dmPelsHeight > maximum->dmPelsWidth) continue;
if (mode.dmPelsWidth == maximum->dmPelsWidth && mode.dmPelsHeight == maximum->dmPelsWidth) continue;
if (mode.dmPelsWidth == initial->dmPelsWidth && mode.dmPelsHeight == initial->dmPelsHeight) continue;
modes[modes_count++] = mode;
}
mode.dmPelsWidth = initial->dmPelsWidth;
mode.dmPelsHeight = initial->dmPelsHeight;
modes[modes_count++] = mode;
if (maximum->dmPelsWidth != initial->dmPelsWidth || maximum->dmPelsWidth != initial->dmPelsHeight)
{
mode.dmPelsWidth = maximum->dmPelsWidth;
mode.dmPelsHeight = maximum->dmPelsHeight;
modes[modes_count++] = mode;
}
}
add_modes( current, modes_count, modes, ctx );
free( modes );
}
UINT screen_width, screen_height, max_width, max_height, modes_count; static BOOL add_virtual_source( struct device_manager_ctx *ctx )
unsigned int depths[] = {8, 16, 0}; {
DEVMODEW current, initial = ctx->primary, maximum = ctx->primary;
struct source virtual_source = struct source virtual_source =
{ {
.state_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE, .state_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE,
.id = ctx->source_count, .id = ctx->source_count,
.gpu = &ctx->gpu, .gpu = &ctx->gpu,
}; };
DEVMODEW current, *modes; struct gdi_monitor monitor = {0};
UINT i, j;
/* Wine specific config key where source settings will be held, symlinked with the logically indexed config key */ /* Wine specific config key where source settings will be held, symlinked with the logically indexed config key */
snprintf( virtual_source.path, sizeof(virtual_source.path), "%s\\%s\\Video\\%s\\Sources\\%s", config_keyA, snprintf( virtual_source.path, sizeof(virtual_source.path), "%s\\%s\\Video\\%s\\Sources\\%s", config_keyA,
...@@ -1874,22 +1914,18 @@ static BOOL add_virtual_source( struct device_manager_ctx *ctx ) ...@@ -1874,22 +1914,18 @@ static BOOL add_virtual_source( struct device_manager_ctx *ctx )
ctx->gpu.source_count++; ctx->gpu.source_count++;
ctx->source_count++; ctx->source_count++;
max_width = ctx->primary.dmPelsWidth; if (!get_default_desktop_size( &initial.dmPelsWidth, &initial.dmPelsHeight ))
max_height = ctx->primary.dmPelsHeight;
depths[ARRAY_SIZE(depths) - 1] = ctx->primary.dmBitsPerPel;
if (!get_default_desktop_size( &screen_width, &screen_height ))
{ {
screen_width = max_width; initial.dmPelsWidth = maximum.dmPelsWidth;
screen_height = max_height; initial.dmPelsHeight = maximum.dmPelsHeight;
} }
if (!read_source_mode( ctx->source_key, ENUM_CURRENT_SETTINGS, &current )) if (!read_source_mode( ctx->source_key, ENUM_CURRENT_SETTINGS, &current ))
{ {
current = ctx->primary; current = ctx->primary;
current.dmDisplayFrequency = 60; current.dmDisplayFrequency = 60;
current.dmPelsWidth = screen_width; current.dmPelsWidth = initial.dmPelsWidth;
current.dmPelsHeight = screen_height; current.dmPelsHeight = initial.dmPelsHeight;
} }
monitor.rc_monitor.right = current.dmPelsWidth; monitor.rc_monitor.right = current.dmPelsWidth;
...@@ -1897,43 +1933,7 @@ static BOOL add_virtual_source( struct device_manager_ctx *ctx ) ...@@ -1897,43 +1933,7 @@ static BOOL add_virtual_source( struct device_manager_ctx *ctx )
monitor.rc_work.right = current.dmPelsWidth; monitor.rc_work.right = current.dmPelsWidth;
monitor.rc_work.bottom = current.dmPelsHeight; monitor.rc_work.bottom = current.dmPelsHeight;
add_monitor( &monitor, ctx ); add_monitor( &monitor, ctx );
add_virtual_modes( ctx, &current, &initial, &maximum );
if (!(modes = malloc( ARRAY_SIZE(depths) * (ARRAY_SIZE(screen_sizes) + 2) * sizeof(*modes) ))) return FALSE;
for (modes_count = i = 0; i < ARRAY_SIZE(depths); ++i)
{
DEVMODEW mode =
{
.dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY,
.dmDisplayFrequency = 60,
.dmBitsPerPel = depths[i],
};
for (j = 0; j < ARRAY_SIZE(screen_sizes); ++j)
{
mode.dmPelsWidth = screen_sizes[j].width;
mode.dmPelsHeight = screen_sizes[j].height;
if (mode.dmPelsWidth > max_width || mode.dmPelsHeight > max_height) continue;
if (mode.dmPelsWidth == max_width && mode.dmPelsHeight == max_height) continue;
if (mode.dmPelsWidth == screen_width && mode.dmPelsHeight == screen_height) continue;
modes[modes_count++] = mode;
}
mode.dmPelsWidth = screen_width;
mode.dmPelsHeight = screen_height;
modes[modes_count++] = mode;
if (max_width != screen_width || max_height != screen_height)
{
mode.dmPelsWidth = max_width;
mode.dmPelsHeight = max_height;
modes[modes_count++] = mode;
}
}
add_modes( &current, modes_count, modes, ctx );
free( modes );
return TRUE; return TRUE;
} }
......
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