#include "flutter/shell/platform/linux/fl_keyboard_handler.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/fl_keyboard_pending_event.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 | _FlKeyboardHandlerUserData |
struct | _FlKeyboardHandler |
Macros | |
#define | DEBUG_PRINT_LAYOUT |
#define | FL_TYPE_KEYBOARD_HANDLER_USER_DATA fl_keyboard_handler_user_data_get_type() |
Functions | |
G_DECLARE_FINAL_TYPE (FlKeyboardHandlerUserData, fl_keyboard_handler_user_data, FL, KEYBOARD_HANDLER_USER_DATA, GObject) | |
static uint64_t | get_logical_key_from_layout (FlKeyEvent *event, const DerivedLayout &layout) |
G_DEFINE_TYPE (FlKeyboardHandlerUserData, fl_keyboard_handler_user_data, G_TYPE_OBJECT) static void fl_keyboard_handler_user_data_dispose(GObject *object) | |
static void | fl_keyboard_handler_user_data_class_init (FlKeyboardHandlerUserDataClass *klass) |
static void | fl_keyboard_handler_user_data_init (FlKeyboardHandlerUserData *self) |
static FlKeyboardHandlerUserData * | fl_keyboard_handler_user_data_new (FlKeyboardHandler *handler, uint64_t sequence_id) |
G_DEFINE_TYPE (FlKeyboardHandler, fl_keyboard_handler, G_TYPE_OBJECT) | |
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 a, gconstpointer b) |
static gboolean | compare_pending_by_hash (gconstpointer a, gconstpointer b) |
static bool | fl_keyboard_handler_remove_redispatched (FlKeyboardHandler *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 (FlKeyboardHandler *self, FlKeyEvent *event) |
static FlMethodResponse * | get_keyboard_state (FlKeyboardHandler *self) |
static void | method_call_handler (FlMethodChannel *channel, FlMethodCall *method_call, gpointer user_data) |
static void | dispatch_to_responder (gpointer responder_data, gpointer foreach_data_ptr) |
static void | fl_keyboard_handler_dispose (GObject *object) |
static void | fl_keyboard_handler_class_init (FlKeyboardHandlerClass *klass) |
static void | fl_keyboard_handler_init (FlKeyboardHandler *self) |
FlKeyboardHandler * | fl_keyboard_handler_new (FlBinaryMessenger *messenger, FlKeyboardViewDelegate *view_delegate) |
gboolean | fl_keyboard_handler_handle_event (FlKeyboardHandler *self, FlKeyEvent *event) |
gboolean | fl_keyboard_handler_is_state_clear (FlKeyboardHandler *self) |
void | fl_keyboard_handler_sync_modifier_if_needed (FlKeyboardHandler *self, guint state, double event_time) |
GHashTable * | fl_keyboard_handler_get_pressed_state (FlKeyboardHandler *self) |
Variables | |
static constexpr char | kChannelName [] = "flutter/keyboard" |
static constexpr char | kGetKeyboardStateMethod [] = "getKeyboardState" |
#define DEBUG_PRINT_LAYOUT |
Definition at line 21 of file fl_keyboard_handler.cc.
#define FL_TYPE_KEYBOARD_HANDLER_USER_DATA fl_keyboard_handler_user_data_get_type() |
Definition at line 28 of file fl_keyboard_handler.cc.
|
static |
Definition at line 244 of file fl_keyboard_handler.cc.
References fl_keyboard_pending_event_get_hash().
Referenced by fl_keyboard_handler_remove_redispatched().
|
static |
Definition at line 235 of file fl_keyboard_handler.cc.
References fl_keyboard_pending_event_get_sequence_id().
Referenced by responder_handle_event_callback().
|
static |
Definition at line 309 of file fl_keyboard_handler.cc.
References fl_keyboard_view_delegate_lookup_key().
Referenced by guarantee_layout().
|
static |
Definition at line 439 of file fl_keyboard_handler.cc.
References fl_key_responder_handle_event(), and responder_handle_event_callback().
Referenced by fl_keyboard_handler_handle_event().
|
static |
Definition at line 473 of file fl_keyboard_handler.cc.
References fl_keyboard_handler_dispose().
|
static |
Definition at line 449 of file fl_keyboard_handler.cc.
References fl_keyboard_view_delegate_subscribe_to_layout_change(), and TRUE.
Referenced by fl_keyboard_handler_class_init().
GHashTable* fl_keyboard_handler_get_pressed_state | ( | FlKeyboardHandler * | handler | ) |
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.*
Definition at line 590 of file fl_keyboard_handler.cc.
References fl_key_embedder_responder_get_pressed_state().
Referenced by fl_view_get_keyboard_state().
gboolean fl_keyboard_handler_handle_event | ( | FlKeyboardHandler * | handler, |
FlKeyEvent * | event | ||
) |
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 #FlKeyboardHandler.
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.
Definition at line 541 of file fl_keyboard_handler.cc.
References dispatch_to_responder(), event, fl_key_event_hash(), fl_keyboard_handler_remove_redispatched(), fl_keyboard_handler_user_data_new(), fl_keyboard_pending_event_get_sequence_id(), 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_handler_is_state_clear | ( | FlKeyboardHandler * | handler | ) |
fl_keyboard_handler_is_state_clear: @handler: the #FlKeyboardHandler self.
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 handler's various states are cleared.
Definition at line 571 of file fl_keyboard_handler.cc.
FlKeyboardHandler* fl_keyboard_handler_new | ( | FlBinaryMessenger * | messenger, |
FlKeyboardViewDelegate * | view_delegate | ||
) |
FlKeyboardHandler:
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:
TextInputHandler
) and are handled synchronously.Create a new #FlKeyboardHandler.
Returns: a new #FlKeyboardHandler.
Definition at line 499 of file fl_keyboard_handler.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 255 of file fl_keyboard_handler.cc.
References compare_pending_by_hash(), g_ptr_array_find_with_equal_func1(), and TRUE.
Referenced by fl_keyboard_handler_handle_event().
void fl_keyboard_handler_sync_modifier_if_needed | ( | FlKeyboardHandler * | handler, |
guint | state, | ||
double | event_time | ||
) |
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.
Definition at line 577 of file fl_keyboard_handler.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 137 of file fl_keyboard_handler.cc.
|
static |
Definition at line 142 of file fl_keyboard_handler.cc.
|
static |
Definition at line 146 of file fl_keyboard_handler.cc.
Referenced by fl_keyboard_handler_handle_event().
G_DECLARE_FINAL_TYPE | ( | FlKeyboardHandlerUserData | , |
fl_keyboard_handler_user_data | , | ||
FL | , | ||
KEYBOARD_HANDLER_USER_DATA | , | ||
GObject | |||
) |
G_DEFINE_TYPE | ( | FlKeyboardHandler | , |
fl_keyboard_handler | , | ||
G_TYPE_OBJECT | |||
) |
G_DEFINE_TYPE | ( | FlKeyboardHandlerUserData | , |
fl_keyboard_handler_user_data | , | ||
G_TYPE_OBJECT | |||
) |
Definition at line 123 of file fl_keyboard_handler.cc.
|
static |
Definition at line 213 of file fl_keyboard_handler.cc.
Referenced by fl_keyboard_handler_remove_redispatched(), and responder_handle_event_callback().
|
static |
Definition at line 397 of file fl_keyboard_handler.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 92 of file fl_keyboard_handler.cc.
References event, fl_key_event_get_group(), and fl_key_event_get_keycode().
Referenced by fl_keyboard_handler_handle_event().
|
static |
Definition at line 321 of file fl_keyboard_handler.cc.
References convert_key_to_char(), event, fl_key_event_get_group(), fl_key_event_get_keycode(), LayoutGoal::keycode, layout_goals, and LayoutGoal::logical_key.
Referenced by fl_keyboard_handler_handle_event().
|
static |
Definition at line 418 of file fl_keyboard_handler.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_handler_new().
|
static |
Definition at line 271 of file fl_keyboard_handler.cc.
References compare_pending_by_sequence_id(), fl_keyboard_pending_event_get_any_handled(), fl_keyboard_pending_event_get_event(), fl_keyboard_pending_event_is_complete(), fl_keyboard_pending_event_mark_replied(), 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 23 of file fl_keyboard_handler.cc.
Referenced by fl_keyboard_handler_new().
|
staticconstexpr |
Definition at line 24 of file fl_keyboard_handler.cc.
Referenced by method_call_handler().