| Flutter Linux Embedder |

Classes | Functions | Variables
fl_key_event_channel.cc File Reference
`#include "flutter/shell/platform/linux/fl_key_event_channel.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_basic_message_channel.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_json_message_codec.h"`

Go to the source code of this file.

## Classes
struct | _FlKeyEventChannel

## Functions
static void | fl_key_event_channel_dispose (GObject *object)
static void | fl_key_event_channel_class_init (FlKeyEventChannelClass *klass)
static void | fl_key_event_channel_init (FlKeyEventChannel *self)
FlKeyEventChannel * | fl_key_event_channel_new (FlBinaryMessenger *messenger)
void | fl_key_event_channel_send (FlKeyEventChannel *self, FlKeyEventType type, int64_t scan_code, int64_t key_code, int64_t modifiers, int64_t unicode_scalar_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)

## Variables
static constexpr char | kChannelName [] = "flutter/keyevent"
static constexpr char | kTypeKey [] = "type"
static constexpr char | kTypeValueUp [] = "keyup"
static constexpr char | kTypeValueDown [] = "keydown"
static constexpr char | kKeymapKey [] = "keymap"
static constexpr char | kKeyCodeKey [] = "keyCode"
static constexpr char | kScanCodeKey [] = "scanCode"
static constexpr char | kModifiersKey [] = "modifiers"
static constexpr char | kToolkitKey [] = "toolkit"
static constexpr char | kSpecifiedLogicalKey [] = "specifiedLogicalKey"
static constexpr char | kUnicodeScalarValuesKey [] = "unicodeScalarValues"
static constexpr char | kGtkToolkit [] = "gtk"
static constexpr char | kLinuxKeymap [] = "linux"
static constexpr int64_t | kUnicodeScalarValuesUnset = 0
static constexpr int64_t | kSpecifiedLogicalKeyUnset = 0

## Function Documentation

## ◆ fl_key_event_channel_class_init()

static void fl_key_event_channel_class_init | ( | FlKeyEventChannelClass * | klass | ) |
| static

Definition at line 44 of file fl_key_event_channel.cc.

44 {
45 G_OBJECT_CLASS(klass)->dispose = fl_key_event_channel_dispose;
46 }
fl_key_event_channel_dispose
static void fl_key_event_channel_dispose(GObject *object)
Definition: fl_key_event_channel.cc:36

References fl_key_event_channel_dispose().

## ◆ fl_key_event_channel_dispose()

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

Definition at line 36 of file fl_key_event_channel.cc.

36 {
37 FlKeyEventChannel* self = FL_KEY_EVENT_CHANNEL(object);
38
39 g_clear_object(&self->channel);
40
41 G_OBJECT_CLASS(fl_key_event_channel_parent_class)->dispose(object);
42 }

Referenced by fl_key_event_channel_class_init().

## ◆ fl_key_event_channel_init()

static void fl_key_event_channel_init | ( | FlKeyEventChannel * | self | ) |
| static

Definition at line 48 of file fl_key_event_channel.cc.

48 {}

## ◆ 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 }
g_autoptr
g_autoptr(FlEngine) engine
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(), g_autoptr(), 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 }
message
const char * message
Definition: fl_accessibility_handler.cc:21
user_data
const char FlTextDirection FlAssertiveness gpointer user_data
Definition: fl_accessibility_handler.cc:24
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
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
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
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(), g_autoptr(), kGtkToolkit, kKeyCodeKey, kKeymapKey, kLinuxKeymap, kModifiersKey, kScanCodeKey, kSpecifiedLogicalKey, kSpecifiedLogicalKeyUnset, kToolkitKey, kTypeKey, kTypeValueDown, kTypeValueUp, kUnicodeScalarValuesKey, kUnicodeScalarValuesUnset, message, 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. If `error` is not NULL, `*error` must be initialized (typically NULL, but an error from a previous call using GLib error handling is explicitly valid).

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_compositor_software.cc:68
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(), g_autoptr(), message, and TRUE.

Referenced by handle_response().

## Variable Documentation

## ◆ kChannelName

constexpr char kChannelName[] = "flutter/keyevent"
| static constexpr

Definition at line 10 of file fl_key_event_channel.cc.

Referenced by fl_key_event_channel_new().

## ◆ kGtkToolkit

constexpr char kGtkToolkit[] = "gtk"
| static constexpr

Definition at line 22 of file fl_key_event_channel.cc.

Referenced by fl_key_event_channel_send().

## ◆ kKeyCodeKey

constexpr char kKeyCodeKey[] = "keyCode"
| static constexpr

Definition at line 15 of file fl_key_event_channel.cc.

Referenced by fl_key_event_channel_send().

## ◆ kKeymapKey

constexpr char kKeymapKey[] = "keymap"
| static constexpr

Definition at line 14 of file fl_key_event_channel.cc.

Referenced by fl_key_event_channel_send().

## ◆ kLinuxKeymap

constexpr char kLinuxKeymap[] = "linux"
| static constexpr

Definition at line 23 of file fl_key_event_channel.cc.

Referenced by fl_key_event_channel_send().

## ◆ kModifiersKey

constexpr char kModifiersKey[] = "modifiers"
| static constexpr

Definition at line 17 of file fl_key_event_channel.cc.

Referenced by fl_key_event_channel_send().

## ◆ kScanCodeKey

constexpr char kScanCodeKey[] = "scanCode"
| static constexpr

Definition at line 16 of file fl_key_event_channel.cc.

Referenced by fl_key_event_channel_send().

## ◆ kSpecifiedLogicalKey

constexpr char kSpecifiedLogicalKey[] = "specifiedLogicalKey"
| static constexpr

Definition at line 19 of file fl_key_event_channel.cc.

Referenced by fl_key_event_channel_send().

## ◆ kSpecifiedLogicalKeyUnset

constexpr int64_t kSpecifiedLogicalKeyUnset = 0
| static constexpr

Definition at line 26 of file fl_key_event_channel.cc.

Referenced by fl_key_event_channel_send().

## ◆ kToolkitKey

constexpr char kToolkitKey[] = "toolkit"
| static constexpr

Definition at line 18 of file fl_key_event_channel.cc.

Referenced by fl_key_event_channel_send().

## ◆ kTypeKey

constexpr char kTypeKey[] = "type"
| static constexpr

Definition at line 11 of file fl_key_event_channel.cc.

Referenced by fl_key_event_channel_send().

## ◆ kTypeValueDown

constexpr char kTypeValueDown[] = "keydown"
| static constexpr

Definition at line 13 of file fl_key_event_channel.cc.

Referenced by fl_key_event_channel_send().

## ◆ kTypeValueUp

constexpr char kTypeValueUp[] = "keyup"
| static constexpr

Definition at line 12 of file fl_key_event_channel.cc.

Referenced by fl_key_event_channel_send().

## ◆ kUnicodeScalarValuesKey

constexpr char kUnicodeScalarValuesKey[] = "unicodeScalarValues"
| static constexpr

Definition at line 20 of file fl_key_event_channel.cc.

Referenced by fl_key_event_channel_send().

## ◆ kUnicodeScalarValuesUnset

constexpr int64_t kUnicodeScalarValuesUnset = 0
| static constexpr

Definition at line 25 of file fl_key_event_channel.cc.

Referenced by fl_key_event_channel_send().