@@ -323,6 +323,10 @@ bool WindowManager::IsMinimized() {
323323}
324324
325325void WindowManager::Minimize () {
326+ if (IsFullScreen ()) { // Like chromium, we don't want to minimize fullscreen
327+ // windows
328+ return ;
329+ }
326330 HWND mainWindow = GetMainWindow ();
327331 WINDOWPLACEMENT windowPlacement;
328332 GetWindowPlacement (mainWindow, &windowPlacement);
@@ -352,7 +356,7 @@ int WindowManager::IsDocked() {
352356
353357double WindowManager::GetDpiForHwnd (HWND hWnd) {
354358 auto monitor = MonitorFromWindow (hWnd, MONITOR_DEFAULTTONEAREST);
355- UINT newDpiX = 96 ; // Default values
359+ UINT newDpiX = 96 ; // Default values
356360 UINT newDpiY = 96 ;
357361
358362 // Dynamically load shcore.dll and get the GetDpiForMonitor function address
@@ -362,21 +366,22 @@ double WindowManager::GetDpiForHwnd(HWND hWnd) {
362366 typedef HRESULT (*GetDpiForMonitor)(HMONITOR, int , UINT*, UINT*);
363367
364368 GetDpiForMonitor GetDpiForMonitorFunc =
365- (GetDpiForMonitor)GetProcAddress (shcore, " GetDpiForMonitor" );
369+ (GetDpiForMonitor)GetProcAddress (shcore, " GetDpiForMonitor" );
366370
367371 if (GetDpiForMonitorFunc) {
368372 // Use the loaded function if available
369373 const int MDT_EFFECTIVE_DPI = 0 ;
370- if (FAILED (GetDpiForMonitorFunc (monitor, MDT_EFFECTIVE_DPI, &newDpiX, &newDpiY))) {
374+ if (FAILED (GetDpiForMonitorFunc (monitor, MDT_EFFECTIVE_DPI, &newDpiX,
375+ &newDpiY))) {
371376 // If it fails, set the default values again
372377 newDpiX = 96 ;
373378 newDpiY = 96 ;
374379 }
375380 }
376381 FreeLibrary (shcore);
377382 }
378- return ((double ) newDpiX);
379- }
383+ return ((double )newDpiX);
384+ }
380385
381386void WindowManager::Dock (const flutter::EncodableMap& args) {
382387 HWND mainWindow = GetMainWindow ();
@@ -468,7 +473,6 @@ void PASCAL WindowManager::AppBarQuerySetPos(HWND hwnd,
468473}
469474
470475BOOL WindowManager::RegisterAccessBar (HWND hwnd, BOOL fRegister ) {
471-
472476 APPBARDATA abd;
473477
474478 // Specify the structure size and handle to the appbar.
@@ -550,8 +554,8 @@ void WindowManager::SetFullScreen(const flutter::EncodableMap& args) {
550554
551555 // Previously inspired by how Chromium does this
552556 // https://src.chromium.org/viewvc/chrome/trunk/src/ui/views/win/fullscreen_handler.cc?revision=247204&view=markup
553- // Instead, we use a modified implementation of how the media_kit package implements this
554- // (we got permission from the author, I believe)
557+ // Instead, we use a modified implementation of how the media_kit package
558+ // implements this (we got permission from the author, I believe)
555559 // https://github.com/alexmercerind/media_kit/blob/1226bcff36eab27cb17d60c33e9c15ca489c1f06/media_kit_video/windows/utils.cc
556560
557561 // Save current window state if not already fullscreen.
@@ -563,35 +567,40 @@ void WindowManager::SetFullScreen(const flutter::EncodableMap& args) {
563567 g_title_bar_style_before_fullscreen = title_bar_style_;
564568 }
565569
566- if (isFullScreen) {
570+ g_is_window_fullscreen = isFullScreen;
571+
572+ if (isFullScreen) { // Set to fullscreen
567573 ::SendMessage (mainWindow, WM_SYSCOMMAND, SC_MAXIMIZE, 0 );
568574 if (!is_frameless_) {
569- auto monitor = MONITORINFO{};
570- auto placement = WINDOWPLACEMENT{};
571- monitor.cbSize = sizeof (MONITORINFO);
572- placement.length = sizeof (WINDOWPLACEMENT);
573- ::GetWindowPlacement (mainWindow, &placement);
574- ::GetMonitorInfo (::MonitorFromWindow(mainWindow, MONITOR_DEFAULTTONEAREST),
575- &monitor);
576- ::SetWindowLongPtr (mainWindow, GWL_STYLE, g_style_before_fullscreen & ~WS_OVERLAPPEDWINDOW);
577- ::SetWindowPos (mainWindow, HWND_TOP, monitor.rcMonitor.left,
578- monitor.rcMonitor.top, monitor.rcMonitor.right - monitor.rcMonitor.left,
579- monitor.rcMonitor.bottom - monitor.rcMonitor.top,
580- SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
575+ auto monitor = MONITORINFO{};
576+ auto placement = WINDOWPLACEMENT{};
577+ monitor.cbSize = sizeof (MONITORINFO);
578+ placement.length = sizeof (WINDOWPLACEMENT);
579+ ::GetWindowPlacement (mainWindow, &placement);
580+ ::GetMonitorInfo (
581+ ::MonitorFromWindow (mainWindow, MONITOR_DEFAULTTONEAREST), &monitor);
582+ ::SetWindowLongPtr (mainWindow, GWL_STYLE,
583+ g_style_before_fullscreen & ~WS_OVERLAPPEDWINDOW);
584+ ::SetWindowPos (mainWindow, HWND_TOP, monitor.rcMonitor.left,
585+ monitor.rcMonitor.top,
586+ monitor.rcMonitor.right - monitor.rcMonitor.left,
587+ monitor.rcMonitor.bottom - monitor.rcMonitor.top,
588+ SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
581589 }
582- } else {
590+ } else { // Restore from fullscreen
583591 if (!g_maximized_before_fullscreen)
584592 Restore ();
585- ::SetWindowLongPtr (mainWindow, GWL_STYLE, g_style_before_fullscreen | WS_OVERLAPPEDWINDOW);
593+ ::SetWindowLongPtr (mainWindow, GWL_STYLE,
594+ g_style_before_fullscreen | WS_OVERLAPPEDWINDOW);
586595 if (::IsZoomed (mainWindow)) {
587596 // Refresh the parent mainWindow.
588597 ::SetWindowPos (mainWindow, nullptr , 0 , 0 , 0 , 0 ,
589598 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
590599 SWP_FRAMECHANGED);
591600 auto rect = RECT{};
592601 ::GetClientRect (mainWindow, &rect);
593- auto flutter_view =
594- ::FindWindowEx (mainWindow, nullptr , kFlutterViewWindowClassName , nullptr );
602+ auto flutter_view = :: FindWindowEx (mainWindow, nullptr ,
603+ kFlutterViewWindowClassName , nullptr );
595604 ::SetWindowPos (flutter_view, nullptr , rect.left, rect.top,
596605 rect.right - rect.left, rect.bottom - rect.top,
597606 SWP_NOACTIVATE | SWP_NOZORDER);
@@ -606,8 +615,6 @@ void WindowManager::SetFullScreen(const flutter::EncodableMap& args) {
606615 SWP_NOACTIVATE | SWP_NOZORDER);
607616 }
608617 }
609-
610- g_is_window_fullscreen = isFullScreen;
611618}
612619
613620void WindowManager::SetAspectRatio (const flutter::EncodableMap& args) {
@@ -838,22 +845,16 @@ void WindowManager::SetAlwaysOnTop(const flutter::EncodableMap& args) {
838845}
839846
840847bool WindowManager::IsAlwaysOnBottom () {
841- return is_always_on_bottom_;
848+ return is_always_on_bottom_;
842849}
843850
844851void WindowManager::SetAlwaysOnBottom (const flutter::EncodableMap& args) {
845852 is_always_on_bottom_ =
846853 std::get<bool >(args.at (flutter::EncodableValue (" isAlwaysOnBottom" )));
847854
848- SetWindowPos (
849- GetMainWindow (),
850- is_always_on_bottom_ ? HWND_BOTTOM : HWND_NOTOPMOST,
851- 0 ,
852- 0 ,
853- 0 ,
854- 0 ,
855- SWP_NOMOVE | SWP_NOSIZE
856- );
855+ SetWindowPos (GetMainWindow (),
856+ is_always_on_bottom_ ? HWND_BOTTOM : HWND_NOTOPMOST, 0 , 0 , 0 , 0 ,
857+ SWP_NOMOVE | SWP_NOSIZE);
857858}
858859
859860std::string WindowManager::GetTitle () {
0 commit comments