From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/window.c | 1 + server/protocol.def | 1 + server/window.c | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 173672030f3..77471213431 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -2008,6 +2008,7 @@ static BOOL apply_window_pos( HWND hwnd, HWND insert_after, UINT swp_flags, stru req->handle = wine_server_user_handle( hwnd ); req->previous = wine_server_user_handle( insert_after ); req->swp_flags = swp_flags; + req->monitor_dpi = monitor_dpi; req->window = wine_server_rectangle( new_rects->window ); req->client = wine_server_rectangle( new_rects->client ); if (!EqualRect( &new_rects->window, &new_rects->visible ) || new_surface || valid_rects) diff --git a/server/protocol.def b/server/protocol.def index 2c791cbdd46..f260bae2d21 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -2592,6 +2592,7 @@ enum message_type @REQ(set_window_pos) unsigned short swp_flags; /* SWP_* flags */ unsigned short paint_flags; /* paint flags (see below) */ + unsigned int monitor_dpi; /* DPI of the window's monitor */ user_handle_t handle; /* handle to the window */ user_handle_t previous; /* previous window in Z order */ rectangle_t window; /* window rectangle (in parent coords) */ diff --git a/server/window.c b/server/window.c index 564c69bf18d..16c2656b8f2 100644 --- a/server/window.c +++ b/server/window.c @@ -84,6 +84,7 @@ struct window unsigned int alpha; /* alpha value for a layered window */ unsigned int layered_flags; /* flags for a layered window */ unsigned int dpi_context; /* DPI awareness context */ + unsigned int monitor_dpi; /* DPI of the window monitor */ lparam_t user_data; /* user-specific data */ WCHAR *text; /* window caption text */ data_size_t text_len; /* length of window caption */ @@ -245,20 +246,17 @@ static inline void update_pixel_format_flags( struct window *win ) win->paint_flags |= PAINT_PIXEL_FORMAT_CHILD; }
-static unsigned int get_window_dpi( struct window *win ) +/* get the per-monitor DPI for a window */ +static unsigned int get_monitor_dpi( struct window *win ) { - unsigned int dpi; - if ((dpi = NTUSER_DPI_CONTEXT_GET_DPI( win->dpi_context ))) return dpi; - /* FIXME: return the window monitor DPI? */ - return USER_DEFAULT_SCREEN_DPI; + while (win->parent && !is_desktop_window( win->parent )) win = win->parent; + return win->monitor_dpi; }
-/* get the per-monitor DPI for a window */ -static unsigned int get_monitor_dpi( struct window *win ) +static unsigned int get_window_dpi( struct window *win ) { - /* FIXME: we return the desktop window DPI for now */ - while (!is_desktop_window( win )) win = win->parent; - return get_window_dpi( win ); + if (NTUSER_DPI_CONTEXT_IS_MONITOR_AWARE( win->dpi_context )) return get_monitor_dpi( win ); + return NTUSER_DPI_CONTEXT_GET_DPI( win->dpi_context ); }
/* link a window at the right place in the siblings list */ @@ -578,6 +576,7 @@ static struct window *create_window( struct window *parent, struct window *owner win->is_layered = 0; win->is_orphan = 0; win->dpi_context = NTUSER_DPI_PER_MONITOR_AWARE; + win->monitor_dpi = USER_DEFAULT_SCREEN_DPI; win->user_data = 0; win->text = NULL; win->text_len = 0; @@ -2476,6 +2475,7 @@ DECL_HANDLER(set_window_pos) win->paint_flags = (win->paint_flags & ~PAINT_CLIENT_FLAGS) | (req->paint_flags & PAINT_CLIENT_FLAGS); if (win->paint_flags & PAINT_HAS_PIXEL_FORMAT) update_pixel_format_flags( win );
+ win->monitor_dpi = req->monitor_dpi; set_window_pos( win, previous, flags, &window_rect, &client_rect, &visible_rect, &surface_rect, &valid_rect );