From 5571d37e94a2989ea0dd727abb43887a95f585f3 Mon Sep 17 00:00:00 2001 From: Damien Plisson Date: Tue, 20 Oct 2009 15:23:04 +0000 Subject: Cocoa: - fix windowDidResize event not forwarded in some cases on 10.6 - fix crash on repeated Cmd-Q + Cancel quit actions - place stub for .blend drop on blender app icon --- intern/ghost/intern/GHOST_SystemCocoa.mm | 21 ++++++++++++++++++--- intern/ghost/intern/GHOST_WindowCocoa.mm | 4 ++-- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'intern') diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index f8e124991af..3b2c5ea76a3 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -525,7 +525,8 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG]) { @interface CocoaAppDelegate : NSObject { GHOST_SystemCocoa *systemCocoa; } --(void)setSystemCocoa:(GHOST_SystemCocoa *)sysCocoa; +- (void)setSystemCocoa:(GHOST_SystemCocoa *)sysCocoa; +- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename; - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; - (void)applicationWillTerminate:(NSNotification *)aNotification; @end @@ -536,6 +537,12 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG]) { systemCocoa = sysCocoa; } +- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename +{ + NSLog(@"\nGet open file event from cocoa : %@",filename); + return YES; +} + - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { //TODO: implement graceful termination through Cocoa mechanism to avoid session log off to be cancelled @@ -658,13 +665,14 @@ GHOST_TSuccess GHOST_SystemCocoa::init() [NSApp setWindowsMenu:windowMenu]; [windowMenu release]; } - [NSApp finishLaunching]; } if ([NSApp delegate] == nil) { CocoaAppDelegate *appDelegate = [[CocoaAppDelegate alloc] init]; [appDelegate setSystemCocoa:this]; [NSApp setDelegate:appDelegate]; } + + [NSApp finishLaunching]; [pool drain]; } @@ -995,7 +1003,7 @@ GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest() GHOST_Window* window = (GHOST_Window*)m_windowManager->getActiveWindow(); //Discard quit event if we are in cursor grab sequence - if ((window->getCursorGrabMode() != GHOST_kGrabDisable) && (window->getCursorGrabMode() != GHOST_kGrabNormal)) + if (window && (window->getCursorGrabMode() != GHOST_kGrabDisable) && (window->getCursorGrabMode() != GHOST_kGrabNormal)) return GHOST_kExitCancel; //Check open windows if some changes are not saved @@ -1007,7 +1015,14 @@ GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest() { pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventQuit, NULL) ); return GHOST_kExitNow; + } else { + //Give back focus to the blender window if user selected cancel quit + NSArray *windowsList = [NSApp orderedWindows]; + if ([windowsList count]) { + [[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil]; + } } + } else { pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventQuit, NULL) ); diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index 197b2de1f32..b9a598cb265 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -115,12 +115,12 @@ extern "C" { - (void)windowDidResize:(NSNotification *)notification { #ifdef MAC_OS_X_VERSION_10_6 - if (![[notification object] inLiveResize]) { + //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]) { -- cgit v1.2.3