summaryrefslogtreecommitdiff
path: root/redo/uitask_darwin.m
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-08 16:47:28 -0400
committerPietro Gagliardi <[email protected]>2014-07-08 16:47:28 -0400
commitb4357db4be6688c67e522b637f100ceecc4a9680 (patch)
tree4b631edcb1e1fed7e6287b41b63a6a08d5aa3a45 /redo/uitask_darwin.m
parent60d0953fe9f16726958f709007402ea4c8b89fc6 (diff)
Added the beginning of the Mac OS X code.
Diffstat (limited to 'redo/uitask_darwin.m')
-rw-r--r--redo/uitask_darwin.m58
1 files changed, 58 insertions, 0 deletions
diff --git a/redo/uitask_darwin.m b/redo/uitask_darwin.m
new file mode 100644
index 0000000..796bc18
--- /dev/null
+++ b/redo/uitask_darwin.m
@@ -0,0 +1,58 @@
+// 8 july 2014
+
+#import "objc_darwin.h"
+#import "_cgo_export.h"
+#import <Cocoa/Cocoa.h>
+
+@interface appDelegateClass : NSObject
+@end
+
+@implementation appDelegateClass
+
+- (void)issue:(id)obj
+{
+ NSValue *what = (NSValue *) obj;
+
+ doissue([what pointerValue]);
+}
+
+@end
+
+appDelegateClass *appDelegate;
+
+id getAppDelegate(void)
+{
+ return appDelegate;
+}
+
+BOOL uiinit(void)
+{
+ appDelegate = [appDelegateClass new];
+ [NSApplication sharedApplication];
+ [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
+ [NSApp activateIgnoringOtherApps:YES]; // TODO rsc does this; finder says NO?
+ [NSApp setDelegate:appDelegate];
+ return YES;
+}
+
+void uimsgloop(void)
+{
+ [NSApp run];
+}
+
+// Ideally we would have this work like on the other platforms and issue a NSEvent to the end of the event queue
+// Unfortunately, there doesn't seem to be a way for NSEvents to hold pointer values, only (signed) NSIntegers
+// So we'll have to do the performSelectorOnMainThread: approach
+// [TODO]
+void issue(void *what)
+{
+ NSAutoreleasePool *p;
+ NSValue *v;
+
+ p = [NSAutoreleasePool new];
+ v = [NSValue valueWithPointer:what];
+ [appDelegate performSelectorOnMainThread:@selector(issue:)
+ withObject:v
+ waitUntilDone:NO];
+ [p release];
+}