From 5df49201843da11d514ffaeeb76aad5ea2c4d68f Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 17 Sep 2010 00:25:09 +0200 Subject: [PATCH] Added window move handler to window delegate. --- src/cocoa/cocoa_window.m | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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;