commit b4d0ac961262aace74431d78fe952a404a6f25a1 from: Russ Cox date: Sun Oct 23 22:47:29 2011 UTC devdraw: cocoa fixes, bigarrow support (thanks Marius Eriksen) commit - 813b3eea8b469a6d603f13a51a8afb8e3dae3a32 commit + b4d0ac961262aace74431d78fe952a404a6f25a1 blob - 58c53f7d2f313cf18ee57cd1fe3ff33b66a8ecce blob + bbe481647a388433cb1b693fa10a3fd5c536238f --- src/cmd/devdraw/cocoa-screen.m +++ src/cmd/devdraw/cocoa-screen.m @@ -30,7 +30,12 @@ AUTOFRAMEWORK(Cocoa) int usegestures = 0; int useoldfullscreen = 0; +int usebigarrow = 0; +extern Cursor bigarrow; + +void setcursor0(Cursor *c); + void usage(void) { @@ -64,12 +69,20 @@ threadmain(int argc, char **argv) case 'g': usegestures = 1; break; + case 'b': + usebigarrow = 1; + break; default: usage(); }ARGEND if(OSX_VERSION < 100700) [NSAutoreleasePool new]; + + // Reset cursor to ensure we start + // with bigarrow. + if(usebigarrow) + setcursor0(nil); [NSApplication sharedApplication]; [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; @@ -163,6 +176,7 @@ static void togglefs(void); + (void)calldrawimg:(id)arg{ drawimg();} + (void)callflushwin:(id)arg{ flushwin();} + (void)callmakewin:(id)arg{ makewin();} ++ (void)callsetcursor0:(id)arg{ setcursor0([[arg autorelease] pointerValue]);} - (void)calltogglefs:(id)arg{ togglefs();} @end @@ -453,13 +467,15 @@ static void gettouch(NSEvent*, int); { NSCursor *c; + [super resetCursorRects]; + qlock(&win.cursorl); c = win.cursor; if(c == nil) c = [NSCursor arrowCursor]; - [self addCursorRect:[self bounds] cursor:c]; + [self addCursorRect:[self bounds] cursor:c]; qunlock(&win.cursorl); } - (BOOL)isFlipped @@ -1128,8 +1144,17 @@ kicklabel(char *label) } void -setcursor(Cursor *c) +setcursor(Cursor *cursor) { + [appdelegate + performSelectorOnMainThread:@selector(callsetcursor0:) + withObject:[[NSValue valueWithPointer:cursor] retain] + waitUntilDone:YES]; +} + +void +setcursor0(Cursor *c) +{ NSBitmapImageRep *r; NSImage *i; NSPoint p; @@ -1142,6 +1167,10 @@ setcursor(Cursor *c) [win.cursor release]; win.cursor = nil; } + + if(c == nil && usebigarrow) + c = &bigarrow; + if(c){ r = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil @@ -1167,9 +1196,11 @@ setcursor(Cursor *c) win.cursor = [[NSCursor alloc] initWithImage:i hotSpot:p]; + [win.cursor set]; [i release]; [r release]; } + qunlock(&win.cursorl); [WIN invalidateCursorRectsForView:win.content]; } blob - /dev/null blob + af7e65db52ef79b5ae68033531be4aacda6997e4 (mode 644) --- /dev/null +++ src/cmd/devdraw/cursor.c @@ -0,0 +1,16 @@ +#include +#include +#include +#include + +Cursor bigarrow = { + {0, 0}, + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC, + 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF8, 0xFF, 0xFC, + 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC, + 0xF3, 0xF8, 0xF1, 0xF0, 0xE0, 0xE0, 0xC0, 0x40}, + {0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFC, 0x7F, 0xF0, + 0x7F, 0xE0, 0x7F, 0xE0, 0x7F, 0xF0, 0x7F, 0xF8, + 0x7F, 0xFC, 0x7F, 0xFE, 0x7F, 0xFC, 0x73, 0xF8, + 0x61, 0xF0, 0x60, 0xE0, 0x40, 0x40, 0x00, 0x00}, +}; blob - dde44c819e98fddfc8509fb12becf2d283fe9599 blob + a9072adfef66f80bf5889312abfebd1d5a787b76 --- src/cmd/devdraw/mkwsysrules.sh +++ src/cmd/devdraw/mkwsysrules.sh @@ -59,7 +59,7 @@ elif [ $WSYSTYPE = osx ]; then echo 'WSYSOFILES=$WSYSOFILES osx-screen-carbon-objc.o osx-draw.o osx-srv.o' echo 'MACARGV=macargv.o' elif [ $WSYSTYPE = osx-cocoa ]; then - echo 'WSYSOFILES=$WSYSOFILES osx-draw.o cocoa-screen-objc.o cocoa-srv.o cocoa-thread.o' + echo 'WSYSOFILES=$WSYSOFILES osx-draw.o cocoa-screen-objc.o cocoa-srv.o cocoa-thread.o cursor.o' echo 'MACARGV=macargv-objc.o' elif [ $WSYSTYPE = nowsys ]; then echo 'WSYSOFILES=nowsys.o'