forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfl_keyboard_view_delegate.h
More file actions
133 lines (109 loc) · 4.36 KB
/
fl_keyboard_view_delegate.h
File metadata and controls
133 lines (109 loc) · 4.36 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// 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_VIEW_DELEGATE_H_
#define FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_VIEW_DELEGATE_H_
#include <gdk/gdk.h>
#include <cinttypes>
#include <functional>
#include <memory>
#include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/linux/fl_key_event.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h"
typedef std::function<void()> KeyboardLayoutNotifier;
G_BEGIN_DECLS
G_DECLARE_INTERFACE(FlKeyboardViewDelegate,
fl_keyboard_view_delegate,
FL,
KEYBOARD_VIEW_DELEGATE,
GObject);
/**
* FlKeyboardViewDelegate:
*
* An interface for a class that provides `FlKeyboardHandler` with
* platform-related features.
*
* This interface is typically implemented by `FlView`.
*/
struct _FlKeyboardViewDelegateInterface {
GTypeInterface g_iface;
void (*send_key_event)(FlKeyboardViewDelegate* delegate,
const FlutterKeyEvent* event,
FlutterKeyEventCallback callback,
void* user_data);
gboolean (*text_filter_key_press)(FlKeyboardViewDelegate* delegate,
FlKeyEvent* event);
FlBinaryMessenger* (*get_messenger)(FlKeyboardViewDelegate* delegate);
void (*redispatch_event)(FlKeyboardViewDelegate* delegate,
std::unique_ptr<FlKeyEvent> event);
void (*subscribe_to_layout_change)(FlKeyboardViewDelegate* delegate,
KeyboardLayoutNotifier notifier);
guint (*lookup_key)(FlKeyboardViewDelegate* view_delegate,
const GdkKeymapKey* key);
GHashTable* (*get_keyboard_state)(FlKeyboardViewDelegate* delegate);
};
/**
* fl_keyboard_view_delegate_send_key_event:
*
* Handles `FlKeyboardHandler`'s request to send a `FlutterKeyEvent` through the
* embedder API to the framework.
*
* The ownership of the `event` is kept by the keyboard handler, and the `event`
* might be immediately destroyed after this function returns.
*
* The `callback` must eventually be called exactly once with the event result
* and the `user_data`.
*/
void fl_keyboard_view_delegate_send_key_event(FlKeyboardViewDelegate* delegate,
const FlutterKeyEvent* event,
FlutterKeyEventCallback callback,
void* user_data);
/**
* fl_keyboard_view_delegate_text_filter_key_press:
*
* Handles `FlKeyboardHandler`'s request to check if the GTK text input IM
* filter would like to handle a GDK event.
*
* The ownership of the `event` is kept by the keyboard handler.
*/
gboolean fl_keyboard_view_delegate_text_filter_key_press(
FlKeyboardViewDelegate* delegate,
FlKeyEvent* event);
/**
* fl_keyboard_view_delegate_get_messenger:
*
* Returns a binary messenger that can be used to send messages to the
* framework.
*
* The ownership of messenger is kept by the view delegate.
*/
FlBinaryMessenger* fl_keyboard_view_delegate_get_messenger(
FlKeyboardViewDelegate* delegate);
/**
* fl_keyboard_view_delegate_redispatch_event:
*
* Handles `FlKeyboardHandler`'s request to insert a GDK event to the system for
* redispatching.
*
* The ownership of event will be transferred to the view delegate. The view
* delegate is responsible to call fl_key_event_dispose.
*/
void fl_keyboard_view_delegate_redispatch_event(
FlKeyboardViewDelegate* delegate,
std::unique_ptr<FlKeyEvent> event);
void fl_keyboard_view_delegate_subscribe_to_layout_change(
FlKeyboardViewDelegate* delegate,
KeyboardLayoutNotifier notifier);
guint fl_keyboard_view_delegate_lookup_key(FlKeyboardViewDelegate* delegate,
const GdkKeymapKey* key);
/**
* fl_keyboard_view_delegate_get_keyboard_state:
*
* Returns the keyboard pressed state. The hash table contains one entry per
* pressed keys, mapping from the logical key to the physical key.*
*
*/
GHashTable* fl_keyboard_view_delegate_get_keyboard_state(
FlKeyboardViewDelegate* delegate);
G_END_DECLS
#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_VIEW_DELEGATE_H_