| Flutter Linux Embedder |

fl_key_embedder_responder.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "flutter/shell/platform/linux/fl_key_embedder_responder.h"
6
7 #include <gtk/gtk.h>
8 #include <cinttypes>
9
10 #include "flutter/shell/platform/embedder/embedder.h"
11 #include "flutter/shell/platform/linux/fl_key_embedder_responder_private.h"
12 #include "flutter/shell/platform/linux/key_mapping.h"
13
14 constexpr uint64_t kMicrosecondsPerMillisecond = 1000;
15
16 static const FlutterKeyEvent kEmptyEvent{
17 .struct_size = sizeof(FlutterKeyEvent),
18 .timestamp = 0,
19 .type = kFlutterKeyEventTypeDown,
20 .physical = 0,
21 .logical = 0,
22 .character = nullptr,
23 .synthesized = false,
24 };
25
26 // Look up a hash table that maps a uint64_t to a uint64_t.
27 //
28 // Returns 0 if not found.
29 //
30 // Both key and value should be directly hashed.
31 static uint64_t lookup_hash_table(GHashTable* table, uint64_t key) {
32 return gpointer_to_uint64(
33 g_hash_table_lookup(table, uint64_to_gpointer(key)));
34 }
35
36 static gboolean hash_table_find_equal_value(gpointer key,
37 gpointer value,
38 gpointer user_data) {
39 return gpointer_to_uint64(value) == gpointer_to_uint64(user_data);
40 }
41
42 // Look up a hash table that maps a uint64_t to a uint64_t; given its key,
43 // find its value.
44 //
45 // Returns 0 if not found.
46 //
47 // Both key and value should be directly hashed.
48 static uint64_t reverse_lookup_hash_table(GHashTable* table, uint64_t value) {
49 return gpointer_to_uint64(g_hash_table_find(
50 table, hash_table_find_equal_value, uint64_to_gpointer(value)));
51 }
52
53 static uint64_t to_lower(uint64_t n) {
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 }
75
76 /* Define FlKeyEmbedderUserData */
77
78 /**
79 * FlKeyEmbedderUserData:
80 * The user_data used when #FlKeyEmbedderResponder sends message through the
81 * embedder.SendKeyEvent API.
82 */
83 #define FL_TYPE_EMBEDDER_USER_DATA fl_key_embedder_user_data_get_type()
84 G_DECLARE_FINAL_TYPE(FlKeyEmbedderUserData,
85 fl_key_embedder_user_data,
86 FL,
87 KEY_EMBEDDER_USER_DATA,
88 GObject);
89
90 struct _FlKeyEmbedderUserData {
91 GObject parent_instance;
92
93 FlKeyResponderAsyncCallback callback;
94 gpointer user_data;
95 };
96
97 G_DEFINE_TYPE(FlKeyEmbedderUserData, fl_key_embedder_user_data, G_TYPE_OBJECT)
98
99 static void fl_key_embedder_user_data_dispose(GObject* object);
100
101 static void fl_key_embedder_user_data_class_init(
102 FlKeyEmbedderUserDataClass* klass) {
103 G_OBJECT_CLASS(klass)->dispose = fl_key_embedder_user_data_dispose;
104 }
105
106 static void fl_key_embedder_user_data_init(FlKeyEmbedderUserData* self) {}
107
108 static void fl_key_embedder_user_data_dispose(GObject* object) {
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 }
113
114 // Creates a new FlKeyChannelUserData private class with all information.
115 //
116 // The callback and the user_data might be nullptr.
117 static FlKeyEmbedderUserData* fl_key_embedder_user_data_new(
118 FlKeyResponderAsyncCallback callback,
119 gpointer user_data) {
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 }
127
128 /* Define FlKeyEmbedderResponder */
129
130 namespace {
131
132 typedef enum {
133 kStateLogicUndecided,
134 kStateLogicNormal,
135 kStateLogicReversed,
136 } StateLogicInferrence;
137
138 }
139
140 struct _FlKeyEmbedderResponder {
141 GObject parent_instance;
142
143 EmbedderSendKeyEvent send_key_event;
144
145 // Internal record for states of whether a key is pressed.
146 //
147 // It is a map from Flutter physical key to Flutter logical key. Both keys
148 // and values are directly stored uint64s. This table is freed by the
149 // responder.
150 GHashTable* pressing_records;
151
152 // Internal record for states of whether a lock mode is enabled.
153 //
154 // It is a bit mask composed of GTK mode bits.
155 guint lock_records;
156
157 // Internal record for the last observed key mapping.
158 //
159 // It stores the physical key last seen during a key down event for a logical
160 // key. It is used to synthesize modifier keys and lock keys.
161 //
162 // It is a map from Flutter logical key to physical key. Both keys and
163 // values are directly stored uint64s. This table is freed by the responder.
164 GHashTable* mapping_records;
165
166 // The inferred logic type indicating whether the CapsLock state logic is
167 // reversed on this platform.
168 //
169 // For more information, see #update_caps_lock_state_logic_inferrence.
170 StateLogicInferrence caps_lock_state_logic_inferrence;
171
172 // Record if any events has been sent during a
173 // |fl_key_embedder_responder_handle_event| call.
174 bool sent_any_events;
175
176 // A static map from GTK modifier bits to #FlKeyEmbedderCheckedKey to
177 // configure the modifier keys that needs to be tracked and kept synchronous
178 // on.
179 //
180 // The keys are directly stored guints. The values must be freed with g_free.
181 // This table is freed by the responder.
182 GHashTable* modifier_bit_to_checked_keys;
183
184 // A static map from GTK modifier bits to #FlKeyEmbedderCheckedKey to
185 // configure the lock mode bits that needs to be tracked and kept synchronous
186 // on.
187 //
188 // The keys are directly stored guints. The values must be freed with g_free.
189 // This table is freed by the responder.
190 GHashTable* lock_bit_to_checked_keys;
191
192 // A static map generated by reverse mapping lock_bit_to_checked_keys.
193 //
194 // It is a map from primary physical keys to lock bits. Both keys and values
195 // are directly stored uint64s. This table is freed by the responder.
196 GHashTable* logical_key_to_lock_bit;
197 };
198
199 static void fl_key_embedder_responder_iface_init(
200 FlKeyResponderInterface* iface);
201 static void fl_key_embedder_responder_dispose(GObject* object);
202
203 #define FL_TYPE_EMBEDDER_RESPONDER_USER_DATA \
204 fl_key_embedder_responder_get_type()
205 G_DEFINE_TYPE_WITH_CODE(
206 FlKeyEmbedderResponder,
207 fl_key_embedder_responder,
208 G_TYPE_OBJECT,
209 G_IMPLEMENT_INTERFACE(FL_TYPE_KEY_RESPONDER,
210 fl_key_embedder_responder_iface_init))
211
212 static void fl_key_embedder_responder_handle_event(
213 FlKeyResponder* responder,
214 FlKeyEvent* event,
215 uint64_t specified_logical_key,
216 FlKeyResponderAsyncCallback callback,
217 gpointer user_data);
218
219 static void fl_key_embedder_responder_iface_init(
220 FlKeyResponderInterface* iface) {
221 iface->handle_event = fl_key_embedder_responder_handle_event;
222 }
223
224 // Initializes the FlKeyEmbedderResponder class methods.
225 static void fl_key_embedder_responder_class_init(
226 FlKeyEmbedderResponderClass* klass) {
227 G_OBJECT_CLASS(klass)->dispose = fl_key_embedder_responder_dispose;
228 }
229
230 // Initializes an FlKeyEmbedderResponder instance.
231 static void fl_key_embedder_responder_init(FlKeyEmbedderResponder* self) {}
232
233 // Disposes of an FlKeyEmbedderResponder instance.
234 static void fl_key_embedder_responder_dispose(GObject* object) {
235 FlKeyEmbedderResponder* self = FL_KEY_EMBEDDER_RESPONDER(object);
236
237 g_clear_pointer(&self->pressing_records, g_hash_table_unref);
238 g_clear_pointer(&self->mapping_records, g_hash_table_unref);
239 g_clear_pointer(&self->modifier_bit_to_checked_keys, g_hash_table_unref);
240 g_clear_pointer(&self->lock_bit_to_checked_keys, g_hash_table_unref);
241 g_clear_pointer(&self->logical_key_to_lock_bit, g_hash_table_unref);
242
243 G_OBJECT_CLASS(fl_key_embedder_responder_parent_class)->dispose(object);
244 }
245
246 // Fill in #logical_key_to_lock_bit by associating a logical key with
247 // its corresponding modifier bit.
248 //
249 // This is used as the body of a loop over #lock_bit_to_checked_keys.
250 static void initialize_logical_key_to_lock_bit_loop_body(gpointer lock_bit,
251 gpointer value,
252 gpointer user_data) {
253 FlKeyEmbedderCheckedKey* checked_key =
254 reinterpret_cast<FlKeyEmbedderCheckedKey*>(value);
255 GHashTable* table = reinterpret_cast<GHashTable*>(user_data);
256 g_hash_table_insert(table,
257 uint64_to_gpointer(checked_key->primary_logical_key),
258 GUINT_TO_POINTER(lock_bit));
259 }
260
261 // Creates a new FlKeyEmbedderResponder instance.
262 FlKeyEmbedderResponder* fl_key_embedder_responder_new(
263 EmbedderSendKeyEvent send_key_event) {
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 }
290
291 /* Implement FlKeyEmbedderUserData */
292
293 static uint64_t apply_id_plane(uint64_t logical_id, uint64_t plane) {
294 return (logical_id & kValueMask) | plane;
295 }
296
297 static uint64_t event_to_physical_key(const FlKeyEvent* event) {
298 auto found = xkb_to_physical_key_map.find(event->keycode);
299 if (found != xkb_to_physical_key_map.end()) {
300 return found->second;
301 }
302 return apply_id_plane(event->keycode, kGtkPlane);
303 }
304
305 static uint64_t event_to_logical_key(const FlKeyEvent* event) {
306 guint keyval = event->keyval;
307 auto found = gtk_keyval_to_logical_key_map.find(keyval);
308 if (found != gtk_keyval_to_logical_key_map.end()) {
309 return found->second;
310 }
311 // EASCII range
312 if (keyval < 256) {
313 return apply_id_plane(to_lower(keyval), kUnicodePlane);
314 }
315 // Auto-generate key
316 return apply_id_plane(keyval, kGtkPlane);
317 }
318
319 static uint64_t event_to_timestamp(const FlKeyEvent* event) {
320 return kMicrosecondsPerMillisecond * static_cast<double>(event->time);
321 }
322
323 // Returns a newly accocated UTF-8 string from event->keyval that must be
324 // freed later with g_free().
325 static char* event_to_character(const FlKeyEvent* event) {
326 gunichar unicodeChar = gdk_keyval_to_unicode(event->keyval);
327 glong items_written;
328 gchar* result = g_ucs4_to_utf8(&unicodeChar, 1, NULL, &items_written, NULL);
329 if (items_written == 0) {
330 if (result != NULL) {
331 g_free(result);
332 }
333 return nullptr;
334 }
335 return result;
336 }
337
338 // Handles a response from the embedder API to a key event sent to the framework
339 // earlier.
340 static void handle_response(bool handled, gpointer user_data) {
341 g_autoptr(FlKeyEmbedderUserData) data = FL_KEY_EMBEDDER_USER_DATA(user_data);
342
343 g_return_if_fail(data->callback != nullptr);
344
345 data->callback(handled, data->user_data);
346 }
347
348 // Sends a synthesized event to the framework with no demand for callback.
349 static void synthesize_simple_event(FlKeyEmbedderResponder* self,
350 FlutterKeyEventType type,
351 uint64_t physical,
352 uint64_t logical,
353 double timestamp) {
354 FlutterKeyEvent out_event;
355 out_event.struct_size = sizeof(out_event);
356 out_event.timestamp = timestamp;
357 out_event.type = type;
358 out_event.physical = physical;
359 out_event.logical = logical;
360 out_event.character = nullptr;
361 out_event.synthesized = true;
362 self->sent_any_events = true;
363 self->send_key_event(&out_event, nullptr, nullptr);
364 }
365
366 namespace {
367
368 // Context variables for the foreach call used to synchronize pressing states
369 // and lock states.
370 typedef struct {
371 FlKeyEmbedderResponder* self;
372 guint state;
373 uint64_t event_logical_key;
374 bool is_down;
375 double timestamp;
376 } SyncStateLoopContext;
377
378 // Context variables for the foreach call used to find the physical key from
379 // a modifier logical key.
380 typedef struct {
381 bool known_modifier_physical_key;
382 uint64_t logical_key;
383 uint64_t physical_key_from_event;
384 uint64_t corrected_physical_key;
385 } ModifierLogicalToPhysicalContext;
386
387 } // namespace
388
389 // Update the pressing record.
390 //
391 // If `logical_key` is 0, the record will be set as "released". Otherwise, the
392 // record will be set as "pressed" with this logical key. This function asserts
393 // that the key is pressed if the caller asked to release, and vice versa.
394 static void update_pressing_state(FlKeyEmbedderResponder* self,
395 uint64_t physical_key,
396 uint64_t logical_key) {
397 if (logical_key != 0) {
398 g_return_if_fail(lookup_hash_table(self->pressing_records, physical_key) ==
399 0);
400 g_hash_table_insert(self->pressing_records,
401 uint64_to_gpointer(physical_key),
402 uint64_to_gpointer(logical_key));
403 } else {
404 g_return_if_fail(lookup_hash_table(self->pressing_records, physical_key) !=
405 0);
406 g_hash_table_remove(self->pressing_records,
407 uint64_to_gpointer(physical_key));
408 }
409 }
410
411 // Update the lock record.
412 //
413 // If `is_down` is false, this function is a no-op. Otherwise, this function
414 // finds the lock bit corresponding to `physical_key`, and flips its bit.
415 static void possibly_update_lock_bit(FlKeyEmbedderResponder* self,
416 uint64_t logical_key,
417 bool is_down) {
418 if (!is_down) {
419 return;
420 }
421 const guint mode_bit = GPOINTER_TO_UINT(g_hash_table_lookup(
422 self->logical_key_to_lock_bit, uint64_to_gpointer(logical_key)));
423 if (mode_bit != 0) {
424 self->lock_records ^= mode_bit;
425 }
426 }
427
428 static void update_mapping_record(FlKeyEmbedderResponder* self,
429 uint64_t physical_key,
430 uint64_t logical_key) {
431 g_hash_table_insert(self->mapping_records, uint64_to_gpointer(logical_key),
432 uint64_to_gpointer(physical_key));
433 }
434
435 // Synchronizes the pressing state of a key to its state from the event by
436 // synthesizing events.
437 //
438 // This is used as the body of a loop over #modifier_bit_to_checked_keys.
439 static void synchronize_pressed_states_loop_body(gpointer key,
440 gpointer value,
441 gpointer user_data) {
442 SyncStateLoopContext* context =
443 reinterpret_cast<SyncStateLoopContext*>(user_data);
444 FlKeyEmbedderCheckedKey* checked_key =
445 reinterpret_cast<FlKeyEmbedderCheckedKey*>(value);
446
447 const guint modifier_bit = GPOINTER_TO_INT(key);
448 FlKeyEmbedderResponder* self = context->self;
449 // Each TestKey contains up to two logical keys, typically the left modifier
450 // and the right modifier, that correspond to the same modifier_bit. We'd
451 // like to infer whether to synthesize a down or up event for each key.
452 //
453 // The hard part is that, if we want to synthesize a down event, we don't know
454 // which physical key to use. Here we assume the keyboard layout do not change
455 // frequently and use the last physical-logical relationship, recorded in
456 // #mapping_records.
457 const uint64_t logical_keys[] = {
458 checked_key->primary_logical_key,
459 checked_key->secondary_logical_key,
460 };
461 const guint length = checked_key->secondary_logical_key == 0 ? 1 : 2;
462
463 const bool any_pressed_by_state = (context->state & modifier_bit) != 0;
464
465 bool any_pressed_by_record = false;
466
467 // Traverse each logical key of this modifier bit for 2 purposes:
468 //
469 // 1. Perform the synthesization of release events: If the modifier bit is 0
470 // and the key is pressed, synthesize a release event.
471 // 2. Prepare for the synthesization of press events: If the modifier bit is
472 // 1, and no keys are pressed (discovered here), synthesize a press event
473 // later.
474 for (guint logical_key_idx = 0; logical_key_idx < length; logical_key_idx++) {
475 const uint64_t logical_key = logical_keys[logical_key_idx];
476 g_return_if_fail(logical_key != 0);
477 const uint64_t pressing_physical_key =
478 reverse_lookup_hash_table(self->pressing_records, logical_key);
479 const bool this_key_pressed_before_event = pressing_physical_key != 0;
480
481 any_pressed_by_record =
482 any_pressed_by_record || this_key_pressed_before_event;
483
484 if (this_key_pressed_before_event && !any_pressed_by_state) {
485 const uint64_t recorded_physical_key =
486 lookup_hash_table(self->mapping_records, logical_key);
487 // Since this key has been pressed before, there must have been a recorded
488 // physical key.
489 g_return_if_fail(recorded_physical_key != 0);
490 // In rare cases #recorded_logical_key is different from #logical_key.
491 const uint64_t recorded_logical_key =
492 lookup_hash_table(self->pressing_records, recorded_physical_key);
493 synthesize_simple_event(self, kFlutterKeyEventTypeUp,
494 recorded_physical_key, recorded_logical_key,
495 context->timestamp);
496 update_pressing_state(self, recorded_physical_key, 0);
497 }
498 }
499 // If the modifier should be pressed, synthesize a down event for its primary
500 // key.
501 if (any_pressed_by_state && !any_pressed_by_record) {
502 const uint64_t logical_key = checked_key->primary_logical_key;
503 const uint64_t recorded_physical_key =
504 lookup_hash_table(self->mapping_records, logical_key);
505 // The physical key is derived from past mapping record if possible.
506 //
507 // The event to be synthesized is a key down event. There might not have
508 // been a mapping record, in which case the hard-coded #primary_physical_key
509 // is used.
510 const uint64_t physical_key = recorded_physical_key != 0
511 ? recorded_physical_key
512 : checked_key->primary_physical_key;
513 if (recorded_physical_key == 0) {
514 update_mapping_record(self, physical_key, logical_key);
515 }
516 synthesize_simple_event(self, kFlutterKeyEventTypeDown, physical_key,
517 logical_key, context->timestamp);
518 update_pressing_state(self, physical_key, logical_key);
519 }
520 }
521
522 // Find the stage # by the current record, which should be the recorded stage
523 // before the event.
524 static int find_stage_by_record(bool is_down, bool is_enabled) {
525 constexpr int stage_by_record_index[] = {
526 0, // is_down: 0, is_enabled: 0
527 2, // 0 1
528 3, // 1 0
529 1 // 1 1
530 };
531 return stage_by_record_index[(is_down << 1) + is_enabled];
532 }
533
534 // Find the stage # by an event for the target key, which should be inferred
535 // stage before the event.
536 static int find_stage_by_self_event(int stage_by_record,
537 bool is_down_event,
538 bool is_state_on,
539 bool reverse_state_logic) {
540 if (!is_state_on) {
541 return reverse_state_logic ? 2 : 0;
542 }
543 if (is_down_event) {
544 return reverse_state_logic ? 0 : 2;
545 }
546 return stage_by_record;
547 }
548
549 // Find the stage # by an event for a non-target key, which should be inferred
550 // stage during the event.
551 static int find_stage_by_others_event(int stage_by_record, bool is_state_on) {
552 g_return_val_if_fail(stage_by_record >= 0 && stage_by_record < 4,
553 stage_by_record);
554 if (!is_state_on) {
555 return 0;
556 }
557 if (stage_by_record == 0) {
558 return 1;
559 }
560 return stage_by_record;
561 }
562
563 // Infer the logic type of CapsLock on the current platform if applicable.
564 //
565 // In most cases, when a lock key is pressed or released, its event has the
566 // key's state as 0-1-1-1 for the 4 stages (as documented in
567 // #synchronize_lock_states_loop_body) respectively. But in very rare cases it
568 // produces 1-1-0-1, which we call "reversed state logic". This is observed
569 // when using Chrome Remote Desktop on macOS (likely a bug).
570 //
571 // To detect whether the current platform behaves normally or reversed, this
572 // function is called on the first down event of CapsLock before calculating
573 // stages. This function then store the inferred mode as
574 // self->caps_lock_state_logic_inferrence.
575 //
576 // This does not help if the same app session is used alternatively between a
577 // reversed platform and a normal platform. But this is the best we can do.
578 static void update_caps_lock_state_logic_inferrence(
579 FlKeyEmbedderResponder* self,
580 bool is_down_event,
581 bool enabled_by_state,
582 int stage_by_record) {
583 if (self->caps_lock_state_logic_inferrence != kStateLogicUndecided) {
584 return;
585 }
586 if (!is_down_event) {
587 return;
588 }
589 const int stage_by_event = find_stage_by_self_event(
590 stage_by_record, is_down_event, enabled_by_state, false);
591 if ((stage_by_event == 0 && stage_by_record == 2) ||
592 (stage_by_event == 2 && stage_by_record == 0)) {
593 self->caps_lock_state_logic_inferrence = kStateLogicReversed;
594 } else {
595 self->caps_lock_state_logic_inferrence = kStateLogicNormal;
596 }
597 }
598
599 // Synchronizes the lock state of a key to its state from the event by
600 // synthesizing events.
601 //
602 // This is used as the body of a loop over #lock_bit_to_checked_keys.
603 //
604 // This function might modify #caps_lock_state_logic_inferrence.
605 static void synchronize_lock_states_loop_body(gpointer key,
606 gpointer value,
607 gpointer user_data) {
608 SyncStateLoopContext* context =
609 reinterpret_cast<SyncStateLoopContext*>(user_data);
610 FlKeyEmbedderCheckedKey* checked_key =
611 reinterpret_cast<FlKeyEmbedderCheckedKey*>(value);
612
613 guint modifier_bit = GPOINTER_TO_INT(key);
614 FlKeyEmbedderResponder* self = context->self;
615
616 const uint64_t logical_key = checked_key->primary_logical_key;
617 const uint64_t recorded_physical_key =
618 lookup_hash_table(self->mapping_records, logical_key);
619 // The physical key is derived from past mapping record if possible.
620 //
621 // If the event to be synthesized is a key up event, then there must have
622 // been a key down event before, which has updated the mapping record.
623 // If the event to be synthesized is a key down event, then there might
624 // not have been a mapping record, in which case the hard-coded
625 // #primary_physical_key is used.
626 const uint64_t physical_key = recorded_physical_key != 0
627 ? recorded_physical_key
628 : checked_key->primary_physical_key;
629
630 // A lock mode key can be at any of a 4-stage cycle, depending on whether it's
631 // pressed and enabled. The following table lists the definition of each
632 // stage (TruePressed and TrueEnabled), the event of the lock key between
633 // every 2 stages (SelfType and SelfState), and the event of other keys at
634 // each stage (OthersState). On certain platforms SelfState uses a reversed
635 // rule for certain keys (SelfState(rvsd), as documented in
636 // #update_caps_lock_state_logic_inferrence).
637 //
638 // # [0] [1] [2] [3]
639 // TruePressed: Released Pressed Released Pressed
640 // TrueEnabled: Disabled Enabled Enabled Disabled
641 // SelfType: Down Up Down Up
642 // SelfState: 0 1 1 1
643 // SelfState(rvsd): 1 1 0 1
644 // OthersState: 0 1 1 1
645 //
646 // When the exact stage can't be derived, choose the stage that requires the
647 // minimal synthesization.
648
649 const uint64_t pressed_logical_key =
650 recorded_physical_key == 0
651 ? 0
652 : lookup_hash_table(self->pressing_records, recorded_physical_key);
653
654 g_return_if_fail(pressed_logical_key == 0 ||
655 pressed_logical_key == logical_key);
656 const int stage_by_record = find_stage_by_record(
657 pressed_logical_key != 0, (self->lock_records & modifier_bit) != 0);
658
659 const bool enabled_by_state = (context->state & modifier_bit) != 0;
660 const bool this_key_is_event_key = logical_key == context->event_logical_key;
661 if (this_key_is_event_key && checked_key->is_caps_lock) {
662 update_caps_lock_state_logic_inferrence(self, context->is_down,
663 enabled_by_state, stage_by_record);
664 g_return_if_fail(self->caps_lock_state_logic_inferrence !=
665 kStateLogicUndecided);
666 }
667 const bool reverse_state_logic =
668 checked_key->is_caps_lock &&
669 self->caps_lock_state_logic_inferrence == kStateLogicReversed;
670 const int stage_by_event =
671 this_key_is_event_key
672 ? find_stage_by_self_event(stage_by_record, context->is_down,
673 enabled_by_state, reverse_state_logic)
674 : find_stage_by_others_event(stage_by_record, enabled_by_state);
675
676 // The destination stage is equal to stage_by_event but shifted cyclically to
677 // be no less than stage_by_record.
678 constexpr int kNumStages = 4;
679 const int destination_stage = stage_by_event >= stage_by_record
680 ? stage_by_event
681 : stage_by_event + kNumStages;
682
683 g_return_if_fail(stage_by_record <= destination_stage);
684 if (stage_by_record == destination_stage) {
685 return;
686 }
687 for (int current_stage = stage_by_record; current_stage < destination_stage;
688 current_stage += 1) {
689 if (current_stage == 9) {
690 return;
691 }
692
693 const int standard_current_stage = current_stage % kNumStages;
694 const bool is_down_event =
695 standard_current_stage == 0 || standard_current_stage == 2;
696 if (is_down_event && recorded_physical_key == 0) {
697 update_mapping_record(self, physical_key, logical_key);
698 }
699 FlutterKeyEventType type =
700 is_down_event ? kFlutterKeyEventTypeDown : kFlutterKeyEventTypeUp;
701 update_pressing_state(self, physical_key, is_down_event ? logical_key : 0);
702 possibly_update_lock_bit(self, logical_key, is_down_event);
703 synthesize_simple_event(self, type, physical_key, logical_key,
704 context->timestamp);
705 }
706 }
707
708 // Find if a given physical key is the primary physical of one of the known
709 // modifier keys.
710 //
711 // This is used as the body of a loop over #modifier_bit_to_checked_keys.
712 static void is_known_modifier_physical_key_loop_body(gpointer key,
713 gpointer value,
714 gpointer user_data) {
715 ModifierLogicalToPhysicalContext* context =
716 reinterpret_cast<ModifierLogicalToPhysicalContext*>(user_data);
717 FlKeyEmbedderCheckedKey* checked_key =
718 reinterpret_cast<FlKeyEmbedderCheckedKey*>(value);
719
720 if (checked_key->primary_physical_key == context->physical_key_from_event) {
721 context->known_modifier_physical_key = true;
722 }
723 }
724
725 // Return the primary physical key of a known modifier key which matches the
726 // given logical key.
727 //
728 // This is used as the body of a loop over #modifier_bit_to_checked_keys.
729 static void find_physical_from_logical_loop_body(gpointer key,
730 gpointer value,
731 gpointer user_data) {
732 ModifierLogicalToPhysicalContext* context =
733 reinterpret_cast<ModifierLogicalToPhysicalContext*>(user_data);
734 FlKeyEmbedderCheckedKey* checked_key =
735 reinterpret_cast<FlKeyEmbedderCheckedKey*>(value);
736
737 if (checked_key->primary_logical_key == context->logical_key ||
738 checked_key->secondary_logical_key == context->logical_key) {
739 context->corrected_physical_key = checked_key->primary_physical_key;
740 }
741 }
742
743 static uint64_t corrected_modifier_physical_key(
744 GHashTable* modifier_bit_to_checked_keys,
745 uint64_t physical_key_from_event,
746 uint64_t logical_key) {
747 ModifierLogicalToPhysicalContext logical_to_physical_context;
748 logical_to_physical_context.known_modifier_physical_key = false;
749 logical_to_physical_context.physical_key_from_event = physical_key_from_event;
750 logical_to_physical_context.logical_key = logical_key;
751 // If no match is found, defaults to the physical key retrieved from the
752 // event.
753 logical_to_physical_context.corrected_physical_key = physical_key_from_event;
754
755 // Check if the physical key is one of the known modifier physical key.
756 g_hash_table_foreach(modifier_bit_to_checked_keys,
757 is_known_modifier_physical_key_loop_body,
758 &logical_to_physical_context);
759
760 // If the physical key matches a known modifier key, find the modifier
761 // physical key from the logical key.
762 if (logical_to_physical_context.known_modifier_physical_key) {
763 g_hash_table_foreach(modifier_bit_to_checked_keys,
764 find_physical_from_logical_loop_body,
765 &logical_to_physical_context);
766 }
767
768 return logical_to_physical_context.corrected_physical_key;
769 }
770
771 static void fl_key_embedder_responder_handle_event_impl(
772 FlKeyResponder* responder,
773 FlKeyEvent* event,
774 uint64_t specified_logical_key,
775 FlKeyResponderAsyncCallback callback,
776 gpointer user_data) {
777 FlKeyEmbedderResponder* self = FL_KEY_EMBEDDER_RESPONDER(responder);
778
779 g_return_if_fail(event != nullptr);
780 g_return_if_fail(callback != nullptr);
781
782 const uint64_t logical_key = specified_logical_key != 0
783 ? specified_logical_key
784 : event_to_logical_key(event);
785 const uint64_t physical_key_from_event = event_to_physical_key(event);
786 const uint64_t physical_key = corrected_modifier_physical_key(
787 self->modifier_bit_to_checked_keys, physical_key_from_event, logical_key);
788 const double timestamp = event_to_timestamp(event);
789 const bool is_down_event = event->is_press;
790
791 SyncStateLoopContext sync_state_context;
792 sync_state_context.self = self;
793 sync_state_context.state = event->state;
794 sync_state_context.timestamp = timestamp;
795 sync_state_context.is_down = is_down_event;
796 sync_state_context.event_logical_key = logical_key;
797
798 // Update lock mode states
799 g_hash_table_foreach(self->lock_bit_to_checked_keys,
800 synchronize_lock_states_loop_body, &sync_state_context);
801
802 // Update pressing states
803 g_hash_table_foreach(self->modifier_bit_to_checked_keys,
804 synchronize_pressed_states_loop_body,
805 &sync_state_context);
806
807 // Construct the real event
808 const uint64_t last_logical_record =
809 lookup_hash_table(self->pressing_records, physical_key);
810
811 FlutterKeyEvent out_event;
812 out_event.struct_size = sizeof(out_event);
813 out_event.timestamp = timestamp;
814 out_event.physical = physical_key;
815 out_event.logical =
816 last_logical_record != 0 ? last_logical_record : logical_key;
817 out_event.character = nullptr;
818 out_event.synthesized = false;
819
820 g_autofree char* character_to_free = nullptr;
821 if (is_down_event) {
822 if (last_logical_record) {
823 // A key has been pressed that has the exact physical key as a currently
824 // pressed one. This can happen during repeated events.
825 out_event.type = kFlutterKeyEventTypeRepeat;
826 } else {
827 out_event.type = kFlutterKeyEventTypeDown;
828 }
829 character_to_free = event_to_character(event); // Might be null
830 out_event.character = character_to_free;
831 } else { // is_down_event false
832 if (!last_logical_record) {
833 // The physical key has been released before. It might indicate a missed
834 // event due to loss of focus, or multiple keyboards pressed keys with the
835 // same physical key. Ignore the up event.
836 callback(true, user_data);
837 return;
838 } else {
839 out_event.type = kFlutterKeyEventTypeUp;
840 }
841 }
842
843 if (out_event.type != kFlutterKeyEventTypeRepeat) {
844 update_pressing_state(self, physical_key, is_down_event ? logical_key : 0);
845 }
846 possibly_update_lock_bit(self, logical_key, is_down_event);
847 if (is_down_event) {
848 update_mapping_record(self, physical_key, logical_key);
849 }
850 FlKeyEmbedderUserData* response_data =
851 fl_key_embedder_user_data_new(callback, user_data);
852 self->sent_any_events = true;
853 self->send_key_event(&out_event, handle_response, response_data);
854 }
855
856 // Sends a key event to the framework.
857 static void fl_key_embedder_responder_handle_event(
858 FlKeyResponder* responder,
859 FlKeyEvent* event,
860 uint64_t specified_logical_key,
861 FlKeyResponderAsyncCallback callback,
862 gpointer user_data) {
863 FlKeyEmbedderResponder* self = FL_KEY_EMBEDDER_RESPONDER(responder);
864 self->sent_any_events = false;
865 fl_key_embedder_responder_handle_event_impl(
866 responder, event, specified_logical_key, callback, user_data);
867 if (!self->sent_any_events) {
868 self->send_key_event(&kEmptyEvent, nullptr, nullptr);
869 }
870 }
871
872 void fl_key_embedder_responder_sync_modifiers_if_needed(
873 FlKeyEmbedderResponder* responder,
874 guint state,
875 double event_time) {
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 }
888
889 GHashTable* fl_key_embedder_responder_get_pressed_state(
890 FlKeyEmbedderResponder* self) {
891 return self->pressing_records;
892 }
fl_key_embedder_user_data_init
static void fl_key_embedder_user_data_init(FlKeyEmbedderUserData *self)
Definition: fl_key_embedder_responder.cc:106
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
_FlKeyEmbedderResponder::pressing_records
GHashTable * pressing_records
Definition: fl_key_embedder_responder.cc:150
apply_id_plane
static uint64_t apply_id_plane(uint64_t logical_id, uint64_t plane)
Definition: fl_key_embedder_responder.cc:293
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:536
event_to_timestamp
static uint64_t event_to_timestamp(const FlKeyEvent *event)
Definition: fl_key_embedder_responder.cc:319
G_DECLARE_FINAL_TYPE
G_DECLARE_FINAL_TYPE(FlKeyEmbedderUserData, fl_key_embedder_user_data, FL, KEY_EMBEDDER_USER_DATA, GObject)
user_data
FlKeyEvent uint64_t FlKeyResponderAsyncCallback gpointer user_data
Definition: fl_key_embedder_responder.cc:217
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
fl_key_embedder_responder_get_pressed_state
GHashTable * fl_key_embedder_responder_get_pressed_state(FlKeyEmbedderResponder *self)
Definition: fl_key_embedder_responder.cc:889
_FlKeyEmbedderResponder::sent_any_events
bool sent_any_events
Definition: fl_key_embedder_responder.cc:174
FL_TYPE_EMBEDDER_RESPONDER_USER_DATA
#define FL_TYPE_EMBEDDER_RESPONDER_USER_DATA
Definition: fl_key_embedder_responder.cc:203
fl_key_embedder_responder_init
static void fl_key_embedder_responder_init(FlKeyEmbedderResponder *self)
Definition: fl_key_embedder_responder.cc:231
_FlKeyEmbedderResponder::parent_instance
GObject parent_instance
Definition: fl_key_embedder_responder.cc:141
fl_key_embedder_responder.h
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:349
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:514
FL_TYPE_EMBEDDER_USER_DATA
#define FL_TYPE_EMBEDDER_USER_DATA
Definition: fl_key_embedder_responder.cc:83
event_to_logical_key
static uint64_t event_to_logical_key(const FlKeyEvent *event)
Definition: fl_key_embedder_responder.cc:305
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
event
FlKeyEvent * event
Definition: fl_key_embedder_responder.cc:214
_FlKeyEmbedderResponder
Definition: fl_key_embedder_responder.cc:140
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:551
_FlKeyEvent
Definition: fl_key_event.h:31
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:394
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:857
_FlKeyEmbedderUserData::user_data
gpointer user_data
Definition: fl_key_embedder_responder.cc:94
find_stage_by_record
static int find_stage_by_record(bool is_down, bool is_enabled)
Definition: fl_key_embedder_responder.cc:524
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:771
event_to_physical_key
static uint64_t event_to_physical_key(const FlKeyEvent *event)
Definition: fl_key_embedder_responder.cc:297
_FlKeyEmbedderResponder::modifier_bit_to_checked_keys
GHashTable * modifier_bit_to_checked_keys
Definition: fl_key_embedder_responder.cc:182
_FlKeyEmbedderUserData::parent_instance
GObject parent_instance
Definition: fl_key_embedder_responder.cc:91
specified_logical_key
FlKeyEvent uint64_t specified_logical_key
Definition: fl_key_embedder_responder.cc:215
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:729
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:515
_FlKeyEmbedderResponder::logical_key_to_lock_bit
GHashTable * logical_key_to_lock_bit
Definition: fl_key_embedder_responder.cc:196
fl_key_embedder_responder_new
FlKeyEmbedderResponder * fl_key_embedder_responder_new(EmbedderSendKeyEvent send_key_event)
Definition: fl_key_embedder_responder.cc:262
_FlKeyEvent::keycode
guint16 keycode
Definition: fl_key_event.h:37
FL_TYPE_KEY_RESPONDER
#define FL_TYPE_KEY_RESPONDER
Definition: fl_key_responder.h:30
callback
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
Definition: fl_key_embedder_responder.cc:216
event_to_character
static char * event_to_character(const FlKeyEvent *event)
Definition: fl_key_embedder_responder.cc:325
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:513
_FlKeyEmbedderResponder::lock_records
guint lock_records
Definition: fl_key_embedder_responder.cc:155
fl_key_embedder_responder_dispose
static void fl_key_embedder_responder_dispose(GObject *object)
Definition: fl_key_embedder_responder.cc:234
_FlKeyEmbedderUserData::callback
FlKeyResponderAsyncCallback callback
Definition: fl_key_embedder_responder.cc:93
FlKeyResponderAsyncCallback
void(* FlKeyResponderAsyncCallback)(bool handled, gpointer user_data)
Definition: fl_key_responder.h:28
key_mapping.h
G_DEFINE_TYPE
G_DEFINE_TYPE(FlBasicMessageChannelResponseHandle, fl_basic_message_channel_response_handle, G_TYPE_OBJECT) static void fl_basic_message_channel_response_handle_dispose(GObject *object)
Definition: fl_basic_message_channel.cc:37
EmbedderSendKeyEvent
std::function< void(const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *user_data)> EmbedderSendKeyEvent
Definition: fl_key_embedder_responder.h:21
initialize_lock_bit_to_checked_keys
void initialize_lock_bit_to_checked_keys(GHashTable *table)
Definition: key_mapping.g.cc:446
_FlKeyEvent::keyval
guint keyval
Definition: fl_key_event.h:39
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:578
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)) static void fl_key_embedder_responder_handle_event(FlKeyResponder *responder
_FlKeyEmbedderUserData
Definition: fl_key_embedder_responder.cc:90
fl_key_embedder_responder_sync_modifiers_if_needed
void fl_key_embedder_responder_sync_modifiers_if_needed(FlKeyEmbedderResponder *responder, guint state, double event_time)
Definition: fl_key_embedder_responder.cc:872
_FlKeyEmbedderResponder::mapping_records
GHashTable * mapping_records
Definition: fl_key_embedder_responder.cc:164
FL
FL
Definition: fl_binary_messenger.cc:27
lookup_hash_table
static uint64_t lookup_hash_table(GHashTable *table, uint64_t key)
Definition: fl_key_embedder_responder.cc:31
_FlKeyEmbedderResponder::send_key_event
EmbedderSendKeyEvent send_key_event
Definition: fl_key_embedder_responder.cc:143
fl_key_embedder_responder_private.h
self
GdkEvent FlView * self
Definition: fl_view.cc:100
result
GAsyncResult * result
Definition: fl_text_input_plugin.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
kMicrosecondsPerMillisecond
constexpr uint64_t kMicrosecondsPerMillisecond
Definition: fl_key_embedder_responder.cc:14
fl_key_embedder_responder_class_init
static void fl_key_embedder_responder_class_init(FlKeyEmbedderResponderClass *klass)
Definition: fl_key_embedder_responder.cc:225
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:605
fl_key_embedder_user_data_class_init
static void fl_key_embedder_user_data_class_init(FlKeyEmbedderUserDataClass *klass)
Definition: fl_key_embedder_responder.cc:101
FlKeyEmbedderCheckedKey::secondary_logical_key
uint64_t secondary_logical_key
Definition: fl_key_embedder_responder_private.h:40
send_key_event
static void send_key_event(FlTextInputPlugin *plugin, gint keyval, gint state=0)
Definition: fl_text_input_plugin_test.cc:181
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:712
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
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:743
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
handle_response
static void handle_response(bool handled, gpointer user_data)
Definition: fl_key_embedder_responder.cc:340
fl_key_embedder_responder_iface_init
static void fl_key_embedder_responder_iface_init(FlKeyResponderInterface *iface)
Definition: fl_key_embedder_responder.cc:219
value
uint8_t value
Definition: fl_standard_message_codec.cc:41
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:415
FlKeyEmbedderCheckedKey
Definition: fl_key_embedder_responder_private.h:34
update_mapping_record
static void update_mapping_record(FlKeyEmbedderResponder *self, uint64_t physical_key, uint64_t logical_key)
Definition: fl_key_embedder_responder.cc:428
_FlKeyEmbedderResponder::caps_lock_state_logic_inferrence
StateLogicInferrence caps_lock_state_logic_inferrence
Definition: fl_key_embedder_responder.cc:170
gpointer_to_uint64
uint64_t gpointer_to_uint64(gpointer pointer)
Definition: key_mapping.h:13
_FlKeyEmbedderResponder::lock_bit_to_checked_keys
GHashTable * lock_bit_to_checked_keys
Definition: fl_key_embedder_responder.cc:190
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