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/embedder/embedder.h"
13 
14 G_BEGIN_DECLS
15 
16 G_DECLARE_FINAL_TYPE(FlKeyboardManager,
17  fl_keyboard_manager,
18  FL,
19  KEYBOARD_MANAGER,
20  GObject);
21 
22 /**
23  * FlKeyboardManager:
24  *
25  * Processes keyboard events and cooperate with `TextInputManager`.
26  *
27  * A keyboard event goes through a few sections, each can choose to handle the
28  * event, and only unhandled events can move to the next section:
29  *
30  * - Keyboard: Dispatch to the embedder responder and the channel responder
31  * simultaneously. After both responders have responded (asynchronously), the
32  * event is considered handled if either responder handles it.
33  * - Text input: Events are sent to IM filter (usually owned by
34  * `TextInputManager`) and are handled synchronously.
35  * - Redispatching: Events are inserted back to the system for redispatching.
36  */
37 
38 /**
39  * fl_keyboard_manager_new:
40  * @engine: an #FlEngine.
41  *
42  * Create a new #FlKeyboardManager.
43  *
44  * Returns: a new #FlKeyboardManager.
45  */
46 FlKeyboardManager* fl_keyboard_manager_new(FlEngine* engine);
47 
48 /** fl_keyboard_manager_add_redispatched_event:
49  * @manager: an #FlKeyboardManager.
50  * @event: an event that will be handled by the manager in the future.
51  *
52  * Add an event that will be redispatched and handled by the manager in the
53  * future. When that event is received it will be ignored.
54  */
55 void fl_keyboard_manager_add_redispatched_event(FlKeyboardManager* manager,
56  FlKeyEvent* event);
57 
58 /**
59  * fl_keyboard_manager_handle_event:
60  * @manager: an #FlKeyboardManager.
61  * @event: the event to be dispatched. It is usually a wrap of a GdkEventKey.
62  * This event will be managed and released by #FlKeyboardManager.
63  * @cancellable: (allow-none): a #GCancellable or %NULL.
64  * @callback: (scope async): a #GAsyncReadyCallback to call when the view is
65  * added.
66  * @user_data: (closure): user data to pass to @callback.
67  *
68  * Make the manager process a system key event. This might eventually send
69  * messages to the framework, trigger text input effects, or redispatch the
70  * event back to the system.
71  */
72 void fl_keyboard_manager_handle_event(FlKeyboardManager* manager,
73  FlKeyEvent* event,
74  GCancellable* cancellable,
75  GAsyncReadyCallback callback,
76  gpointer user_data);
77 
78 /**
79  * fl_keyboard_manager_handle_event_finish:
80  * @manager: an #FlKeyboardManager.
81  * @result: a #GAsyncResult.
82  * @redispatched_event: FIXME
83  * @error: (allow-none): #GError location to store the error occurring, or %NULL
84  * to ignore.
85  *
86  * Completes request started with fl_keyboard_manager_handle_event().
87  *
88  * Returns: %TRUE on success.
89  */
91  FlKeyboardManager* manager,
92  GAsyncResult* result,
93  FlKeyEvent** redispatched_event,
94  GError** error);
95 
96 /**
97  * fl_keyboard_manager_sync_modifier_if_needed:
98  * @manager: the #FlKeyboardManager self.
99  * @state: the state of the modifiers mask.
100  * @event_time: the time attribute of the incoming GDK event.
101  *
102  * If needed, synthesize modifier keys up and down event by comparing their
103  * current pressing states with the given modifiers mask.
104  */
105 void fl_keyboard_manager_sync_modifier_if_needed(FlKeyboardManager* manager,
106  guint state,
107  double event_time);
108 
109 /**
110  * fl_keyboard_manager_get_pressed_state:
111  * @manager: the #FlKeyboardManager 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_keyboard_manager_get_pressed_state(FlKeyboardManager* manager);
117 
118 typedef guint (*FlKeyboardManagerLookupKeyHandler)(const GdkKeymapKey* key,
119  gpointer user_data);
120 
121 /**
122  * fl_keyboard_manager_set_lookup_key_handler:
123  * @manager: the #FlKeyboardManager self.
124  *
125  * Set the handler for key lookup, for testing purposes only.
126  */
128  FlKeyboardManager* manager,
129  FlKeyboardManagerLookupKeyHandler lookup_key_handler,
130  gpointer user_data);
131 
132 G_END_DECLS
133 
134 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_MANAGER_H_
fl_keyboard_manager_handle_event_finish
gboolean fl_keyboard_manager_handle_event_finish(FlKeyboardManager *manager, GAsyncResult *result, FlKeyEvent **redispatched_event, GError **error)
Definition: fl_keyboard_manager.cc:410
fl_keyboard_manager_add_redispatched_event
void fl_keyboard_manager_add_redispatched_event(FlKeyboardManager *manager, FlKeyEvent *event)
Definition: fl_keyboard_manager.cc:367
state
AtkStateType state
Definition: fl_accessible_node.cc:10
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:441
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
G_DECLARE_FINAL_TYPE
G_BEGIN_DECLS G_DECLARE_FINAL_TYPE(FlKeyboardManager, fl_keyboard_manager, FL, KEYBOARD_MANAGER, GObject)
fl_keyboard_manager_handle_event
void fl_keyboard_manager_handle_event(FlKeyboardManager *manager, FlKeyEvent *event, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_keyboard_manager.cc:374
FL
FL
Definition: fl_binary_messenger.cc:27
fl_keyboard_manager_new
FlKeyboardManager * fl_keyboard_manager_new(FlEngine *engine)
Definition: fl_keyboard_manager.cc:356
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:427
fl_key_event.h
fl_engine.h
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
fl_keyboard_manager_get_pressed_state
GHashTable * fl_keyboard_manager_get_pressed_state(FlKeyboardManager *manager)
Definition: fl_keyboard_manager.cc:435
FlKeyboardManagerLookupKeyHandler
guint(* FlKeyboardManagerLookupKeyHandler)(const GdkKeymapKey *key, gpointer user_data)
Definition: fl_keyboard_manager.h:118