forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlutterEngine_Internal.h
More file actions
212 lines (170 loc) · 6.6 KB
/
FlutterEngine_Internal.h
File metadata and controls
212 lines (170 loc) · 6.6 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
// 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.
#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h"
#import <Cocoa/Cocoa.h>
#include <memory>
#include "flutter/shell/platform/common/app_lifecycle_state.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/AccessibilityBridgeMac.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformViewController.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderer.h"
NS_ASSUME_NONNULL_BEGIN
#pragma mark - Typedefs
typedef void (^FlutterTerminationCallback)(id _Nullable sender);
#pragma mark - Enumerations
/**
* An enum for defining the different request types allowed when requesting an
* application exit.
*
* Must match the entries in the `AppExitType` enum in the Dart code.
*/
typedef NS_ENUM(NSInteger, FlutterAppExitType) {
kFlutterAppExitTypeCancelable = 0,
kFlutterAppExitTypeRequired = 1,
};
/**
* An enum for defining the different responses the framework can give to an
* application exit request from the engine.
*
* Must match the entries in the `AppExitResponse` enum in the Dart code.
*/
typedef NS_ENUM(NSInteger, FlutterAppExitResponse) {
kFlutterAppExitResponseCancel = 0,
kFlutterAppExitResponseExit = 1,
};
#pragma mark - FlutterEngineTerminationHandler
/**
* A handler interface for handling application termination that the
* FlutterAppDelegate can use to coordinate an application exit by sending
* messages through the platform channel managed by the engine.
*/
@interface FlutterEngineTerminationHandler : NSObject
@property(nonatomic, readonly) BOOL shouldTerminate;
@property(nonatomic, readwrite) BOOL acceptingRequests;
- (instancetype)initWithEngine:(FlutterEngine*)engine
terminator:(nullable FlutterTerminationCallback)terminator;
- (void)handleRequestAppExitMethodCall:(NSDictionary<NSString*, id>*)data
result:(FlutterResult)result;
- (void)requestApplicationTermination:(NSApplication*)sender
exitType:(FlutterAppExitType)type
result:(nullable FlutterResult)result;
@end
@interface FlutterEngine ()
/**
* True if the engine is currently running.
*/
@property(nonatomic, readonly) BOOL running;
/**
* Provides the renderer config needed to initialize the engine and also handles external
* texture management.
*/
@property(nonatomic, readonly, nullable) FlutterRenderer* renderer;
/**
* Function pointers for interacting with the embedder.h API.
*/
@property(nonatomic) FlutterEngineProcTable& embedderAPI;
/**
* True if the semantics is enabled. The Flutter framework starts sending
* semantics update through the embedder as soon as it is set to YES.
*/
@property(nonatomic) BOOL semanticsEnabled;
/**
* The executable name for the current process.
*/
@property(nonatomic, readonly, nonnull) NSString* executableName;
/**
* This just returns the NSPasteboard so that it can be mocked in the tests.
*/
@property(nonatomic, readonly, nonnull) NSPasteboard* pasteboard;
/**
* The command line arguments array for the engine.
*/
@property(nonatomic, readonly) std::vector<std::string> switches;
/**
* Provides the |FlutterEngineTerminationHandler| to be used for this engine.
*/
@property(nonatomic, readonly) FlutterEngineTerminationHandler* terminationHandler;
/**
* Attach a view controller to the engine as its default controller.
*
* Practically, since FlutterEngine can only be attached with one controller,
* the given controller, if successfully attached, will always have the default
* view ID kFlutterImplicitViewId.
*
* The engine holds a weak reference to the attached view controller.
*
* If the given view controller is already attached to an engine, this call
* throws an assertion.
*/
- (void)addViewController:(FlutterViewController*)viewController;
/**
* Dissociate the given view controller from this engine.
*
* If the view controller is not associated with this engine, this call throws an
* assertion.
*
* Practically, since FlutterEngine can only be attached with one controller for
* now, the given controller must be the current view controller.
*/
- (void)removeViewController:(FlutterViewController*)viewController;
/**
* The |FlutterViewController| associated with the given view ID, if any.
*/
- (nullable FlutterViewController*)viewControllerForId:(FlutterViewId)viewId;
/**
* Informs the engine that the specified view controller's window metrics have changed.
*/
- (void)updateWindowMetricsForViewController:(FlutterViewController*)viewController;
/**
* Dispatches the given pointer event data to engine.
*/
- (void)sendPointerEvent:(const FlutterPointerEvent&)event;
/**
* Dispatches the given pointer event data to engine.
*/
- (void)sendKeyEvent:(const FlutterKeyEvent&)event
callback:(nullable FlutterKeyEventCallback)callback
userData:(nullable void*)userData;
/**
* Registers an external texture with the given id. Returns YES on success.
*/
- (BOOL)registerTextureWithID:(int64_t)textureId;
/**
* Marks texture with the given id as available. Returns YES on success.
*/
- (BOOL)markTextureFrameAvailable:(int64_t)textureID;
/**
* Unregisters an external texture with the given id. Returns YES on success.
*/
- (BOOL)unregisterTextureWithID:(int64_t)textureID;
- (nonnull FlutterPlatformViewController*)platformViewController;
/**
* Handles changes to the application state, sending them to the framework.
*
* @param state One of the lifecycle constants in app_lifecycle_state.h,
* corresponding to the Dart enum AppLifecycleState.
*/
- (void)setApplicationState:(flutter::AppLifecycleState)state;
// Accessibility API.
/**
* Dispatches semantics action back to the framework. The semantics must be enabled by calling
* the updateSemanticsEnabled before dispatching semantics actions.
*/
- (void)dispatchSemanticsAction:(FlutterSemanticsAction)action
toTarget:(uint16_t)target
withData:(fml::MallocMapping)data;
/**
* Handles accessibility events.
*/
- (void)handleAccessibilityEvent:(NSDictionary<NSString*, id>*)annotatedEvent;
/**
* Announces accessibility messages.
*/
- (void)announceAccessibilityMessage:(NSString*)message
withPriority:(NSAccessibilityPriorityLevel)priority;
@end
@interface FlutterEngine (Tests)
- (nonnull FlutterThreadSynchronizer*)testThreadSynchronizer;
@end
NS_ASSUME_NONNULL_END