diff options
| author | Pietro Gagliardi <[email protected]> | 2014-07-13 21:31:13 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-07-13 21:31:13 -0400 |
| commit | 0e7589af4718d8f90bbc007306c75c2a39386d2f (patch) | |
| tree | ad4ab0ea2764593900e08614157b38076e85ddfc /redo/uitask_darwin.m | |
| parent | 0eded3f7749a8a767a2002b52236c1c2e93363cb (diff) | |
Implemented Stop() on Mac OS X.
Diffstat (limited to 'redo/uitask_darwin.m')
| -rw-r--r-- | redo/uitask_darwin.m | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/redo/uitask_darwin.m b/redo/uitask_darwin.m index faf78a2..842f991 100644 --- a/redo/uitask_darwin.m +++ b/redo/uitask_darwin.m @@ -32,7 +32,26 @@ void uimsgloop(void) [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) { dispatch_async(dispatch_get_main_queue(), ^{ |
