| Flutter Linux Embedder |

Functions
fl_key_event.cc File Reference
`#include "flutter/shell/platform/linux/fl_key_event.h"`

Go to the source code of this file.

## Functions
static void | dispose_origin_from_gdk_event (gpointer origin)
FlKeyEvent * | fl_key_event_new_from_gdk_event (GdkEvent *event)
void | fl_key_event_dispose (FlKeyEvent *event)
FlKeyEvent * | fl_key_event_clone (const FlKeyEvent *event)

## Function Documentation

## ◆ dispose_origin_from_gdk_event()

static void dispose_origin_from_gdk_event | ( | gpointer | origin | ) |
| static

Definition at line 7 of file fl_key_event.cc.

7 {
8 g_return_if_fail(origin != nullptr);
9 gdk_event_free(reinterpret_cast<GdkEvent*>(origin));
10 }

Referenced by fl_key_event_new_from_gdk_event().

## ◆ fl_key_event_clone()

FlKeyEvent* fl_key_event_clone | ( | const FlKeyEvent * | event | ) |

Definition at line 49 of file fl_key_event.cc.

49 {
50 FlKeyEvent* new_event = g_new(FlKeyEvent, 1);
51 *new_event = *event;
52 new_event->string = g_strdup(event->string);
53 return new_event;
54 }

References event, and _FlKeyEvent::string.

## ◆ fl_key_event_dispose()

void fl_key_event_dispose | ( | FlKeyEvent * | event | ) |

fl_key_event_dispose: @event: the event to dispose.

Properly disposes the content of event and then the pointer.

Definition at line 39 of file fl_key_event.cc.

39 {
40 if (event->string != nullptr) {
41 g_free(const_cast<char*>(event->string));
42 }
43 if (event->dispose_origin != nullptr) {
44 event->dispose_origin(event->origin);
45 }
46 g_free(event);
47 }

References _FlKeyEvent::dispose_origin, event, _FlKeyEvent::origin, and _FlKeyEvent::string.

Referenced by fl_keyboard_pending_event_dispose(), fl_view_keyboard_delegate_iface_init(), and send_key_event().

## ◆ fl_key_event_new_from_gdk_event()

FlKeyEvent* fl_key_event_new_from_gdk_event | ( | GdkEvent * | event | ) |

fl_key_event_new_from_gdk_event: @event: the #GdkEvent this FlKeyEvent is based on. The event must be a #GdkEventKey, and will be destroyed by fl_key_event_dispose.

Create a new FlKeyEvent based on a #GdkEvent.

Returns: a new FlKeyEvent. Must be freed with fl_key_event_dispose.

Definition at line 12 of file fl_key_event.cc.

12 {
13 g_return_val_if_fail(event != nullptr, nullptr);
14 GdkEventType type = gdk_event_get_event_type(event);
15 g_return_val_if_fail(type == GDK_KEY_PRESS || type == GDK_KEY_RELEASE,
16 nullptr);
17 FlKeyEvent* result = g_new(FlKeyEvent, 1);
18
19 guint16 keycode = 0;
20 gdk_event_get_keycode(event, &keycode);
21 guint keyval = 0;
22 gdk_event_get_keyval(event, &keyval);
23 GdkModifierType state = static_cast<GdkModifierType>(0);
24 gdk_event_get_state(event, &state);
25
26 result->time = gdk_event_get_time(event);
27 result->is_press = type == GDK_KEY_PRESS;
28 result->keycode = keycode;
29 result->keyval = keyval;
30 result->state = state;
31 result->string = g_strdup(event->key.string);
32 result->group = event->key.group;
33 result->origin = event;
34 result->dispose_origin = dispose_origin_from_gdk_event;
35
36 return result;
37 }

References dispose_origin_from_gdk_event(), event, result, state, and _FlKeyEvent::string.

Referenced by fl_view_key_press_event(), fl_view_key_release_event(), and send_key_event().

event
FlKeyEvent * event
Definition: fl_key_channel_responder.cc:118
_FlKeyEvent::origin
gpointer origin
Definition: fl_key_event.h:52
_FlKeyEvent
Definition: fl_key_event.h:31
state
AtkStateType state
Definition: fl_accessible_node.cc:10
_FlValue::type
FlValueType type
Definition: fl_value.cc:12
_FlKeyEvent::dispose_origin
FlKeyEventDisposeOrigin dispose_origin
Definition: fl_key_event.h:56
result
GAsyncResult * result
Definition: fl_text_input_plugin.cc:106
dispose_origin_from_gdk_event
static void dispose_origin_from_gdk_event(gpointer origin)
Definition: fl_key_event.cc:7
_FlKeyEvent::string
const char * string
Definition: fl_key_event.h:47