| Flutter Windows Embedder |

flutter_view_controller.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "include/flutter/flutter_view_controller.h"
6
7 #include <algorithm>
8 #include <iostream>
9
10 namespace flutter {
11
12 FlutterViewController::FlutterViewController(int width,
13 int height,
14 const DartProject& project) {
15 engine_ = std::make_unique<FlutterEngine>(project);
16 controller_ = FlutterDesktopViewControllerCreate(width, height,
17 engine_->RelinquishEngine());
18 if (!controller_) {
19 std::cerr << "Failed to create view controller." << std::endl;
20 return;
21 }
22 view_ = std::make_unique<FlutterView>(
23 FlutterDesktopViewControllerGetView(controller_));
24 }
25
26 FlutterViewController::~FlutterViewController() {
27 if (controller_) {
28 FlutterDesktopViewControllerDestroy(controller_);
29 }
30 }
31
32 void FlutterViewController::ForceRedraw() {
33 FlutterDesktopViewControllerForceRedraw(controller_);
34 }
35
36 std::optional<LRESULT> FlutterViewController::HandleTopLevelWindowProc(
37 HWND hwnd,
38 UINT message,
39 WPARAM wparam,
40 LPARAM lparam) {
41 LRESULT result;
42 bool handled = FlutterDesktopViewControllerHandleTopLevelWindowProc(
43 controller_, hwnd, message, wparam, lparam, &result);
44 return handled ? result : std::optional<LRESULT>(std::nullopt);
45 }
46
47 } // namespace flutter
FlutterDesktopViewControllerHandleTopLevelWindowProc
bool FlutterDesktopViewControllerHandleTopLevelWindowProc(FlutterDesktopViewControllerRef ref, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, LRESULT *result)
Definition: flutter_windows.cc:132
FlutterDesktopViewControllerGetView
FlutterDesktopViewRef FlutterDesktopViewControllerGetView(FlutterDesktopViewControllerRef ref)
Definition: flutter_windows.cc:120
flutter::FlutterViewController::HandleTopLevelWindowProc
std::optional< LRESULT > HandleTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
Definition: flutter_view_controller.cc:36
flutter::DartProject
Definition: dart_project.h:14
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::FlutterViewController::FlutterViewController
FlutterViewController(int width, int height, const DartProject &project)
Definition: flutter_view_controller.cc:12
FlutterDesktopViewControllerForceRedraw
void FlutterDesktopViewControllerForceRedraw(FlutterDesktopViewControllerRef ref)
Definition: flutter_windows.cc:126
flutter_view_controller.h
message
Win32Message message
Definition: keyboard_unittests.cc:137
flutter::FlutterViewController::ForceRedraw
void ForceRedraw()
Definition: flutter_view_controller.cc:32
FlutterDesktopViewControllerDestroy
void FlutterDesktopViewControllerDestroy(FlutterDesktopViewControllerRef ref)
Definition: flutter_windows.cc:109
FlutterDesktopViewControllerCreate
FlutterDesktopViewControllerRef FlutterDesktopViewControllerCreate(int width, int height, FlutterDesktopEngineRef engine_ref)
Definition: flutter_windows.cc:75
flutter::FlutterViewController::~FlutterViewController
virtual ~FlutterViewController()
Definition: flutter_view_controller.cc:26