From ce27d7babdf2ee09ff6d1f8d4a166c2208995774 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 8 Jan 2020 20:03:31 -0500 Subject: devdraw: can use libthread directly now on macOS --- src/cmd/devdraw/cocoa-screen.m | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/cmd/devdraw/cocoa-screen.m') diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m index 984ede03..64b2bf4c 100644 --- a/src/cmd/devdraw/cocoa-screen.m +++ b/src/cmd/devdraw/cocoa-screen.m @@ -12,7 +12,7 @@ #include #include -#include "cocoa-thread.h" +#include #include #include #include @@ -41,8 +41,8 @@ usage(void) threadexitsall("usage"); } + @interface AppDelegate : NSObject -+ (void)callservep9p:(id)arg; + (void)makewin:(NSValue *)v; + (void)callkicklabel:(NSString *)v; + (void)callsetNeedsDisplayInRect:(NSValue *)v; @@ -108,14 +108,18 @@ threadmain(int argc, char **argv) } } -@implementation AppDelegate -+ (void)callservep9p:(id)arg +void +callservep9p(void *v) { + USED(v); + servep9p(); - [NSApp terminate:self]; + [NSApp terminate:myApp]; } +@implementation AppDelegate + + (void)makewin:(NSValue *)v { NSRect r, sr; @@ -331,9 +335,7 @@ struct Cursors { [NSApp setApplicationIconImage:i]; [[NSApp dockTile] display]; - [NSThread - detachNewThreadSelector:@selector(callservep9p:) - toTarget:[self class] withObject:nil]; + proccreate(callservep9p, nil, 0); } - (NSApplicationPresentationOptions)window:(id)arg @@ -671,6 +673,7 @@ struct Cursors { if(actualRange) *actualRange = sr; LOG(@"use range: %ld, %ld", sr.location, sr.length); + s = nil; if(sr.length) s = [[NSAttributedString alloc] initWithString:[_tmpText substringWithRange:sr]]; -- cgit v1.2.3