| Flutter Linux Embedder |

Classes | Typedefs | Functions
fl_key_event.h File Reference
`#include <gdk/gdk.h>`

Go to the source code of this file.

## Classes
struct | _FlKeyEvent

## Typedefs
typedef void(* | FlKeyEventDisposeOrigin) (gpointer origin)
typedef struct _FlKeyEvent | FlKeyEvent

## Functions
FlKeyEvent * | fl_key_event_new_from_gdk_event (GdkEvent *event)
void | fl_key_event_dispose (FlKeyEvent *event)
FlKeyEvent * | fl_key_event_clone (const FlKeyEvent *source)

## Typedef Documentation

## ◆ FlKeyEvent

typedef struct _FlKeyEvent FlKeyEvent

FlKeyEvent: A struct that stores information from GdkEvent.

This is a class only used within the GTK embedding, created by FlView and consumed by FlKeyboardManager. It is not sent to the embedder.

This object contains information from GdkEvent as well as an origin event object, so that Flutter can create an event object in unit tests even after migrating to GDK 4.0 which stops supporting creating GdkEvent.

## ◆ FlKeyEventDisposeOrigin

typedef void(* FlKeyEventDisposeOrigin) (gpointer origin)

FlKeyEventDispose: @origin: the FlKeyEvent::origin to dispose.

The signature for FlKeyEvent::dispose_origin, which frees FlKeyEvent::origin.

Definition at line 17 of file fl_key_event.h.

## Function Documentation

## ◆ fl_key_event_clone()

FlKeyEvent* fl_key_event_clone | ( | const FlKeyEvent * | source | ) |

Definition at line 43 of file fl_key_event.cc.

43 {
44 FlKeyEvent* new_event = g_new(FlKeyEvent, 1);
45 *new_event = *event;
46 new_event->string = g_strdup(event->string);
47 return new_event;
48 }

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 33 of file fl_key_event.cc.

33 {
34 if (event->string != nullptr) {
35 g_free(const_cast<char*>(event->string));
36 }
37 if (event->dispose_origin != nullptr) {
38 event->dispose_origin(event->origin);
39 }
40 g_free(event);
41 }

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(raw_event != nullptr, nullptr);
14 GdkEventKey* event = reinterpret_cast<GdkEventKey*>(raw_event);
15 GdkEventType type = event->type;
16 g_return_val_if_fail(type == GDK_KEY_PRESS || type == GDK_KEY_RELEASE,
17 nullptr);
18 FlKeyEvent* result = g_new(FlKeyEvent, 1);
19
20 result->time = event->time;
21 result->is_press = type == GDK_KEY_PRESS;
22 result->keycode = event->hardware_keycode;
23 result->keyval = event->keyval;
24 result->state = event->state;
25 result->string = g_strdup(event->string);
26 result->group = event->group;
27 result->origin = event;
28 result->dispose_origin = dispose_origin_from_gdk_event;
29
30 return result;
31 }

References dispose_origin_from_gdk_event(), event, result, 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
_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