From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winemac.drv/window.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-)
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 32e544d733b..dacda1e7e78 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -55,6 +55,25 @@ static UINT get_win_monitor_dpi(HWND hwnd) }
+/* per-monitor DPI aware NtUserSetWindowPos call */ +static BOOL set_window_pos(HWND hwnd, HWND after, INT x, INT y, INT cx, INT cy, UINT flags) +{ + UINT context = NtUserSetThreadDpiAwarenessContext(NTUSER_DPI_PER_MONITOR_AWARE_V2); + BOOL ret = NtUserSetWindowPos(hwnd, after, x, y, cx, cy, flags); + NtUserSetThreadDpiAwarenessContext(context); + return ret; +} + + +/* per-monitor DPI aware NtUserSetInternalWindowPos call */ +static void set_internal_window_pos(HWND hwnd, UINT cmd, RECT *rect, POINT *pt) +{ + UINT context = NtUserSetThreadDpiAwarenessContext(NTUSER_DPI_PER_MONITOR_AWARE_V2); + NtUserSetInternalWindowPos(hwnd, cmd, rect, pt); + NtUserSetThreadDpiAwarenessContext(context); +} + + /*********************************************************************** * get_cocoa_window_features */ @@ -930,10 +949,8 @@ static void set_focus(HWND hwnd, BOOL raise)
if (!(hwnd = NtUserGetAncestor(hwnd, GA_ROOT))) return;
- if (raise && hwnd == NtUserGetForegroundWindow() && hwnd != NtUserGetDesktopWindow() && - !is_all_the_way_front(hwnd)) - NtUserSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOOWNERZORDER); + if (raise && hwnd == NtUserGetForegroundWindow() && hwnd != NtUserGetDesktopWindow() && !is_all_the_way_front(hwnd)) + set_window_pos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
if (!(data = get_win_data(hwnd))) return;
@@ -1480,8 +1497,7 @@ static LRESULT move_window(HWND hwnd, WPARAM wparam) capturePoint = pt;
send_message(hwnd, WM_MOVING, 0, (LPARAM)&movedRect); - NtUserSetWindowPos(hwnd, 0, movedRect.left, movedRect.top, 0, 0, - SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); + set_window_pos(hwnd, 0, movedRect.left, movedRect.top, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); } } } @@ -1494,8 +1510,7 @@ static LRESULT move_window(HWND hwnd, WPARAM wparam) /* if the move is canceled, restore the previous position */ if (moved && msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE) { - NtUserSetWindowPos(hwnd, 0, origRect.left, origRect.top, 0, 0, - SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); + set_window_pos(hwnd, 0, origRect.left, origRect.top, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); }
return 0; @@ -2259,7 +2274,7 @@ void macdrv_window_frame_changed(HWND hwnd, const macdrv_event *event) int send_sizemove = !event->window_frame_changed.in_resize && !being_dragged && !event->window_frame_changed.skip_size_move_loop; if (send_sizemove) send_message(hwnd, WM_ENTERSIZEMOVE, 0, 0); - NtUserSetWindowPos(hwnd, 0, rect.left, rect.top, width, height, flags); + set_window_pos(hwnd, 0, rect.left, rect.top, width, height, flags); if (send_sizemove) send_message(hwnd, WM_EXITSIZEMOVE, 0, 0); } @@ -2429,7 +2444,7 @@ done: void macdrv_window_brought_forward(HWND hwnd) { TRACE("win %p\n", hwnd); - NtUserSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + set_window_pos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); }
@@ -2469,7 +2484,7 @@ void macdrv_window_restore_requested(HWND hwnd, const macdrv_event *event)
release_win_data(data);
- NtUserSetInternalWindowPos(hwnd, SW_SHOW, &rect, NULL); + set_internal_window_pos(hwnd, SW_SHOW, &rect, NULL); } }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winewayland.drv/window.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c index 73bee46cc35..274ce24db4c 100644 --- a/dlls/winewayland.drv/window.c +++ b/dlls/winewayland.drv/window.c @@ -46,6 +46,16 @@ static UINT get_win_monitor_dpi(HWND hwnd) }
+/* per-monitor DPI aware NtUserSetWindowPos call */ +static BOOL set_window_pos(HWND hwnd, HWND after, INT x, INT y, INT cx, INT cy, UINT flags) +{ + UINT context = NtUserSetThreadDpiAwarenessContext(NTUSER_DPI_PER_MONITOR_AWARE_V2); + BOOL ret = NtUserSetWindowPos(hwnd, after, x, y, cx, cy, flags); + NtUserSetThreadDpiAwarenessContext(context); + return ret; +} + + /* private window data */ struct wayland_win_data { @@ -628,7 +638,7 @@ static void wayland_configure_window(HWND hwnd) flags |= SWP_NOSENDCHANGING; }
- NtUserSetWindowPos(hwnd, 0, 0, 0, window_width, window_height, flags); + set_window_pos(hwnd, 0, 0, 0, window_width, window_height, flags); }
/**********************************************************************
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/event.c | 12 ++++++------ dlls/winex11.drv/window.c | 6 +++--- dlls/winex11.drv/x11drv.h | 9 +++++++++ 3 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 3c4a5254b33..7adb083134c 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -974,7 +974,7 @@ static BOOL X11DRV_UnmapNotify( HWND hwnd, XEvent *event ) static void reparent_notify( Display *display, HWND hwnd, Window xparent, int x, int y ) { HWND parent, old_parent; - DWORD style; + DWORD style, flags = 0;
style = NtUserGetWindowLongW( hwnd, GWL_STYLE ); if (xparent == root_window) @@ -991,9 +991,9 @@ static void reparent_notify( Display *display, HWND hwnd, Window xparent, int x, NtUserShowWindow( hwnd, SW_HIDE ); old_parent = NtUserSetParent( hwnd, parent ); NtUserSetWindowLong( hwnd, GWL_STYLE, style, FALSE ); - NtUserSetWindowPos( hwnd, HWND_TOP, x, y, 0, 0, - SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOCOPYBITS | - ((style & WS_VISIBLE) ? SWP_SHOWWINDOW : 0) ); + + if (style & WS_VISIBLE) flags = SWP_SHOWWINDOW; + set_window_pos( hwnd, HWND_TOP, x, y, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOCOPYBITS | flags );
/* make old parent destroy itself if it no longer has children */ if (old_parent != NtUserGetDesktopWindow()) NtUserPostMessage( old_parent, WM_CLOSE, 0, 0 ); @@ -1145,7 +1145,7 @@ static BOOL X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev ) if ((flags & (SWP_NOSIZE | SWP_NOMOVE)) != (SWP_NOSIZE | SWP_NOMOVE)) { release_win_data( data ); - NtUserSetWindowPos( hwnd, 0, x, y, cx, cy, flags ); + set_window_pos( hwnd, 0, x, y, cx, cy, flags ); return TRUE; }
@@ -1183,7 +1183,7 @@ static BOOL X11DRV_GravityNotify( HWND hwnd, XEvent *xev ) release_win_data( data );
if (window_rect.left != x || window_rect.top != y) - NtUserSetWindowPos( hwnd, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS ); + set_window_pos( hwnd, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS );
return TRUE; } diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index d24b1c08184..39a8d2a4b5d 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -908,15 +908,15 @@ static void set_initial_wm_hints( Display *display, Window window ) */ static void make_owner_managed( HWND hwnd ) { + static const UINT flags = SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | SWP_NOREDRAW | + SWP_DEFERERASE | SWP_NOSENDCHANGING | SWP_STATECHANGED; HWND owner;
if (!(owner = NtUserGetWindowRelative( hwnd, GW_OWNER ))) return; if (is_managed( owner )) return; if (!is_managed( hwnd )) return;
- NtUserSetWindowPos( owner, 0, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | - SWP_NOREDRAW | SWP_DEFERERASE | SWP_NOSENDCHANGING | SWP_STATECHANGED ); + set_window_pos( owner, 0, 0, 0, 0, 0, flags ); }
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index be76dd2609e..055b1a9be8b 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -885,6 +885,15 @@ static inline BOOL send_notify_message( HWND hwnd, UINT msg, WPARAM wparam, LPAR return NtUserMessageCall( hwnd, msg, wparam, lparam, 0, NtUserSendNotifyMessage, FALSE ); }
+/* per-monitor DPI aware NtUserSetWindowPos call */ +static inline BOOL set_window_pos( HWND hwnd, HWND after, INT x, INT y, INT cx, INT cy, UINT flags ) +{ + UINT context = NtUserSetThreadDpiAwarenessContext( NTUSER_DPI_PER_MONITOR_AWARE_V2 ); + BOOL ret = NtUserSetWindowPos( hwnd, after, x, y, cx, cy, flags ); + NtUserSetThreadDpiAwarenessContext( context ); + return ret; +} + static inline HWND get_focus(void) { GUITHREADINFO info;
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/event.c | 2 +- dlls/winex11.drv/window.c | 5 ++--- dlls/winex11.drv/x11drv.h | 9 +++++++++ 3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 7adb083134c..a0b46fe1fd9 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -931,7 +931,7 @@ static BOOL X11DRV_Expose( HWND hwnd, XEvent *xev )
release_win_data( data );
- if (flags) NtUserRedrawWindow( hwnd, &rect, surface_region, flags ); + if (flags) redraw_window( hwnd, &rect, surface_region, flags ); if (surface_region) NtGdiDeleteObjectApp( surface_region ); return TRUE; } diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 39a8d2a4b5d..845cd896bb0 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1551,10 +1551,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 ); - NtUserRedrawWindow( hwnd, NULL, rgn, - RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ALLCHILDREN ); + redraw_window( hwnd, NULL, rgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ALLCHILDREN ); } - else NtUserRedrawWindow( hwnd, NULL, rgn, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN ); + else redraw_window( hwnd, NULL, rgn, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN ); NtGdiDeleteObjectApp( rgn ); } } diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 055b1a9be8b..3485d239fa2 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -894,6 +894,15 @@ 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; +} + static inline HWND get_focus(void) { GUITHREADINFO info;
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/event.c | 3 +-- dlls/winex11.drv/x11drv.h | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index a0b46fe1fd9..c377bbc9984 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1423,8 +1423,7 @@ static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt )
if (PtInRect( &tempRect, pt)) { - HWND ret = NtUserChildWindowFromPointEx( hQueryWnd, pt.x, pt.y, - CWP_SKIPINVISIBLE|CWP_SKIPDISABLED ); + HWND ret = child_window_from_point( hQueryWnd, pt.x, pt.y, CWP_SKIPINVISIBLE | CWP_SKIPDISABLED ); if (ret && ret != hQueryWnd) { ret = find_drop_window( ret, lpPt ); diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 3485d239fa2..6d257a2afbd 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -903,6 +903,15 @@ static inline BOOL redraw_window( HWND hwnd, const RECT *rect, HRGN hrgn, UINT f return ret; }
+/* per-monitor DPI aware NtUserChildWindowFromPointEx call */ +static inline HWND child_window_from_point( HWND parent, LONG x, LONG y, UINT flags ) +{ + UINT context = NtUserSetThreadDpiAwarenessContext( NTUSER_DPI_PER_MONITOR_AWARE_V2 ); + HWND ret = NtUserChildWindowFromPointEx( parent, x, y, flags ); + NtUserSetThreadDpiAwarenessContext( context ); + return ret; +} + static inline HWND get_focus(void) { GUITHREADINFO info;
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=146213
Your paranoid android.
=== debian11b (64 bit WoW report) ===
user32: input.c:4305: Test succeeded inside todo block: button_down_hwnd_todo 1: got MSG_TEST_WIN hwnd 0000000000A800F0, msg WM_LBUTTONDOWN, wparam 0x1, lparam 0x320032