update tracking area on OSX when resizing view

This commit is contained in:
2019-03-11 17:27:00 +01:00
parent fda399f7dd
commit c111495cae
3 changed files with 22 additions and 10 deletions

View File

@@ -125,7 +125,7 @@ std::mutex task_mutex;
[self setPixelFormat:pf];
[self setOpenGLContext:context];
NSTrackingArea* trackingArea = [[NSTrackingArea alloc] initWithRect:frameRect
self->trackingArea = [[NSTrackingArea alloc] initWithRect:frameRect
options: (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveInKeyWindow )
owner:self userInfo:nil];
[self addTrackingArea:trackingArea];
@@ -266,20 +266,28 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
CGLFlushDrawable(cgl);
CGLUnlockContext(cgl);
}
- (void)updateTrackingAreas
{
if(self->trackingArea != nil)
[self removeTrackingArea:self->trackingArea];
self->trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
options: (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveInKeyWindow)
owner:self userInfo:nil];
[self addTrackingArea:trackingArea];
}
- (void)reshape
{
[super reshape];
// Get the view size in Points
NSRect viewRectPoints = [self bounds];
// We draw on a secondary thread through the display link. However, when
// resizing the view, -drawRect is called on the main thread.
// Add a mutex around to avoid the threads accessing the context
// simultaneously when resizing.
CGLLockContext([[self openGLContext] CGLContextObj]);
// Get the view size in Points
NSRect viewRectPoints = [self bounds];
#if SUPPORT_RETINA_RESOLUTION
// Rendering at retina resolutions will reduce aliasing, but at the potential