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

win32u: Broadcast WM_DISPLAYCHANGE message on display settings change.

parent 59a76b3a
......@@ -2493,7 +2493,6 @@ static void test_WM_DISPLAYCHANGE(void)
/* Wait quite long for the message, screen setting changes can take some time */
res = WaitForSingleObject( displaychange_sem, 10000 );
ok( !res, "WaitForSingleObject returned %#lx\n", res );
todo_wine
ok( last_bpp == bpp, "got WM_DISPLAYCHANGE bpp %u\n", last_bpp );
}
else
......
......@@ -2460,6 +2460,7 @@ static BOOL all_detached_settings( const DEVMODEW *displays )
static LONG apply_display_settings( const WCHAR *devname, const DEVMODEW *devmode,
HWND hwnd, DWORD flags, void *lparam )
{
struct adapter *adapter;
DEVMODEW *displays;
LONG ret;
......@@ -2478,6 +2479,19 @@ static LONG apply_display_settings( const WCHAR *devname, const DEVMODEW *devmod
ret = user_driver->pChangeDisplaySettings( displays, hwnd, flags, lparam );
free( displays );
if (ret) return ret;
if ((adapter = find_adapter( NULL )))
{
DEVMODEW current_mode = {.dmSize = sizeof(DEVMODEW)};
user_driver->pGetCurrentDisplaySettings( adapter->dev.device_name, &current_mode );
adapter_release( adapter );
send_message_timeout( HWND_BROADCAST, WM_DISPLAYCHANGE, current_mode.dmBitsPerPel,
MAKELPARAM( current_mode.dmPelsWidth, current_mode.dmPelsHeight ),
SMTO_ABORTIFHUNG, 2000, FALSE );
}
return ret;
}
......
......@@ -832,20 +832,8 @@ LONG macdrv_ChangeDisplaySettings(LPDEVMODEW displays, HWND hwnd, DWORD flags, L
}
else if (macdrv_set_display_mode(&macdrv_displays[0], best_display_mode))
{
int mode_bpp = display_mode_bits_per_pixel(best_display_mode);
size_t width = CGDisplayModeGetWidth(best_display_mode);
size_t height = CGDisplayModeGetHeight(best_display_mode);
macdrv_init_display_devices(TRUE);
if (retina_enabled && display_mode_matches_descriptor(best_display_mode, desc))
{
width *= 2;
height *= 2;
}
send_message(NtUserGetDesktopWindow(), WM_MACDRV_UPDATE_DESKTOP_RECT, mode_bpp,
MAKELPARAM(width, height));
send_message(NtUserGetDesktopWindow(), WM_MACDRV_UPDATE_DESKTOP_RECT, 0, 0);
}
else
{
......@@ -1182,28 +1170,9 @@ void macdrv_displays_changed(const macdrv_event *event)
if (event->displays_changed.activating ||
NtUserGetWindowThread(hwnd, NULL) == GetCurrentThreadId())
{
CGDirectDisplayID mainDisplay = CGMainDisplayID();
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(mainDisplay);
size_t width = CGDisplayModeGetWidth(mode);
size_t height = CGDisplayModeGetHeight(mode);
int mode_bpp = display_mode_bits_per_pixel(mode);
struct display_mode_descriptor* desc = create_original_display_mode_descriptor(mainDisplay);
BOOL is_original = display_mode_matches_descriptor(mode, desc);
free_display_mode_descriptor(desc);
CGDisplayModeRelease(mode);
macdrv_init_display_devices(TRUE);
init_registry_display_settings();
if (is_original && retina_enabled)
{
width *= 2;
height *= 2;
}
send_message(hwnd, WM_MACDRV_UPDATE_DESKTOP_RECT, mode_bpp,
MAKELPARAM(width, height));
send_message(hwnd, WM_MACDRV_UPDATE_DESKTOP_RECT, 0, 0);
}
}
......
......@@ -2003,7 +2003,7 @@ LRESULT macdrv_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
NtUserSetWindowPos(hwnd, 0, CGRectGetMinX(new_desktop_rect), CGRectGetMinY(new_desktop_rect),
CGRectGetWidth(new_desktop_rect), CGRectGetHeight(new_desktop_rect),
SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE);
send_message_timeout(HWND_BROADCAST, WM_MACDRV_DISPLAYCHANGE, wp, lp,
send_message_timeout(HWND_BROADCAST, WM_MACDRV_DISPLAYCHANGE, 0, 0,
SMTO_ABORTIFHUNG, 2000, NULL);
}
}
......@@ -2013,7 +2013,6 @@ LRESULT macdrv_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
return 0;
case WM_MACDRV_DISPLAYCHANGE:
macdrv_reassert_window_position(hwnd);
send_message(hwnd, WM_DISPLAYCHANGE, wp, lp);
return 0;
case WM_MACDRV_ACTIVATE_ON_FOLLOWING_FOCUS:
activate_on_following_focus();
......
......@@ -454,7 +454,7 @@ static void update_desktop_fullscreen( unsigned int width, unsigned int height)
/***********************************************************************
* X11DRV_resize_desktop
*/
void X11DRV_resize_desktop( BOOL send_display_change )
void X11DRV_resize_desktop(void)
{
RECT primary_rect, virtual_rect;
HWND hwnd = NtUserGetDesktopWindow();
......@@ -467,7 +467,7 @@ void X11DRV_resize_desktop( BOOL send_display_change )
if (NtUserGetWindowThread( hwnd, NULL ) != GetCurrentThreadId())
{
send_message( hwnd, WM_X11DRV_RESIZE_DESKTOP, 0, (LPARAM)send_display_change );
send_message( hwnd, WM_X11DRV_RESIZE_DESKTOP, 0, 0 );
}
else
{
......@@ -477,11 +477,5 @@ void X11DRV_resize_desktop( BOOL send_display_change )
virtual_rect.right - virtual_rect.left, virtual_rect.bottom - virtual_rect.top,
SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE );
ungrab_clipping_window();
if (send_display_change)
{
send_message_timeout( HWND_BROADCAST, WM_DISPLAYCHANGE, screen_bpp, MAKELPARAM( width, height ),
SMTO_ABORTIFHUNG, 2000, NULL );
}
}
}
......@@ -419,7 +419,7 @@ LONG X11DRV_ChangeDisplaySettings( LPDEVMODEW displays, HWND hwnd, DWORD flags,
if (ret == DISP_CHANGE_SUCCESSFUL)
ret = apply_display_settings( displays, ids, TRUE );
if (ret == DISP_CHANGE_SUCCESSFUL)
X11DRV_DisplayDevices_Update(TRUE);
X11DRV_DisplayDevices_Update();
done:
free( ids );
......@@ -558,7 +558,7 @@ void X11DRV_DisplayDevices_RegisterEventHandlers(void)
handler->register_event_handlers();
}
void X11DRV_DisplayDevices_Update(BOOL send_display_change)
void X11DRV_DisplayDevices_Update(void)
{
RECT old_virtual_rect, new_virtual_rect;
DWORD tid, pid;
......@@ -576,7 +576,7 @@ void X11DRV_DisplayDevices_Update(BOOL send_display_change)
if (old_virtual_rect.top != new_virtual_rect.top)
mask |= CWY;
X11DRV_resize_desktop(send_display_change);
X11DRV_resize_desktop();
list = build_hwnd_list();
for (i = 0; list && list[i] != HWND_BOTTOM; i++)
......
......@@ -2993,7 +2993,7 @@ LRESULT X11DRV_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
}
return 0;
case WM_X11DRV_RESIZE_DESKTOP:
X11DRV_resize_desktop( (BOOL)lp );
X11DRV_resize_desktop();
return 0;
case WM_X11DRV_SET_CURSOR:
{
......
......@@ -745,7 +745,7 @@ struct x11drv_settings_handler
extern void X11DRV_Settings_SetHandler(const struct x11drv_settings_handler *handler) DECLSPEC_HIDDEN;
extern void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height ) DECLSPEC_HIDDEN;
extern void X11DRV_resize_desktop(BOOL) 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;
......@@ -804,7 +804,7 @@ extern BOOL get_host_primary_gpu(struct gdi_gpu *gpu) DECLSPEC_HIDDEN;
extern void X11DRV_DisplayDevices_SetHandler(const struct x11drv_display_device_handler *handler) DECLSPEC_HIDDEN;
extern void X11DRV_DisplayDevices_Init(BOOL force) DECLSPEC_HIDDEN;
extern void X11DRV_DisplayDevices_RegisterEventHandlers(void) DECLSPEC_HIDDEN;
extern void X11DRV_DisplayDevices_Update(BOOL) DECLSPEC_HIDDEN;
extern void X11DRV_DisplayDevices_Update(void) DECLSPEC_HIDDEN;
/* Display device handler used in virtual desktop mode */
extern struct x11drv_display_device_handler desktop_handler DECLSPEC_HIDDEN;
......
......@@ -1198,11 +1198,7 @@ static BOOL xrandr14_device_change_handler( HWND hwnd, XEvent *event )
xrandr14_invalidate_current_mode_cache();
if (hwnd == NtUserGetDesktopWindow() && NtUserGetWindowThread( hwnd, NULL ) == GetCurrentThreadId())
{
/* Don't send a WM_DISPLAYCHANGE message here because this event may be a result from
* ChangeDisplaySettings(). Otherwise, ChangeDisplaySettings() would send multiple
* WM_DISPLAYCHANGE messages instead of just one */
X11DRV_DisplayDevices_Update( FALSE );
X11DRV_DisplayDevices_Update();
init_registry_display_settings();
}
return FALSE;
......
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