@@ -589,7 +589,7 @@ void WindowManager::SetFullScreen(const flutter::EncodableMap& args) {
589
589
g_is_window_fullscreen = isFullScreen;
590
590
591
591
if (isFullScreen) { // Set to fullscreen
592
- ::SendMessage (mainWindow, WM_SYSCOMMAND, SC_MAXIMIZE, 0 );
592
+ // ::SendMessage(mainWindow, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
593
593
if (!is_frameless_) {
594
594
auto monitor = MONITORINFO{};
595
595
auto placement = WINDOWPLACEMENT{};
@@ -598,19 +598,26 @@ void WindowManager::SetFullScreen(const flutter::EncodableMap& args) {
598
598
::GetWindowPlacement (mainWindow, &placement);
599
599
::GetMonitorInfo (
600
600
::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));
603
607
::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 ,
605
611
monitor.rcMonitor.right - monitor.rcMonitor.left,
606
612
monitor.rcMonitor.bottom - monitor.rcMonitor.top,
607
- SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
613
+ SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
608
614
}
609
615
} 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));
614
621
if (::IsZoomed (mainWindow)) {
615
622
// Refresh the parent mainWindow.
616
623
::SetWindowPos (mainWindow, nullptr , 0 , 0 , 0 , 0 ,
@@ -632,6 +639,17 @@ void WindowManager::SetFullScreen(const flutter::EncodableMap& args) {
632
639
g_frame_before_fullscreen.right - g_frame_before_fullscreen.left,
633
640
g_frame_before_fullscreen.bottom - g_frame_before_fullscreen.top,
634
641
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);
635
653
}
636
654
}
637
655
}
0 commit comments