| 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 "flutter/shell/platform/linux/fl_engine_private.h"
9 #include "flutter/shell/platform/linux/fl_key_event.h"
10
11 // The signature of a function that FlKeyEmbedderResponder calls on every key
12 // event.
13 //
14 // The `user_data` is opaque data managed by the object that creates
15 // FlKeyEmbedderResponder, and is registered along with this callback
16 // via `fl_key_embedder_responder_new`.
17 //
18 // The `callback_user_data` is opaque data managed by FlKeyEmbedderResponder.
19 // Instances of the EmbedderSendKeyEvent callback are required to invoke
20 // `callback` with the `callback_user_data` parameter after the `event` has been
21 // processed.
22 typedef void (*EmbedderSendKeyEvent)(const FlutterKeyEvent* event,
23 FlutterKeyEventCallback callback,
24 void* callback_user_data,
25 void* send_key_event_user_data);
26
27 /**
28 * FlKeyEmbedderResponderAsyncCallback:
29 * @event: whether the event has been handled.
30 * @user_data: the same value as user_data sent by
31 * #fl_key_responder_handle_event.
32 *
33 * The signature for a callback with which a #FlKeyEmbedderResponder
34 *asynchronously reports whether the responder handles the event.
35 **/
36 typedef void (*FlKeyEmbedderResponderAsyncCallback)(bool handled,
37 gpointer user_data);
38
39 G_BEGIN_DECLS
40
41 G_DECLARE_FINAL_TYPE(FlKeyEmbedderResponder,
42 fl_key_embedder_responder,
43 FL,
44 KEY_EMBEDDER_RESPONDER,
45 GObject);
46
47 /**
48 * FlKeyEmbedderResponder:
49 *
50 * A #FlKeyResponder that handles events by sending the converted events
51 * through the embedder API.
52 *
53 * This class communicates with the HardwareKeyboard API in the framework.
54 */
55
56 /**
57 * fl_key_embedder_responder_new:
58 * @engine: The #FlEngine, whose the embedder API will be used to send
59 * the event.
60 *
61 * Creates a new #FlKeyEmbedderResponder.
62 * @send_key_event: a function that is called on every key event.
63 * @send_key_event_user_data: an opaque pointer that will be sent back as the
64 * last argument of send_key_event, created and managed by the object that holds
65 * FlKeyEmbedderResponder.
66 *
67 * Returns: a new #FlKeyEmbedderResponder.
68 */
69 FlKeyEmbedderResponder* fl_key_embedder_responder_new(
70 EmbedderSendKeyEvent send_key_event,
71 void* send_key_event_user_data);
72
73 /**
74 * fl_key_embedder_responder_handle_event:
75 * @responder: the #FlKeyEmbedderResponder self.
76 * @event: the event to be handled. Must not be null. The object is managed by
77 * callee and must not be assumed available after this function.
78 * @specified_logical_key:
79 * @callback: the callback to report the result. It should be called exactly
80 * once. Must not be null.
81 * @user_data: a value that will be sent back in the callback. Can be null.
82 *
83 * Let the responder handle an event, expecting the responder to report
84 * whether to handle the event. The result will be reported by invoking
85 * `callback` exactly once, which might happen after
86 * `fl_key_embedder_responder_handle_event` or during it.
87 */
88 void fl_key_embedder_responder_handle_event(
89 FlKeyEmbedderResponder* responder,
90 FlKeyEvent* event,
91 uint64_t specified_logical_key,
92 FlKeyEmbedderResponderAsyncCallback callback,
93 gpointer user_data);
94
95 /**
96 * fl_key_embedder_responder_sync_modifiers_if_needed:
97 * @responder: the #FlKeyEmbedderResponder self.
98 * @state: the state of the modifiers mask.
99 * @event_time: the time attribute of the incoming GDK event.
100 *
101 * If needed, synthesize modifier keys up and down event by comparing their
102 * current pressing states with the given modifiers mask.
103 */
104 void fl_key_embedder_responder_sync_modifiers_if_needed(
105 FlKeyEmbedderResponder* responder,
106 guint state,
107 double event_time);
108
109 /**
110 * fl_key_embedder_responder_get_pressed_state:
111 * @responder: the #FlKeyEmbedderResponder self.
112 *
113 * Returns the keyboard pressed state. The hash table contains one entry per
114 * pressed keys, mapping from the logical key to the physical key.
115 */
116 GHashTable* fl_key_embedder_responder_get_pressed_state(
117 FlKeyEmbedderResponder* responder);
118
119 G_END_DECLS
120
121 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_EMBEDDER_RESPONDER_H_
state
AtkStateType state
Definition: fl_accessible_node.cc:10
FL
FL
Definition: fl_binary_messenger.cc:27
fl_engine_private.h
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
FlKeyEmbedderResponderAsyncCallback
void(* FlKeyEmbedderResponderAsyncCallback)(bool handled, gpointer user_data)
Definition: fl_key_embedder_responder.h:36
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:237
EmbedderSendKeyEvent
void(* EmbedderSendKeyEvent)(const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *callback_user_data, void *send_key_event_user_data)
Definition: fl_key_embedder_responder.h:22
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:850
fl_key_embedder_responder_handle_event
void fl_key_embedder_responder_handle_event(FlKeyEmbedderResponder *responder, FlKeyEvent *event, uint64_t specified_logical_key, FlKeyEmbedderResponderAsyncCallback callback, gpointer user_data)
Definition: fl_key_embedder_responder.cc:835
fl_key_embedder_responder_get_pressed_state
GHashTable * fl_key_embedder_responder_get_pressed_state(FlKeyEmbedderResponder *responder)
Definition: fl_key_embedder_responder.cc:867
G_DECLARE_FINAL_TYPE
G_BEGIN_DECLS G_DECLARE_FINAL_TYPE(FlKeyEmbedderResponder, fl_key_embedder_responder, FL, KEY_EMBEDDER_RESPONDER, GObject)
fl_key_event.h
send_key_event
static void send_key_event(FlTextInputHandler *handler, gint keyval, gint state=0)
Definition: fl_text_input_handler_test.cc:144