99#include " flutter/fml/platform/win/wstring_conversion.h"
1010#include " flutter/shell/platform/common/accessibility_bridge.h"
1111#include " flutter/shell/platform/windows/keyboard_key_channel_handler.h"
12- #include " flutter/shell/platform/windows/keyboard_key_embedder_handler.h"
1312#include " flutter/shell/platform/windows/text_input_plugin.h"
1413#include " flutter/third_party/accessibility/ax/platform/ax_platform_node_win.h"
1514
@@ -59,42 +58,12 @@ void FlutterWindowsView::SetEngine(
5958
6059 engine_->SetView (this );
6160
62- internal_plugin_registrar_ =
63- std::make_unique<PluginRegistrar>(engine_->GetRegistrar ());
64-
65- // Set up the system channel handlers.
66- auto internal_plugin_messenger = internal_plugin_registrar_->messenger ();
67- InitializeKeyboard ();
68-
6961 PhysicalWindowBounds bounds = binding_handler_->GetPhysicalWindowBounds ();
7062
7163 SendWindowMetrics (bounds.width , bounds.height ,
7264 binding_handler_->GetDpiScale ());
7365}
7466
75- std::unique_ptr<KeyboardHandlerBase>
76- FlutterWindowsView::CreateKeyboardKeyHandler (
77- BinaryMessenger* messenger,
78- KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state,
79- KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan) {
80- auto keyboard_key_handler = std::make_unique<KeyboardKeyHandler>();
81- keyboard_key_handler->AddDelegate (
82- std::make_unique<KeyboardKeyEmbedderHandler>(
83- [this ](const FlutterKeyEvent& event, FlutterKeyEventCallback callback,
84- void * user_data) {
85- return engine_->SendKeyEvent (event, callback, user_data);
86- },
87- get_key_state, map_vk_to_scan));
88- keyboard_key_handler->AddDelegate (
89- std::make_unique<KeyboardKeyChannelHandler>(messenger));
90- return keyboard_key_handler;
91- }
92-
93- std::unique_ptr<TextInputPlugin> FlutterWindowsView::CreateTextInputPlugin (
94- BinaryMessenger* messenger) {
95- return std::make_unique<TextInputPlugin>(messenger, this );
96- }
97-
9867uint32_t FlutterWindowsView::GetFrameBufferId (size_t width, size_t height) {
9968 // Called on an engine-controlled (non-platform) thread.
10069 std::unique_lock<std::mutex> lock (resize_mutex_);
@@ -129,10 +98,6 @@ void FlutterWindowsView::ForceRedraw() {
12998 }
13099}
131100
132- void FlutterWindowsView::OnPreEngineRestart () {
133- InitializeKeyboard ();
134- }
135-
136101void FlutterWindowsView::OnWindowSizeChanged (size_t width, size_t height) {
137102 // Called on the platform thread.
138103 std::unique_lock<std::mutex> lock (resize_mutex_);
@@ -176,7 +141,7 @@ void FlutterWindowsView::OnPointerMove(double x,
176141 FlutterPointerDeviceKind device_kind,
177142 int32_t device_id,
178143 int modifiers_state) {
179- keyboard_key_handler_ ->SyncModifiersIfNeeded (modifiers_state);
144+ engine_-> keyboard_key_handler () ->SyncModifiersIfNeeded (modifiers_state);
180145 SendPointerMove (x, y, GetOrCreatePointerState (device_kind, device_id));
181146}
182147
@@ -293,20 +258,6 @@ void FlutterWindowsView::OnResetImeComposing() {
293258 binding_handler_->OnResetImeComposing ();
294259}
295260
296- void FlutterWindowsView::InitializeKeyboard () {
297- auto internal_plugin_messenger = internal_plugin_registrar_->messenger ();
298- KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state = GetKeyState;
299- KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan =
300- [](UINT virtual_key, bool extended) {
301- return MapVirtualKey (virtual_key,
302- extended ? MAPVK_VK_TO_VSC_EX : MAPVK_VK_TO_VSC);
303- };
304- keyboard_key_handler_ = std::move (CreateKeyboardKeyHandler (
305- internal_plugin_messenger, get_key_state, map_vk_to_scan));
306- text_input_plugin_ =
307- std::move (CreateTextInputPlugin (internal_plugin_messenger));
308- }
309-
310261// Sends new size information to FlutterEngine.
311262void FlutterWindowsView::SendWindowMetrics (size_t width,
312263 size_t height,
@@ -454,7 +405,7 @@ void FlutterWindowsView::SendPointerPanZoomEnd(int32_t device_id) {
454405}
455406
456407void FlutterWindowsView::SendText (const std::u16string& text) {
457- text_input_plugin_ ->TextHook (text);
408+ engine_-> text_input_plugin () ->TextHook (text);
458409}
459410
460411void FlutterWindowsView::SendKey (int key,
@@ -464,32 +415,32 @@ void FlutterWindowsView::SendKey(int key,
464415 bool extended,
465416 bool was_down,
466417 KeyEventCallback callback) {
467- keyboard_key_handler_ ->KeyboardHook (
418+ engine_-> keyboard_key_handler () ->KeyboardHook (
468419 key, scancode, action, character, extended, was_down,
469420 [=, callback = std::move (callback)](bool handled) {
470421 if (!handled) {
471- text_input_plugin_-> KeyboardHook (key, scancode, action, character,
472- extended, was_down);
422+ engine_-> text_input_plugin ()-> KeyboardHook (
423+ key, scancode, action, character, extended, was_down);
473424 }
474425 callback (handled);
475426 });
476427}
477428
478429void FlutterWindowsView::SendComposeBegin () {
479- text_input_plugin_ ->ComposeBeginHook ();
430+ engine_-> text_input_plugin () ->ComposeBeginHook ();
480431}
481432
482433void FlutterWindowsView::SendComposeCommit () {
483- text_input_plugin_ ->ComposeCommitHook ();
434+ engine_-> text_input_plugin () ->ComposeCommitHook ();
484435}
485436
486437void FlutterWindowsView::SendComposeEnd () {
487- text_input_plugin_ ->ComposeEndHook ();
438+ engine_-> text_input_plugin () ->ComposeEndHook ();
488439}
489440
490441void FlutterWindowsView::SendComposeChange (const std::u16string& text,
491442 int cursor_pos) {
492- text_input_plugin_ ->ComposeChangeHook (text, cursor_pos);
443+ engine_-> text_input_plugin () ->ComposeChangeHook (text, cursor_pos);
493444}
494445
495446void FlutterWindowsView::SendScroll (double x,
0 commit comments