| Flutter Linux Embedder |

fl_keyboard_manager.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_KEYBOARD_MANAGER_H_
6 #define FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_MANAGER_H_
7
8 #include <gdk/gdk.h>
9
10 #include "flutter/shell/platform/linux/fl_keyboard_view_delegate.h"
11 #include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"
12
13 G_BEGIN_DECLS
14
15 G_DECLARE_FINAL_TYPE(FlKeyboardManager,
16 fl_keyboard_manager,
17 FL,
18 KEYBOARD_MANAGER,
19 GObject);
20
21 /**
22 * FlKeyboardManager:
23 *
24 * Processes keyboard events and cooperate with `TextInputManager`.
25 *
26 * A keyboard event goes through a few sections, each can choose to handle the
27 * event, and only unhandled events can move to the next section:
28 *
29 * - Keyboard: Dispatch to the embedder responder and the channel responder
30 * simultaneously. After both responders have responded (asynchronously), the
31 * event is considered handled if either responder handles it.
32 * - Text input: Events are sent to IM filter (usually owned by
33 * `TextInputManager`) and are handled synchronously.
34 * - Redispatching: Events are inserted back to the system for redispatching.
35 */
36
37 /**
38 * fl_keyboard_manager_new:
39 * @engine: an #FlEngine.
40 * @view_delegate: An interface that the manager requires to communicate with
41 * the platform. Usually implemented by FlView.
42 *
43 * Create a new #FlKeyboardManager.
44 *
45 * Returns: a new #FlKeyboardManager.
46 */
47 FlKeyboardManager* fl_keyboard_manager_new(
48 FlEngine* engine,
49 FlKeyboardViewDelegate* view_delegate);
50
51 /**
52 * fl_keyboard_manager_handle_event:
53 * @manager: the #FlKeyboardManager self.
54 * @event: the event to be dispatched. It is usually a wrap of a GdkEventKey.
55 * This event will be managed and released by #FlKeyboardManager.
56 *
57 * Make the manager process a system key event. This might eventually send
58 * messages to the framework, trigger text input effects, or redispatch the
59 * event back to the system.
60 */
61 gboolean fl_keyboard_manager_handle_event(FlKeyboardManager* manager,
62 FlKeyEvent* event);
63
64 /**
65 * fl_keyboard_manager_is_state_clear:
66 * @manager: the #FlKeyboardManager self.
67 *
68 * A debug-only method that queries whether the manager's various states are
69 * cleared, i.e. no pending events for redispatching or for responding.
70 *
71 * Returns: true if the manager's various states are cleared.
72 */
73 gboolean fl_keyboard_manager_is_state_clear(FlKeyboardManager* manager);
74
75 /**
76 * fl_keyboard_manager_sync_modifier_if_needed:
77 * @manager: the #FlKeyboardManager self.
78 * @state: the state of the modifiers mask.
79 * @event_time: the time attribute of the incoming GDK event.
80 *
81 * If needed, synthesize modifier keys up and down event by comparing their
82 * current pressing states with the given modifiers mask.
83 */
84 void fl_keyboard_manager_sync_modifier_if_needed(FlKeyboardManager* manager,
85 guint state,
86 double event_time);
87
88 /**
89 * fl_keyboard_manager_get_pressed_state:
90 * @manager: the #FlKeyboardManager self.
91 *
92 * Returns the keyboard pressed state. The hash table contains one entry per
93 * pressed keys, mapping from the logical key to the physical key.*
94 */
95 GHashTable* fl_keyboard_manager_get_pressed_state(FlKeyboardManager* manager);
96
97 typedef void (*FlKeyboardManagerSendKeyEventHandler)(
98 const FlutterKeyEvent* event,
99 FlutterKeyEventCallback callback,
100 void* callback_user_data,
101 gpointer user_data);
102
103 /**
104 * fl_keyboard_manager_set_send_key_event_handler:
105 * @manager: the #FlKeyboardManager self.
106 *
107 * Set the handler for sending events, for testing purposes only.
108 */
109 void fl_keyboard_manager_set_send_key_event_handler(
110 FlKeyboardManager* manager,
111 FlKeyboardManagerSendKeyEventHandler send_key_event_handler,
112 gpointer user_data);
113
114 typedef guint (*FlKeyboardManagerLookupKeyHandler)(const GdkKeymapKey* key,
115 gpointer user_data);
116
117 /**
118 * fl_keyboard_manager_set_lookup_key_handler:
119 * @manager: the #FlKeyboardManager self.
120 *
121 * Set the handler for key lookup, for testing purposes only.
122 */
123 void fl_keyboard_manager_set_lookup_key_handler(
124 FlKeyboardManager* manager,
125 FlKeyboardManagerLookupKeyHandler lookup_key_handler,
126 gpointer user_data);
127
128 typedef void (*FlKeyboardManagerRedispatchEventHandler)(FlKeyEvent* event,
129 gpointer user_data);
130
131 /**
132 * fl_keyboard_manager_set_redispatch_handler:
133 * @manager: the #FlKeyboardManager self.
134 *
135 * Set the handler for redispatches, for testing purposes only.
136 */
137 void fl_keyboard_manager_set_redispatch_handler(
138 FlKeyboardManager* manager,
139 FlKeyboardManagerRedispatchEventHandler redispatch_handler,
140 gpointer user_data);
141
142 typedef GHashTable* (*FlKeyboardManagerGetPressedStateHandler)(
143 gpointer user_data);
144
145 /**
146 * fl_keyboard_manager_set_get_pressed_state_handler:
147 * @manager: the #FlKeyboardManager self.
148 *
149 * Set the handler for gettting the keyboard state, for testing purposes only.
150 */
151 void fl_keyboard_manager_set_get_pressed_state_handler(
152 FlKeyboardManager* manager,
153 FlKeyboardManagerGetPressedStateHandler get_pressed_state_handler,
154 gpointer user_data);
155
156 G_END_DECLS
157
158 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_MANAGER_H_
fl_keyboard_manager_is_state_clear
gboolean fl_keyboard_manager_is_state_clear(FlKeyboardManager *manager)
Definition: fl_keyboard_manager.cc:552
fl_keyboard_manager_set_get_pressed_state_handler
void fl_keyboard_manager_set_get_pressed_state_handler(FlKeyboardManager *manager, FlKeyboardManagerGetPressedStateHandler get_pressed_state_handler, gpointer user_data)
Definition: fl_keyboard_manager.cc:604
FlKeyboardManagerGetPressedStateHandler
GHashTable *(* FlKeyboardManagerGetPressedStateHandler)(gpointer user_data)
Definition: fl_keyboard_manager.h:142
state
AtkStateType state
Definition: fl_accessible_node.cc:10
FlKeyboardManagerSendKeyEventHandler
void(* FlKeyboardManagerSendKeyEventHandler)(const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *callback_user_data, gpointer user_data)
Definition: fl_keyboard_manager.h:97
fl_keyboard_manager_set_lookup_key_handler
void fl_keyboard_manager_set_lookup_key_handler(FlKeyboardManager *manager, FlKeyboardManagerLookupKeyHandler lookup_key_handler, gpointer user_data)
Definition: fl_keyboard_manager.cc:586
fl_keyboard_manager_set_redispatch_handler
void fl_keyboard_manager_set_redispatch_handler(FlKeyboardManager *manager, FlKeyboardManagerRedispatchEventHandler redispatch_handler, gpointer user_data)
Definition: fl_keyboard_manager.cc:595
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
fl_keyboard_manager_new
FlKeyboardManager * fl_keyboard_manager_new(FlEngine *engine, FlKeyboardViewDelegate *view_delegate)
Definition: fl_keyboard_manager.cc:462
FlKeyboardManagerRedispatchEventHandler
void(* FlKeyboardManagerRedispatchEventHandler)(FlKeyEvent *event, gpointer user_data)
Definition: fl_keyboard_manager.h:128
G_DECLARE_FINAL_TYPE
G_BEGIN_DECLS G_DECLARE_FINAL_TYPE(FlKeyboardManager, fl_keyboard_manager, FL, KEYBOARD_MANAGER, GObject)
fl_keyboard_manager_handle_event
gboolean fl_keyboard_manager_handle_event(FlKeyboardManager *manager, FlKeyEvent *event)
Definition: fl_keyboard_manager.cc:522
fl_keyboard_manager_set_send_key_event_handler
void fl_keyboard_manager_set_send_key_event_handler(FlKeyboardManager *manager, FlKeyboardManagerSendKeyEventHandler send_key_event_handler, gpointer user_data)
Definition: fl_keyboard_manager.cc:577
FL
FL
Definition: fl_binary_messenger.cc:27
fl_keyboard_manager_sync_modifier_if_needed
void fl_keyboard_manager_sync_modifier_if_needed(FlKeyboardManager *manager, guint state, double event_time)
Definition: fl_keyboard_manager.cc:558
fl_engine.h
fl_keyboard_view_delegate.h
fl_keyboard_manager_get_pressed_state
GHashTable * fl_keyboard_manager_get_pressed_state(FlKeyboardManager *manager)
Definition: fl_keyboard_manager.cc:566
FlKeyboardManagerLookupKeyHandler
guint(* FlKeyboardManagerLookupKeyHandler)(const GdkKeymapKey *key, gpointer user_data)
Definition: fl_keyboard_manager.h:114