@@ -133,15 +133,21 @@ void FlutterWindow::SetupPipChannel() {
133133 }
134134
135135 if (!is_pip_) {
136- pip_saved_style_ = GetWindowLongPtr (hwnd, GWL_STYLE );
137136 pip_saved_placement_.length = sizeof (WINDOWPLACEMENT );
138137 GetWindowPlacement (hwnd, &pip_saved_placement_);
139138 }
140139
141- // Size the PiP window to ~380 px wide, height from aspect ratio.
142- const int pip_w = 380 ;
143- const int pip_h =
144- static_cast <int >(pip_w / aspect_ratio + 0.5 );
140+ // Keep the existing window style (title bar stays) to avoid
141+ // triggering a D3D surface rebuild that corrupts the FVP renderer.
142+ // Only the size, position, and z-order change.
143+ const LONG_PTR cur_style = GetWindowLongPtr (hwnd, GWL_STYLE );
144+
145+ // Compute the window rect that gives the desired client video area.
146+ // AdjustWindowRect accounts for title bar + borders in cur_style.
147+ RECT wr{0 , 0 , 380 , static_cast <LONG >(380.0 / aspect_ratio + 0.5 )};
148+ AdjustWindowRect (&wr, static_cast <DWORD >(cur_style), FALSE );
149+ const int pip_w = wr.right - wr.left ;
150+ const int pip_h = wr.bottom - wr.top ;
145151
146152 // Position at bottom-right of the monitor work area.
147153 MONITORINFO mi{sizeof (mi)};
@@ -151,10 +157,8 @@ void FlutterWindow::SetupPipChannel() {
151157 const int pip_x = mi.rcWork .right - pip_w - kMargin ;
152158 const int pip_y = mi.rcWork .bottom - pip_h - kMargin ;
153159
154- // Borderless with a thin resize frame (no title bar).
155- SetWindowLongPtr (hwnd, GWL_STYLE , WS_POPUP | WS_THICKFRAME );
156160 SetWindowPos (hwnd, HWND_TOPMOST , pip_x, pip_y, pip_w, pip_h,
157- SWP_NOOWNERZORDER | SWP_FRAMECHANGED | SWP_SHOWWINDOW );
161+ SWP_NOOWNERZORDER | SWP_SHOWWINDOW );
158162 is_pip_ = true ;
159163
160164 if (pip_channel_) {
@@ -168,11 +172,10 @@ void FlutterWindow::SetupPipChannel() {
168172 call.method_name () == " exit" ) {
169173 if (is_pip_) {
170174 is_pip_ = false ;
171- SetWindowLongPtr (hwnd, GWL_STYLE , pip_saved_style_);
172175 SetWindowPlacement (hwnd, &pip_saved_placement_);
173176 SetWindowPos (hwnd, HWND_NOTOPMOST , 0 , 0 , 0 , 0 ,
174177 SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER |
175- SWP_FRAMECHANGED | SWP_SHOWWINDOW );
178+ SWP_SHOWWINDOW );
176179 SetForegroundWindow (hwnd);
177180
178181 if (pip_channel_) {
@@ -209,17 +212,6 @@ LRESULT
209212FlutterWindow::MessageHandler (HWND hwnd, UINT const message,
210213 WPARAM const wparam,
211214 LPARAM const lparam) noexcept {
212- // In PiP mode the top 28 px acts as a drag strip so the frameless window
213- // can still be moved by the user. Handle this before Flutter sees it.
214- if (message == WM_NCHITTEST && is_pip_) {
215- const int py = static_cast <int >(static_cast <short >(HIWORD (lparam)));
216- RECT rc;
217- GetWindowRect (hwnd, &rc);
218- if (py < rc.top + 28 ) {
219- return HTCAPTION ;
220- }
221- }
222-
223215 switch (message) {
224216 case WM_CLOSE :
225217 if (!is_pip_) SaveWindowGeometry (hwnd);
0 commit comments