From f9c47408949c870a7d63bf50b107b94048c4a20d Mon Sep 17 00:00:00 2001 From: mantognini Date: Thu, 20 Jan 2011 13:04:25 +0000 Subject: [PATCH] OSX, fixed mouse pos in event. git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1771 4e206d99-4929-0410-ac5d-dfc041789085 --- src/SFML/Window/OSX/SFContext.hpp | 8 ++++---- src/SFML/Window/OSX/SFContext.mm | 14 +++++++++----- src/SFML/Window/OSX/SFOpenGLView.mm | 20 ++++++++++---------- src/SFML/Window/OSX/WindowImplCocoa.mm | 2 +- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/SFML/Window/OSX/SFContext.hpp b/src/SFML/Window/OSX/SFContext.hpp index 58b4d43be..31dbc673a 100644 --- a/src/SFML/Window/OSX/SFContext.hpp +++ b/src/SFML/Window/OSX/SFContext.hpp @@ -79,7 +79,7 @@ public: /// //////////////////////////////////////////////////////////// SFContext(SFContext* shared, const WindowImpl* owner, - unsigned int bitsPerPixel, const ContextSettings& settings); + unsigned int bitsPerPixel, const ContextSettings& settings); //////////////////////////////////////////////////////////// /// \brief Destructor @@ -127,13 +127,13 @@ private: /// //////////////////////////////////////////////////////////// void CreateContext(SFContext* shared, - const ContextSettings& settings, - unsigned int bitsPerPixel); + const ContextSettings& settings, + unsigned int bitsPerPixel); //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - NSOpenGLContextRef myContext; ///< OpenGL context + NSOpenGLContextRef myContext; ///< OpenGL context NSAutoreleasePoolRef myPool; ///< Memory manager for this class. }; diff --git a/src/SFML/Window/OSX/SFContext.mm b/src/SFML/Window/OSX/SFContext.mm index 7f632ee9a..629067ded 100644 --- a/src/SFML/Window/OSX/SFContext.mm +++ b/src/SFML/Window/OSX/SFContext.mm @@ -62,7 +62,7 @@ SFContext::SFContext(SFContext* shared) //////////////////////////////////////////////////////////// SFContext::SFContext(SFContext* shared, const WindowImpl* owner, - unsigned int bitsPerPixel, const ContextSettings& settings) + unsigned int bitsPerPixel, const ContextSettings& settings) { myPool = [[NSAutoreleasePool alloc] init]; @@ -79,7 +79,11 @@ SFContext::SFContext(SFContext* shared, const WindowImpl* owner, SFContext::~SFContext() { [myContext release]; - [myPool release]; + [myPool drain]; // [1] + + /* + [1] : Produce sometimes "*** attempt to pop an unknown autorelease pool" + */ } @@ -114,8 +118,8 @@ void SFContext::EnableVerticalSync(bool enabled) //////////////////////////////////////////////////////////// void SFContext::CreateContext(SFContext* shared, - const ContextSettings& settings, - unsigned int bitsPerPixel) + const ContextSettings& settings, + unsigned int bitsPerPixel) { // Choose the attributs of OGL context. std::vector attrs; @@ -163,7 +167,7 @@ void SFContext::CreateContext(SFContext* shared, // Create the context. myContext = [[NSOpenGLContext alloc] initWithFormat:pixFmt - shareContext:sharedContext]; + shareContext:sharedContext]; // Free up. [pixFmt release]; diff --git a/src/SFML/Window/OSX/SFOpenGLView.mm b/src/SFML/Window/OSX/SFOpenGLView.mm index 9631ac448..dc540ca7d 100644 --- a/src/SFML/Window/OSX/SFOpenGLView.mm +++ b/src/SFML/Window/OSX/SFOpenGLView.mm @@ -160,7 +160,7 @@ NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; // Don't forget to change to SFML coord system. - float h = [[theEvent window] frame].size.height; + float h = [self frame].size.height; myRequester->MouseDownAt(sf::Mouse::Left, loc.x, h - loc.y); } @@ -172,7 +172,7 @@ NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; // Don't forget to change to SFML coord system. - float h = [[theEvent window] frame].size.height; + float h = [self frame].size.height; myRequester->MouseUpAt(sf::Mouse::Left, loc.x, h - loc.y); } @@ -199,7 +199,7 @@ NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; // Don't forget to change to SFML coord system. - float h = [[theEvent window] frame].size.height; + float h = [self frame].size.height; myRequester->MouseWheelScrolledAt([theEvent deltaY], loc.x, h - loc.y); } @@ -233,7 +233,7 @@ NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; // Don't forget to change to SFML coord system. - float h = [[theEvent window] frame].size.height; + float h = [self frame].size.height; myRequester->MouseDownAt(sf::Mouse::Right, loc.x, h - loc.y); } @@ -245,7 +245,7 @@ NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; // Don't forget to change to SFML coord system. - float h = [[theEvent window] frame].size.height; + float h = [self frame].size.height; myRequester->MouseUpAt(sf::Mouse::Right, loc.x, h - loc.y); } @@ -271,7 +271,7 @@ break; } // Don't forget to change to SFML coord system. - float h = [[theEvent window] frame].size.height; + float h = [self frame].size.height; myRequester->MouseDownAt(button, loc.x, h - loc.y); } @@ -297,7 +297,7 @@ break; } // Don't forget to change to SFML coord system. - float h = [[theEvent window] frame].size.height; + float h = [self frame].size.height; myRequester->MouseUpAt(button, loc.x, h - loc.y); } @@ -312,7 +312,7 @@ NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; // Don't forget to change to SFML coord system. - float h = [[theEvent window] frame].size.height; + float h = [self frame].size.height; myRequester->MouseMovedAt(loc.x, h - loc.y); } @@ -327,7 +327,7 @@ NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; // Don't forget to change to SFML coord system. - float h = [[theEvent window] frame].size.height; + float h = [self frame].size.height; myRequester->MouseMovedAt(loc.x, h - loc.y); } @@ -342,7 +342,7 @@ NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; // Don't forget to change to SFML coord system. - float h = [[theEvent window] frame].size.height; + float h = [self frame].size.height; myRequester->MouseMovedAt(loc.x, h - loc.y); } diff --git a/src/SFML/Window/OSX/WindowImplCocoa.mm b/src/SFML/Window/OSX/WindowImplCocoa.mm index cc3cc7e29..293b25f40 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.mm +++ b/src/SFML/Window/OSX/WindowImplCocoa.mm @@ -104,7 +104,7 @@ WindowImplCocoa::~WindowImplCocoa() [myDelegate closeWindow]; [myDelegate release]; - [myPool release]; + [myPool drain]; }