|
|
|
@ -195,7 +195,11 @@ public: |
|
|
|
{ |
|
|
|
@autoreleasepool |
|
|
|
{ |
|
|
|
[Window close]; |
|
|
|
if (Window != nullptr) |
|
|
|
{ |
|
|
|
[Window close]; |
|
|
|
} |
|
|
|
|
|
|
|
return S_OK; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -291,7 +295,14 @@ public: |
|
|
|
{ |
|
|
|
@autoreleasepool |
|
|
|
{ |
|
|
|
return [View lockFocusIfCanDraw] == YES; |
|
|
|
@try |
|
|
|
{ |
|
|
|
return [View lockFocusIfCanDraw] == YES; |
|
|
|
} |
|
|
|
@catch (NSException*) |
|
|
|
{ |
|
|
|
return NO; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -719,15 +730,33 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent |
|
|
|
bool _isLeftPressed, _isMiddlePressed, _isRightPressed, _isMouseOver; |
|
|
|
NSEvent* _lastMouseDownEvent; |
|
|
|
bool _lastKeyHandled; |
|
|
|
AvnPixelSize _lastPixelSize; |
|
|
|
} |
|
|
|
|
|
|
|
- (void)dealloc |
|
|
|
- (void)onClosed |
|
|
|
{ |
|
|
|
@synchronized (self) |
|
|
|
{ |
|
|
|
_parent = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
- (void)onClosed |
|
|
|
- (BOOL)lockFocusIfCanDraw |
|
|
|
{ |
|
|
|
@synchronized (self) |
|
|
|
{ |
|
|
|
if(_parent == nullptr) |
|
|
|
{ |
|
|
|
return NO; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return [super lockFocusIfCanDraw]; |
|
|
|
} |
|
|
|
|
|
|
|
-(AvnPixelSize) getPixelSize |
|
|
|
{ |
|
|
|
_parent = NULL; |
|
|
|
return _lastPixelSize; |
|
|
|
} |
|
|
|
|
|
|
|
- (NSEvent*) lastMouseDownEvent |
|
|
|
@ -741,6 +770,8 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent |
|
|
|
[self setWantsBestResolutionOpenGLSurface:true]; |
|
|
|
_parent = parent; |
|
|
|
_area = nullptr; |
|
|
|
_lastPixelSize.Height = 100; |
|
|
|
_lastPixelSize.Width = 100; |
|
|
|
return self; |
|
|
|
} |
|
|
|
|
|
|
|
@ -782,6 +813,10 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent |
|
|
|
[self addTrackingArea:_area]; |
|
|
|
|
|
|
|
_parent->UpdateCursor(); |
|
|
|
|
|
|
|
auto fsize = [self convertSizeToBacking: [self frame].size]; |
|
|
|
_lastPixelSize.Width = (int)fsize.width; |
|
|
|
_lastPixelSize.Height = (int)fsize.height; |
|
|
|
|
|
|
|
_parent->BaseEvents->Resized(AvnSize{newSize.width, newSize.height}); |
|
|
|
} |
|
|
|
@ -811,7 +846,13 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent |
|
|
|
|
|
|
|
- (void)drawRect:(NSRect)dirtyRect |
|
|
|
{ |
|
|
|
if (_parent == nullptr) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
_parent->BaseEvents->RunRenderPriorityJobs(); |
|
|
|
|
|
|
|
@synchronized (self) { |
|
|
|
if(_swRenderedFrame != NULL) |
|
|
|
{ |
|
|
|
@ -878,7 +919,12 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent |
|
|
|
|
|
|
|
- (void) viewDidChangeBackingProperties |
|
|
|
{ |
|
|
|
auto fsize = [self convertSizeToBacking: [self frame].size]; |
|
|
|
_lastPixelSize.Width = (int)fsize.width; |
|
|
|
_lastPixelSize.Height = (int)fsize.height; |
|
|
|
|
|
|
|
_parent->BaseEvents->ScalingChanged([_parent->Window backingScaleFactor]); |
|
|
|
|
|
|
|
[super viewDidChangeBackingProperties]; |
|
|
|
} |
|
|
|
|
|
|
|
@ -1129,6 +1175,12 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent |
|
|
|
bool _closed; |
|
|
|
NSMenu* _menu; |
|
|
|
bool _isAppMenuApplied; |
|
|
|
double _lastScaling; |
|
|
|
} |
|
|
|
|
|
|
|
-(double) getScaling |
|
|
|
{ |
|
|
|
return _lastScaling; |
|
|
|
} |
|
|
|
|
|
|
|
+(void)closeAll |
|
|
|
@ -1142,10 +1194,6 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
- (void)dealloc |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
- (void)pollModalSession:(nonnull NSModalSession)session |
|
|
|
{ |
|
|
|
auto response = [NSApp runModalSession:session]; |
|
|
|
@ -1200,6 +1248,9 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent |
|
|
|
[self setReleasedWhenClosed:false]; |
|
|
|
_parent = parent; |
|
|
|
[self setDelegate:self]; |
|
|
|
_closed = false; |
|
|
|
|
|
|
|
_lastScaling = [self backingScaleFactor]; |
|
|
|
return self; |
|
|
|
} |
|
|
|
|
|
|
|
@ -1215,6 +1266,11 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
- (void)windowDidChangeBackingProperties:(NSNotification *)notification |
|
|
|
{ |
|
|
|
_lastScaling = [self backingScaleFactor]; |
|
|
|
} |
|
|
|
|
|
|
|
- (void)windowWillClose:(NSNotification *)notification |
|
|
|
{ |
|
|
|
_closed = true; |
|
|
|
@ -1225,9 +1281,6 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent |
|
|
|
[self restoreParentWindow]; |
|
|
|
parent->BaseEvents->Closed(); |
|
|
|
[parent->View onClosed]; |
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{ |
|
|
|
[self setContentView: nil]; |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -1374,18 +1427,6 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent |
|
|
|
_parent->GetPosition(&position); |
|
|
|
_parent->BaseEvents->PositionChanged(position); |
|
|
|
} |
|
|
|
|
|
|
|
// TODO this breaks resizing. |
|
|
|
/*- (void)windowDidResize:(NSNotification *)notification |
|
|
|
{ |
|
|
|
|
|
|
|
auto parent = dynamic_cast<IWindowStateChanged*>(_parent.operator->()); |
|
|
|
|
|
|
|
if(parent != nullptr) |
|
|
|
{ |
|
|
|
parent->WindowStateChanged(); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
@end |
|
|
|
|
|
|
|
class PopupImpl : public virtual WindowBaseImpl, public IAvnPopup |
|
|
|
|