@@ -323,6 +323,10 @@ bool WindowManager::IsMinimized() {
323
323
}
324
324
325
325
void WindowManager::Minimize () {
326
+ if (IsFullScreen ()) { // Like chromium, we don't want to minimize fullscreen
327
+ // windows
328
+ return ;
329
+ }
326
330
HWND mainWindow = GetMainWindow ();
327
331
WINDOWPLACEMENT windowPlacement;
328
332
GetWindowPlacement (mainWindow, &windowPlacement);
@@ -352,7 +356,7 @@ int WindowManager::IsDocked() {
352
356
353
357
double WindowManager::GetDpiForHwnd (HWND hWnd) {
354
358
auto monitor = MonitorFromWindow (hWnd, MONITOR_DEFAULTTONEAREST);
355
- UINT newDpiX = 96 ; // Default values
359
+ UINT newDpiX = 96 ; // Default values
356
360
UINT newDpiY = 96 ;
357
361
358
362
// Dynamically load shcore.dll and get the GetDpiForMonitor function address
@@ -362,21 +366,22 @@ double WindowManager::GetDpiForHwnd(HWND hWnd) {
362
366
typedef HRESULT (*GetDpiForMonitor)(HMONITOR, int , UINT*, UINT*);
363
367
364
368
GetDpiForMonitor GetDpiForMonitorFunc =
365
- (GetDpiForMonitor)GetProcAddress (shcore, " GetDpiForMonitor" );
369
+ (GetDpiForMonitor)GetProcAddress (shcore, " GetDpiForMonitor" );
366
370
367
371
if (GetDpiForMonitorFunc) {
368
372
// Use the loaded function if available
369
373
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))) {
371
376
// If it fails, set the default values again
372
377
newDpiX = 96 ;
373
378
newDpiY = 96 ;
374
379
}
375
380
}
376
381
FreeLibrary (shcore);
377
382
}
378
- return ((double ) newDpiX);
379
- }
383
+ return ((double )newDpiX);
384
+ }
380
385
381
386
void WindowManager::Dock (const flutter::EncodableMap& args) {
382
387
HWND mainWindow = GetMainWindow ();
@@ -468,7 +473,6 @@ void PASCAL WindowManager::AppBarQuerySetPos(HWND hwnd,
468
473
}
469
474
470
475
BOOL WindowManager::RegisterAccessBar (HWND hwnd, BOOL fRegister ) {
471
-
472
476
APPBARDATA abd;
473
477
474
478
// Specify the structure size and handle to the appbar.
@@ -550,8 +554,8 @@ void WindowManager::SetFullScreen(const flutter::EncodableMap& args) {
550
554
551
555
// Previously inspired by how Chromium does this
552
556
// 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)
555
559
// https://github.com/alexmercerind/media_kit/blob/1226bcff36eab27cb17d60c33e9c15ca489c1f06/media_kit_video/windows/utils.cc
556
560
557
561
// Save current window state if not already fullscreen.
@@ -563,35 +567,40 @@ void WindowManager::SetFullScreen(const flutter::EncodableMap& args) {
563
567
g_title_bar_style_before_fullscreen = title_bar_style_;
564
568
}
565
569
566
- if (isFullScreen) {
570
+ g_is_window_fullscreen = isFullScreen;
571
+
572
+ if (isFullScreen) { // Set to fullscreen
567
573
::SendMessage (mainWindow, WM_SYSCOMMAND, SC_MAXIMIZE, 0 );
568
574
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);
581
589
}
582
- } else {
590
+ } else { // Restore from fullscreen
583
591
if (!g_maximized_before_fullscreen)
584
592
Restore ();
585
- ::SetWindowLongPtr (mainWindow, GWL_STYLE, g_style_before_fullscreen | WS_OVERLAPPEDWINDOW);
593
+ ::SetWindowLongPtr (mainWindow, GWL_STYLE,
594
+ g_style_before_fullscreen | WS_OVERLAPPEDWINDOW);
586
595
if (::IsZoomed (mainWindow)) {
587
596
// Refresh the parent mainWindow.
588
597
::SetWindowPos (mainWindow, nullptr , 0 , 0 , 0 , 0 ,
589
598
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
590
599
SWP_FRAMECHANGED);
591
600
auto rect = RECT{};
592
601
::GetClientRect (mainWindow, &rect);
593
- auto flutter_view =
594
- ::FindWindowEx (mainWindow, nullptr , kFlutterViewWindowClassName , nullptr );
602
+ auto flutter_view = :: FindWindowEx (mainWindow, nullptr ,
603
+ kFlutterViewWindowClassName , nullptr );
595
604
::SetWindowPos (flutter_view, nullptr , rect.left, rect.top,
596
605
rect.right - rect.left, rect.bottom - rect.top,
597
606
SWP_NOACTIVATE | SWP_NOZORDER);
@@ -606,8 +615,6 @@ void WindowManager::SetFullScreen(const flutter::EncodableMap& args) {
606
615
SWP_NOACTIVATE | SWP_NOZORDER);
607
616
}
608
617
}
609
-
610
- g_is_window_fullscreen = isFullScreen;
611
618
}
612
619
613
620
void WindowManager::SetAspectRatio (const flutter::EncodableMap& args) {
@@ -838,22 +845,16 @@ void WindowManager::SetAlwaysOnTop(const flutter::EncodableMap& args) {
838
845
}
839
846
840
847
bool WindowManager::IsAlwaysOnBottom () {
841
- return is_always_on_bottom_;
848
+ return is_always_on_bottom_;
842
849
}
843
850
844
851
void WindowManager::SetAlwaysOnBottom (const flutter::EncodableMap& args) {
845
852
is_always_on_bottom_ =
846
853
std::get<bool >(args.at (flutter::EncodableValue (" isAlwaysOnBottom" )));
847
854
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);
857
858
}
858
859
859
860
std::string WindowManager::GetTitle () {
0 commit comments