10 #import <QuartzCore/QuartzCore.h>
23 - (instancetype)initWithMTLDevice:(
id<MTLDevice>)device
24 commandQueue:(
id<MTLCommandQueue>)commandQueue
27 viewId:(int64_t)viewId {
28 self = [
super initWithFrame:NSZeroRect];
30 [
self setWantsLayer:YES];
31 [
self setBackgroundColor:[NSColor blackColor]];
32 [
self setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawDuringViewResize];
34 _viewDelegate = delegate;
37 commandQueue:commandQueue
44 - (void)onPresent:(CGSize)frameSize withBlock:(dispatch_block_t)block {
45 [_threadSynchronizer performCommitForView:_viewId size:frameSize notify:block];
49 return _surfaceManager;
53 CGSize scaledSize = [
self convertSizeToBacking:self.bounds.size];
54 [_threadSynchronizer beginResizeForView:_viewId
57 [_viewDelegate viewDidReshape:self];
61 - (void)setBackgroundColor:(NSColor*)color {
62 self.layer.backgroundColor = color.CGColor;
65 #pragma mark - NSView overrides
67 - (void)setFrameSize:(NSSize)newSize {
68 [
super setFrameSize:newSize];
87 - (BOOL)acceptsFirstMouse:(NSEvent*)event {
91 - (BOOL)acceptsFirstResponder {
94 return [_viewDelegate viewShouldAcceptFirstResponder:self];
97 - (void)cursorUpdate:(NSEvent*)event {
106 - (void)viewDidChangeBackingProperties {
107 [
super viewDidChangeBackingProperties];
109 [_viewDelegate viewDidReshape:self];
112 - (BOOL)layer:(CALayer*)layer
113 shouldInheritContentsScale:(CGFloat)newScale
114 fromWindow:(NSWindow*)window {
118 #pragma mark - NSAccessibility overrides
120 - (BOOL)isAccessibilityElement {
124 - (NSAccessibilityRole)accessibilityRole {
125 return NSAccessibilityGroupRole;
128 - (NSString*)accessibilityLabel {
132 NSString* applicationName =
133 [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
134 if (!applicationName) {
135 applicationName = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleName"];
137 return applicationName;