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 | 76 +++++++++++++++++++------------------- dlls/winex11.drv/x11drv.h | 1 - dlls/winex11.drv/xrandr.c | 1 - 3 files changed, 39 insertions(+), 39 deletions(-)
diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index e675194b9fd..ab7a12a981a 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; @@ -551,6 +516,32 @@ BOOL X11DRV_DisplayDevices_SupportEventHandlers(void)
static BOOL force_display_devices_refresh;
+static BOOL is_same_devmode( const DEVMODEW *a, const DEVMODEW *b ) +{ + static const DWORD fields = DM_DISPLAYORIENTATION | DM_DISPLAYFIXEDOUTPUT | + DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | + DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY; + + if ((a->dmFields & fields) != (b->dmFields & fields)) return FALSE; + + if ((a->dmFields & DM_DISPLAYORIENTATION) && a->dmDisplayOrientation != b->dmDisplayOrientation) + return FALSE; + if ((a->dmFields & DM_DISPLAYFIXEDOUTPUT) && a->dmDisplayFixedOutput != b->dmDisplayFixedOutput) + return FALSE; + if ((a->dmFields & DM_BITSPERPEL) && a->dmBitsPerPel != b->dmBitsPerPel) + return FALSE; + if ((a->dmFields & DM_PELSWIDTH) && a->dmPelsWidth != b->dmPelsWidth) + return FALSE; + if ((a->dmFields & DM_PELSHEIGHT) && a->dmPelsHeight != b->dmPelsHeight) + return FALSE; + if ((a->dmFields & DM_DISPLAYFLAGS) && a->dmDisplayFlags != b->dmDisplayFlags) + return FALSE; + if ((a->dmFields & DM_DISPLAYFREQUENCY) && a->dmDisplayFrequency != b->dmDisplayFrequency) + return FALSE; + + return TRUE; +} + BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, BOOL force, void *param ) { struct x11drv_display_device_handler *handler; @@ -582,6 +573,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; @@ -593,13 +586,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() */