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 _reshapeListener = reshapeListener;
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 [_reshapeListener 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 {
95 - (void)cursorUpdate:(NSEvent*)event {
104 - (void)viewDidChangeBackingProperties {
105 [
super viewDidChangeBackingProperties];
107 [_reshapeListener viewDidReshape:self];
110 - (BOOL)layer:(CALayer*)layer
111 shouldInheritContentsScale:(CGFloat)newScale
112 fromWindow:(NSWindow*)window {
116 #pragma mark - NSAccessibility overrides
118 - (BOOL)isAccessibilityElement {
122 - (NSAccessibilityRole)accessibilityRole {
123 return NSAccessibilityGroupRole;
126 - (NSString*)accessibilityLabel {
130 NSString* applicationName =
131 [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
132 if (!applicationName) {
133 applicationName = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleName"];
135 return applicationName;