Alexandre Julliard : user32: Update the window DPI awareness in SetParent( ).

Alexandre Julliard julliard at winehq.org
Tue May 15 16:25:22 CDT 2018


Module: wine
Branch: master
Commit: 8a70b70f42b4121816d8acaa2f2533b211efc7a1
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=8a70b70f42b4121816d8acaa2f2533b211efc7a1

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue May 15 16:21:36 2018 +0200

user32: Update the window DPI awareness in SetParent().

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/tests/sysparams.c  | 18 +++++++++++++++++-
 dlls/user32/win.c              |  1 +
 include/wine/server_protocol.h |  4 +++-
 server/protocol.def            |  1 +
 server/request.h               |  3 ++-
 server/trace.c                 |  1 +
 server/window.c                |  3 +++
 7 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/dlls/user32/tests/sysparams.c b/dlls/user32/tests/sysparams.c
index d898828..f1addbb 100644
--- a/dlls/user32/tests/sysparams.c
+++ b/dlls/user32/tests/sysparams.c
@@ -3526,7 +3526,7 @@ static void test_dpi_window(void)
     DPI_AWARENESS_CONTEXT context, orig;
     DPI_AWARENESS awareness;
     ULONG_PTR i, j;
-    HWND hwnd, child;
+    HWND hwnd, child, ret;
     MSG msg = { 0, WM_USER + 1, 0, 0 };
 
     if (!pGetWindowDpiAwarenessContext)
@@ -3556,6 +3556,22 @@ static void test_dpi_window(void)
             context = pGetWindowDpiAwarenessContext( child );
             awareness = pGetAwarenessFromDpiAwarenessContext( context );
             ok( awareness == i, "%lu/%lu: wrong awareness %u\n", i, j, awareness );
+            ret = SetParent( child, NULL );
+            ok( ret != 0, "SetParent failed err %u\n", GetLastError() );
+            context = pGetWindowDpiAwarenessContext( child );
+            awareness = pGetAwarenessFromDpiAwarenessContext( context );
+            ok( awareness == i, "%lu/%lu: wrong awareness %u\n", i, j, awareness );
+            DestroyWindow( child );
+            child = CreateWindowA( "DpiTestClass", "Test",
+                                   WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL );
+            context = pGetWindowDpiAwarenessContext( child );
+            awareness = pGetAwarenessFromDpiAwarenessContext( context );
+            ok( awareness == j, "%lu/%lu: wrong awareness %u\n", i, j, awareness );
+            ret = SetParent( child, hwnd );
+            ok( ret != 0, "SetParent failed err %u\n", GetLastError() );
+            context = pGetWindowDpiAwarenessContext( child );
+            awareness = pGetAwarenessFromDpiAwarenessContext( context );
+            ok( awareness == i, "%lu/%lu: wrong awareness %u\n", i, j, awareness );
             DestroyWindow( child );
         }
         DestroyWindow( hwnd );
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 737fce4..c2bf84c 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -3083,6 +3083,7 @@ HWND WINAPI SetParent( HWND hwnd, HWND parent )
         {
             old_parent = wine_server_ptr_handle( reply->old_parent );
             wndPtr->parent = parent = wine_server_ptr_handle( reply->full_parent );
+            wndPtr->dpi_awareness = reply->awareness;
         }
 
     }
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index 0ca7171..b63f1d2 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -3571,6 +3571,8 @@ struct set_parent_reply
     struct reply_header __header;
     user_handle_t  old_parent;
     user_handle_t  full_parent;
+    int            awareness;
+    char __pad_20[4];
 };
 
 
@@ -6507,6 +6509,6 @@ union generic_reply
     struct terminate_job_reply terminate_job_reply;
 };
 
-#define SERVER_PROTOCOL_VERSION 549
+#define SERVER_PROTOCOL_VERSION 550
 
 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/server/protocol.def b/server/protocol.def
index 6e78a14..8d7d220 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -2564,6 +2564,7 @@ enum message_type
 @REPLY
     user_handle_t  old_parent;  /* old parent window */
     user_handle_t  full_parent; /* full handle of new parent */
+    int            awareness;   /* new DPI awareness */
 @END
 
 
diff --git a/server/request.h b/server/request.h
index 9cc735a..6a36070 100644
--- a/server/request.h
+++ b/server/request.h
@@ -1717,7 +1717,8 @@ C_ASSERT( FIELD_OFFSET(struct set_parent_request, parent) == 16 );
 C_ASSERT( sizeof(struct set_parent_request) == 24 );
 C_ASSERT( FIELD_OFFSET(struct set_parent_reply, old_parent) == 8 );
 C_ASSERT( FIELD_OFFSET(struct set_parent_reply, full_parent) == 12 );
-C_ASSERT( sizeof(struct set_parent_reply) == 16 );
+C_ASSERT( FIELD_OFFSET(struct set_parent_reply, awareness) == 16 );
+C_ASSERT( sizeof(struct set_parent_reply) == 24 );
 C_ASSERT( FIELD_OFFSET(struct get_window_parents_request, handle) == 12 );
 C_ASSERT( sizeof(struct get_window_parents_request) == 16 );
 C_ASSERT( FIELD_OFFSET(struct get_window_parents_reply, count) == 8 );
diff --git a/server/trace.c b/server/trace.c
index d4c44c8..261a8cc 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -3131,6 +3131,7 @@ static void dump_set_parent_reply( const struct set_parent_reply *req )
 {
     fprintf( stderr, " old_parent=%08x", req->old_parent );
     fprintf( stderr, ", full_parent=%08x", req->full_parent );
+    fprintf( stderr, ", awareness=%d", req->awareness );
 }
 
 static void dump_get_window_parents_request( const struct get_window_parents_request *req )
diff --git a/server/window.c b/server/window.c
index 592ae23..4c9b321 100644
--- a/server/window.c
+++ b/server/window.c
@@ -250,6 +250,8 @@ static int set_parent_window( struct window *win, struct window *parent )
         win->parent = parent;
         link_window( win, WINPTR_TOP );
 
+        if (!is_desktop_window( parent )) win->dpi_awareness = parent->dpi_awareness;
+
         /* if parent belongs to a different thread and the window isn't */
         /* top-level, attach the two threads */
         if (parent->thread && parent->thread != win->thread && !is_desktop_window(parent))
@@ -1939,6 +1941,7 @@ DECL_HANDLER(set_parent)
     reply->old_parent  = win->parent->handle;
     reply->full_parent = parent ? parent->handle : 0;
     set_parent_window( win, parent );
+    reply->awareness = win->dpi_awareness;
 }
 
 




More information about the wine-cvs mailing list