@@ -61,6 +61,15 @@ class WindowManagerPlugin : public flutter::Plugin {
61
61
void HandleMethodCall (
62
62
const flutter::MethodCall<flutter::EncodableValue>& method_call,
63
63
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
64
+
65
+ void adjustNCCALCSIZE (NCCALCSIZE_PARAMS* sz) {
66
+ LONG l = sz->rgrc [0 ].left ;
67
+ LONG t = sz->rgrc [0 ].top ;
68
+ sz->rgrc [0 ].left -= l;
69
+ sz->rgrc [0 ].top -= t;
70
+ sz->rgrc [0 ].right += l;
71
+ sz->rgrc [0 ].bottom += t;
72
+ }
64
73
};
65
74
66
75
// static
@@ -119,43 +128,30 @@ std::optional<LRESULT> WindowManagerPlugin::HandleWindowProc(HWND hWnd,
119
128
if (window_manager->IsFullScreen () &&
120
129
window_manager->title_bar_style_ != " normal" ) {
121
130
if (window_manager->is_frameless_ ) {
122
- NCCALCSIZE_PARAMS* sz = reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam);
123
- sz->rgrc [0 ].left += 8 ;
124
- sz->rgrc [0 ].top += 8 ;
125
- sz->rgrc [0 ].right -= 8 ;
126
- sz->rgrc [0 ].bottom -= 8 ;
131
+ adjustNCCALCSIZE (reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam));
127
132
}
128
133
return 0 ;
129
134
}
130
135
// This must always be before handling title_bar_style_ == "hidden" so
131
136
// the `if TitleBarStyle.hidden` doesn't get executed.
132
137
if (window_manager->is_frameless_ ) {
133
- NCCALCSIZE_PARAMS* sz = reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam);
134
138
if (window_manager->IsMaximized ()) {
135
- // Add borders when maximized so app doesn't get cut off.
136
- sz->rgrc [0 ].left += 8 ;
137
- sz->rgrc [0 ].top += 8 ;
138
- sz->rgrc [0 ].right -= 8 ;
139
- sz->rgrc [0 ].bottom -= 9 ;
139
+ adjustNCCALCSIZE (reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam));
140
140
}
141
141
return 0 ;
142
142
}
143
143
144
144
// This must always be last.
145
145
if (wParam && window_manager->title_bar_style_ == " hidden" ) {
146
- NCCALCSIZE_PARAMS* sz = reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam);
147
-
148
- // Add 8 pixel to the top border when maximized so the app isn't cut off
149
146
if (window_manager->IsMaximized ()) {
150
- sz->rgrc [0 ].top += 8 ;
147
+ // Adjust the borders when maximized so the app isn't cut off
148
+ adjustNCCALCSIZE (reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam));
151
149
} else {
150
+ NCCALCSIZE_PARAMS* sz = reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam);
152
151
// on windows 10, if set to 0, there's a white line at the top
153
152
// of the app and I've yet to find a way to remove that.
154
153
sz->rgrc [0 ].top += IsWindows11OrGreater () ? 0 : 1 ;
155
154
}
156
- sz->rgrc [0 ].right -= 8 ;
157
- sz->rgrc [0 ].bottom -= 8 ;
158
- sz->rgrc [0 ].left -= -8 ;
159
155
160
156
// Previously (WVR_HREDRAW | WVR_VREDRAW), but returning 0 or 1 doesn't
161
157
// actually break anything so I've set it to 0. Unless someone pointed a
0 commit comments