[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24005] trunk/blender/intern/ghost/intern: Cocoa:

Damien Plisson damien.plisson at yahoo.fr
Tue Oct 20 17:23:04 CEST 2009


Revision: 24005
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24005
Author:   damien78
Date:     2009-10-20 17:23:04 +0200 (Tue, 20 Oct 2009)

Log Message:
-----------
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

Modified Paths:
--------------
    trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
    trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm	2009-10-20 14:55:53 UTC (rev 24004)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm	2009-10-20 15:23:04 UTC (rev 24005)
@@ -525,7 +525,8 @@
 @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 @@
 	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 @@
 				[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_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 @@
 		{
 			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) );

Modified: trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm	2009-10-20 14:55:53 UTC (rev 24004)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm	2009-10-20 15:23:04 UTC (rev 24005)
@@ -115,12 +115,12 @@
 - (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]) {





More information about the Bf-blender-cvs mailing list