| 10 | FlutterWindow::~FlutterWindow() {} |
| 11 | |
| 12 | bool FlutterWindow::OnCreate() { |
| 13 | if (!Win32Window::OnCreate()) { |
| 14 | return false; |
| 15 | } |
| 16 | |
| 17 | RECT frame = GetClientArea(); |
| 18 | |
| 19 | // The size here must match the window dimensions to avoid unnecessary surface |
| 20 | // creation / destruction in the startup path. |
| 21 | flutter_controller_ = std::make_unique<flutter::FlutterViewController>( |
| 22 | frame.right - frame.left, frame.bottom - frame.top, project_); |
| 23 | // Ensure that basic setup of the controller was successful. |
| 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { |
| 25 | return false; |
| 26 | } |
| 27 | RegisterPlugins(flutter_controller_->engine()); |
| 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); |
| 29 | |
| 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { |
| 31 | this->Show(); |
| 32 | }); |
| 33 | |
| 34 | // Flutter can complete the first frame before the "show window" callback is |
| 35 | // registered. The following call ensures a frame is pending to ensure the |
| 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. |
| 37 | flutter_controller_->ForceRedraw(); |
| 38 | |
| 39 | return true; |
| 40 | } |
| 41 | |
| 42 | void FlutterWindow::OnDestroy() { |
| 43 | if (flutter_controller_) { |
nothing calls this directly
no test coverage detected