| Flutter Linux Embedder |

Enumerations | Functions
fl_key_event_channel.h File Reference
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h"`

Go to the source code of this file.

## Enumerations
enum | FlKeyEventType { FL_KEY_EVENT_TYPE_KEYUP , FL_KEY_EVENT_TYPE_KEYDOWN }

## Functions
G_BEGIN_DECLS | G_DECLARE_FINAL_TYPE (FlKeyEventChannel, fl_key_event_channel, FL, KEY_EVENT_CHANNEL, GObject)
FlKeyEventChannel * | fl_key_event_channel_new (FlBinaryMessenger *messenger)
void | fl_key_event_channel_send (FlKeyEventChannel *channel, FlKeyEventType type, int64_t scan_code, int64_t key_code, int64_t modifiers, int64_t unicode_scarlar_values, int64_t specified_logical_key, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
gboolean | fl_key_event_channel_send_finish (GObject *object, GAsyncResult *result, gboolean *handled, GError **error)

## Enumeration Type Documentation

## ◆ FlKeyEventType

enum FlKeyEventType

FlKeyEventChannel:

#FlKeyEventChannel is a channel that implements the shell side of SystemChannels.keyEvent from the Flutter services library.

Enumerator
FL_KEY_EVENT_TYPE_KEYUP |
FL_KEY_EVENT_TYPE_KEYDOWN |

Definition at line 25 of file fl_key_event_channel.h.

25 {
26 FL_KEY_EVENT_TYPE_KEYUP,
27 FL_KEY_EVENT_TYPE_KEYDOWN,
28 } FlKeyEventType;
FlKeyEventType
FlKeyEventType
Definition: fl_key_event_channel.h:25
FL_KEY_EVENT_TYPE_KEYDOWN
@ FL_KEY_EVENT_TYPE_KEYDOWN
Definition: fl_key_event_channel.h:27
FL_KEY_EVENT_TYPE_KEYUP
@ FL_KEY_EVENT_TYPE_KEYUP
Definition: fl_key_event_channel.h:26

## Function Documentation

## ◆ fl_key_event_channel_new()

FlKeyEventChannel* fl_key_event_channel_new | ( | FlBinaryMessenger * | messenger | ) |

fl_key_event_channel_new: @messenger: an #FlBinaryMessenger

Creates a new channel that implements SystemChannels.keyEvent from the Flutter services library.

Returns: a new #FlKeyEventChannel.

Definition at line 50 of file fl_key_event_channel.cc.

50 {
51 g_return_val_if_fail(FL_IS_BINARY_MESSENGER(messenger), nullptr);
52
53 FlKeyEventChannel* self = FL_KEY_EVENT_CHANNEL(
54 g_object_new(fl_key_event_channel_get_type(), nullptr));
55
56 g_autoptr(FlJsonMessageCodec) codec = fl_json_message_codec_new();
57 self->channel = fl_basic_message_channel_new(messenger, kChannelName,
58 FL_MESSAGE_CODEC(codec));
59
60 return self;
61 }
fl_basic_message_channel_new
G_MODULE_EXPORT FlBasicMessageChannel * fl_basic_message_channel_new(FlBinaryMessenger *messenger, const gchar *name, FlMessageCodec *codec)
Definition: fl_basic_message_channel.cc:154
fl_json_message_codec_new
G_MODULE_EXPORT FlJsonMessageCodec * fl_json_message_codec_new()
Definition: fl_json_message_codec.cc:306
kChannelName
static constexpr char kChannelName[]
Definition: fl_key_event_channel.cc:10

References fl_basic_message_channel_new(), fl_json_message_codec_new(), and kChannelName.

Referenced by fl_key_channel_responder_new().

## ◆ fl_key_event_channel_send()

void fl_key_event_channel_send | ( | FlKeyEventChannel * | channel,
|  | FlKeyEventType | type,
|  | int64_t | scan_code,
|  | int64_t | key_code,
|  | int64_t | modifiers,
|  | int64_t | unicode_scarlar_values,
|  | int64_t | specified_logical_key,
|  | GCancellable * | cancellable,
|  | GAsyncReadyCallback | callback,
|  | gpointer | user_data
| ) |  |

fl_key_event_channel_send: @channel: an #FlKeyEventChannel @type: event type. @scan_code: scan code. @key_code: key code. @modifiers: modifiers. @unicode_scarlar_values: @specified_logical_key: @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the method returns. @user_data: (closure): user data to pass to @callback.

Send a key event to the platform.

Definition at line 63 of file fl_key_event_channel.cc.

72 {
73 g_return_if_fail(FL_IS_KEY_EVENT_CHANNEL(self));
74
75 const gchar* type_string;
76 switch (type) {
77 case FL_KEY_EVENT_TYPE_KEYUP:
78 type_string = kTypeValueUp;
79 break;
80 case FL_KEY_EVENT_TYPE_KEYDOWN:
81 type_string = kTypeValueDown;
82 break;
83 default:
84 g_assert_not_reached();
85 }
86
87 g_autoptr(FlValue) message = fl_value_new_map();
88 fl_value_set_string_take(message, kTypeKey, fl_value_new_string(type_string));
89 fl_value_set_string_take(message, kKeymapKey,
90 fl_value_new_string(kLinuxKeymap));
91 fl_value_set_string_take(message, kScanCodeKey, fl_value_new_int(scan_code));
92 fl_value_set_string_take(message, kToolkitKey,
93 fl_value_new_string(kGtkToolkit));
94 fl_value_set_string_take(message, kKeyCodeKey, fl_value_new_int(key_code));
95 fl_value_set_string_take(message, kModifiersKey, fl_value_new_int(modifiers));
96 if (unicode_scalar_values != kUnicodeScalarValuesUnset) {
97 fl_value_set_string_take(message, kUnicodeScalarValuesKey,
98 fl_value_new_int(unicode_scalar_values));
99 }
100 if (specified_logical_key != kSpecifiedLogicalKeyUnset) {
101 fl_value_set_string_take(message, kSpecifiedLogicalKey,
102 fl_value_new_int(specified_logical_key));
103 }
104 fl_basic_message_channel_send(self->channel, message, cancellable, callback,
105 user_data);
106 }
fl_basic_message_channel_send
G_MODULE_EXPORT void fl_basic_message_channel_send(FlBasicMessageChannel *self, FlValue *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_basic_message_channel.cc:226
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
kScanCodeKey
static constexpr char kScanCodeKey[]
Definition: fl_key_event_channel.cc:16
kToolkitKey
static constexpr char kToolkitKey[]
Definition: fl_key_event_channel.cc:18
kSpecifiedLogicalKeyUnset
static constexpr int64_t kSpecifiedLogicalKeyUnset
Definition: fl_key_event_channel.cc:26
kTypeKey
static constexpr char kTypeKey[]
Definition: fl_key_event_channel.cc:11
kGtkToolkit
static constexpr char kGtkToolkit[]
Definition: fl_key_event_channel.cc:22
kUnicodeScalarValuesUnset
static constexpr int64_t kUnicodeScalarValuesUnset
Definition: fl_key_event_channel.cc:25
kModifiersKey
static constexpr char kModifiersKey[]
Definition: fl_key_event_channel.cc:17
kSpecifiedLogicalKey
static constexpr char kSpecifiedLogicalKey[]
Definition: fl_key_event_channel.cc:19
kLinuxKeymap
static constexpr char kLinuxKeymap[]
Definition: fl_key_event_channel.cc:23
kKeyCodeKey
static constexpr char kKeyCodeKey[]
Definition: fl_key_event_channel.cc:15
kUnicodeScalarValuesKey
static constexpr char kUnicodeScalarValuesKey[]
Definition: fl_key_event_channel.cc:20
kKeymapKey
static constexpr char kKeymapKey[]
Definition: fl_key_event_channel.cc:14
kTypeValueUp
static constexpr char kTypeValueUp[]
Definition: fl_key_event_channel.cc:12
kTypeValueDown
static constexpr char kTypeValueDown[]
Definition: fl_key_event_channel.cc:13
type
uint8_t type
Definition: fl_standard_message_codec_test.cc:1117
fl_value_set_string_take
G_MODULE_EXPORT void fl_value_set_string_take(FlValue *self, const gchar *key, FlValue *value)
Definition: fl_value.cc:650
fl_value_new_string
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:276
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

References fl_basic_message_channel_send(), FL_KEY_EVENT_TYPE_KEYDOWN, FL_KEY_EVENT_TYPE_KEYUP, fl_value_new_int(), fl_value_new_map(), fl_value_new_string(), fl_value_set_string_take(), kGtkToolkit, kKeyCodeKey, kKeymapKey, kLinuxKeymap, kModifiersKey, kScanCodeKey, kSpecifiedLogicalKey, kSpecifiedLogicalKeyUnset, kToolkitKey, kTypeKey, kTypeValueDown, kTypeValueUp, kUnicodeScalarValuesKey, kUnicodeScalarValuesUnset, type, and user_data.

Referenced by fl_key_channel_responder_handle_event().

## ◆ fl_key_event_channel_send_finish()

gboolean fl_key_event_channel_send_finish | ( | GObject * | object,
|  | GAsyncResult * | result,
|  | gboolean * | handled,
|  | GError ** | error
| ) |  |

fl_key_event_channel_send_finish: @object:

Returns
  : a #GAsyncResult. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_key_event_channel_send().

Returns: TRUE on success.

Definition at line 108 of file fl_key_event_channel.cc.

111 {
112 g_autoptr(FlValue) message = fl_basic_message_channel_send_finish(
113 FL_BASIC_MESSAGE_CHANNEL(object), result, error);
114 if (message == nullptr) {
115 return FALSE;
116 }
117
118 FlValue* handled_value = fl_value_lookup_string(message, "handled");
119 *handled = fl_value_get_bool(handled_value);
120
121 return TRUE;
122 }
fl_basic_message_channel_send_finish
G_MODULE_EXPORT FlValue * fl_basic_message_channel_send_finish(FlBasicMessageChannel *self, GAsyncResult *result, GError **error)
Definition: fl_basic_message_channel.cc:253
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
fl_value_lookup_string
G_MODULE_EXPORT FlValue * fl_value_lookup_string(FlValue *self, const gchar *key)
Definition: fl_value.cc:811
fl_value_get_bool
G_MODULE_EXPORT bool fl_value_get_bool(FlValue *self)
Definition: fl_value.cc:661

References error, fl_basic_message_channel_send_finish(), fl_value_get_bool(), fl_value_lookup_string(), and TRUE.

Referenced by handle_response().

## ◆ G_DECLARE_FINAL_TYPE()

G_BEGIN_DECLS G_DECLARE_FINAL_TYPE | ( | FlKeyEventChannel | ,
|  | fl_key_event_channel | ,
|  | FL | ,
|  | KEY_EVENT_CHANNEL | ,
|  | GObject |
| ) |  |