Cocoa port :

Bug fix : newly created window not seen as activated by WM

Added more conservative memory management (may need to optimize later)
This commit is contained in:
Damien Plisson 2009-10-08 15:28:31 +00:00
parent e936c80985
commit 88613b9184
2 changed files with 13 additions and 3 deletions

@ -806,7 +806,10 @@ GHOST_IWindow* GHOST_SystemCocoa::createWindow(
GHOST_ASSERT(m_windowManager, "m_windowManager not initialized");
m_windowManager->addWindow(window);
m_windowManager->setActiveWindow(window);
//Need to tell window manager the new window is the active one (Cocoa does not send the event activate upon window creation)
pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window));
pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
}
else {
GHOST_PRINT("GHOST_SystemCocoa::createWindow(): window invalid\n");
@ -1156,7 +1159,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
GHOST_IWindow* window = m_windowManager->getActiveWindow();
if (!window) {
printf("\nM invalid window");
return GHOST_kFailure;
}

@ -319,7 +319,7 @@ GHOST_WindowCocoa::~GHOST_WindowCocoa()
/*if(ugly_hack==m_windowRef) ugly_hack= NULL;
if(ugly_hack==NULL) setDrawingContextType(GHOST_kDrawingContextTypeNone);*/
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[m_openGLView release];
if (m_window) {
@ -327,6 +327,7 @@ GHOST_WindowCocoa::~GHOST_WindowCocoa()
[m_window release];
m_window = nil;
}
[pool drain];
}
#pragma mark accessors
@ -566,7 +567,9 @@ GHOST_TSuccess GHOST_WindowCocoa::swapBuffers()
{
if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
if (m_openGLContext != nil) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[m_openGLContext flushBuffer];
[pool drain];
return GHOST_kSuccess;
}
}
@ -577,7 +580,9 @@ GHOST_TSuccess GHOST_WindowCocoa::updateDrawingContext()
{
if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
if (m_openGLContext != nil) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[m_openGLContext update];
[pool drain];
return GHOST_kSuccess;
}
}
@ -588,6 +593,8 @@ GHOST_TSuccess GHOST_WindowCocoa::activateDrawingContext()
{
if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
if (m_openGLContext != nil) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[m_openGLContext makeCurrentContext];
#ifdef GHOST_DRAW_CARBON_GUTTER
// Restrict drawing to non-gutter area
@ -603,6 +610,7 @@ GHOST_TSuccess GHOST_WindowCocoa::activateDrawingContext()
};
GLboolean result = ::aglSetInteger(m_aglCtx, AGL_BUFFER_RECT, b);
#endif //GHOST_DRAW_CARBON_GUTTER
[pool drain];
return GHOST_kSuccess;
}
}