File tree Expand file tree Collapse file tree 3 files changed +23
-25
lines changed
engine/src/flutter/shell/platform/windows Expand file tree Collapse file tree 3 files changed +23
-25
lines changed Original file line number Diff line number Diff line change @@ -446,10 +446,6 @@ FlutterHostWindow* FlutterHostWindow::GetThisFromHandle(HWND hwnd) {
446446 GetWindowLongPtr (hwnd, GWLP_USERDATA));
447447}
448448
449- WindowState FlutterHostWindow::GetState () const {
450- return state_;
451- }
452-
453449HWND FlutterHostWindow::GetWindowHandle () const {
454450 return window_handle_;
455451}
@@ -593,6 +589,25 @@ void FlutterHostWindow::SetChildContent(HWND content) {
593589 client_rect.bottom - client_rect.top , true );
594590}
595591
592+ void FlutterHostWindow::SetState (WindowState state) {
593+ WINDOWPLACEMENT window_placement = {.length = sizeof (WINDOWPLACEMENT)};
594+ GetWindowPlacement (window_handle_, &window_placement);
595+ window_placement.showCmd = [&]() {
596+ switch (state) {
597+ case WindowState::kRestored :
598+ return SW_RESTORE;
599+ case WindowState::kMaximized :
600+ return SW_MAXIMIZE;
601+ case WindowState::kMinimized :
602+ return SW_MINIMIZE;
603+ default :
604+ FML_UNREACHABLE ();
605+ };
606+ }();
607+ SetWindowPlacement (window_handle_, &window_placement);
608+ state_ = state;
609+ }
610+
596611void FlutterHostWindow::SetTitle (std::string_view title) const {
597612 std::wstring title_wide = StringToWstring (title);
598613 SetWindowText (window_handle_, title_wide.c_str ());
Original file line number Diff line number Diff line change @@ -33,9 +33,6 @@ class FlutterHostWindow {
3333 // Returns the instance pointer for |hwnd| or nulllptr if invalid.
3434 static FlutterHostWindow* GetThisFromHandle (HWND hwnd);
3535
36- // Returns the current window state.
37- WindowState GetState () const ;
38-
3936 // Returns the backing window handle, or nullptr if the native window is not
4037 // created or has already been destroyed.
4138 HWND GetWindowHandle () const ;
@@ -63,6 +60,9 @@ class FlutterHostWindow {
6360 // Inserts |content| into the window tree.
6461 void SetChildContent (HWND content);
6562
63+ // Sets the window state.
64+ void SetState (WindowState state);
65+
6666 // Sets the window title.
6767 void SetTitle (std::string_view title) const ;
6868
Original file line number Diff line number Diff line change @@ -69,8 +69,6 @@ bool FlutterHostWindowController::ModifyHostWindow(
6969 return false ;
7070 }
7171
72- HWND const window_handle = window->GetWindowHandle ();
73-
7472 std::optional<Size> changed_size;
7573 Size const size_before = GetViewSize (view_id);
7674
@@ -81,22 +79,7 @@ bool FlutterHostWindowController::ModifyHostWindow(
8179 window->SetTitle (*settings.title );
8280 }
8381 if (settings.state .has_value ()) {
84- WINDOWPLACEMENT window_placement = {.length = sizeof (WINDOWPLACEMENT)};
85- if (GetWindowPlacement (window_handle, &window_placement)) {
86- window_placement.showCmd = [&]() {
87- switch (*settings.state ) {
88- case WindowState::kRestored :
89- return SW_RESTORE;
90- case WindowState::kMaximized :
91- return SW_MAXIMIZE;
92- case WindowState::kMinimized :
93- return SW_MINIMIZE;
94- default :
95- FML_UNREACHABLE ();
96- };
97- }();
98- SetWindowPlacement (window_handle, &window_placement);
99- }
82+ window->SetState (*settings.state );
10083 }
10184
10285 Size const size_after = GetViewSize (view_id);
You can’t perform that action at this time.
0 commit comments