Implemented Stop() on Mac OS X.

This commit is contained in:
Pietro Gagliardi 2014-07-13 21:31:13 -04:00
parent 0eded3f774
commit 0e7589af47
3 changed files with 25 additions and 1 deletions

View File

@ -14,6 +14,7 @@
extern id getAppDelegate(void); /* used by the other .m files */ extern id getAppDelegate(void); /* used by the other .m files */
extern BOOL uiinit(void); extern BOOL uiinit(void);
extern void uimsgloop(void); extern void uimsgloop(void);
extern void uistop(void);
extern void issue(void *); extern void issue(void *);
/* window_darwin.m */ /* window_darwin.m */

View File

@ -21,6 +21,10 @@ func uimsgloop() {
C.uimsgloop() C.uimsgloop()
} }
func uistop() {
C.uistop()
}
func issue(req *Request) { func issue(req *Request) {
C.issue(unsafe.Pointer(req)) C.issue(unsafe.Pointer(req))
} }

View File

@ -32,7 +32,26 @@ void uimsgloop(void)
[NSApp run]; [NSApp run];
} }
// thanks to mikeash in irc.freenode.net/#macdev for suggesting the use of Grand Dispatch and blocks for this // don't use [NSApp terminate:]; that quits the program
void uistop(void)
{
NSEvent *e;
[NSApp stop:NSApp];
// stop: won't register until another event has passed; let's synthesize one
e = [NSEvent otherEventWithType:NSApplicationDefined
location:NSZeroPoint
modifierFlags:0
timestamp:[[NSProcessInfo processInfo] systemUptime]
windowNumber:0
context:[NSGraphicsContext currentContext]
subtype:0
data1:0
data2:0];
[NSApp postEvent:e atStart:NO]; // let pending events take priority
}
// thanks to mikeash in irc.freenode.net/#macdev for suggesting the use of Grand Central Dispatch and blocks for this
void issue(void *what) void issue(void *what)
{ {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{