19
19
#include " flutter/shell/platform/common/cpp/incoming_message_dispatcher.h"
20
20
#include " flutter/shell/platform/common/cpp/path_utils.h"
21
21
#include " flutter/shell/platform/embedder/embedder.h"
22
- #include " flutter/shell/platform/windows/dpi_utils .h"
22
+ #include " flutter/shell/platform/windows/flutter_windows_view .h"
23
23
#include " flutter/shell/platform/windows/key_event_handler.h"
24
24
#include " flutter/shell/platform/windows/keyboard_hook_handler.h"
25
- #include " flutter/shell/platform/windows/platform_handler.h"
26
25
#include " flutter/shell/platform/windows/text_input_plugin.h"
26
+ #include " flutter/shell/platform/windows/win32_dpi_utils.h"
27
27
#include " flutter/shell/platform/windows/win32_flutter_window.h"
28
+ #include " flutter/shell/platform/windows/win32_platform_handler.h"
28
29
#include " flutter/shell/platform/windows/win32_task_runner.h"
30
+ #include " flutter/shell/platform/windows/window_binding_handler.h"
29
31
#include " flutter/shell/platform/windows/window_state.h"
30
32
31
33
static_assert (FLUTTER_ENGINE_VERSION == 1 , " " );
@@ -66,7 +68,7 @@ UniqueAotDataPtr LoadAotData(std::filesystem::path aot_data_path) {
66
68
// Returns the state object for the engine, or null on failure to start the
67
69
// engine.
68
70
static std::unique_ptr<FlutterDesktopEngineState> RunFlutterEngine (
69
- flutter::Win32FlutterWindow* window ,
71
+ flutter::FlutterWindowsView* view ,
70
72
const FlutterDesktopEngineProperties& engine_properties) {
71
73
auto state = std::make_unique<FlutterDesktopEngineState>();
72
74
@@ -79,22 +81,22 @@ static std::unique_ptr<FlutterDesktopEngineState> RunFlutterEngine(
79
81
&engine_properties.switches [engine_properties.switches_count ]);
80
82
}
81
83
82
- window ->CreateRenderSurface ();
84
+ view ->CreateRenderSurface ();
83
85
84
86
// Provide the necessary callbacks for rendering within a win32 child window.
85
87
FlutterRendererConfig config = {};
86
88
config.type = kOpenGL ;
87
89
config.open_gl .struct_size = sizeof (config.open_gl );
88
90
config.open_gl .make_current = [](void * user_data) -> bool {
89
- auto host = static_cast <flutter::Win32FlutterWindow *>(user_data);
91
+ auto host = static_cast <flutter::FlutterWindowsView *>(user_data);
90
92
return host->MakeCurrent ();
91
93
};
92
94
config.open_gl .clear_current = [](void * user_data) -> bool {
93
- auto host = static_cast <flutter::Win32FlutterWindow *>(user_data);
95
+ auto host = static_cast <flutter::FlutterWindowsView *>(user_data);
94
96
return host->ClearContext ();
95
97
};
96
98
config.open_gl .present = [](void * user_data) -> bool {
97
- auto host = static_cast <flutter::Win32FlutterWindow *>(user_data);
99
+ auto host = static_cast <flutter::FlutterWindowsView *>(user_data);
98
100
return host->SwapBuffers ();
99
101
};
100
102
config.open_gl .fbo_callback = [](void * user_data) -> uint32_t { return 0 ; };
@@ -103,7 +105,7 @@ static std::unique_ptr<FlutterDesktopEngineState> RunFlutterEngine(
103
105
return reinterpret_cast <void *>(eglGetProcAddress (what));
104
106
};
105
107
config.open_gl .make_resource_current = [](void * user_data) -> bool {
106
- auto host = static_cast <flutter::Win32FlutterWindow *>(user_data);
108
+ auto host = static_cast <flutter::FlutterWindowsView *>(user_data);
107
109
return host->MakeResourceCurrent ();
108
110
};
109
111
@@ -178,7 +180,7 @@ static std::unique_ptr<FlutterDesktopEngineState> RunFlutterEngine(
178
180
args.platform_message_callback =
179
181
[](const FlutterPlatformMessage* engine_message,
180
182
void * user_data) -> void {
181
- auto window = reinterpret_cast <flutter::Win32FlutterWindow *>(user_data);
183
+ auto window = reinterpret_cast <flutter::FlutterWindowsView *>(user_data);
182
184
return window->HandlePlatformMessage (engine_message);
183
185
};
184
186
args.custom_task_runners = &custom_task_runners;
@@ -188,7 +190,7 @@ static std::unique_ptr<FlutterDesktopEngineState> RunFlutterEngine(
188
190
189
191
FLUTTER_API_SYMBOL (FlutterEngine) engine = nullptr ;
190
192
auto result =
191
- FlutterEngineRun (FLUTTER_ENGINE_VERSION, &config, &args, window , &engine);
193
+ FlutterEngineRun (FLUTTER_ENGINE_VERSION, &config, &args, view , &engine);
192
194
if (result != kSuccess || engine == nullptr ) {
193
195
std::cerr << " Failed to start Flutter engine: error " << result
194
196
<< std::endl;
@@ -202,8 +204,12 @@ FlutterDesktopViewControllerRef FlutterDesktopCreateViewController(
202
204
int width,
203
205
int height,
204
206
const FlutterDesktopEngineProperties& engine_properties) {
207
+ std::unique_ptr<flutter::WindowBindingHandler> window_wrapper =
208
+ std::make_unique<flutter::Win32FlutterWindow>(width, height);
209
+
205
210
FlutterDesktopViewControllerRef state =
206
- flutter::Win32FlutterWindow::CreateWin32FlutterWindow (width, height);
211
+ flutter::FlutterWindowsView::CreateFlutterWindowsView (
212
+ std::move (window_wrapper));
207
213
208
214
auto engine_state = RunFlutterEngine (state->view .get (), engine_properties);
209
215
@@ -261,8 +267,8 @@ FlutterDesktopViewRef FlutterDesktopGetView(
261
267
return controller->view_wrapper .get ();
262
268
}
263
269
264
- HWND FlutterDesktopViewGetHWND (FlutterDesktopViewRef view ) {
265
- return view-> window -> GetWindowHandle ( );
270
+ HWND FlutterDesktopViewGetHWND (FlutterDesktopViewRef view_ref ) {
271
+ return std::get<HWND>(*view_ref-> view -> GetRenderTarget () );
266
272
}
267
273
268
274
UINT FlutterDesktopGetDpiForHWND (HWND hwnd) {
@@ -316,7 +322,7 @@ void FlutterDesktopRegistrarSetDestructionHandler(
316
322
317
323
FlutterDesktopViewRef FlutterDesktopRegistrarGetView (
318
324
FlutterDesktopPluginRegistrarRef registrar) {
319
- return registrar->window ;
325
+ return registrar->view ;
320
326
}
321
327
322
328
bool FlutterDesktopMessengerSendWithReply (FlutterDesktopMessengerRef messenger,
0 commit comments