From a98641cf45042f7c76c3dd7913dfdd61ce0c073b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 1 Oct 2023 17:44:15 +0200 Subject: [PATCH] win32: add WS_THICKFRAME style in borderless mode Fixes window resizing in borderless mode after adding WS_SYSMENU. Fixes: 172d9be3005c6a85f4f139f1dedccefe26ea8d91 --- video/out/w32_common.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 8db3e35c34f87..931a902c76439 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -174,6 +174,9 @@ struct vo_w32_state { static void adjust_window_rect(struct vo_w32_state *w32, HWND hwnd, RECT *rc) { + if (!w32->opts->border) + return; + if (w32->api.pAdjustWindowRectExForDpi) { w32->api.pAdjustWindowRectExForDpi(rc, GetWindowLongPtrW(hwnd, GWL_STYLE), 0, @@ -811,7 +814,7 @@ static bool snap_to_screen_edges(struct vo_w32_state *w32, RECT *rc) static DWORD update_style(struct vo_w32_state *w32, DWORD style) { - const DWORD NO_FRAME = WS_OVERLAPPED | WS_MINIMIZEBOX; + const DWORD NO_FRAME = WS_OVERLAPPED | WS_MINIMIZEBOX | WS_THICKFRAME; const DWORD FRAME = WS_OVERLAPPEDWINDOW; const DWORD FULLSCREEN = NO_FRAME; style &= ~(NO_FRAME | FRAME | FULLSCREEN); @@ -1282,6 +1285,9 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, break; } break; + case WM_NCACTIVATE: + // Cosmetic to remove blinking window border when initializing window + return 1; case WM_NCHITTEST: // Provide sizing handles for borderless windows if ((!w32->opts->border || !w32->opts->title_bar) && !w32->current_fs) { @@ -1406,6 +1412,8 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, update_dark_mode(w32); break; case WM_NCCALCSIZE: + if (!w32->opts->border) + return 0; // Apparently removing WS_CAPTION disables some window animation, instead // just reduce non-client size to remove title bar. if (wParam && lParam && w32->opts->border && !w32->opts->title_bar &&