Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
fl_key_mapping.h
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#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_MAPPING_H_
6#define FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_MAPPING_H_
7
8#include <gdk/gdk.h>
9#include <cinttypes>
10#include <map>
11#include <vector>
12
13/**
14 * FlKeyEmbedderCheckedKey:
15 *
16 * The information for a key that #FlKeyEmbedderResponder should keep state
17 * synchronous on. For every record of #FlKeyEmbedderCheckedKey, the responder
18 * will check the #GdkEvent::state and the internal state, and synchronize
19 * events if they don't match.
20 *
21 * #FlKeyEmbedderCheckedKey can synchronize pressing states (such as
22 * whether ControlLeft is pressed) or lock states (such as whether CapsLock
23 * is enabled).
24 *
25 * #FlKeyEmbedderCheckedKey has a "primary key". For pressing states, the
26 * primary key is the left of the modifiers. For lock states, the primary
27 * key is the key.
28 *
29 * #FlKeyEmbedderCheckedKey may also have a "secondary key". It is only
30 * available to pressing states, which is the right of the modifiers.
31 */
32typedef struct {
33 // The physical key for the primary key.
35 // The logical key for the primary key.
37 // The logical key for the secondary key.
39 // Whether this key is CapsLock. CapsLock uses a different event model in GDK
40 // and needs special treatment.
43
44inline uint64_t gpointer_to_uint64(gpointer pointer) {
45 return pointer == nullptr ? 0 : reinterpret_cast<uint64_t>(pointer);
46}
47
48inline gpointer uint64_to_gpointer(uint64_t number) {
49 return reinterpret_cast<gpointer>(number);
50}
51
52// Maps XKB specific key code values to Flutter's physical key code values.
53extern std::map<uint64_t, uint64_t> xkb_to_physical_key_map;
54
55// Maps GDK keyval values to Flutter's logical key code values.
56extern std::map<uint64_t, uint64_t> gtk_keyval_to_logical_key_map;
57
58void initialize_modifier_bit_to_checked_keys(GHashTable* table);
59
60void initialize_lock_bit_to_checked_keys(GHashTable* table);
61
62// Mask for the 32-bit value portion of the key code.
63extern const uint64_t kValueMask;
64
65// The plane value for keys which have a Unicode representation.
66extern const uint64_t kUnicodePlane;
67
68// The plane value for the private keys defined by the GTK embedding.
69extern const uint64_t kGtkPlane;
70
71typedef struct {
72 // The key code for a key that prints `keyChar` in the US keyboard layout.
73 uint16_t keycode;
74
75 // The logical key for this key.
76 uint64_t logical_key;
77
78 // If the goal is mandatory, the keyboard handler will make sure to find a
79 // logical key for this character, falling back to the US keyboard layout.
82
83// NOLINTNEXTLINE(readability-identifier-naming)
84extern const std::vector<LayoutGoal> layout_goals;
85
86#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_MAPPING_H_
std::map< uint64_t, uint64_t > xkb_to_physical_key_map
void initialize_modifier_bit_to_checked_keys(GHashTable *table)
gpointer uint64_to_gpointer(uint64_t number)
const uint64_t kValueMask
const uint64_t kGtkPlane
void initialize_lock_bit_to_checked_keys(GHashTable *table)
const std::vector< LayoutGoal > layout_goals
const uint64_t kUnicodePlane
std::map< uint64_t, uint64_t > gtk_keyval_to_logical_key_map
uint64_t gpointer_to_uint64(gpointer pointer)
uint16_t keycode
uint64_t logical_key