Aggregating all the rects of a window, instead of storing and passing them separately. This is in order to make future changes easier, where we would pass monitor DPI rects in addition to window DPI rects to the drivers for DPI scaling.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/window.c | 34 +++++++++++++++++----------------- include/wine/gdi_driver.h | 14 ++++++++++++++ 2 files changed, 31 insertions(+), 17 deletions(-)
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 8e1ec0370ed..88c52dfbf5f 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -2191,8 +2191,9 @@ BOOL WINAPI NtUserUpdateLayeredWindow( HWND hwnd, HDC hdc_dst, const POINT *pts_ const BLENDFUNCTION *blend, DWORD flags, const RECT *dirty ) { DWORD swp_flags = SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW; + struct window_rects new_rects; struct window_surface *surface; - RECT window_rect, client_rect, visible_rect, surface_rect; + RECT surface_rect; SIZE offset; BOOL ret = FALSE;
@@ -2204,20 +2205,20 @@ BOOL WINAPI NtUserUpdateLayeredWindow( HWND hwnd, HDC hdc_dst, const POINT *pts_ return FALSE; }
- get_window_rects( hwnd, COORDS_PARENT, &window_rect, &client_rect, get_thread_dpi() ); + get_window_rects( hwnd, COORDS_PARENT, &new_rects.window, &new_rects.client, get_thread_dpi() );
if (pts_dst) { - offset.cx = pts_dst->x - window_rect.left; - offset.cy = pts_dst->y - window_rect.top; - OffsetRect( &client_rect, offset.cx, offset.cy ); - OffsetRect( &window_rect, offset.cx, offset.cy ); + offset.cx = pts_dst->x - new_rects.window.left; + offset.cy = pts_dst->y - new_rects.window.top; + OffsetRect( &new_rects.client, offset.cx, offset.cy ); + OffsetRect( &new_rects.window, offset.cx, offset.cy ); swp_flags &= ~SWP_NOMOVE; } if (size) { - offset.cx = size->cx - (window_rect.right - window_rect.left); - offset.cy = size->cy - (window_rect.bottom - window_rect.top); + offset.cx = size->cx - (new_rects.window.right - new_rects.window.left); + offset.cy = size->cy - (new_rects.window.bottom - new_rects.window.top); if (size->cx <= 0 || size->cy <= 0) { RtlSetLastWin32Error( ERROR_INVALID_PARAMETER ); @@ -2228,25 +2229,24 @@ BOOL WINAPI NtUserUpdateLayeredWindow( HWND hwnd, HDC hdc_dst, const POINT *pts_ RtlSetLastWin32Error( ERROR_INCORRECT_SIZE ); return FALSE; } - client_rect.right += offset.cx; - client_rect.bottom += offset.cy; - window_rect.right += offset.cx; - window_rect.bottom += offset.cy; + new_rects.client.right += offset.cx; + new_rects.client.bottom += offset.cy; + new_rects.window.right += offset.cx; + new_rects.window.bottom += offset.cy; swp_flags &= ~SWP_NOSIZE; }
- TRACE( "window %p win %s client %s\n", hwnd, - wine_dbgstr_rect(&window_rect), wine_dbgstr_rect(&client_rect) ); + TRACE( "window %p new_rects %s\n", hwnd, debugstr_window_rects( &new_rects ) );
- surface = create_window_surface( hwnd, swp_flags, TRUE, &window_rect, &client_rect, &visible_rect, &surface_rect ); - apply_window_pos( hwnd, 0, swp_flags, surface, &window_rect, &client_rect, &visible_rect, NULL ); + surface = create_window_surface( hwnd, swp_flags, TRUE, &new_rects.window, &new_rects.client, &new_rects.visible, &surface_rect ); + apply_window_pos( hwnd, 0, swp_flags, surface, &new_rects.window, &new_rects.client, &new_rects.visible, NULL ); if (!surface) return FALSE;
if (!hdc_src || surface == &dummy_surface) ret = TRUE; else { BLENDFUNCTION src_blend = { AC_SRC_OVER, 0, 255, 0 }; - RECT rect = window_rect, src_rect; + RECT rect = new_rects.window, src_rect; HDC hdc = NULL;
OffsetRect( &rect, -rect.left, -rect.top ); diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index ec52c599175..6321740f41a 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -39,11 +39,25 @@ #include "ddk/d3dkmthk.h" #include "kbd.h" #include "wine/list.h" +#include "wine/debug.h"
struct gdi_dc_funcs; struct opengl_funcs; struct vulkan_funcs;
+struct window_rects +{ + RECT window; /* window area, including non-client frame */ + RECT client; /* client area, excluding non-client frame */ + RECT visible; /* area currently visible on the host screen, backed with a surface */ +}; + +static inline const char *debugstr_window_rects( const struct window_rects *rects ) +{ + return wine_dbg_sprintf( "{ window %s, client %s }", wine_dbgstr_rect( &rects->window ), + wine_dbgstr_rect( &rects->client ) ); +} + typedef struct gdi_physdev { const struct gdi_dc_funcs *funcs;
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/window.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 88c52dfbf5f..e196c148ffb 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -3492,8 +3492,9 @@ done: /* NtUserSetWindowPos implementation */ BOOL set_window_pos( WINDOWPOS *winpos, int parent_x, int parent_y ) { - RECT old_window_rect, old_client_rect, new_window_rect, new_client_rect, valid_rects[2], visible_rect, surface_rect; + RECT valid_rects[2], surface_rect; struct window_surface *surface; + struct window_rects old_rects, new_rects; UINT orig_flags, context; BOOL ret = FALSE;
@@ -3538,11 +3539,11 @@ BOOL set_window_pos( WINDOWPOS *winpos, int parent_x, int parent_y )
context = set_thread_dpi_awareness_context( get_window_dpi_awareness_context( winpos->hwnd ));
- if (!calc_winpos( winpos, &old_window_rect, &old_client_rect, - &new_window_rect, &new_client_rect )) goto done; + if (!calc_winpos( winpos, &old_rects.window, &old_rects.client, + &new_rects.window, &new_rects.client )) goto done;
/* Fix redundant flags */ - if (!fixup_swp_flags( winpos, &old_window_rect, parent_x, parent_y )) goto done; + if (!fixup_swp_flags( winpos, &old_rects.window, parent_x, parent_y )) goto done;
if((winpos->flags & (SWP_NOZORDER | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) != SWP_NOZORDER) { @@ -3552,13 +3553,13 @@ BOOL set_window_pos( WINDOWPOS *winpos, int parent_x, int parent_y )
/* Common operations */
- calc_ncsize( winpos, &old_window_rect, &old_client_rect, - &new_window_rect, &new_client_rect, valid_rects, parent_x, parent_y ); + calc_ncsize( winpos, &old_rects.window, &old_rects.client, + &new_rects.window, &new_rects.client, valid_rects, parent_x, parent_y );
- surface = create_window_surface( winpos->hwnd, winpos->flags, FALSE, &new_window_rect, &new_client_rect, - &visible_rect, &surface_rect ); + surface = create_window_surface( winpos->hwnd, winpos->flags, FALSE, &new_rects.window, &new_rects.client, + &new_rects.visible, &surface_rect ); if (!apply_window_pos( winpos->hwnd, winpos->hwndInsertAfter, winpos->flags, surface, - &new_window_rect, &new_client_rect, &visible_rect, valid_rects )) + &new_rects.window, &new_rects.client, &new_rects.visible, valid_rects )) { if (surface) window_surface_release( surface ); goto done; @@ -3617,10 +3618,10 @@ BOOL set_window_pos( WINDOWPOS *winpos, int parent_x, int parent_y ) /* WM_WINDOWPOSCHANGED is sent even if SWP_NOSENDCHANGING is set and always contains final window position. */ - winpos->x = new_window_rect.left; - winpos->y = new_window_rect.top; - winpos->cx = new_window_rect.right - new_window_rect.left; - winpos->cy = new_window_rect.bottom - new_window_rect.top; + winpos->x = new_rects.window.left; + winpos->y = new_rects.window.top; + winpos->cx = new_rects.window.right - new_rects.window.left; + winpos->cy = new_rects.window.bottom - new_rects.window.top; send_message( winpos->hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)winpos ); }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/window.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index e196c148ffb..88e247fb768 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -4342,8 +4342,9 @@ void update_window_state( HWND hwnd ) static const UINT swp_flags = SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW; UINT context; - RECT window_rect, client_rect, valid_rects[2], visible_rect, surface_rect; + RECT valid_rects[2], surface_rect; struct window_surface *surface; + struct window_rects new_rects;
if (!is_current_thread_window( hwnd )) { @@ -4352,11 +4353,13 @@ void update_window_state( HWND hwnd ) }
context = set_thread_dpi_awareness_context( get_window_dpi_awareness_context( hwnd )); - get_window_rects( hwnd, COORDS_PARENT, &window_rect, &client_rect, get_thread_dpi() ); - valid_rects[0] = valid_rects[1] = client_rect; + get_window_rects( hwnd, COORDS_PARENT, &new_rects.window, &new_rects.client, get_thread_dpi() ); + valid_rects[0] = valid_rects[1] = new_rects.client;
- surface = create_window_surface( hwnd, swp_flags, FALSE, &window_rect, &client_rect, &visible_rect, &surface_rect ); - apply_window_pos( hwnd, 0, swp_flags, surface, &window_rect, &client_rect, &visible_rect, valid_rects ); + surface = create_window_surface( hwnd, swp_flags, FALSE, &new_rects.window, &new_rects.client, + &new_rects.visible, &surface_rect ); + apply_window_pos( hwnd, 0, swp_flags, surface, &new_rects.window, &new_rects.client, + &new_rects.visible, valid_rects ); if (surface) window_surface_release( surface );
set_thread_dpi_awareness_context( context );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/window.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 88e247fb768..a4df1c06e7b 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -5232,11 +5232,12 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name, { UINT win_dpi, thread_dpi = get_thread_dpi(), context; struct window_surface *surface; + struct window_rects new_rects; CBT_CREATEWNDW cbtc; HWND hwnd, owner = 0; CREATESTRUCTW cs; INT sw = SW_SHOW; - RECT rect, visible_rect, surface_rect; + RECT surface_rect; WND *win;
static const WCHAR messageW[] = {'M','e','s','s','a','g','e'}; @@ -5405,13 +5406,16 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name,
if (cx < 0) cx = 0; if (cy < 0) cy = 0; - SetRect( &rect, cs.x, cs.y, cs.x + cx, cs.y + cy ); + SetRect( &new_rects.window, cs.x, cs.y, cs.x + cx, cs.y + cy ); /* check for wraparound */ - if (cs.x > 0x7fffffff - cx) rect.right = 0x7fffffff; - if (cs.y > 0x7fffffff - cy) rect.bottom = 0x7fffffff; + if (cs.x > 0x7fffffff - cx) new_rects.window.right = 0x7fffffff; + if (cs.y > 0x7fffffff - cy) new_rects.window.bottom = 0x7fffffff; + new_rects.client = new_rects.window;
- surface = create_window_surface( hwnd, SWP_NOZORDER | SWP_NOACTIVATE, FALSE, &rect, &rect, &visible_rect, &surface_rect ); - if (!apply_window_pos( hwnd, 0, SWP_NOZORDER | SWP_NOACTIVATE, surface, &rect, &rect, &visible_rect, NULL )) + surface = create_window_surface( hwnd, SWP_NOZORDER | SWP_NOACTIVATE, FALSE, &new_rects.window, &new_rects.client, + &new_rects.visible, &surface_rect ); + if (!apply_window_pos( hwnd, 0, SWP_NOZORDER | SWP_NOACTIVATE, surface, &new_rects.window, &new_rects.client, + &new_rects.visible, NULL )) { if (surface) window_surface_release( surface ); goto failed; @@ -5420,7 +5424,7 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name,
/* send WM_NCCREATE */
- TRACE( "hwnd %p cs %d,%d %dx%d %s\n", hwnd, cs.x, cs.y, cs.cx, cs.cy, wine_dbgstr_rect(&rect) ); + TRACE( "hwnd %p cs %d,%d %dx%d %s\n", hwnd, cs.x, cs.y, cs.cx, cs.cy, debugstr_window_rects(&new_rects) ); if (!send_message_timeout( hwnd, WM_NCCREATE, 0, (LPARAM)&cs, SMTO_NORMAL, 0, ansi )) { WARN( "%p: aborted by WM_NCCREATE\n", hwnd ); @@ -5438,19 +5442,21 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name,
/* send WM_NCCALCSIZE */
- if (get_window_rects( hwnd, COORDS_PARENT, &rect, NULL, win_dpi )) + if (get_window_rects( hwnd, COORDS_PARENT, &new_rects.window, NULL, win_dpi )) { /* yes, even if the CBT hook was called with HWND_TOP */ HWND insert_after = (get_window_long( hwnd, GWL_STYLE ) & WS_CHILD) ? HWND_BOTTOM : HWND_TOP; - RECT client_rect = rect; + new_rects.client = new_rects.window;
/* the rectangle is in screen coords for WM_NCCALCSIZE when wparam is FALSE */ - map_window_points( parent, 0, (POINT *)&client_rect, 2, win_dpi ); - send_message( hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&client_rect ); - map_window_points( 0, parent, (POINT *)&client_rect, 2, win_dpi ); - - surface = create_window_surface( hwnd, SWP_NOACTIVATE, FALSE, &rect, &client_rect, &visible_rect, &surface_rect ); - apply_window_pos( hwnd, insert_after, SWP_NOACTIVATE, surface, &rect, &client_rect, &visible_rect, NULL ); + map_window_points( parent, 0, (POINT *)&new_rects.client, 2, win_dpi ); + send_message( hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&new_rects.client ); + map_window_points( 0, parent, (POINT *)&new_rects.client, 2, win_dpi ); + + surface = create_window_surface( hwnd, SWP_NOACTIVATE, FALSE, &new_rects.window, &new_rects.client, + &new_rects.visible, &surface_rect ); + apply_window_pos( hwnd, insert_after, SWP_NOACTIVATE, surface, &new_rects.window, &new_rects.client, + &new_rects.visible, NULL ); if (surface) window_surface_release( surface ); } else goto failed; @@ -5469,9 +5475,9 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name,
if (!(win_get_flags( hwnd ) & WIN_NEED_SIZE)) { + RECT rect; get_window_rects( hwnd, COORDS_PARENT, NULL, &rect, win_dpi ); - send_message( hwnd, WM_SIZE, SIZE_RESTORED, - MAKELONG(rect.right-rect.left, rect.bottom-rect.top)); + send_message( hwnd, WM_SIZE, SIZE_RESTORED, MAKELONG( rect.right - rect.left, rect.bottom - rect.top ) ); send_message( hwnd, WM_MOVE, 0, MAKELONG( rect.left, rect.top ) ); }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/window.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-)
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index a4df1c06e7b..ce8d2b1cacf 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -3114,8 +3114,7 @@ static void map_dpi_winpos( WINDOWPOS *winpos ) /*********************************************************************** * calc_winpos */ -static BOOL calc_winpos( WINDOWPOS *winpos, RECT *old_window_rect, RECT *old_client_rect, - RECT *new_window_rect, RECT *new_client_rect ) +static BOOL calc_winpos( WINDOWPOS *winpos, struct window_rects *old_rects, struct window_rects *new_rects ) { WND *win;
@@ -3128,21 +3127,21 @@ static BOOL calc_winpos( WINDOWPOS *winpos, RECT *old_window_rect, RECT *old_cli win == WND_OTHER_PROCESS || win == WND_DESKTOP) return FALSE;
/* Calculate new position and size */ - get_window_rects( winpos->hwnd, COORDS_PARENT, old_window_rect, old_client_rect, get_thread_dpi() ); - *new_window_rect = *old_window_rect; - *new_client_rect = *old_client_rect; + get_window_rects( winpos->hwnd, COORDS_PARENT, &old_rects->window, &old_rects->client, get_thread_dpi() ); + old_rects->visible = win->visible_rect; + *new_rects = *old_rects;
if (!(winpos->flags & SWP_NOSIZE)) { if (win->dwStyle & WS_MINIMIZE) { - new_window_rect->right = new_window_rect->left + get_system_metrics( SM_CXMINIMIZED ); - new_window_rect->bottom = new_window_rect->top + get_system_metrics( SM_CYMINIMIZED ); + new_rects->window.right = new_rects->window.left + get_system_metrics( SM_CXMINIMIZED ); + new_rects->window.bottom = new_rects->window.top + get_system_metrics( SM_CYMINIMIZED ); } else { - new_window_rect->right = new_window_rect->left + winpos->cx; - new_window_rect->bottom = new_window_rect->top + winpos->cy; + new_rects->window.right = new_rects->window.left + winpos->cx; + new_rects->window.bottom = new_rects->window.top + winpos->cy; } }
@@ -3156,21 +3155,21 @@ static BOOL calc_winpos( WINDOWPOS *winpos, RECT *old_window_rect, RECT *old_cli winpos->x = -32000; winpos->y = -32000; } - new_window_rect->left = winpos->x; - new_window_rect->top = winpos->y; - new_window_rect->right += winpos->x - old_window_rect->left; - new_window_rect->bottom += winpos->y - old_window_rect->top; + new_rects->window.left = winpos->x; + new_rects->window.top = winpos->y; + new_rects->window.right += winpos->x - old_rects->window.left; + new_rects->window.bottom += winpos->y - old_rects->window.top;
- OffsetRect( new_client_rect, winpos->x - old_window_rect->left, - winpos->y - old_window_rect->top ); + OffsetRect( &new_rects->client, winpos->x - old_rects->window.left, + winpos->y - old_rects->window.top ); + OffsetRect( &new_rects->visible, winpos->x - old_rects->window.left, + winpos->y - old_rects->window.top ); } winpos->flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE;
- TRACE( "hwnd %p, after %p, swp %d,%d %dx%d flags %08x current %s style %08x new %s\n", - winpos->hwnd, winpos->hwndInsertAfter, winpos->x, winpos->y, - winpos->cx, winpos->cy, winpos->flags, - wine_dbgstr_rect( old_window_rect ), win->dwStyle, - wine_dbgstr_rect( new_window_rect )); + TRACE( "hwnd %p, after %p, swp %d,%d %dx%d flags %08x style %08x old_rects %s new_rects %s\n", + winpos->hwnd, winpos->hwndInsertAfter, winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags, win->dwStyle, + debugstr_window_rects( old_rects ), debugstr_window_rects( new_rects ) );
release_win_ptr( win ); return TRUE; @@ -3539,8 +3538,7 @@ BOOL set_window_pos( WINDOWPOS *winpos, int parent_x, int parent_y )
context = set_thread_dpi_awareness_context( get_window_dpi_awareness_context( winpos->hwnd ));
- if (!calc_winpos( winpos, &old_rects.window, &old_rects.client, - &new_rects.window, &new_rects.client )) goto done; + if (!calc_winpos( winpos, &old_rects, &new_rects )) goto done;
/* Fix redundant flags */ if (!fixup_swp_flags( winpos, &old_rects.window, parent_x, parent_y )) goto done;