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;