Skip to content

Commit

Permalink
win32: add WS_THICKFRAME style in borderless mode
Browse files Browse the repository at this point in the history
Fixes window resizing in borderless mode after adding WS_SYSMENU.

Fixes: 172d9be
  • Loading branch information
kasper93 authored and Dudemanguy committed Oct 1, 2023
1 parent 0b70598 commit a98641c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion video/out/w32_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 &&
Expand Down

0 comments on commit a98641c

Please sign in to comment.