From 22be809700c3b686576b5fa25bd66e440bf00c23 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Fri, 5 Jul 2024 14:01:27 +1200 Subject: [PATCH 01/10] Rename FlMouseCursorPlugin to FlMouseCursorHandler This matches the naming used in the other embedders and removes the confusion between this and Flutter plugins. --- ci/licenses_golden/licenses_flutter | 8 ++-- shell/platform/linux/BUILD.gn | 2 +- ...r_plugin.cc => fl_mouse_cursor_handler.cc} | 28 ++++++------ .../platform/linux/fl_mouse_cursor_handler.h | 43 +++++++++++++++++++ shell/platform/linux/fl_mouse_cursor_plugin.h | 43 ------------------- shell/platform/linux/fl_view.cc | 8 ++-- 6 files changed, 66 insertions(+), 66 deletions(-) rename shell/platform/linux/{fl_mouse_cursor_plugin.cc => fl_mouse_cursor_handler.cc} (87%) create mode 100644 shell/platform/linux/fl_mouse_cursor_handler.h delete mode 100644 shell/platform/linux/fl_mouse_cursor_plugin.h diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 312b14e585b8a..318d91832ba54 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -44021,8 +44021,8 @@ ORIGIN: ../../../flutter/shell/platform/linux/fl_method_codec_private.h + ../../ ORIGIN: ../../../flutter/shell/platform/linux/fl_method_codec_test.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_method_response.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_method_response_test.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/linux/fl_mouse_cursor_plugin.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/linux/fl_mouse_cursor_plugin.h + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/linux/fl_mouse_cursor_handler.cc + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/linux/fl_mouse_cursor_handler.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture_private.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture_test.cc + ../../../flutter/LICENSE @@ -46918,8 +46918,8 @@ FILE: ../../../flutter/shell/platform/linux/fl_method_codec_private.h FILE: ../../../flutter/shell/platform/linux/fl_method_codec_test.cc FILE: ../../../flutter/shell/platform/linux/fl_method_response.cc FILE: ../../../flutter/shell/platform/linux/fl_method_response_test.cc -FILE: ../../../flutter/shell/platform/linux/fl_mouse_cursor_plugin.cc -FILE: ../../../flutter/shell/platform/linux/fl_mouse_cursor_plugin.h +FILE: ../../../flutter/shell/platform/linux/fl_mouse_cursor_handler.cc +FILE: ../../../flutter/shell/platform/linux/fl_mouse_cursor_handler.h FILE: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture.cc FILE: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture_private.h FILE: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture_test.cc diff --git a/shell/platform/linux/BUILD.gn b/shell/platform/linux/BUILD.gn index 8e1b8fc86e18c..68a3301691b15 100644 --- a/shell/platform/linux/BUILD.gn +++ b/shell/platform/linux/BUILD.gn @@ -119,7 +119,7 @@ source_set("flutter_linux_sources") { "fl_method_channel.cc", "fl_method_codec.cc", "fl_method_response.cc", - "fl_mouse_cursor_plugin.cc", + "fl_mouse_cursor_handler.cc", "fl_pixel_buffer_texture.cc", "fl_platform_plugin.cc", "fl_plugin_registrar.cc", diff --git a/shell/platform/linux/fl_mouse_cursor_plugin.cc b/shell/platform/linux/fl_mouse_cursor_handler.cc similarity index 87% rename from shell/platform/linux/fl_mouse_cursor_plugin.cc rename to shell/platform/linux/fl_mouse_cursor_handler.cc index 79cad6f774b96..dafa3bf647b73 100644 --- a/shell/platform/linux/fl_mouse_cursor_plugin.cc +++ b/shell/platform/linux/fl_mouse_cursor_handler.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/platform/linux/fl_mouse_cursor_plugin.h" +#include "flutter/shell/platform/linux/fl_mouse_cursor_handler.h" #include #include @@ -17,7 +17,7 @@ static constexpr char kKindKey[] = "kind"; static constexpr char kFallbackCursor[] = "default"; -struct _FlMouseCursorPlugin { +struct _FlMouseCursorHandler { GObject parent_instance; FlMethodChannel* channel; @@ -27,7 +27,7 @@ struct _FlMouseCursorPlugin { GHashTable* system_cursor_table; }; -G_DEFINE_TYPE(FlMouseCursorPlugin, fl_mouse_cursor_plugin, G_TYPE_OBJECT) +G_DEFINE_TYPE(FlMouseCursorHandler, fl_mouse_cursor_handler, G_TYPE_OBJECT) // Insert a new entry into a hashtable from strings to strings. // @@ -85,7 +85,7 @@ static void populate_system_cursor_table(GHashTable* table) { } // Sets the mouse cursor. -FlMethodResponse* activate_system_cursor(FlMouseCursorPlugin* self, +FlMethodResponse* activate_system_cursor(FlMouseCursorHandler* self, FlValue* args) { if (fl_value_get_type(args) != FL_VALUE_TYPE_MAP) { return FL_METHOD_RESPONSE(fl_method_error_response_new( @@ -122,7 +122,7 @@ FlMethodResponse* activate_system_cursor(FlMouseCursorPlugin* self, static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call, gpointer user_data) { - FlMouseCursorPlugin* self = FL_MOUSE_CURSOR_PLUGIN(user_data); + FlMouseCursorHandler* self = FL_MOUSE_CURSOR_HANDLER(user_data); const gchar* method = fl_method_call_get_name(method_call); FlValue* args = fl_method_call_get_args(method_call); @@ -140,8 +140,8 @@ static void method_call_cb(FlMethodChannel* channel, } } -static void fl_mouse_cursor_plugin_dispose(GObject* object) { - FlMouseCursorPlugin* self = FL_MOUSE_CURSOR_PLUGIN(object); +static void fl_mouse_cursor_handler_dispose(GObject* object) { + FlMouseCursorHandler* self = FL_MOUSE_CURSOR_HANDLER(object); g_clear_object(&self->channel); if (self->view != nullptr) { @@ -151,21 +151,21 @@ static void fl_mouse_cursor_plugin_dispose(GObject* object) { } g_clear_pointer(&self->system_cursor_table, g_hash_table_unref); - G_OBJECT_CLASS(fl_mouse_cursor_plugin_parent_class)->dispose(object); + G_OBJECT_CLASS(fl_mouse_cursor_handler_parent_class)->dispose(object); } -static void fl_mouse_cursor_plugin_class_init(FlMouseCursorPluginClass* klass) { - G_OBJECT_CLASS(klass)->dispose = fl_mouse_cursor_plugin_dispose; +static void fl_mouse_cursor_handler_class_init(FlMouseCursorHandlerClass* klass) { + G_OBJECT_CLASS(klass)->dispose = fl_mouse_cursor_handler_dispose; } -static void fl_mouse_cursor_plugin_init(FlMouseCursorPlugin* self) {} +static void fl_mouse_cursor_handler_init(FlMouseCursorHandler* self) {} -FlMouseCursorPlugin* fl_mouse_cursor_plugin_new(FlBinaryMessenger* messenger, +FlMouseCursorHandler* fl_mouse_cursor_handler_new(FlBinaryMessenger* messenger, FlView* view) { g_return_val_if_fail(FL_IS_BINARY_MESSENGER(messenger), nullptr); - FlMouseCursorPlugin* self = FL_MOUSE_CURSOR_PLUGIN( - g_object_new(fl_mouse_cursor_plugin_get_type(), nullptr)); + FlMouseCursorHandler* self = FL_MOUSE_CURSOR_HANDLER( + g_object_new(fl_mouse_cursor_handler_get_type(), nullptr)); g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new(); self->channel = diff --git a/shell/platform/linux/fl_mouse_cursor_handler.h b/shell/platform/linux/fl_mouse_cursor_handler.h new file mode 100644 index 0000000000000..7ec7b6412fa1b --- /dev/null +++ b/shell/platform/linux/fl_mouse_cursor_handler.h @@ -0,0 +1,43 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_MOUSE_CURSOR_HANDLER_H_ +#define FLUTTER_SHELL_PLATFORM_LINUX_FL_MOUSE_CURSOR_HANDLER_H_ + +#include + +#include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h" +#include "flutter/shell/platform/linux/public/flutter_linux/fl_view.h" + +G_BEGIN_DECLS + +G_DECLARE_FINAL_TYPE(FlMouseCursorHandler, + fl_mouse_cursor_handler, + FL, + MOUSE_CURSOR_HANDLER, + GObject); + +/** + * FlMouseCursorHandler: + * + * #FlMouseCursorHandler is a mouse_cursor channel that implements the shell + * side of SystemChannels.mouseCursor from the Flutter services library. + */ + +/** + * fl_mouse_cursor_handler_new: + * @messenger: an #FlBinaryMessenger. + * @view: an #FlView to control. + * + * Creates a new handler that implements SystemChannels.mouseCursor from the + * Flutter services library. + * + * Returns: a new #FlMouseCursorHandler. + */ +FlMouseCursorHandler* fl_mouse_cursor_handler_new(FlBinaryMessenger* messenger, + FlView* view); + +G_END_DECLS + +#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_MOUSE_CURSOR_HANDLER_H_ diff --git a/shell/platform/linux/fl_mouse_cursor_plugin.h b/shell/platform/linux/fl_mouse_cursor_plugin.h deleted file mode 100644 index 5962996f80d36..0000000000000 --- a/shell/platform/linux/fl_mouse_cursor_plugin.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_MOUSE_CURSOR_PLUGIN_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_MOUSE_CURSOR_PLUGIN_H_ - -#include - -#include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h" -#include "flutter/shell/platform/linux/public/flutter_linux/fl_view.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlMouseCursorPlugin, - fl_mouse_cursor_plugin, - FL, - MOUSE_CURSOR_PLUGIN, - GObject); - -/** - * FlMouseCursorPlugin: - * - * #FlMouseCursorPlugin is a mouse_cursor channel that implements the shell side - * of SystemChannels.mouseCursor from the Flutter services library. - */ - -/** - * fl_mouse_cursor_plugin_new: - * @messenger: an #FlBinaryMessenger. - * @view: an #FlView to control. - * - * Creates a new plugin that implements SystemChannels.mouseCursor from the - * Flutter services library. - * - * Returns: a new #FlMouseCursorPlugin. - */ -FlMouseCursorPlugin* fl_mouse_cursor_plugin_new(FlBinaryMessenger* messenger, - FlView* view); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_MOUSE_CURSOR_PLUGIN_H_ diff --git a/shell/platform/linux/fl_view.cc b/shell/platform/linux/fl_view.cc index 150de42b88f24..e0f91649727e6 100644 --- a/shell/platform/linux/fl_view.cc +++ b/shell/platform/linux/fl_view.cc @@ -17,7 +17,7 @@ #include "flutter/shell/platform/linux/fl_key_event.h" #include "flutter/shell/platform/linux/fl_keyboard_manager.h" #include "flutter/shell/platform/linux/fl_keyboard_view_delegate.h" -#include "flutter/shell/platform/linux/fl_mouse_cursor_plugin.h" +#include "flutter/shell/platform/linux/fl_mouse_cursor_handler.h" #include "flutter/shell/platform/linux/fl_platform_plugin.h" #include "flutter/shell/platform/linux/fl_plugin_registrar_private.h" #include "flutter/shell/platform/linux/fl_renderer_gdk.h" @@ -54,7 +54,7 @@ struct _FlView { FlKeyboardManager* keyboard_manager; FlScrollingManager* scrolling_manager; FlTextInputPlugin* text_input_plugin; - FlMouseCursorPlugin* mouse_cursor_plugin; + FlMouseCursorHandler* mouse_cursor_handler; FlPlatformPlugin* platform_plugin; GtkWidget* event_box; @@ -561,7 +561,7 @@ static GdkGLContext* create_context_cb(FlView* self) { // Create system channel handlers. FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(self->engine); init_scrolling(self); - self->mouse_cursor_plugin = fl_mouse_cursor_plugin_new(messenger, self); + self->mouse_cursor_handler = fl_mouse_cursor_handler_new(messenger, self); self->platform_plugin = fl_platform_plugin_new(messenger); g_autoptr(GError) error = nullptr; @@ -729,7 +729,7 @@ static void fl_view_dispose(GObject* object) { g_signal_handler_disconnect(self->keymap, self->keymap_keys_changed_cb_id); self->keymap_keys_changed_cb_id = 0; } - g_clear_object(&self->mouse_cursor_plugin); + g_clear_object(&self->mouse_cursor_handler); g_clear_object(&self->platform_plugin); g_clear_object(&self->view_accessible); From e0478c17f5610bbaa7fb6c66929b6ca2446b07d6 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Fri, 5 Jul 2024 14:07:12 +1200 Subject: [PATCH 02/10] Rename FlPlatformPlugin to FlPlatformHandler This matches the naming used in the other embedders and removes the confusion between this and Flutter plugins. --- ci/licenses_golden/licenses_flutter | 12 ++--- shell/platform/linux/BUILD.gn | 4 +- .../platform/linux/fl_mouse_cursor_handler.cc | 5 +- ...tform_plugin.cc => fl_platform_handler.cc} | 48 +++++++++---------- ...latform_plugin.h => fl_platform_handler.h} | 30 ++++++------ ...in_test.cc => fl_platform_handler_test.cc} | 20 ++++---- shell/platform/linux/fl_view.cc | 8 ++-- 7 files changed, 64 insertions(+), 63 deletions(-) rename shell/platform/linux/{fl_platform_plugin.cc => fl_platform_handler.cc} (91%) rename shell/platform/linux/{fl_platform_plugin.h => fl_platform_handler.h} (54%) rename shell/platform/linux/{fl_platform_plugin_test.cc => fl_platform_handler_test.cc} (94%) diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 318d91832ba54..cf2df8de4562a 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -44026,9 +44026,9 @@ ORIGIN: ../../../flutter/shell/platform/linux/fl_mouse_cursor_handler.h + ../../ ORIGIN: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture_private.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture_test.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/linux/fl_platform_plugin.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/linux/fl_platform_plugin.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/linux/fl_platform_plugin_test.cc + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/linux/fl_platform_handler.cc + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/linux/fl_platform_handler.h + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/linux/fl_platform_handler_test.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_plugin_registrar.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_plugin_registrar_private.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_plugin_registrar_test.cc + ../../../flutter/LICENSE @@ -46923,9 +46923,9 @@ FILE: ../../../flutter/shell/platform/linux/fl_mouse_cursor_handler.h FILE: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture.cc FILE: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture_private.h FILE: ../../../flutter/shell/platform/linux/fl_pixel_buffer_texture_test.cc -FILE: ../../../flutter/shell/platform/linux/fl_platform_plugin.cc -FILE: ../../../flutter/shell/platform/linux/fl_platform_plugin.h -FILE: ../../../flutter/shell/platform/linux/fl_platform_plugin_test.cc +FILE: ../../../flutter/shell/platform/linux/fl_platform_handler.cc +FILE: ../../../flutter/shell/platform/linux/fl_platform_handler.h +FILE: ../../../flutter/shell/platform/linux/fl_platform_handler_test.cc FILE: ../../../flutter/shell/platform/linux/fl_plugin_registrar.cc FILE: ../../../flutter/shell/platform/linux/fl_plugin_registrar_private.h FILE: ../../../flutter/shell/platform/linux/fl_plugin_registrar_test.cc diff --git a/shell/platform/linux/BUILD.gn b/shell/platform/linux/BUILD.gn index 68a3301691b15..565c0d4466a3b 100644 --- a/shell/platform/linux/BUILD.gn +++ b/shell/platform/linux/BUILD.gn @@ -121,7 +121,7 @@ source_set("flutter_linux_sources") { "fl_method_response.cc", "fl_mouse_cursor_handler.cc", "fl_pixel_buffer_texture.cc", - "fl_platform_plugin.cc", + "fl_platform_handler.cc", "fl_plugin_registrar.cc", "fl_plugin_registry.cc", "fl_renderer.cc", @@ -212,7 +212,7 @@ executable("flutter_linux_unittests") { "fl_method_codec_test.cc", "fl_method_response_test.cc", "fl_pixel_buffer_texture_test.cc", - "fl_platform_plugin_test.cc", + "fl_platform_handler_test.cc", "fl_plugin_registrar_test.cc", "fl_renderer_test.cc", "fl_scrolling_manager_test.cc", diff --git a/shell/platform/linux/fl_mouse_cursor_handler.cc b/shell/platform/linux/fl_mouse_cursor_handler.cc index dafa3bf647b73..107a8d65f3d43 100644 --- a/shell/platform/linux/fl_mouse_cursor_handler.cc +++ b/shell/platform/linux/fl_mouse_cursor_handler.cc @@ -154,14 +154,15 @@ static void fl_mouse_cursor_handler_dispose(GObject* object) { G_OBJECT_CLASS(fl_mouse_cursor_handler_parent_class)->dispose(object); } -static void fl_mouse_cursor_handler_class_init(FlMouseCursorHandlerClass* klass) { +static void fl_mouse_cursor_handler_class_init( + FlMouseCursorHandlerClass* klass) { G_OBJECT_CLASS(klass)->dispose = fl_mouse_cursor_handler_dispose; } static void fl_mouse_cursor_handler_init(FlMouseCursorHandler* self) {} FlMouseCursorHandler* fl_mouse_cursor_handler_new(FlBinaryMessenger* messenger, - FlView* view) { + FlView* view) { g_return_val_if_fail(FL_IS_BINARY_MESSENGER(messenger), nullptr); FlMouseCursorHandler* self = FL_MOUSE_CURSOR_HANDLER( diff --git a/shell/platform/linux/fl_platform_plugin.cc b/shell/platform/linux/fl_platform_handler.cc similarity index 91% rename from shell/platform/linux/fl_platform_plugin.cc rename to shell/platform/linux/fl_platform_handler.cc index 2f4beb4bfdb4d..9eb004ca00c17 100644 --- a/shell/platform/linux/fl_platform_plugin.cc +++ b/shell/platform/linux/fl_platform_handler.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/platform/linux/fl_platform_plugin.h" +#include "flutter/shell/platform/linux/fl_platform_handler.h" #include #include @@ -40,7 +40,7 @@ static constexpr char kTextPlainFormat[] = "text/plain"; static constexpr char kSoundTypeAlert[] = "SystemSoundType.alert"; static constexpr char kSoundTypeClick[] = "SystemSoundType.click"; -struct _FlPlatformPlugin { +struct _FlPlatformHandler { GObject parent_instance; FlMethodChannel* channel; @@ -49,7 +49,7 @@ struct _FlPlatformPlugin { bool app_initialization_complete; }; -G_DEFINE_TYPE(FlPlatformPlugin, fl_platform_plugin, G_TYPE_OBJECT) +G_DEFINE_TYPE(FlPlatformHandler, fl_platform_handler, G_TYPE_OBJECT) // Sends the method call response to Flutter. static void send_response(FlMethodCall* method_call, @@ -94,7 +94,7 @@ static void clipboard_text_has_strings_cb(GtkClipboard* clipboard, } // Called when Flutter wants to copy to the clipboard. -static FlMethodResponse* clipboard_set_data(FlPlatformPlugin* self, +static FlMethodResponse* clipboard_set_data(FlPlatformHandler* self, FlValue* args) { if (fl_value_get_type(args) != FL_VALUE_TYPE_MAP) { return FL_METHOD_RESPONSE(fl_method_error_response_new( @@ -116,7 +116,7 @@ static FlMethodResponse* clipboard_set_data(FlPlatformPlugin* self, } // Called when Flutter wants to paste from the clipboard. -static FlMethodResponse* clipboard_get_data_async(FlPlatformPlugin* self, +static FlMethodResponse* clipboard_get_data_async(FlPlatformHandler* self, FlMethodCall* method_call) { FlValue* args = fl_method_call_get_args(method_call); @@ -144,7 +144,7 @@ static FlMethodResponse* clipboard_get_data_async(FlPlatformPlugin* self, // Called when Flutter wants to know if the content of the clipboard is able to // be pasted, without actually accessing the clipboard content itself. static FlMethodResponse* clipboard_has_strings_async( - FlPlatformPlugin* self, + FlPlatformHandler* self, FlMethodCall* method_call) { GtkClipboard* clipboard = gtk_clipboard_get_default(gdk_display_get_default()); @@ -206,7 +206,7 @@ static void quit_application() { static void request_app_exit_response_cb(GObject* object, GAsyncResult* result, gpointer user_data) { - FlPlatformPlugin* self = FL_PLATFORM_PLUGIN(user_data); + FlPlatformHandler* self = FL_PLATFORM_HANDLER(user_data); g_autoptr(GError) error = nullptr; g_autoptr(FlMethodResponse) method_response = @@ -250,7 +250,7 @@ static void request_app_exit_response_cb(GObject* object, // Send a request to Flutter to exit the application, but only if it's ready for // a request. -static void request_app_exit(FlPlatformPlugin* self, const char* type) { +static void request_app_exit(FlPlatformHandler* self, const char* type) { g_autoptr(FlValue) args = fl_value_new_map(); if (!self->app_initialization_complete || g_str_equal(type, kExitTypeRequired)) { @@ -268,14 +268,14 @@ static void request_app_exit(FlPlatformPlugin* self, const char* type) { // requests. For the Flutter framework, this means after the ServicesBinding has // been initialized and it sends a System.initializationComplete message. static FlMethodResponse* system_intitialization_complete( - FlPlatformPlugin* self, + FlPlatformHandler* self, FlMethodCall* method_call) { self->app_initialization_complete = TRUE; return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr)); } // Called when Flutter wants to exit the application. -static FlMethodResponse* system_exit_application(FlPlatformPlugin* self, +static FlMethodResponse* system_exit_application(FlPlatformHandler* self, FlMethodCall* method_call) { FlValue* args = fl_method_call_get_args(method_call); if (fl_value_get_type(args) != FL_VALUE_TYPE_MAP) { @@ -318,7 +318,7 @@ static FlMethodResponse* system_exit_application(FlPlatformPlugin* self, } // Called when Flutter wants to play a sound. -static FlMethodResponse* system_sound_play(FlPlatformPlugin* self, +static FlMethodResponse* system_sound_play(FlPlatformHandler* self, FlValue* args) { if (fl_value_get_type(args) != FL_VALUE_TYPE_STRING) { return FL_METHOD_RESPONSE(fl_method_error_response_new( @@ -341,7 +341,7 @@ static FlMethodResponse* system_sound_play(FlPlatformPlugin* self, } // Called when Flutter wants to quit the application. -static FlMethodResponse* system_navigator_pop(FlPlatformPlugin* self) { +static FlMethodResponse* system_navigator_pop(FlPlatformHandler* self) { quit_application(); return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr)); } @@ -350,7 +350,7 @@ static FlMethodResponse* system_navigator_pop(FlPlatformPlugin* self) { static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call, gpointer user_data) { - FlPlatformPlugin* self = FL_PLATFORM_PLUGIN(user_data); + FlPlatformHandler* self = FL_PLATFORM_HANDLER(user_data); const gchar* method = fl_method_call_get_name(method_call); FlValue* args = fl_method_call_get_args(method_call); @@ -379,8 +379,8 @@ static void method_call_cb(FlMethodChannel* channel, } } -static void fl_platform_plugin_dispose(GObject* object) { - FlPlatformPlugin* self = FL_PLATFORM_PLUGIN(object); +static void fl_platform_handler_dispose(GObject* object) { + FlPlatformHandler* self = FL_PLATFORM_HANDLER(object); g_cancellable_cancel(self->cancellable); @@ -388,22 +388,22 @@ static void fl_platform_plugin_dispose(GObject* object) { g_clear_object(&self->exit_application_method_call); g_clear_object(&self->cancellable); - G_OBJECT_CLASS(fl_platform_plugin_parent_class)->dispose(object); + G_OBJECT_CLASS(fl_platform_handler_parent_class)->dispose(object); } -static void fl_platform_plugin_class_init(FlPlatformPluginClass* klass) { - G_OBJECT_CLASS(klass)->dispose = fl_platform_plugin_dispose; +static void fl_platform_handler_class_init(FlPlatformHandlerClass* klass) { + G_OBJECT_CLASS(klass)->dispose = fl_platform_handler_dispose; } -static void fl_platform_plugin_init(FlPlatformPlugin* self) { +static void fl_platform_handler_init(FlPlatformHandler* self) { self->cancellable = g_cancellable_new(); } -FlPlatformPlugin* fl_platform_plugin_new(FlBinaryMessenger* messenger) { +FlPlatformHandler* fl_platform_handler_new(FlBinaryMessenger* messenger) { g_return_val_if_fail(FL_IS_BINARY_MESSENGER(messenger), nullptr); - FlPlatformPlugin* self = - FL_PLATFORM_PLUGIN(g_object_new(fl_platform_plugin_get_type(), nullptr)); + FlPlatformHandler* self = FL_PLATFORM_HANDLER( + g_object_new(fl_platform_handler_get_type(), nullptr)); g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new(); self->channel = @@ -415,8 +415,8 @@ FlPlatformPlugin* fl_platform_plugin_new(FlBinaryMessenger* messenger) { return self; } -void fl_platform_plugin_request_app_exit(FlPlatformPlugin* self) { - g_return_if_fail(FL_IS_PLATFORM_PLUGIN(self)); +void fl_platform_handler_request_app_exit(FlPlatformHandler* self) { + g_return_if_fail(FL_IS_PLATFORM_HANDLER(self)); // Request a cancellable exit. request_app_exit(self, kExitTypeCancelable); } diff --git a/shell/platform/linux/fl_platform_plugin.h b/shell/platform/linux/fl_platform_handler.h similarity index 54% rename from shell/platform/linux/fl_platform_plugin.h rename to shell/platform/linux/fl_platform_handler.h index 573becb44a660..d3ad8233c727c 100644 --- a/shell/platform/linux/fl_platform_plugin.h +++ b/shell/platform/linux/fl_platform_handler.h @@ -2,40 +2,40 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_PLATFORM_PLUGIN_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_PLATFORM_PLUGIN_H_ +#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_PLATFORM_HANDLER_H_ +#define FLUTTER_SHELL_PLATFORM_LINUX_FL_PLATFORM_HANDLER_H_ #include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h" G_BEGIN_DECLS -G_DECLARE_FINAL_TYPE(FlPlatformPlugin, - fl_platform_plugin, +G_DECLARE_FINAL_TYPE(FlPlatformHandler, + fl_platform_handler, FL, - PLATFORM_PLUGIN, + PLATFORM_HANDLER, GObject); /** - * FlPlatformPlugin: + * FlPlatformHandler: * - * #FlPlatformPlugin is a plugin that implements the shell side + * #FlPlatformHandler is a handler that implements the shell side * of SystemChannels.platform from the Flutter services library. */ /** - * fl_platform_plugin_new: + * fl_platform_handler_new: * @messenger: an #FlBinaryMessenger * - * Creates a new plugin that implements SystemChannels.platform from the + * Creates a new handler that implements SystemChannels.platform from the * Flutter services library. * - * Returns: a new #FlPlatformPlugin + * Returns: a new #FlPlatformHandler */ -FlPlatformPlugin* fl_platform_plugin_new(FlBinaryMessenger* messenger); +FlPlatformHandler* fl_platform_handler_new(FlBinaryMessenger* messenger); /** - * fl_platform_plugin_request_app_exit: - * @plugin: an #FlPlatformPlugin + * fl_platform_handler_request_app_exit: + * @handler: an #FlPlatformHandler * * Request the application exits (i.e. due to the window being requested to be * closed). @@ -45,8 +45,8 @@ FlPlatformPlugin* fl_platform_plugin_new(FlBinaryMessenger* messenger); * "System.initializationComplete" method call on the platform channel. Calls * before initialization is complete will result in an immediate exit. */ -void fl_platform_plugin_request_app_exit(FlPlatformPlugin* plugin); +void fl_platform_handler_request_app_exit(FlPlatformHandler* handler); G_END_DECLS -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_PLATFORM_PLUGIN_H_ +#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_PLATFORM_HANDLER_H_ diff --git a/shell/platform/linux/fl_platform_plugin_test.cc b/shell/platform/linux/fl_platform_handler_test.cc similarity index 94% rename from shell/platform/linux/fl_platform_plugin_test.cc rename to shell/platform/linux/fl_platform_handler_test.cc index e5fe1d7963bb6..98369d227beff 100644 --- a/shell/platform/linux/fl_platform_plugin_test.cc +++ b/shell/platform/linux/fl_platform_handler_test.cc @@ -6,7 +6,7 @@ #include "flutter/shell/platform/linux/fl_binary_messenger_private.h" #include "flutter/shell/platform/linux/fl_method_codec_private.h" -#include "flutter/shell/platform/linux/fl_platform_plugin.h" +#include "flutter/shell/platform/linux/fl_platform_handler.h" #include "flutter/shell/platform/linux/public/flutter_linux/fl_json_method_codec.h" #include "flutter/shell/platform/linux/public/flutter_linux/fl_method_codec.h" #include "flutter/shell/platform/linux/testing/fl_test.h" @@ -117,8 +117,8 @@ static void fl_test_application_activate(GApplication* application) { G_APPLICATION_CLASS(fl_test_application_parent_class)->activate(application); ::testing::NiceMock messenger; - g_autoptr(FlPlatformPlugin) plugin = fl_platform_plugin_new(messenger); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlPlatformHandler) handler = fl_platform_handler_new(messenger); + EXPECT_NE(handler, nullptr); g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new(); g_autoptr(FlValue) exit_result = fl_value_new_map(); @@ -170,11 +170,11 @@ FlTestApplication* fl_test_application_new(gboolean* dispose_called) { return self; } -TEST(FlPlatformPluginTest, PlaySound) { +TEST(FlPlatformHandlerTest, PlaySound) { ::testing::NiceMock messenger; - g_autoptr(FlPlatformPlugin) plugin = fl_platform_plugin_new(messenger); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlPlatformHandler) handler = fl_platform_handler_new(messenger); + EXPECT_NE(handler, nullptr); g_autoptr(FlValue) args = fl_value_new_string("SystemSoundType.alert"); g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new(); @@ -190,11 +190,11 @@ TEST(FlPlatformPluginTest, PlaySound) { messenger.ReceiveMessage("flutter/platform", message); } -TEST(FlPlatformPluginTest, ExitApplication) { +TEST(FlPlatformHandlerTest, ExitApplication) { ::testing::NiceMock messenger; - g_autoptr(FlPlatformPlugin) plugin = fl_platform_plugin_new(messenger); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlPlatformHandler) handler = fl_platform_handler_new(messenger); + EXPECT_NE(handler, nullptr); g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new(); g_autoptr(FlValue) null = fl_value_new_null(); @@ -226,7 +226,7 @@ TEST(FlPlatformPluginTest, ExitApplication) { messenger.ReceiveMessage("flutter/platform", message); } -TEST(FlPlatformPluginTest, ExitApplicationDispose) { +TEST(FlPlatformHandlerTest, ExitApplicationDispose) { gtk_init(0, nullptr); gboolean dispose_called = false; diff --git a/shell/platform/linux/fl_view.cc b/shell/platform/linux/fl_view.cc index e0f91649727e6..76202c4382855 100644 --- a/shell/platform/linux/fl_view.cc +++ b/shell/platform/linux/fl_view.cc @@ -18,7 +18,7 @@ #include "flutter/shell/platform/linux/fl_keyboard_manager.h" #include "flutter/shell/platform/linux/fl_keyboard_view_delegate.h" #include "flutter/shell/platform/linux/fl_mouse_cursor_handler.h" -#include "flutter/shell/platform/linux/fl_platform_plugin.h" +#include "flutter/shell/platform/linux/fl_platform_handler.h" #include "flutter/shell/platform/linux/fl_plugin_registrar_private.h" #include "flutter/shell/platform/linux/fl_renderer_gdk.h" #include "flutter/shell/platform/linux/fl_scrolling_manager.h" @@ -55,7 +55,7 @@ struct _FlView { FlScrollingManager* scrolling_manager; FlTextInputPlugin* text_input_plugin; FlMouseCursorHandler* mouse_cursor_handler; - FlPlatformPlugin* platform_plugin; + FlPlatformHandler* platform_plugin; GtkWidget* event_box; GtkGLArea* gl_area; @@ -103,7 +103,7 @@ G_DEFINE_TYPE_WITH_CODE( // Signal handler for GtkWidget::delete-event static gboolean window_delete_event_cb(FlView* self) { - fl_platform_plugin_request_app_exit(self->platform_plugin); + fl_platform_handler_request_app_exit(self->platform_plugin); // Stop the event from propagating. return TRUE; } @@ -562,7 +562,7 @@ static GdkGLContext* create_context_cb(FlView* self) { FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(self->engine); init_scrolling(self); self->mouse_cursor_handler = fl_mouse_cursor_handler_new(messenger, self); - self->platform_plugin = fl_platform_plugin_new(messenger); + self->platform_plugin = fl_platform_handler_new(messenger); g_autoptr(GError) error = nullptr; if (!fl_renderer_gdk_create_contexts(self->renderer, &error)) { From 264edbc96a3f7eb96e3801a95e3829faadf24220 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Fri, 5 Jul 2024 14:18:28 +1200 Subject: [PATCH 03/10] Rename FlTextInputPlugin to FlTextInputHandler This matches the naming used in the other embedders and removes the confusion between this and Flutter plugins. --- ci/licenses_golden/licenses_flutter | 12 +- shell/platform/linux/BUILD.gn | 6 +- .../linux/fl_key_channel_responder.cc | 2 +- shell/platform/linux/fl_keyboard_manager.h | 4 +- .../linux/fl_keyboard_manager_test.cc | 6 +- ...put_plugin.cc => fl_text_input_handler.cc} | 185 +++++++++--------- ...input_plugin.h => fl_text_input_handler.h} | 36 ++-- ..._test.cc => fl_text_input_handler_test.cc} | 148 +++++++------- .../linux/fl_text_input_view_delegate.h | 2 +- shell/platform/linux/fl_view.cc | 19 +- .../linux/testing/mock_text_input_handler.cc | 42 ++++ .../linux/testing/mock_text_input_handler.h | 25 +++ .../linux/testing/mock_text_input_plugin.cc | 41 ---- .../linux/testing/mock_text_input_plugin.h | 25 --- 14 files changed, 278 insertions(+), 275 deletions(-) rename shell/platform/linux/{fl_text_input_plugin.cc => fl_text_input_handler.cc} (81%) rename shell/platform/linux/{fl_text_input_plugin.h => fl_text_input_handler.h} (53%) rename shell/platform/linux/{fl_text_input_plugin_test.cc => fl_text_input_handler_test.cc} (93%) create mode 100644 shell/platform/linux/testing/mock_text_input_handler.cc create mode 100644 shell/platform/linux/testing/mock_text_input_handler.h delete mode 100644 shell/platform/linux/testing/mock_text_input_plugin.cc delete mode 100644 shell/platform/linux/testing/mock_text_input_plugin.h diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index cf2df8de4562a..4412ea7e3178d 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -44063,9 +44063,9 @@ ORIGIN: ../../../flutter/shell/platform/linux/fl_string_codec.cc + ../../../flut ORIGIN: ../../../flutter/shell/platform/linux/fl_string_codec_test.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_task_runner.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_task_runner.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/linux/fl_text_input_plugin.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/linux/fl_text_input_plugin.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/linux/fl_text_input_plugin_test.cc + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/linux/fl_text_input_handler.cc + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/linux/fl_text_input_handler.h + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/linux/fl_text_input_handler_test.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_text_input_view_delegate.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_text_input_view_delegate.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_texture.cc + ../../../flutter/LICENSE @@ -46960,9 +46960,9 @@ FILE: ../../../flutter/shell/platform/linux/fl_string_codec.cc FILE: ../../../flutter/shell/platform/linux/fl_string_codec_test.cc FILE: ../../../flutter/shell/platform/linux/fl_task_runner.cc FILE: ../../../flutter/shell/platform/linux/fl_task_runner.h -FILE: ../../../flutter/shell/platform/linux/fl_text_input_plugin.cc -FILE: ../../../flutter/shell/platform/linux/fl_text_input_plugin.h -FILE: ../../../flutter/shell/platform/linux/fl_text_input_plugin_test.cc +FILE: ../../../flutter/shell/platform/linux/fl_text_input_handler.cc +FILE: ../../../flutter/shell/platform/linux/fl_text_input_handler.h +FILE: ../../../flutter/shell/platform/linux/fl_text_input_handler_test.cc FILE: ../../../flutter/shell/platform/linux/fl_text_input_view_delegate.cc FILE: ../../../flutter/shell/platform/linux/fl_text_input_view_delegate.h FILE: ../../../flutter/shell/platform/linux/fl_texture.cc diff --git a/shell/platform/linux/BUILD.gn b/shell/platform/linux/BUILD.gn index 565c0d4466a3b..7907fd788ff2b 100644 --- a/shell/platform/linux/BUILD.gn +++ b/shell/platform/linux/BUILD.gn @@ -138,7 +138,7 @@ source_set("flutter_linux_sources") { "fl_string_codec.cc", "fl_task_runner.cc", "fl_task_runner.h", - "fl_text_input_plugin.cc", + "fl_text_input_handler.cc", "fl_text_input_view_delegate.cc", "fl_texture.cc", "fl_texture_gl.cc", @@ -221,7 +221,7 @@ executable("flutter_linux_unittests") { "fl_standard_message_codec_test.cc", "fl_standard_method_codec_test.cc", "fl_string_codec_test.cc", - "fl_text_input_plugin_test.cc", + "fl_text_input_handler_test.cc", "fl_texture_gl_test.cc", "fl_texture_registrar_test.cc", "fl_value_test.cc", @@ -240,7 +240,7 @@ executable("flutter_linux_unittests") { "testing/mock_renderer.cc", "testing/mock_settings.cc", "testing/mock_signal_handler.cc", - "testing/mock_text_input_plugin.cc", + "testing/mock_text_input_handler.cc", "testing/mock_text_input_view_delegate.cc", "testing/mock_texture_registrar.cc", ] diff --git a/shell/platform/linux/fl_key_channel_responder.cc b/shell/platform/linux/fl_key_channel_responder.cc index b00f1f7ae861d..f4cb5353aedb9 100644 --- a/shell/platform/linux/fl_key_channel_responder.cc +++ b/shell/platform/linux/fl_key_channel_responder.cc @@ -179,7 +179,7 @@ static void fl_key_channel_responder_class_init( static void fl_key_channel_responder_init(FlKeyChannelResponder* self) {} // Creates a new FlKeyChannelResponder instance, with a messenger used to send -// messages to the framework, and an FlTextInputPlugin that is used to handle +// messages to the framework, and an FlTextInputHandler that is used to handle // key events that the framework doesn't handle. Mainly for testing purposes, it // also takes an optional callback to call when a response is received, and an // optional channel name to use when sending messages. diff --git a/shell/platform/linux/fl_keyboard_manager.h b/shell/platform/linux/fl_keyboard_manager.h index 84f4b574bd28e..5e43596dc2abd 100644 --- a/shell/platform/linux/fl_keyboard_manager.h +++ b/shell/platform/linux/fl_keyboard_manager.h @@ -21,7 +21,7 @@ G_DECLARE_FINAL_TYPE(FlKeyboardManager, /** * FlKeyboardManager: * - * Processes keyboard events and cooperate with `TextInputPlugin`. + * Processes keyboard events and cooperate with `TextInputHandler`. * * A keyboard event goes through a few sections, each can choose to handle the * event, and only unhandled events can move to the next section: @@ -30,7 +30,7 @@ G_DECLARE_FINAL_TYPE(FlKeyboardManager, * simultaneously. After both responders have responded (asynchronously), the * event is considered handled if either responder handles it. * - Text input: Events are sent to IM filter (usually owned by - * `TextInputPlugin`) and are handled synchronously. + * `TextInputHandler`) and are handled synchronously. * - Redispatching: Events are inserted back to the system for redispatching. */ diff --git a/shell/platform/linux/fl_keyboard_manager_test.cc b/shell/platform/linux/fl_keyboard_manager_test.cc index 8a5f02d21d21f..9539eb01ac8af 100644 --- a/shell/platform/linux/fl_keyboard_manager_test.cc +++ b/shell/platform/linux/fl_keyboard_manager_test.cc @@ -16,7 +16,7 @@ #include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_method_codec.h" #include "flutter/shell/platform/linux/testing/fl_test.h" #include "flutter/shell/platform/linux/testing/mock_binary_messenger.h" -#include "flutter/shell/platform/linux/testing/mock_text_input_plugin.h" +#include "flutter/shell/platform/linux/testing/mock_text_input_handler.h" #include "flutter/testing/testing.h" #include "gmock/gmock.h" @@ -852,7 +852,7 @@ TEST(FlKeyboardManagerTest, WithTwoAsyncDelegates) { EXPECT_TRUE(fl_keyboard_manager_is_state_clear(tester.manager())); } -TEST(FlKeyboardManagerTest, TextInputPluginReturnsFalse) { +TEST(FlKeyboardManagerTest, TextInputHandlerReturnsFalse) { KeyboardTester tester; std::vector> redispatched; gboolean manager_handled = false; @@ -875,7 +875,7 @@ TEST(FlKeyboardManagerTest, TextInputPluginReturnsFalse) { EXPECT_TRUE(fl_keyboard_manager_is_state_clear(tester.manager())); } -TEST(FlKeyboardManagerTest, TextInputPluginReturnsTrue) { +TEST(FlKeyboardManagerTest, TextInputHandlerReturnsTrue) { KeyboardTester tester; std::vector> redispatched; gboolean manager_handled = false; diff --git a/shell/platform/linux/fl_text_input_plugin.cc b/shell/platform/linux/fl_text_input_handler.cc similarity index 81% rename from shell/platform/linux/fl_text_input_plugin.cc rename to shell/platform/linux/fl_text_input_handler.cc index 2d5fa0c9f58f6..afc8afc09858c 100644 --- a/shell/platform/linux/fl_text_input_plugin.cc +++ b/shell/platform/linux/fl_text_input_handler.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/platform/linux/fl_text_input_plugin.h" +#include "flutter/shell/platform/linux/fl_text_input_handler.h" #include @@ -59,7 +59,7 @@ typedef enum { kFlTextInputTypeNone, } FlTextInputType; -struct FlTextInputPluginPrivate { +struct FlTextInputHandlerPrivate { GObject parent_instance; FlMethodChannel* channel; @@ -97,8 +97,8 @@ struct FlTextInputPluginPrivate { GdkRectangle composing_rect; }; -G_DEFINE_TYPE_WITH_PRIVATE(FlTextInputPlugin, - fl_text_input_plugin, +G_DEFINE_TYPE_WITH_PRIVATE(FlTextInputHandler, + fl_text_input_handler, G_TYPE_OBJECT) // Completes method call and returns TRUE if the call was successful. @@ -125,9 +125,9 @@ static void update_editing_state_response_cb(GObject* object, } // Informs Flutter of text input changes. -static void update_editing_state(FlTextInputPlugin* self) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); +static void update_editing_state(FlTextInputHandler* self) { + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); g_autoptr(FlValue) args = fl_value_new_list(); fl_value_append_take(args, fl_value_new_int(priv->client_id)); @@ -167,10 +167,10 @@ static void update_editing_state(FlTextInputPlugin* self) { } // Informs Flutter of text input changes by passing just the delta. -static void update_editing_state_with_delta(FlTextInputPlugin* self, +static void update_editing_state_with_delta(FlTextInputHandler* self, flutter::TextEditingDelta* delta) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); g_autoptr(FlValue) args = fl_value_new_list(); fl_value_append_take(args, fl_value_new_int(priv->client_id)); @@ -235,11 +235,11 @@ static void perform_action_response_cb(GObject* object, } // Inform Flutter that the input has been activated. -static void perform_action(FlTextInputPlugin* self) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); +static void perform_action(FlTextInputHandler* self) { + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); - g_return_if_fail(FL_IS_TEXT_INPUT_PLUGIN(self)); + g_return_if_fail(FL_IS_TEXT_INPUT_HANDLER(self)); g_return_if_fail(priv->client_id != 0); g_return_if_fail(priv->input_action != nullptr); @@ -252,16 +252,16 @@ static void perform_action(FlTextInputPlugin* self) { } // Signal handler for GtkIMContext::preedit-start -static void im_preedit_start_cb(FlTextInputPlugin* self) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); +static void im_preedit_start_cb(FlTextInputHandler* self) { + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); priv->text_model->BeginComposing(); } // Signal handler for GtkIMContext::preedit-changed -static void im_preedit_changed_cb(FlTextInputPlugin* self) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); +static void im_preedit_changed_cb(FlTextInputHandler* self) { + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); std::string text_before_change = priv->text_model->GetText(); flutter::TextRange composing_before_change = priv->text_model->composing_range(); @@ -288,9 +288,9 @@ static void im_preedit_changed_cb(FlTextInputPlugin* self) { } // Signal handler for GtkIMContext::commit -static void im_commit_cb(FlTextInputPlugin* self, const gchar* text) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); +static void im_commit_cb(FlTextInputHandler* self, const gchar* text) { + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); std::string text_before_change = priv->text_model->GetText(); flutter::TextRange composing_before_change = priv->text_model->composing_range(); @@ -315,9 +315,9 @@ static void im_commit_cb(FlTextInputPlugin* self, const gchar* text) { } // Signal handler for GtkIMContext::preedit-end -static void im_preedit_end_cb(FlTextInputPlugin* self) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); +static void im_preedit_end_cb(FlTextInputHandler* self) { + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); priv->text_model->EndComposing(); if (priv->enable_delta_model) { flutter::TextEditingDelta delta = @@ -329,9 +329,9 @@ static void im_preedit_end_cb(FlTextInputPlugin* self) { } // Signal handler for GtkIMContext::retrieve-surrounding -static gboolean im_retrieve_surrounding_cb(FlTextInputPlugin* self) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); +static gboolean im_retrieve_surrounding_cb(FlTextInputHandler* self) { + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); auto text = priv->text_model->GetText(); size_t cursor_offset = priv->text_model->GetCursorOffset(); gtk_im_context_set_surrounding(priv->im_context, text.c_str(), -1, @@ -340,11 +340,11 @@ static gboolean im_retrieve_surrounding_cb(FlTextInputPlugin* self) { } // Signal handler for GtkIMContext::delete-surrounding -static gboolean im_delete_surrounding_cb(FlTextInputPlugin* self, +static gboolean im_delete_surrounding_cb(FlTextInputHandler* self, gint offset, gint n_chars) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); std::string text_before_change = priv->text_model->GetText(); if (priv->text_model->DeleteSurrounding(offset, n_chars)) { @@ -361,14 +361,14 @@ static gboolean im_delete_surrounding_cb(FlTextInputPlugin* self, } // Called when the input method client is set up. -static FlMethodResponse* set_client(FlTextInputPlugin* self, FlValue* args) { +static FlMethodResponse* set_client(FlTextInputHandler* self, FlValue* args) { if (fl_value_get_type(args) != FL_VALUE_TYPE_LIST || fl_value_get_length(args) < 2) { return FL_METHOD_RESPONSE(fl_method_error_response_new( kBadArgumentsError, "Expected 2-element list", nullptr)); } - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); priv->client_id = fl_value_get_int(fl_value_get_list_value(args, 0)); FlValue* config_value = fl_value_get_list_value(args, 1); @@ -405,18 +405,18 @@ static FlMethodResponse* set_client(FlTextInputPlugin* self, FlValue* args) { } // Hides the input method. -static FlMethodResponse* hide(FlTextInputPlugin* self) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); +static FlMethodResponse* hide(FlTextInputHandler* self) { + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); gtk_im_context_focus_out(priv->im_context); return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr)); } // Shows the input method. -static FlMethodResponse* show(FlTextInputPlugin* self) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); +static FlMethodResponse* show(FlTextInputHandler* self) { + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); if (priv->input_type == kFlTextInputTypeNone) { return hide(self); } @@ -427,10 +427,10 @@ static FlMethodResponse* show(FlTextInputPlugin* self) { } // Updates the editing state from Flutter. -static FlMethodResponse* set_editing_state(FlTextInputPlugin* self, +static FlMethodResponse* set_editing_state(FlTextInputHandler* self, FlValue* args) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); const gchar* text = fl_value_get_string(fl_value_lookup_string(args, kTextKey)); priv->text_model->SetText(text); @@ -465,9 +465,9 @@ static FlMethodResponse* set_editing_state(FlTextInputPlugin* self, } // Called when the input method client is complete. -static FlMethodResponse* clear_client(FlTextInputPlugin* self) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); +static FlMethodResponse* clear_client(FlTextInputHandler* self) { + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); priv->client_id = kClientIdUnset; return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr)); @@ -481,9 +481,9 @@ static FlMethodResponse* clear_client(FlTextInputPlugin* self) { // coordinates to Flutter root coordinates. This function is called after each // of these updates. It transforms the composing rect to GDK window coordinates // and notifies GTK of the updated cursor position. -static void update_im_cursor_position(FlTextInputPlugin* self) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); +static void update_im_cursor_position(FlTextInputHandler* self) { + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); // Skip update if not composing to avoid setting to position 0. if (!priv->text_model->composing()) { @@ -516,7 +516,7 @@ static void update_im_cursor_position(FlTextInputPlugin* self) { // transform from the local coordinate system of the EditableText to root // Flutter coordinate system. static FlMethodResponse* set_editable_size_and_transform( - FlTextInputPlugin* self, + FlTextInputHandler* self, FlValue* args) { FlValue* transform = fl_value_lookup_string(args, kTransform); size_t transform_len = fl_value_get_length(transform); @@ -524,8 +524,8 @@ static FlMethodResponse* set_editable_size_and_transform( for (size_t i = 0; i < transform_len; ++i) { double val = fl_value_get_float(fl_value_get_list_value(transform, i)); - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); priv->editabletext_transform[i / 4][i % 4] = val; } update_im_cursor_position(self); @@ -539,10 +539,10 @@ static FlMethodResponse* set_editable_size_and_transform( // may be triggered. It provides an updated rect for the composing region in // local coordinates of the EditableText. In the case where there is no // composing region, the cursor rect is sent. -static FlMethodResponse* set_marked_text_rect(FlTextInputPlugin* self, +static FlMethodResponse* set_marked_text_rect(FlTextInputHandler* self, FlValue* args) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); priv->composing_rect.x = fl_value_get_float(fl_value_lookup_string(args, "x")); priv->composing_rect.y = @@ -560,7 +560,7 @@ static FlMethodResponse* set_marked_text_rect(FlTextInputPlugin* self, static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call, gpointer user_data) { - FlTextInputPlugin* self = FL_TEXT_INPUT_PLUGIN(user_data); + FlTextInputHandler* self = FL_TEXT_INPUT_HANDLER(user_data); const gchar* method = fl_method_call_get_name(method_call); FlValue* args = fl_method_call_get_args(method_call); @@ -590,11 +590,11 @@ static void method_call_cb(FlMethodChannel* channel, } } -// Disposes of an FlTextInputPlugin. -static void fl_text_input_plugin_dispose(GObject* object) { - FlTextInputPlugin* self = FL_TEXT_INPUT_PLUGIN(object); - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); +// Disposes of an FlTextInputHandler. +static void fl_text_input_handler_dispose(GObject* object) { + FlTextInputHandler* self = FL_TEXT_INPUT_HANDLER(object); + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); g_clear_object(&priv->channel); g_clear_pointer(&priv->input_action, g_free); @@ -610,17 +610,17 @@ static void fl_text_input_plugin_dispose(GObject* object) { priv->view_delegate = nullptr; } - G_OBJECT_CLASS(fl_text_input_plugin_parent_class)->dispose(object); + G_OBJECT_CLASS(fl_text_input_handler_parent_class)->dispose(object); } -// Implements FlTextInputPlugin::filter_keypress. -static gboolean fl_text_input_plugin_filter_keypress_default( - FlTextInputPlugin* self, +// Implements FlTextInputHandler::filter_keypress. +static gboolean fl_text_input_handler_filter_keypress_default( + FlTextInputHandler* self, FlKeyEvent* event) { - g_return_val_if_fail(FL_IS_TEXT_INPUT_PLUGIN(self), false); + g_return_val_if_fail(FL_IS_TEXT_INPUT_HANDLER(self), false); - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); if (priv->client_id == kClientIdUnset) { return FALSE; @@ -696,26 +696,27 @@ static gboolean fl_text_input_plugin_filter_keypress_default( return changed; } -// Initializes the FlTextInputPlugin class. -static void fl_text_input_plugin_class_init(FlTextInputPluginClass* klass) { - G_OBJECT_CLASS(klass)->dispose = fl_text_input_plugin_dispose; - FL_TEXT_INPUT_PLUGIN_CLASS(klass)->filter_keypress = - fl_text_input_plugin_filter_keypress_default; +// Initializes the FlTextInputHandler class. +static void fl_text_input_handler_class_init(FlTextInputHandlerClass* klass) { + G_OBJECT_CLASS(klass)->dispose = fl_text_input_handler_dispose; + FL_TEXT_INPUT_HANDLER_CLASS(klass)->filter_keypress = + fl_text_input_handler_filter_keypress_default; } -// Initializes an instance of the FlTextInputPlugin class. -static void fl_text_input_plugin_init(FlTextInputPlugin* self) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); +// Initializes an instance of the FlTextInputHandler class. +static void fl_text_input_handler_init(FlTextInputHandler* self) { + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); priv->client_id = kClientIdUnset; priv->input_type = kFlTextInputTypeText; priv->text_model = new flutter::TextInputModel(); } -static void init_im_context(FlTextInputPlugin* self, GtkIMContext* im_context) { - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); +static void init_im_context(FlTextInputHandler* self, + GtkIMContext* im_context) { + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); priv->im_context = GTK_IM_CONTEXT(g_object_ref(im_context)); // On Wayland, this call sets up the input method so it can be enabled @@ -742,7 +743,7 @@ static void init_im_context(FlTextInputPlugin* self, GtkIMContext* im_context) { G_CONNECT_SWAPPED); } -FlTextInputPlugin* fl_text_input_plugin_new( +FlTextInputHandler* fl_text_input_handler_new( FlBinaryMessenger* messenger, GtkIMContext* im_context, FlTextInputViewDelegate* view_delegate) { @@ -750,12 +751,12 @@ FlTextInputPlugin* fl_text_input_plugin_new( g_return_val_if_fail(GTK_IS_IM_CONTEXT(im_context), nullptr); g_return_val_if_fail(FL_IS_TEXT_INPUT_VIEW_DELEGATE(view_delegate), nullptr); - FlTextInputPlugin* self = FL_TEXT_INPUT_PLUGIN( - g_object_new(fl_text_input_plugin_get_type(), nullptr)); + FlTextInputHandler* self = FL_TEXT_INPUT_HANDLER( + g_object_new(fl_text_input_handler_get_type(), nullptr)); g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new(); - FlTextInputPluginPrivate* priv = static_cast( - fl_text_input_plugin_get_instance_private(self)); + FlTextInputHandlerPrivate* priv = static_cast( + fl_text_input_handler_get_instance_private(self)); priv->channel = fl_method_channel_new(messenger, kChannelName, FL_METHOD_CODEC(codec)); fl_method_channel_set_method_call_handler(priv->channel, method_call_cb, self, @@ -771,13 +772,13 @@ FlTextInputPlugin* fl_text_input_plugin_new( return self; } -// Filters the a keypress given to the plugin through the plugin's +// Filters the a keypress given to the handler through the handler's // filter_keypress callback. -gboolean fl_text_input_plugin_filter_keypress(FlTextInputPlugin* self, - FlKeyEvent* event) { - g_return_val_if_fail(FL_IS_TEXT_INPUT_PLUGIN(self), FALSE); - if (FL_TEXT_INPUT_PLUGIN_GET_CLASS(self)->filter_keypress) { - return FL_TEXT_INPUT_PLUGIN_GET_CLASS(self)->filter_keypress(self, event); +gboolean fl_text_input_handler_filter_keypress(FlTextInputHandler* self, + FlKeyEvent* event) { + g_return_val_if_fail(FL_IS_TEXT_INPUT_HANDLER(self), FALSE); + if (FL_TEXT_INPUT_HANDLER_GET_CLASS(self)->filter_keypress) { + return FL_TEXT_INPUT_HANDLER_GET_CLASS(self)->filter_keypress(self, event); } return FALSE; } diff --git a/shell/platform/linux/fl_text_input_plugin.h b/shell/platform/linux/fl_text_input_handler.h similarity index 53% rename from shell/platform/linux/fl_text_input_plugin.h rename to shell/platform/linux/fl_text_input_handler.h index 17a33c9114e15..9fe4355c67729 100644 --- a/shell/platform/linux/fl_text_input_plugin.h +++ b/shell/platform/linux/fl_text_input_handler.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXT_INPUT_PLUGIN_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXT_INPUT_PLUGIN_H_ +#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXT_INPUT_HANDLER_H_ +#define FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXT_INPUT_HANDLER_H_ #include @@ -13,56 +13,56 @@ G_BEGIN_DECLS -G_DECLARE_DERIVABLE_TYPE(FlTextInputPlugin, - fl_text_input_plugin, +G_DECLARE_DERIVABLE_TYPE(FlTextInputHandler, + fl_text_input_handler, FL, - TEXT_INPUT_PLUGIN, + TEXT_INPUT_HANDLER, GObject); /** - * FlTextInputPlugin: + * FlTextInputHandler: * - * #FlTextInputPlugin is a plugin that implements the shell side + * #FlTextInputHandler is a handler that implements the shell side * of SystemChannels.textInput from the Flutter services library. */ -struct _FlTextInputPluginClass { +struct _FlTextInputHandlerClass { GObjectClass parent_class; /** * Virtual method called to filter a keypress. */ - gboolean (*filter_keypress)(FlTextInputPlugin* self, FlKeyEvent* event); + gboolean (*filter_keypress)(FlTextInputHandler* self, FlKeyEvent* event); }; /** - * fl_text_input_plugin_new: + * fl_text_input_handler_new: * @messenger: an #FlBinaryMessenger. * @im_context: (allow-none): a #GtkIMContext. * @view_delegate: an #FlTextInputViewDelegate. * - * Creates a new plugin that implements SystemChannels.textInput from the + * Creates a new handler that implements SystemChannels.textInput from the * Flutter services library. * - * Returns: a new #FlTextInputPlugin. + * Returns: a new #FlTextInputHandler. */ -FlTextInputPlugin* fl_text_input_plugin_new( +FlTextInputHandler* fl_text_input_handler_new( FlBinaryMessenger* messenger, GtkIMContext* im_context, FlTextInputViewDelegate* view_delegate); /** - * fl_text_input_plugin_filter_keypress - * @plugin: an #FlTextInputPlugin. + * fl_text_input_handler_filter_keypress + * @handler: an #FlTextInputHandler. * @event: a #FlKeyEvent * * Process a Gdk key event. * * Returns: %TRUE if the event was used. */ -gboolean fl_text_input_plugin_filter_keypress(FlTextInputPlugin* plugin, - FlKeyEvent* event); +gboolean fl_text_input_handler_filter_keypress(FlTextInputHandler* handler, + FlKeyEvent* event); G_END_DECLS -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXT_INPUT_PLUGIN_H_ +#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXT_INPUT_HANDLER_H_ diff --git a/shell/platform/linux/fl_text_input_plugin_test.cc b/shell/platform/linux/fl_text_input_handler_test.cc similarity index 93% rename from shell/platform/linux/fl_text_input_plugin_test.cc rename to shell/platform/linux/fl_text_input_handler_test.cc index d01fa7642f8ba..4c4606ac7809e 100644 --- a/shell/platform/linux/fl_text_input_plugin_test.cc +++ b/shell/platform/linux/fl_text_input_handler_test.cc @@ -5,7 +5,7 @@ #include #include "flutter/shell/platform/linux/fl_method_codec_private.h" -#include "flutter/shell/platform/linux/fl_text_input_plugin.h" +#include "flutter/shell/platform/linux/fl_text_input_handler.h" #include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h" #include "flutter/shell/platform/linux/public/flutter_linux/fl_json_method_codec.h" #include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h" @@ -178,37 +178,37 @@ static FlValue* build_editing_delta(EditingDelta delta) { }); } -static void send_key_event(FlTextInputPlugin* plugin, +static void send_key_event(FlTextInputHandler* handler, gint keyval, gint state = 0) { GdkEvent* gdk_event = gdk_event_new(GDK_KEY_PRESS); gdk_event->key.keyval = keyval; gdk_event->key.state = state; FlKeyEvent* key_event = fl_key_event_new_from_gdk_event(gdk_event); - fl_text_input_plugin_filter_keypress(plugin, key_event); + fl_text_input_handler_filter_keypress(handler, key_event); fl_key_event_dispose(key_event); } -TEST(FlTextInputPluginTest, MessageHandler) { +TEST(FlTextInputHandlerTest, MessageHandler) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); EXPECT_TRUE(messenger.HasMessageHandler("flutter/textinput")); } -TEST(FlTextInputPluginTest, SetClient) { +TEST(FlTextInputHandlerTest, SetClient) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); g_autoptr(FlValue) args = build_input_config({.client_id = 1}); g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new(); @@ -224,14 +224,14 @@ TEST(FlTextInputPluginTest, SetClient) { messenger.ReceiveMessage("flutter/textinput", message); } -TEST(FlTextInputPluginTest, Show) { +TEST(FlTextInputHandlerTest, Show) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); EXPECT_CALL(context, gtk_im_context_focus_in(::testing::Eq(context))); @@ -249,14 +249,14 @@ TEST(FlTextInputPluginTest, Show) { messenger.ReceiveMessage("flutter/textinput", message); } -TEST(FlTextInputPluginTest, Hide) { +TEST(FlTextInputHandlerTest, Hide) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); EXPECT_CALL(context, gtk_im_context_focus_out(::testing::Eq(context))); @@ -274,14 +274,14 @@ TEST(FlTextInputPluginTest, Hide) { messenger.ReceiveMessage("flutter/textinput", message); } -TEST(FlTextInputPluginTest, ClearClient) { +TEST(FlTextInputHandlerTest, ClearClient) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); g_autoptr(FlValue) null = fl_value_new_null(); EXPECT_CALL(messenger, fl_binary_messenger_send_response( @@ -296,14 +296,14 @@ TEST(FlTextInputPluginTest, ClearClient) { messenger.ReceiveMessage("flutter/textinput", message); } -TEST(FlTextInputPluginTest, PerformAction) { +TEST(FlTextInputHandlerTest, PerformAction) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); // set input config g_autoptr(FlValue) config = build_input_config({ @@ -369,18 +369,18 @@ TEST(FlTextInputPluginTest, PerformAction) { FlValueEq(action)), ::testing::_, ::testing::_, ::testing::_)); - send_key_event(plugin, GDK_KEY_Return); + send_key_event(handler, GDK_KEY_Return); } // Regression test for https://github.com/flutter/flutter/issues/125879. -TEST(FlTextInputPluginTest, MultilineWithSendAction) { +TEST(FlTextInputHandlerTest, MultilineWithSendAction) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); // Set input config. g_autoptr(FlValue) config = build_input_config({ @@ -434,17 +434,17 @@ TEST(FlTextInputPluginTest, MultilineWithSendAction) { FlValueEq(action)), ::testing::_, ::testing::_, ::testing::_)); - send_key_event(plugin, GDK_KEY_Return); + send_key_event(handler, GDK_KEY_Return); } -TEST(FlTextInputPluginTest, MoveCursor) { +TEST(FlTextInputHandlerTest, MoveCursor) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); // set input config g_autoptr(FlValue) config = build_input_config({.client_id = 1}); @@ -493,7 +493,7 @@ TEST(FlTextInputPluginTest, MoveCursor) { FlValueEq(beginning)), ::testing::_, ::testing::_, ::testing::_)); - send_key_event(plugin, GDK_KEY_Home); + send_key_event(handler, GDK_KEY_Home); // move cursor to end g_autoptr(FlValue) end = build_list({ @@ -512,17 +512,17 @@ TEST(FlTextInputPluginTest, MoveCursor) { FlValueEq(end)), ::testing::_, ::testing::_, ::testing::_)); - send_key_event(plugin, GDK_KEY_End); + send_key_event(handler, GDK_KEY_End); } -TEST(FlTextInputPluginTest, Select) { +TEST(FlTextInputHandlerTest, Select) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); // set input config g_autoptr(FlValue) config = build_input_config({.client_id = 1}); @@ -571,7 +571,7 @@ TEST(FlTextInputPluginTest, Select) { FlValueEq(select_to_end)), ::testing::_, ::testing::_, ::testing::_)); - send_key_event(plugin, GDK_KEY_End, GDK_SHIFT_MASK); + send_key_event(handler, GDK_KEY_End, GDK_SHIFT_MASK); // select to beginning g_autoptr(FlValue) select_to_beginning = build_list({ @@ -590,17 +590,17 @@ TEST(FlTextInputPluginTest, Select) { FlValueEq(select_to_beginning)), ::testing::_, ::testing::_, ::testing::_)); - send_key_event(plugin, GDK_KEY_Home, GDK_SHIFT_MASK); + send_key_event(handler, GDK_KEY_Home, GDK_SHIFT_MASK); } -TEST(FlTextInputPluginTest, Composing) { +TEST(FlTextInputHandlerTest, Composing) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); g_signal_emit_by_name(context, "preedit-start", nullptr); @@ -663,14 +663,14 @@ TEST(FlTextInputPluginTest, Composing) { g_signal_emit_by_name(context, "preedit-end", nullptr); } -TEST(FlTextInputPluginTest, SurroundingText) { +TEST(FlTextInputHandlerTest, SurroundingText) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); // set input config g_autoptr(FlValue) config = build_input_config({.client_id = 1}); @@ -733,14 +733,14 @@ TEST(FlTextInputPluginTest, SurroundingText) { EXPECT_TRUE(deleted); } -TEST(FlTextInputPluginTest, SetMarkedTextRect) { +TEST(FlTextInputHandlerTest, SetMarkedTextRect) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); g_signal_emit_by_name(context, "preedit-start", nullptr); @@ -816,14 +816,14 @@ TEST(FlTextInputPluginTest, SetMarkedTextRect) { messenger.ReceiveMessage("flutter/textinput", set_marked_text_rect); } -TEST(FlTextInputPluginTest, TextInputTypeNone) { +TEST(FlTextInputHandlerTest, TextInputTypeNone) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); g_autoptr(FlValue) args = build_input_config({ .client_id = 1, @@ -859,14 +859,14 @@ TEST(FlTextInputPluginTest, TextInputTypeNone) { messenger.ReceiveMessage("flutter/textinput", show); } -TEST(FlTextInputPluginTest, TextEditingDelta) { +TEST(FlTextInputHandlerTest, TextEditingDelta) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); // set config g_autoptr(FlValue) args = build_input_config({ @@ -928,17 +928,17 @@ TEST(FlTextInputPluginTest, TextEditingDelta) { FlValueEq(deltas)), ::testing::_, ::testing::_, ::testing::_)); - send_key_event(plugin, GDK_KEY_Home); + send_key_event(handler, GDK_KEY_Home); } -TEST(FlTextInputPluginTest, ComposingDelta) { +TEST(FlTextInputHandlerTest, ComposingDelta) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); // set config g_autoptr(FlValue) args = build_input_config({ @@ -1054,14 +1054,14 @@ TEST(FlTextInputPluginTest, ComposingDelta) { g_signal_emit_by_name(context, "preedit-end", nullptr); } -TEST(FlTextInputPluginTest, NonComposingDelta) { +TEST(FlTextInputHandlerTest, NonComposingDelta) { ::testing::NiceMock messenger; ::testing::NiceMock context; ::testing::NiceMock delegate; - g_autoptr(FlTextInputPlugin) plugin = - fl_text_input_plugin_new(messenger, context, delegate); - EXPECT_NE(plugin, nullptr); + g_autoptr(FlTextInputHandler) handler = + fl_text_input_handler_new(messenger, context, delegate); + EXPECT_NE(handler, nullptr); // set config g_autoptr(FlValue) args = build_input_config({ diff --git a/shell/platform/linux/fl_text_input_view_delegate.h b/shell/platform/linux/fl_text_input_view_delegate.h index 6c8b491f19f89..8dc3d37c94ccc 100644 --- a/shell/platform/linux/fl_text_input_view_delegate.h +++ b/shell/platform/linux/fl_text_input_view_delegate.h @@ -20,7 +20,7 @@ G_DECLARE_INTERFACE(FlTextInputViewDelegate, /** * FlTextInputViewDelegate: * - * An interface for a class that provides `FlTextInputPlugin` with + * An interface for a class that provides `FlTextInputHandler` with * view-related features. * * This interface is typically implemented by `FlView`. diff --git a/shell/platform/linux/fl_view.cc b/shell/platform/linux/fl_view.cc index 76202c4382855..2ec1c7e43e9e5 100644 --- a/shell/platform/linux/fl_view.cc +++ b/shell/platform/linux/fl_view.cc @@ -24,7 +24,7 @@ #include "flutter/shell/platform/linux/fl_scrolling_manager.h" #include "flutter/shell/platform/linux/fl_scrolling_view_delegate.h" #include "flutter/shell/platform/linux/fl_socket_accessible.h" -#include "flutter/shell/platform/linux/fl_text_input_plugin.h" +#include "flutter/shell/platform/linux/fl_text_input_handler.h" #include "flutter/shell/platform/linux/fl_text_input_view_delegate.h" #include "flutter/shell/platform/linux/fl_view_accessible.h" #include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h" @@ -53,9 +53,9 @@ struct _FlView { // Flutter system channel handlers. FlKeyboardManager* keyboard_manager; FlScrollingManager* scrolling_manager; - FlTextInputPlugin* text_input_plugin; + FlTextInputHandler* text_input_handler; FlMouseCursorHandler* mouse_cursor_handler; - FlPlatformHandler* platform_plugin; + FlPlatformHandler* platform_handler; GtkWidget* event_box; GtkGLArea* gl_area; @@ -103,7 +103,7 @@ G_DEFINE_TYPE_WITH_CODE( // Signal handler for GtkWidget::delete-event static gboolean window_delete_event_cb(FlView* self) { - fl_platform_handler_request_app_exit(self->platform_plugin); + fl_platform_handler_request_app_exit(self->platform_handler); // Stop the event from propagating. return TRUE; } @@ -118,8 +118,8 @@ static void init_keyboard(FlView* self) { g_autoptr(GtkIMContext) im_context = gtk_im_multicontext_new(); gtk_im_context_set_client_window(im_context, window); - g_clear_object(&self->text_input_plugin); - self->text_input_plugin = fl_text_input_plugin_new( + g_clear_object(&self->text_input_handler); + self->text_input_handler = fl_text_input_handler_new( messenger, im_context, FL_TEXT_INPUT_VIEW_DELEGATE(self)); g_clear_object(&self->keyboard_manager); self->keyboard_manager = @@ -305,7 +305,8 @@ static void fl_view_keyboard_delegate_iface_init( iface->text_filter_key_press = [](FlKeyboardViewDelegate* view_delegate, FlKeyEvent* event) { FlView* self = FL_VIEW(view_delegate); - return fl_text_input_plugin_filter_keypress(self->text_input_plugin, event); + return fl_text_input_handler_filter_keypress(self->text_input_handler, + event); }; iface->get_messenger = [](FlKeyboardViewDelegate* view_delegate) { @@ -562,7 +563,7 @@ static GdkGLContext* create_context_cb(FlView* self) { FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(self->engine); init_scrolling(self); self->mouse_cursor_handler = fl_mouse_cursor_handler_new(messenger, self); - self->platform_plugin = fl_platform_handler_new(messenger); + self->platform_handler = fl_platform_handler_new(messenger); g_autoptr(GError) error = nullptr; if (!fl_renderer_gdk_create_contexts(self->renderer, &error)) { @@ -730,7 +731,7 @@ static void fl_view_dispose(GObject* object) { self->keymap_keys_changed_cb_id = 0; } g_clear_object(&self->mouse_cursor_handler); - g_clear_object(&self->platform_plugin); + g_clear_object(&self->platform_handler); g_clear_object(&self->view_accessible); G_OBJECT_CLASS(fl_view_parent_class)->dispose(object); diff --git a/shell/platform/linux/testing/mock_text_input_handler.cc b/shell/platform/linux/testing/mock_text_input_handler.cc new file mode 100644 index 0000000000000..049e36926a9ad --- /dev/null +++ b/shell/platform/linux/testing/mock_text_input_handler.cc @@ -0,0 +1,42 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter/shell/platform/linux/testing/mock_text_input_handler.h" + +struct _FlMockTextInputHandler { + FlTextInputHandler parent_instance; + + gboolean (*filter_keypress)(FlTextInputHandler* self, FlKeyEvent* event); +}; + +G_DEFINE_TYPE(FlMockTextInputHandler, + fl_mock_text_input_handler, + fl_text_input_handler_get_type()) + +static gboolean mock_text_input_handler_filter_keypress( + FlTextInputHandler* self, + FlKeyEvent* event) { + FlMockTextInputHandler* mock_self = FL_MOCK_TEXT_INPUT_HANDLER(self); + if (mock_self->filter_keypress) { + return mock_self->filter_keypress(self, event); + } + return FALSE; +} + +static void fl_mock_text_input_handler_class_init( + FlMockTextInputHandlerClass* klass) { + FL_TEXT_INPUT_HANDLER_CLASS(klass)->filter_keypress = + mock_text_input_handler_filter_keypress; +} + +static void fl_mock_text_input_handler_init(FlMockTextInputHandler* self) {} + +// Creates a mock text_input_handler +FlMockTextInputHandler* fl_mock_text_input_handler_new( + gboolean (*filter_keypress)(FlTextInputHandler* self, FlKeyEvent* event)) { + FlMockTextInputHandler* self = FL_MOCK_TEXT_INPUT_HANDLER( + g_object_new(fl_mock_text_input_handler_get_type(), nullptr)); + self->filter_keypress = filter_keypress; + return self; +} diff --git a/shell/platform/linux/testing/mock_text_input_handler.h b/shell/platform/linux/testing/mock_text_input_handler.h new file mode 100644 index 0000000000000..7bb736dd3d14b --- /dev/null +++ b/shell/platform/linux/testing/mock_text_input_handler.h @@ -0,0 +1,25 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_SHELL_PLATFORM_LINUX_TESTING_MOCK_TEXT_INPUT_HANDLER_H_ +#define FLUTTER_SHELL_PLATFORM_LINUX_TESTING_MOCK_TEXT_INPUT_HANDLER_H_ + +#include + +#include "flutter/shell/platform/linux/fl_text_input_handler.h" + +G_BEGIN_DECLS + +G_DECLARE_FINAL_TYPE(FlMockTextInputHandler, + fl_mock_text_input_handler, + FL, + MOCK_TEXT_INPUT_HANDLER, + FlTextInputHandler) + +FlMockTextInputHandler* fl_mock_text_input_handler_new( + gboolean (*filter_keypress)(FlTextInputHandler* self, FlKeyEvent* event)); + +G_END_DECLS + +#endif // FLUTTER_SHELL_PLATFORM_LINUX_TESTING_MOCK_TEXT_INPUT_HANDLER_H_ diff --git a/shell/platform/linux/testing/mock_text_input_plugin.cc b/shell/platform/linux/testing/mock_text_input_plugin.cc deleted file mode 100644 index bb6d7f070ae0b..0000000000000 --- a/shell/platform/linux/testing/mock_text_input_plugin.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/shell/platform/linux/testing/mock_text_input_plugin.h" - -struct _FlMockTextInputPlugin { - FlTextInputPlugin parent_instance; - - gboolean (*filter_keypress)(FlTextInputPlugin* self, FlKeyEvent* event); -}; - -G_DEFINE_TYPE(FlMockTextInputPlugin, - fl_mock_text_input_plugin, - fl_text_input_plugin_get_type()) - -static gboolean mock_text_input_plugin_filter_keypress(FlTextInputPlugin* self, - FlKeyEvent* event) { - FlMockTextInputPlugin* mock_self = FL_MOCK_TEXT_INPUT_PLUGIN(self); - if (mock_self->filter_keypress) { - return mock_self->filter_keypress(self, event); - } - return FALSE; -} - -static void fl_mock_text_input_plugin_class_init( - FlMockTextInputPluginClass* klass) { - FL_TEXT_INPUT_PLUGIN_CLASS(klass)->filter_keypress = - mock_text_input_plugin_filter_keypress; -} - -static void fl_mock_text_input_plugin_init(FlMockTextInputPlugin* self) {} - -// Creates a mock text_input_plugin -FlMockTextInputPlugin* fl_mock_text_input_plugin_new( - gboolean (*filter_keypress)(FlTextInputPlugin* self, FlKeyEvent* event)) { - FlMockTextInputPlugin* self = FL_MOCK_TEXT_INPUT_PLUGIN( - g_object_new(fl_mock_text_input_plugin_get_type(), nullptr)); - self->filter_keypress = filter_keypress; - return self; -} diff --git a/shell/platform/linux/testing/mock_text_input_plugin.h b/shell/platform/linux/testing/mock_text_input_plugin.h deleted file mode 100644 index 7d97f1ad88fb6..0000000000000 --- a/shell/platform/linux/testing/mock_text_input_plugin.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_TESTING_MOCK_TEXT_INPUT_PLUGIN_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_TESTING_MOCK_TEXT_INPUT_PLUGIN_H_ - -#include - -#include "flutter/shell/platform/linux/fl_text_input_plugin.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlMockTextInputPlugin, - fl_mock_text_input_plugin, - FL, - MOCK_TEXT_INPUT_PLUGIN, - FlTextInputPlugin) - -FlMockTextInputPlugin* fl_mock_text_input_plugin_new( - gboolean (*filter_keypress)(FlTextInputPlugin* self, FlKeyEvent* event)); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_TESTING_MOCK_TEXT_INPUT_PLUGIN_H_ From 090f4e1ff30ed66c575ca471d8a89f8bd094e6d8 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Fri, 5 Jul 2024 14:28:38 +1200 Subject: [PATCH 04/10] Rename FlSettingsPlugin to FlSettingsHandler --- ci/licenses_golden/licenses_flutter | 12 ++--- shell/platform/linux/BUILD.gn | 4 +- shell/platform/linux/fl_engine.cc | 10 ++-- shell/platform/linux/fl_engine_test.cc | 4 +- ...tings_plugin.cc => fl_settings_handler.cc} | 30 ++++++------ shell/platform/linux/fl_settings_handler.h | 47 +++++++++++++++++++ ...in_test.cc => fl_settings_handler_test.cc} | 26 +++++----- shell/platform/linux/fl_settings_plugin.h | 46 ------------------ 8 files changed, 90 insertions(+), 89 deletions(-) rename shell/platform/linux/{fl_settings_plugin.cc => fl_settings_handler.cc} (79%) create mode 100644 shell/platform/linux/fl_settings_handler.h rename shell/platform/linux/{fl_settings_plugin_test.cc => fl_settings_handler_test.cc} (89%) delete mode 100644 shell/platform/linux/fl_settings_plugin.h diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 4412ea7e3178d..96c27e223b3ef 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -44047,9 +44047,9 @@ ORIGIN: ../../../flutter/shell/platform/linux/fl_scrolling_view_delegate.cc + .. ORIGIN: ../../../flutter/shell/platform/linux/fl_scrolling_view_delegate.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_settings.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_settings.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/linux/fl_settings_plugin.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/linux/fl_settings_plugin.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/linux/fl_settings_plugin_test.cc + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/linux/fl_settings_handler.cc + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/linux/fl_settings_handler.h + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/linux/fl_settings_handler_test.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_settings_portal.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_settings_portal.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_settings_portal_test.cc + ../../../flutter/LICENSE @@ -46944,9 +46944,9 @@ FILE: ../../../flutter/shell/platform/linux/fl_scrolling_view_delegate.cc FILE: ../../../flutter/shell/platform/linux/fl_scrolling_view_delegate.h FILE: ../../../flutter/shell/platform/linux/fl_settings.cc FILE: ../../../flutter/shell/platform/linux/fl_settings.h -FILE: ../../../flutter/shell/platform/linux/fl_settings_plugin.cc -FILE: ../../../flutter/shell/platform/linux/fl_settings_plugin.h -FILE: ../../../flutter/shell/platform/linux/fl_settings_plugin_test.cc +FILE: ../../../flutter/shell/platform/linux/fl_settings_handler.cc +FILE: ../../../flutter/shell/platform/linux/fl_settings_handler.h +FILE: ../../../flutter/shell/platform/linux/fl_settings_handler_test.cc FILE: ../../../flutter/shell/platform/linux/fl_settings_portal.cc FILE: ../../../flutter/shell/platform/linux/fl_settings_portal.h FILE: ../../../flutter/shell/platform/linux/fl_settings_portal_test.cc diff --git a/shell/platform/linux/BUILD.gn b/shell/platform/linux/BUILD.gn index 7907fd788ff2b..dd8c9772d39ae 100644 --- a/shell/platform/linux/BUILD.gn +++ b/shell/platform/linux/BUILD.gn @@ -130,7 +130,7 @@ source_set("flutter_linux_sources") { "fl_scrolling_manager.cc", "fl_scrolling_view_delegate.cc", "fl_settings.cc", - "fl_settings_plugin.cc", + "fl_settings_handler.cc", "fl_settings_portal.cc", "fl_socket_accessible.cc", "fl_standard_message_codec.cc", @@ -216,7 +216,7 @@ executable("flutter_linux_unittests") { "fl_plugin_registrar_test.cc", "fl_renderer_test.cc", "fl_scrolling_manager_test.cc", - "fl_settings_plugin_test.cc", + "fl_settings_handler_test.cc", "fl_settings_portal_test.cc", "fl_standard_message_codec_test.cc", "fl_standard_method_codec_test.cc", diff --git a/shell/platform/linux/fl_engine.cc b/shell/platform/linux/fl_engine.cc index ace289a1b08bb..ca2395c2e7f2b 100644 --- a/shell/platform/linux/fl_engine.cc +++ b/shell/platform/linux/fl_engine.cc @@ -21,7 +21,7 @@ #include "flutter/shell/platform/linux/fl_plugin_registrar_private.h" #include "flutter/shell/platform/linux/fl_renderer.h" #include "flutter/shell/platform/linux/fl_renderer_headless.h" -#include "flutter/shell/platform/linux/fl_settings_plugin.h" +#include "flutter/shell/platform/linux/fl_settings_handler.h" #include "flutter/shell/platform/linux/fl_texture_gl_private.h" #include "flutter/shell/platform/linux/fl_texture_registrar_private.h" #include "flutter/shell/platform/linux/public/flutter_linux/fl_plugin_registry.h" @@ -46,7 +46,7 @@ struct _FlEngine { FlDartProject* project; FlRenderer* renderer; FlBinaryMessenger* binary_messenger; - FlSettingsPlugin* settings_plugin; + FlSettingsHandler* settings_handler; FlTextureRegistrar* texture_registrar; FlTaskRunner* task_runner; FlutterEngineAOTData aot_data; @@ -406,7 +406,7 @@ static void fl_engine_dispose(GObject* object) { g_clear_object(&self->renderer); g_clear_object(&self->texture_registrar); g_clear_object(&self->binary_messenger); - g_clear_object(&self->settings_plugin); + g_clear_object(&self->settings_handler); g_clear_object(&self->task_runner); if (self->platform_message_handler_destroy_notify) { @@ -568,8 +568,8 @@ gboolean fl_engine_start(FlEngine* self, GError** error) { setup_locales(self); g_autoptr(FlSettings) settings = fl_settings_new(); - self->settings_plugin = fl_settings_plugin_new(self); - fl_settings_plugin_start(self->settings_plugin, settings); + self->settings_handler = fl_settings_handler_new(self); + fl_settings_handler_start(self->settings_handler, settings); result = self->embedder_api.UpdateSemanticsEnabled(self->engine, TRUE); if (result != kSuccess) { diff --git a/shell/platform/linux/fl_engine_test.cc b/shell/platform/linux/fl_engine_test.cc index ce690c0535a90..652549eae5471 100644 --- a/shell/platform/linux/fl_engine_test.cc +++ b/shell/platform/linux/fl_engine_test.cc @@ -220,8 +220,8 @@ TEST(FlEngineTest, PlatformMessageResponse) { EXPECT_TRUE(called); } -// Checks settings plugin sends settings on startup. -TEST(FlEngineTest, SettingsPlugin) { +// Checks settings handler sends settings on startup. +TEST(FlEngineTest, SettingsHandler) { g_autoptr(FlEngine) engine = make_mock_engine(); FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine); diff --git a/shell/platform/linux/fl_settings_plugin.cc b/shell/platform/linux/fl_settings_handler.cc similarity index 79% rename from shell/platform/linux/fl_settings_plugin.cc rename to shell/platform/linux/fl_settings_handler.cc index c6d946d2c5838..6ad63228f8b78 100644 --- a/shell/platform/linux/fl_settings_plugin.cc +++ b/shell/platform/linux/fl_settings_handler.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/platform/linux/fl_settings_plugin.h" +#include "flutter/shell/platform/linux/fl_settings_handler.h" #include @@ -19,7 +19,7 @@ static constexpr char kPlatformBrightnessKey[] = "platformBrightness"; static constexpr char kPlatformBrightnessLight[] = "light"; static constexpr char kPlatformBrightnessDark[] = "dark"; -struct _FlSettingsPlugin { +struct _FlSettingsHandler { GObject parent_instance; FlBasicMessageChannel* channel; @@ -27,7 +27,7 @@ struct _FlSettingsPlugin { FlSettings* settings; }; -G_DEFINE_TYPE(FlSettingsPlugin, fl_settings_plugin, G_TYPE_OBJECT) +G_DEFINE_TYPE(FlSettingsHandler, fl_settings_handler, G_TYPE_OBJECT) static const gchar* to_platform_brightness(FlColorScheme color_scheme) { switch (color_scheme) { @@ -41,7 +41,7 @@ static const gchar* to_platform_brightness(FlColorScheme color_scheme) { } // Sends the current settings to the Flutter engine. -static void update_settings(FlSettingsPlugin* self) { +static void update_settings(FlSettingsHandler* self) { FlClockFormat clock_format = fl_settings_get_clock_format(self->settings); FlColorScheme color_scheme = fl_settings_get_color_scheme(self->settings); gdouble scaling_factor = fl_settings_get_text_scaling_factor(self->settings); @@ -70,8 +70,8 @@ static void update_settings(FlSettingsPlugin* self) { } } -static void fl_settings_plugin_dispose(GObject* object) { - FlSettingsPlugin* self = FL_SETTINGS_PLUGIN(object); +static void fl_settings_handler_dispose(GObject* object) { + FlSettingsHandler* self = FL_SETTINGS_HANDLER(object); g_clear_object(&self->channel); g_clear_object(&self->settings); @@ -82,20 +82,20 @@ static void fl_settings_plugin_dispose(GObject* object) { self->engine = nullptr; } - G_OBJECT_CLASS(fl_settings_plugin_parent_class)->dispose(object); + G_OBJECT_CLASS(fl_settings_handler_parent_class)->dispose(object); } -static void fl_settings_plugin_class_init(FlSettingsPluginClass* klass) { - G_OBJECT_CLASS(klass)->dispose = fl_settings_plugin_dispose; +static void fl_settings_handler_class_init(FlSettingsHandlerClass* klass) { + G_OBJECT_CLASS(klass)->dispose = fl_settings_handler_dispose; } -static void fl_settings_plugin_init(FlSettingsPlugin* self) {} +static void fl_settings_handler_init(FlSettingsHandler* self) {} -FlSettingsPlugin* fl_settings_plugin_new(FlEngine* engine) { +FlSettingsHandler* fl_settings_handler_new(FlEngine* engine) { g_return_val_if_fail(FL_IS_ENGINE(engine), nullptr); - FlSettingsPlugin* self = - FL_SETTINGS_PLUGIN(g_object_new(fl_settings_plugin_get_type(), nullptr)); + FlSettingsHandler* self = FL_SETTINGS_HANDLER( + g_object_new(fl_settings_handler_get_type(), nullptr)); self->engine = engine; g_object_add_weak_pointer(G_OBJECT(self), @@ -109,8 +109,8 @@ FlSettingsPlugin* fl_settings_plugin_new(FlEngine* engine) { return self; } -void fl_settings_plugin_start(FlSettingsPlugin* self, FlSettings* settings) { - g_return_if_fail(FL_IS_SETTINGS_PLUGIN(self)); +void fl_settings_handler_start(FlSettingsHandler* self, FlSettings* settings) { + g_return_if_fail(FL_IS_SETTINGS_HANDLER(self)); g_return_if_fail(FL_IS_SETTINGS(settings)); self->settings = FL_SETTINGS(g_object_ref(settings)); diff --git a/shell/platform/linux/fl_settings_handler.h b/shell/platform/linux/fl_settings_handler.h new file mode 100644 index 0000000000000..30364222ef818 --- /dev/null +++ b/shell/platform/linux/fl_settings_handler.h @@ -0,0 +1,47 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_SETTINGS_HANDLER_H_ +#define FLUTTER_SHELL_PLATFORM_LINUX_FL_SETTINGS_HANDLER_H_ + +#include "flutter/shell/platform/linux/fl_settings.h" +#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h" + +G_BEGIN_DECLS + +G_DECLARE_FINAL_TYPE(FlSettingsHandler, + fl_settings_handler, + FL, + SETTINGS_HANDLER, + GObject); + +/** + * FlSettingsHandler: + * + * #FlSettingsHandler is a handler that implements the Flutter user settings + * channel. + */ + +/** + * fl_settings_handler_new: + * @messenger: an #FlEngine + * + * Creates a new handler that sends user settings to the Flutter engine. + * + * Returns: a new #FlSettingsHandler + */ +FlSettingsHandler* fl_settings_handler_new(FlEngine* engine); + +/** + * fl_settings_handler_start: + * @handler: an #FlSettingsHandler. + * + * Sends the current settings to the engine and updates when they change. + */ +void fl_settings_handler_start(FlSettingsHandler* handler, + FlSettings* settings); + +G_END_DECLS + +#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_SETTINGS_HANDLER_H_ diff --git a/shell/platform/linux/fl_settings_plugin_test.cc b/shell/platform/linux/fl_settings_handler_test.cc similarity index 89% rename from shell/platform/linux/fl_settings_plugin_test.cc rename to shell/platform/linux/fl_settings_handler_test.cc index 7100a1c46c0aa..3bffcc2f23313 100644 --- a/shell/platform/linux/fl_settings_plugin_test.cc +++ b/shell/platform/linux/fl_settings_handler_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/platform/linux/fl_settings_plugin.h" +#include "flutter/shell/platform/linux/fl_settings_handler.h" #include "flutter/shell/platform/embedder/embedder.h" #include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h" #include "flutter/shell/platform/linux/fl_engine_private.h" @@ -37,14 +37,14 @@ MATCHER_P2(HasSetting, key, value, "") { ::testing::A(), ::testing::A(), \ ::testing::A())) -TEST(FlSettingsPluginTest, AlwaysUse24HourFormat) { +TEST(FlSettingsHandlerTest, AlwaysUse24HourFormat) { ::testing::NiceMock settings; ::testing::NiceMock messenger; g_autoptr(FlEngine) engine = FL_ENGINE(g_object_new(fl_engine_get_type(), "binary-messenger", FL_BINARY_MESSENGER(messenger), nullptr)); - g_autoptr(FlSettingsPlugin) plugin = fl_settings_plugin_new(engine); + g_autoptr(FlSettingsHandler) handler = fl_settings_handler_new(engine); g_autoptr(FlValue) use_12h = fl_value_new_bool(false); g_autoptr(FlValue) use_24h = fl_value_new_bool(true); @@ -56,21 +56,21 @@ TEST(FlSettingsPluginTest, AlwaysUse24HourFormat) { EXPECT_SETTING(messenger, "alwaysUse24HourFormat", use_12h); - fl_settings_plugin_start(plugin, settings); + fl_settings_handler_start(handler, settings); EXPECT_SETTING(messenger, "alwaysUse24HourFormat", use_24h); fl_settings_emit_changed(settings); } -TEST(FlSettingsPluginTest, PlatformBrightness) { +TEST(FlSettingsHandlerTest, PlatformBrightness) { ::testing::NiceMock settings; ::testing::NiceMock messenger; g_autoptr(FlEngine) engine = FL_ENGINE(g_object_new(fl_engine_get_type(), "binary-messenger", FL_BINARY_MESSENGER(messenger), nullptr)); - g_autoptr(FlSettingsPlugin) plugin = fl_settings_plugin_new(engine); + g_autoptr(FlSettingsHandler) handler = fl_settings_handler_new(engine); g_autoptr(FlValue) light = fl_value_new_string("light"); g_autoptr(FlValue) dark = fl_value_new_string("dark"); @@ -82,21 +82,21 @@ TEST(FlSettingsPluginTest, PlatformBrightness) { EXPECT_SETTING(messenger, "platformBrightness", light); - fl_settings_plugin_start(plugin, settings); + fl_settings_handler_start(handler, settings); EXPECT_SETTING(messenger, "platformBrightness", dark); fl_settings_emit_changed(settings); } -TEST(FlSettingsPluginTest, TextScaleFactor) { +TEST(FlSettingsHandlerTest, TextScaleFactor) { ::testing::NiceMock settings; ::testing::NiceMock messenger; g_autoptr(FlEngine) engine = FL_ENGINE(g_object_new(fl_engine_get_type(), "binary-messenger", FL_BINARY_MESSENGER(messenger), nullptr)); - g_autoptr(FlSettingsPlugin) plugin = fl_settings_plugin_new(engine); + g_autoptr(FlSettingsHandler) handler = fl_settings_handler_new(engine); g_autoptr(FlValue) one = fl_value_new_float(1.0); g_autoptr(FlValue) two = fl_value_new_float(2.0); @@ -108,7 +108,7 @@ TEST(FlSettingsPluginTest, TextScaleFactor) { EXPECT_SETTING(messenger, "textScaleFactor", one); - fl_settings_plugin_start(plugin, settings); + fl_settings_handler_start(handler, settings); EXPECT_SETTING(messenger, "textScaleFactor", two); @@ -117,7 +117,7 @@ TEST(FlSettingsPluginTest, TextScaleFactor) { // MOCK_ENGINE_PROC is leaky by design // NOLINTBEGIN(clang-analyzer-core.StackAddressEscape) -TEST(FlSettingsPluginTest, AccessibilityFeatures) { +TEST(FlSettingsHandlerTest, AccessibilityFeatures) { g_autoptr(FlEngine) engine = make_mock_engine(); FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine); @@ -129,7 +129,7 @@ TEST(FlSettingsPluginTest, AccessibilityFeatures) { return kSuccess; })); - g_autoptr(FlSettingsPlugin) plugin = fl_settings_plugin_new(engine); + g_autoptr(FlSettingsHandler) handler = fl_settings_handler_new(engine); ::testing::NiceMock settings; @@ -147,7 +147,7 @@ TEST(FlSettingsPluginTest, AccessibilityFeatures) { .WillOnce(::testing::Return(false)) .WillOnce(::testing::Return(true)); - fl_settings_plugin_start(plugin, settings); + fl_settings_handler_start(handler, settings); EXPECT_THAT(calls, ::testing::SizeIs(1)); EXPECT_EQ(calls.back(), static_cast( kFlutterAccessibilityFeatureDisableAnimations | diff --git a/shell/platform/linux/fl_settings_plugin.h b/shell/platform/linux/fl_settings_plugin.h deleted file mode 100644 index 2b6782a06df2d..0000000000000 --- a/shell/platform/linux/fl_settings_plugin.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_SETTINGS_PLUGIN_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_SETTINGS_PLUGIN_H_ - -#include "flutter/shell/platform/linux/fl_settings.h" -#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlSettingsPlugin, - fl_settings_plugin, - FL, - SETTINGS_PLUGIN, - GObject); - -/** - * FlSettingsPlugin: - * - * #FlSettingsPlugin is a plugin that implements the Flutter user settings - * channel. - */ - -/** - * fl_settings_plugin_new: - * @messenger: an #FlEngine - * - * Creates a new plugin that sends user settings to the Flutter engine. - * - * Returns: a new #FlSettingsPlugin - */ -FlSettingsPlugin* fl_settings_plugin_new(FlEngine* engine); - -/** - * fl_settings_plugin_start: - * @self: an #FlSettingsPlugin. - * - * Sends the current settings to the engine and updates when they change. - */ -void fl_settings_plugin_start(FlSettingsPlugin* plugin, FlSettings* settings); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_SETTINGS_PLUGIN_H_ From 7f75cf5adba2349b89aa8d50270fa5539cef6ec2 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Fri, 5 Jul 2024 14:57:56 +1200 Subject: [PATCH 05/10] Rename FlKeyboardManager to FlKeyboardHandler --- ci/licenses_golden/licenses_flutter | 12 +- shell/platform/linux/BUILD.gn | 6 +- .../platform/linux/fl_key_channel_responder.h | 2 +- .../linux/fl_key_embedder_responder.h | 2 +- .../linux/fl_key_embedder_responder_private.h | 2 +- shell/platform/linux/fl_key_responder.h | 2 +- ...oard_manager.cc => fl_keyboard_handler.cc} | 160 ++++++++--------- ...yboard_manager.h => fl_keyboard_handler.h} | 58 +++---- ...er_test.cc => fl_keyboard_handler_test.cc} | 164 +++++++++--------- shell/platform/linux/fl_view.cc | 31 ++-- 10 files changed, 220 insertions(+), 219 deletions(-) rename shell/platform/linux/{fl_keyboard_manager.cc => fl_keyboard_handler.cc} (84%) rename shell/platform/linux/{fl_keyboard_manager.h => fl_keyboard_handler.h} (58%) rename shell/platform/linux/{fl_keyboard_manager_test.cc => fl_keyboard_handler_test.cc} (92%) diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 96c27e223b3ef..511edc54fe1ad 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -44004,9 +44004,9 @@ ORIGIN: ../../../flutter/shell/platform/linux/fl_key_event.cc + ../../../flutter ORIGIN: ../../../flutter/shell/platform/linux/fl_key_event.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_key_responder.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_key_responder.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/linux/fl_keyboard_manager.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/linux/fl_keyboard_manager.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/linux/fl_keyboard_manager_test.cc + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/linux/fl_keyboard_handler.cc + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/linux/fl_keyboard_handler.h + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/linux/fl_keyboard_handler_test.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_keyboard_view_delegate.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_keyboard_view_delegate.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/linux/fl_message_codec.cc + ../../../flutter/LICENSE @@ -46901,9 +46901,9 @@ FILE: ../../../flutter/shell/platform/linux/fl_key_event.cc FILE: ../../../flutter/shell/platform/linux/fl_key_event.h FILE: ../../../flutter/shell/platform/linux/fl_key_responder.cc FILE: ../../../flutter/shell/platform/linux/fl_key_responder.h -FILE: ../../../flutter/shell/platform/linux/fl_keyboard_manager.cc -FILE: ../../../flutter/shell/platform/linux/fl_keyboard_manager.h -FILE: ../../../flutter/shell/platform/linux/fl_keyboard_manager_test.cc +FILE: ../../../flutter/shell/platform/linux/fl_keyboard_handler.cc +FILE: ../../../flutter/shell/platform/linux/fl_keyboard_handler.h +FILE: ../../../flutter/shell/platform/linux/fl_keyboard_handler_test.cc FILE: ../../../flutter/shell/platform/linux/fl_keyboard_view_delegate.cc FILE: ../../../flutter/shell/platform/linux/fl_keyboard_view_delegate.h FILE: ../../../flutter/shell/platform/linux/fl_message_codec.cc diff --git a/shell/platform/linux/BUILD.gn b/shell/platform/linux/BUILD.gn index dd8c9772d39ae..16ab4d00fb422 100644 --- a/shell/platform/linux/BUILD.gn +++ b/shell/platform/linux/BUILD.gn @@ -79,7 +79,7 @@ source_set("flutter_linux_sources") { "fl_binary_messenger_private.h", "fl_dart_project_private.h", "fl_engine_private.h", - "fl_keyboard_manager.h", + "fl_keyboard_handler.h", "fl_keyboard_view_delegate.h", "fl_key_event.h", "fl_key_responder.h", @@ -112,7 +112,7 @@ source_set("flutter_linux_sources") { "fl_key_embedder_responder.cc", "fl_key_event.cc", "fl_key_responder.cc", - "fl_keyboard_manager.cc", + "fl_keyboard_handler.cc", "fl_keyboard_view_delegate.cc", "fl_message_codec.cc", "fl_method_call.cc", @@ -206,7 +206,7 @@ executable("flutter_linux_unittests") { "fl_json_method_codec_test.cc", "fl_key_channel_responder_test.cc", "fl_key_embedder_responder_test.cc", - "fl_keyboard_manager_test.cc", + "fl_keyboard_handler_test.cc", "fl_message_codec_test.cc", "fl_method_channel_test.cc", "fl_method_codec_test.cc", diff --git a/shell/platform/linux/fl_key_channel_responder.h b/shell/platform/linux/fl_key_channel_responder.h index 7337dfdc9819e..9f133d64483a5 100644 --- a/shell/platform/linux/fl_key_channel_responder.h +++ b/shell/platform/linux/fl_key_channel_responder.h @@ -8,7 +8,7 @@ #include #include "flutter/shell/platform/linux/fl_key_responder.h" -#include "flutter/shell/platform/linux/fl_keyboard_manager.h" +#include "flutter/shell/platform/linux/fl_keyboard_handler.h" #include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h" #include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h" diff --git a/shell/platform/linux/fl_key_embedder_responder.h b/shell/platform/linux/fl_key_embedder_responder.h index 73c754bf77b4b..c916a6286217a 100644 --- a/shell/platform/linux/fl_key_embedder_responder.h +++ b/shell/platform/linux/fl_key_embedder_responder.h @@ -9,7 +9,7 @@ #include #include "flutter/shell/platform/linux/fl_key_responder.h" -#include "flutter/shell/platform/linux/fl_keyboard_manager.h" +#include "flutter/shell/platform/linux/fl_keyboard_handler.h" #include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h" #include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h" diff --git a/shell/platform/linux/fl_key_embedder_responder_private.h b/shell/platform/linux/fl_key_embedder_responder_private.h index 635cbc672e4af..6e92957eb862d 100644 --- a/shell/platform/linux/fl_key_embedder_responder_private.h +++ b/shell/platform/linux/fl_key_embedder_responder_private.h @@ -8,7 +8,7 @@ #include #include "flutter/shell/platform/linux/fl_key_responder.h" -#include "flutter/shell/platform/linux/fl_keyboard_manager.h" +#include "flutter/shell/platform/linux/fl_keyboard_handler.h" #include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h" #include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h" diff --git a/shell/platform/linux/fl_key_responder.h b/shell/platform/linux/fl_key_responder.h index 756bc3206f72e..f66f9214bddf9 100644 --- a/shell/platform/linux/fl_key_responder.h +++ b/shell/platform/linux/fl_key_responder.h @@ -40,7 +40,7 @@ G_DECLARE_INTERFACE(FlKeyResponder, * An interface for a responder that can process a key event and decides * asynchronously whether to handle an event. * - * To use this class, add it with #fl_keyboard_manager_add_responder. + * To use this class, add it with #fl_keyboard_handler_add_responder. */ struct _FlKeyResponderInterface { diff --git a/shell/platform/linux/fl_keyboard_manager.cc b/shell/platform/linux/fl_keyboard_handler.cc similarity index 84% rename from shell/platform/linux/fl_keyboard_manager.cc rename to shell/platform/linux/fl_keyboard_handler.cc index 2d14293560eac..759721371aee3 100644 --- a/shell/platform/linux/fl_keyboard_manager.cc +++ b/shell/platform/linux/fl_keyboard_handler.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/platform/linux/fl_keyboard_manager.h" +#include "flutter/shell/platform/linux/fl_keyboard_handler.h" #include #include @@ -30,12 +30,12 @@ G_DECLARE_FINAL_TYPE(FlKeyboardPendingEvent, KEYBOARD_PENDING_EVENT, GObject); -#define FL_TYPE_KEYBOARD_MANAGER_USER_DATA \ - fl_keyboard_manager_user_data_get_type() -G_DECLARE_FINAL_TYPE(FlKeyboardManagerUserData, - fl_keyboard_manager_user_data, +#define FL_TYPE_KEYBOARD_HANDLER_USER_DATA \ + fl_keyboard_handler_user_data_get_type() +G_DECLARE_FINAL_TYPE(FlKeyboardHandlerUserData, + fl_keyboard_handler_user_data, FL, - KEYBOARD_MANAGER_USER_DATA, + KEYBOARD_HANDLER_USER_DATA, GObject); /* End declarations */ @@ -60,7 +60,7 @@ typedef std::map DerivedLayout; typedef struct { FlKeyEvent* event; uint64_t specified_logical_key; - FlKeyboardManagerUserData* user_data; + FlKeyboardHandlerUserData* user_data; } DispatchToResponderLoopContext; bool is_eascii(uint16_t character) { @@ -113,7 +113,7 @@ static uint64_t get_logical_key_from_layout(const FlKeyEvent* event, /** * FlKeyboardPendingEvent: - * A record for events that have been received by the manager, but + * A record for events that have been received by the handler, but * dispatched to other objects, whose results have yet to return. * * This object is used by both the "pending_responds" list and the @@ -165,7 +165,7 @@ static void fl_keyboard_pending_event_init(FlKeyboardPendingEvent* self) {} // Calculates a unique ID for a given FlKeyEvent object to use for // identification of responses from the framework. -static uint64_t fl_keyboard_manager_get_event_hash(FlKeyEvent* event) { +static uint64_t fl_keyboard_handler_get_event_hash(FlKeyEvent* event) { // Combine the event timestamp, the type of event, and the hardware keycode // (scan code) of the event to come up with a unique id for this event that // can be derived solely from the event data itself, so that we can identify @@ -192,79 +192,79 @@ static FlKeyboardPendingEvent* fl_keyboard_pending_event_new( self->sequence_id = sequence_id; self->unreplied = to_reply; self->any_handled = false; - self->hash = fl_keyboard_manager_get_event_hash(self->event.get()); + self->hash = fl_keyboard_handler_get_event_hash(self->event.get()); return self; } -/* Define FlKeyboardManagerUserData */ +/* Define FlKeyboardHandlerUserData */ /** - * FlKeyboardManagerUserData: - * The user_data used when #FlKeyboardManager sends event to + * FlKeyboardHandlerUserData: + * The user_data used when #FlKeyboardHandler sends event to * responders. */ -struct _FlKeyboardManagerUserData { +struct _FlKeyboardHandlerUserData { GObject parent_instance; - // A weak reference to the owner manager. - FlKeyboardManager* manager; + // A weak reference to the owner handler. + FlKeyboardHandler* handler; uint64_t sequence_id; }; -G_DEFINE_TYPE(FlKeyboardManagerUserData, - fl_keyboard_manager_user_data, +G_DEFINE_TYPE(FlKeyboardHandlerUserData, + fl_keyboard_handler_user_data, G_TYPE_OBJECT) -static void fl_keyboard_manager_user_data_dispose(GObject* object) { - g_return_if_fail(FL_IS_KEYBOARD_MANAGER_USER_DATA(object)); - FlKeyboardManagerUserData* self = FL_KEYBOARD_MANAGER_USER_DATA(object); - if (self->manager != nullptr) { - g_object_remove_weak_pointer(G_OBJECT(self->manager), - reinterpret_cast(&(self->manager))); - self->manager = nullptr; +static void fl_keyboard_handler_user_data_dispose(GObject* object) { + g_return_if_fail(FL_IS_KEYBOARD_HANDLER_USER_DATA(object)); + FlKeyboardHandlerUserData* self = FL_KEYBOARD_HANDLER_USER_DATA(object); + if (self->handler != nullptr) { + g_object_remove_weak_pointer(G_OBJECT(self->handler), + reinterpret_cast(&(self->handler))); + self->handler = nullptr; } } -static void fl_keyboard_manager_user_data_class_init( - FlKeyboardManagerUserDataClass* klass) { - G_OBJECT_CLASS(klass)->dispose = fl_keyboard_manager_user_data_dispose; +static void fl_keyboard_handler_user_data_class_init( + FlKeyboardHandlerUserDataClass* klass) { + G_OBJECT_CLASS(klass)->dispose = fl_keyboard_handler_user_data_dispose; } -static void fl_keyboard_manager_user_data_init( - FlKeyboardManagerUserData* self) {} +static void fl_keyboard_handler_user_data_init( + FlKeyboardHandlerUserData* self) {} -// Creates a new FlKeyboardManagerUserData private class with all information. -static FlKeyboardManagerUserData* fl_keyboard_manager_user_data_new( - FlKeyboardManager* manager, +// Creates a new FlKeyboardHandlerUserData private class with all information. +static FlKeyboardHandlerUserData* fl_keyboard_handler_user_data_new( + FlKeyboardHandler* handler, uint64_t sequence_id) { - FlKeyboardManagerUserData* self = FL_KEYBOARD_MANAGER_USER_DATA( - g_object_new(fl_keyboard_manager_user_data_get_type(), nullptr)); + FlKeyboardHandlerUserData* self = FL_KEYBOARD_HANDLER_USER_DATA( + g_object_new(fl_keyboard_handler_user_data_get_type(), nullptr)); - self->manager = manager; + self->handler = handler; // Add a weak pointer so we can know if the key event responder disappeared // while the framework was responding. - g_object_add_weak_pointer(G_OBJECT(manager), - reinterpret_cast(&(self->manager))); + g_object_add_weak_pointer(G_OBJECT(handler), + reinterpret_cast(&(self->handler))); self->sequence_id = sequence_id; return self; } -/* Define FlKeyboardManager */ +/* Define FlKeyboardHandler */ -struct _FlKeyboardManager { +struct _FlKeyboardHandler { GObject parent_instance; FlKeyboardViewDelegate* view_delegate; // An array of #FlKeyResponder. Elements are added with - // #fl_keyboard_manager_add_responder immediately after initialization and are + // #fl_keyboard_handler_add_responder immediately after initialization and are // automatically released on dispose. GPtrArray* responder_list; // An array of #FlKeyboardPendingEvent. // - // Its elements are *not* unreferenced when removed. When FlKeyboardManager is + // Its elements are *not* unreferenced when removed. When FlKeyboardHandler is // disposed, this array will be set with a free_func so that the elements are // unreferenced when removed. GPtrArray* pending_responds; @@ -285,11 +285,11 @@ struct _FlKeyboardManager { std::unique_ptr derived_layout; // A static map from keycodes to all layout goals. // - // It is set up when the manager is initialized and is not changed ever after. + // It is set up when the handler is initialized and is not changed ever after. std::unique_ptr> keycode_to_goals; // A static map from logical keys to all mandatory layout goals. // - // It is set up when the manager is initialized and is not changed ever after. + // It is set up when the handler is initialized and is not changed ever after. std::unique_ptr> logical_to_mandatory_goals; @@ -297,15 +297,15 @@ struct _FlKeyboardManager { FlMethodChannel* channel; }; -G_DEFINE_TYPE(FlKeyboardManager, fl_keyboard_manager, G_TYPE_OBJECT); +G_DEFINE_TYPE(FlKeyboardHandler, fl_keyboard_handler, G_TYPE_OBJECT); -static void fl_keyboard_manager_dispose(GObject* object); +static void fl_keyboard_handler_dispose(GObject* object); -static void fl_keyboard_manager_class_init(FlKeyboardManagerClass* klass) { - G_OBJECT_CLASS(klass)->dispose = fl_keyboard_manager_dispose; +static void fl_keyboard_handler_class_init(FlKeyboardHandlerClass* klass) { + G_OBJECT_CLASS(klass)->dispose = fl_keyboard_handler_dispose; } -static void fl_keyboard_manager_init(FlKeyboardManager* self) { +static void fl_keyboard_handler_init(FlKeyboardHandler* self) { self->derived_layout = std::make_unique(); self->keycode_to_goals = @@ -327,8 +327,8 @@ static void fl_keyboard_manager_init(FlKeyboardManager* self) { self->last_sequence_id = 1; } -static void fl_keyboard_manager_dispose(GObject* object) { - FlKeyboardManager* self = FL_KEYBOARD_MANAGER(object); +static void fl_keyboard_handler_dispose(GObject* object) { + FlKeyboardHandler* self = FL_KEYBOARD_HANDLER(object); if (self->view_delegate != nullptr) { fl_keyboard_view_delegate_subscribe_to_layout_change(self->view_delegate, @@ -348,10 +348,10 @@ static void fl_keyboard_manager_dispose(GObject* object) { g_ptr_array_free(self->pending_responds, TRUE); g_ptr_array_free(self->pending_redispatches, TRUE); - G_OBJECT_CLASS(fl_keyboard_manager_parent_class)->dispose(object); + G_OBJECT_CLASS(fl_keyboard_handler_parent_class)->dispose(object); } -/* Implement FlKeyboardManager */ +/* Implement FlKeyboardHandler */ // This is an exact copy of g_ptr_array_find_with_equal_func. Somehow CI // reports that can not find symbol g_ptr_array_find_with_equal_func, despite @@ -399,7 +399,7 @@ static gboolean compare_pending_by_hash(gconstpointer pending, // hash. // // Returns true if the event is found and removed. -static bool fl_keyboard_manager_remove_redispatched(FlKeyboardManager* self, +static bool fl_keyboard_handler_remove_redispatched(FlKeyboardHandler* self, uint64_t hash) { guint result_index; gboolean found = g_ptr_array_find_with_equal_func1( @@ -417,10 +417,10 @@ static bool fl_keyboard_manager_remove_redispatched(FlKeyboardManager* self, // The callback used by a responder after the event was dispatched. static void responder_handle_event_callback(bool handled, gpointer user_data_ptr) { - g_return_if_fail(FL_IS_KEYBOARD_MANAGER_USER_DATA(user_data_ptr)); - FlKeyboardManagerUserData* user_data = - FL_KEYBOARD_MANAGER_USER_DATA(user_data_ptr); - FlKeyboardManager* self = user_data->manager; + g_return_if_fail(FL_IS_KEYBOARD_HANDLER_USER_DATA(user_data_ptr)); + FlKeyboardHandlerUserData* user_data = + FL_KEYBOARD_HANDLER_USER_DATA(user_data_ptr); + FlKeyboardHandler* self = user_data->handler; g_return_if_fail(self->view_delegate != nullptr); guint result_index = -1; @@ -465,7 +465,7 @@ static uint16_t convert_key_to_char(FlKeyboardViewDelegate* view_delegate, // Make sure that Flutter has derived the layout for the group of the event, // if the event contains a goal keycode. -static void guarantee_layout(FlKeyboardManager* self, FlKeyEvent* event) { +static void guarantee_layout(FlKeyboardHandler* self, FlKeyEvent* event) { guint8 group = event->group; if (self->derived_layout->find(group) != self->derived_layout->end()) { return; @@ -541,7 +541,7 @@ static void guarantee_layout(FlKeyboardManager* self, FlKeyEvent* event) { } // Returns the keyboard pressed state. -FlMethodResponse* get_keyboard_state(FlKeyboardManager* self) { +FlMethodResponse* get_keyboard_state(FlKeyboardHandler* self) { g_autoptr(FlValue) result = fl_value_new_map(); GHashTable* pressing_records = @@ -565,7 +565,7 @@ FlMethodResponse* get_keyboard_state(FlKeyboardManager* self) { static void method_call_handler(FlMethodChannel* channel, FlMethodCall* method_call, gpointer user_data) { - FlKeyboardManager* self = FL_KEYBOARD_MANAGER(user_data); + FlKeyboardHandler* self = FL_KEYBOARD_HANDLER(user_data); const gchar* method = fl_method_call_get_name(method_call); @@ -582,13 +582,13 @@ static void method_call_handler(FlMethodChannel* channel, } } -FlKeyboardManager* fl_keyboard_manager_new( +FlKeyboardHandler* fl_keyboard_handler_new( FlBinaryMessenger* messenger, FlKeyboardViewDelegate* view_delegate) { g_return_val_if_fail(FL_IS_KEYBOARD_VIEW_DELEGATE(view_delegate), nullptr); - FlKeyboardManager* self = FL_KEYBOARD_MANAGER( - g_object_new(fl_keyboard_manager_get_type(), nullptr)); + FlKeyboardHandler* self = FL_KEYBOARD_HANDLER( + g_object_new(fl_keyboard_handler_get_type(), nullptr)); self->view_delegate = view_delegate; g_object_add_weak_pointer( @@ -601,8 +601,8 @@ FlKeyboardManager* fl_keyboard_manager_new( FL_KEY_RESPONDER(fl_key_embedder_responder_new( [](const FlutterKeyEvent* event, FlutterKeyEventCallback callback, void* callback_user_data, void* send_key_event_user_data) { - FlKeyboardManager* self = - FL_KEYBOARD_MANAGER(send_key_event_user_data); + FlKeyboardHandler* self = + FL_KEYBOARD_HANDLER(send_key_event_user_data); g_return_if_fail(self->view_delegate != nullptr); fl_keyboard_view_delegate_send_key_event( self->view_delegate, event, callback, callback_user_data); @@ -635,16 +635,16 @@ static void dispatch_to_responder(gpointer responder_data, context->user_data, context->specified_logical_key); } -gboolean fl_keyboard_manager_handle_event(FlKeyboardManager* self, +gboolean fl_keyboard_handler_handle_event(FlKeyboardHandler* self, FlKeyEvent* event) { - g_return_val_if_fail(FL_IS_KEYBOARD_MANAGER(self), FALSE); + g_return_val_if_fail(FL_IS_KEYBOARD_HANDLER(self), FALSE); g_return_val_if_fail(event != nullptr, FALSE); g_return_val_if_fail(self->view_delegate != nullptr, FALSE); guarantee_layout(self, event); - uint64_t incoming_hash = fl_keyboard_manager_get_event_hash(event); - if (fl_keyboard_manager_remove_redispatched(self, incoming_hash)) { + uint64_t incoming_hash = fl_keyboard_handler_get_event_hash(event); + if (fl_keyboard_handler_remove_redispatched(self, incoming_hash)) { return FALSE; } @@ -653,8 +653,8 @@ gboolean fl_keyboard_manager_handle_event(FlKeyboardManager* self, self->responder_list->len); g_ptr_array_add(self->pending_responds, pending); - FlKeyboardManagerUserData* user_data = - fl_keyboard_manager_user_data_new(self, pending->sequence_id); + FlKeyboardHandlerUserData* user_data = + fl_keyboard_handler_user_data_new(self, pending->sequence_id); DispatchToResponderLoopContext data{ .event = event, .specified_logical_key = @@ -666,30 +666,30 @@ gboolean fl_keyboard_manager_handle_event(FlKeyboardManager* self, return TRUE; } -gboolean fl_keyboard_manager_is_state_clear(FlKeyboardManager* self) { - g_return_val_if_fail(FL_IS_KEYBOARD_MANAGER(self), FALSE); +gboolean fl_keyboard_handler_is_state_clear(FlKeyboardHandler* self) { + g_return_val_if_fail(FL_IS_KEYBOARD_HANDLER(self), FALSE); return self->pending_responds->len == 0 && self->pending_redispatches->len == 0; } -void fl_keyboard_manager_sync_modifier_if_needed(FlKeyboardManager* self, +void fl_keyboard_handler_sync_modifier_if_needed(FlKeyboardHandler* self, guint state, double event_time) { - g_return_if_fail(FL_IS_KEYBOARD_MANAGER(self)); + g_return_if_fail(FL_IS_KEYBOARD_HANDLER(self)); // The embedder responder is the first element in - // FlKeyboardManager.responder_list. + // FlKeyboardHandler.responder_list. FlKeyEmbedderResponder* responder = FL_KEY_EMBEDDER_RESPONDER(g_ptr_array_index(self->responder_list, 0)); fl_key_embedder_responder_sync_modifiers_if_needed(responder, state, event_time); } -GHashTable* fl_keyboard_manager_get_pressed_state(FlKeyboardManager* self) { - g_return_val_if_fail(FL_IS_KEYBOARD_MANAGER(self), nullptr); +GHashTable* fl_keyboard_handler_get_pressed_state(FlKeyboardHandler* self) { + g_return_val_if_fail(FL_IS_KEYBOARD_HANDLER(self), nullptr); // The embedder responder is the first element in - // FlKeyboardManager.responder_list. + // FlKeyboardHandler.responder_list. FlKeyEmbedderResponder* responder = FL_KEY_EMBEDDER_RESPONDER(g_ptr_array_index(self->responder_list, 0)); return fl_key_embedder_responder_get_pressed_state(responder); diff --git a/shell/platform/linux/fl_keyboard_manager.h b/shell/platform/linux/fl_keyboard_handler.h similarity index 58% rename from shell/platform/linux/fl_keyboard_manager.h rename to shell/platform/linux/fl_keyboard_handler.h index 5e43596dc2abd..c75bc24664603 100644 --- a/shell/platform/linux/fl_keyboard_manager.h +++ b/shell/platform/linux/fl_keyboard_handler.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_MANAGER_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_MANAGER_H_ +#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_HANDLER_H_ +#define FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_HANDLER_H_ #include @@ -11,15 +11,15 @@ G_BEGIN_DECLS -#define FL_TYPE_KEYBOARD_MANAGER fl_keyboard_manager_get_type() -G_DECLARE_FINAL_TYPE(FlKeyboardManager, - fl_keyboard_manager, +#define FL_TYPE_KEYBOARD_HANDLER fl_keyboard_handler_get_type() +G_DECLARE_FINAL_TYPE(FlKeyboardHandler, + fl_keyboard_handler, FL, - KEYBOARD_MANAGER, + KEYBOARD_HANDLER, GObject); /** - * FlKeyboardManager: + * FlKeyboardHandler: * * Processes keyboard events and cooperate with `TextInputHandler`. * @@ -35,64 +35,64 @@ G_DECLARE_FINAL_TYPE(FlKeyboardManager, */ /** - * fl_keyboard_manager_new: - * @view_delegate: An interface that the manager requires to communicate with + * fl_keyboard_handler_new: + * @view_delegate: An interface that the handler requires to communicate with * the platform. Usually implemented by FlView. * - * Create a new #FlKeyboardManager. + * Create a new #FlKeyboardHandler. * - * Returns: a new #FlKeyboardManager. + * Returns: a new #FlKeyboardHandler. */ -FlKeyboardManager* fl_keyboard_manager_new( +FlKeyboardHandler* fl_keyboard_handler_new( FlBinaryMessenger* messenger, FlKeyboardViewDelegate* view_delegate); /** - * fl_keyboard_manager_handle_event: - * @manager: the #FlKeyboardManager self. + * fl_keyboard_handler_handle_event: + * @handler: the #FlKeyboardHandler self. * @event: the event to be dispatched. It is usually a wrap of a GdkEventKey. - * This event will be managed and released by #FlKeyboardManager. + * This event will be managed and released by #FlKeyboardHandler. * - * Make the manager process a system key event. This might eventually send + * Make the handler process a system key event. This might eventually send * messages to the framework, trigger text input effects, or redispatch the * event back to the system. */ -gboolean fl_keyboard_manager_handle_event(FlKeyboardManager* manager, +gboolean fl_keyboard_handler_handle_event(FlKeyboardHandler* handler, FlKeyEvent* event); /** - * fl_keyboard_manager_is_state_clear: - * @manager: the #FlKeyboardManager self. + * fl_keyboard_handler_is_state_clear: + * @handler: the #FlKeyboardHandler self. * - * A debug-only method that queries whether the manager's various states are + * A debug-only method that queries whether the handler's various states are * cleared, i.e. no pending events for redispatching or for responding. * - * Returns: true if the manager's various states are cleared. + * Returns: true if the handler's various states are cleared. */ -gboolean fl_keyboard_manager_is_state_clear(FlKeyboardManager* manager); +gboolean fl_keyboard_handler_is_state_clear(FlKeyboardHandler* handler); /** - * fl_keyboard_manager_sync_modifier_if_needed: - * @manager: the #FlKeyboardManager self. + * fl_keyboard_handler_sync_modifier_if_needed: + * @handler: the #FlKeyboardHandler self. * @state: the state of the modifiers mask. * @event_time: the time attribute of the incoming GDK event. * * If needed, synthesize modifier keys up and down event by comparing their * current pressing states with the given modifiers mask. */ -void fl_keyboard_manager_sync_modifier_if_needed(FlKeyboardManager* manager, +void fl_keyboard_handler_sync_modifier_if_needed(FlKeyboardHandler* handler, guint state, double event_time); /** - * fl_keyboard_manager_get_pressed_state: - * @manager: the #FlKeyboardManager self. + * fl_keyboard_handler_get_pressed_state: + * @handler: the #FlKeyboardHandler self. * * Returns the keyboard pressed state. The hash table contains one entry per * pressed keys, mapping from the logical key to the physical key.* */ -GHashTable* fl_keyboard_manager_get_pressed_state(FlKeyboardManager* manager); +GHashTable* fl_keyboard_handler_get_pressed_state(FlKeyboardHandler* handler); G_END_DECLS -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_MANAGER_H_ +#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_HANDLER_H_ diff --git a/shell/platform/linux/fl_keyboard_manager_test.cc b/shell/platform/linux/fl_keyboard_handler_test.cc similarity index 92% rename from shell/platform/linux/fl_keyboard_manager_test.cc rename to shell/platform/linux/fl_keyboard_handler_test.cc index 9539eb01ac8af..6acb2abf79540 100644 --- a/shell/platform/linux/fl_keyboard_manager_test.cc +++ b/shell/platform/linux/fl_keyboard_handler_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/platform/linux/fl_keyboard_manager.h" +#include "flutter/shell/platform/linux/fl_keyboard_handler.h" #include #include @@ -73,7 +73,7 @@ typedef std::function)> RedispatchHandler; -// A type that can record all kinds of effects that the keyboard manager +// A type that can record all kinds of effects that the keyboard handler // triggers. // // An instance of `CallRecord` might not have all the fields filled. @@ -495,16 +495,16 @@ class KeyboardTester { respondToTextInputWith(false); setLayout(kLayoutUs); - manager_ = - fl_keyboard_manager_new(messenger, FL_KEYBOARD_VIEW_DELEGATE(view_)); + handler_ = + fl_keyboard_handler_new(messenger, FL_KEYBOARD_VIEW_DELEGATE(view_)); } ~KeyboardTester() { g_clear_object(&view_); - g_clear_object(&manager_); + g_clear_object(&handler_); } - FlKeyboardManager* manager() { return manager_; } + FlKeyboardHandler* handler() { return handler_; } // Block until all GdkMainLoop messages are processed, which is basically // used only for channel messages. @@ -526,8 +526,8 @@ class KeyboardTester { int first_error = -1; during_redispatch_ = true; for (size_t event_id = 0; event_id < event_count; event_id += 1) { - bool handled = fl_keyboard_manager_handle_event( - manager_, events[event_id].release()); + bool handled = fl_keyboard_handler_handle_event( + handler_, events[event_id].release()); EXPECT_FALSE(handled); if (handled) { first_error = first_error == -1 ? event_id : first_error; @@ -624,7 +624,7 @@ class KeyboardTester { private: FlMockViewDelegate* view_; - FlKeyboardManager* manager_; + FlKeyboardHandler* handler_; bool during_redispatch_ = false; static gboolean _flushChannelMessagesCb(gpointer data) { @@ -636,20 +636,20 @@ class KeyboardTester { // Make sure that the keyboard can be disposed without crashes when there are // unresolved pending events. -TEST(FlKeyboardManagerTest, DisposeWithUnresolvedPends) { +TEST(FlKeyboardHandlerTest, DisposeWithUnresolvedPends) { KeyboardTester tester; std::vector call_records; // Record calls so that they aren't responded. tester.recordEmbedderCallsTo(call_records); - fl_keyboard_manager_handle_event( - tester.manager(), + fl_keyboard_handler_handle_event( + tester.handler(), fl_key_event_new_by_mock(true, GDK_KEY_a, kKeyCodeKeyA, static_cast(0), false)); tester.respondToEmbedderCallsWith(true); - fl_keyboard_manager_handle_event( - tester.manager(), + fl_keyboard_handler_handle_event( + tester.handler(), fl_key_event_new_by_mock(false, GDK_KEY_a, kKeyCodeKeyA, static_cast(0), false)); @@ -658,24 +658,24 @@ TEST(FlKeyboardManagerTest, DisposeWithUnresolvedPends) { // Passes if the cleanup does not crash. } -TEST(FlKeyboardManagerTest, SingleDelegateWithAsyncResponds) { +TEST(FlKeyboardHandlerTest, SingleDelegateWithAsyncResponds) { KeyboardTester tester; std::vector call_records; std::vector> redispatched; - gboolean manager_handled = false; + gboolean handler_handled = false; /// Test 1: One event that is handled by the framework tester.recordEmbedderCallsTo(call_records); tester.recordRedispatchedEventsTo(redispatched); // Dispatch a key event - manager_handled = fl_keyboard_manager_handle_event( - tester.manager(), + handler_handled = fl_keyboard_handler_handle_event( + tester.handler(), fl_key_event_new_by_mock(true, GDK_KEY_a, kKeyCodeKeyA, static_cast(0), false)); tester.flushChannelMessages(); - EXPECT_EQ(manager_handled, true); + EXPECT_EQ(handler_handled, true); EXPECT_EQ(redispatched.size(), 0u); EXPECT_EQ(call_records.size(), 1u); EXPECT_KEY_EVENT(call_records[0], kFlutterKeyEventTypeDown, kPhysicalKeyA, @@ -684,28 +684,28 @@ TEST(FlKeyboardManagerTest, SingleDelegateWithAsyncResponds) { call_records[0].callback(true); tester.flushChannelMessages(); EXPECT_EQ(redispatched.size(), 0u); - EXPECT_TRUE(fl_keyboard_manager_is_state_clear(tester.manager())); + EXPECT_TRUE(fl_keyboard_handler_is_state_clear(tester.handler())); call_records.clear(); /// Test 2: Two events that are unhandled by the framework - manager_handled = fl_keyboard_manager_handle_event( - tester.manager(), + handler_handled = fl_keyboard_handler_handle_event( + tester.handler(), fl_key_event_new_by_mock(false, GDK_KEY_a, kKeyCodeKeyA, static_cast(0), false)); tester.flushChannelMessages(); - EXPECT_EQ(manager_handled, true); + EXPECT_EQ(handler_handled, true); EXPECT_EQ(redispatched.size(), 0u); EXPECT_EQ(call_records.size(), 1u); EXPECT_KEY_EVENT(call_records[0], kFlutterKeyEventTypeUp, kPhysicalKeyA, kLogicalKeyA, nullptr, false); // Dispatch another key event - manager_handled = fl_keyboard_manager_handle_event( - tester.manager(), + handler_handled = fl_keyboard_handler_handle_event( + tester.handler(), fl_key_event_new_by_mock(true, GDK_KEY_b, kKeyCodeKeyB, static_cast(0), false)); tester.flushChannelMessages(); - EXPECT_EQ(manager_handled, true); + EXPECT_EQ(handler_handled, true); EXPECT_EQ(redispatched.size(), 0u); EXPECT_EQ(call_records.size(), 2u); EXPECT_KEY_EVENT(call_records[1], kFlutterKeyEventTypeDown, kPhysicalKeyB, @@ -720,33 +720,33 @@ TEST(FlKeyboardManagerTest, SingleDelegateWithAsyncResponds) { EXPECT_EQ(redispatched.size(), 2u); EXPECT_EQ(redispatched[1]->keyval, 0x61u); - EXPECT_FALSE(fl_keyboard_manager_is_state_clear(tester.manager())); + EXPECT_FALSE(fl_keyboard_handler_is_state_clear(tester.handler())); call_records.clear(); // Resolve redispatches EXPECT_EQ(tester.redispatchEventsAndClear(redispatched), 2); tester.flushChannelMessages(); EXPECT_EQ(call_records.size(), 0u); - EXPECT_TRUE(fl_keyboard_manager_is_state_clear(tester.manager())); + EXPECT_TRUE(fl_keyboard_handler_is_state_clear(tester.handler())); /// Test 3: Dispatch the same event again to ensure that prevention from /// redispatching only works once. - manager_handled = fl_keyboard_manager_handle_event( - tester.manager(), + handler_handled = fl_keyboard_handler_handle_event( + tester.handler(), fl_key_event_new_by_mock(false, GDK_KEY_a, kKeyCodeKeyA, static_cast(0), false)); tester.flushChannelMessages(); - EXPECT_EQ(manager_handled, true); + EXPECT_EQ(handler_handled, true); EXPECT_EQ(redispatched.size(), 0u); EXPECT_EQ(call_records.size(), 1u); call_records[0].callback(true); - EXPECT_TRUE(fl_keyboard_manager_is_state_clear(tester.manager())); + EXPECT_TRUE(fl_keyboard_handler_is_state_clear(tester.handler())); } -TEST(FlKeyboardManagerTest, SingleDelegateWithSyncResponds) { +TEST(FlKeyboardHandlerTest, SingleDelegateWithSyncResponds) { KeyboardTester tester; - gboolean manager_handled = false; + gboolean handler_handled = false; std::vector call_records; std::vector> redispatched; @@ -755,49 +755,49 @@ TEST(FlKeyboardManagerTest, SingleDelegateWithSyncResponds) { tester.recordRedispatchedEventsTo(redispatched); // Dispatch a key event - manager_handled = fl_keyboard_manager_handle_event( - tester.manager(), + handler_handled = fl_keyboard_handler_handle_event( + tester.handler(), fl_key_event_new_by_mock(true, GDK_KEY_a, kKeyCodeKeyA, static_cast(0), false)); tester.flushChannelMessages(); - EXPECT_EQ(manager_handled, true); + EXPECT_EQ(handler_handled, true); EXPECT_EQ(call_records.size(), 1u); EXPECT_KEY_EVENT(call_records[0], kFlutterKeyEventTypeDown, kPhysicalKeyA, kLogicalKeyA, "a", false); EXPECT_EQ(redispatched.size(), 0u); call_records.clear(); - EXPECT_TRUE(fl_keyboard_manager_is_state_clear(tester.manager())); + EXPECT_TRUE(fl_keyboard_handler_is_state_clear(tester.handler())); redispatched.clear(); /// Test 2: An event unhandled by the framework tester.respondToEmbedderCallsWithAndRecordsTo(false, call_records); - manager_handled = fl_keyboard_manager_handle_event( - tester.manager(), + handler_handled = fl_keyboard_handler_handle_event( + tester.handler(), fl_key_event_new_by_mock(false, GDK_KEY_a, kKeyCodeKeyA, static_cast(0), false)); tester.flushChannelMessages(); - EXPECT_EQ(manager_handled, true); + EXPECT_EQ(handler_handled, true); EXPECT_EQ(call_records.size(), 1u); EXPECT_KEY_EVENT(call_records[0], kFlutterKeyEventTypeUp, kPhysicalKeyA, kLogicalKeyA, nullptr, false); EXPECT_EQ(redispatched.size(), 1u); call_records.clear(); - EXPECT_FALSE(fl_keyboard_manager_is_state_clear(tester.manager())); + EXPECT_FALSE(fl_keyboard_handler_is_state_clear(tester.handler())); EXPECT_EQ(tester.redispatchEventsAndClear(redispatched), 1); EXPECT_EQ(call_records.size(), 0u); - EXPECT_TRUE(fl_keyboard_manager_is_state_clear(tester.manager())); + EXPECT_TRUE(fl_keyboard_handler_is_state_clear(tester.handler())); } -TEST(FlKeyboardManagerTest, WithTwoAsyncDelegates) { +TEST(FlKeyboardHandlerTest, WithTwoAsyncDelegates) { KeyboardTester tester; std::vector call_records; std::vector> redispatched; - gboolean manager_handled = false; + gboolean handler_handled = false; tester.recordEmbedderCallsTo(call_records); tester.recordChannelCallsTo(call_records); @@ -805,12 +805,12 @@ TEST(FlKeyboardManagerTest, WithTwoAsyncDelegates) { /// Test 1: One delegate responds true, the other false - manager_handled = fl_keyboard_manager_handle_event( - tester.manager(), + handler_handled = fl_keyboard_handler_handle_event( + tester.handler(), fl_key_event_new_by_mock(true, GDK_KEY_a, kKeyCodeKeyA, static_cast(0), false)); - EXPECT_EQ(manager_handled, true); + EXPECT_EQ(handler_handled, true); EXPECT_EQ(redispatched.size(), 0u); EXPECT_EQ(call_records.size(), 2u); @@ -822,16 +822,16 @@ TEST(FlKeyboardManagerTest, WithTwoAsyncDelegates) { tester.flushChannelMessages(); EXPECT_EQ(redispatched.size(), 0u); - EXPECT_TRUE(fl_keyboard_manager_is_state_clear(tester.manager())); + EXPECT_TRUE(fl_keyboard_handler_is_state_clear(tester.handler())); call_records.clear(); /// Test 2: All delegates respond false - manager_handled = fl_keyboard_manager_handle_event( - tester.manager(), + handler_handled = fl_keyboard_handler_handle_event( + tester.handler(), fl_key_event_new_by_mock(false, GDK_KEY_a, kKeyCodeKeyA, static_cast(0), false)); - EXPECT_EQ(manager_handled, true); + EXPECT_EQ(handler_handled, true); EXPECT_EQ(redispatched.size(), 0u); EXPECT_EQ(call_records.size(), 2u); @@ -849,65 +849,65 @@ TEST(FlKeyboardManagerTest, WithTwoAsyncDelegates) { EXPECT_EQ(tester.redispatchEventsAndClear(redispatched), 1); EXPECT_EQ(call_records.size(), 0u); - EXPECT_TRUE(fl_keyboard_manager_is_state_clear(tester.manager())); + EXPECT_TRUE(fl_keyboard_handler_is_state_clear(tester.handler())); } -TEST(FlKeyboardManagerTest, TextInputHandlerReturnsFalse) { +TEST(FlKeyboardHandlerTest, TextInputHandlerReturnsFalse) { KeyboardTester tester; std::vector> redispatched; - gboolean manager_handled = false; + gboolean handler_handled = false; tester.recordRedispatchedEventsTo(redispatched); tester.respondToTextInputWith(false); // Dispatch a key event. - manager_handled = fl_keyboard_manager_handle_event( - tester.manager(), + handler_handled = fl_keyboard_handler_handle_event( + tester.handler(), fl_key_event_new_by_mock(true, GDK_KEY_a, kKeyCodeKeyA, static_cast(0), false)); tester.flushChannelMessages(); - EXPECT_EQ(manager_handled, true); + EXPECT_EQ(handler_handled, true); // The event was redispatched because no one handles it. EXPECT_EQ(redispatched.size(), 1u); // Resolve redispatched event. EXPECT_EQ(tester.redispatchEventsAndClear(redispatched), 1); - EXPECT_TRUE(fl_keyboard_manager_is_state_clear(tester.manager())); + EXPECT_TRUE(fl_keyboard_handler_is_state_clear(tester.handler())); } -TEST(FlKeyboardManagerTest, TextInputHandlerReturnsTrue) { +TEST(FlKeyboardHandlerTest, TextInputHandlerReturnsTrue) { KeyboardTester tester; std::vector> redispatched; - gboolean manager_handled = false; + gboolean handler_handled = false; tester.recordRedispatchedEventsTo(redispatched); tester.respondToTextInputWith(true); // Dispatch a key event. - manager_handled = fl_keyboard_manager_handle_event( - tester.manager(), + handler_handled = fl_keyboard_handler_handle_event( + tester.handler(), fl_key_event_new_by_mock(true, GDK_KEY_a, kKeyCodeKeyA, static_cast(0), false)); tester.flushChannelMessages(); - EXPECT_EQ(manager_handled, true); - // The event was not redispatched because text input plugin handles it. + EXPECT_EQ(handler_handled, true); + // The event was not redispatched because handler handles it. EXPECT_EQ(redispatched.size(), 0u); - EXPECT_TRUE(fl_keyboard_manager_is_state_clear(tester.manager())); + EXPECT_TRUE(fl_keyboard_handler_is_state_clear(tester.handler())); } -TEST(FlKeyboardManagerTest, CorrectLogicalKeyForLayouts) { +TEST(FlKeyboardHandlerTest, CorrectLogicalKeyForLayouts) { KeyboardTester tester; std::vector call_records; tester.recordEmbedderCallsTo(call_records); auto sendTap = [&](guint8 keycode, guint keyval, guint8 group) { - fl_keyboard_manager_handle_event( - tester.manager(), fl_key_event_new_by_mock( + fl_keyboard_handler_handle_event( + tester.handler(), fl_key_event_new_by_mock( true, keyval, keycode, static_cast(0), false, group)); - fl_keyboard_manager_handle_event( - tester.manager(), fl_key_event_new_by_mock( + fl_keyboard_handler_handle_event( + tester.handler(), fl_key_event_new_by_mock( false, keyval, keycode, static_cast(0), false, group)); }; @@ -990,7 +990,7 @@ TEST(FlKeyboardManagerTest, CorrectLogicalKeyForLayouts) { VERIFY_DOWN(kLogicalBracketLeft, "["); } -TEST(FlKeyboardManagerTest, SynthesizeModifiersIfNeeded) { +TEST(FlKeyboardHandlerTest, SynthesizeModifiersIfNeeded) { KeyboardTester tester; std::vector call_records; tester.recordEmbedderCallsTo(call_records); @@ -999,13 +999,13 @@ TEST(FlKeyboardManagerTest, SynthesizeModifiersIfNeeded) { uint64_t physical, uint64_t logical) { // Modifier is pressed. guint state = mask; - fl_keyboard_manager_sync_modifier_if_needed(tester.manager(), state, 1000); + fl_keyboard_handler_sync_modifier_if_needed(tester.handler(), state, 1000); EXPECT_EQ(call_records.size(), 1u); EXPECT_KEY_EVENT(call_records[0], kFlutterKeyEventTypeDown, physical, logical, NULL, true); // Modifier is released. state = state ^ mask; - fl_keyboard_manager_sync_modifier_if_needed(tester.manager(), state, 1001); + fl_keyboard_handler_sync_modifier_if_needed(tester.handler(), state, 1001); EXPECT_EQ(call_records.size(), 2u); EXPECT_KEY_EVENT(call_records[1], kFlutterKeyEventTypeUp, physical, logical, NULL, true); @@ -1014,7 +1014,7 @@ TEST(FlKeyboardManagerTest, SynthesizeModifiersIfNeeded) { // No modifiers pressed. guint state = 0; - fl_keyboard_manager_sync_modifier_if_needed(tester.manager(), state, 1000); + fl_keyboard_handler_sync_modifier_if_needed(tester.handler(), state, 1000); EXPECT_EQ(call_records.size(), 0u); call_records.clear(); @@ -1028,18 +1028,18 @@ TEST(FlKeyboardManagerTest, SynthesizeModifiersIfNeeded) { kLogicalShiftLeft); } -TEST(FlKeyboardManagerTest, GetPressedState) { +TEST(FlKeyboardHandlerTest, GetPressedState) { KeyboardTester tester; tester.respondToTextInputWith(true); // Dispatch a key event. - fl_keyboard_manager_handle_event( - tester.manager(), + fl_keyboard_handler_handle_event( + tester.handler(), fl_key_event_new_by_mock(true, GDK_KEY_a, kKeyCodeKeyA, static_cast(0), false)); GHashTable* pressedState = - fl_keyboard_manager_get_pressed_state(tester.manager()); + fl_keyboard_handler_get_pressed_state(tester.handler()); EXPECT_EQ(g_hash_table_size(pressedState), 1u); gpointer physical_key = @@ -1047,12 +1047,12 @@ TEST(FlKeyboardManagerTest, GetPressedState) { EXPECT_EQ(gpointer_to_uint64(physical_key), kLogicalKeyA); } -TEST(FlKeyboardPluginTest, KeyboardChannelGetPressedState) { +TEST(FlKeyboardHandlerTest, KeyboardChannelGetPressedState) { ::testing::NiceMock messenger; - g_autoptr(FlKeyboardManager) manager = fl_keyboard_manager_new( + g_autoptr(FlKeyboardHandler) handler = fl_keyboard_handler_new( messenger, FL_KEYBOARD_VIEW_DELEGATE(fl_mock_view_delegate_new())); - EXPECT_NE(manager, nullptr); + EXPECT_NE(handler, nullptr); g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new(); g_autoptr(GBytes) message = fl_method_codec_encode_method_call( diff --git a/shell/platform/linux/fl_view.cc b/shell/platform/linux/fl_view.cc index 2ec1c7e43e9e5..8672fa76748d4 100644 --- a/shell/platform/linux/fl_view.cc +++ b/shell/platform/linux/fl_view.cc @@ -15,7 +15,7 @@ #include "flutter/shell/platform/linux/fl_backing_store_provider.h" #include "flutter/shell/platform/linux/fl_engine_private.h" #include "flutter/shell/platform/linux/fl_key_event.h" -#include "flutter/shell/platform/linux/fl_keyboard_manager.h" +#include "flutter/shell/platform/linux/fl_keyboard_handler.h" #include "flutter/shell/platform/linux/fl_keyboard_view_delegate.h" #include "flutter/shell/platform/linux/fl_mouse_cursor_handler.h" #include "flutter/shell/platform/linux/fl_platform_handler.h" @@ -50,9 +50,10 @@ struct _FlView { // Current state information for the window associated with this view. GdkWindowState window_state; - // Flutter system channel handlers. - FlKeyboardManager* keyboard_manager; FlScrollingManager* scrolling_manager; + + // Flutter system channel handlers. + FlKeyboardHandler* keyboard_handler; FlTextInputHandler* text_input_handler; FlMouseCursorHandler* mouse_cursor_handler; FlPlatformHandler* platform_handler; @@ -108,7 +109,7 @@ static gboolean window_delete_event_cb(FlView* self) { return TRUE; } -// Initialize keyboard manager. +// Initialize keyboard. static void init_keyboard(FlView* self) { FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(self->engine); @@ -121,9 +122,9 @@ static void init_keyboard(FlView* self) { g_clear_object(&self->text_input_handler); self->text_input_handler = fl_text_input_handler_new( messenger, im_context, FL_TEXT_INPUT_VIEW_DELEGATE(self)); - g_clear_object(&self->keyboard_manager); - self->keyboard_manager = - fl_keyboard_manager_new(messenger, FL_KEYBOARD_VIEW_DELEGATE(self)); + g_clear_object(&self->keyboard_handler); + self->keyboard_handler = + fl_keyboard_handler_new(messenger, FL_KEYBOARD_VIEW_DELEGATE(self)); } static void init_scrolling(FlView* self) { @@ -203,7 +204,7 @@ static gboolean send_pointer_button_event(FlView* self, GdkEvent* event) { gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self)); fl_scrolling_manager_set_last_mouse_position( self->scrolling_manager, event_x * scale_factor, event_y * scale_factor); - fl_keyboard_manager_sync_modifier_if_needed(self->keyboard_manager, + fl_keyboard_handler_sync_modifier_if_needed(self->keyboard_handler, event_state, event_time); fl_engine_send_mouse_pointer_event( self->engine, phase, event_time * kMicrosecondsPerMillisecond, @@ -437,7 +438,7 @@ static gboolean motion_notify_event_cb(FlView* self, gint scale_factor = gtk_widget_get_scale_factor(GTK_WIDGET(self)); - fl_keyboard_manager_sync_modifier_if_needed(self->keyboard_manager, + fl_keyboard_handler_sync_modifier_if_needed(self->keyboard_handler, event_state, event_time); fl_engine_send_mouse_pointer_event( self->engine, self->button_state != 0 ? kMove : kHover, @@ -725,7 +726,7 @@ static void fl_view_dispose(GObject* object) { g_clear_object(&self->project); g_clear_object(&self->renderer); g_clear_object(&self->engine); - g_clear_object(&self->keyboard_manager); + g_clear_object(&self->keyboard_handler); if (self->keymap_keys_changed_cb_id != 0) { g_signal_handler_disconnect(self->keymap, self->keymap_keys_changed_cb_id); self->keymap_keys_changed_cb_id = 0; @@ -741,8 +742,8 @@ static void fl_view_dispose(GObject* object) { static gboolean fl_view_key_press_event(GtkWidget* widget, GdkEventKey* event) { FlView* self = FL_VIEW(widget); - return fl_keyboard_manager_handle_event( - self->keyboard_manager, fl_key_event_new_from_gdk_event(gdk_event_copy( + return fl_keyboard_handler_handle_event( + self->keyboard_handler, fl_key_event_new_from_gdk_event(gdk_event_copy( reinterpret_cast(event)))); } @@ -750,8 +751,8 @@ static gboolean fl_view_key_press_event(GtkWidget* widget, GdkEventKey* event) { static gboolean fl_view_key_release_event(GtkWidget* widget, GdkEventKey* event) { FlView* self = FL_VIEW(widget); - return fl_keyboard_manager_handle_event( - self->keyboard_manager, fl_key_event_new_from_gdk_event(gdk_event_copy( + return fl_keyboard_handler_handle_event( + self->keyboard_handler, fl_key_event_new_from_gdk_event(gdk_event_copy( reinterpret_cast(event)))); } @@ -852,5 +853,5 @@ void fl_view_redraw(FlView* self) { GHashTable* fl_view_get_keyboard_state(FlView* self) { g_return_val_if_fail(FL_IS_VIEW(self), nullptr); - return fl_keyboard_manager_get_pressed_state(self->keyboard_manager); + return fl_keyboard_handler_get_pressed_state(self->keyboard_handler); } From ac7382a395e30c43d6432a60b6f9690b111013e0 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Fri, 5 Jul 2024 14:59:00 +1200 Subject: [PATCH 06/10] Fix FlScrollingManager not being destroyed --- shell/platform/linux/fl_view.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/platform/linux/fl_view.cc b/shell/platform/linux/fl_view.cc index 8672fa76748d4..82ed9829c2ef7 100644 --- a/shell/platform/linux/fl_view.cc +++ b/shell/platform/linux/fl_view.cc @@ -726,6 +726,7 @@ static void fl_view_dispose(GObject* object) { g_clear_object(&self->project); g_clear_object(&self->renderer); g_clear_object(&self->engine); + g_clear_object(&self->scrolling_manager); g_clear_object(&self->keyboard_handler); if (self->keymap_keys_changed_cb_id != 0) { g_signal_handler_disconnect(self->keymap, self->keymap_keys_changed_cb_id); From d37e6282dcf48ef0ee9156c265b9cdf56d5121fd Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Wed, 10 Jul 2024 09:49:20 +1200 Subject: [PATCH 07/10] Add more replacements of manager to handler --- shell/platform/linux/fl_key_channel_responder.cc | 4 ++-- shell/platform/linux/fl_key_event.h | 2 +- shell/platform/linux/fl_key_responder.h | 2 -- shell/platform/linux/fl_keyboard_view_delegate.h | 12 ++++++------ shell/platform/linux/key_mapping.h | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/shell/platform/linux/fl_key_channel_responder.cc b/shell/platform/linux/fl_key_channel_responder.cc index f4cb5353aedb9..c79ac942e78a0 100644 --- a/shell/platform/linux/fl_key_channel_responder.cc +++ b/shell/platform/linux/fl_key_channel_responder.cc @@ -43,9 +43,9 @@ struct _FlKeyChannelUserData { // The current responder. FlKeyChannelResponder* responder; - // The callback provided by the caller #FlKeyboardManager. + // The callback provided by the caller #FlKeyboardHandler. FlKeyResponderAsyncCallback callback; - // The user_data provided by the caller #FlKeyboardManager. + // The user_data provided by the caller #FlKeyboardHandler. gpointer user_data; }; diff --git a/shell/platform/linux/fl_key_event.h b/shell/platform/linux/fl_key_event.h index 48221d463a653..2a3a4334ed7eb 100644 --- a/shell/platform/linux/fl_key_event.h +++ b/shell/platform/linux/fl_key_event.h @@ -12,7 +12,7 @@ * A struct that stores information from GdkEvent. * * This is a class only used within the GTK embedding, created by - * FlView and consumed by FlKeyboardManager. It is not sent to + * FlView and consumed by FlKeyboardHandler. It is not sent to * the embedder. * * This object contains information from GdkEvent as well as an origin event diff --git a/shell/platform/linux/fl_key_responder.h b/shell/platform/linux/fl_key_responder.h index f66f9214bddf9..50fd6c51e6f48 100644 --- a/shell/platform/linux/fl_key_responder.h +++ b/shell/platform/linux/fl_key_responder.h @@ -14,8 +14,6 @@ G_BEGIN_DECLS -typedef struct _FlKeyboardManager FlKeyboardManager; - /** * FlKeyResponderAsyncCallback: * @event: whether the event has been handled. diff --git a/shell/platform/linux/fl_keyboard_view_delegate.h b/shell/platform/linux/fl_keyboard_view_delegate.h index 6d66b12ca3537..59fdc3f29e360 100644 --- a/shell/platform/linux/fl_keyboard_view_delegate.h +++ b/shell/platform/linux/fl_keyboard_view_delegate.h @@ -27,7 +27,7 @@ G_DECLARE_INTERFACE(FlKeyboardViewDelegate, /** * FlKeyboardViewDelegate: * - * An interface for a class that provides `FlKeyboardManager` with + * An interface for a class that provides `FlKeyboardHandler` with * platform-related features. * * This interface is typically implemented by `FlView`. @@ -61,10 +61,10 @@ struct _FlKeyboardViewDelegateInterface { /** * fl_keyboard_view_delegate_send_key_event: * - * Handles `FlKeyboardManager`'s request to send a `FlutterKeyEvent` through the + * Handles `FlKeyboardHandler`'s request to send a `FlutterKeyEvent` through the * embedder API to the framework. * - * The ownership of the `event` is kept by the keyboard manager, and the `event` + * The ownership of the `event` is kept by the keyboard handler, and the `event` * might be immediately destroyed after this function returns. * * The `callback` must eventually be called exactly once with the event result @@ -78,10 +78,10 @@ void fl_keyboard_view_delegate_send_key_event(FlKeyboardViewDelegate* delegate, /** * fl_keyboard_view_delegate_text_filter_key_press: * - * Handles `FlKeyboardManager`'s request to check if the GTK text input IM + * Handles `FlKeyboardHandler`'s request to check if the GTK text input IM * filter would like to handle a GDK event. * - * The ownership of the `event` is kept by the keyboard manager. + * The ownership of the `event` is kept by the keyboard handler. */ gboolean fl_keyboard_view_delegate_text_filter_key_press( FlKeyboardViewDelegate* delegate, @@ -101,7 +101,7 @@ FlBinaryMessenger* fl_keyboard_view_delegate_get_messenger( /** * fl_keyboard_view_delegate_redispatch_event: * - * Handles `FlKeyboardManager`'s request to insert a GDK event to the system for + * Handles `FlKeyboardHandler`'s request to insert a GDK event to the system for * redispatching. * * The ownership of event will be transferred to the view delegate. The view diff --git a/shell/platform/linux/key_mapping.h b/shell/platform/linux/key_mapping.h index 9b1468586f9a9..54a8f30208943 100644 --- a/shell/platform/linux/key_mapping.h +++ b/shell/platform/linux/key_mapping.h @@ -44,7 +44,7 @@ typedef struct { // The logical key for this key. uint64_t logical_key; - // If the goal is mandatory, the keyboard manager will make sure to find a + // If the goal is mandatory, the keyboard handler will make sure to find a // logical key for this character, falling back to the US keyboard layout. bool mandatory; } LayoutGoal; From e8eec4dfe9888bec0b70c0f9988d63047600b7c2 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Thu, 18 Jul 2024 15:33:37 +1200 Subject: [PATCH 08/10] Revert 'Fix FlScrollingManager not being destroyed' in case it's causing the CI failure --- shell/platform/linux/fl_view.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/shell/platform/linux/fl_view.cc b/shell/platform/linux/fl_view.cc index 82ed9829c2ef7..8672fa76748d4 100644 --- a/shell/platform/linux/fl_view.cc +++ b/shell/platform/linux/fl_view.cc @@ -726,7 +726,6 @@ static void fl_view_dispose(GObject* object) { g_clear_object(&self->project); g_clear_object(&self->renderer); g_clear_object(&self->engine); - g_clear_object(&self->scrolling_manager); g_clear_object(&self->keyboard_handler); if (self->keymap_keys_changed_cb_id != 0) { g_signal_handler_disconnect(self->keymap, self->keymap_keys_changed_cb_id); From fe911e63e20f0dca8a405184e78fd9ef60e074b7 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Fri, 19 Jul 2024 11:54:38 +1200 Subject: [PATCH 09/10] Update lsan suppression --- testing/lsan_suppressions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/lsan_suppressions.txt b/testing/lsan_suppressions.txt index 9a36fe57ecd68..25f507f67d610 100644 --- a/testing/lsan_suppressions.txt +++ b/testing/lsan_suppressions.txt @@ -51,7 +51,7 @@ leak:RefCountedTest_DebugChecks_Test::TestBody leak:*flutter/shell/platform/linux/testing/mock_engine.cc # TODO(bdero): Fix FL leaks: https://github.com/flutter/flutter/issues/90155 -leak:*flutter/shell/platform/linux/fl_keyboard_manager_test.cc* +leak:*flutter/shell/platform/linux/fl_keyboard_handler_test.cc* leak:*flutter/shell/platform/linux/fl_key_channel_responder_test.cc* leak:*flutter/shell/platform/linux/fl_basic_message_channel_test.cc* leak:fl_message_codec_decode_message From a3d0a24098390f99be219799b9d20eb5b4a6ff26 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Fri, 19 Jul 2024 11:55:53 +1200 Subject: [PATCH 10/10] Fix FlScrollingManager not being destroyed --- shell/platform/linux/fl_view.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/platform/linux/fl_view.cc b/shell/platform/linux/fl_view.cc index 8672fa76748d4..82ed9829c2ef7 100644 --- a/shell/platform/linux/fl_view.cc +++ b/shell/platform/linux/fl_view.cc @@ -726,6 +726,7 @@ static void fl_view_dispose(GObject* object) { g_clear_object(&self->project); g_clear_object(&self->renderer); g_clear_object(&self->engine); + g_clear_object(&self->scrolling_manager); g_clear_object(&self->keyboard_handler); if (self->keymap_keys_changed_cb_id != 0) { g_signal_handler_disconnect(self->keymap, self->keymap_keys_changed_cb_id);