|
|
|
|
@ -32,11 +32,48 @@
|
|
|
|
|
|
|
|
|
|
#include "display_server_macos.h"
|
|
|
|
|
#include "key_mapping_macos.h"
|
|
|
|
|
#include "main/main.h"
|
|
|
|
|
|
|
|
|
|
@implementation GodotContentLayerDelegate
|
|
|
|
|
|
|
|
|
|
- (id)init {
|
|
|
|
|
self = [super init];
|
|
|
|
|
window_id = DisplayServer::INVALID_WINDOW_ID;
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)setWindowID:(DisplayServerMacOS::WindowID)wid {
|
|
|
|
|
window_id = wid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)displayLayer:(CALayer *)layer {
|
|
|
|
|
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
|
|
|
|
|
if (OS::get_singleton()->get_main_loop() && ds->get_is_resizing()) {
|
|
|
|
|
Main::force_redraw();
|
|
|
|
|
if (!Main::is_iterating()) { // Avoid cyclic loop.
|
|
|
|
|
Main::iteration();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation GodotContentView
|
|
|
|
|
|
|
|
|
|
- (void)setFrameSize:(NSSize)newSize {
|
|
|
|
|
[super setFrameSize:newSize];
|
|
|
|
|
[self.layer setNeedsDisplay]; // Force "drawRect" call.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)updateLayerDelegate {
|
|
|
|
|
self.layer.delegate = layer_delegate;
|
|
|
|
|
self.layer.autoresizingMask = kCALayerHeightSizable | kCALayerWidthSizable;
|
|
|
|
|
self.layer.needsDisplayOnBoundsChange = YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id)init {
|
|
|
|
|
self = [super init];
|
|
|
|
|
layer_delegate = [[GodotContentLayerDelegate alloc] init];
|
|
|
|
|
window_id = DisplayServer::INVALID_WINDOW_ID;
|
|
|
|
|
tracking_area = nil;
|
|
|
|
|
ime_input_event_in_progress = false;
|
|
|
|
|
@ -45,6 +82,9 @@
|
|
|
|
|
last_pen_inverted = false;
|
|
|
|
|
[self updateTrackingAreas];
|
|
|
|
|
|
|
|
|
|
self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawDuringViewResize;
|
|
|
|
|
self.layerContentsPlacement = NSViewLayerContentsPlacementTopLeft;
|
|
|
|
|
|
|
|
|
|
if (@available(macOS 10.13, *)) {
|
|
|
|
|
[self registerForDraggedTypes:[NSArray arrayWithObject:NSPasteboardTypeFileURL]];
|
|
|
|
|
#if !defined(__aarch64__) // Do not build deprectead 10.13 code on ARM.
|
|
|
|
|
@ -58,6 +98,7 @@
|
|
|
|
|
|
|
|
|
|
- (void)setWindowID:(DisplayServerMacOS::WindowID)wid {
|
|
|
|
|
window_id = wid;
|
|
|
|
|
[layer_delegate setWindowID:window_id];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: Backing Layer
|
|
|
|
|
|