forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fl_keyboard_manager.h
113 lines (100 loc) · 4.04 KB
/
fl_keyboard_manager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_MANAGER_H_
#define FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_MANAGER_H_
#include <gdk/gdk.h>
#include "flutter/shell/platform/linux/fl_key_responder.h"
#include "flutter/shell/platform/linux/fl_text_input_plugin.h"
/**
* FlKeyboardManagerRedispatcher:
* @event: the pointer to the event to dispatch.
*
* The signature for a callback with which a #FlKeyboardManager redispatches
* key events that are not handled by anyone.
**/
typedef void (*FlKeyboardManagerRedispatcher)(gpointer event);
G_BEGIN_DECLS
#define FL_TYPE_KEYBOARD_MANAGER fl_keyboard_manager_get_type()
G_DECLARE_FINAL_TYPE(FlKeyboardManager,
fl_keyboard_manager,
FL,
KEYBOARD_MANAGER,
GObject);
/**
* FlKeyboardManager:
*
* A hub that manages how key events are dispatched to various processing
* objects of Flutter, or possibly back to the system.
*
* This class manage one or more objects of #FlKeyResponder, as well as a
* #TextInputPlugin.
*
* An event that is received by #fl_keyboard_manager_handle_event is first
* dispatched to *all* responders. Each responder responds *ascynchronously*
* with a boolean, indicating whether it handles the event.
*
* An event that is not handled by any responders is then passed to to the
* #TextInputPlugin, which responds *synchronously* with a boolean, indicating
* whether it handles the event.
*
* If no processing objects handle the event, the event is then "redispatched":
* sent back to the system using #redispatch_callback.
*
* Preventing responders from receiving events is not supported, because in
* reality this class will only support 2 hardcoded ones (channel and
* embedder), where the only purpose of supporting two is to support the legacy
* API (channel) during the deprecation window, after which the channel
* responder should be removed.
*/
/**
* fl_keyboard_manager_new:
* @text_input_plugin: the #FlTextInputPlugin to send key events to if the
* framework doesn't handle them. This object will be managed and freed by
* #FlKeyboardManager.
* @redispatch_callback: how the events should be sent if no processing
* objects handle the event. Typically a function that calls #gdk_event_put
* on #FlKeyEvent::origin.
*
* Create a new #FlKeyboardManager. The text input plugin must be specified
* now, while the responders should be added later with
* #fl_keyboard_manager_add_responder.
*
* Returns: a new #FlKeyboardManager.
*/
FlKeyboardManager* fl_keyboard_manager_new(
FlTextInputPlugin* text_input_plugin,
FlKeyboardManagerRedispatcher redispatch_callback);
/**
* fl_keyboard_manager_add_responder:
* @manager: the #FlKeyboardManager self.
* @responder: the new responder to be added.
*
* Add a new #FlKeyResponder to the #FlKeyboardManager. Responders added
* earlier will receive events earlier.
*/
void fl_keyboard_manager_add_responder(FlKeyboardManager* manager,
FlKeyResponder* responder);
/**
* fl_keyboard_manager_handle_event:
* @manager: the #FlKeyboardManager self.
* @event: the event to be dispatched. This event will be managed and
* released by #FlKeyboardManager.
*
* Add a new #FlKeyResponder to the #FlKeyboardManager. Responders added
* earlier will receive events earlier.
*/
gboolean fl_keyboard_manager_handle_event(FlKeyboardManager* manager,
FlKeyEvent* event);
/**
* fl_keyboard_manager_is_state_clear:
* @manager: the #FlKeyboardManager self.
*
* Whether the manager's various states are cleared, i.e. no pending events
* for redispatching or for responding. This is mostly used in unittests.
*
* Returns: true if the manager's various states are cleared.
*/
gboolean fl_keyboard_manager_is_state_clear(FlKeyboardManager* manager);
G_END_DECLS
#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_MANAGER_H_