@@ -62,9 +62,24 @@ class WindowManagerPlugin : public flutter::Plugin {
62
62
const flutter::MethodCall<flutter::EncodableValue>& method_call,
63
63
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
64
64
65
- void adjustNCCALCSIZE (NCCALCSIZE_PARAMS* sz) {
66
- LONG l = sz->rgrc [0 ].left ;
67
- LONG t = sz->rgrc [0 ].top ;
65
+ void adjustNCCALCSIZE (HWND hwnd, NCCALCSIZE_PARAMS* sz) {
66
+ LONG l = 8 ;
67
+ LONG t = 8 ;
68
+
69
+ HMONITOR monitor = MonitorFromWindow (hwnd, MONITOR_DEFAULTTONEAREST);
70
+ if (monitor != NULL ) {
71
+ MONITORINFO monitorInfo;
72
+ monitorInfo.cbSize = sizeof (MONITORINFO);
73
+ if (TRUE == GetMonitorInfo (monitor, &monitorInfo)) {
74
+ l = sz->rgrc [0 ].left - monitorInfo.rcWork .left ;
75
+ t = sz->rgrc [0 ].top - monitorInfo.rcWork .top ;
76
+ } else {
77
+ // GetMonitorInfo failed, use (8, 8) as default value
78
+ }
79
+ } else {
80
+ // unreachable code
81
+ }
82
+
68
83
sz->rgrc [0 ].left -= l;
69
84
sz->rgrc [0 ].top -= t;
70
85
sz->rgrc [0 ].right += l;
@@ -105,7 +120,8 @@ WindowManagerPlugin::~WindowManagerPlugin() {
105
120
}
106
121
107
122
void WindowManagerPlugin::_EmitEvent (std::string eventName) {
108
- if (channel == nullptr ) return ;
123
+ if (channel == nullptr )
124
+ return ;
109
125
flutter::EncodableMap args = flutter::EncodableMap ();
110
126
args[flutter::EncodableValue (" eventName" )] =
111
127
flutter::EncodableValue (eventName);
@@ -128,15 +144,15 @@ std::optional<LRESULT> WindowManagerPlugin::HandleWindowProc(HWND hWnd,
128
144
if (window_manager->IsFullScreen () &&
129
145
window_manager->title_bar_style_ != " normal" ) {
130
146
if (window_manager->is_frameless_ ) {
131
- adjustNCCALCSIZE (reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam));
147
+ adjustNCCALCSIZE (hWnd, reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam));
132
148
}
133
149
return 0 ;
134
150
}
135
151
// This must always be before handling title_bar_style_ == "hidden" so
136
152
// the `if TitleBarStyle.hidden` doesn't get executed.
137
153
if (window_manager->is_frameless_ ) {
138
154
if (window_manager->IsMaximized ()) {
139
- adjustNCCALCSIZE (reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam));
155
+ adjustNCCALCSIZE (hWnd, reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam));
140
156
}
141
157
return 0 ;
142
158
}
@@ -145,12 +161,17 @@ std::optional<LRESULT> WindowManagerPlugin::HandleWindowProc(HWND hWnd,
145
161
if (wParam && window_manager->title_bar_style_ == " hidden" ) {
146
162
if (window_manager->IsMaximized ()) {
147
163
// Adjust the borders when maximized so the app isn't cut off
148
- adjustNCCALCSIZE (reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam));
164
+ adjustNCCALCSIZE (hWnd, reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam));
149
165
} else {
150
166
NCCALCSIZE_PARAMS* sz = reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam);
151
167
// on windows 10, if set to 0, there's a white line at the top
152
168
// of the app and I've yet to find a way to remove that.
153
169
sz->rgrc [0 ].top += IsWindows11OrGreater () ? 0 : 1 ;
170
+ // The following lines are required for resizing the window.
171
+ // https://github.com/leanflutter/window_manager/issues/483
172
+ sz->rgrc [0 ].right -= 8 ;
173
+ sz->rgrc [0 ].bottom -= 8 ;
174
+ sz->rgrc [0 ].left -= -8 ;
154
175
}
155
176
156
177
// Previously (WVR_HREDRAW | WVR_VREDRAW), but returning 0 or 1 doesn't
0 commit comments