| Flutter Linux Embedder |

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

Go to the source code of this file.

## Classes
struct | _FlKeyEvent

## Functions
FlKeyEvent * | fl_key_event_new (guint32 time, gboolean is_press, guint16 keycode, guint keyval, GdkModifierType state, guint8 group)
FlKeyEvent * | fl_key_event_new_from_gdk_event (GdkEvent *event)
guint32 | fl_key_event_get_time (FlKeyEvent *self)
gboolean | fl_key_event_get_is_press (FlKeyEvent *self)
guint16 | fl_key_event_get_keycode (FlKeyEvent *self)
guint | fl_key_event_get_keyval (FlKeyEvent *self)
GdkModifierType | fl_key_event_get_state (FlKeyEvent *self)
guint8 | fl_key_event_get_group (FlKeyEvent *self)
GdkEvent * | fl_key_event_get_origin (FlKeyEvent *self)
uint64_t | fl_key_event_hash (FlKeyEvent *self)
static void | fl_key_event_dispose (GObject *object)
static void | fl_key_event_class_init (FlKeyEventClass *klass)
static void | fl_key_event_init (FlKeyEvent *self)

## Function Documentation

## ◆ fl_key_event_class_init()

static void fl_key_event_class_init | ( | FlKeyEventClass * | klass | ) |
| static

Definition at line 136 of file fl_key_event.cc.

136 {
137 G_OBJECT_CLASS(klass)->dispose = fl_key_event_dispose;
138 }
fl_key_event_dispose
static void fl_key_event_dispose(GObject *object)
Definition: fl_key_event.cc:128

References fl_key_event_dispose().

## ◆ fl_key_event_dispose()

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

Definition at line 128 of file fl_key_event.cc.

128 {
129 FlKeyEvent* self = FL_KEY_EVENT(object);
130
131 g_clear_pointer(&self->origin, gdk_event_free);
132
133 G_OBJECT_CLASS(fl_key_event_parent_class)->dispose(object);
134 }

Referenced by fl_key_event_class_init().

## ◆ fl_key_event_get_group()

guint8 fl_key_event_get_group | ( | FlKeyEvent * | self | ) |

Definition at line 104 of file fl_key_event.cc.

104 {
105 g_return_val_if_fail(FL_IS_KEY_EVENT(self), 0);
106 return self->group;
107 }

Referenced by fl_keyboard_manager_handle_event(), and guarantee_layout().

## ◆ fl_key_event_get_is_press()

gboolean fl_key_event_get_is_press | ( | FlKeyEvent * | self | ) |

Definition at line 84 of file fl_key_event.cc.

84 {
85 g_return_val_if_fail(FL_IS_KEY_EVENT(self), FALSE);
86 return self->is_press;
87 }

Referenced by fl_key_channel_responder_handle_event(), fl_key_embedder_responder_handle_event_impl(), and fl_text_input_handler_filter_keypress().

## ◆ fl_key_event_get_keycode()

guint16 fl_key_event_get_keycode | ( | FlKeyEvent * | self | ) |

Definition at line 89 of file fl_key_event.cc.

89 {
90 g_return_val_if_fail(FL_IS_KEY_EVENT(self), 0);
91 return self->keycode;
92 }

Referenced by event_to_physical_key(), fl_key_channel_responder_handle_event(), fl_keyboard_manager_handle_event(), and guarantee_layout().

## ◆ fl_key_event_get_keyval()

guint fl_key_event_get_keyval | ( | FlKeyEvent * | self | ) |

Definition at line 94 of file fl_key_event.cc.

94 {
95 g_return_val_if_fail(FL_IS_KEY_EVENT(self), 0);
96 return self->keyval;
97 }

Referenced by event_to_character(), event_to_logical_key(), fl_key_channel_responder_handle_event(), and fl_text_input_handler_filter_keypress().

## ◆ fl_key_event_get_origin()

GdkEvent* fl_key_event_get_origin | ( | FlKeyEvent * | self | ) |

Definition at line 109 of file fl_key_event.cc.

109 {
110 g_return_val_if_fail(FL_IS_KEY_EVENT(self), nullptr);
111 return self->origin;
112 }

Referenced by fl_text_input_handler_filter_keypress(), and responder_handle_event_callback().

## ◆ fl_key_event_get_state()

GdkModifierType fl_key_event_get_state | ( | FlKeyEvent * | self | ) |

Definition at line 99 of file fl_key_event.cc.

99 {
100 g_return_val_if_fail(FL_IS_KEY_EVENT(self), static_cast<GdkModifierType>(0));
101 return self->state;
102 }

Referenced by fl_key_channel_responder_handle_event(), fl_key_embedder_responder_handle_event_impl(), and fl_text_input_handler_filter_keypress().

## ◆ fl_key_event_get_time()

guint32 fl_key_event_get_time | ( | FlKeyEvent * | self | ) |

Definition at line 79 of file fl_key_event.cc.

79 {
80 g_return_val_if_fail(FL_IS_KEY_EVENT(self), 0);
81 return self->time;
82 }

Referenced by event_to_timestamp().

## ◆ fl_key_event_hash()

uint64_t fl_key_event_hash | ( | FlKeyEvent * | event | ) |

fl_key_event_hash: @event: an #FlKeyEvent.

Calculates a unique ID for a given FlKeyEvent object to use for identification of responses from the framework.

Returns: a hash code.

Definition at line 114 of file fl_key_event.cc.

114 {
115 g_return_val_if_fail(FL_IS_KEY_EVENT(self), 0);
116
117 // Combine the event timestamp, the type of event, and the hardware keycode
118 // (scan code) of the event to come up with a unique id for this event that
119 // can be derived solely from the event data itself, so that we can identify
120 // whether or not we have seen this event already.
121 guint64 type =
122 static_cast<uint64_t>(self->is_press ? GDK_KEY_PRESS : GDK_KEY_RELEASE);
123 guint64 keycode = static_cast<uint64_t>(self->keycode);
124 return (self->time & 0xffffffff) | ((type & 0xffff) << 32) |
125 ((keycode & 0xffff) << 48);
126 }
type
uint8_t type
Definition: fl_standard_message_codec_test.cc:1115

References type.

Referenced by fl_keyboard_manager_handle_event(), and fl_keyboard_pending_event_new().

## ◆ fl_key_event_init()

static void fl_key_event_init | ( | FlKeyEvent * | self | ) |
| static

Definition at line 140 of file fl_key_event.cc.

140 {}

## ◆ fl_key_event_new()

FlKeyEvent* fl_key_event_new | ( | guint32 | time,
|  | gboolean | is_press,
|  | guint16 | keycode,
|  | guint | keyval,
|  | GdkModifierType | state,
|  | guint8 | group
| ) |  |

FlKeyEvent: A struct that stores information from GdkEvent.

This is a class only used within the GTK embedding, created by FlView and consumed by FlKeyboardHandler. 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.

Definition at line 34 of file fl_key_event.cc.

39 {
40 FlKeyEvent* self =
41 FL_KEY_EVENT(g_object_new(fl_key_event_get_type(), nullptr));
42
43 self->time = time;
44 self->is_press = is_press;
45 self->keycode = keycode;
46 self->keyval = keyval;
47 self->state = state;
48 self->group = group;
49
50 return self;
51 }
state
AtkStateType state
Definition: fl_accessible_node.cc:10

References state.

Referenced by TEST(), and test_lock_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.

Create a new #FlKeyEvent based on a #GdkEvent.

Returns: a new #FlKeyEvent.

Definition at line 53 of file fl_key_event.cc.

53 {
54 FlKeyEvent* self =
55 FL_KEY_EVENT(g_object_new(fl_key_event_get_type(), nullptr));
56
57 GdkEventType type = gdk_event_get_event_type(event);
58 g_return_val_if_fail(type == GDK_KEY_PRESS || type == GDK_KEY_RELEASE,
59 nullptr);
60
61 guint16 keycode = 0;
62 gdk_event_get_keycode(event, &keycode);
63 guint keyval = 0;
64 gdk_event_get_keyval(event, &keyval);
65 GdkModifierType state = static_cast<GdkModifierType>(0);
66 gdk_event_get_state(event, &state);
67
68 self->time = gdk_event_get_time(event);
69 self->is_press = type == GDK_KEY_PRESS;
70 self->keycode = keycode;
71 self->keyval = keyval;
72 self->state = state;
73 self->group = event->key.group;
74 self->origin = event;
75
76 return self;
77 }

References state, and type.

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