| Flutter Linux Embedder |

Classes | Functions | Variables
fl_keyboard_handler.cc File Reference
`#include "flutter/shell/platform/linux/fl_keyboard_handler.h"`
`#include "flutter/shell/platform/linux/fl_keyboard_channel.h"`
`#include "flutter/shell/platform/linux/key_mapping.h"`

Go to the source code of this file.

## Classes
struct | _FlKeyboardHandler

## Functions
| G_DEFINE_TYPE (FlKeyboardHandler, fl_keyboard_handler, G_TYPE_OBJECT)
static FlValue * | get_keyboard_state (gpointer user_data)
static void | fl_keyboard_handler_dispose (GObject *object)
static void | fl_keyboard_handler_class_init (FlKeyboardHandlerClass *klass)
static void | fl_keyboard_handler_init (FlKeyboardHandler *self)
FlKeyboardHandler * | fl_keyboard_handler_new (FlBinaryMessenger *messenger, FlKeyboardManager *keyboard_manager)

## Variables
static FlKeyboardChannelVTable | keyboard_channel_vtable

## Function Documentation

## ◆ fl_keyboard_handler_class_init()

static void fl_keyboard_handler_class_init | ( | FlKeyboardHandlerClass * | klass | ) |
| static

Definition at line 54 of file fl_keyboard_handler.cc.

54 {
55 G_OBJECT_CLASS(klass)->dispose = fl_keyboard_handler_dispose;
56 }
fl_keyboard_handler_dispose
static void fl_keyboard_handler_dispose(GObject *object)
Definition: fl_keyboard_handler.cc:45

References fl_keyboard_handler_dispose().

## ◆ fl_keyboard_handler_dispose()

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

Definition at line 45 of file fl_keyboard_handler.cc.

45 {
46 FlKeyboardHandler* self = FL_KEYBOARD_HANDLER(object);
47
48 g_clear_object(&self->keyboard_manager);
49 g_clear_object(&self->channel);
50
51 G_OBJECT_CLASS(fl_keyboard_handler_parent_class)->dispose(object);
52 }

Referenced by fl_keyboard_handler_class_init().

## ◆ fl_keyboard_handler_init()

static void fl_keyboard_handler_init | ( | FlKeyboardHandler * | self | ) |
| static

Definition at line 61 of file fl_keyboard_handler.cc.

61 {}

## ◆ fl_keyboard_handler_new()

FlKeyboardHandler* fl_keyboard_handler_new | ( | FlBinaryMessenger * | messenger,
|  | FlKeyboardManager * | keyboard_manager
| ) |  |

FlKeyboardHandler:

Provides the channel to receive keyboard requests from the Dart code. fl_keyboard_handler_new: @messenger: a #FlBinaryMessenger. @keyboard_manager: a #FlKeyboardManager.

Create a new #FlKeyboardHandler.

Returns: a new #FlKeyboardHandler.

Definition at line 63 of file fl_keyboard_handler.cc.

65 {
66 FlKeyboardHandler* self = FL_KEYBOARD_HANDLER(
67 g_object_new(fl_keyboard_handler_get_type(), nullptr));
68
69 self->keyboard_manager = FL_KEYBOARD_MANAGER(g_object_ref(keyboard_manager));
70 self->channel =
71 fl_keyboard_channel_new(messenger, &keyboard_channel_vtable, self);
72
73 return self;
74 }
fl_keyboard_channel_new
FlKeyboardChannel * fl_keyboard_channel_new(FlBinaryMessenger *messenger, FlKeyboardChannelVTable *vtable, gpointer user_data)
Definition: fl_keyboard_channel.cc:65
keyboard_channel_vtable
static FlKeyboardChannelVTable keyboard_channel_vtable
Definition: fl_keyboard_handler.cc:58

References fl_keyboard_channel_new(), and keyboard_channel_vtable.

Referenced by setup_keyboard(), and TEST().

## ◆ G_DEFINE_TYPE()

G_DEFINE_TYPE | ( | FlKeyboardHandler | ,
|  | fl_keyboard_handler | ,
|  | G_TYPE_OBJECT |
| ) |  |

## ◆ get_keyboard_state()

static FlValue* get_keyboard_state | ( | gpointer | user_data | ) |
| static

Definition at line 22 of file fl_keyboard_handler.cc.

22 {
23 FlKeyboardHandler* self = FL_KEYBOARD_HANDLER(user_data);
24
25 FlValue* result = fl_value_new_map();
26
27 GHashTable* pressing_records =
28 fl_keyboard_manager_get_pressed_state(self->keyboard_manager);
29
30 g_hash_table_foreach(
31 pressing_records,
32 [](gpointer key, gpointer value, gpointer user_data) {
33 int64_t physical_key = gpointer_to_uint64(key);
34 int64_t logical_key = gpointer_to_uint64(value);
35 FlValue* fl_value_map = reinterpret_cast<FlValue*>(user_data);
36
37 fl_value_set_take(fl_value_map, fl_value_new_int(physical_key),
38 fl_value_new_int(logical_key));
39 },
40 result);
41
42 return result;
43 }
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
fl_keyboard_manager_get_pressed_state
GHashTable * fl_keyboard_manager_get_pressed_state(FlKeyboardManager *self)
Definition: fl_keyboard_manager.cc:435
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
fl_value_set_take
G_MODULE_EXPORT void fl_value_set_take(FlValue *self, FlValue *key, FlValue *value)
Definition: fl_value.cc:618
fl_value_new_int
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition: fl_value.cc:262
fl_value_new_map
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition: fl_value.cc:366
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
gpointer_to_uint64
uint64_t gpointer_to_uint64(gpointer pointer)
Definition: key_mapping.h:13

References fl_keyboard_manager_get_pressed_state(), fl_value_new_int(), fl_value_new_map(), fl_value_set_take(), gpointer_to_uint64(), user_data, and value.

## Variable Documentation

## ◆ keyboard_channel_vtable

FlKeyboardChannelVTable keyboard_channel_vtable
| static

Initial value:
= {
.get_keyboard_state = get_keyboard_state}
get_keyboard_state
static FlValue * get_keyboard_state(gpointer user_data)
Definition: fl_keyboard_handler.cc:22

Definition at line 58 of file fl_keyboard_handler.cc.

Referenced by fl_keyboard_handler_new().