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.
This changes also allows us to remove the driver code that manually changes the registry settings.
-- v6: wineandroid.drv: Set the current mode using gdi_device_manager. winemac.drv: Set the current mode using gdi_device_manager.
From: Alexandros Frantzis alexandros.frantzis@collabora.com
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: Alexandros Frantzis alexandros.frantzis@collabora.com --- dlls/win32u/sysparams.c | 32 ++++++++++++++++++++++++++++---- dlls/wineandroid.drv/init.c | 2 +- dlls/winemac.drv/display.c | 2 +- dlls/winewayland.drv/display.c | 2 +- dlls/winex11.drv/display.c | 2 +- include/wine/gdi_driver.h | 2 +- 6 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 60b12321953..32b20682d24 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1482,9 +1482,10 @@ static void add_monitor( const struct gdi_monitor *monitor, void *param ) 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; + DEVMODEW nopos_mode;
if (!ctx->adapter_count) { @@ -1496,10 +1497,21 @@ static void add_mode( const DEVMODEW *mode, void *param ) 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++; 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) 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 ) { HWINSTA winstation = NtUserGetProcessWindowStation(); @@ -1682,7 +1703,6 @@ static BOOL update_display_cache( BOOL force ) { mode = modes[2]; mode.dmFields |= DM_POSITION; - write_adapter_mode( ctx.adapter_key, ENUM_CURRENT_SETTINGS, &mode ); } monitor.rc_monitor.right = mode.dmPelsWidth; monitor.rc_monitor.bottom = mode.dmPelsHeight; @@ -1690,7 +1710,11 @@ static BOOL update_display_cache( BOOL force ) monitor.rc_work.bottom = mode.dmPelsHeight;
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 );
diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c index 074aa6c6257..0ba8a0b3ebb 100644 --- a/dlls/wineandroid.drv/init.c +++ b/dlls/wineandroid.drv/init.c @@ -295,7 +295,7 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag device_manager->add_gpu( &gpu, param ); device_manager->add_adapter( &adapter, 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; }
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index 6a798994e47..438e2bb5390 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -1205,7 +1205,7 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage (int)mode->dmBitsPerPel, (int)mode->dmDisplayFrequency, mode->dmDisplayFixedOutput == DMDFO_STRETCH ? "" : "un", mode->dmDisplayFlags & DM_INTERLACED ? "" : "non-"); - device_manager->add_mode( mode, param ); + device_manager->add_mode( mode, FALSE, param ); }
free(modes); diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index e72b26a9da0..1d86b2fd4e3 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -126,7 +126,7 @@ static void wayland_add_device_modes(const struct gdi_device_manager *device_man { DEVMODEW mode; populate_devmode(output_mode, &mode); - device_manager->add_mode(&mode, param); + device_manager->add_mode(&mode, FALSE, param); } }
diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index 78de6a6f88b..e675194b9fd 100644 --- a/dlls/winex11.drv/display.c +++ b/dlls/winex11.drv/display.c @@ -599,7 +599,7 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage for (mode = modes; mode_count; mode_count--) { 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); }
diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index c492252d4ab..0eb24fd4424 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -266,7 +266,7 @@ struct gdi_device_manager void (*add_gpu)( const struct gdi_gpu *gpu, void *param ); void (*add_adapter)( const struct gdi_adapter *adapter, 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
From: Alexandros Frantzis alexandros.frantzis@collabora.com
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- dlls/winex11.drv/display.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index e675194b9fd..5fb027da680 100644 --- a/dlls/winex11.drv/display.c +++ b/dlls/winex11.drv/display.c @@ -278,6 +278,15 @@ BOOL is_detached_mode(const DEVMODEW *mode) mode->dmPelsHeight == 0; }
+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; +} + /* Get the full display mode with all the necessary fields set. * Return NULL on failure. Caller should call free_full_mode() to free the returned mode. */ static DEVMODEW *get_full_mode(ULONG_PTR id, DEVMODEW *dev_mode) @@ -294,19 +303,7 @@ static DEVMODEW *get_full_mode(ULONG_PTR 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); - - if (found_mode->dmBitsPerPel != dev_mode->dmBitsPerPel) - continue; - if (found_mode->dmPelsWidth != dev_mode->dmPelsWidth) - continue; - if (found_mode->dmPelsHeight != dev_mode->dmPelsHeight) - continue; - if (found_mode->dmDisplayFrequency != dev_mode->dmDisplayFrequency) - continue; - if (found_mode->dmDisplayOrientation != dev_mode->dmDisplayOrientation) - continue; - - break; + if (is_same_devmode( found_mode, dev_mode )) break; }
if (!found_mode || mode_idx == mode_count)
From: Alexandros Frantzis alexandros.frantzis@collabora.com
Since setting the current mode also sets the registry settings (if not previously set), we also remove the code that manually changes the registry settings.
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- dlls/winex11.drv/display.c | 69 ++++++++++++++++++-------------------- dlls/winex11.drv/x11drv.h | 1 - dlls/winex11.drv/xrandr.c | 1 - 3 files changed, 32 insertions(+), 39 deletions(-)
diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index 5fb027da680..cd36c3c559c 100644 --- a/dlls/winex11.drv/display.c +++ b/dlls/winex11.drv/display.c @@ -156,41 +156,6 @@ void X11DRV_Settings_Init(void) X11DRV_Settings_SetHandler(&nores_handler); }
-/* Initialize registry display settings when new display devices are added */ -void init_registry_display_settings(void) -{ - DEVMODEW dm = {.dmSize = sizeof(dm)}; - DISPLAY_DEVICEW dd = {sizeof(dd)}; - UNICODE_STRING device_name; - DWORD i = 0; - int ret; - - while (!NtUserEnumDisplayDevices( NULL, i++, &dd, 0 )) - { - RtlInitUnicodeString( &device_name, dd.DeviceName ); - - /* Skip if the device already has registry display settings */ - if (NtUserEnumDisplaySettings( &device_name, ENUM_REGISTRY_SETTINGS, &dm, 0 )) - continue; - - if (!NtUserEnumDisplaySettings( &device_name, ENUM_CURRENT_SETTINGS, &dm, 0 )) - { - ERR("Failed to query current display settings for %s.\n", wine_dbgstr_w(dd.DeviceName)); - continue; - } - - TRACE("Device %s current display mode %ux%u %ubits %uHz at %d,%d.\n", - wine_dbgstr_w(dd.DeviceName), (int)dm.dmPelsWidth, (int)dm.dmPelsHeight, - (int)dm.dmBitsPerPel, (int)dm.dmDisplayFrequency, (int)dm.dmPosition.x, (int)dm.dmPosition.y); - - ret = NtUserChangeDisplaySettings( &device_name, &dm, NULL, - CDS_GLOBAL | CDS_NORESET | CDS_UPDATEREGISTRY, NULL ); - if (ret != DISP_CHANGE_SUCCESSFUL) - ERR("Failed to save registry display settings for %s, returned %d.\n", - wine_dbgstr_w(dd.DeviceName), ret); - } -} - static void set_display_depth(ULONG_PTR display_id, DWORD depth) { struct x11drv_display_depth *display_depth; @@ -548,6 +513,25 @@ BOOL X11DRV_DisplayDevices_SupportEventHandlers(void)
static BOOL force_display_devices_refresh;
+static const char *debugstr_devmodew( const DEVMODEW *devmode ) +{ + char position[32] = {0}; + + if (devmode->dmFields & DM_POSITION) + { + snprintf( position, sizeof(position), " at (%d,%d)", + (int)devmode->dmPosition.x, (int)devmode->dmPosition.y ); + } + + return wine_dbg_sprintf( "%ux%u %ubits %uHz rotated %u degrees%s", + (unsigned int)devmode->dmPelsWidth, + (unsigned int)devmode->dmPelsHeight, + (unsigned int)devmode->dmBitsPerPel, + (unsigned int)devmode->dmDisplayFrequency, + (unsigned int)devmode->dmDisplayOrientation * 90, + position ); +} + BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, BOOL force, void *param ) { struct x11drv_display_device_handler *handler; @@ -579,6 +563,8 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
for (adapter = 0; adapter < adapter_count; adapter++) { + DEVMODEW current_mode = {.dmSize = sizeof(current_mode)}; + device_manager->add_adapter( &adapters[adapter], param );
if (!handler->get_monitors(adapters[adapter].id, &monitors, &monitor_count)) break; @@ -590,13 +576,22 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
handler->free_monitors(monitors, monitor_count);
+ settings_handler.get_current_mode( adapters[adapter].id, ¤t_mode ); if (!settings_handler.get_modes( adapters[adapter].id, EDS_ROTATEDMODE, &modes, &mode_count )) continue;
for (mode = modes; mode_count; mode_count--) { - TRACE( "mode: %p\n", mode ); - device_manager->add_mode( mode, FALSE, param ); + if (is_same_devmode( mode, ¤t_mode )) + { + TRACE( "current mode: %s\n", debugstr_devmodew( ¤t_mode ) ); + device_manager->add_mode( ¤t_mode, TRUE, param ); + } + else + { + TRACE( "mode: %s\n", debugstr_devmodew( mode ) ); + device_manager->add_mode( mode, FALSE, param ); + } mode = (DEVMODEW *)((char *)mode + sizeof(*modes) + modes[0].dmDriverExtra); }
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index a41eac928ad..893099489e3 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -758,7 +758,6 @@ extern void X11DRV_Settings_SetHandler(const struct x11drv_settings_handler *han
extern void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height ) DECLSPEC_HIDDEN; extern void X11DRV_resize_desktop(void) DECLSPEC_HIDDEN; -extern void init_registry_display_settings(void) DECLSPEC_HIDDEN; extern BOOL is_virtual_desktop(void) DECLSPEC_HIDDEN; extern BOOL is_desktop_fullscreen(void) DECLSPEC_HIDDEN; extern BOOL is_detached_mode(const DEVMODEW *) DECLSPEC_HIDDEN; diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index 7c32e683c5d..3731ca6b4d0 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -1188,7 +1188,6 @@ static BOOL xrandr14_device_change_handler( HWND hwnd, XEvent *event ) if (hwnd == NtUserGetDesktopWindow() && NtUserGetWindowThread( hwnd, NULL ) == GetCurrentThreadId()) { X11DRV_DisplayDevices_Init( TRUE ); - init_registry_display_settings(); X11DRV_resize_desktop(); } /* Update xinerama monitors for xinerama_get_fullscreen_monitors() */
From: Alexandros Frantzis alexandros.frantzis@collabora.com
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- dlls/winewayland.drv/display.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index 1d86b2fd4e3..bd99441170e 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -124,9 +124,11 @@ static void wayland_add_device_modes(const struct gdi_device_manager *device_man
RB_FOR_EACH_ENTRY(output_mode, &output->modes, struct wayland_output_mode, entry) { - DEVMODEW mode; + DEVMODEW mode = {.dmSize = sizeof(mode)}; + BOOL mode_is_current = output_mode == output->current_mode; populate_devmode(output_mode, &mode); - device_manager->add_mode(&mode, FALSE, param); + if (mode_is_current) mode.dmFields |= DM_POSITION; + device_manager->add_mode(&mode, mode_is_current, param); } }
From: Alexandros Frantzis alexandros.frantzis@collabora.com
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- dlls/winemac.drv/display.c | 50 +++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 22 deletions(-)
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index 438e2bb5390..b93ebaaa5e7 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -864,6 +864,33 @@ static DEVMODEW *display_get_modes(CGDirectDisplayID display_id, int *modes_coun return devmodes; }
+static void display_get_current_mode(struct macdrv_display *display, DEVMODEW *devmode) +{ + CGDisplayModeRef display_mode; + CGDirectDisplayID display_id; + + display_id = display->displayID; + display_mode = CGDisplayCopyDisplayMode(display_id); + + devmode->dmPosition.x = CGRectGetMinX(display->frame); + devmode->dmPosition.y = CGRectGetMinY(display->frame); + devmode->dmFields |= DM_POSITION; + + display_mode_to_devmode(display_id, display_mode, devmode); + if (retina_enabled) + { + struct display_mode_descriptor *desc = create_original_display_mode_descriptor(display_id); + if (display_mode_matches_descriptor(display_mode, desc)) + { + devmode->dmPelsWidth *= 2; + devmode->dmPelsHeight *= 2; + } + free_display_mode_descriptor(desc); + } + + CFRelease(display_mode); +} + /*********************************************************************** * GetCurrentDisplaySettings (MACDRV.@) * @@ -872,8 +899,6 @@ BOOL macdrv_GetCurrentDisplaySettings(LPCWSTR devname, BOOL is_primary, LPDEVMOD { struct macdrv_display *displays = NULL; int num_displays, display_idx; - CGDisplayModeRef display_mode; - CGDirectDisplayID display_id; WCHAR *end;
TRACE("%s, %u, %p + %hu\n", debugstr_w(devname), is_primary, devmode, devmode->dmSize); @@ -890,26 +915,7 @@ BOOL macdrv_GetCurrentDisplaySettings(LPCWSTR devname, BOOL is_primary, LPDEVMOD return FALSE; }
- display_id = displays[display_idx].displayID; - display_mode = CGDisplayCopyDisplayMode(display_id); - - devmode->dmPosition.x = CGRectGetMinX(displays[display_idx].frame); - devmode->dmPosition.y = CGRectGetMinY(displays[display_idx].frame); - devmode->dmFields |= DM_POSITION; - - display_mode_to_devmode(display_id, display_mode, devmode); - if (retina_enabled) - { - struct display_mode_descriptor *desc = create_original_display_mode_descriptor(display_id); - if (display_mode_matches_descriptor(display_mode, desc)) - { - devmode->dmPelsWidth *= 2; - devmode->dmPelsHeight *= 2; - } - free_display_mode_descriptor(desc); - } - - CFRelease(display_mode); + display_get_current_mode(&displays[display_idx], devmode); macdrv_free_displays(displays);
TRACE("current mode -- %dx%d-%dx%dx%dbpp @%d Hz",
From: Alexandros Frantzis alexandros.frantzis@collabora.com
Since setting the current mode also sets the registry settings (if not already set), we also remove the code that manually changes the registry settings.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com --- dlls/winemac.drv/display.c | 111 ++++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 46 deletions(-)
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index b93ebaaa5e7..14c09649211 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -1076,45 +1076,6 @@ done: return (err == kCGErrorSuccess); }
-/*********************************************************************** - * init_registry_display_settings - * - * Initialize registry display settings when new display devices are added. - */ -static void init_registry_display_settings(void) -{ - DEVMODEW dm = {.dmSize = sizeof(dm)}; - DISPLAY_DEVICEW dd = {sizeof(dd)}; - UNICODE_STRING str; - DWORD i = 0; - int ret; - - while (!NtUserEnumDisplayDevices(NULL, i++, &dd, 0)) - { - RtlInitUnicodeString(&str, dd.DeviceName); - - /* Skip if the device already has registry display settings */ - if (NtUserEnumDisplaySettings(&str, ENUM_REGISTRY_SETTINGS, &dm, 0)) - continue; - - if (!NtUserEnumDisplaySettings(&str, ENUM_CURRENT_SETTINGS, &dm, 0)) - { - ERR("Failed to query current display settings for %s.\n", wine_dbgstr_w(dd.DeviceName)); - continue; - } - - TRACE("Device %s current display mode %ux%u %ubits %uHz at %d,%d.\n", - wine_dbgstr_w(dd.DeviceName), (unsigned int)dm.dmPelsWidth, (unsigned int)dm.dmPelsHeight, - (unsigned int)dm.dmBitsPerPel, (unsigned int)dm.dmDisplayFrequency, (int)dm.dmPosition.x, (int)dm.dmPosition.y); - - ret = NtUserChangeDisplaySettings(&str, &dm, NULL, - CDS_GLOBAL | CDS_NORESET | CDS_UPDATEREGISTRY, NULL); - if (ret != DISP_CHANGE_SUCCESSFUL) - ERR("Failed to save registry display settings for %s, returned %d.\n", - wine_dbgstr_w(dd.DeviceName), ret); - } -} - /*********************************************************************** * macdrv_displays_changed * @@ -1133,25 +1094,63 @@ void macdrv_displays_changed(const macdrv_event *event) NtUserGetWindowThread(hwnd, NULL) == GetCurrentThreadId()) { macdrv_init_display_devices(TRUE); - init_registry_display_settings(); macdrv_resize_desktop(); } }
static BOOL force_display_devices_refresh;
+static BOOL is_same_devmode(const DEVMODEW *a, const DEVMODEW *b) +{ + return a->dmDisplayOrientation == b->dmDisplayOrientation && + a->dmDisplayFixedOutput == b->dmDisplayFixedOutput && + a->dmBitsPerPel == b->dmBitsPerPel && + a->dmPelsWidth == b->dmPelsWidth && + a->dmPelsHeight == b->dmPelsHeight && + a->dmDisplayFlags == b->dmDisplayFlags && + a->dmDisplayFrequency == b->dmDisplayFrequency; +} + +static const char *debugstr_devmodew(const DEVMODEW *devmode) +{ + char position[32] = {0}; + + if (devmode->dmFields & DM_POSITION) + { + snprintf(position, sizeof(position), " at (%d,%d)", + (int)devmode->dmPosition.x, (int)devmode->dmPosition.y); + } + + return wine_dbg_sprintf("%ux%u %ubits %uHz rotated %u degrees %sstretched %sinterlaced%s", + (unsigned int)devmode->dmPelsWidth, + (unsigned int)devmode->dmPelsHeight, + (unsigned int)devmode->dmBitsPerPel, + (unsigned int)devmode->dmDisplayFrequency, + (unsigned int)devmode->dmDisplayOrientation * 90, + devmode->dmDisplayFixedOutput == DMDFO_STRETCH ? "" : "un", + devmode->dmDisplayFlags & DM_INTERLACED ? "" : "non-", + position); +} + BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, BOOL force, void *param ) { struct macdrv_adapter *adapters, *adapter; struct macdrv_monitor *monitors, *monitor; struct macdrv_gpu *gpus, *gpu; - INT gpu_count, adapter_count, monitor_count, mode_count; + struct macdrv_display *displays, *display; + INT gpu_count, adapter_count, monitor_count, mode_count, display_count; DEVMODEW *mode, *modes; DWORD len;
if (!force && !force_display_devices_refresh) return TRUE; force_display_devices_refresh = FALSE;
+ if (macdrv_get_displays(&displays, &display_count)) + { + displays = NULL; + display_count = 0; + } + /* Initialize GPUs */ if (macdrv_get_gpus(&gpus, &gpu_count)) { @@ -1179,6 +1178,7 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
for (adapter = adapters; adapter < adapters + adapter_count; adapter++) { + DEVMODEW current_mode = { .dmSize = sizeof(current_mode) }; struct gdi_adapter gdi_adapter = { .id = adapter->id, @@ -1201,17 +1201,35 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage device_manager->add_monitor( &gdi_monitor, param ); }
+ /* Get the current mode */ + if (displays) + { + for (display = displays; display < displays + display_count; display++) + { + if (display->displayID == adapter->id) + { + display_get_current_mode(display, ¤t_mode); + break; + } + } + } + if (!(modes = display_get_modes(adapter->id, &mode_count))) break; TRACE("adapter: %#x, mode count: %d\n", adapter->id, mode_count);
/* Initialize modes */ for (mode = modes; mode < modes + mode_count; mode++) { - TRACE("mode: %dx%dx%dbpp @%d Hz, %sstretched %sinterlaced\n", (int)mode->dmPelsWidth, (int)mode->dmPelsHeight, - (int)mode->dmBitsPerPel, (int)mode->dmDisplayFrequency, - mode->dmDisplayFixedOutput == DMDFO_STRETCH ? "" : "un", - mode->dmDisplayFlags & DM_INTERLACED ? "" : "non-"); - device_manager->add_mode( mode, FALSE, param ); + if (is_same_devmode(mode, ¤t_mode)) + { + TRACE("current mode: %s\n", debugstr_devmodew(¤t_mode)); + device_manager->add_mode( ¤t_mode, TRUE, param ); + } + else + { + TRACE("mode: %s\n", debugstr_devmodew(mode)); + device_manager->add_mode( mode, FALSE, param ); + } }
free(modes); @@ -1222,6 +1240,7 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage }
macdrv_free_gpus(gpus); + macdrv_free_displays(displays); return TRUE; }
From: Alexandros Frantzis alexandros.frantzis@collabora.com
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- dlls/wineandroid.drv/init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c index 0ba8a0b3ebb..f2423d96407 100644 --- a/dlls/wineandroid.drv/init.c +++ b/dlls/wineandroid.drv/init.c @@ -289,13 +289,14 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag }; const DEVMODEW mode = { - .dmFields = DM_DISPLAYORIENTATION | DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY, + .dmFields = DM_DISPLAYORIENTATION | DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | + DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY | DM_POSITION, .dmBitsPerPel = screen_bpp, .dmPelsWidth = screen_width, .dmPelsHeight = screen_height, .dmDisplayFrequency = 60, }; device_manager->add_gpu( &gpu, param ); device_manager->add_adapter( &adapter, param ); device_manager->add_monitor( &gdi_monitor, param ); - device_manager->add_mode( &mode, FALSE, param ); + device_manager->add_mode( &mode, TRUE, param ); force_display_devices_refresh = FALSE; }
This merge request was approved by Rémi Bernon.
Approving assuming it builds on macOS, which I haven't checked :sweat_smile:
On Tue Apr 4 14:19:09 2023 +0000, Alexandros Frantzis wrote:
I have moved the `macdrv_get_displays()` outside the loop. I changed the behavior (compared to the last version) to (try) to populate the modes even when there are no macdrv_displays, since I am not certain about the expected mac semantics in terms of displays, adapters, modes etc (but I can reinstate if someone more familiar with this code can verify that this is the right thing to do).
I don't know much about `winemac` and I don't care as much as I do with `winex11` so I'm going to be very flexible about it :smile:. It just felt wrong to request the display list on every iteration.