devdraw: can use libthread directly now on macOS

This commit is contained in:
Russ Cox 2020-01-08 20:03:31 -05:00
parent db20f89c32
commit ce27d7babd
5 changed files with 13 additions and 79 deletions

View file

@ -12,7 +12,7 @@
#include <u.h>
#include <libc.h>
#include "cocoa-thread.h"
#include <thread.h>
#include <draw.h>
#include <memdraw.h>
#include <keyboard.h>
@ -41,8 +41,8 @@ usage(void)
threadexitsall("usage");
}
@interface AppDelegate : NSObject<NSApplicationDelegate,NSWindowDelegate>
+ (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]];