| Flutter Linux Embedder |

fl_keyboard_handler.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_HANDLER_H_
6 #define FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_HANDLER_H_
7
8 #include <gdk/gdk.h>
9
10 #include "flutter/shell/platform/linux/fl_keyboard_view_delegate.h"
11
12 G_BEGIN_DECLS
13
14 #define FL_TYPE_KEYBOARD_HANDLER fl_keyboard_handler_get_type()
15 G_DECLARE_FINAL_TYPE(FlKeyboardHandler,
16 fl_keyboard_handler,
17 FL,
18 KEYBOARD_HANDLER,
19 GObject);
20
21 /**
22 * FlKeyboardHandler:
23 *
24 * Processes keyboard events and cooperate with `TextInputHandler`.
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 * `TextInputHandler`) and are handled synchronously.
34 * - Redispatching: Events are inserted back to the system for redispatching.
35 */
36
37 /**
38 * fl_keyboard_handler_new:
39 * @view_delegate: An interface that the handler requires to communicate with
40 * the platform. Usually implemented by FlView.
41 *
42 * Create a new #FlKeyboardHandler.
43 *
44 * Returns: a new #FlKeyboardHandler.
45 */
46 FlKeyboardHandler* fl_keyboard_handler_new(
47 FlBinaryMessenger* messenger,
48 FlKeyboardViewDelegate* view_delegate);
49
50 /**
51 * fl_keyboard_handler_handle_event:
52 * @handler: the #FlKeyboardHandler self.
53 * @event: the event to be dispatched. It is usually a wrap of a GdkEventKey.
54 * This event will be managed and released by #FlKeyboardHandler.
55 *
56 * Make the handler process a system key event. This might eventually send
57 * messages to the framework, trigger text input effects, or redispatch the
58 * event back to the system.
59 */
60 gboolean fl_keyboard_handler_handle_event(FlKeyboardHandler* handler,
61 FlKeyEvent* event);
62
63 /**
64 * fl_keyboard_handler_is_state_clear:
65 * @handler: the #FlKeyboardHandler self.
66 *
67 * A debug-only method that queries whether the handler's various states are
68 * cleared, i.e. no pending events for redispatching or for responding.
69 *
70 * Returns: true if the handler's various states are cleared.
71 */
72 gboolean fl_keyboard_handler_is_state_clear(FlKeyboardHandler* handler);
73
74 /**
75 * fl_keyboard_handler_sync_modifier_if_needed:
76 * @handler: the #FlKeyboardHandler self.
77 * @state: the state of the modifiers mask.
78 * @event_time: the time attribute of the incoming GDK event.
79 *
80 * If needed, synthesize modifier keys up and down event by comparing their
81 * current pressing states with the given modifiers mask.
82 */
83 void fl_keyboard_handler_sync_modifier_if_needed(FlKeyboardHandler* handler,
84 guint state,
85 double event_time);
86
87 /**
88 * fl_keyboard_handler_get_pressed_state:
89 * @handler: the #FlKeyboardHandler self.
90 *
91 * Returns the keyboard pressed state. The hash table contains one entry per
92 * pressed keys, mapping from the logical key to the physical key.*
93 */
94 GHashTable* fl_keyboard_handler_get_pressed_state(FlKeyboardHandler* handler);
95
96 G_END_DECLS
97
98 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_HANDLER_H_
fl_keyboard_handler_handle_event
gboolean fl_keyboard_handler_handle_event(FlKeyboardHandler *handler, FlKeyEvent *event)
Definition: fl_keyboard_handler.cc:541
event
FlKeyEvent * event
Definition: fl_key_channel_responder.cc:118
fl_keyboard_handler_sync_modifier_if_needed
void fl_keyboard_handler_sync_modifier_if_needed(FlKeyboardHandler *handler, guint state, double event_time)
Definition: fl_keyboard_handler.cc:577
state
AtkStateType state
Definition: fl_accessible_node.cc:10
fl_keyboard_handler_new
FlKeyboardHandler * fl_keyboard_handler_new(FlBinaryMessenger *messenger, FlKeyboardViewDelegate *view_delegate)
Definition: fl_keyboard_handler.cc:499
fl_keyboard_handler_get_pressed_state
GHashTable * fl_keyboard_handler_get_pressed_state(FlKeyboardHandler *handler)
Definition: fl_keyboard_handler.cc:590
G_DECLARE_FINAL_TYPE
G_DECLARE_FINAL_TYPE(FlKeyboardHandler, fl_keyboard_handler, FL, KEYBOARD_HANDLER, GObject)
FL
FL
Definition: fl_binary_messenger.cc:27
fl_keyboard_handler_is_state_clear
gboolean fl_keyboard_handler_is_state_clear(FlKeyboardHandler *handler)
Definition: fl_keyboard_handler.cc:571
fl_keyboard_view_delegate.h