Add these after windowShouldClose on line 39 and see what happens ;)
-(void) windowDidMiniaturize:(NSNotification *) note { bbSystemEmitEvent( BBEVENT_APPSUSPEND,&bbNullObject,0,0,0,0,&bbNullObject ); } -(void) windowDidDeminiaturize:(NSNotification *) note { bbSystemEmitEvent( BBEVENT_APPRESUME,&bbNullObject,0,0,0,0,&bbNullObject ); }