OSX: make sure closing the mainwindow forewards to the quitdialog - todo: check if...
authorJens Verwiebe <info@jensverwiebe.de>
Sat, 28 Sep 2013 17:55:22 +0000 (17:55 +0000)
committerJens Verwiebe <info@jensverwiebe.de>
Sat, 28 Sep 2013 17:55:22 +0000 (17:55 +0000)
intern/ghost/intern/GHOST_SystemCocoa.mm
intern/ghost/intern/GHOST_WindowCocoa.h

index 37b698c8d3d0c7c8300a098081f521d67c8e4252..c5d906d60736716efae0b1af03c991441d2adb5b 100644 (file)
@@ -1018,12 +1018,20 @@ void GHOST_SystemCocoa::notifyExternalEventProcessed()
 //Note: called from NSWindow delegate
 GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent(GHOST_TEventType eventType, GHOST_WindowCocoa* window)
 {
+       NSArray *windowsList;
+       windowsList = [NSApp orderedWindows];
        if (!validWindow(window)) {
                return GHOST_kFailure;
        }
                switch (eventType) {
                        case GHOST_kEventWindowClose:
-                               pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window) );
+                               // make sure index 1 exists and compare window adress
+                               if ([windowsList count] > 1 && (window->m_window != [windowsList objectAtIndex:1])) {
+                                       pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window) );
+                               }
+                               else {
+                                       handleQuitRequest(); // -> quit dialog
+                               }
                                break;
                        case GHOST_kEventWindowActivate:
                                m_windowManager->setActiveWindow(window);
index fe0830edeae5bb57ed63e4e3ecd371f1310840a3..af8aa4b0062c874670d871cc8dbd2de06cb0f7c0 100644 (file)
@@ -269,6 +269,9 @@ public:
        GHOST_TSuccess beginFullScreen() const {return GHOST_kFailure;}
 
        GHOST_TSuccess endFullScreen() const {return GHOST_kFailure;}
+       
+       /** The window containing the OpenGL view */
+       CocoaWindow *m_window;
 
        
 protected:
@@ -318,8 +321,8 @@ protected:
                                        
        virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY);
 
-       /** The window containing the OpenGL view */
-       CocoaWindow *m_window;
+//     /** The window containing the OpenGL view */
+//     CocoaWindow *m_window;
        
        /** The openGL view */
        CocoaOpenGLView *m_openGLView;