-- v3: win32u: Pass the rect DPI to NtUserIsWindowRectFullScreen. win32u: Introduce a new get_monitor_rect helper. win32u: Pass desired DPI to NtUserGet(Client|Window)Rect. win32u: Introduce NtUserAdjustWindowRect call for AdjustWindowRect*. win32u: Introduce new helpers to convert server rectangle_t.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/dce.c | 15 +++-------- dlls/win32u/input.c | 47 +++++++---------------------------- dlls/win32u/message.c | 5 +--- dlls/win32u/window.c | 31 ++++------------------- dlls/wineandroid.drv/window.c | 5 +--- dlls/winex11.drv/event.c | 5 +--- dlls/winex11.drv/mouse.c | 5 +--- dlls/winex11.drv/window.c | 5 +--- include/wine/server.h | 26 +++++++++++++++++++ 9 files changed, 49 insertions(+), 95 deletions(-)
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index 57a3ae59eff..2458b65d1de 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -417,17 +417,10 @@ static void update_visible_region( struct dce *dce ) data->rdh.nCount = reply_size / sizeof(RECT); data->rdh.nRgnSize = reply_size; vis_rgn = NtGdiExtCreateRegion( NULL, data->rdh.dwSize + data->rdh.nRgnSize, data ); - - top_win = wine_server_ptr_handle( reply->top_win ); - win_rect.left = reply->win_rect.left; - win_rect.top = reply->win_rect.top; - win_rect.right = reply->win_rect.right; - win_rect.bottom = reply->win_rect.bottom; - top_rect.left = reply->top_rect.left; - top_rect.top = reply->top_rect.top; - top_rect.right = reply->top_rect.right; - top_rect.bottom = reply->top_rect.bottom; - paint_flags = reply->paint_flags; + top_win = wine_server_ptr_handle( reply->top_win ); + win_rect = wine_server_get_rect( reply->win_rect ); + top_rect = wine_server_get_rect( reply->top_rect ); + paint_flags = reply->paint_flags; } else size = reply->total_size; } diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index b305e00b1a3..cddcfd22081 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -2219,10 +2219,7 @@ BOOL WINAPI NtUserCreateCaret( HWND hwnd, HBITMAP bitmap, int width, int height if ((ret = !wine_server_call_err( req ))) { prev = wine_server_ptr_handle( reply->previous ); - r.left = reply->old_rect.left; - r.top = reply->old_rect.top; - r.right = reply->old_rect.right; - r.bottom = reply->old_rect.bottom; + r = wine_server_get_rect( reply->old_rect ); old_state = reply->old_state; hidden = reply->old_hide; } @@ -2262,10 +2259,7 @@ BOOL destroy_caret(void) if ((ret = !wine_server_call_err( req ))) { prev = wine_server_ptr_handle( reply->previous ); - r.left = reply->old_rect.left; - r.top = reply->old_rect.top; - r.right = reply->old_rect.right; - r.bottom = reply->old_rect.bottom; + r = wine_server_get_rect( reply->old_rect ); old_state = reply->old_state; hidden = reply->old_hide; } @@ -2352,10 +2346,7 @@ BOOL set_caret_pos( int x, int y ) if ((ret = !wine_server_call_err( req ))) { hwnd = wine_server_ptr_handle( reply->full_handle ); - r.left = reply->old_rect.left; - r.top = reply->old_rect.top; - r.right = reply->old_rect.right; - r.bottom = reply->old_rect.bottom; + r = wine_server_get_rect( reply->old_rect ); old_state = reply->old_state; hidden = reply->old_hide; } @@ -2394,10 +2385,7 @@ BOOL WINAPI NtUserShowCaret( HWND hwnd ) if ((ret = !wine_server_call_err( req ))) { hwnd = wine_server_ptr_handle( reply->full_handle ); - r.left = reply->old_rect.left; - r.top = reply->old_rect.top; - r.right = reply->old_rect.right; - r.bottom = reply->old_rect.bottom; + r = wine_server_get_rect( reply->old_rect ); hidden = reply->old_hide; } } @@ -2432,10 +2420,7 @@ BOOL WINAPI NtUserHideCaret( HWND hwnd ) if ((ret = !wine_server_call_err( req ))) { hwnd = wine_server_ptr_handle( reply->full_handle ); - r.left = reply->old_rect.left; - r.top = reply->old_rect.top; - r.right = reply->old_rect.right; - r.bottom = reply->old_rect.bottom; + r = wine_server_get_rect( reply->old_rect ); old_state = reply->old_state; hidden = reply->old_hide; } @@ -2467,10 +2452,7 @@ void toggle_caret( HWND hwnd ) if ((ret = !wine_server_call( req ))) { hwnd = wine_server_ptr_handle( reply->full_handle ); - r.left = reply->old_rect.left; - r.top = reply->old_rect.top; - r.right = reply->old_rect.right; - r.bottom = reply->old_rect.bottom; + r = wine_server_get_rect( reply->old_rect ); hidden = reply->old_hide; } } @@ -2550,10 +2532,7 @@ BOOL clip_fullscreen_window( HWND hwnd, BOOL reset ) SERVER_START_REQ( set_cursor ) { req->flags = SET_CURSOR_CLIP | SET_CURSOR_FSCLIP; - req->clip.left = monitor_info.rcMonitor.left; - req->clip.top = monitor_info.rcMonitor.top; - req->clip.right = monitor_info.rcMonitor.right; - req->clip.bottom = monitor_info.rcMonitor.bottom; + req->clip = wine_server_rectangle( monitor_info.rcMonitor ); ret = !wine_server_call( req ); } SERVER_END_REQ; @@ -2584,12 +2563,7 @@ BOOL get_clip_cursor( RECT *rect ) { req->flags = 0; if ((ret = !wine_server_call( req ))) - { - rect->left = reply->new_clip.left; - rect->top = reply->new_clip.top; - rect->right = reply->new_clip.right; - rect->bottom = reply->new_clip.bottom; - } + *rect = wine_server_get_rect( reply->new_clip ); } SERVER_END_REQ;
@@ -2664,10 +2638,7 @@ BOOL WINAPI NtUserClipCursor( const RECT *rect ) if (rect) { req->flags = SET_CURSOR_CLIP; - req->clip.left = rect->left; - req->clip.top = rect->top; - req->clip.right = rect->right; - req->clip.bottom = rect->bottom; + req->clip = wine_server_rectangle( *rect ); } else req->flags = SET_CURSOR_NOCLIP;
diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index 877be545810..0f0fe22db33 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -2160,10 +2160,7 @@ BOOL WINAPI NtUserGetGUIThreadInfo( DWORD id, GUITHREADINFO *info ) info->hwndMenuOwner = wine_server_ptr_handle( reply->menu_owner ); info->hwndMoveSize = wine_server_ptr_handle( reply->move_size ); info->hwndCaret = wine_server_ptr_handle( reply->caret ); - info->rcCaret.left = reply->rect.left; - info->rcCaret.top = reply->rect.top; - info->rcCaret.right = reply->rect.right; - info->rcCaret.bottom = reply->rect.bottom; + info->rcCaret = wine_server_get_rect( reply->rect ); if (reply->menu_owner) info->flags |= GUI_INMENUMODE; if (reply->move_size) info->flags |= GUI_INMOVESIZE; if (reply->caret) info->flags |= GUI_CARETBLINKING; diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 0122ac2e4f7..06067a95892 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -1667,20 +1667,8 @@ other_process: req->dpi = dpi; if ((ret = !wine_server_call_err( req ))) { - if (window_rect) - { - window_rect->left = reply->window.left; - window_rect->top = reply->window.top; - window_rect->right = reply->window.right; - window_rect->bottom = reply->window.bottom; - } - if (client_rect) - { - client_rect->left = reply->client.left; - client_rect->top = reply->client.top; - client_rect->right = reply->client.right; - client_rect->bottom = reply->client.bottom; - } + if (window_rect) *window_rect = wine_server_get_rect( reply->window ); + if (client_rect) *client_rect = wine_server_get_rect( reply->client ); } } SERVER_END_REQ; @@ -1743,10 +1731,7 @@ static NTSTATUS get_window_region( HWND hwnd, BOOL surface, HRGN *region, RECT * data->rdh.nCount = reply_size / sizeof(RECT); data->rdh.nRgnSize = reply_size; *region = NtGdiExtCreateRegion( NULL, data->rdh.dwSize + data->rdh.nRgnSize, data ); - visible->left = reply->visible_rect.left; - visible->top = reply->visible_rect.top; - visible->right = reply->visible_rect.right; - visible->bottom = reply->visible_rect.bottom; + *visible = wine_server_get_rect( reply->visible_rect ); } } else size = reply->total_size; @@ -1861,14 +1846,8 @@ static BOOL apply_window_pos( HWND hwnd, HWND insert_after, UINT swp_flags, req->handle = wine_server_user_handle( hwnd ); req->previous = wine_server_user_handle( insert_after ); req->swp_flags = swp_flags; - req->window.left = window_rect->left; - req->window.top = window_rect->top; - req->window.right = window_rect->right; - req->window.bottom = window_rect->bottom; - req->client.left = client_rect->left; - req->client.top = client_rect->top; - req->client.right = client_rect->right; - req->client.bottom = client_rect->bottom; + req->window = wine_server_rectangle( *window_rect ); + req->client = wine_server_rectangle( *client_rect ); if (!EqualRect( window_rect, &visible_rect ) || new_surface || valid_rects) { extra_rects[0] = extra_rects[1] = visible_rect; diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index 19900c7e509..5e095288f91 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -499,10 +499,7 @@ static int process_events( DWORD mask ) SERVER_START_REQ( update_window_zorder ) { req->window = wine_server_user_handle( event->data.motion.hwnd ); - req->rect.left = rect.left; - req->rect.top = rect.top; - req->rect.right = rect.right; - req->rect.bottom = rect.bottom; + req->rect = wine_server_rectangle( rect ); wine_server_call( req ); } SERVER_END_REQ; diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 3e9e0254c91..2bc80cea5e9 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -922,10 +922,7 @@ static BOOL X11DRV_Expose( HWND hwnd, XEvent *xev ) SERVER_START_REQ( update_window_zorder ) { req->window = wine_server_user_handle( hwnd ); - req->rect.left = abs_rect.left; - req->rect.top = abs_rect.top; - req->rect.right = abs_rect.right; - req->rect.bottom = abs_rect.bottom; + req->rect = wine_server_rectangle( abs_rect ); wine_server_call( req ); } SERVER_END_REQ; diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index 7293480b635..1196986424d 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -564,10 +564,7 @@ static void send_mouse_input( HWND hwnd, Window window, unsigned int state, INPU SERVER_START_REQ( update_window_zorder ) { req->window = wine_server_user_handle( hwnd ); - req->rect.left = rect.left; - req->rect.top = rect.top; - req->rect.right = rect.right; - req->rect.bottom = rect.bottom; + req->rect = wine_server_rectangle( rect ); wine_server_call( req ); } SERVER_END_REQ; diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index f2ffbebcc7c..925c5d7e61b 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -2001,10 +2001,7 @@ void X11DRV_SetDesktopWindow( HWND hwnd ) req->handle = wine_server_user_handle( hwnd ); req->previous = 0; req->swp_flags = SWP_NOZORDER; - req->window.left = rect.left; - req->window.top = rect.top; - req->window.right = rect.right; - req->window.bottom = rect.bottom; + req->window = wine_server_rectangle( rect ); req->client = req->window; wine_server_call( req ); } diff --git a/include/wine/server.h b/include/wine/server.h index 87b43c7e63f..081c71492fa 100644 --- a/include/wine/server.h +++ b/include/wine/server.h @@ -118,6 +118,32 @@ static inline void *wine_server_get_ptr( client_ptr_t ptr ) return (void *)(ULONG_PTR)ptr; }
+/* convert a server rectangle_t to a RECT */ +static inline RECT wine_server_get_rect( rectangle_t rectangle ) +{ + RECT rect = + { + .left = rectangle.left, + .top = rectangle.top, + .right = rectangle.right, + .bottom = rectangle.bottom, + }; + return rect; +} + +/* convert a RECT to a server rectangle_t */ +static inline rectangle_t wine_server_rectangle( RECT rect ) +{ + rectangle_t rectangle = + { + .left = rect.left, + .top = rect.top, + .right = rect.right, + .bottom = rect.bottom, + }; + return rectangle; +} +
/* macros for server requests */
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/user32/nonclient.c | 78 ------------------------------------ dlls/user32/sysparams.c | 30 ++++++++++++++ dlls/win32u/defwnd.c | 13 +++--- dlls/win32u/sysparams.c | 6 +++ dlls/win32u/win32u_private.h | 1 + dlls/win32u/window.c | 2 +- dlls/winemac.drv/window.c | 21 ++++++++-- dlls/winex11.drv/window.c | 13 +++++- include/ntuser.h | 21 ++++++++++ 9 files changed, 93 insertions(+), 92 deletions(-)
diff --git a/dlls/user32/nonclient.c b/dlls/user32/nonclient.c index b28e9e258da..d65e7c9864c 100644 --- a/dlls/user32/nonclient.c +++ b/dlls/user32/nonclient.c @@ -22,42 +22,9 @@ #include "controls.h" #include "wine/debug.h"
-WINE_DEFAULT_DEBUG_CHANNEL(nonclient);
#define SC_ABOUTWINE (SC_SCREENSAVE+1)
- -static void adjust_window_rect( RECT *rect, DWORD style, BOOL menu, DWORD exStyle, NONCLIENTMETRICSW *ncm ) -{ - int adjust = 0; - - if ((exStyle & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) == WS_EX_STATICEDGE) - adjust = 1; /* for the outer frame always present */ - else if ((exStyle & WS_EX_DLGMODALFRAME) || (style & (WS_THICKFRAME|WS_DLGFRAME))) - adjust = 2; /* outer */ - - if (style & WS_THICKFRAME) - adjust += ncm->iBorderWidth + ncm->iPaddedBorderWidth; /* The resize border */ - - if ((style & (WS_BORDER|WS_DLGFRAME)) || (exStyle & WS_EX_DLGMODALFRAME)) - adjust++; /* The other border */ - - InflateRect (rect, adjust, adjust); - - if ((style & WS_CAPTION) == WS_CAPTION) - { - if (exStyle & WS_EX_TOOLWINDOW) - rect->top -= ncm->iSmCaptionHeight + 1; - else - rect->top -= ncm->iCaptionHeight + 1; - } - if (menu) rect->top -= ncm->iMenuHeight + 1; - - if (exStyle & WS_EX_CLIENTEDGE) - InflateRect(rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE)); -} - - /*********************************************************************** * DrawCaption (USER32.@) Draws a caption bar */ @@ -91,51 +58,6 @@ BOOL WINAPI DrawCaptionTempA (HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont, }
-/*********************************************************************** - * AdjustWindowRect (USER32.@) - */ -BOOL WINAPI DECLSPEC_HOTPATCH AdjustWindowRect( LPRECT rect, DWORD style, BOOL menu ) -{ - return AdjustWindowRectEx( rect, style, menu, 0 ); -} - - -/*********************************************************************** - * AdjustWindowRectEx (USER32.@) - */ -BOOL WINAPI DECLSPEC_HOTPATCH AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle ) -{ - NONCLIENTMETRICSW ncm; - - TRACE("(%s) %08lx %d %08lx\n", wine_dbgstr_rect(rect), style, menu, exStyle ); - - ncm.cbSize = sizeof(ncm); - SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); - - adjust_window_rect( rect, style, menu, exStyle, &ncm ); - return TRUE; -} - - -/*********************************************************************** - * AdjustWindowRectExForDpi (USER32.@) - */ -BOOL WINAPI DECLSPEC_HOTPATCH AdjustWindowRectExForDpi( LPRECT rect, DWORD style, BOOL menu, - DWORD exStyle, UINT dpi ) -{ - NONCLIENTMETRICSW ncm; - - TRACE("(%s) %08lx %d %08lx %u\n", wine_dbgstr_rect(rect), style, menu, exStyle, dpi ); - - ncm.cbSize = sizeof(ncm); - SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi ); - - adjust_window_rect( rect, style, menu, exStyle, &ncm ); - return TRUE; -} - - - /*********************************************************************** * NC_HandleSysCommand * diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index 2ec970fe1ac..273dccc6930 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -1026,3 +1026,33 @@ LONG WINAPI SetDisplayConfig(UINT32 path_info_count, DISPLAYCONFIG_PATH_INFO *pa
return ERROR_SUCCESS; } + + +/*********************************************************************** + * AdjustWindowRect (USER32.@) + */ +BOOL WINAPI DECLSPEC_HOTPATCH AdjustWindowRect( RECT *rect, DWORD style, BOOL menu ) +{ + TRACE( "(%s) %08lx %d\n", wine_dbgstr_rect( rect ), style, menu ); + return NtUserAdjustWindowRect( rect, style, menu, 0, system_dpi ); +} + + +/*********************************************************************** + * AdjustWindowRectEx (USER32.@) + */ +BOOL WINAPI DECLSPEC_HOTPATCH AdjustWindowRectEx( RECT *rect, DWORD style, BOOL menu, DWORD ex_style ) +{ + TRACE( "(%s) %08lx %d %08lx\n", wine_dbgstr_rect( rect ), style, menu, ex_style ); + return NtUserAdjustWindowRect( rect, style, menu, ex_style, system_dpi ); +} + + +/*********************************************************************** + * AdjustWindowRectExForDpi (USER32.@) + */ +BOOL WINAPI DECLSPEC_HOTPATCH AdjustWindowRectExForDpi( RECT *rect, DWORD style, BOOL menu, DWORD ex_style, UINT dpi ) +{ + TRACE( "(%s) %08lx %d %08lx %u\n", wine_dbgstr_rect( rect ), style, menu, ex_style, dpi ); + return NtUserAdjustWindowRect( rect, style, menu, ex_style, dpi ); +} diff --git a/dlls/win32u/defwnd.c b/dlls/win32u/defwnd.c index b0a5af26d2b..ceb1ed2694e 100644 --- a/dlls/win32u/defwnd.c +++ b/dlls/win32u/defwnd.c @@ -250,16 +250,13 @@ BOOL draw_rect_edge( HDC hdc, RECT *rc, UINT type, UINT flags, UINT width ) return retval; }
-/*********************************************************************** - * AdjustWindowRectEx (win32u.so) - */ -BOOL WINAPI AdjustWindowRectEx( RECT *rect, DWORD style, BOOL menu, DWORD ex_style ) +/* see AdjustWindowRectExForDpi */ +BOOL adjust_window_rect( RECT *rect, DWORD style, BOOL menu, DWORD ex_style, UINT dpi ) { - NONCLIENTMETRICSW ncm; + NONCLIENTMETRICSW ncm = {.cbSize = sizeof(ncm)}; int adjust = 0;
- ncm.cbSize = sizeof(ncm); - NtUserSystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); + NtUserSystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
if ((ex_style & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) == WS_EX_STATICEDGE) adjust = 1; /* for the outer frame always present */ @@ -1856,7 +1853,7 @@ static void handle_nc_calc_size( HWND hwnd, WPARAM wparam, RECT *win_rect )
if (!(style & WS_MINIMIZE)) { - AdjustWindowRectEx( &rect, style, FALSE, ex_style & ~WS_EX_CLIENTEDGE ); + adjust_window_rect( &rect, style, FALSE, ex_style & ~WS_EX_CLIENTEDGE, get_system_dpi() );
win_rect->left -= rect.left; win_rect->top -= rect.top; diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index db23795d57c..f4287c15a5f 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -6474,6 +6474,12 @@ ULONG_PTR WINAPI NtUserCallTwoParam( ULONG_PTR arg1, ULONG_PTR arg2, ULONG code case NtUserCallTwoParam_UnhookWindowsHook: return unhook_windows_hook( arg1, (HOOKPROC)arg2 );
+ case NtUserCallTwoParam_AdjustWindowRect: + { + struct adjust_window_rect_params *params = (void *)arg2; + return adjust_window_rect( (RECT *)arg1, params->style, params->menu, params->ex_style, params->dpi ); + } + /* temporary exports */ case NtUserAllocWinProc: return (UINT_PTR)alloc_winproc( (WNDPROC)arg1, arg2 ); diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 6539fb0bff1..6a6b732d270 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -57,6 +57,7 @@ extern void register_window_surface( struct window_surface *old, struct window_surface *new );
/* defwnd.c */ +extern BOOL adjust_window_rect( RECT *rect, DWORD style, BOOL menu, DWORD ex_style, UINT dpi ); extern LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, BOOL ansi ); extern LRESULT desktop_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ); diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 06067a95892..4ca6d1e7344 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -3843,7 +3843,7 @@ MINMAXINFO get_min_max_info( HWND hwnd ) adjusted_style = style;
get_client_rect( NtUserGetAncestor( hwnd, GA_PARENT ), &rc ); - AdjustWindowRectEx( &rc, adjusted_style, (style & WS_POPUP) && get_menu( hwnd ), exstyle ); + adjust_window_rect( &rc, adjusted_style, (style & WS_POPUP) && get_menu( hwnd ), exstyle, get_system_dpi() );
xinc = -rc.left; yinc = -rc.top; diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 0bc3bf62add..7ff792dd8ba 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -46,6 +46,15 @@ static CFMutableDictionaryRef win_datas; static unsigned int activate_on_focus_time;
+/********************************************************************** + * get_win_monitor_dpi + */ +static UINT get_win_monitor_dpi(HWND hwnd) +{ + return NtUserGetSystemDpiForProcess(NULL); /* FIXME: get monitor dpi */ +} + + /*********************************************************************** * get_cocoa_window_features */ @@ -133,6 +142,7 @@ static void get_mac_rect_offset(struct macdrv_win_data *data, unsigned int style const RECT *window_rect, const RECT *client_rect) { unsigned int ex_style, style_mask = 0, ex_style_mask = 0; + UINT dpi = get_win_monitor_dpi(data->hwnd);
rect->top = rect->bottom = rect->left = rect->right = 0;
@@ -155,7 +165,7 @@ static void get_mac_rect_offset(struct macdrv_win_data *data, unsigned int style } }
- AdjustWindowRectEx(rect, style & style_mask, FALSE, ex_style & ex_style_mask); + NtUserAdjustWindowRect(rect, style & style_mask, FALSE, ex_style & ex_style_mask, dpi);
TRACE("%p/%p style %08x ex_style %08x shaped %d -> %s\n", data->hwnd, data->cocoa_window, style, ex_style, data->shaped, wine_dbgstr_rect(rect)); @@ -522,6 +532,7 @@ static void sync_window_min_max_info(HWND hwnd) { LONG style = NtUserGetWindowLongW(hwnd, GWL_STYLE); LONG exstyle = NtUserGetWindowLongW(hwnd, GWL_EXSTYLE); + UINT dpi = get_win_monitor_dpi(hwnd); RECT win_rect, primary_monitor_rect; MINMAXINFO minmax; LONG adjustedStyle; @@ -529,6 +540,7 @@ static void sync_window_min_max_info(HWND hwnd) WINDOWPLACEMENT wpl; HMONITOR monitor; struct macdrv_win_data *data; + BOOL menu;
TRACE("win %p\n", hwnd);
@@ -546,8 +558,8 @@ static void sync_window_min_max_info(HWND hwnd) primary_monitor_rect.left = primary_monitor_rect.top = 0; primary_monitor_rect.right = NtUserGetSystemMetrics(SM_CXSCREEN); primary_monitor_rect.bottom = NtUserGetSystemMetrics(SM_CYSCREEN); - AdjustWindowRectEx(&primary_monitor_rect, adjustedStyle, - ((style & WS_POPUP) && NtUserGetWindowLongPtrW(hwnd, GWLP_ID)), exstyle); + menu = ((style & WS_POPUP) && NtUserGetWindowLongPtrW(hwnd, GWLP_ID)); + NtUserAdjustWindowRect(&primary_monitor_rect, adjustedStyle, menu, exstyle, dpi);
xinc = -primary_monitor_rect.left; yinc = -primary_monitor_rect.top; @@ -1313,6 +1325,7 @@ static HMONITOR monitor_from_point(POINT pt, UINT flags) */ static LRESULT move_window(HWND hwnd, WPARAM wparam) { + UINT dpi = get_win_monitor_dpi(hwnd); MSG msg; RECT origRect, movedRect, desktopRect; int hittest = (int)(wparam & 0x0f); @@ -1334,7 +1347,7 @@ static LRESULT move_window(HWND hwnd, WPARAM wparam) TRACE("hwnd %p hittest %d, pos %d,%d\n", hwnd, hittest, (int)capturePoint.x, (int)capturePoint.y);
origRect.left = origRect.right = origRect.top = origRect.bottom = 0; - if (AdjustWindowRectEx(&origRect, style, FALSE, NtUserGetWindowLongW(hwnd, GWL_EXSTYLE))) + if (NtUserAdjustWindowRect(&origRect, style, FALSE, NtUserGetWindowLongW(hwnd, GWL_EXSTYLE), dpi)) captionHeight = -origRect.top; else captionHeight = 0; diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 925c5d7e61b..fce9eb24646 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -113,6 +113,15 @@ static const WCHAR clip_window_prop[] = static pthread_mutex_t win_data_mutex = PTHREAD_MUTEX_INITIALIZER;
+/********************************************************************** + * get_win_monitor_dpi + */ +static UINT get_win_monitor_dpi( HWND hwnd ) +{ + return NtUserGetSystemDpiForProcess( NULL ); /* FIXME: get monitor dpi */ +} + + /*********************************************************************** * http://standards.freedesktop.org/startup-notification-spec */ @@ -1301,10 +1310,12 @@ static void get_decoration_rect( struct x11drv_win_data *data, RECT *rect, { DWORD style, ex_style, style_mask = 0, ex_style_mask = 0; unsigned long decor; + UINT dpi;
SetRectEmpty( rect ); if (!data->managed) return;
+ dpi = get_win_monitor_dpi( data->hwnd ); style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE ); ex_style = NtUserGetWindowLongW( data->hwnd, GWL_EXSTYLE ); decor = get_mwm_decorations( data, style, ex_style, window_rect, client_rect ); @@ -1316,7 +1327,7 @@ static void get_decoration_rect( struct x11drv_win_data *data, RECT *rect, ex_style_mask |= WS_EX_DLGMODALFRAME; }
- AdjustWindowRectEx( rect, style & style_mask, FALSE, ex_style & ex_style_mask ); + NtUserAdjustWindowRect( rect, style & style_mask, FALSE, ex_style & ex_style_mask, dpi ); }
diff --git a/include/ntuser.h b/include/ntuser.h index 1d2f32b5ea6..8983a6d1cec 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -1046,6 +1046,7 @@ enum NtUserCallTwoParam_SetCaretPos, NtUserCallTwoParam_SetIconParam, NtUserCallTwoParam_UnhookWindowsHook, + NtUserCallTwoParam_AdjustWindowRect, /* temporary exports */ NtUserAllocWinProc, }; @@ -1093,6 +1094,26 @@ static inline BOOL NtUserUnhookWindowsHook( INT id, HOOKPROC proc ) return NtUserCallTwoParam( id, (UINT_PTR)proc, NtUserCallTwoParam_UnhookWindowsHook ); }
+struct adjust_window_rect_params +{ + DWORD style; + DWORD ex_style; + BOOL menu; + UINT dpi; +}; + +static inline BOOL NtUserAdjustWindowRect( RECT *rect, DWORD style, BOOL menu, DWORD ex_style, UINT dpi ) +{ + struct adjust_window_rect_params params = + { + .style = style, + .ex_style = ex_style, + .menu = menu, + .dpi = dpi, + }; + return NtUserCallTwoParam( (ULONG_PTR)rect, (ULONG_PTR)¶ms, NtUserCallTwoParam_AdjustWindowRect ); +} + /* NtUserCallHwnd codes, not compatible with Windows */ enum {
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/user32/win.c | 6 ++++-- dlls/win32u/dce.c | 2 +- dlls/win32u/defwnd.c | 6 +++--- dlls/win32u/input.c | 2 +- dlls/win32u/menu.c | 2 +- dlls/win32u/scroll.c | 6 +++--- dlls/win32u/win32u_private.h | 2 +- dlls/win32u/window.c | 23 ++++++++++++----------- dlls/wineandroid.drv/android.h | 1 + dlls/wineandroid.drv/init.c | 2 +- dlls/wineandroid.drv/window.c | 2 +- dlls/winemac.drv/window.c | 4 ++-- dlls/winevulkan/vulkan.c | 19 +++++++++++++++---- dlls/winex11.drv/event.c | 7 ++++--- dlls/winex11.drv/opengl.c | 2 +- dlls/winex11.drv/window.c | 5 ++--- dlls/winex11.drv/x11drv.h | 1 + dlls/wow64win/user.c | 16 ++++++++++++++++ include/ntuser.h | 20 ++++++++++++++------ 19 files changed, 84 insertions(+), 44 deletions(-)
diff --git a/dlls/user32/win.c b/dlls/user32/win.c index b17ae73d97f..2aa06b1dccb 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -673,7 +673,8 @@ void WINAPI SwitchToThisWindow( HWND hwnd, BOOL alt_tab ) */ BOOL WINAPI GetWindowRect( HWND hwnd, RECT *rect ) { - BOOL ret = NtUserGetWindowRect( hwnd, rect ); + UINT dpi = NTUSER_DPI_CONTEXT_GET_DPI( (UINT_PTR)GetThreadDpiAwarenessContext() ); + BOOL ret = NtUserGetWindowRect( hwnd, rect, dpi ); if (ret) TRACE( "hwnd %p %s\n", hwnd, wine_dbgstr_rect(rect) ); return ret; } @@ -715,7 +716,8 @@ int WINAPI GetWindowRgnBox( HWND hwnd, RECT *rect ) */ BOOL WINAPI GetClientRect( HWND hwnd, RECT *rect ) { - return NtUserGetClientRect( hwnd, rect ); + UINT dpi = NTUSER_DPI_CONTEXT_GET_DPI( (UINT_PTR)GetThreadDpiAwarenessContext() ); + return NtUserGetClientRect( hwnd, rect, dpi ); }
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index 2458b65d1de..cfa3510c60b 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -1634,7 +1634,7 @@ INT WINAPI NtUserScrollWindowEx( HWND hwnd, INT dx, INT dy, const RECT *rect, if (!is_window_drawable( hwnd, TRUE )) return ERROR; hwnd = get_full_window_handle( hwnd );
- get_client_rect( hwnd, &rc ); + get_client_rect( hwnd, &rc, get_thread_dpi() ); if (clip_rect) intersect_rect( &cliprc, &rc, clip_rect ); else cliprc = rc;
diff --git a/dlls/win32u/defwnd.c b/dlls/win32u/defwnd.c index ceb1ed2694e..95ad9481958 100644 --- a/dlls/win32u/defwnd.c +++ b/dlls/win32u/defwnd.c @@ -716,7 +716,7 @@ static void sys_command_size_move( HWND hwnd, WPARAM wparam ) if (style & WS_CHILD) { parent = get_parent( hwnd ); - get_client_rect( parent, &mouse_rect ); + get_client_rect( parent, &mouse_rect, get_thread_dpi() ); map_window_points( parent, 0, (POINT *)&mouse_rect, 2, dpi ); map_window_points( parent, 0, (POINT *)&sizing_rect, 2, dpi ); } @@ -2522,7 +2522,7 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, RECT rc; int x, y;
- get_client_rect( hwnd, &rc ); + get_client_rect( hwnd, &rc, get_thread_dpi() ); x = (rc.right - rc.left - get_system_metrics( SM_CXICON )) / 2; y = (rc.bottom - rc.top - get_system_metrics( SM_CYICON )) / 2; TRACE( "Painting class icon: vis rect=(%s)\n", wine_dbgstr_rect(&ps.rcPaint) ); @@ -2585,7 +2585,7 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, if (get_class_long( hwnd, GCL_STYLE, FALSE ) & CS_PARENTDC) { /* can't use GetClipBox with a parent DC or we fill the whole parent */ - get_client_rect( hwnd, &rect ); + get_client_rect( hwnd, &rect, get_thread_dpi() ); NtGdiTransformPoints( hdc, (POINT *)&rect, (POINT *)&rect, 1, NtGdiDPtoLP ); } else NtGdiGetAppClipBox( hdc, &rect ); diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index cddcfd22081..ab3144dbb68 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -2512,7 +2512,7 @@ BOOL clip_fullscreen_window( HWND hwnd, BOOL reset ) /* maximized windows don't count as full screen */ if ((style & WS_MAXIMIZE) && (style & WS_CAPTION) == WS_CAPTION) return FALSE;
- if (!NtUserGetWindowRect( hwnd, &rect )) return FALSE; + if (!NtUserGetWindowRect( hwnd, &rect, get_thread_dpi() )) return FALSE; if (!NtUserIsWindowRectFullScreen( &rect )) return FALSE; if (is_captured_by_system()) return FALSE; if (NtGetTickCount() - thread_info->clipping_reset < 1000) return FALSE; diff --git a/dlls/win32u/menu.c b/dlls/win32u/menu.c index b57093256e2..05eb5445395 100644 --- a/dlls/win32u/menu.c +++ b/dlls/win32u/menu.c @@ -2837,7 +2837,7 @@ static void draw_popup_menu( HWND hwnd, HDC hdc, HMENU hmenu )
TRACE( "wnd=%p dc=%p menu=%p\n", hwnd, hdc, hmenu );
- get_client_rect( hwnd, &rect ); + get_client_rect( hwnd, &rect, get_thread_dpi() );
if (menu && menu->hbrBack) brush = menu->hbrBack; if ((prev_hrush = NtGdiSelectBrush( hdc, brush )) diff --git a/dlls/win32u/scroll.c b/dlls/win32u/scroll.c index f34fe80c7e6..da52a7a4fba 100644 --- a/dlls/win32u/scroll.c +++ b/dlls/win32u/scroll.c @@ -220,7 +220,7 @@ static BOOL get_scroll_bar_rect( HWND hwnd, int bar, RECT *rect, int *arrow_size break;
case SB_CTL: - get_client_rect( hwnd, rect ); + get_client_rect( hwnd, rect, get_thread_dpi() ); vertical = (win->dwStyle & SBS_VERT) != 0; break;
@@ -312,7 +312,7 @@ static void draw_scroll_bar( HWND hwnd, HDC hdc, int bar, enum SCROLL_HITTEST hi
if (bar == SB_CTL && get_window_long( hwnd, GWL_STYLE ) & (SBS_SIZEGRIP | SBS_SIZEBOX)) { - get_client_rect( hwnd, ¶ms.rect ); + get_client_rect( hwnd, ¶ms.rect, get_thread_dpi() ); params.arrow_size = 0; params.thumb_pos = 0; params.thumb_size = 0; @@ -580,7 +580,7 @@ void handle_scroll_event( HWND hwnd, int bar, UINT msg, POINT pt ) g_tracking_info.hit_test = hittest = SCROLL_THUMB; break; case WM_MOUSEMOVE: - get_client_rect( get_parent( get_parent( hwnd )), &rect ); + get_client_rect( get_parent( get_parent( hwnd )), &rect, get_thread_dpi() ); prev_pt = pt; break; case WM_LBUTTONUP: diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 6a6b732d270..8cc4d1beed3 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -214,7 +214,7 @@ extern BOOL client_to_screen( HWND hwnd, POINT *pt ); extern void destroy_thread_windows(void); extern LRESULT destroy_window( HWND hwnd ); extern BOOL enable_window( HWND hwnd, BOOL enable ); -extern BOOL get_client_rect( HWND hwnd, RECT *rect ); +extern BOOL get_client_rect( HWND hwnd, RECT *rect, UINT dpi ); extern HWND get_desktop_window(void); extern UINT get_dpi_for_window( HWND hwnd ); extern HWND get_full_window_handle( HWND hwnd ); diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 4ca6d1e7344..5d1b7fdf702 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -1682,9 +1682,9 @@ BOOL get_window_rect( HWND hwnd, RECT *rect, UINT dpi ) }
/* see GetClientRect */ -BOOL get_client_rect( HWND hwnd, RECT *rect ) +BOOL get_client_rect( HWND hwnd, RECT *rect, UINT dpi ) { - return get_window_rects( hwnd, COORDS_CLIENT, NULL, rect, get_thread_dpi() ); + return get_window_rects( hwnd, COORDS_CLIENT, NULL, rect, dpi ); }
/* see GetWindowInfo */ @@ -2277,7 +2277,7 @@ HWND WINAPI NtUserChildWindowFromPointEx( HWND parent, LONG x, LONG y, UINT flag RECT rect; HWND ret;
- get_client_rect( parent, &rect ); + get_client_rect( parent, &rect, get_thread_dpi() ); if (!PtInRect( &rect, pt )) return 0; if (!(list = list_window_children( 0, parent, NULL, 0 ))) return parent;
@@ -3842,7 +3842,7 @@ MINMAXINFO get_min_max_info( HWND hwnd ) else adjusted_style = style;
- get_client_rect( NtUserGetAncestor( hwnd, GA_PARENT ), &rc ); + get_client_rect( NtUserGetAncestor( hwnd, GA_PARENT ), &rc, get_thread_dpi() ); adjust_window_rect( &rc, adjusted_style, (style & WS_POPUP) && get_menu( hwnd ), exstyle, get_system_dpi() );
xinc = -rc.left; @@ -3992,7 +3992,7 @@ static POINT get_minimized_pos( HWND hwnd, POINT pt ) get_monitor_info( monitor, &mon_info ); parent_rect = mon_info.rcWork; } - else get_client_rect( parent, &parent_rect ); + else get_client_rect( parent, &parent_rect, get_thread_dpi() );
if (pt.x >= parent_rect.left && (pt.x + get_system_metrics( SM_CXMINIMIZED ) < parent_rect.right) && pt.y >= parent_rect.top && (pt.y + get_system_metrics( SM_CYMINIMIZED ) < parent_rect.bottom)) @@ -4176,7 +4176,7 @@ static UINT arrange_iconic_windows( HWND parent ) get_monitor_info( monitor, &mon_info ); parent_rect = mon_info.rcWork; } - else get_client_rect( parent, &parent_rect ); + else get_client_rect( parent, &parent_rect, get_thread_dpi() );
pt = get_first_minimized_child_pos( &parent_rect, &metrics, width, height );
@@ -5503,9 +5503,6 @@ ULONG_PTR WINAPI NtUserCallHwndParam( HWND hwnd, DWORD_PTR param, DWORD code ) case NtUserCallHwndParam_GetClassWord: return get_class_word( hwnd, param );
- case NtUserCallHwndParam_GetClientRect: - return get_client_rect( hwnd, (RECT *)param ); - case NtUserCallHwndParam_GetScrollInfo: { struct get_scroll_info_params *params = (void *)param; @@ -5527,8 +5524,12 @@ ULONG_PTR WINAPI NtUserCallHwndParam( HWND hwnd, DWORD_PTR param, DWORD code ) case NtUserCallHwndParam_GetWindowLongPtrW: return get_window_long_ptr( hwnd, param, FALSE );
- case NtUserCallHwndParam_GetWindowRect: - return get_window_rect( hwnd, (RECT *)param, get_thread_dpi() ); + case NtUserCallHwndParam_GetWindowRects: + { + struct get_window_rects_params *params = (void *)param; + return params->client ? get_client_rect( hwnd, params->rect, params->dpi ) + : get_window_rect( hwnd, params->rect, params->dpi ); + }
case NtUserCallHwndParam_GetWindowRelative: return HandleToUlong( get_window_relative( hwnd, param )); diff --git a/dlls/wineandroid.drv/android.h b/dlls/wineandroid.drv/android.h index 2512976089b..9902170aa78 100644 --- a/dlls/wineandroid.drv/android.h +++ b/dlls/wineandroid.drv/android.h @@ -132,6 +132,7 @@ extern HWND get_capture_window(void); extern void init_monitors( int width, int height ); extern void set_screen_dpi( DWORD dpi ); extern void update_keyboard_lock_state( WORD vkey, UINT state ); +extern UINT get_win_monitor_dpi( HWND hwnd );
/* JNI entry points */ extern void desktop_changed( JNIEnv *env, jobject obj, jint width, jint height ); diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c index cc01852d87f..cabbe3f834c 100644 --- a/dlls/wineandroid.drv/init.c +++ b/dlls/wineandroid.drv/init.c @@ -77,7 +77,7 @@ void init_monitors( int width, int height ) monitor_rc_work = virtual_screen_rect;
if (!hwnd || !NtUserIsWindowVisible( hwnd )) return; - if (!NtUserGetWindowRect( hwnd, &rect )) return; + if (!NtUserGetWindowRect( hwnd, &rect, get_win_monitor_dpi( hwnd ) )) return; if (rect.top) monitor_rc_work.bottom = rect.top; else monitor_rc_work.top = rect.bottom; TRACE( "found tray %p %s work area %s\n", hwnd, diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index 5e095288f91..b5a2fa6f5f7 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -104,7 +104,7 @@ static BOOL intersect_rect( RECT *dst, const RECT *src1, const RECT *src2 ) /********************************************************************** * get_win_monitor_dpi */ -static UINT get_win_monitor_dpi( HWND hwnd ) +UINT get_win_monitor_dpi( HWND hwnd ) { return NtUserGetSystemDpiForProcess( NULL ); /* FIXME: get monitor dpi */ } diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 7ff792dd8ba..344b14ab0ea 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -546,7 +546,7 @@ static void sync_window_min_max_info(HWND hwnd)
if (!macdrv_get_cocoa_window(hwnd, FALSE)) return;
- NtUserGetWindowRect(hwnd, &win_rect); + NtUserGetWindowRect(hwnd, &win_rect, get_win_monitor_dpi(hwnd)); minmax.ptReserved.x = win_rect.left; minmax.ptReserved.y = win_rect.top;
@@ -1352,7 +1352,7 @@ static LRESULT move_window(HWND hwnd, WPARAM wparam) else captionHeight = 0;
- NtUserGetWindowRect(hwnd, &origRect); + NtUserGetWindowRect(hwnd, &origRect, get_win_monitor_dpi(hwnd)); movedRect = origRect;
if (!hittest) diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index e7d00813a42..f6e06bcc085 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -37,6 +37,16 @@ static PFN_vkCreateInstance p_vkCreateInstance; static PFN_vkEnumerateInstanceVersion p_vkEnumerateInstanceVersion; static PFN_vkEnumerateInstanceExtensionProperties p_vkEnumerateInstanceExtensionProperties;
+ +/********************************************************************** + * get_win_monitor_dpi + */ +static UINT get_win_monitor_dpi( HWND hwnd ) +{ + return NtUserGetSystemDpiForProcess( NULL ); /* FIXME: get monitor dpi */ +} + + static int window_surface_compare(const void *key, const struct rb_entry *entry) { const struct wine_surface *surface = RB_ENTRY_VALUE(entry, struct wine_surface, window_entry); @@ -1643,7 +1653,7 @@ VkResult wine_vkAcquireNextImage2KHR(VkDevice device_handle, const VkAcquireNext acquire_info_host.swapchain = swapchain->host_swapchain; res = device->funcs.p_vkAcquireNextImage2KHR(device->host_device, &acquire_info_host, image_index);
- if (res == VK_SUCCESS && NtUserGetClientRect(surface->hwnd, &client_rect) && + if (res == VK_SUCCESS && NtUserGetClientRect(surface->hwnd, &client_rect, get_win_monitor_dpi(surface->hwnd)) && !extents_equals(&swapchain->extents, &client_rect)) { WARN("Swapchain size %dx%d does not match client rect %s, returning VK_SUBOPTIMAL_KHR\n", @@ -1666,7 +1676,7 @@ VkResult wine_vkAcquireNextImageKHR(VkDevice device_handle, VkSwapchainKHR swapc res = device->funcs.p_vkAcquireNextImageKHR(device->host_device, swapchain->host_swapchain, timeout, semaphore, fence, image_index);
- if (res == VK_SUCCESS && NtUserGetClientRect(surface->hwnd, &client_rect) && + if (res == VK_SUCCESS && NtUserGetClientRect(surface->hwnd, &client_rect, get_win_monitor_dpi(surface->hwnd)) && !extents_equals(&swapchain->extents, &client_rect)) { WARN("Swapchain size %dx%d does not match client rect %s, returning VK_SUBOPTIMAL_KHR\n", @@ -1774,7 +1784,7 @@ VkResult wine_vkQueuePresentKHR(VkQueue queue_handle, const VkPresentInfoKHR *pr RECT client_rect;
if (swapchain_res < VK_SUCCESS) continue; - if (!NtUserGetClientRect(surface->hwnd, &client_rect)) + if (!NtUserGetClientRect(surface->hwnd, &client_rect, get_win_monitor_dpi(surface->hwnd))) { WARN("Swapchain window %p is invalid, returning VK_ERROR_OUT_OF_DATE_KHR\n", surface->hwnd); if (present_info->pResults) present_info->pResults[i] = VK_ERROR_OUT_OF_DATE_KHR; @@ -2136,7 +2146,8 @@ static void adjust_surface_capabilities(struct wine_instance *instance, struct w capabilities->maxImageCount = max(capabilities->minImageCount, 16);
/* Update the image extents to match what the Win32 WSI would provide. */ - NtUserGetClientRect(surface->hwnd, &client_rect); + /* FIXME: handle DPI scaling, somehow */ + NtUserGetClientRect(surface->hwnd, &client_rect, get_win_monitor_dpi(surface->hwnd)); capabilities->minImageExtent.width = client_rect.right - client_rect.left; capabilities->minImageExtent.height = client_rect.bottom - client_rect.top; capabilities->maxImageExtent.width = client_rect.right - client_rect.left; diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 2bc80cea5e9..7ba3be8d95e 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -536,7 +536,7 @@ static inline BOOL can_activate_window( HWND hwnd ) if (style & WS_MINIMIZE) return FALSE; if (NtUserGetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_NOACTIVATE) return FALSE; if (hwnd == NtUserGetDesktopWindow()) return FALSE; - if (NtUserGetWindowRect( hwnd, &rect ) && IsRectEmpty( &rect )) return FALSE; + if (NtUserGetWindowRect( hwnd, &rect, get_win_monitor_dpi( hwnd ) ) && IsRectEmpty( &rect )) return FALSE; return !(style & WS_DISABLED); }
@@ -1405,11 +1405,12 @@ void X11DRV_SetFocus( HWND hwnd )
static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt ) { + UINT dpi = get_win_monitor_dpi( hQueryWnd ); RECT tempRect;
if (!NtUserIsWindowEnabled(hQueryWnd)) return 0;
- NtUserGetWindowRect(hQueryWnd, &tempRect); + NtUserGetWindowRect( hQueryWnd, &tempRect, dpi );
if(!PtInRect(&tempRect, *lpPt)) return 0;
@@ -1417,7 +1418,7 @@ static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt ) { POINT pt = *lpPt; NtUserScreenToClient( hQueryWnd, &pt ); - NtUserGetClientRect( hQueryWnd, &tempRect ); + NtUserGetClientRect( hQueryWnd, &tempRect, dpi );
if (PtInRect( &tempRect, pt)) { diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 8ab3e3474d3..09105a8c842 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1316,7 +1316,7 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, const struct glx_pixel RECT rect; int width, height;
- NtUserGetClientRect( hwnd, &rect ); + NtUserGetClientRect( hwnd, &rect, get_win_monitor_dpi( hwnd ) ); width = min( max( 1, rect.right ), 65535 ); height = min( max( 1, rect.bottom ), 65535 );
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index fce9eb24646..7fbb5283629 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -116,7 +116,7 @@ static pthread_mutex_t win_data_mutex = PTHREAD_MUTEX_INITIALIZER; /********************************************************************** * get_win_monitor_dpi */ -static UINT get_win_monitor_dpi( HWND hwnd ) +UINT get_win_monitor_dpi( HWND hwnd ) { return NtUserGetSystemDpiForProcess( NULL ); /* FIXME: get monitor dpi */ } @@ -179,7 +179,6 @@ static void remove_startup_notification(Display *display, Window window) } }
- static BOOL is_managed( HWND hwnd ) { struct x11drv_win_data *data = get_win_data( hwnd ); @@ -1693,7 +1692,7 @@ Window create_client_window( HWND hwnd, const XVisualInfo *visual, Colormap colo HWND parent = NtUserGetAncestor( hwnd, GA_PARENT ); if (parent == NtUserGetDesktopWindow() || NtUserGetAncestor( parent, GA_PARENT )) return 0; if (!(data = alloc_win_data( thread_init_display(), hwnd ))) return 0; - NtUserGetClientRect( hwnd, &data->client_rect ); + NtUserGetClientRect( hwnd, &data->client_rect, get_win_monitor_dpi( hwnd ) ); data->window_rect = data->whole_rect = data->client_rect; }
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 06d76499db7..d95f14dc208 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -670,6 +670,7 @@ extern XContext winContext; /* X context to associate an X cursor to a Win32 cursor handle */ extern XContext cursor_context;
+extern UINT get_win_monitor_dpi( HWND hwnd ); extern BOOL is_current_process_focused(void); extern void X11DRV_SetFocus( HWND hwnd ); extern void set_window_cursor( Window window, HCURSOR handle ); diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 33d4d786714..35bcbdf6c3e 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -1694,6 +1694,22 @@ NTSTATUS WINAPI wow64_NtUserCallHwndParam( UINT *args ) return NtUserCallHwndParam( hwnd, (UINT_PTR)&info, code ); }
+ case NtUserCallHwndParam_GetWindowRects: + { + struct + { + ULONG rect; + BOOL client; + UINT dpi; + } *params32 = UlongToPtr( param ); + struct get_window_rects_params params; + + params.rect = UlongToPtr( params32->rect ); + params.client = params32->client; + params.dpi = params32->dpi; + return NtUserCallHwndParam( hwnd, (UINT_PTR)¶ms, code ); + } + case NtUserCallHwndParam_MapWindowPoints: { struct diff --git a/include/ntuser.h b/include/ntuser.h index 8983a6d1cec..bc36e47af3f 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -1254,14 +1254,13 @@ enum NtUserCallHwndParam_GetClassLongPtrA, NtUserCallHwndParam_GetClassLongPtrW, NtUserCallHwndParam_GetClassWord, - NtUserCallHwndParam_GetClientRect, NtUserCallHwndParam_GetScrollInfo, NtUserCallHwndParam_GetWindowInfo, NtUserCallHwndParam_GetWindowLongA, NtUserCallHwndParam_GetWindowLongW, NtUserCallHwndParam_GetWindowLongPtrA, NtUserCallHwndParam_GetWindowLongPtrW, - NtUserCallHwndParam_GetWindowRect, + NtUserCallHwndParam_GetWindowRects, NtUserCallHwndParam_GetWindowRelative, NtUserCallHwndParam_GetWindowThread, NtUserCallHwndParam_GetWindowWord, @@ -1280,6 +1279,13 @@ enum NtUserSetWindowStyle, };
+struct get_window_rects_params +{ + RECT *rect; + BOOL client; + UINT dpi; +}; + static inline BOOL NtUserClientToScreen( HWND hwnd, POINT *pt ) { return NtUserCallHwndParam( hwnd, (UINT_PTR)pt, NtUserCallHwndParam_ClientToScreen ); @@ -1320,9 +1326,10 @@ static inline WORD NtUserGetClassWord( HWND hwnd, INT offset ) return NtUserCallHwndParam( hwnd, offset, NtUserCallHwndParam_GetClassWord ); }
-static inline BOOL NtUserGetClientRect( HWND hwnd, RECT *rect ) +static inline BOOL NtUserGetClientRect( HWND hwnd, RECT *rect, UINT dpi ) { - return NtUserCallHwndParam( hwnd, (UINT_PTR)rect, NtUserCallHwndParam_GetClientRect ); + struct get_window_rects_params params = {.rect = rect, .client = TRUE, .dpi = dpi}; + return NtUserCallHwndParam( hwnd, (UINT_PTR)¶ms, NtUserCallHwndParam_GetWindowRects ); }
struct get_scroll_info_params @@ -1362,9 +1369,10 @@ static inline LONG NtUserGetWindowLongW( HWND hwnd, INT offset ) return NtUserCallHwndParam( hwnd, offset, NtUserCallHwndParam_GetWindowLongW ); }
-static inline BOOL NtUserGetWindowRect( HWND hwnd, RECT *rect ) +static inline BOOL NtUserGetWindowRect( HWND hwnd, RECT *rect, UINT dpi ) { - return NtUserCallHwndParam( hwnd, (UINT_PTR)rect, NtUserCallHwndParam_GetWindowRect ); + struct get_window_rects_params params = {.rect = rect, .client = FALSE, .dpi = dpi}; + return NtUserCallHwndParam( hwnd, (UINT_PTR)¶ms, NtUserCallHwndParam_GetWindowRects ); }
static inline HWND NtUserGetWindowRelative( HWND hwnd, UINT rel )
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/sysparams.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index f4287c15a5f..00b5e9522a3 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -2102,6 +2102,11 @@ UINT get_monitor_dpi( HMONITOR monitor ) return system_dpi; }
+static RECT get_monitor_rect( struct monitor *monitor, UINT dpi ) +{ + return map_dpi_rect( monitor->rc_monitor, get_monitor_dpi( monitor->handle ), dpi ); +} + /********************************************************************** * get_win_monitor_dpi */ @@ -2303,9 +2308,7 @@ static BOOL is_window_rect_full_screen( const RECT *rect )
if (!is_monitor_active( monitor ) || monitor->is_clone) continue;
- monrect = map_dpi_rect( monitor->rc_monitor, get_monitor_dpi( monitor->handle ), - get_thread_dpi() ); - + monrect = get_monitor_rect( monitor, get_thread_dpi() ); if (rect->left <= monrect.left && rect->right >= monrect.right && rect->top <= monrect.top && rect->bottom >= monrect.bottom) { @@ -3474,8 +3477,7 @@ static BOOL should_enumerate_monitor( struct monitor *monitor, const POINT *orig if (!is_monitor_active( monitor )) return FALSE; if (monitor->is_clone) return FALSE;
- *rect = map_dpi_rect( monitor->rc_monitor, get_monitor_dpi( monitor->handle ), - get_thread_dpi() ); + *rect = get_monitor_rect( monitor, get_thread_dpi() ); OffsetRect( rect, -origin->x, -origin->y ); return intersect_rect( rect, rect, limit ); } @@ -3628,7 +3630,7 @@ HMONITOR monitor_from_rect( const RECT *rect, UINT flags, UINT dpi )
if (!is_monitor_active( monitor ) || monitor->is_clone) continue;
- monitor_rect = map_dpi_rect( monitor->rc_monitor, get_monitor_dpi( monitor->handle ), system_dpi ); + monitor_rect = get_monitor_rect( monitor, system_dpi ); if (intersect_rect( &intersect, &monitor_rect, &r )) { /* check for larger intersecting area */
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/input.c | 6 ++++-- dlls/win32u/sysparams.c | 10 +++++----- dlls/winewayland.drv/window.c | 12 +++++++++++- dlls/winex11.drv/event.c | 5 +++-- dlls/winex11.drv/window.c | 7 ++++--- include/ntuser.h | 12 ++++++------ 6 files changed, 33 insertions(+), 19 deletions(-)
diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index ab3144dbb68..cf84be6ef0e 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -2501,6 +2501,7 @@ BOOL clip_fullscreen_window( HWND hwnd, BOOL reset ) RECT rect; HMONITOR monitor; DWORD style; + UINT dpi; BOOL ret;
if (hwnd == NtUserGetDesktopWindow()) return FALSE; @@ -2512,8 +2513,9 @@ BOOL clip_fullscreen_window( HWND hwnd, BOOL reset ) /* maximized windows don't count as full screen */ if ((style & WS_MAXIMIZE) && (style & WS_CAPTION) == WS_CAPTION) return FALSE;
- if (!NtUserGetWindowRect( hwnd, &rect, get_thread_dpi() )) return FALSE; - if (!NtUserIsWindowRectFullScreen( &rect )) return FALSE; + dpi = get_dpi_for_window( hwnd ); + if (!NtUserGetWindowRect( hwnd, &rect, dpi )) return FALSE; + if (!NtUserIsWindowRectFullScreen( &rect, dpi )) return FALSE; if (is_captured_by_system()) return FALSE; if (NtGetTickCount() - thread_info->clipping_reset < 1000) return FALSE; if (!reset && clipping_cursor && thread_info->clipping_cursor) return FALSE; /* already clipping */ diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 00b5e9522a3..12aaac5329f 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -2295,7 +2295,7 @@ RECT get_virtual_screen_rect( UINT dpi ) return rect; }
-static BOOL is_window_rect_full_screen( const RECT *rect ) +static BOOL is_window_rect_full_screen( const RECT *rect, UINT dpi ) { struct monitor *monitor; BOOL ret = FALSE; @@ -2308,7 +2308,7 @@ static BOOL is_window_rect_full_screen( const RECT *rect )
if (!is_monitor_active( monitor ) || monitor->is_clone) continue;
- monrect = get_monitor_rect( monitor, get_thread_dpi() ); + monrect = get_monitor_rect( monitor, dpi ); if (rect->left <= monrect.left && rect->right >= monrect.right && rect->top <= monrect.top && rect->bottom >= monrect.bottom) { @@ -6393,9 +6393,6 @@ ULONG_PTR WINAPI NtUserCallOneParam( ULONG_PTR arg, ULONG code ) case NtUserCallOneParam_GetSysColor: return get_sys_color( arg );
- case NtUserCallOneParam_IsWindowRectFullScreen: - return is_window_rect_full_screen( (const RECT *)arg ); - case NtUserCallOneParam_RealizePalette: return realize_palette( UlongToHandle(arg) );
@@ -6482,6 +6479,9 @@ ULONG_PTR WINAPI NtUserCallTwoParam( ULONG_PTR arg1, ULONG_PTR arg2, ULONG code return adjust_window_rect( (RECT *)arg1, params->style, params->menu, params->ex_style, params->dpi ); }
+ case NtUserCallTwoParam_IsWindowRectFullScreen: + return is_window_rect_full_screen( (const RECT *)arg1, arg2 ); + /* temporary exports */ case NtUserAllocWinProc: return (UINT_PTR)alloc_winproc( (WNDPROC)arg1, arg2 ); diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c index 906dcbc42df..cd8ca76b679 100644 --- a/dlls/winewayland.drv/window.c +++ b/dlls/winewayland.drv/window.c @@ -36,6 +36,16 @@
WINE_DEFAULT_DEBUG_CHANNEL(waylanddrv);
+ +/********************************************************************** + * get_win_monitor_dpi + */ +static UINT get_win_monitor_dpi(HWND hwnd) +{ + return NtUserGetSystemDpiForProcess(NULL); /* FIXME: get monitor dpi */ +} + + /* private window data */ struct wayland_win_data { @@ -171,7 +181,7 @@ static void wayland_win_data_get_config(struct wayland_win_data *data, TRACE("window=%s style=%#lx\n", wine_dbgstr_rect(&conf->rect), (long)style);
/* The fullscreen state is implied by the window position and style. */ - if (NtUserIsWindowRectFullScreen(&conf->rect)) + if (NtUserIsWindowRectFullScreen(&conf->rect, get_win_monitor_dpi(data->hwnd))) { if ((style & WS_MAXIMIZE) && (style & WS_CAPTION) == WS_CAPTION) window_state |= WAYLAND_SURFACE_CONFIG_STATE_MAXIMIZED; diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 7ba3be8d95e..88863e62dd1 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1046,7 +1046,7 @@ static BOOL X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev ) struct x11drv_win_data *data; RECT rect; POINT pos; - UINT flags; + UINT flags, dpi; HWND parent; BOOL root_coords; int cx, cy, x = event->x, y = event->y; @@ -1068,6 +1068,7 @@ static BOOL X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev )
/* Get geometry */
+ dpi = get_win_monitor_dpi( data->hwnd ); parent = NtUserGetAncestor( hwnd, GA_PARENT ); root_coords = event->send_event; /* synthetic events are always in root coords */
@@ -1119,7 +1120,7 @@ static BOOL X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev ) (int)(data->window_rect.bottom - data->window_rect.top), cx, cy );
style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE ); - if ((style & WS_CAPTION) == WS_CAPTION || !NtUserIsWindowRectFullScreen( &data->whole_rect )) + if ((style & WS_CAPTION) == WS_CAPTION || !NtUserIsWindowRectFullScreen( &data->whole_rect, dpi )) { read_net_wm_states( event->display, data ); if ((data->net_wm_state & (1 << NET_WM_STATE_MAXIMIZED))) diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 7fbb5283629..640d7914b67 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -297,7 +297,7 @@ static inline BOOL is_window_resizable( struct x11drv_win_data *data, DWORD styl { if (style & WS_THICKFRAME) return TRUE; /* Metacity needs the window to be resizable to make it fullscreen */ - return NtUserIsWindowRectFullScreen( &data->whole_rect ); + return NtUserIsWindowRectFullScreen( &data->whole_rect, get_win_monitor_dpi( data->hwnd ) ); }
/*********************************************************************** @@ -1089,7 +1089,7 @@ void update_net_wm_states( struct x11drv_win_data *data ) style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE ); if (style & WS_MINIMIZE) new_state |= data->net_wm_state & ((1 << NET_WM_STATE_FULLSCREEN)|(1 << NET_WM_STATE_MAXIMIZED)); - if (NtUserIsWindowRectFullScreen( &data->whole_rect )) + if (NtUserIsWindowRectFullScreen( &data->whole_rect, get_win_monitor_dpi( data->hwnd ) )) { if ((style & WS_MAXIMIZE) && (style & WS_CAPTION) == WS_CAPTION) new_state |= (1 << NET_WM_STATE_MAXIMIZED); @@ -2761,7 +2761,8 @@ void X11DRV_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags, { release_win_data( data ); unmap_window( hwnd ); - if (NtUserIsWindowRectFullScreen( &old_window_rect )) NtUserClipCursor( NULL ); + if (NtUserIsWindowRectFullScreen( &old_window_rect, get_win_monitor_dpi( hwnd ) )) + NtUserClipCursor( NULL ); if (!(data = get_win_data( hwnd ))) return; } } diff --git a/include/ntuser.h b/include/ntuser.h index bc36e47af3f..7713f7c6886 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -904,7 +904,6 @@ enum NtUserCallOneParam_GetSysColorPen, NtUserCallOneParam_GetSystemMetrics, NtUserCallOneParam_GetVirtualScreenRect, - NtUserCallOneParam_IsWindowRectFullScreen, NtUserCallOneParam_MessageBeep, NtUserCallOneParam_RealizePalette, NtUserCallOneParam_ReplyMessage, @@ -1005,11 +1004,6 @@ static inline RECT NtUserGetVirtualScreenRect(void) return virtual; }
-static inline BOOL NtUserIsWindowRectFullScreen( const RECT *rect ) -{ - return NtUserCallOneParam( (UINT_PTR)rect, NtUserCallOneParam_IsWindowRectFullScreen ); -} - static inline BOOL NtUserMessageBeep( UINT i ) { return NtUserCallOneParam( i, NtUserCallOneParam_MessageBeep ); @@ -1047,6 +1041,7 @@ enum NtUserCallTwoParam_SetIconParam, NtUserCallTwoParam_UnhookWindowsHook, NtUserCallTwoParam_AdjustWindowRect, + NtUserCallTwoParam_IsWindowRectFullScreen, /* temporary exports */ NtUserAllocWinProc, }; @@ -1114,6 +1109,11 @@ static inline BOOL NtUserAdjustWindowRect( RECT *rect, DWORD style, BOOL menu, D return NtUserCallTwoParam( (ULONG_PTR)rect, (ULONG_PTR)¶ms, NtUserCallTwoParam_AdjustWindowRect ); }
+static inline BOOL NtUserIsWindowRectFullScreen( const RECT *rect, UINT dpi ) +{ + return NtUserCallTwoParam( (UINT_PTR)rect, dpi, NtUserCallTwoParam_IsWindowRectFullScreen ); +} + /* NtUserCallHwnd codes, not compatible with Windows */ enum {
Rebased, to fix the macos failure.
Is there something wrong with this? Should wineserver use RECT directly maybe?