#include "flutter/shell/platform/linux/fl_keyboard_manager.h"
#include <array>
#include <cinttypes>
#include <memory>
#include <string>
#include "flutter/shell/platform/linux/fl_key_channel_responder.h"
#include "flutter/shell/platform/linux/fl_key_embedder_responder.h"
#include "flutter/shell/platform/linux/key_mapping.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_method_channel.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_method_codec.h"
Go to the source code of this file.
Classes | |
struct | _FlKeyboardPendingEvent |
struct | _FlKeyboardManagerUserData |
struct | _FlKeyboardManager |
Macros | |
#define | DEBUG_PRINT_LAYOUT |
#define | FL_TYPE_KEYBOARD_MANAGER_USER_DATA fl_keyboard_manager_user_data_get_type() |
Functions | |
G_DECLARE_FINAL_TYPE (FlKeyboardPendingEvent, fl_keyboard_pending_event, FL, KEYBOARD_PENDING_EVENT, GObject) | |
G_DECLARE_FINAL_TYPE (FlKeyboardManagerUserData, fl_keyboard_manager_user_data, FL, KEYBOARD_MANAGER_USER_DATA, GObject) | |
static uint64_t | get_logical_key_from_layout (const FlKeyEvent *event, const DerivedLayout &layout) |
static void | fl_keyboard_pending_event_dispose (GObject *object) |
static void | fl_keyboard_pending_event_class_init (FlKeyboardPendingEventClass *klass) |
static void | fl_keyboard_pending_event_init (FlKeyboardPendingEvent *self) |
static uint64_t | fl_keyboard_manager_get_event_hash (FlKeyEvent *event) |
static FlKeyboardPendingEvent * | fl_keyboard_pending_event_new (std::unique_ptr< FlKeyEvent > event, uint64_t sequence_id, size_t to_reply) |
G_DEFINE_TYPE (FlKeyboardManagerUserData, fl_keyboard_manager_user_data, G_TYPE_OBJECT) static void fl_keyboard_manager_user_data_dispose(GObject *object) | |
static void | fl_keyboard_manager_user_data_class_init (FlKeyboardManagerUserDataClass *klass) |
static void | fl_keyboard_manager_user_data_init (FlKeyboardManagerUserData *self) |
static FlKeyboardManagerUserData * | fl_keyboard_manager_user_data_new (FlKeyboardManager *manager, uint64_t sequence_id) |
G_DEFINE_TYPE (FlKeyboardManager, fl_keyboard_manager, G_TYPE_OBJECT) | |
static void | fl_keyboard_manager_dispose (GObject *object) |
static void | fl_keyboard_manager_class_init (FlKeyboardManagerClass *klass) |
static void | fl_keyboard_manager_init (FlKeyboardManager *self) |
static gboolean | g_ptr_array_find_with_equal_func1 (GPtrArray *haystack, gconstpointer needle, GEqualFunc equal_func, guint *index_) |
static gboolean | compare_pending_by_sequence_id (gconstpointer pending, gconstpointer needle_sequence_id) |
static gboolean | compare_pending_by_hash (gconstpointer pending, gconstpointer needle_hash) |
static bool | fl_keyboard_manager_remove_redispatched (FlKeyboardManager *self, uint64_t hash) |
static void | responder_handle_event_callback (bool handled, gpointer user_data_ptr) |
static uint16_t | convert_key_to_char (FlKeyboardViewDelegate *view_delegate, guint keycode, gint group, gint level) |
static void | guarantee_layout (FlKeyboardManager *self, FlKeyEvent *event) |
FlMethodResponse * | get_keyboard_state (FlKeyboardManager *self) |
static void | method_call_handler (FlMethodChannel *channel, FlMethodCall *method_call, gpointer user_data) |
FlKeyboardManager * | fl_keyboard_manager_new (FlBinaryMessenger *messenger, FlKeyboardViewDelegate *view_delegate) |
static void | dispatch_to_responder (gpointer responder_data, gpointer foreach_data_ptr) |
gboolean | fl_keyboard_manager_handle_event (FlKeyboardManager *self, FlKeyEvent *event) |
gboolean | fl_keyboard_manager_is_state_clear (FlKeyboardManager *self) |
void | fl_keyboard_manager_sync_modifier_if_needed (FlKeyboardManager *self, guint state, double event_time) |
GHashTable * | fl_keyboard_manager_get_pressed_state (FlKeyboardManager *self) |
Variables | |
static constexpr char | kChannelName [] = "flutter/keyboard" |
static constexpr char | kGetKeyboardStateMethod [] = "getKeyboardState" |
#define DEBUG_PRINT_LAYOUT |
Definition at line 20 of file fl_keyboard_manager.cc.
#define FL_TYPE_KEYBOARD_MANAGER_USER_DATA fl_keyboard_manager_user_data_get_type() |
Definition at line 33 of file fl_keyboard_manager.cc.
|
static |
Definition at line 392 of file fl_keyboard_manager.cc.
Referenced by fl_keyboard_manager_remove_redispatched().
|
static |
Definition at line 382 of file fl_keyboard_manager.cc.
Referenced by responder_handle_event_callback().
|
static |
Definition at line 456 of file fl_keyboard_manager.cc.
References fl_keyboard_view_delegate_lookup_key().
Referenced by guarantee_layout().
|
static |
Definition at line 628 of file fl_keyboard_manager.cc.
References fl_key_responder_handle_event(), and responder_handle_event_callback().
Referenced by fl_keyboard_manager_handle_event().
|
static |
Definition at line 304 of file fl_keyboard_manager.cc.
References fl_keyboard_manager_dispose().
|
static |
Definition at line 330 of file fl_keyboard_manager.cc.
References fl_keyboard_view_delegate_subscribe_to_layout_change(), and TRUE.
Referenced by fl_keyboard_manager_class_init().
|
static |
Definition at line 168 of file fl_keyboard_manager.cc.
References event, _FlKeyEvent::time, and type.
Referenced by fl_keyboard_manager_handle_event(), and fl_keyboard_pending_event_new().
GHashTable* fl_keyboard_manager_get_pressed_state | ( | FlKeyboardManager * | manager | ) |
fl_keyboard_manager_get_pressed_state: @manager: the FlKeyboardManager self.
Returns the keyboard pressed state. The hash table contains one entry per pressed keys, mapping from the logical key to the physical key.*
Definition at line 688 of file fl_keyboard_manager.cc.
References fl_key_embedder_responder_get_pressed_state().
Referenced by fl_view_get_keyboard_state().
gboolean fl_keyboard_manager_handle_event | ( | FlKeyboardManager * | manager, |
FlKeyEvent * | event | ||
) |
fl_keyboard_manager_handle_event: @manager: the FlKeyboardManager self. @event: the event to be dispatched. It is usually a wrap of a GdkEventKey. This event will be managed and released by FlKeyboardManager.
Make the manager 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.
Definition at line 638 of file fl_keyboard_manager.cc.
References dispatch_to_responder(), event, fl_keyboard_manager_get_event_hash(), fl_keyboard_manager_remove_redispatched(), fl_keyboard_manager_user_data_new(), fl_keyboard_pending_event_new(), get_logical_key_from_layout(), guarantee_layout(), TRUE, and user_data.
Referenced by fl_view_key_press_event(), and fl_view_key_release_event().
|
static |
gboolean fl_keyboard_manager_is_state_clear | ( | FlKeyboardManager * | manager | ) |
fl_keyboard_manager_is_state_clear: @manager: the FlKeyboardManager self.
A debug-only method that queries whether the manager'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.
Definition at line 669 of file fl_keyboard_manager.cc.
FlKeyboardManager* fl_keyboard_manager_new | ( | FlBinaryMessenger * | messenger, |
FlKeyboardViewDelegate * | view_delegate | ||
) |
FlKeyboardManager:
Processes keyboard events and cooperate with TextInputPlugin
.
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:
TextInputPlugin
) and are handled synchronously.Create a new FlKeyboardManager.
Returns: a new FlKeyboardManager.
Definition at line 585 of file fl_keyboard_manager.cc.
References callback, event, fl_key_channel_responder_new(), fl_key_embedder_responder_new(), fl_keyboard_view_delegate_get_messenger(), fl_keyboard_view_delegate_send_key_event(), fl_keyboard_view_delegate_subscribe_to_layout_change(), fl_method_channel_new(), fl_method_channel_set_method_call_handler(), fl_standard_method_codec_new(), kChannelName, and method_call_handler().
Referenced by init_keyboard().
|
static |
Definition at line 402 of file fl_keyboard_manager.cc.
References compare_pending_by_hash(), g_ptr_array_find_with_equal_func1(), and TRUE.
Referenced by fl_keyboard_manager_handle_event().
void fl_keyboard_manager_sync_modifier_if_needed | ( | FlKeyboardManager * | manager, |
guint | state, | ||
double | event_time | ||
) |
fl_keyboard_manager_sync_modifier_if_needed: @manager: the FlKeyboardManager 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.
Definition at line 675 of file fl_keyboard_manager.cc.
References fl_key_embedder_responder_sync_modifiers_if_needed(), and state.
Referenced by motion_notify_event_cb(), and send_pointer_button_event().
|
static |
Definition at line 229 of file fl_keyboard_manager.cc.
|
static |
Definition at line 234 of file fl_keyboard_manager.cc.
|
static |
Definition at line 238 of file fl_keyboard_manager.cc.
Referenced by fl_keyboard_manager_handle_event().
|
static |
Definition at line 159 of file fl_keyboard_manager.cc.
References fl_keyboard_pending_event_dispose().
|
static |
Definition at line 147 of file fl_keyboard_manager.cc.
References fl_key_event_dispose().
Referenced by fl_keyboard_pending_event_class_init().
|
static |
Definition at line 164 of file fl_keyboard_manager.cc.
|
static |
Definition at line 184 of file fl_keyboard_manager.cc.
References event, and fl_keyboard_manager_get_event_hash().
Referenced by fl_keyboard_manager_handle_event().
G_DECLARE_FINAL_TYPE | ( | FlKeyboardManagerUserData | , |
fl_keyboard_manager_user_data | , | ||
FL | , | ||
KEYBOARD_MANAGER_USER_DATA | , | ||
GObject | |||
) |
G_DECLARE_FINAL_TYPE | ( | FlKeyboardPendingEvent | , |
fl_keyboard_pending_event | , | ||
FL | , | ||
KEYBOARD_PENDING_EVENT | , | ||
GObject | |||
) |
G_DEFINE_TYPE | ( | FlKeyboardManager | , |
fl_keyboard_manager | , | ||
G_TYPE_OBJECT | |||
) |
G_DEFINE_TYPE | ( | FlKeyboardManagerUserData | , |
fl_keyboard_manager_user_data | , | ||
G_TYPE_OBJECT | |||
) |
Definition at line 215 of file fl_keyboard_manager.cc.
|
static |
Definition at line 359 of file fl_keyboard_manager.cc.
Referenced by fl_keyboard_manager_remove_redispatched(), and responder_handle_event_callback().
FlMethodResponse* get_keyboard_state | ( | FlKeyboardManager * | self | ) |
Definition at line 544 of file fl_keyboard_manager.cc.
References fl_keyboard_view_delegate_get_keyboard_state(), fl_method_success_response_new(), fl_value_new_int(), fl_value_new_map(), fl_value_set_take(), result, user_data, and value.
Referenced by method_call_handler().
|
static |
Definition at line 97 of file fl_keyboard_manager.cc.
Referenced by fl_keyboard_manager_handle_event().
|
static |
Definition at line 468 of file fl_keyboard_manager.cc.
References convert_key_to_char(), event, _FlKeyEvent::keycode, LayoutGoal::keycode, layout_goals, and LayoutGoal::logical_key.
Referenced by fl_keyboard_manager_handle_event().
|
static |
Definition at line 565 of file fl_keyboard_manager.cc.
References error, fl_method_call_get_name(), fl_method_call_respond(), fl_method_not_implemented_response_new(), get_keyboard_state(), kGetKeyboardStateMethod, method_call, and user_data.
Referenced by fl_keyboard_manager_new().
|
static |
Definition at line 418 of file fl_keyboard_manager.cc.
References compare_pending_by_sequence_id(), fl_keyboard_view_delegate_redispatch_event(), fl_keyboard_view_delegate_text_filter_key_press(), g_ptr_array_find_with_equal_func1(), and user_data.
Referenced by dispatch_to_responder().
|
staticconstexpr |
Definition at line 22 of file fl_keyboard_manager.cc.
Referenced by fl_keyboard_manager_new().
|
staticconstexpr |
Definition at line 23 of file fl_keyboard_manager.cc.
Referenced by method_call_handler().