| Flutter Linux Embedder |

Macros | Typedefs | Functions | Variables
fl_key_embedder_responder.h File Reference
`#include <gdk/gdk.h>`
`#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/public/flutter_linux/fl_binary_messenger.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h"`

Go to the source code of this file.

## Macros
#define | FL_TYPE_KEY_EMBEDDER_RESPONDER fl_key_embedder_responder_get_type()

## Typedefs
typedef std::function< void(const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *user_data)> | EmbedderSendKeyEvent

## Functions
| G_DECLARE_FINAL_TYPE (FlKeyEmbedderResponder, fl_key_embedder_responder, FL, KEY_EMBEDDER_RESPONDER, GObject)
FlKeyEmbedderResponder * | fl_key_embedder_responder_new (EmbedderSendKeyEvent send_key_event)
void | fl_key_embedder_responder_sync_modifiers_if_needed (FlKeyEmbedderResponder *responder, guint state, double event_time)
GHashTable * | fl_key_embedder_responder_get_pressed_state (FlKeyEmbedderResponder *responder)

## Variables
constexpr int | kMaxConvertedKeyData = 3

## Macro Definition Documentation

## ◆ FL_TYPE_KEY_EMBEDDER_RESPONDER

#define FL_TYPE_KEY_EMBEDDER_RESPONDER fl_key_embedder_responder_get_type()

Definition at line 25 of file fl_key_embedder_responder.h.

## Typedef Documentation

## ◆ EmbedderSendKeyEvent

typedef std::function<void(const FlutterKeyEvent* event, FlutterKeyEventCallback callback, void* user_data)> EmbedderSendKeyEvent

Definition at line 21 of file fl_key_embedder_responder.h.

## Function Documentation

## ◆ fl_key_embedder_responder_get_pressed_state()

GHashTable* fl_key_embedder_responder_get_pressed_state | ( | FlKeyEmbedderResponder * | responder | ) |

fl_key_embedder_responder_get_pressed_state: @responder: the #FlKeyEmbedderResponder 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 889 of file fl_key_embedder_responder.cc.

890 {
891 return self->pressing_records;
892 }

Referenced by fl_keyboard_manager_get_pressed_state().

## ◆ fl_key_embedder_responder_new()

FlKeyEmbedderResponder* fl_key_embedder_responder_new | ( | EmbedderSendKeyEvent | send_key_event | ) |

FlKeyEmbedderResponder:

A #FlKeyResponder that handles events by sending the converted events through the embedder API.

This class communicates with the HardwareKeyboard API in the framework. fl_key_embedder_responder_new: @engine: The #FlEngine, whose the embedder API will be used to send the event.

Creates a new #FlKeyEmbedderResponder.

Returns: a new #FlKeyEmbedderResponder.

Definition at line 262 of file fl_key_embedder_responder.cc.

263 {
264 FlKeyEmbedderResponder* self = FL_KEY_EMBEDDER_RESPONDER(
265 g_object_new(FL_TYPE_EMBEDDER_RESPONDER_USER_DATA, nullptr));
266
267 self->send_key_event = std::move(send_key_event);
268
269 self->pressing_records = g_hash_table_new(g_direct_hash, g_direct_equal);
270 self->mapping_records = g_hash_table_new(g_direct_hash, g_direct_equal);
271 self->lock_records = 0;
272 self->caps_lock_state_logic_inferrence = kStateLogicUndecided;
273
274 self->modifier_bit_to_checked_keys =
275 g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
276 initialize_modifier_bit_to_checked_keys(self->modifier_bit_to_checked_keys);
277
278 self->lock_bit_to_checked_keys =
279 g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
280 initialize_lock_bit_to_checked_keys(self->lock_bit_to_checked_keys);
281
282 self->logical_key_to_lock_bit =
283 g_hash_table_new(g_direct_hash, g_direct_equal);
284 g_hash_table_foreach(self->lock_bit_to_checked_keys,
285 initialize_logical_key_to_lock_bit_loop_body,
286 self->logical_key_to_lock_bit);
287
288 return self;
289 }

References FL_TYPE_EMBEDDER_RESPONDER_USER_DATA, initialize_lock_bit_to_checked_keys(), initialize_logical_key_to_lock_bit_loop_body(), initialize_modifier_bit_to_checked_keys(), self, and send_key_event().

Referenced by fl_keyboard_manager_new(), and TEST().

## ◆ fl_key_embedder_responder_sync_modifiers_if_needed()

void fl_key_embedder_responder_sync_modifiers_if_needed | ( | FlKeyEmbedderResponder * | responder,
|  | guint | state,
|  | double | event_time
| ) |  |

fl_key_embedder_responder_sync_modifiers_if_needed: @responder: the #FlKeyEmbedderResponder 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 872 of file fl_key_embedder_responder.cc.

875 {
876 const double timestamp = event_time * kMicrosecondsPerMillisecond;
877
878 SyncStateLoopContext sync_state_context;
879 sync_state_context.self = responder;
880 sync_state_context.state = state;
881 sync_state_context.timestamp = timestamp;
882
883 // Update pressing states.
884 g_hash_table_foreach(responder->modifier_bit_to_checked_keys,
885 synchronize_pressed_states_loop_body,
886 &sync_state_context);
887 }

References kMicrosecondsPerMillisecond, state, and synchronize_pressed_states_loop_body().

Referenced by fl_keyboard_manager_sync_modifier_if_needed().

## ◆ G_DECLARE_FINAL_TYPE()

G_DECLARE_FINAL_TYPE | ( | FlKeyEmbedderResponder | ,
|  | fl_key_embedder_responder | ,
|  | FL | ,
|  | KEY_EMBEDDER_RESPONDER | ,
|  | GObject |
| ) |  |

## Variable Documentation

## ◆ kMaxConvertedKeyData

constexpr int kMaxConvertedKeyData = 3
| constexpr

Definition at line 16 of file fl_key_embedder_responder.h.

FL_TYPE_EMBEDDER_RESPONDER_USER_DATA
#define FL_TYPE_EMBEDDER_RESPONDER_USER_DATA
Definition: fl_key_embedder_responder.cc:203
synchronize_pressed_states_loop_body
static void synchronize_pressed_states_loop_body(gpointer key, gpointer value, gpointer user_data)
Definition: fl_key_embedder_responder.cc:439
state
AtkStateType state
Definition: fl_accessible_node.cc:10
initialize_modifier_bit_to_checked_keys
void initialize_modifier_bit_to_checked_keys(GHashTable *table)
Definition: key_mapping.g.cc:414
initialize_lock_bit_to_checked_keys
void initialize_lock_bit_to_checked_keys(GHashTable *table)
Definition: key_mapping.g.cc:446
self
GdkEvent FlView * self
Definition: fl_view.cc:100
kMicrosecondsPerMillisecond
constexpr uint64_t kMicrosecondsPerMillisecond
Definition: fl_key_embedder_responder.cc:14
send_key_event
static void send_key_event(FlTextInputPlugin *plugin, gint keyval, gint state=0)
Definition: fl_text_input_plugin_test.cc:181
initialize_logical_key_to_lock_bit_loop_body
static void initialize_logical_key_to_lock_bit_loop_body(gpointer lock_bit, gpointer value, gpointer user_data)
Definition: fl_key_embedder_responder.cc:250