From 37c22c871cde992aec6ff638bc3cbc73890504e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Mon, 16 Mar 2026 15:30:22 +0100 Subject: [PATCH 1/2] w32_common: add missing title bar height calc back I've lost this piece of code when doing rebases or testing. This is needed to correctly calc maximized window size. --- video/out/w32_common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 2ef475e9d86a2..2db5384bb3327 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -231,7 +231,11 @@ static int get_title_bar_height(struct vo_w32_state *w32) DwmGetWindowAttribute(w32->window, DWMWA_VISIBLE_FRAME_BORDER_THICKNESS, &visible_border, sizeof(visible_border)); } - return visible_border; + int top_bar = IsMaximized(w32->window) + ? get_system_metrics(w32, SM_CYFRAME) + + get_system_metrics(w32, SM_CXPADDEDBORDER) + : visible_border; + return top_bar; } static void add_window_borders(struct vo_w32_state *w32, HWND hwnd, RECT *rc) From 93c397c10b68cc164b33a529ac19d4ac6c1fa196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Mon, 16 Mar 2026 15:36:14 +0100 Subject: [PATCH 2/2] w32_common: force DWMWA_EXTENDED_FRAME_BOUNDS to work on init DWMWA_EXTENDED_FRAME_BOUNDS is not available before window is shown, so show it off-screen to get correct values. Fixes: https://github.com/mpv-player/mpv/pull/16127#issuecomment-4063603866 --- video/out/w32_common.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 2db5384bb3327..14ebc6980122c 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -1935,6 +1935,16 @@ static void window_resize(struct vo_w32_state *w32) } else { ShowWindow(w32->window, SW_SHOW); } + + // DWMWA_EXTENDED_FRAME_BOUNDS doesn't work when the window was not yet + // shown. We need it to correctly account for invisible window borders. + // Do one more forced resize after showing the window. This is only + // needed for Windows 10, but let's do the same for Windows 11 to get + // the same init behavior. In practice, this will only cause small + // adjustment to window position based on invisible borders, on + // Windows 11 it should be a no-op. + w32->pending_reset_size = true; + window_resize(w32); } finish: