@@ -589,7 +589,7 @@ void WindowManager::SetFullScreen(const flutter::EncodableMap& args) {
589589 g_is_window_fullscreen = isFullScreen;
590590
591591 if (isFullScreen) { // Set to fullscreen
592- ::SendMessage (mainWindow, WM_SYSCOMMAND, SC_MAXIMIZE, 0 );
592+ // ::SendMessage(mainWindow, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
593593 if (!is_frameless_) {
594594 auto monitor = MONITORINFO{};
595595 auto placement = WINDOWPLACEMENT{};
@@ -598,19 +598,26 @@ void WindowManager::SetFullScreen(const flutter::EncodableMap& args) {
598598 ::GetWindowPlacement (mainWindow, &placement);
599599 ::GetMonitorInfo (
600600 ::MonitorFromWindow (mainWindow, MONITOR_DEFAULTTONEAREST), &monitor);
601- ::SetWindowLongPtr (mainWindow, GWL_STYLE,
602- g_style_before_fullscreen & ~WS_OVERLAPPEDWINDOW);
601+ if (!g_maximized_before_fullscreen) {
602+ SetAsFrameless ();
603+ }
604+ ::SetWindowLongPtr (
605+ mainWindow, GWL_STYLE,
606+ g_style_before_fullscreen & ~(WS_THICKFRAME | WS_MAXIMIZEBOX));
603607 ::SetWindowPos (mainWindow, HWND_TOP, monitor.rcMonitor.left,
604- monitor.rcMonitor.top,
608+ monitor.rcMonitor.top, 0 , 0 ,
609+ SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
610+ ::SetWindowPos (mainWindow, HWND_TOP, 0 , 0 ,
605611 monitor.rcMonitor.right - monitor.rcMonitor.left,
606612 monitor.rcMonitor.bottom - monitor.rcMonitor.top,
607- SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
613+ SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
608614 }
609615 } else { // Restore from fullscreen
610- if (!g_maximized_before_fullscreen)
611- Restore ();
612- ::SetWindowLongPtr (mainWindow, GWL_STYLE,
613- g_style_before_fullscreen | WS_OVERLAPPEDWINDOW);
616+ // if (!g_maximized_before_fullscreen)
617+ // Restore();
618+ ::SetWindowLongPtr (
619+ mainWindow, GWL_STYLE,
620+ g_style_before_fullscreen | (WS_THICKFRAME | WS_MAXIMIZEBOX));
614621 if (::IsZoomed (mainWindow)) {
615622 // Refresh the parent mainWindow.
616623 ::SetWindowPos (mainWindow, nullptr , 0 , 0 , 0 , 0 ,
@@ -632,6 +639,17 @@ void WindowManager::SetFullScreen(const flutter::EncodableMap& args) {
632639 g_frame_before_fullscreen.right - g_frame_before_fullscreen.left,
633640 g_frame_before_fullscreen.bottom - g_frame_before_fullscreen.top,
634641 SWP_NOACTIVATE | SWP_NOZORDER);
642+
643+ // restore titlebar style
644+ title_bar_style_ = g_title_bar_style_before_fullscreen;
645+ is_frameless_ = false ;
646+ MARGINS margins = {0 , 0 , 0 , 0 };
647+ RECT rect1;
648+ GetWindowRect (mainWindow, &rect1);
649+ DwmExtendFrameIntoClientArea (mainWindow, &margins);
650+ SetWindowPos (mainWindow, nullptr , rect1.left , rect1.top , 0 , 0 ,
651+ SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE |
652+ SWP_FRAMECHANGED);
635653 }
636654 }
637655}
0 commit comments