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>
24- (instancetype)initWithMTLDevice:(
id<MTLDevice>)device
25 commandQueue:(
id<MTLCommandQueue>)commandQueue
29 self = [
super initWithFrame:NSZeroRect];
31 [
self setWantsLayer:YES];
32 [
self setBackgroundColor:[NSColor blackColor]];
33 [
self setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawDuringViewResize];
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 NSPoint mouseLocation = [[
self superview] convertPoint:event.locationInWindow fromView:nil];
111 NSView* hitTestView = [
self hitTest:mouseLocation];
112 if (hitTestView !=
self) {
120 [[NSRunLoop currentRunLoop] performBlock:^{
126 [
super viewDidChangeBackingProperties];
128 [_viewDelegate viewDidReshape:self];
131- (
BOOL)layer:(CALayer*)layer
132 shouldInheritContentsScale:(CGFloat)newScale
133 fromWindow:(NSWindow*)window {
137#pragma mark - NSAccessibility overrides
144 return NSAccessibilityGroupRole;
151 NSString* applicationName =
152 [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
153 if (!applicationName) {
154 applicationName = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleName"];
156 return applicationName;
BOOL acceptsFirstResponder()
BOOL isAccessibilityElement()
__weak id< FlutterViewDelegate > _viewDelegate
FlutterSurfaceManager * surfaceManager
NSString * accessibilityLabel()
id< FlutterViewEngineDelegate > delegate
NSAccessibilityRole accessibilityRole()
void viewDidChangeBackingProperties()
FlutterSurfaceManager * _surfaceManager
FlutterThreadSynchronizer * _threadSynchronizer
FlutterViewIdentifier _viewIdentifier