@@ -62,9 +62,24 @@ class WindowManagerPlugin : public flutter::Plugin {
6262 const flutter::MethodCall<flutter::EncodableValue>& method_call,
6363 std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
6464
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+
6883 sz->rgrc [0 ].left -= l;
6984 sz->rgrc [0 ].top -= t;
7085 sz->rgrc [0 ].right += l;
@@ -105,7 +120,8 @@ WindowManagerPlugin::~WindowManagerPlugin() {
105120}
106121
107122void WindowManagerPlugin::_EmitEvent (std::string eventName) {
108- if (channel == nullptr ) return ;
123+ if (channel == nullptr )
124+ return ;
109125 flutter::EncodableMap args = flutter::EncodableMap ();
110126 args[flutter::EncodableValue (" eventName" )] =
111127 flutter::EncodableValue (eventName);
@@ -128,15 +144,15 @@ std::optional<LRESULT> WindowManagerPlugin::HandleWindowProc(HWND hWnd,
128144 if (window_manager->IsFullScreen () &&
129145 window_manager->title_bar_style_ != " normal" ) {
130146 if (window_manager->is_frameless_ ) {
131- adjustNCCALCSIZE (reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam));
147+ adjustNCCALCSIZE (hWnd, reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam));
132148 }
133149 return 0 ;
134150 }
135151 // This must always be before handling title_bar_style_ == "hidden" so
136152 // the `if TitleBarStyle.hidden` doesn't get executed.
137153 if (window_manager->is_frameless_ ) {
138154 if (window_manager->IsMaximized ()) {
139- adjustNCCALCSIZE (reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam));
155+ adjustNCCALCSIZE (hWnd, reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam));
140156 }
141157 return 0 ;
142158 }
@@ -145,12 +161,17 @@ std::optional<LRESULT> WindowManagerPlugin::HandleWindowProc(HWND hWnd,
145161 if (wParam && window_manager->title_bar_style_ == " hidden" ) {
146162 if (window_manager->IsMaximized ()) {
147163 // 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));
149165 } else {
150166 NCCALCSIZE_PARAMS* sz = reinterpret_cast <NCCALCSIZE_PARAMS*>(lParam);
151167 // on windows 10, if set to 0, there's a white line at the top
152168 // of the app and I've yet to find a way to remove that.
153169 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 ;
154175 }
155176
156177 // Previously (WVR_HREDRAW | WVR_VREDRAW), but returning 0 or 1 doesn't
0 commit comments