2015-04-06 18:04:13 -05:00
|
|
|
// 6 april 2015
|
2015-04-06 23:26:27 -05:00
|
|
|
#import "uipriv_darwin.h"
|
2015-04-06 18:04:13 -05:00
|
|
|
|
|
|
|
@interface uiApplication : NSApplication
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation uiApplication
|
|
|
|
|
|
|
|
// hey look! we're overriding terminate:!
|
|
|
|
// we're going to make sure we can go back to main() whether Cocoa likes it or not!
|
|
|
|
// and just how are we going to do that, hm?
|
|
|
|
// (note: this is called after applicationShouldTerminate:)
|
|
|
|
- (void)terminate:(id)sender
|
|
|
|
{
|
|
|
|
// yes that's right folks: DO ABSOLUTELY NOTHING.
|
|
|
|
// the magic is [NSApp run] will just... stop.
|
2015-04-10 12:39:45 -05:00
|
|
|
|
|
|
|
// for debugging
|
|
|
|
NSLog(@"in terminate:");
|
2015-04-06 18:04:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2015-04-10 12:39:45 -05:00
|
|
|
@interface uiAppDelegate : NSObject <NSApplicationDelegate>
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation uiAppDelegate
|
|
|
|
|
|
|
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)app
|
|
|
|
{
|
|
|
|
// for debugging
|
|
|
|
NSLog(@"in applicationShouldTerminate:");
|
|
|
|
return NSTerminateNow;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)app
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
2015-04-06 18:04:13 -05:00
|
|
|
|
2015-04-09 21:38:11 -05:00
|
|
|
uiInitOptions options;
|
|
|
|
|
2015-04-10 15:54:06 -05:00
|
|
|
const char *uiInit(uiInitOptions *o)
|
2015-04-06 18:04:13 -05:00
|
|
|
{
|
2015-04-09 21:38:11 -05:00
|
|
|
options = *o;
|
2015-04-06 18:04:13 -05:00
|
|
|
[uiApplication sharedApplication];
|
|
|
|
// don't check for a NO return; something (launch services?) causes running from application bundles to always return NO when asking to change activation policy, even if the change is to the same activation policy!
|
|
|
|
// see https://github.com/andlabs/ui/issues/6
|
|
|
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
2015-04-10 12:39:45 -05:00
|
|
|
[NSApp setDelegate:[uiAppDelegate new]];
|
2015-04-06 18:04:13 -05:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-04-10 15:54:06 -05:00
|
|
|
void uiFreeInitError(const char *err)
|
2015-04-06 18:04:13 -05:00
|
|
|
{
|
|
|
|
}
|