diff --git a/src/cocoa/cocoa_window.m b/src/cocoa/cocoa_window.m index 8f5fbe18..ee9ac522 100644 --- a/src/cocoa/cocoa_window.m +++ b/src/cocoa/cocoa_window.m @@ -74,6 +74,23 @@ window->windowSizeCallback(window, window->width, window->height); } +- (void)windowDidMove:(NSNotification *)notification +{ + [window->NSGL.context update]; + + NSRect contentRect = + [window->NS.window contentRectForFrameRect:[window->NS.window frame]]; + + CGPoint mainScreenOrigin = CGDisplayBounds(CGMainDisplayID()).origin; + double mainScreenHeight = CGDisplayBounds(CGMainDisplayID()).size.height; + CGPoint flippedPos = CGPointMake(contentRect.origin.x - mainScreenOrigin.x, + mainScreenHeight - contentRect.origin.y - + mainScreenOrigin.y - window->height); + + window->positionX = flippedPos.x; + window->positionY = flippedPos.y; +} + - (void)windowDidMiniaturize:(NSNotification*)notification { window->iconified = GL_TRUE;