Renamed plugin classes to handler (flutter/engine#53736)

The Linux embedder had a number of handlers for Flutter channels that
were named plugin/handler/manager. Rename these all to handler to be
consistent and reduce confusion with Flutter plugins (which these don't
use the infrastructure for).
This commit is contained in:
Robert Ancell
2024-07-19 12:44:41 +12:00
committed by GitHub
parent f4bab93f77
commit 4a63063be6
35 changed files with 724 additions and 719 deletions

View File

@@ -44098,9 +44098,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
@@ -44115,14 +44115,14 @@ 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
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
@@ -44141,9 +44141,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
@@ -44157,9 +44157,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
@@ -47004,9 +47004,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
@@ -47021,14 +47021,14 @@ 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
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
@@ -47047,9 +47047,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
@@ -47063,9 +47063,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

View File

@@ -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,16 +112,16 @@ 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",
"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_platform_handler.cc",
"fl_plugin_registrar.cc",
"fl_plugin_registry.cc",
"fl_renderer.cc",
@@ -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",
@@ -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",
@@ -206,22 +206,22 @@ 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",
"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",
"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",
"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",
]

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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;
};
@@ -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.

View File

@@ -8,7 +8,7 @@
#include <gdk/gdk.h>
#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"

View File

@@ -9,7 +9,7 @@
#include <functional>
#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"

View File

@@ -8,7 +8,7 @@
#include <gdk/gdk.h>
#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"

View File

@@ -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

View File

@@ -14,8 +14,6 @@
G_BEGIN_DECLS
typedef struct _FlKeyboardManager FlKeyboardManager;
/**
* FlKeyResponderAsyncCallback:
* @event: whether the event has been handled.
@@ -40,7 +38,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 {

View File

@@ -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 <array>
#include <cinttypes>
@@ -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<guint8, DerivedGroupLayout> 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<gpointer*>(&(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<gpointer*>(&(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<gpointer*>(&(self->manager)));
g_object_add_weak_pointer(G_OBJECT(handler),
reinterpret_cast<gpointer*>(&(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<DerivedLayout> 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<std::map<uint16_t, const LayoutGoal*>> 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<std::map<uint64_t, const LayoutGoal*>>
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<DerivedLayout>();
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);

View File

@@ -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 <gdk/gdk.h>
@@ -11,17 +11,17 @@
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 `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,69 +30,69 @@ 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.
*/
/**
* 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_

View File

@@ -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 <cstring>
#include <vector>
@@ -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"
@@ -73,7 +73,7 @@ typedef std::function<void(const FlutterKeyEvent* event,
EmbedderCallHandler;
typedef std::function<void(std::unique_ptr<FlKeyEvent>)> 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<CallRecord> 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<GdkModifierType>(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<GdkModifierType>(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<CallRecord> call_records;
std::vector<std::unique_ptr<FlKeyEvent>> 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<GdkModifierType>(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<GdkModifierType>(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<GdkModifierType>(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<GdkModifierType>(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<CallRecord> call_records;
std::vector<std::unique_ptr<FlKeyEvent>> 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<GdkModifierType>(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<GdkModifierType>(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<CallRecord> call_records;
std::vector<std::unique_ptr<FlKeyEvent>> 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<GdkModifierType>(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<GdkModifierType>(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, TextInputPluginReturnsFalse) {
TEST(FlKeyboardHandlerTest, TextInputHandlerReturnsFalse) {
KeyboardTester tester;
std::vector<std::unique_ptr<FlKeyEvent>> 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<GdkModifierType>(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, TextInputPluginReturnsTrue) {
TEST(FlKeyboardHandlerTest, TextInputHandlerReturnsTrue) {
KeyboardTester tester;
std::vector<std::unique_ptr<FlKeyEvent>> 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<GdkModifierType>(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<CallRecord> 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<GdkModifierType>(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<GdkModifierType>(0), false, group));
};
@@ -990,7 +990,7 @@ TEST(FlKeyboardManagerTest, CorrectLogicalKeyForLayouts) {
VERIFY_DOWN(kLogicalBracketLeft, "[");
}
TEST(FlKeyboardManagerTest, SynthesizeModifiersIfNeeded) {
TEST(FlKeyboardHandlerTest, SynthesizeModifiersIfNeeded) {
KeyboardTester tester;
std::vector<CallRecord> 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<GdkModifierType>(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<flutter::testing::MockBinaryMessenger> 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(

View File

@@ -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

View File

@@ -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 <gtk/gtk.h>
#include <cstring>
@@ -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,22 @@ 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,
FlView* view) {
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 =

View File

@@ -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 <gdk/gdk.h>
#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_

View File

@@ -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 <gdk/gdk.h>
#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_

View File

@@ -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 <gtk/gtk.h>
#include <cstring>
@@ -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);
}

View File

@@ -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_

View File

@@ -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<flutter::testing::MockBinaryMessenger> 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<flutter::testing::MockBinaryMessenger> 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<flutter::testing::MockBinaryMessenger> 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;

View File

@@ -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 <gmodule.h>
@@ -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));

View File

@@ -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_

View File

@@ -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<GCancellable*>(), ::testing::A<GAsyncReadyCallback>(), \
::testing::A<gpointer>()))
TEST(FlSettingsPluginTest, AlwaysUse24HourFormat) {
TEST(FlSettingsHandlerTest, AlwaysUse24HourFormat) {
::testing::NiceMock<flutter::testing::MockSettings> settings;
::testing::NiceMock<flutter::testing::MockBinaryMessenger> 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<flutter::testing::MockSettings> settings;
::testing::NiceMock<flutter::testing::MockBinaryMessenger> 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<flutter::testing::MockSettings> settings;
::testing::NiceMock<flutter::testing::MockBinaryMessenger> 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<flutter::testing::MockSettings> 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<FlutterAccessibilityFeature>(
kFlutterAccessibilityFeatureDisableAnimations |

View File

@@ -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_

View File

@@ -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 <gtk/gtk.h>
@@ -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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
static void update_editing_state(FlTextInputHandler* self) {
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
static void perform_action(FlTextInputHandler* self) {
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
static void im_preedit_start_cb(FlTextInputHandler* self) {
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
static void im_preedit_changed_cb(FlTextInputHandler* self) {
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
static void im_commit_cb(FlTextInputHandler* self, const gchar* text) {
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
static void im_preedit_end_cb(FlTextInputHandler* self) {
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
static gboolean im_retrieve_surrounding_cb(FlTextInputHandler* self) {
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
static FlMethodResponse* hide(FlTextInputHandler* self) {
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
static FlMethodResponse* show(FlTextInputHandler* self) {
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
static FlMethodResponse* clear_client(FlTextInputHandler* self) {
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
static void update_im_cursor_position(FlTextInputHandler* self) {
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
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<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
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<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
static void init_im_context(FlTextInputHandler* self,
GtkIMContext* im_context) {
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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<FlTextInputPluginPrivate*>(
fl_text_input_plugin_get_instance_private(self));
FlTextInputHandlerPrivate* priv = static_cast<FlTextInputHandlerPrivate*>(
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;
}

View File

@@ -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 <gtk/gtk.h>
@@ -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_

View File

@@ -5,7 +5,7 @@
#include <utility>
#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<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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<GtkIMContext*>(context)));
@@ -249,14 +249,14 @@ TEST(FlTextInputPluginTest, Show) {
messenger.ReceiveMessage("flutter/textinput", message);
}
TEST(FlTextInputPluginTest, Hide) {
TEST(FlTextInputHandlerTest, Hide) {
::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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<GtkIMContext*>(context)));
@@ -274,14 +274,14 @@ TEST(FlTextInputPluginTest, Hide) {
messenger.ReceiveMessage("flutter/textinput", message);
}
TEST(FlTextInputPluginTest, ClearClient) {
TEST(FlTextInputHandlerTest, ClearClient) {
::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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<flutter::testing::MockBinaryMessenger> messenger;
::testing::NiceMock<flutter::testing::MockIMContext> context;
::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> 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({

View File

@@ -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`.

View File

@@ -15,16 +15,16 @@
#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_plugin.h"
#include "flutter/shell/platform/linux/fl_platform_plugin.h"
#include "flutter/shell/platform/linux/fl_mouse_cursor_handler.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"
#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"
@@ -50,12 +50,13 @@ 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;
FlTextInputPlugin* text_input_plugin;
FlMouseCursorPlugin* mouse_cursor_plugin;
FlPlatformPlugin* platform_plugin;
// Flutter system channel handlers.
FlKeyboardHandler* keyboard_handler;
FlTextInputHandler* text_input_handler;
FlMouseCursorHandler* mouse_cursor_handler;
FlPlatformHandler* platform_handler;
GtkWidget* event_box;
GtkGLArea* gl_area;
@@ -103,12 +104,12 @@ 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_handler);
// Stop the event from propagating.
return TRUE;
}
// Initialize keyboard manager.
// Initialize keyboard.
static void init_keyboard(FlView* self) {
FlBinaryMessenger* messenger = fl_engine_get_binary_messenger(self->engine);
@@ -118,12 +119,12 @@ 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 =
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,
@@ -305,7 +306,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) {
@@ -436,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,
@@ -561,8 +563,8 @@ 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->platform_plugin = fl_platform_plugin_new(messenger);
self->mouse_cursor_handler = fl_mouse_cursor_handler_new(messenger, self);
self->platform_handler = fl_platform_handler_new(messenger);
g_autoptr(GError) error = nullptr;
if (!fl_renderer_gdk_create_contexts(self->renderer, &error)) {
@@ -724,13 +726,14 @@ 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->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);
self->keymap_keys_changed_cb_id = 0;
}
g_clear_object(&self->mouse_cursor_plugin);
g_clear_object(&self->platform_plugin);
g_clear_object(&self->mouse_cursor_handler);
g_clear_object(&self->platform_handler);
g_clear_object(&self->view_accessible);
G_OBJECT_CLASS(fl_view_parent_class)->dispose(object);
@@ -740,8 +743,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<GdkEvent*>(event))));
}
@@ -749,8 +752,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<GdkEvent*>(event))));
}
@@ -851,5 +854,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);
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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 <gdk/gdk.h>
#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_

View File

@@ -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;
}

View File

@@ -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 <gdk/gdk.h>
#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_

View File

@@ -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