| 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"
11 #include "flutter/shell/platform/linux/fl_key_event.h"
12 #include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.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. If `error` is not %NULL, `*error` must be initialized (typically
85 * %NULL, but an error from a previous call using GLib error handling is
86 * explicitly valid).
87 *
88 * Completes request started with fl_keyboard_manager_handle_event().
89 *
90 * Returns: %TRUE on success.
91 */
92 gboolean fl_keyboard_manager_handle_event_finish(
93 FlKeyboardManager* manager,
94 GAsyncResult* result,
95 FlKeyEvent** redispatched_event,
96 GError** error);
97
98 /**
99 * fl_keyboard_manager_sync_modifier_if_needed:
100 * @manager: the #FlKeyboardManager self.
101 * @state: the state of the modifiers mask.
102 * @event_time: the time attribute of the incoming GDK event.
103 *
104 * If needed, synthesize modifier keys up and down event by comparing their
105 * current pressing states with the given modifiers mask.
106 */
107 void fl_keyboard_manager_sync_modifier_if_needed(FlKeyboardManager* manager,
108 guint state,
109 double event_time);
110
111 /**
112 * fl_keyboard_manager_get_pressed_state:
113 * @manager: the #FlKeyboardManager self.
114 *
115 * Returns the keyboard pressed state. The hash table contains one entry per
116 * pressed keys, mapping from the logical key to the physical key.*
117 */
118 GHashTable* fl_keyboard_manager_get_pressed_state(FlKeyboardManager* manager);
119
120 typedef guint (*FlKeyboardManagerLookupKeyHandler)(const GdkKeymapKey* key,
121 gpointer user_data);
122
123 /**
124 * fl_keyboard_manager_set_lookup_key_handler:
125 * @manager: the #FlKeyboardManager self.
126 *
127 * Set the handler for key lookup, for testing purposes only.
128 */
129 void fl_keyboard_manager_set_lookup_key_handler(
130 FlKeyboardManager* manager,
131 FlKeyboardManagerLookupKeyHandler lookup_key_handler,
132 gpointer user_data);
133
134 G_END_DECLS
135
136 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_MANAGER_H_
user_data
const char FlTextDirection FlAssertiveness gpointer user_data
Definition: fl_accessibility_handler.cc:24
FL
FL
Definition: fl_binary_messenger.cc:27
fl_engine.h
fl_key_event.h
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
fl_keyboard_manager_new
FlKeyboardManager * fl_keyboard_manager_new(FlEngine *engine)
Definition: fl_keyboard_manager.cc:356
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_keyboard_manager_get_pressed_state
GHashTable * fl_keyboard_manager_get_pressed_state(FlKeyboardManager *manager)
Definition: fl_keyboard_manager.cc:435
fl_keyboard_manager_add_redispatched_event
void fl_keyboard_manager_add_redispatched_event(FlKeyboardManager *manager, FlKeyEvent *event)
Definition: fl_keyboard_manager.cc:367
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_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
G_DECLARE_FINAL_TYPE
G_BEGIN_DECLS G_DECLARE_FINAL_TYPE(FlKeyboardManager, fl_keyboard_manager, FL, KEYBOARD_MANAGER, GObject)
FlKeyboardManagerLookupKeyHandler
guint(* FlKeyboardManagerLookupKeyHandler)(const GdkKeymapKey *key, gpointer user_data)
Definition: fl_keyboard_manager.h:120
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40