Skip to content

[macos] Adjust for embedding API type name change #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ - (BOOL)launchEngineInternalWithAssetsPath:(NSURL *)assets
flutterArguments.command_line_argv = argv;
flutterArguments.platform_message_callback = (FlutterPlatformMessageCallback)OnPlatformMessage;

FlutterResult result = FlutterEngineRun(FLUTTER_ENGINE_VERSION, &config, &flutterArguments,
// TODO: Replace auto with FlutterEngineResult after next required Flutter update.
auto result = FlutterEngineRun(FLUTTER_ENGINE_VERSION, &config, &flutterArguments,
(__bridge void *)(self), &_engine);
free(argv);
if (result != kSuccess) {
Expand Down Expand Up @@ -350,7 +351,8 @@ - (void)handlePlatformMessage:(const FlutterPlatformMessage *)message {

FLEBinaryReply binaryResponseHandler = ^(NSData *response) {
if (responseHandle) {
FlutterEngineSendPlatformMessageResponse(self->_engine, responseHandle, response.bytes,
FlutterEngineSendPlatformMessageResponse(self->_engine, responseHandle,
static_cast<const uint8_t *>(response.bytes),
response.length);
responseHandle = NULL;
} else {
Expand All @@ -376,7 +378,7 @@ - (void)dispatchMouseEvent:(NSEvent *)event phase:(FlutterPointerPhase)phase {
.phase = phase,
.x = locationInBackingCoordinates.x,
.y = -locationInBackingCoordinates.y, // convertPointToBacking makes this negative.
.timestamp = event.timestamp * NSEC_PER_MSEC,
.timestamp = static_cast<const size_t>(event.timestamp * NSEC_PER_MSEC),
};
FlutterEngineSendPointerEvent(_engine, &flutterEvent, 1);
}
Expand All @@ -386,12 +388,11 @@ - (void)dispatchKeyEvent:(NSEvent *)event ofType:(NSString *)type {
@"keymap" : @"android",
@"type" : type,
@"keyCode" : @(event.keyCode),
@"metaState" : @(
((event.modifierFlags & NSEventModifierFlagShift) ? kAndroidMetaStateShift : 0) |
((event.modifierFlags & NSEventModifierFlagOption) ? kAndroidMetaStateAlt : 0) |
((event.modifierFlags & NSEventModifierFlagControl) ? kAndroidMetaStateCtrl : 0) |
((event.modifierFlags & NSEventModifierFlagCommand) ? kAndroidMetaStateMeta : 0)
)
@"metaState" :
@(((event.modifierFlags & NSEventModifierFlagShift) ? kAndroidMetaStateShift : 0) |
((event.modifierFlags & NSEventModifierFlagOption) ? kAndroidMetaStateAlt : 0) |
((event.modifierFlags & NSEventModifierFlagControl) ? kAndroidMetaStateCtrl : 0) |
((event.modifierFlags & NSEventModifierFlagCommand) ? kAndroidMetaStateMeta : 0))
}];
}

Expand All @@ -404,8 +405,8 @@ - (void)viewDidReshape:(NSOpenGLView *)view {
CGRect scaledBounds = [view convertRectToBacking:view.bounds];
const FlutterWindowMetricsEvent event = {
.struct_size = sizeof(event),
.width = scaledBounds.size.width,
.height = scaledBounds.size.height,
.width = static_cast<const size_t>(scaledBounds.size.width),
.height = static_cast<const size_t>(scaledBounds.size.height),
.pixel_ratio = scaledBounds.size.width / view.bounds.size.width,
};
FlutterEngineSendWindowMetricsEvent(_engine, &event);
Expand All @@ -417,11 +418,12 @@ - (void)sendOnChannel:(nonnull NSString *)channel message:(nullable NSData *)mes
FlutterPlatformMessage platformMessage = {
.struct_size = sizeof(FlutterPlatformMessage),
.channel = [channel UTF8String],
.message = message.bytes,
.message = static_cast<const uint8_t *>(message.bytes),
.message_size = message.length,
};

FlutterResult result = FlutterEngineSendPlatformMessage(_engine, &platformMessage);
// TODO: Replace auto with FlutterEngineResult after next required Flutter update.
auto result = FlutterEngineSendPlatformMessage(_engine, &platformMessage);
if (result != kSuccess) {
NSLog(@"Failed to send message to Flutter engine on channel '%@' (%d).", channel, result);
}
Expand Down
8 changes: 4 additions & 4 deletions library/macos/FlutterEmbedderMac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
1E24923C1FCF50BE00DD3BBB /* FLEReshapeListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E2492321FCF50BE00DD3BBB /* FLEReshapeListener.h */; settings = {ATTRIBUTES = (Public, ); }; };
1E24923E1FCF50BE00DD3BBB /* FLETextInputPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E2492341FCF50BE00DD3BBB /* FLETextInputPlugin.m */; };
1E24923F1FCF50BE00DD3BBB /* FLEViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E2492351FCF50BE00DD3BBB /* FLEViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
1E2492401FCF50BE00DD3BBB /* FLEViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E2492361FCF50BE00DD3BBB /* FLEViewController.m */; };
1E2492401FCF50BE00DD3BBB /* FLEViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1E2492361FCF50BE00DD3BBB /* FLEViewController.mm */; };
1E2492411FCF50BE00DD3BBB /* FlutterEmbedderMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E2492371FCF50BE00DD3BBB /* FlutterEmbedderMac.h */; settings = {ATTRIBUTES = (Public, ); }; };
1EEF8E071FD1F0C300DD563C /* FLEView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1EEF8E051FD1F0C300DD563C /* FLEView.h */; settings = {ATTRIBUTES = (Public, ); }; };
1EEF8E081FD1F0C300DD563C /* FLEView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1EEF8E061FD1F0C300DD563C /* FLEView.m */; };
Expand Down Expand Up @@ -87,7 +87,7 @@
1E2492331FCF50BE00DD3BBB /* FLETextInputPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLETextInputPlugin.h; sourceTree = "<group>"; };
1E2492341FCF50BE00DD3BBB /* FLETextInputPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLETextInputPlugin.m; sourceTree = "<group>"; };
1E2492351FCF50BE00DD3BBB /* FLEViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEViewController.h; sourceTree = "<group>"; };
1E2492361FCF50BE00DD3BBB /* FLEViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEViewController.m; sourceTree = "<group>"; };
1E2492361FCF50BE00DD3BBB /* FLEViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FLEViewController.mm; sourceTree = "<group>"; };
1E2492371FCF50BE00DD3BBB /* FlutterEmbedderMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlutterEmbedderMac.h; sourceTree = "<group>"; };
1E2492381FCF50BE00DD3BBB /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
1EEF8E051FD1F0C300DD563C /* FLEView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEView.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -148,7 +148,7 @@
1E2492341FCF50BE00DD3BBB /* FLETextInputPlugin.m */,
1EEF8E061FD1F0C300DD563C /* FLEView.m */,
6442F82C20EA6C5F00A393AE /* FLEViewController+Internal.h */,
1E2492361FCF50BE00DD3BBB /* FLEViewController.m */,
1E2492361FCF50BE00DD3BBB /* FLEViewController.mm */,
1E2492381FCF50BE00DD3BBB /* Info.plist */,
33B1650E201A5F7400732DC9 /* Dependencies */,
1E2492251FCF504200DD3BBB /* Products */,
Expand Down Expand Up @@ -316,7 +316,7 @@
buildActionMask = 2147483647;
files = (
33D7B59A20A4F54400296EFC /* FLEMethodChannel.m in Sources */,
1E2492401FCF50BE00DD3BBB /* FLEViewController.m in Sources */,
1E2492401FCF50BE00DD3BBB /* FLEViewController.mm in Sources */,
3389A68D215949CB00A27898 /* FLEMethodError.m in Sources */,
33C0FA2721B84AA4008F8959 /* FLEMethodCall.m in Sources */,
33C0FA2021B84810008F8959 /* FLEJSONMessageCodec.m in Sources */,
Expand Down