forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fl_key_channel_responder.h
101 lines (88 loc) · 3.37 KB
/
fl_key_channel_responder.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
// 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_KEY_CHANNEL_RESPONDER_H_
#define FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_CHANNEL_RESPONDER_H_
#include "flutter/shell/platform/linux/fl_key_event.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h"
typedef FlValue* (*FlValueConverter)(FlValue*);
/**
* FlKeyChannelResponderMock:
*
* Allows mocking of FlKeyChannelResponder methods and values. Only used in
* unittests.
*/
typedef struct _FlKeyChannelResponderMock {
/**
* FlKeyChannelResponderMock::value_converter:
* If #value_converter is not nullptr, then this function is applied to the
* reply of the message, whose return value is taken as the message reply.
*/
FlValueConverter value_converter;
/**
* FlKeyChannelResponderMock::channel_name:
* Mocks the channel name to send the message.
*/
const char* channel_name;
} FlKeyChannelResponderMock;
G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE(FlKeyChannelResponder,
fl_key_channel_responder,
FL,
KEY_CHANNEL_RESPONDER,
GObject);
/**
* FlKeyChannelResponderAsyncCallback:
* @event: whether the event has been handled.
* @user_data: the same value as user_data sent by
* #fl_key_responder_handle_event.
*
* The signature for a callback with which a #FlKeyChannelResponder
*asynchronously reports whether the responder handles the event.
**/
typedef void (*FlKeyChannelResponderAsyncCallback)(bool handled,
gpointer user_data);
/**
* FlKeyChannelResponder:
*
* A #FlKeyResponder that handles events by sending the raw event data
* in JSON through the message channel.
*
* This class communicates with the RawKeyboard API in the framework.
*/
/**
* fl_key_channel_responder_new:
* @messenger: the messenger that the message channel should be built on.
* @mock: options to mock several functionalities. Only used in unittests.
*
* Creates a new #FlKeyChannelResponder.
*
* Returns: a new #FlKeyChannelResponder.
*/
FlKeyChannelResponder* fl_key_channel_responder_new(
FlBinaryMessenger* messenger,
FlKeyChannelResponderMock* mock = nullptr);
/**
* fl_key_channel_responder_handle_event:
* @responder: the #FlKeyChannelResponder self.
* @event: the event to be handled. Must not be null. The object is managed by
* callee and must not be assumed available after this function.
* @specified_logical_key:
* @callback: the callback to report the result. It should be called exactly
* once. Must not be null.
* @user_data: a value that will be sent back in the callback. Can be null.
*
* Let the responder handle an event, expecting the responder to report
* whether to handle the event. The result will be reported by invoking
* `callback` exactly once, which might happen after
* `fl_key_channel_responder_handle_event` or during it.
*/
void fl_key_channel_responder_handle_event(
FlKeyChannelResponder* responder,
FlKeyEvent* event,
uint64_t specified_logical_key,
FlKeyChannelResponderAsyncCallback callback,
gpointer user_data);
G_END_DECLS
#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEY_CHANNEL_RESPONDER_H_