From 1f9d8826dbe94a8d616fe1d90efcb242b233cbd9 Mon Sep 17 00:00:00 2001 From: Damien Plisson Date: Tue, 20 Oct 2009 08:13:12 +0000 Subject: [PATCH] Cocoa: - fix 10.6 API used in window resizing callback causing crash on 10.5 systems (Thx Jasper Mine for the bug report) - implemented min window size enforcement to prevent tiny windows messing up blender's internal ui layout (same as done by Campbell on X11, is a partial fix of bug #19550) - added (commented) code for enabling multithreaded opengl (this optimization is here for experimental tests, not for mainstream, so bleeding edge testers would want to uncomment the three "Multithreaded opengl code : uncomment for enabling" sections) --- intern/ghost/intern/GHOST_WindowCocoa.mm | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index c9b4fe40001..197b2de1f32 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -34,6 +34,10 @@ #include #endif +/***** Multithreaded opengl code : uncomment for enabling +#include +*/ + #include "GHOST_WindowCocoa.h" #include "GHOST_SystemCocoa.h" #include "GHOST_Debug.h" @@ -110,10 +114,14 @@ extern "C" { - (void)windowDidResize:(NSNotification *)notification { +#ifdef MAC_OS_X_VERSION_10_6 if (![[notification object] inLiveResize]) { //Send event only once, at end of resize operation (when user has released mouse button) +#endif systemCocoa->handleWindowEvent(GHOST_kEventWindowSize, associatedWindow); +#ifdef MAC_OS_X_VERSION_10_6 } +#endif /* Live resize ugly patch. Needed because live resize runs in a modal loop, not letting main loop run if ([[notification object] inLiveResize]) { systemCocoa->dispatchEvents(); @@ -194,6 +202,7 @@ GHOST_WindowCocoa::GHOST_WindowCocoa( //Creates the window NSRect rect; + NSSize minSize; rect.origin.x = left; rect.origin.y = top; @@ -208,6 +217,11 @@ GHOST_WindowCocoa::GHOST_WindowCocoa( return; } + //Forbid to resize the window below the blender defined minimum one + minSize.width = 320; + minSize.height = 240; + [m_window setContentMinSize:minSize]; + setTitle(title); @@ -719,6 +733,10 @@ GHOST_TSuccess GHOST_WindowCocoa::installDrawingContext(GHOST_TDrawingContextTyp NSOpenGLPixelFormat *pixelFormat; NSOpenGLContext *tmpOpenGLContext; + /***** Multithreaded opengl code : uncomment for enabling + CGLContextObj cglCtx; + */ + switch (type) { case GHOST_kDrawingContextTypeOpenGL: if (!getValid()) break; @@ -731,6 +749,13 @@ GHOST_TSuccess GHOST_WindowCocoa::installDrawingContext(GHOST_TDrawingContextTyp break; } + //Switch openGL to multhreaded mode + /******* Multithreaded opengl code : uncomment for enabling + cglCtx = (CGLContextObj)[tmpOpenGLContext CGLContextObj]; + if (CGLEnable(cglCtx, kCGLCEMPEngine) == kCGLNoError) + printf("\nSwitched openGL to multithreaded mode"); + */ + if (!s_firstOpenGLcontext) s_firstOpenGLcontext = tmpOpenGLContext; #ifdef WAIT_FOR_VSYNC /* wait for vsync, to avoid tearing artifacts */