Flutter Linux Embedder
fl_key_embedder_responder.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_EMBEDDER_RESPONDER_H_
6 #define FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_EMBEDDER_RESPONDER_H_
7 
8 #include <gdk/gdk.h>
9 #include <functional>
10 
15 
16 constexpr int kMaxConvertedKeyData = 3;
17 
18 // The signature of a function that FlKeyEmbedderResponder calls on every key
19 // event.
20 //
21 // The `user_data` is opaque data managed by the object that creates
22 // FlKeyEmbedderResponder, and is registered along with this callback
23 // via `fl_key_embedder_responder_new`.
24 //
25 // The `callback_user_data` is opaque data managed by FlKeyEmbedderResponder.
26 // Instances of the EmbedderSendKeyEvent callback are required to invoke
27 // `callback` with the `callback_user_data` parameter after the `event` has been
28 // processed.
29 typedef void (*EmbedderSendKeyEvent)(const FlutterKeyEvent* event,
30  FlutterKeyEventCallback callback,
31  void* callback_user_data,
32  void* send_key_event_user_data);
33 
34 G_BEGIN_DECLS
35 
36 #define FL_TYPE_KEY_EMBEDDER_RESPONDER fl_key_embedder_responder_get_type()
37 G_DECLARE_FINAL_TYPE(FlKeyEmbedderResponder,
38  fl_key_embedder_responder,
39  FL,
40  KEY_EMBEDDER_RESPONDER,
41  GObject);
42 
43 /**
44  * FlKeyEmbedderResponder:
45  *
46  * A #FlKeyResponder that handles events by sending the converted events
47  * through the embedder API.
48  *
49  * This class communicates with the HardwareKeyboard API in the framework.
50  */
51 
52 /**
53  * fl_key_embedder_responder_new:
54  * @engine: The #FlEngine, whose the embedder API will be used to send
55  * the event.
56  *
57  * Creates a new #FlKeyEmbedderResponder.
58  * @send_key_event: a function that is called on every key event.
59  * @send_key_event_user_data: an opaque pointer that will be sent back as the
60  * last argument of send_key_event, created and managed by the object that holds
61  * FlKeyEmbedderResponder.
62  *
63  * Returns: a new #FlKeyEmbedderResponder.
64  */
65 FlKeyEmbedderResponder* fl_key_embedder_responder_new(
67  void* send_key_event_user_data);
68 
69 /**
70  * fl_key_embedder_responder_sync_modifiers_if_needed:
71  * @responder: the #FlKeyEmbedderResponder self.
72  * @state: the state of the modifiers mask.
73  * @event_time: the time attribute of the incoming GDK event.
74  *
75  * If needed, synthesize modifier keys up and down event by comparing their
76  * current pressing states with the given modifiers mask.
77  */
79  FlKeyEmbedderResponder* responder,
80  guint state,
81  double event_time);
82 
83 /**
84  * fl_key_embedder_responder_get_pressed_state:
85  * @responder: the #FlKeyEmbedderResponder self.
86  *
87  * Returns the keyboard pressed state. The hash table contains one entry per
88  * pressed keys, mapping from the logical key to the physical key.
89  */
91  FlKeyEmbedderResponder* responder);
92 
93 G_END_DECLS
94 
95 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_EMBEDDER_RESPONDER_H_
fl_key_embedder_responder_get_pressed_state
GHashTable * fl_key_embedder_responder_get_pressed_state(FlKeyEmbedderResponder *responder)
Definition: fl_key_embedder_responder.cc:896
event
FlKeyEvent * event
Definition: fl_key_channel_responder.cc:118
state
AtkStateType state
Definition: fl_accessible_node.cc:10
fl_keyboard_handler.h
fl_binary_messenger.h
fl_key_embedder_responder_new
FlKeyEmbedderResponder * fl_key_embedder_responder_new(EmbedderSendKeyEvent send_key_event, void *send_key_event_user_data)
Definition: fl_key_embedder_responder.cc:263
FL
FL
Definition: fl_binary_messenger.cc:27
kMaxConvertedKeyData
constexpr int kMaxConvertedKeyData
Definition: fl_key_embedder_responder.h:16
send_key_event
static void send_key_event(FlTextInputHandler *handler, gint keyval, gint state=0)
Definition: fl_text_input_handler_test.cc:181
fl_value.h
fl_key_embedder_responder_sync_modifiers_if_needed
void fl_key_embedder_responder_sync_modifiers_if_needed(FlKeyEmbedderResponder *responder, guint state, double event_time)
Definition: fl_key_embedder_responder.cc:879
callback
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
Definition: fl_key_channel_responder.cc:120
EmbedderSendKeyEvent
void(* EmbedderSendKeyEvent)(const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *callback_user_data, void *send_key_event_user_data)
Definition: fl_key_embedder_responder.h:29
G_DECLARE_FINAL_TYPE
G_DECLARE_FINAL_TYPE(FlKeyEmbedderResponder, fl_key_embedder_responder, FL, KEY_EMBEDDER_RESPONDER, GObject)
fl_key_responder.h