win32: add WS_THICKFRAME style in borderless mode

Fixes window resizing in borderless mode after adding WS_SYSMENU.

Fixes: 172d9be300
This commit is contained in:
Kacper Michajłow 2023-10-01 17:44:15 +02:00 committed by Dudemanguy
parent 0b70598358
commit a98641cf45
1 changed files with 9 additions and 1 deletions

View File

@ -174,6 +174,9 @@ struct vo_w32_state {
static void adjust_window_rect(struct vo_w32_state *w32, HWND hwnd, RECT *rc) static void adjust_window_rect(struct vo_w32_state *w32, HWND hwnd, RECT *rc)
{ {
if (!w32->opts->border)
return;
if (w32->api.pAdjustWindowRectExForDpi) { if (w32->api.pAdjustWindowRectExForDpi) {
w32->api.pAdjustWindowRectExForDpi(rc, w32->api.pAdjustWindowRectExForDpi(rc,
GetWindowLongPtrW(hwnd, GWL_STYLE), 0, 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) 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 FRAME = WS_OVERLAPPEDWINDOW;
const DWORD FULLSCREEN = NO_FRAME; const DWORD FULLSCREEN = NO_FRAME;
style &= ~(NO_FRAME | FRAME | FULLSCREEN); style &= ~(NO_FRAME | FRAME | FULLSCREEN);
@ -1282,6 +1285,9 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
break; break;
} }
break; break;
case WM_NCACTIVATE:
// Cosmetic to remove blinking window border when initializing window
return 1;
case WM_NCHITTEST: case WM_NCHITTEST:
// Provide sizing handles for borderless windows // Provide sizing handles for borderless windows
if ((!w32->opts->border || !w32->opts->title_bar) && !w32->current_fs) { 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); update_dark_mode(w32);
break; break;
case WM_NCCALCSIZE: case WM_NCCALCSIZE:
if (!w32->opts->border)
return 0;
// Apparently removing WS_CAPTION disables some window animation, instead // Apparently removing WS_CAPTION disables some window animation, instead
// just reduce non-client size to remove title bar. // just reduce non-client size to remove title bar.
if (wParam && lParam && w32->opts->border && !w32->opts->title_bar && if (wParam && lParam && w32->opts->border && !w32->opts->title_bar &&