Skip to content

Commit 4a0890e

Browse files
authored
Merge pull request #46 from damywise/main
Fix setResizable glitch on titleBarStyle="hidden"
2 parents 7df34c4 + 8836f75 commit 4a0890e

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

windows/window_manager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ void WindowManager::SetResizable(const flutter::EncodableMap &args)
450450
DWORD gwlStyle = GetWindowLong(hWnd, GWL_STYLE);
451451
gwlStyle = isResizable ? gwlStyle | WS_THICKFRAME : gwlStyle & ~WS_THICKFRAME;
452452
SetWindowLong(hWnd, GWL_STYLE, gwlStyle);
453+
SetWindowPos(hWnd, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_DRAWFRAME);
453454
}
454455

455456
bool WindowManager::IsMinimizable()

windows/window_manager_plugin.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,7 @@ std::optional<LRESULT> WindowManagerPlugin::HandleWindowProc(HWND hWnd, UINT mes
8585
{
8686
std::optional<LRESULT> result = std::nullopt;
8787

88-
if (message == WM_NCPAINT)
89-
{
90-
if (window_manager->title_bar_style == "hidden")
91-
return 1;
92-
}
93-
else if (message == WM_NCCALCSIZE)
88+
if (message == WM_NCCALCSIZE)
9489
{
9590
if (wParam && window_manager->is_frameless)
9691
{
@@ -105,18 +100,25 @@ std::optional<LRESULT> WindowManagerPlugin::HandleWindowProc(HWND hWnd, UINT mes
105100
GetWindowPlacement(hWnd, &wPos);
106101
RECT borderThickness;
107102
SetRectEmpty(&borderThickness);
108-
AdjustWindowRectEx(&borderThickness, GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION, FALSE, NULL);
103+
AdjustWindowRectEx(&borderThickness, GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION & WS_BORDER, FALSE, NULL);
109104
NCCALCSIZE_PARAMS *sz = reinterpret_cast<NCCALCSIZE_PARAMS *>(lParam);
105+
106+
bool isResizable = window_manager->IsResizable();
110107
// Add 1 pixel to the top border to make the window resizable from the top border
111-
sz->rgrc[0].top += 1;
112-
sz->rgrc[0].right -= borderThickness.right;
113-
sz->rgrc[0].bottom -= borderThickness.bottom;
114-
sz->rgrc[0].left -= borderThickness.left;
108+
sz->rgrc[0].top += isResizable ? 1 : 0;
109+
sz->rgrc[0].right -= isResizable ? 7 : 0;
110+
sz->rgrc[0].bottom -= isResizable ? 7 : 0;
111+
sz->rgrc[0].left += isResizable ? 7 : 0;
115112

116113
return (WVR_HREDRAW | WVR_VREDRAW);
117114
}
118115
}
119-
else if (message == WM_NCHITTEST)
116+
if (message == WM_NCPAINT)
117+
{
118+
if (window_manager->title_bar_style == "hidden")
119+
return 1;
120+
}
121+
else if (message == WM_NCHITTEST)
120122
{
121123
LONG width = 10;
122124
POINT mouse = {LOWORD(lParam), HIWORD(lParam)};

0 commit comments

Comments
 (0)