| Flutter Linux Embedder |

fl_key_event.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_EVENT_H_
6 #define FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_EVENT_H_
7
8 #include <gdk/gdk.h>
9
10 /**
11 * FlKeyEventDispose:
12 * @origin: the #FlKeyEvent::origin to dispose.
13 *
14 * The signature for #FlKeyEvent::dispose_origin, which
15 * frees #FlKeyEvent::origin.
16 **/
17 typedef void (*FlKeyEventDisposeOrigin)(gpointer origin);
18
19 /**
20 * FlKeyEvent:
21 * A struct that stores information from GdkEvent.
22 *
23 * This is a class only used within the GTK embedding, created by
24 * FlView and consumed by FlKeyboardManager. It is not sent to
25 * the embedder.
26 *
27 * This object contains information from GdkEvent as well as an origin event
28 * object, so that Flutter can create an event object in unit tests even after
29 * migrating to GDK 4.0 which stops supporting creating GdkEvent.
30 */
31 typedef struct _FlKeyEvent {
32 // Time in milliseconds.
33 guint32 time;
34 // True if is a press event, otherwise a release event.
35 bool is_press;
36 // Hardware keycode.
37 guint16 keycode;
38 // Keyval.
39 guint keyval;
40 // Modifier state.
41 int state;
42 // Keyboard group.
43 guint8 group;
44 // String, null-terminated.
45 //
46 // Can be nullptr.
47 const char* string;
48 // An opaque pointer to the original event.
49 //
50 // This is used when dispatching. For native events, this is #GdkEvent
51 // pointer. For unit tests, this is a dummy pointer.
52 gpointer origin;
53 // A callback to free #origin, called in #fl_key_event_dispose.
54 //
55 // Can be nullptr.
56 FlKeyEventDisposeOrigin dispose_origin;
57 } FlKeyEvent;
58
59 /**
60 * fl_key_event_new_from_gdk_event:
61 * @event: the #GdkEvent this #FlKeyEvent is based on. The #event must be a
62 * #GdkEventKey, and will be destroyed by #fl_key_event_dispose.
63 *
64 * Create a new #FlKeyEvent based on a #GdkEvent.
65 *
66 * Returns: a new #FlKeyEvent. Must be freed with #fl_key_event_dispose.
67 */
68 FlKeyEvent* fl_key_event_new_from_gdk_event(GdkEvent* event);
69
70 /**
71 * fl_key_event_dispose:
72 * @event: the event to dispose.
73 *
74 * Properly disposes the content of #event and then the pointer.
75 */
76 void fl_key_event_dispose(FlKeyEvent* event);
77
78 FlKeyEvent* fl_key_event_clone(const FlKeyEvent* source);
79
80 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_EVENT_H_
_FlKeyEvent::time
guint32 time
Definition: fl_key_event.h:33
_FlKeyEvent::group
guint8 group
Definition: fl_key_event.h:43
event
FlKeyEvent * event
Definition: fl_key_channel_responder.cc:118
fl_key_event_dispose
void fl_key_event_dispose(FlKeyEvent *event)
Definition: fl_key_event.cc:33
fl_key_event_new_from_gdk_event
FlKeyEvent * fl_key_event_new_from_gdk_event(GdkEvent *event)
Definition: fl_key_event.cc:12
FlKeyEvent
struct _FlKeyEvent FlKeyEvent
_FlKeyEvent::origin
gpointer origin
Definition: fl_key_event.h:52
_FlKeyEvent
Definition: fl_key_event.h:31
_FlKeyEvent::keycode
guint16 keycode
Definition: fl_key_event.h:37
_FlKeyEvent::dispose_origin
FlKeyEventDisposeOrigin dispose_origin
Definition: fl_key_event.h:56
_FlKeyEvent::state
int state
Definition: fl_key_event.h:41
_FlKeyEvent::is_press
bool is_press
Definition: fl_key_event.h:35
_FlKeyEvent::keyval
guint keyval
Definition: fl_key_event.h:39
fl_key_event_clone
FlKeyEvent * fl_key_event_clone(const FlKeyEvent *source)
Definition: fl_key_event.cc:43
FlKeyEventDisposeOrigin
void(* FlKeyEventDisposeOrigin)(gpointer origin)
Definition: fl_key_event.h:17
_FlKeyEvent::string
const char * string
Definition: fl_key_event.h:47