1919#include " flutter/shell/platform/common/cpp/incoming_message_dispatcher.h"
2020#include " flutter/shell/platform/common/cpp/path_utils.h"
2121#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"
2323#include " flutter/shell/platform/windows/key_event_handler.h"
2424#include " flutter/shell/platform/windows/keyboard_hook_handler.h"
25- #include " flutter/shell/platform/windows/platform_handler.h"
2625#include " flutter/shell/platform/windows/text_input_plugin.h"
26+ #include " flutter/shell/platform/windows/win32_dpi_utils.h"
2727#include " flutter/shell/platform/windows/win32_flutter_window.h"
28+ #include " flutter/shell/platform/windows/win32_platform_handler.h"
2829#include " flutter/shell/platform/windows/win32_task_runner.h"
30+ #include " flutter/shell/platform/windows/window_binding_handler.h"
2931#include " flutter/shell/platform/windows/window_state.h"
3032
3133static_assert (FLUTTER_ENGINE_VERSION == 1 , " " );
@@ -66,7 +68,7 @@ UniqueAotDataPtr LoadAotData(std::filesystem::path aot_data_path) {
6668// Returns the state object for the engine, or null on failure to start the
6769// engine.
6870static std::unique_ptr<FlutterDesktopEngineState> RunFlutterEngine (
69- flutter::Win32FlutterWindow* window ,
71+ flutter::FlutterWindowsView* view ,
7072 const FlutterDesktopEngineProperties& engine_properties) {
7173 auto state = std::make_unique<FlutterDesktopEngineState>();
7274
@@ -79,22 +81,22 @@ static std::unique_ptr<FlutterDesktopEngineState> RunFlutterEngine(
7981 &engine_properties.switches [engine_properties.switches_count ]);
8082 }
8183
82- window ->CreateRenderSurface ();
84+ view ->CreateRenderSurface ();
8385
8486 // Provide the necessary callbacks for rendering within a win32 child window.
8587 FlutterRendererConfig config = {};
8688 config.type = kOpenGL ;
8789 config.open_gl .struct_size = sizeof (config.open_gl );
8890 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);
9092 return host->MakeCurrent ();
9193 };
9294 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);
9496 return host->ClearContext ();
9597 };
9698 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);
98100 return host->SwapBuffers ();
99101 };
100102 config.open_gl .fbo_callback = [](void * user_data) -> uint32_t { return 0 ; };
@@ -103,7 +105,7 @@ static std::unique_ptr<FlutterDesktopEngineState> RunFlutterEngine(
103105 return reinterpret_cast <void *>(eglGetProcAddress (what));
104106 };
105107 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);
107109 return host->MakeResourceCurrent ();
108110 };
109111
@@ -178,7 +180,7 @@ static std::unique_ptr<FlutterDesktopEngineState> RunFlutterEngine(
178180 args.platform_message_callback =
179181 [](const FlutterPlatformMessage* engine_message,
180182 void * user_data) -> void {
181- auto window = reinterpret_cast <flutter::Win32FlutterWindow *>(user_data);
183+ auto window = reinterpret_cast <flutter::FlutterWindowsView *>(user_data);
182184 return window->HandlePlatformMessage (engine_message);
183185 };
184186 args.custom_task_runners = &custom_task_runners;
@@ -188,7 +190,7 @@ static std::unique_ptr<FlutterDesktopEngineState> RunFlutterEngine(
188190
189191 FLUTTER_API_SYMBOL (FlutterEngine) engine = nullptr ;
190192 auto result =
191- FlutterEngineRun (FLUTTER_ENGINE_VERSION, &config, &args, window , &engine);
193+ FlutterEngineRun (FLUTTER_ENGINE_VERSION, &config, &args, view , &engine);
192194 if (result != kSuccess || engine == nullptr ) {
193195 std::cerr << " Failed to start Flutter engine: error " << result
194196 << std::endl;
@@ -202,8 +204,12 @@ FlutterDesktopViewControllerRef FlutterDesktopCreateViewController(
202204 int width,
203205 int height,
204206 const FlutterDesktopEngineProperties& engine_properties) {
207+ std::unique_ptr<flutter::FlutterWindowBindingHandler> window_wrapper =
208+ std::make_unique<flutter::Win32FlutterWindow>(width, height);
209+
205210 FlutterDesktopViewControllerRef state =
206- flutter::Win32FlutterWindow::CreateWin32FlutterWindow (width, height);
211+ flutter::FlutterWindowsView::CreateFlutterWindowsView (
212+ std::move (window_wrapper));
207213
208214 auto engine_state = RunFlutterEngine (state->view .get (), engine_properties);
209215
@@ -261,8 +267,8 @@ FlutterDesktopViewRef FlutterDesktopGetView(
261267 return controller->view_wrapper .get ();
262268}
263269
264- HWND FlutterDesktopViewGetHWND (FlutterDesktopViewRef view ) {
265- return view->window ->GetWindowHandle ();
270+ HWND FlutterDesktopViewGetHWND (FlutterDesktopViewRef view_ref ) {
271+ return view_ref-> view ->GetRenderTarget () ->GetWindowHandle ();
266272}
267273
268274UINT FlutterDesktopGetDpiForHWND (HWND hwnd) {
@@ -316,7 +322,7 @@ void FlutterDesktopRegistrarSetDestructionHandler(
316322
317323FlutterDesktopViewRef FlutterDesktopRegistrarGetView (
318324 FlutterDesktopPluginRegistrarRef registrar) {
319- return registrar->window ;
325+ return registrar->view ;
320326}
321327
322328bool FlutterDesktopMessengerSendWithReply (FlutterDesktopMessengerRef messenger,
0 commit comments