| 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"`

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 53 of file fl_keyboard_handler.cc.

53 {
54 G_OBJECT_CLASS(klass)->dispose = fl_keyboard_handler_dispose;
55 }

References fl_keyboard_handler_dispose().

## ◆ fl_keyboard_handler_dispose()

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

Definition at line 44 of file fl_keyboard_handler.cc.

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

Referenced by fl_keyboard_handler_class_init().

## ◆ fl_keyboard_handler_init()

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

Definition at line 60 of file fl_keyboard_handler.cc.

60 {}

## ◆ 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 62 of file fl_keyboard_handler.cc.

64 {
65 FlKeyboardHandler* self = FL_KEYBOARD_HANDLER(
66 g_object_new(fl_keyboard_handler_get_type(), nullptr));
67
68 self->keyboard_manager = FL_KEYBOARD_MANAGER(g_object_ref(keyboard_manager));
69
70 // Setup the flutter/keyboard channel.
71 self->channel =
72 fl_keyboard_channel_new(messenger, &keyboard_channel_vtable, self);
73 return self;
74 }

References fl_keyboard_channel_new(), and keyboard_channel_vtable.

Referenced by init_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 21 of file fl_keyboard_handler.cc.

21 {
22 FlKeyboardHandler* self = FL_KEYBOARD_HANDLER(user_data);
23
24 FlValue* result = fl_value_new_map();
25
26 GHashTable* pressing_records =
27 fl_keyboard_manager_get_pressed_state(self->keyboard_manager);
28
29 g_hash_table_foreach(
30 pressing_records,
31 [](gpointer key, gpointer value, gpointer user_data) {
32 int64_t physical_key = reinterpret_cast<int64_t>(key);
33 int64_t logical_key = reinterpret_cast<int64_t>(value);
34 FlValue* fl_value_map = reinterpret_cast<FlValue*>(user_data);
35
36 fl_value_set_take(fl_value_map, fl_value_new_int(physical_key),
37 fl_value_new_int(logical_key));
38 },
39 result);
40
41 return result;
42 }

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

## Variable Documentation

## ◆ keyboard_channel_vtable

FlKeyboardChannelVTable keyboard_channel_vtable
| static

Initial value:
= {
.get_keyboard_state = get_keyboard_state}

Definition at line 57 of file fl_keyboard_handler.cc.

Referenced by fl_keyboard_handler_new().

FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
keyboard_channel_vtable
static FlKeyboardChannelVTable keyboard_channel_vtable
Definition: fl_keyboard_handler.cc:57
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
get_keyboard_state
static FlValue * get_keyboard_state(gpointer user_data)
Definition: fl_keyboard_handler.cc:21
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
fl_value_new_map
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition: fl_value.cc:366
fl_keyboard_channel_new
FlKeyboardChannel * fl_keyboard_channel_new(FlBinaryMessenger *messenger, FlKeyboardChannelVTable *vtable, gpointer user_data)
Definition: fl_keyboard_channel.cc:65
fl_keyboard_manager_get_pressed_state
GHashTable * fl_keyboard_manager_get_pressed_state(FlKeyboardManager *self)
Definition: fl_keyboard_manager.cc:566
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
fl_keyboard_handler_dispose
static void fl_keyboard_handler_dispose(GObject *object)
Definition: fl_keyboard_handler.cc:44