Flutter Linux Embedder
fl_key_event.cc File Reference

Go to the source code of this file.

Functions

FlKeyEventfl_key_event_new_from_gdk_event (GdkEvent *event)
 
void fl_key_event_dispose (FlKeyEvent *event)
 
FlKeyEventfl_key_event_clone (const FlKeyEvent *event)
 

Function Documentation

◆ fl_key_event_clone()

FlKeyEvent* fl_key_event_clone ( const FlKeyEvent event)

Definition at line 39 of file fl_key_event.cc.

39  {
40  FlKeyEvent* new_event = g_new(FlKeyEvent, 1);
41  *new_event = *event;
42  return new_event;
43 }

References event.

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

32  {
33  if (event->origin != nullptr) {
34  gdk_event_free(event->origin);
35  }
36  g_free(event);
37 }

References event, and _FlKeyEvent::origin.

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

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

References event, result, state, and type.

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
type
uint8_t type
Definition: fl_standard_message_codec_test.cc:1115
_FlKeyEvent::origin
GdkEvent * origin
Definition: fl_key_event.h:36
_FlKeyEvent
Definition: fl_key_event.h:22
state
AtkStateType state
Definition: fl_accessible_node.cc:10
result
GAsyncResult * result
Definition: fl_text_input_plugin.cc:106