5#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h"
7#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h"
8#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterThreadSynchronizer.h"
10#import <QuartzCore/QuartzCore.h>
12@interface FlutterView () <FlutterSurfaceManagerDelegate> {
24- (instancetype)initWithMTLDevice:(
id<MTLDevice>)device
25 commandQueue:(
id<MTLCommandQueue>)commandQueue
26 delegate:(
id<FlutterViewDelegate>)delegate
29 self = [
super initWithFrame:NSZeroRect];
31 [
self setWantsLayer:YES];
32 [
self setBackgroundColor:[NSColor blackColor]];
33 [
self setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawDuringViewResize];
34 _viewIdentifier = viewIdentifier;
35 _viewDelegate = delegate;
38 commandQueue:commandQueue
45- (void)onPresent:(CGSize)frameSize withBlock:(dispatch_block_t)block {
46 [_threadSynchronizer performCommitForView:_viewIdentifier size:frameSize notify:block];
54 CGSize scaledSize = [
self convertSizeToBacking:self.bounds.size];
55 [_threadSynchronizer beginResizeForView:_viewIdentifier
58 [_viewDelegate viewDidReshape:self];
62- (void)setBackgroundColor:(NSColor*)color {
63 self.layer.backgroundColor =
color.CGColor;
66#pragma mark - NSView overrides
68- (void)setFrameSize:(NSSize)newSize {
69 [
super setFrameSize:newSize];
88- (
BOOL)acceptsFirstMouse:(NSEvent*)event {
95 return [_viewDelegate viewShouldAcceptFirstResponder:self];
98- (void)didUpdateMouseCursor:(NSCursor*)cursor {
108- (void)cursorUpdate:(NSEvent*)event {
110 NSView* hitTestView = [
self hitTest:[
self convertPoint:event.locationInWindow fromView:nil]];
111 if (hitTestView !=
self) {
119 [[NSRunLoop currentRunLoop] performBlock:^{
125 [
super viewDidChangeBackingProperties];
127 [_viewDelegate viewDidReshape:self];
130- (
BOOL)layer:(CALayer*)layer
131 shouldInheritContentsScale:(CGFloat)newScale
132 fromWindow:(NSWindow*)window {
136#pragma mark - NSAccessibility overrides
143 return NSAccessibilityGroupRole;
150 NSString* applicationName =
151 [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
152 if (!applicationName) {
153 applicationName = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleName"];
155 return applicationName;
BOOL acceptsFirstResponder()
BOOL isAccessibilityElement()
__weak id< FlutterViewDelegate > _viewDelegate
FlutterSurfaceManager * surfaceManager
NSString * accessibilityLabel()
NSAccessibilityRole accessibilityRole()
void viewDidChangeBackingProperties()
FlutterSurfaceManager * _surfaceManager
FlutterThreadSynchronizer * _threadSynchronizer
FlutterViewIdentifier _viewIdentifier
FlutterThreadSynchronizer * _threadSynchronizer