[PATCH 0/2] MR6604: win32u: Pass rects in window DPI to MoveWindowBits.
This is used to move pixels when drawing directly to the host window. In this case, the DC operations are all in window DPI, and DPI scaling isn't supported. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6604
From: Rémi Bernon <rbernon(a)codeweavers.com> This is only called when surfaces are not used, which isn't the case on macOS. --- dlls/winemac.drv/gdi.c | 1 - dlls/winemac.drv/macdrv.h | 1 - dlls/winemac.drv/window.c | 76 --------------------------------------- 3 files changed, 78 deletions(-) diff --git a/dlls/winemac.drv/gdi.c b/dlls/winemac.drv/gdi.c index f5c4c5eb7f1..8592111521c 100644 --- a/dlls/winemac.drv/gdi.c +++ b/dlls/winemac.drv/gdi.c @@ -304,7 +304,6 @@ static const struct user_driver_funcs macdrv_funcs = .pImeProcessKey = macdrv_ImeProcessKey, .pNotifyIMEStatus = macdrv_NotifyIMEStatus, .pWindowMessage = macdrv_WindowMessage, - .pMoveWindowBits = macdrv_MoveWindowBits, .pWindowPosChanged = macdrv_WindowPosChanged, .pWindowPosChanging = macdrv_WindowPosChanging, .pGetWindowStyleMasks = macdrv_GetWindowStyleMasks, diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 76a1ffbed60..91e7a53dba9 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -153,7 +153,6 @@ extern void macdrv_SetLayeredWindowAttributes(HWND hwnd, COLORREF key, BYTE alph extern BOOL macdrv_WindowPosChanging(HWND hwnd, UINT swp_flags, BOOL shaped, const struct window_rects *rects); extern BOOL macdrv_GetWindowStyleMasks(HWND hwnd, UINT style, UINT ex_style, UINT *style_mask, UINT *ex_style_mask); extern BOOL macdrv_CreateWindowSurface(HWND hwnd, BOOL layered, const RECT *surface_rect, struct window_surface **surface); -extern void macdrv_MoveWindowBits(HWND hwnd, const struct window_rects *new_rects, const RECT *valid_rects); extern void macdrv_WindowPosChanged(HWND hwnd, HWND insert_after, UINT swp_flags, BOOL fullscreen, const struct window_rects *new_rects, struct window_surface *surface); extern void macdrv_DestroyCursorIcon(HCURSOR cursor); diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index bccb0caff16..d5b71434af3 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -1014,53 +1014,6 @@ static void sync_window_position(struct macdrv_win_data *data, UINT swp_flags, c } -/*********************************************************************** - * move_window_bits - * - * Move the window bits when a window is moved. - */ -static void move_window_bits(HWND hwnd, macdrv_window window, const RECT *old_rect, const RECT *new_rect, - const RECT *old_client_rect, const RECT *new_client_rect, - const RECT *new_window_rect) -{ - RECT src_rect = *old_rect; - RECT dst_rect = *new_rect; - HDC hdc_src, hdc_dst; - HRGN rgn; - HWND parent = 0; - - if (!window) - { - OffsetRect(&dst_rect, -new_window_rect->left, -new_window_rect->top); - parent = NtUserGetAncestor(hwnd, GA_PARENT); - hdc_src = NtUserGetDCEx(parent, 0, DCX_CACHE); - hdc_dst = NtUserGetDCEx(hwnd, 0, DCX_CACHE | DCX_WINDOW); - } - else - { - OffsetRect(&dst_rect, -new_client_rect->left, -new_client_rect->top); - /* make src rect relative to the old position of the window */ - OffsetRect(&src_rect, -old_client_rect->left, -old_client_rect->top); - if (dst_rect.left == src_rect.left && dst_rect.top == src_rect.top) return; - hdc_src = hdc_dst = NtUserGetDCEx(hwnd, 0, DCX_CACHE); - } - - rgn = NtGdiCreateRectRgn(dst_rect.left, dst_rect.top, dst_rect.right, dst_rect.bottom); - NtGdiExtSelectClipRgn(hdc_dst, rgn, RGN_COPY); - NtGdiDeleteObjectApp(rgn); - NtUserExcludeUpdateRgn(hdc_dst, hwnd); - - TRACE("copying bits for win %p/%p %s -> %s\n", hwnd, window, - wine_dbgstr_rect(&src_rect), wine_dbgstr_rect(&dst_rect)); - NtGdiBitBlt(hdc_dst, dst_rect.left, dst_rect.top, - dst_rect.right - dst_rect.left, dst_rect.bottom - dst_rect.top, - hdc_src, src_rect.left, src_rect.top, SRCCOPY, 0, 0); - - NtUserReleaseDC(hwnd, hdc_dst); - if (hdc_src != hdc_dst) NtUserReleaseDC(parent, hdc_src); -} - - /********************************************************************** * activate_on_following_focus */ @@ -1752,35 +1705,6 @@ BOOL macdrv_WindowPosChanging(HWND hwnd, UINT swp_flags, BOOL shaped, const stru return ret; } -/*********************************************************************** - * MoveWindowBits (MACDRV.@) - */ -void macdrv_MoveWindowBits(HWND hwnd, const struct window_rects *new_rects, const RECT *valid_rects) -{ - RECT old_visible_rect, old_client_rect; - struct macdrv_win_data *data; - macdrv_window window; - - if (!(data = get_win_data(hwnd))) return; - old_visible_rect = data->rects.visible; - old_client_rect = data->rects.client; - window = data->cocoa_window; - release_win_data(data); - - /* if all that happened is that the whole window moved, copy everything */ - if (EqualRect(&valid_rects[0], &new_rects->visible) && EqualRect(&valid_rects[1], &old_visible_rect)) - { - /* A Cocoa window's bits are moved automatically */ - if (!window && (valid_rects[0].left - valid_rects[1].left || valid_rects[0].top - valid_rects[1].top)) - move_window_bits(hwnd, 0, &old_visible_rect, &new_rects->visible, - &old_client_rect, &new_rects->client, &new_rects->window); - } - else - { - move_window_bits(hwnd, window, &valid_rects[1], &valid_rects[0], - &old_client_rect, &new_rects->client, &new_rects->window); - } -} /*********************************************************************** * GetWindowStyleMasks (X11DRV.@) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6604
From: Rémi Bernon <rbernon(a)codeweavers.com> This is used to move pixels when drawing directly to the host window. In this case, the DC operations are all in window DPI, and DPI scaling isn't supported. --- dlls/win32u/driver.c | 3 ++- dlls/win32u/window.c | 6 +----- dlls/winex11.drv/window.c | 18 ++++++++---------- dlls/winex11.drv/x11drv.h | 12 ++---------- include/wine/gdi_driver.h | 2 +- 5 files changed, 14 insertions(+), 27 deletions(-) diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c index 02478b18a8a..5ef417a9346 100644 --- a/dlls/win32u/driver.c +++ b/dlls/win32u/driver.c @@ -886,7 +886,8 @@ static BOOL nulldrv_CreateWindowSurface( HWND hwnd, BOOL layered, const RECT *su return FALSE; } -static void nulldrv_MoveWindowBits( HWND hwnd, const struct window_rects *new_rects, const RECT *valid_rects ) +static void nulldrv_MoveWindowBits( HWND hwnd, const struct window_rects *old_rects, + const struct window_rects *new_rects, const RECT *valid_rects ) { } diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index cb7b1f6e3a6..5ad846f5a89 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -2125,11 +2125,7 @@ static BOOL apply_window_pos( HWND hwnd, HWND insert_after, UINT swp_flags, stru if (surface_win && surface_win != hwnd) move_window_bits( hwnd, &new_rects->visible, &new_rects->visible, &new_rects->window, valid_rects ); else - { - rects[0] = map_dpi_rect( valid_rects[0], get_thread_dpi(), monitor_dpi ); - rects[1] = map_dpi_rect( valid_rects[1], get_thread_dpi(), monitor_dpi ); - user_driver->pMoveWindowBits( hwnd, &monitor_rects, rects ); - } + user_driver->pMoveWindowBits( hwnd, &old_rects, new_rects, valid_rects ); } user_driver->pWindowPosChanged( hwnd, insert_after, swp_flags, is_fullscreen, &monitor_rects, get_driver_window_surface( new_surface, monitor_dpi ) ); diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index f18ab302e5e..a4327398b8a 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1460,9 +1460,9 @@ static void move_window_bits( HWND hwnd, Window window, const RECT *old_rect, co /* map region to client rect since we are using DCX_WINDOW */ NtGdiOffsetRgn( rgn, new_window_rect->left - new_client_rect->left, new_window_rect->top - new_client_rect->top ); - redraw_window( hwnd, NULL, rgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ALLCHILDREN ); + NtUserRedrawWindow( hwnd, NULL, rgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ALLCHILDREN ); } - else redraw_window( hwnd, NULL, rgn, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN ); + else NtUserRedrawWindow( hwnd, NULL, rgn, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN ); NtGdiDeleteObjectApp( rgn ); } } @@ -2515,30 +2515,28 @@ BOOL X11DRV_WindowPosChanging( HWND hwnd, UINT swp_flags, BOOL shaped, const str /*********************************************************************** * MoveWindowBits (X11DRV.@) */ -void X11DRV_MoveWindowBits( HWND hwnd, const struct window_rects *new_rects, const RECT *valid_rects ) +void X11DRV_MoveWindowBits( HWND hwnd, const struct window_rects *old_rects, + const struct window_rects *new_rects, const RECT *valid_rects ) { - RECT old_visible_rect, old_client_rect; struct x11drv_win_data *data; Window window; if (!(data = get_win_data( hwnd ))) return; - old_visible_rect = data->rects.visible; - old_client_rect = data->rects.client; window = data->whole_window; release_win_data( data ); /* if all that happened is that the whole window moved, copy everything */ - if (EqualRect( &valid_rects[0], &new_rects->visible ) && EqualRect( &valid_rects[1], &old_visible_rect )) + if (EqualRect( &valid_rects[0], &new_rects->visible ) && EqualRect( &valid_rects[1], &old_rects->visible )) { /* if we have an X window the bits will be moved by the X server */ if (!window && (valid_rects[0].left - valid_rects[1].left || valid_rects[0].top - valid_rects[1].top)) - move_window_bits( hwnd, 0, &old_visible_rect, &new_rects->visible, - &old_client_rect, &new_rects->client, &new_rects->window ); + move_window_bits( hwnd, 0, &old_rects->visible, &new_rects->visible, + &old_rects->client, &new_rects->client, &new_rects->window ); } else { move_window_bits( hwnd, window, &valid_rects[1], &valid_rects[0], - &old_client_rect, &new_rects->client, &new_rects->window ); + &old_rects->client, &new_rects->client, &new_rects->window ); } } diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 02cba58f09f..74fa9c17973 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -244,7 +244,8 @@ extern LRESULT X11DRV_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) extern BOOL X11DRV_WindowPosChanging( HWND hwnd, UINT swp_flags, BOOL shaped, const struct window_rects *rects ); extern BOOL X11DRV_GetWindowStyleMasks( HWND hwnd, UINT style, UINT ex_style, UINT *style_mask, UINT *ex_style_mask ); extern BOOL X11DRV_CreateWindowSurface( HWND hwnd, BOOL layered, const RECT *surface_rect, struct window_surface **surface ); -extern void X11DRV_MoveWindowBits( HWND hwnd, const struct window_rects *new_rects, const RECT *valid_rects ); +extern void X11DRV_MoveWindowBits( HWND hwnd, const struct window_rects *old_rects, + const struct window_rects *new_rects, const RECT *valid_rects ); extern void X11DRV_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags, BOOL fullscreen, const struct window_rects *new_rects, struct window_surface *surface ); extern BOOL X11DRV_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param, @@ -881,15 +882,6 @@ static inline BOOL set_window_pos( HWND hwnd, HWND after, INT x, INT y, INT cx, return ret; } -/* per-monitor DPI aware NtUserRedrawWindow call */ -static inline BOOL redraw_window( HWND hwnd, const RECT *rect, HRGN hrgn, UINT flags ) -{ - UINT context = NtUserSetThreadDpiAwarenessContext( NTUSER_DPI_PER_MONITOR_AWARE_V2 ); - BOOL ret = NtUserRedrawWindow( hwnd, rect, hrgn, flags ); - NtUserSetThreadDpiAwarenessContext( context ); - return ret; -} - /* per-monitor DPI aware NtUserChildWindowFromPointEx call */ static inline HWND child_window_from_point( HWND parent, LONG x, LONG y, UINT flags ) { diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 8d628a426ae..66ab52754a0 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -386,7 +386,7 @@ struct user_driver_funcs BOOL (*pWindowPosChanging)(HWND,UINT,BOOL,const struct window_rects *); BOOL (*pGetWindowStyleMasks)(HWND,UINT,UINT,UINT*,UINT*); BOOL (*pCreateWindowSurface)(HWND,BOOL,const RECT *,struct window_surface**); - void (*pMoveWindowBits)(HWND,const struct window_rects *,const RECT *); + void (*pMoveWindowBits)(HWND,const struct window_rects *,const struct window_rects *,const RECT *); void (*pWindowPosChanged)(HWND,HWND,UINT,BOOL,const struct window_rects*,struct window_surface*); /* system parameters */ BOOL (*pSystemParametersInfo)(UINT,UINT,void*,UINT); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6604
participants (1)
-
Rémi Bernon