Commit df8b7e04 authored by Alexandros Frantzis's avatar Alexandros Frantzis Committed by Alexandre Julliard

win32u: Support setting the current mode using gdi_device_manager.

Update the gdi_device_manager API to enable drivers to set the current mode (along with the registry mode if not already set) in UpdateDisplayDevices. Signed-off-by: 's avatarAlexandros Frantzis <alexandros.frantzis@collabora.com>
parent b7225671
...@@ -1482,9 +1482,10 @@ static void add_monitor( const struct gdi_monitor *monitor, void *param ) ...@@ -1482,9 +1482,10 @@ static void add_monitor( const struct gdi_monitor *monitor, void *param )
if (hkey) NtClose( hkey ); if (hkey) NtClose( hkey );
} }
static void add_mode( const DEVMODEW *mode, void *param ) static void add_mode( const DEVMODEW *mode, BOOL current, void *param )
{ {
struct device_manager_ctx *ctx = param; struct device_manager_ctx *ctx = param;
DEVMODEW nopos_mode;
if (!ctx->adapter_count) if (!ctx->adapter_count)
{ {
...@@ -1496,10 +1497,21 @@ static void add_mode( const DEVMODEW *mode, void *param ) ...@@ -1496,10 +1497,21 @@ static void add_mode( const DEVMODEW *mode, void *param )
add_adapter( &default_adapter, ctx ); add_adapter( &default_adapter, ctx );
} }
if (write_adapter_mode( ctx->adapter_key, ctx->mode_count, mode )) nopos_mode = *mode;
nopos_mode.dmPosition.x = 0;
nopos_mode.dmPosition.y = 0;
nopos_mode.dmFields &= ~DM_POSITION;
if (write_adapter_mode( ctx->adapter_key, ctx->mode_count, &nopos_mode ))
{ {
ctx->mode_count++; ctx->mode_count++;
set_reg_value( ctx->adapter_key, mode_countW, REG_DWORD, &ctx->mode_count, sizeof(ctx->mode_count) ); set_reg_value( ctx->adapter_key, mode_countW, REG_DWORD, &ctx->mode_count, sizeof(ctx->mode_count) );
if (current)
{
if (!read_adapter_mode( ctx->adapter_key, ENUM_REGISTRY_SETTINGS, &nopos_mode ))
write_adapter_mode( ctx->adapter_key, ENUM_REGISTRY_SETTINGS, mode );
write_adapter_mode( ctx->adapter_key, ENUM_CURRENT_SETTINGS, mode );
}
} }
} }
...@@ -1626,6 +1638,15 @@ static BOOL update_display_cache_from_registry(void) ...@@ -1626,6 +1638,15 @@ static BOOL update_display_cache_from_registry(void)
return ret; return ret;
} }
static BOOL is_same_devmode( const DEVMODEW *a, const DEVMODEW *b )
{
return a->dmDisplayOrientation == b->dmDisplayOrientation &&
a->dmBitsPerPel == b->dmBitsPerPel &&
a->dmPelsWidth == b->dmPelsWidth &&
a->dmPelsHeight == b->dmPelsHeight &&
a->dmDisplayFrequency == b->dmDisplayFrequency;
}
static BOOL update_display_cache( BOOL force ) static BOOL update_display_cache( BOOL force )
{ {
HWINSTA winstation = NtUserGetProcessWindowStation(); HWINSTA winstation = NtUserGetProcessWindowStation();
...@@ -1682,7 +1703,6 @@ static BOOL update_display_cache( BOOL force ) ...@@ -1682,7 +1703,6 @@ static BOOL update_display_cache( BOOL force )
{ {
mode = modes[2]; mode = modes[2];
mode.dmFields |= DM_POSITION; mode.dmFields |= DM_POSITION;
write_adapter_mode( ctx.adapter_key, ENUM_CURRENT_SETTINGS, &mode );
} }
monitor.rc_monitor.right = mode.dmPelsWidth; monitor.rc_monitor.right = mode.dmPelsWidth;
monitor.rc_monitor.bottom = mode.dmPelsHeight; monitor.rc_monitor.bottom = mode.dmPelsHeight;
...@@ -1690,7 +1710,11 @@ static BOOL update_display_cache( BOOL force ) ...@@ -1690,7 +1710,11 @@ static BOOL update_display_cache( BOOL force )
monitor.rc_work.bottom = mode.dmPelsHeight; monitor.rc_work.bottom = mode.dmPelsHeight;
add_monitor( &monitor, &ctx ); add_monitor( &monitor, &ctx );
for (i = 0; i < ARRAY_SIZE(modes); ++i) add_mode( modes + i, &ctx ); for (i = 0; i < ARRAY_SIZE(modes); ++i)
{
if (is_same_devmode( modes + i, &mode )) add_mode( &mode, TRUE, &ctx );
else add_mode( modes + i, FALSE, &ctx );
}
} }
release_display_manager_ctx( &ctx ); release_display_manager_ctx( &ctx );
......
...@@ -295,7 +295,7 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag ...@@ -295,7 +295,7 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag
device_manager->add_gpu( &gpu, param ); device_manager->add_gpu( &gpu, param );
device_manager->add_adapter( &adapter, param ); device_manager->add_adapter( &adapter, param );
device_manager->add_monitor( &gdi_monitor, param ); device_manager->add_monitor( &gdi_monitor, param );
device_manager->add_mode( &mode, param ); device_manager->add_mode( &mode, FALSE, param );
force_display_devices_refresh = FALSE; force_display_devices_refresh = FALSE;
} }
......
...@@ -1205,7 +1205,7 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage ...@@ -1205,7 +1205,7 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
(int)mode->dmBitsPerPel, (int)mode->dmDisplayFrequency, (int)mode->dmBitsPerPel, (int)mode->dmDisplayFrequency,
mode->dmDisplayFixedOutput == DMDFO_STRETCH ? "" : "un", mode->dmDisplayFixedOutput == DMDFO_STRETCH ? "" : "un",
mode->dmDisplayFlags & DM_INTERLACED ? "" : "non-"); mode->dmDisplayFlags & DM_INTERLACED ? "" : "non-");
device_manager->add_mode( mode, param ); device_manager->add_mode( mode, FALSE, param );
} }
free(modes); free(modes);
......
...@@ -126,7 +126,7 @@ static void wayland_add_device_modes(const struct gdi_device_manager *device_man ...@@ -126,7 +126,7 @@ static void wayland_add_device_modes(const struct gdi_device_manager *device_man
{ {
DEVMODEW mode; DEVMODEW mode;
populate_devmode(output_mode, &mode); populate_devmode(output_mode, &mode);
device_manager->add_mode(&mode, param); device_manager->add_mode(&mode, FALSE, param);
} }
} }
......
...@@ -599,7 +599,7 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage ...@@ -599,7 +599,7 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
for (mode = modes; mode_count; mode_count--) for (mode = modes; mode_count; mode_count--)
{ {
TRACE( "mode: %p\n", mode ); TRACE( "mode: %p\n", mode );
device_manager->add_mode( mode, param ); device_manager->add_mode( mode, FALSE, param );
mode = (DEVMODEW *)((char *)mode + sizeof(*modes) + modes[0].dmDriverExtra); mode = (DEVMODEW *)((char *)mode + sizeof(*modes) + modes[0].dmDriverExtra);
} }
......
...@@ -266,7 +266,7 @@ struct gdi_device_manager ...@@ -266,7 +266,7 @@ struct gdi_device_manager
void (*add_gpu)( const struct gdi_gpu *gpu, void *param ); void (*add_gpu)( const struct gdi_gpu *gpu, void *param );
void (*add_adapter)( const struct gdi_adapter *adapter, void *param ); void (*add_adapter)( const struct gdi_adapter *adapter, void *param );
void (*add_monitor)( const struct gdi_monitor *monitor, void *param ); void (*add_monitor)( const struct gdi_monitor *monitor, void *param );
void (*add_mode)( const DEVMODEW *mode, void *param ); void (*add_mode)( const DEVMODEW *mode, BOOL current, void *param );
}; };
#define WINE_DM_UNSUPPORTED 0x80000000 #define WINE_DM_UNSUPPORTED 0x80000000
......
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