winemac.drv: Resize desktop window on WM_DISPLAYCHANGE message.

This commit is contained in:
Rémi Bernon 2022-09-27 16:32:21 +02:00 committed by Alexandre Julliard
parent 63eeb236ed
commit 67d3735594
3 changed files with 25 additions and 26 deletions

View file

@ -831,10 +831,7 @@ LONG macdrv_ChangeDisplaySettings(LPDEVMODEW displays, HWND hwnd, DWORD flags, L
ret = DISP_CHANGE_BADMODE;
}
else if (macdrv_set_display_mode(&macdrv_displays[0], best_display_mode))
{
macdrv_init_display_devices(TRUE);
send_message(NtUserGetDesktopWindow(), WM_MACDRV_UPDATE_DESKTOP_RECT, 0, 0);
}
else
{
WARN("Failed to set display mode\n");
@ -1172,7 +1169,7 @@ void macdrv_displays_changed(const macdrv_event *event)
{
macdrv_init_display_devices(TRUE);
init_registry_display_settings();
send_message(hwnd, WM_MACDRV_UPDATE_DESKTOP_RECT, 0, 0);
macdrv_resize_desktop();
}
}

View file

@ -92,7 +92,6 @@ static inline RECT rect_from_cgrect(CGRect cgrect)
enum macdrv_window_messages
{
WM_MACDRV_SET_WIN_REGION = 0x80001000,
WM_MACDRV_UPDATE_DESKTOP_RECT,
WM_MACDRV_RESET_DEVICE_METRICS,
WM_MACDRV_DISPLAYCHANGE,
WM_MACDRV_ACTIVATE_ON_FOLLOWING_FOCUS,
@ -268,6 +267,7 @@ extern CGImageRef create_cgimage_from_icon_bitmaps(HDC hdc, HANDLE icon, HBITMAP
extern void check_retina_status(void) DECLSPEC_HIDDEN;
extern void macdrv_init_display_devices(BOOL force) DECLSPEC_HIDDEN;
extern void macdrv_resize_desktop(void) DECLSPEC_HIDDEN;
extern void init_user_driver(void) DECLSPEC_HIDDEN;
/* unixlib interface */

View file

@ -1570,6 +1570,26 @@ BOOL macdrv_CreateDesktopWindow(HWND hwnd)
return TRUE;
}
void macdrv_resize_desktop(void)
{
HWND hwnd = NtUserGetDesktopWindow();
CGRect new_desktop_rect;
RECT current_desktop_rect;
macdrv_reset_device_metrics();
new_desktop_rect = macdrv_get_desktop_rect();
if (!NtUserGetWindowRect(hwnd, &current_desktop_rect) ||
!CGRectEqualToRect(cgrect_from_rect(current_desktop_rect), new_desktop_rect))
{
send_message_timeout(HWND_BROADCAST, WM_MACDRV_RESET_DEVICE_METRICS, 0, 0,
SMTO_ABORTIFHUNG, 2000, NULL);
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, 0, 0,
SMTO_ABORTIFHUNG, 2000, NULL);
}
}
#define WM_WINE_NOTIFY_ACTIVITY WM_USER
@ -1591,6 +1611,9 @@ LRESULT macdrv_DesktopWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
#pragma clang diagnostic pop
break;
}
case WM_DISPLAYCHANGE:
macdrv_resize_desktop();
break;
}
return NtUserMessageCall(hwnd, msg, wp, lp, 0, NtUserDefWindowProc, FALSE);
}
@ -1987,27 +2010,6 @@ LRESULT macdrv_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
release_win_data(data);
}
return 0;
case WM_MACDRV_UPDATE_DESKTOP_RECT:
if (hwnd == NtUserGetDesktopWindow())
{
CGRect new_desktop_rect;
RECT current_desktop_rect;
macdrv_reset_device_metrics();
new_desktop_rect = macdrv_get_desktop_rect();
if (!NtUserGetWindowRect(hwnd, &current_desktop_rect) ||
!CGRectEqualToRect(cgrect_from_rect(current_desktop_rect), new_desktop_rect))
{
send_message_timeout(HWND_BROADCAST, WM_MACDRV_RESET_DEVICE_METRICS, 0, 0,
SMTO_ABORTIFHUNG, 2000, NULL);
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, 0, 0,
SMTO_ABORTIFHUNG, 2000, NULL);
}
}
return 0;
case WM_MACDRV_RESET_DEVICE_METRICS:
macdrv_reset_device_metrics();
return 0;