| Flutter Linux Embedder |

Classes | Macros | Functions | Variables
fl_key_embedder_responder.cc File Reference
`#include "flutter/shell/platform/linux/fl_key_embedder_responder.h"`
`#include <gtk/gtk.h>`
`#include <cinttypes>`
`#include "flutter/shell/platform/embedder/embedder.h"`
`#include "flutter/shell/platform/linux/fl_key_embedder_responder_private.h"`
`#include "flutter/shell/platform/linux/key_mapping.h"`

Go to the source code of this file.

## Classes
struct | _FlKeyEmbedderUserData
struct | _FlKeyEmbedderResponder

## Macros
#define | FL_TYPE_EMBEDDER_USER_DATA fl_key_embedder_user_data_get_type()
#define | FL_TYPE_EMBEDDER_RESPONDER_USER_DATA fl_key_embedder_responder_get_type()

## Functions
static uint64_t | lookup_hash_table (GHashTable *table, uint64_t key)
static gboolean | hash_table_find_equal_value (gpointer key, gpointer value, gpointer user_data)
static uint64_t | reverse_lookup_hash_table (GHashTable *table, uint64_t value)
static uint64_t | to_lower (uint64_t n)
| G_DECLARE_FINAL_TYPE (FlKeyEmbedderUserData, fl_key_embedder_user_data, FL, KEY_EMBEDDER_USER_DATA, GObject)
static void | fl_key_embedder_user_data_dispose (GObject *object)
static void | fl_key_embedder_user_data_class_init (FlKeyEmbedderUserDataClass *klass)
static void | fl_key_embedder_user_data_init (FlKeyEmbedderUserData *self)
static FlKeyEmbedderUserData * | fl_key_embedder_user_data_new (FlKeyResponderAsyncCallback callback, gpointer user_data)
static void | fl_key_embedder_responder_iface_init (FlKeyResponderInterface *iface)
static void | fl_key_embedder_responder_dispose (GObject *object)
| G_DEFINE_TYPE_WITH_CODE (FlKeyEmbedderResponder, fl_key_embedder_responder, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(FL_TYPE_KEY_RESPONDER, fl_key_embedder_responder_iface_init)) static void fl_key_embedder_responder_handle_event(FlKeyResponder *responder
static void | fl_key_embedder_responder_class_init (FlKeyEmbedderResponderClass *klass)
static void | fl_key_embedder_responder_init (FlKeyEmbedderResponder *self)
static void | initialize_logical_key_to_lock_bit_loop_body (gpointer lock_bit, gpointer value, gpointer user_data)
FlKeyEmbedderResponder * | fl_key_embedder_responder_new (EmbedderSendKeyEvent send_key_event, void *send_key_event_user_data)
static uint64_t | apply_id_plane (uint64_t logical_id, uint64_t plane)
static uint64_t | event_to_physical_key (FlKeyEvent *event)
static uint64_t | event_to_logical_key (FlKeyEvent *event)
static uint64_t | event_to_timestamp (FlKeyEvent *event)
static char * | event_to_character (FlKeyEvent *event)
static void | handle_response (bool handled, gpointer user_data)
static void | synthesize_simple_event (FlKeyEmbedderResponder *self, FlutterKeyEventType type, uint64_t physical, uint64_t logical, double timestamp)
static void | update_pressing_state (FlKeyEmbedderResponder *self, uint64_t physical_key, uint64_t logical_key)
static void | possibly_update_lock_bit (FlKeyEmbedderResponder *self, uint64_t logical_key, bool is_down)
static void | update_mapping_record (FlKeyEmbedderResponder *self, uint64_t physical_key, uint64_t logical_key)
static void | synchronize_pressed_states_loop_body (gpointer key, gpointer value, gpointer user_data)
static int | find_stage_by_record (bool is_down, bool is_enabled)
static int | find_stage_by_self_event (int stage_by_record, bool is_down_event, bool is_state_on, bool reverse_state_logic)
static int | find_stage_by_others_event (int stage_by_record, bool is_state_on)
static void | update_caps_lock_state_logic_inferrence (FlKeyEmbedderResponder *self, bool is_down_event, bool enabled_by_state, int stage_by_record)
static void | synchronize_lock_states_loop_body (gpointer key, gpointer value, gpointer user_data)
static void | is_known_modifier_physical_key_loop_body (gpointer key, gpointer value, gpointer user_data)
static void | find_physical_from_logical_loop_body (gpointer key, gpointer value, gpointer user_data)
static uint64_t | corrected_modifier_physical_key (GHashTable *modifier_bit_to_checked_keys, uint64_t physical_key_from_event, uint64_t logical_key)
static void | fl_key_embedder_responder_handle_event_impl (FlKeyResponder *responder, FlKeyEvent *event, uint64_t specified_logical_key, FlKeyResponderAsyncCallback callback, gpointer user_data)
static void | fl_key_embedder_responder_handle_event (FlKeyResponder *responder, FlKeyEvent *event, uint64_t specified_logical_key, FlKeyResponderAsyncCallback callback, gpointer user_data)
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 *self)

## Variables
constexpr uint64_t | kMicrosecondsPerMillisecond = 1000
static const FlutterKeyEvent | kEmptyEvent
FlKeyEvent * | event
FlKeyEvent uint64_t | specified_logical_key
FlKeyEvent uint64_t FlKeyResponderAsyncCallback | callback
FlKeyEvent uint64_t FlKeyResponderAsyncCallback gpointer | user_data

## Macro Definition Documentation

## ◆ FL_TYPE_EMBEDDER_RESPONDER_USER_DATA

#define FL_TYPE_EMBEDDER_RESPONDER_USER_DATA fl_key_embedder_responder_get_type()

Definition at line 204 of file fl_key_embedder_responder.cc.

## ◆ FL_TYPE_EMBEDDER_USER_DATA

#define FL_TYPE_EMBEDDER_USER_DATA fl_key_embedder_user_data_get_type()

FlKeyEmbedderUserData: The user_data used when #FlKeyEmbedderResponder sends message through the embedder.SendKeyEvent API.

Definition at line 83 of file fl_key_embedder_responder.cc.

## Function Documentation

## ◆ apply_id_plane()

static uint64_t apply_id_plane | ( | uint64_t | logical_id,
|  | uint64_t | plane
| ) |  |
| static

Definition at line 296 of file fl_key_embedder_responder.cc.

296 {
297 return (logical_id & kValueMask) | plane;
298 }

References kValueMask.

Referenced by event_to_logical_key(), and event_to_physical_key().

## ◆ corrected_modifier_physical_key()

static uint64_t corrected_modifier_physical_key | ( | GHashTable * | modifier_bit_to_checked_keys,
|  | uint64_t | physical_key_from_event,
|  | uint64_t | logical_key
| ) |  |
| static

Definition at line 748 of file fl_key_embedder_responder.cc.

751 {
752 ModifierLogicalToPhysicalContext logical_to_physical_context;
753 logical_to_physical_context.known_modifier_physical_key = false;
754 logical_to_physical_context.physical_key_from_event = physical_key_from_event;
755 logical_to_physical_context.logical_key = logical_key;
756 // If no match is found, defaults to the physical key retrieved from the
757 // event.
758 logical_to_physical_context.corrected_physical_key = physical_key_from_event;
759
760 // Check if the physical key is one of the known modifier physical key.
761 g_hash_table_foreach(modifier_bit_to_checked_keys,
762 is_known_modifier_physical_key_loop_body,
763 &logical_to_physical_context);
764
765 // If the physical key matches a known modifier key, find the modifier
766 // physical key from the logical key.
767 if (logical_to_physical_context.known_modifier_physical_key) {
768 g_hash_table_foreach(modifier_bit_to_checked_keys,
769 find_physical_from_logical_loop_body,
770 &logical_to_physical_context);
771 }
772
773 return logical_to_physical_context.corrected_physical_key;
774 }

References find_physical_from_logical_loop_body(), and is_known_modifier_physical_key_loop_body().

Referenced by fl_key_embedder_responder_handle_event_impl().

## ◆ event_to_character()

static char* event_to_character | ( | FlKeyEvent * | event | ) |
| static

Definition at line 329 of file fl_key_embedder_responder.cc.

329 {
330 gunichar unicodeChar = gdk_keyval_to_unicode(fl_key_event_get_keyval(event));
331 glong items_written;
332 gchar* result = g_ucs4_to_utf8(&unicodeChar, 1, NULL, &items_written, NULL);
333 if (items_written == 0) {
334 if (result != NULL) {
335 g_free(result);
336 }
337 return nullptr;
338 }
339 return result;
340 }

References event, fl_key_event_get_keyval(), and result.

Referenced by fl_key_embedder_responder_handle_event_impl().

## ◆ event_to_logical_key()

static uint64_t event_to_logical_key | ( | FlKeyEvent * | event | ) |
| static

Definition at line 308 of file fl_key_embedder_responder.cc.

308 {
309 guint keyval = fl_key_event_get_keyval(event);
310 auto found = gtk_keyval_to_logical_key_map.find(keyval);
311 if (found != gtk_keyval_to_logical_key_map.end()) {
312 return found->second;
313 }
314 // EASCII range
315 if (keyval < 256) {
316 return apply_id_plane(to_lower(keyval), kUnicodePlane);
317 }
318 // Auto-generate key
319 return apply_id_plane(keyval, kGtkPlane);
320 }

References apply_id_plane(), event, fl_key_event_get_keyval(), gtk_keyval_to_logical_key_map, kGtkPlane, kUnicodePlane, and to_lower().

Referenced by fl_key_embedder_responder_handle_event_impl().

## ◆ event_to_physical_key()

static uint64_t event_to_physical_key | ( | FlKeyEvent * | event | ) |
| static

Definition at line 300 of file fl_key_embedder_responder.cc.

300 {
301 auto found = xkb_to_physical_key_map.find(fl_key_event_get_keycode(event));
302 if (found != xkb_to_physical_key_map.end()) {
303 return found->second;
304 }
305 return apply_id_plane(fl_key_event_get_keycode(event), kGtkPlane);
306 }

References apply_id_plane(), event, fl_key_event_get_keycode(), kGtkPlane, and xkb_to_physical_key_map.

Referenced by fl_key_embedder_responder_handle_event_impl().

## ◆ event_to_timestamp()

static uint64_t event_to_timestamp | ( | FlKeyEvent * | event | ) |
| static

Definition at line 322 of file fl_key_embedder_responder.cc.

322 {
323 return kMicrosecondsPerMillisecond *
324 static_cast<double>(fl_key_event_get_time(event));
325 }

References event, fl_key_event_get_time(), and kMicrosecondsPerMillisecond.

Referenced by fl_key_embedder_responder_handle_event_impl().

## ◆ find_physical_from_logical_loop_body()

static void find_physical_from_logical_loop_body | ( | gpointer | key,
|  | gpointer | value,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 734 of file fl_key_embedder_responder.cc.

736 {
737 ModifierLogicalToPhysicalContext* context =
738 reinterpret_cast<ModifierLogicalToPhysicalContext*>(user_data);
739 FlKeyEmbedderCheckedKey* checked_key =
740 reinterpret_cast<FlKeyEmbedderCheckedKey*>(value);
741
742 if (checked_key->primary_logical_key == context->logical_key ||
743 checked_key->secondary_logical_key == context->logical_key) {
744 context->corrected_physical_key = checked_key->primary_physical_key;
745 }
746 }

References FlKeyEmbedderCheckedKey::primary_logical_key, FlKeyEmbedderCheckedKey::primary_physical_key, FlKeyEmbedderCheckedKey::secondary_logical_key, user_data, and value.

Referenced by corrected_modifier_physical_key().

## ◆ find_stage_by_others_event()

static int find_stage_by_others_event | ( | int | stage_by_record,
|  | bool | is_state_on
| ) |  |
| static

Definition at line 556 of file fl_key_embedder_responder.cc.

556 {
557 g_return_val_if_fail(stage_by_record >= 0 && stage_by_record < 4,
558 stage_by_record);
559 if (!is_state_on) {
560 return 0;
561 }
562 if (stage_by_record == 0) {
563 return 1;
564 }
565 return stage_by_record;
566 }

Referenced by synchronize_lock_states_loop_body().

## ◆ find_stage_by_record()

static int find_stage_by_record | ( | bool | is_down,
|  | bool | is_enabled
| ) |  |
| static

Definition at line 529 of file fl_key_embedder_responder.cc.

529 {
530 constexpr int stage_by_record_index[] = {
531 0, // is_down: 0, is_enabled: 0
532 2, // 0 1
533 3, // 1 0
534 1 // 1 1
535 };
536 return stage_by_record_index[(is_down << 1) + is_enabled];
537 }

Referenced by synchronize_lock_states_loop_body().

## ◆ find_stage_by_self_event()

static int find_stage_by_self_event | ( | int | stage_by_record,
|  | bool | is_down_event,
|  | bool | is_state_on,
|  | bool | reverse_state_logic
| ) |  |
| static

Definition at line 541 of file fl_key_embedder_responder.cc.

544 {
545 if (!is_state_on) {
546 return reverse_state_logic ? 2 : 0;
547 }
548 if (is_down_event) {
549 return reverse_state_logic ? 0 : 2;
550 }
551 return stage_by_record;
552 }

Referenced by synchronize_lock_states_loop_body(), and update_caps_lock_state_logic_inferrence().

## ◆ fl_key_embedder_responder_class_init()

static void fl_key_embedder_responder_class_init | ( | FlKeyEmbedderResponderClass * | klass | ) |
| static

Definition at line 226 of file fl_key_embedder_responder.cc.

227 {
228 G_OBJECT_CLASS(klass)->dispose = fl_key_embedder_responder_dispose;
229 }

References fl_key_embedder_responder_dispose().

## ◆ fl_key_embedder_responder_dispose()

static void fl_key_embedder_responder_dispose | ( | GObject * | object | ) |
| static

Definition at line 235 of file fl_key_embedder_responder.cc.

235 {
236 FlKeyEmbedderResponder* self = FL_KEY_EMBEDDER_RESPONDER(object);
237
238 g_clear_pointer(&self->pressing_records, g_hash_table_unref);
239 g_clear_pointer(&self->mapping_records, g_hash_table_unref);
240 g_clear_pointer(&self->modifier_bit_to_checked_keys, g_hash_table_unref);
241 g_clear_pointer(&self->lock_bit_to_checked_keys, g_hash_table_unref);
242 g_clear_pointer(&self->logical_key_to_lock_bit, g_hash_table_unref);
243
244 G_OBJECT_CLASS(fl_key_embedder_responder_parent_class)->dispose(object);
245 }

Referenced by fl_key_embedder_responder_class_init().

## ◆ 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 896 of file fl_key_embedder_responder.cc.

897 {
898 return self->pressing_records;
899 }

Referenced by fl_keyboard_handler_get_pressed_state().

## ◆ fl_key_embedder_responder_handle_event()

static void fl_key_embedder_responder_handle_event | ( | FlKeyResponder * | responder,
|  | FlKeyEvent * | event,
|  | uint64_t | specified_logical_key,
|  | FlKeyResponderAsyncCallback | callback,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 863 of file fl_key_embedder_responder.cc.

868 {
869 FlKeyEmbedderResponder* self = FL_KEY_EMBEDDER_RESPONDER(responder);
870 self->sent_any_events = false;
871 fl_key_embedder_responder_handle_event_impl(
872 responder, event, specified_logical_key, callback, user_data);
873 if (!self->sent_any_events) {
874 self->send_key_event(&kEmptyEvent, nullptr, nullptr,
875 self->send_key_event_user_data);
876 }
877 }

References callback, event, fl_key_embedder_responder_handle_event_impl(), kEmptyEvent, specified_logical_key, and user_data.

Referenced by fl_key_embedder_responder_iface_init().

## ◆ fl_key_embedder_responder_handle_event_impl()

static void fl_key_embedder_responder_handle_event_impl | ( | FlKeyResponder * | responder,
|  | FlKeyEvent * | event,
|  | uint64_t | specified_logical_key,
|  | FlKeyResponderAsyncCallback | callback,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 776 of file fl_key_embedder_responder.cc.

781 {
782 FlKeyEmbedderResponder* self = FL_KEY_EMBEDDER_RESPONDER(responder);
783
784 g_return_if_fail(event != nullptr);
785 g_return_if_fail(callback != nullptr);
786
787 const uint64_t logical_key = specified_logical_key != 0
788 ? specified_logical_key
789 : event_to_logical_key(event);
790 const uint64_t physical_key_from_event = event_to_physical_key(event);
791 const uint64_t physical_key = corrected_modifier_physical_key(
792 self->modifier_bit_to_checked_keys, physical_key_from_event, logical_key);
793 const double timestamp = event_to_timestamp(event);
794 const bool is_down_event = fl_key_event_get_is_press(event);
795
796 SyncStateLoopContext sync_state_context;
797 sync_state_context.self = self;
798 sync_state_context.state = fl_key_event_get_state(event);
799 sync_state_context.timestamp = timestamp;
800 sync_state_context.is_down = is_down_event;
801 sync_state_context.event_logical_key = logical_key;
802
803 // Update lock mode states
804 g_hash_table_foreach(self->lock_bit_to_checked_keys,
805 synchronize_lock_states_loop_body, &sync_state_context);
806
807 // Update pressing states
808 g_hash_table_foreach(self->modifier_bit_to_checked_keys,
809 synchronize_pressed_states_loop_body,
810 &sync_state_context);
811
812 // Construct the real event
813 const uint64_t last_logical_record =
814 lookup_hash_table(self->pressing_records, physical_key);
815
816 FlutterKeyEvent out_event;
817 out_event.struct_size = sizeof(out_event);
818 out_event.timestamp = timestamp;
819 out_event.physical = physical_key;
820 out_event.logical =
821 last_logical_record != 0 ? last_logical_record : logical_key;
822 out_event.character = nullptr;
823 out_event.synthesized = false;
824
825 g_autofree char* character_to_free = nullptr;
826 if (is_down_event) {
827 if (last_logical_record) {
828 // A key has been pressed that has the exact physical key as a currently
829 // pressed one. This can happen during repeated events.
830 out_event.type = kFlutterKeyEventTypeRepeat;
831 } else {
832 out_event.type = kFlutterKeyEventTypeDown;
833 }
834 character_to_free = event_to_character(event); // Might be null
835 out_event.character = character_to_free;
836 } else { // is_down_event false
837 if (!last_logical_record) {
838 // The physical key has been released before. It might indicate a missed
839 // event due to loss of focus, or multiple keyboards pressed keys with the
840 // same physical key. Ignore the up event.
841 callback(true, user_data);
842 return;
843 } else {
844 out_event.type = kFlutterKeyEventTypeUp;
845 }
846 }
847
848 if (out_event.type != kFlutterKeyEventTypeRepeat) {
849 update_pressing_state(self, physical_key, is_down_event ? logical_key : 0);
850 }
851 possibly_update_lock_bit(self, logical_key, is_down_event);
852 if (is_down_event) {
853 update_mapping_record(self, physical_key, logical_key);
854 }
855 FlKeyEmbedderUserData* response_data =
856 fl_key_embedder_user_data_new(callback, user_data);
857 self->sent_any_events = true;
858 self->send_key_event(&out_event, handle_response, response_data,
859 self->send_key_event_user_data);
860 }

References callback, corrected_modifier_physical_key(), event, event_to_character(), event_to_logical_key(), event_to_physical_key(), event_to_timestamp(), fl_key_embedder_user_data_new(), fl_key_event_get_is_press(), fl_key_event_get_state(), handle_response(), lookup_hash_table(), possibly_update_lock_bit(), specified_logical_key, synchronize_lock_states_loop_body(), synchronize_pressed_states_loop_body(), update_mapping_record(), update_pressing_state(), and user_data.

Referenced by fl_key_embedder_responder_handle_event().

## ◆ fl_key_embedder_responder_iface_init()

static void fl_key_embedder_responder_iface_init | ( | FlKeyResponderInterface * | iface | ) |
| static

Definition at line 220 of file fl_key_embedder_responder.cc.

221 {
222 iface->handle_event = fl_key_embedder_responder_handle_event;
223 }

References fl_key_embedder_responder_handle_event().

## ◆ fl_key_embedder_responder_init()

static void fl_key_embedder_responder_init | ( | FlKeyEmbedderResponder * | self | ) |
| static

Definition at line 232 of file fl_key_embedder_responder.cc.

232 {}

## ◆ fl_key_embedder_responder_new()

FlKeyEmbedderResponder* fl_key_embedder_responder_new | ( | EmbedderSendKeyEvent | send_key_event,
|  | void * | send_key_event_user_data
| ) |  |

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. @send_key_event: a function that is called on every key event. @send_key_event_user_data: an opaque pointer that will be sent back as the last argument of send_key_event, created and managed by the object that holds FlKeyEmbedderResponder.

Returns: a new #FlKeyEmbedderResponder.

Definition at line 263 of file fl_key_embedder_responder.cc.

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

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(), and send_key_event().

Referenced by fl_keyboard_handler_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 879 of file fl_key_embedder_responder.cc.

882 {
883 const double timestamp = event_time * kMicrosecondsPerMillisecond;
884
885 SyncStateLoopContext sync_state_context;
886 sync_state_context.self = responder;
887 sync_state_context.state = state;
888 sync_state_context.timestamp = timestamp;
889
890 // Update pressing states.
891 g_hash_table_foreach(responder->modifier_bit_to_checked_keys,
892 synchronize_pressed_states_loop_body,
893 &sync_state_context);
894 }

References kMicrosecondsPerMillisecond, state, and synchronize_pressed_states_loop_body().

Referenced by fl_keyboard_handler_sync_modifier_if_needed().

## ◆ fl_key_embedder_user_data_class_init()

static void fl_key_embedder_user_data_class_init | ( | FlKeyEmbedderUserDataClass * | klass | ) |
| static

Definition at line 101 of file fl_key_embedder_responder.cc.

102 {
103 G_OBJECT_CLASS(klass)->dispose = fl_key_embedder_user_data_dispose;
104 }

References fl_key_embedder_user_data_dispose().

## ◆ fl_key_embedder_user_data_dispose()

static void fl_key_embedder_user_data_dispose | ( | GObject * | object | ) |
| static

Definition at line 108 of file fl_key_embedder_responder.cc.

108 {
109 // The following line suppresses a warning for unused function
110 // FL_IS_KEY_EMBEDDER_USER_DATA.
111 g_return_if_fail(FL_IS_KEY_EMBEDDER_USER_DATA(object));
112 }

Referenced by fl_key_embedder_user_data_class_init().

## ◆ fl_key_embedder_user_data_init()

static void fl_key_embedder_user_data_init | ( | FlKeyEmbedderUserData * | self | ) |
| static

Definition at line 106 of file fl_key_embedder_responder.cc.

106 {}

## ◆ fl_key_embedder_user_data_new()

static FlKeyEmbedderUserData* fl_key_embedder_user_data_new | ( | FlKeyResponderAsyncCallback | callback,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 117 of file fl_key_embedder_responder.cc.

119 {
120 FlKeyEmbedderUserData* self = FL_KEY_EMBEDDER_USER_DATA(
121 g_object_new(FL_TYPE_EMBEDDER_USER_DATA, nullptr));
122
123 self->callback = callback;
124 self->user_data = user_data;
125 return self;
126 }

References callback, FL_TYPE_EMBEDDER_USER_DATA, and user_data.

Referenced by fl_key_embedder_responder_handle_event_impl().

## ◆ G_DECLARE_FINAL_TYPE()

G_DECLARE_FINAL_TYPE | ( | FlKeyEmbedderUserData | ,
|  | fl_key_embedder_user_data | ,
|  | FL | ,
|  | KEY_EMBEDDER_USER_DATA | ,
|  | GObject |
| ) |  |

## ◆ G_DEFINE_TYPE_WITH_CODE()

G_DEFINE_TYPE_WITH_CODE | ( | FlKeyEmbedderResponder | ,
|  | fl_key_embedder_responder | ,
|  | G_TYPE_OBJECT | ,
|  | G_IMPLEMENT_INTERFACE(FL_TYPE_KEY_RESPONDER, fl_key_embedder_responder_iface_init) |
| ) |  |

## ◆ handle_response()

static void handle_response | ( | bool | handled,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 344 of file fl_key_embedder_responder.cc.

344 {
345 g_autoptr(FlKeyEmbedderUserData) data = FL_KEY_EMBEDDER_USER_DATA(user_data);
346
347 g_return_if_fail(data->callback != nullptr);
348
349 data->callback(handled, data->user_data);
350 }

References user_data.

Referenced by fl_key_embedder_responder_handle_event_impl().

## ◆ hash_table_find_equal_value()

static gboolean hash_table_find_equal_value | ( | gpointer | key,
|  | gpointer | value,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 36 of file fl_key_embedder_responder.cc.

38 {
39 return gpointer_to_uint64(value) == gpointer_to_uint64(user_data);
40 }

References gpointer_to_uint64(), user_data, and value.

Referenced by reverse_lookup_hash_table().

## ◆ 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
| ) |  |
| static

Definition at line 251 of file fl_key_embedder_responder.cc.

253 {
254 FlKeyEmbedderCheckedKey* checked_key =
255 reinterpret_cast<FlKeyEmbedderCheckedKey*>(value);
256 GHashTable* table = reinterpret_cast<GHashTable*>(user_data);
257 g_hash_table_insert(table,
258 uint64_to_gpointer(checked_key->primary_logical_key),
259 GUINT_TO_POINTER(lock_bit));
260 }

References FlKeyEmbedderCheckedKey::primary_logical_key, uint64_to_gpointer(), user_data, and value.

Referenced by fl_key_embedder_responder_new().

## ◆ is_known_modifier_physical_key_loop_body()

static void is_known_modifier_physical_key_loop_body | ( | gpointer | key,
|  | gpointer | value,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 717 of file fl_key_embedder_responder.cc.

719 {
720 ModifierLogicalToPhysicalContext* context =
721 reinterpret_cast<ModifierLogicalToPhysicalContext*>(user_data);
722 FlKeyEmbedderCheckedKey* checked_key =
723 reinterpret_cast<FlKeyEmbedderCheckedKey*>(value);
724
725 if (checked_key->primary_physical_key == context->physical_key_from_event) {
726 context->known_modifier_physical_key = true;
727 }
728 }

References FlKeyEmbedderCheckedKey::primary_physical_key, user_data, and value.

Referenced by corrected_modifier_physical_key().

## ◆ lookup_hash_table()

static uint64_t lookup_hash_table | ( | GHashTable * | table,
|  | uint64_t | key
| ) |  |
| static

Definition at line 31 of file fl_key_embedder_responder.cc.

31 {
32 return gpointer_to_uint64(
33 g_hash_table_lookup(table, uint64_to_gpointer(key)));
34 }

References gpointer_to_uint64(), and uint64_to_gpointer().

Referenced by fl_key_embedder_responder_handle_event_impl(), synchronize_lock_states_loop_body(), synchronize_pressed_states_loop_body(), and update_pressing_state().

## ◆ possibly_update_lock_bit()

static void possibly_update_lock_bit | ( | FlKeyEmbedderResponder * | self,
|  | uint64_t | logical_key,
|  | bool | is_down
| ) |  |
| static

Definition at line 420 of file fl_key_embedder_responder.cc.

422 {
423 if (!is_down) {
424 return;
425 }
426 const guint mode_bit = GPOINTER_TO_UINT(g_hash_table_lookup(
427 self->logical_key_to_lock_bit, uint64_to_gpointer(logical_key)));
428 if (mode_bit != 0) {
429 self->lock_records ^= mode_bit;
430 }
431 }

References uint64_to_gpointer().

Referenced by fl_key_embedder_responder_handle_event_impl(), and synchronize_lock_states_loop_body().

## ◆ reverse_lookup_hash_table()

static uint64_t reverse_lookup_hash_table | ( | GHashTable * | table,
|  | uint64_t | value
| ) |  |
| static

Definition at line 48 of file fl_key_embedder_responder.cc.

48 {
49 return gpointer_to_uint64(g_hash_table_find(
50 table, hash_table_find_equal_value, uint64_to_gpointer(value)));
51 }

References gpointer_to_uint64(), hash_table_find_equal_value(), uint64_to_gpointer(), and value.

Referenced by synchronize_pressed_states_loop_body().

## ◆ synchronize_lock_states_loop_body()

static void synchronize_lock_states_loop_body | ( | gpointer | key,
|  | gpointer | value,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 610 of file fl_key_embedder_responder.cc.

612 {
613 SyncStateLoopContext* context =
614 reinterpret_cast<SyncStateLoopContext*>(user_data);
615 FlKeyEmbedderCheckedKey* checked_key =
616 reinterpret_cast<FlKeyEmbedderCheckedKey*>(value);
617
618 guint modifier_bit = GPOINTER_TO_INT(key);
619 FlKeyEmbedderResponder* self = context->self;
620
621 const uint64_t logical_key = checked_key->primary_logical_key;
622 const uint64_t recorded_physical_key =
623 lookup_hash_table(self->mapping_records, logical_key);
624 // The physical key is derived from past mapping record if possible.
625 //
626 // If the event to be synthesized is a key up event, then there must have
627 // been a key down event before, which has updated the mapping record.
628 // If the event to be synthesized is a key down event, then there might
629 // not have been a mapping record, in which case the hard-coded
630 // #primary_physical_key is used.
631 const uint64_t physical_key = recorded_physical_key != 0
632 ? recorded_physical_key
633 : checked_key->primary_physical_key;
634
635 // A lock mode key can be at any of a 4-stage cycle, depending on whether it's
636 // pressed and enabled. The following table lists the definition of each
637 // stage (TruePressed and TrueEnabled), the event of the lock key between
638 // every 2 stages (SelfType and SelfState), and the event of other keys at
639 // each stage (OthersState). On certain platforms SelfState uses a reversed
640 // rule for certain keys (SelfState(rvsd), as documented in
641 // #update_caps_lock_state_logic_inferrence).
642 //
643 // # [0] [1] [2] [3]
644 // TruePressed: Released Pressed Released Pressed
645 // TrueEnabled: Disabled Enabled Enabled Disabled
646 // SelfType: Down Up Down Up
647 // SelfState: 0 1 1 1
648 // SelfState(rvsd): 1 1 0 1
649 // OthersState: 0 1 1 1
650 //
651 // When the exact stage can't be derived, choose the stage that requires the
652 // minimal synthesization.
653
654 const uint64_t pressed_logical_key =
655 recorded_physical_key == 0
656 ? 0
657 : lookup_hash_table(self->pressing_records, recorded_physical_key);
658
659 g_return_if_fail(pressed_logical_key == 0 ||
660 pressed_logical_key == logical_key);
661 const int stage_by_record = find_stage_by_record(
662 pressed_logical_key != 0, (self->lock_records & modifier_bit) != 0);
663
664 const bool enabled_by_state = (context->state & modifier_bit) != 0;
665 const bool this_key_is_event_key = logical_key == context->event_logical_key;
666 if (this_key_is_event_key && checked_key->is_caps_lock) {
667 update_caps_lock_state_logic_inferrence(self, context->is_down,
668 enabled_by_state, stage_by_record);
669 g_return_if_fail(self->caps_lock_state_logic_inferrence !=
670 kStateLogicUndecided);
671 }
672 const bool reverse_state_logic =
673 checked_key->is_caps_lock &&
674 self->caps_lock_state_logic_inferrence == kStateLogicReversed;
675 const int stage_by_event =
676 this_key_is_event_key
677 ? find_stage_by_self_event(stage_by_record, context->is_down,
678 enabled_by_state, reverse_state_logic)
679 : find_stage_by_others_event(stage_by_record, enabled_by_state);
680
681 // The destination stage is equal to stage_by_event but shifted cyclically to
682 // be no less than stage_by_record.
683 constexpr int kNumStages = 4;
684 const int destination_stage = stage_by_event >= stage_by_record
685 ? stage_by_event
686 : stage_by_event + kNumStages;
687
688 g_return_if_fail(stage_by_record <= destination_stage);
689 if (stage_by_record == destination_stage) {
690 return;
691 }
692 for (int current_stage = stage_by_record; current_stage < destination_stage;
693 current_stage += 1) {
694 if (current_stage == 9) {
695 return;
696 }
697
698 const int standard_current_stage = current_stage % kNumStages;
699 const bool is_down_event =
700 standard_current_stage == 0 || standard_current_stage == 2;
701 if (is_down_event && recorded_physical_key == 0) {
702 update_mapping_record(self, physical_key, logical_key);
703 }
704 FlutterKeyEventType type =
705 is_down_event ? kFlutterKeyEventTypeDown : kFlutterKeyEventTypeUp;
706 update_pressing_state(self, physical_key, is_down_event ? logical_key : 0);
707 possibly_update_lock_bit(self, logical_key, is_down_event);
708 synthesize_simple_event(self, type, physical_key, logical_key,
709 context->timestamp);
710 }
711 }

References find_stage_by_others_event(), find_stage_by_record(), find_stage_by_self_event(), FlKeyEmbedderCheckedKey::is_caps_lock, lookup_hash_table(), possibly_update_lock_bit(), FlKeyEmbedderCheckedKey::primary_logical_key, FlKeyEmbedderCheckedKey::primary_physical_key, synthesize_simple_event(), type, update_caps_lock_state_logic_inferrence(), update_mapping_record(), update_pressing_state(), user_data, and value.

Referenced by fl_key_embedder_responder_handle_event_impl().

## ◆ synchronize_pressed_states_loop_body()

static void synchronize_pressed_states_loop_body | ( | gpointer | key,
|  | gpointer | value,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 444 of file fl_key_embedder_responder.cc.

446 {
447 SyncStateLoopContext* context =
448 reinterpret_cast<SyncStateLoopContext*>(user_data);
449 FlKeyEmbedderCheckedKey* checked_key =
450 reinterpret_cast<FlKeyEmbedderCheckedKey*>(value);
451
452 const guint modifier_bit = GPOINTER_TO_INT(key);
453 FlKeyEmbedderResponder* self = context->self;
454 // Each TestKey contains up to two logical keys, typically the left modifier
455 // and the right modifier, that correspond to the same modifier_bit. We'd
456 // like to infer whether to synthesize a down or up event for each key.
457 //
458 // The hard part is that, if we want to synthesize a down event, we don't know
459 // which physical key to use. Here we assume the keyboard layout do not change
460 // frequently and use the last physical-logical relationship, recorded in
461 // #mapping_records.
462 const uint64_t logical_keys[] = {
463 checked_key->primary_logical_key,
464 checked_key->secondary_logical_key,
465 };
466 const guint length = checked_key->secondary_logical_key == 0 ? 1 : 2;
467
468 const bool any_pressed_by_state = (context->state & modifier_bit) != 0;
469
470 bool any_pressed_by_record = false;
471
472 // Traverse each logical key of this modifier bit for 2 purposes:
473 //
474 // 1. Perform the synthesization of release events: If the modifier bit is 0
475 // and the key is pressed, synthesize a release event.
476 // 2. Prepare for the synthesization of press events: If the modifier bit is
477 // 1, and no keys are pressed (discovered here), synthesize a press event
478 // later.
479 for (guint logical_key_idx = 0; logical_key_idx < length; logical_key_idx++) {
480 const uint64_t logical_key = logical_keys[logical_key_idx];
481 g_return_if_fail(logical_key != 0);
482 const uint64_t pressing_physical_key =
483 reverse_lookup_hash_table(self->pressing_records, logical_key);
484 const bool this_key_pressed_before_event = pressing_physical_key != 0;
485
486 any_pressed_by_record =
487 any_pressed_by_record || this_key_pressed_before_event;
488
489 if (this_key_pressed_before_event && !any_pressed_by_state) {
490 const uint64_t recorded_physical_key =
491 lookup_hash_table(self->mapping_records, logical_key);
492 // Since this key has been pressed before, there must have been a recorded
493 // physical key.
494 g_return_if_fail(recorded_physical_key != 0);
495 // In rare cases #recorded_logical_key is different from #logical_key.
496 const uint64_t recorded_logical_key =
497 lookup_hash_table(self->pressing_records, recorded_physical_key);
498 synthesize_simple_event(self, kFlutterKeyEventTypeUp,
499 recorded_physical_key, recorded_logical_key,
500 context->timestamp);
501 update_pressing_state(self, recorded_physical_key, 0);
502 }
503 }
504 // If the modifier should be pressed, synthesize a down event for its primary
505 // key.
506 if (any_pressed_by_state && !any_pressed_by_record) {
507 const uint64_t logical_key = checked_key->primary_logical_key;
508 const uint64_t recorded_physical_key =
509 lookup_hash_table(self->mapping_records, logical_key);
510 // The physical key is derived from past mapping record if possible.
511 //
512 // The event to be synthesized is a key down event. There might not have
513 // been a mapping record, in which case the hard-coded #primary_physical_key
514 // is used.
515 const uint64_t physical_key = recorded_physical_key != 0
516 ? recorded_physical_key
517 : checked_key->primary_physical_key;
518 if (recorded_physical_key == 0) {
519 update_mapping_record(self, physical_key, logical_key);
520 }
521 synthesize_simple_event(self, kFlutterKeyEventTypeDown, physical_key,
522 logical_key, context->timestamp);
523 update_pressing_state(self, physical_key, logical_key);
524 }
525 }

References length, lookup_hash_table(), FlKeyEmbedderCheckedKey::primary_logical_key, FlKeyEmbedderCheckedKey::primary_physical_key, reverse_lookup_hash_table(), FlKeyEmbedderCheckedKey::secondary_logical_key, synthesize_simple_event(), update_mapping_record(), update_pressing_state(), user_data, and value.

Referenced by fl_key_embedder_responder_handle_event_impl(), and fl_key_embedder_responder_sync_modifiers_if_needed().

## ◆ synthesize_simple_event()

static void synthesize_simple_event | ( | FlKeyEmbedderResponder * | self,
|  | FlutterKeyEventType | type,
|  | uint64_t | physical,
|  | uint64_t | logical,
|  | double | timestamp
| ) |  |
| static

Definition at line 353 of file fl_key_embedder_responder.cc.

357 {
358 FlutterKeyEvent out_event;
359 out_event.struct_size = sizeof(out_event);
360 out_event.timestamp = timestamp;
361 out_event.type = type;
362 out_event.physical = physical;
363 out_event.logical = logical;
364 out_event.character = nullptr;
365 out_event.synthesized = true;
366 self->sent_any_events = true;
367 self->send_key_event(&out_event, nullptr, nullptr,
368 self->send_key_event_user_data);
369 }

References type.

Referenced by synchronize_lock_states_loop_body(), and synchronize_pressed_states_loop_body().

## ◆ to_lower()

static uint64_t to_lower | ( | uint64_t | n | ) |
| static

Definition at line 53 of file fl_key_embedder_responder.cc.

53 {
54 constexpr uint64_t lower_a = 0x61;
55 constexpr uint64_t upper_a = 0x41;
56 constexpr uint64_t upper_z = 0x5a;
57
58 constexpr uint64_t lower_a_grave = 0xe0;
59 constexpr uint64_t upper_a_grave = 0xc0;
60 constexpr uint64_t upper_thorn = 0xde;
61 constexpr uint64_t division = 0xf7;
62
63 // ASCII range.
64 if (n >= upper_a && n <= upper_z) {
65 return n - upper_a + lower_a;
66 }
67
68 // EASCII range.
69 if (n >= upper_a_grave && n <= upper_thorn && n != division) {
70 return n - upper_a_grave + lower_a_grave;
71 }
72
73 return n;
74 }

Referenced by event_to_logical_key().

## ◆ update_caps_lock_state_logic_inferrence()

static void update_caps_lock_state_logic_inferrence | ( | FlKeyEmbedderResponder * | self,
|  | bool | is_down_event,
|  | bool | enabled_by_state,
|  | int | stage_by_record
| ) |  |
| static

Definition at line 583 of file fl_key_embedder_responder.cc.

587 {
588 if (self->caps_lock_state_logic_inferrence != kStateLogicUndecided) {
589 return;
590 }
591 if (!is_down_event) {
592 return;
593 }
594 const int stage_by_event = find_stage_by_self_event(
595 stage_by_record, is_down_event, enabled_by_state, false);
596 if ((stage_by_event == 0 && stage_by_record == 2) ||
597 (stage_by_event == 2 && stage_by_record == 0)) {
598 self->caps_lock_state_logic_inferrence = kStateLogicReversed;
599 } else {
600 self->caps_lock_state_logic_inferrence = kStateLogicNormal;
601 }
602 }

References find_stage_by_self_event().

Referenced by synchronize_lock_states_loop_body().

## ◆ update_mapping_record()

static void update_mapping_record | ( | FlKeyEmbedderResponder * | self,
|  | uint64_t | physical_key,
|  | uint64_t | logical_key
| ) |  |
| static

Definition at line 433 of file fl_key_embedder_responder.cc.

435 {
436 g_hash_table_insert(self->mapping_records, uint64_to_gpointer(logical_key),
437 uint64_to_gpointer(physical_key));
438 }

References uint64_to_gpointer().

Referenced by fl_key_embedder_responder_handle_event_impl(), synchronize_lock_states_loop_body(), and synchronize_pressed_states_loop_body().

## ◆ update_pressing_state()

static void update_pressing_state | ( | FlKeyEmbedderResponder * | self,
|  | uint64_t | physical_key,
|  | uint64_t | logical_key
| ) |  |
| static

Definition at line 399 of file fl_key_embedder_responder.cc.

401 {
402 if (logical_key != 0) {
403 g_return_if_fail(lookup_hash_table(self->pressing_records, physical_key) ==
404 0);
405 g_hash_table_insert(self->pressing_records,
406 uint64_to_gpointer(physical_key),
407 uint64_to_gpointer(logical_key));
408 } else {
409 g_return_if_fail(lookup_hash_table(self->pressing_records, physical_key) !=
410 0);
411 g_hash_table_remove(self->pressing_records,
412 uint64_to_gpointer(physical_key));
413 }
414 }

References lookup_hash_table(), and uint64_to_gpointer().

Referenced by fl_key_embedder_responder_handle_event_impl(), synchronize_lock_states_loop_body(), and synchronize_pressed_states_loop_body().

## Variable Documentation

## ◆ callback

FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

Definition at line 217 of file fl_key_embedder_responder.cc.

Referenced by fl_key_embedder_responder_handle_event(), fl_key_embedder_responder_handle_event_impl(), and fl_key_embedder_user_data_new().

## ◆ event

FlKeyEvent* event

Definition at line 215 of file fl_key_embedder_responder.cc.

Referenced by event_to_character(), event_to_logical_key(), event_to_physical_key(), event_to_timestamp(), fl_key_embedder_responder_handle_event(), and fl_key_embedder_responder_handle_event_impl().

## ◆ kEmptyEvent

const FlutterKeyEvent kEmptyEvent
| static

Initial value:
{
.struct_size = sizeof(FlutterKeyEvent),
.timestamp = 0,
.type = kFlutterKeyEventTypeDown,
.physical = 0,
.logical = 0,
.character = nullptr,
.synthesized = false,
}

Definition at line 16 of file fl_key_embedder_responder.cc.

Referenced by fl_key_embedder_responder_handle_event().

## ◆ kMicrosecondsPerMillisecond

constexpr uint64_t kMicrosecondsPerMillisecond = 1000
| constexpr

Definition at line 14 of file fl_key_embedder_responder.cc.

Referenced by event_to_timestamp(), and fl_key_embedder_responder_sync_modifiers_if_needed().

## ◆ specified_logical_key

FlKeyEvent uint64_t specified_logical_key

Definition at line 216 of file fl_key_embedder_responder.cc.

Referenced by fl_key_embedder_responder_handle_event(), and fl_key_embedder_responder_handle_event_impl().

## ◆ user_data

FlKeyEvent uint64_t FlKeyResponderAsyncCallback gpointer user_data

Definition at line 218 of file fl_key_embedder_responder.cc.

Referenced by find_physical_from_logical_loop_body(), fl_key_embedder_responder_handle_event(), fl_key_embedder_responder_handle_event_impl(), fl_key_embedder_user_data_new(), handle_response(), hash_table_find_equal_value(), initialize_logical_key_to_lock_bit_loop_body(), is_known_modifier_physical_key_loop_body(), synchronize_lock_states_loop_body(), and synchronize_pressed_states_loop_body().

gtk_keyval_to_logical_key_map
std::map< uint64_t, uint64_t > gtk_keyval_to_logical_key_map
Definition: key_mapping.g.cc:240
fl_key_embedder_user_data_new
static FlKeyEmbedderUserData * fl_key_embedder_user_data_new(FlKeyResponderAsyncCallback callback, gpointer user_data)
Definition: fl_key_embedder_responder.cc:117
apply_id_plane
static uint64_t apply_id_plane(uint64_t logical_id, uint64_t plane)
Definition: fl_key_embedder_responder.cc:296
find_stage_by_self_event
static int find_stage_by_self_event(int stage_by_record, bool is_down_event, bool is_state_on, bool reverse_state_logic)
Definition: fl_key_embedder_responder.cc:541
user_data
FlKeyEvent uint64_t FlKeyResponderAsyncCallback gpointer user_data
Definition: fl_key_embedder_responder.cc:218
FlKeyEmbedderCheckedKey::is_caps_lock
bool is_caps_lock
Definition: fl_key_embedder_responder_private.h:43
to_lower
static uint64_t to_lower(uint64_t n)
Definition: fl_key_embedder_responder.cc:53
type
uint8_t type
Definition: fl_standard_message_codec_test.cc:1115
event_to_timestamp
static uint64_t event_to_timestamp(FlKeyEvent *event)
Definition: fl_key_embedder_responder.cc:322
FL_TYPE_EMBEDDER_RESPONDER_USER_DATA
#define FL_TYPE_EMBEDDER_RESPONDER_USER_DATA
Definition: fl_key_embedder_responder.cc:204
synthesize_simple_event
static void synthesize_simple_event(FlKeyEmbedderResponder *self, FlutterKeyEventType type, uint64_t physical, uint64_t logical, double timestamp)
Definition: fl_key_embedder_responder.cc:353
uint64_to_gpointer
gpointer uint64_to_gpointer(uint64_t number)
Definition: key_mapping.h:17
kUnicodePlane
const uint64_t kUnicodePlane
Definition: key_mapping.g.cc:515
FL_TYPE_EMBEDDER_USER_DATA
#define FL_TYPE_EMBEDDER_USER_DATA
Definition: fl_key_embedder_responder.cc:83
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:444
event
FlKeyEvent * event
Definition: fl_key_embedder_responder.cc:215
find_stage_by_others_event
static int find_stage_by_others_event(int stage_by_record, bool is_state_on)
Definition: fl_key_embedder_responder.cc:556
state
AtkStateType state
Definition: fl_accessible_node.cc:10
update_pressing_state
static void update_pressing_state(FlKeyEmbedderResponder *self, uint64_t physical_key, uint64_t logical_key)
Definition: fl_key_embedder_responder.cc:399
fl_key_embedder_responder_handle_event
static void fl_key_embedder_responder_handle_event(FlKeyResponder *responder, FlKeyEvent *event, uint64_t specified_logical_key, FlKeyResponderAsyncCallback callback, gpointer user_data)
Definition: fl_key_embedder_responder.cc:863
find_stage_by_record
static int find_stage_by_record(bool is_down, bool is_enabled)
Definition: fl_key_embedder_responder.cc:529
fl_key_embedder_responder_handle_event_impl
static void fl_key_embedder_responder_handle_event_impl(FlKeyResponder *responder, FlKeyEvent *event, uint64_t specified_logical_key, FlKeyResponderAsyncCallback callback, gpointer user_data)
Definition: fl_key_embedder_responder.cc:776
fl_key_event_get_keyval
guint fl_key_event_get_keyval(FlKeyEvent *self)
Definition: fl_key_event.cc:94
specified_logical_key
FlKeyEvent uint64_t specified_logical_key
Definition: fl_key_embedder_responder.cc:216
find_physical_from_logical_loop_body
static void find_physical_from_logical_loop_body(gpointer key, gpointer value, gpointer user_data)
Definition: fl_key_embedder_responder.cc:734
initialize_modifier_bit_to_checked_keys
void initialize_modifier_bit_to_checked_keys(GHashTable *table)
Definition: key_mapping.g.cc:414
kGtkPlane
const uint64_t kGtkPlane
Definition: key_mapping.g.cc:516
callback
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
Definition: fl_key_embedder_responder.cc:217
hash_table_find_equal_value
static gboolean hash_table_find_equal_value(gpointer key, gpointer value, gpointer user_data)
Definition: fl_key_embedder_responder.cc:36
kValueMask
const uint64_t kValueMask
Definition: key_mapping.g.cc:514
fl_key_embedder_responder_dispose
static void fl_key_embedder_responder_dispose(GObject *object)
Definition: fl_key_embedder_responder.cc:235
initialize_lock_bit_to_checked_keys
void initialize_lock_bit_to_checked_keys(GHashTable *table)
Definition: key_mapping.g.cc:446
update_caps_lock_state_logic_inferrence
static void update_caps_lock_state_logic_inferrence(FlKeyEmbedderResponder *self, bool is_down_event, bool enabled_by_state, int stage_by_record)
Definition: fl_key_embedder_responder.cc:583
event_to_physical_key
static uint64_t event_to_physical_key(FlKeyEvent *event)
Definition: fl_key_embedder_responder.cc:300
lookup_hash_table
static uint64_t lookup_hash_table(GHashTable *table, uint64_t key)
Definition: fl_key_embedder_responder.cc:31
fl_key_event_get_time
guint32 fl_key_event_get_time(FlKeyEvent *self)
Definition: fl_key_event.cc:79
event_to_logical_key
static uint64_t event_to_logical_key(FlKeyEvent *event)
Definition: fl_key_embedder_responder.cc:308
result
GAsyncResult * result
Definition: fl_text_input_handler.cc:106
FlKeyEmbedderCheckedKey::primary_physical_key
uint64_t primary_physical_key
Definition: fl_key_embedder_responder_private.h:36
reverse_lookup_hash_table
static uint64_t reverse_lookup_hash_table(GHashTable *table, uint64_t value)
Definition: fl_key_embedder_responder.cc:48
fl_key_event_get_state
GdkModifierType fl_key_event_get_state(FlKeyEvent *self)
Definition: fl_key_event.cc:99
fl_key_event_get_keycode
guint16 fl_key_event_get_keycode(FlKeyEvent *self)
Definition: fl_key_event.cc:89
kMicrosecondsPerMillisecond
constexpr uint64_t kMicrosecondsPerMillisecond
Definition: fl_key_embedder_responder.cc:14
send_key_event
static void send_key_event(FlTextInputHandler *handler, gint keyval, gint state=0)
Definition: fl_text_input_handler_test.cc:181
synchronize_lock_states_loop_body
static void synchronize_lock_states_loop_body(gpointer key, gpointer value, gpointer user_data)
Definition: fl_key_embedder_responder.cc:610
FlKeyEmbedderCheckedKey::secondary_logical_key
uint64_t secondary_logical_key
Definition: fl_key_embedder_responder_private.h:40
is_known_modifier_physical_key_loop_body
static void is_known_modifier_physical_key_loop_body(gpointer key, gpointer value, gpointer user_data)
Definition: fl_key_embedder_responder.cc:717
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:251
corrected_modifier_physical_key
static uint64_t corrected_modifier_physical_key(GHashTable *modifier_bit_to_checked_keys, uint64_t physical_key_from_event, uint64_t logical_key)
Definition: fl_key_embedder_responder.cc:748
xkb_to_physical_key_map
std::map< uint64_t, uint64_t > xkb_to_physical_key_map
Definition: key_mapping.g.cc:20
FlKeyEmbedderCheckedKey::primary_logical_key
uint64_t primary_logical_key
Definition: fl_key_embedder_responder_private.h:38
fl_key_event_get_is_press
gboolean fl_key_event_get_is_press(FlKeyEvent *self)
Definition: fl_key_event.cc:84
handle_response
static void handle_response(bool handled, gpointer user_data)
Definition: fl_key_embedder_responder.cc:344
event_to_character
static char * event_to_character(FlKeyEvent *event)
Definition: fl_key_embedder_responder.cc:329
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
possibly_update_lock_bit
static void possibly_update_lock_bit(FlKeyEmbedderResponder *self, uint64_t logical_key, bool is_down)
Definition: fl_key_embedder_responder.cc:420
FlKeyEmbedderCheckedKey
Definition: fl_key_embedder_responder_private.h:34
length
size_t length
Definition: fl_standard_message_codec_test.cc:1113
update_mapping_record
static void update_mapping_record(FlKeyEmbedderResponder *self, uint64_t physical_key, uint64_t logical_key)
Definition: fl_key_embedder_responder.cc:433
gpointer_to_uint64
uint64_t gpointer_to_uint64(gpointer pointer)
Definition: key_mapping.h:13
kEmptyEvent
static const FlutterKeyEvent kEmptyEvent
Definition: fl_key_embedder_responder.cc:16
fl_key_embedder_user_data_dispose
static void fl_key_embedder_user_data_dispose(GObject *object)
Definition: fl_key_embedder_responder.cc:108