devdraw: cocoa fixes, bigarrow support (thanks Marius Eriksen)
This commit is contained in:
parent
813b3eea8b
commit
b4d0ac9612
3 changed files with 50 additions and 3 deletions
|
|
@ -30,6 +30,11 @@ AUTOFRAMEWORK(Cocoa)
|
||||||
|
|
||||||
int usegestures = 0;
|
int usegestures = 0;
|
||||||
int useoldfullscreen = 0;
|
int useoldfullscreen = 0;
|
||||||
|
int usebigarrow = 0;
|
||||||
|
|
||||||
|
extern Cursor bigarrow;
|
||||||
|
|
||||||
|
void setcursor0(Cursor *c);
|
||||||
|
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
|
|
@ -64,6 +69,9 @@ threadmain(int argc, char **argv)
|
||||||
case 'g':
|
case 'g':
|
||||||
usegestures = 1;
|
usegestures = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'b':
|
||||||
|
usebigarrow = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}ARGEND
|
}ARGEND
|
||||||
|
|
@ -71,6 +79,11 @@ threadmain(int argc, char **argv)
|
||||||
if(OSX_VERSION < 100700)
|
if(OSX_VERSION < 100700)
|
||||||
[NSAutoreleasePool new];
|
[NSAutoreleasePool new];
|
||||||
|
|
||||||
|
// Reset cursor to ensure we start
|
||||||
|
// with bigarrow.
|
||||||
|
if(usebigarrow)
|
||||||
|
setcursor0(nil);
|
||||||
|
|
||||||
[NSApplication sharedApplication];
|
[NSApplication sharedApplication];
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
[NSApp setDelegate:[appdelegate new]];
|
[NSApp setDelegate:[appdelegate new]];
|
||||||
|
|
@ -163,6 +176,7 @@ static void togglefs(void);
|
||||||
+ (void)calldrawimg:(id)arg{ drawimg();}
|
+ (void)calldrawimg:(id)arg{ drawimg();}
|
||||||
+ (void)callflushwin:(id)arg{ flushwin();}
|
+ (void)callflushwin:(id)arg{ flushwin();}
|
||||||
+ (void)callmakewin:(id)arg{ makewin();}
|
+ (void)callmakewin:(id)arg{ makewin();}
|
||||||
|
+ (void)callsetcursor0:(id)arg{ setcursor0([[arg autorelease] pointerValue]);}
|
||||||
- (void)calltogglefs:(id)arg{ togglefs();}
|
- (void)calltogglefs:(id)arg{ togglefs();}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
@ -453,13 +467,15 @@ static void gettouch(NSEvent*, int);
|
||||||
{
|
{
|
||||||
NSCursor *c;
|
NSCursor *c;
|
||||||
|
|
||||||
|
[super resetCursorRects];
|
||||||
|
|
||||||
qlock(&win.cursorl);
|
qlock(&win.cursorl);
|
||||||
|
|
||||||
c = win.cursor;
|
c = win.cursor;
|
||||||
if(c == nil)
|
if(c == nil)
|
||||||
c = [NSCursor arrowCursor];
|
c = [NSCursor arrowCursor];
|
||||||
[self addCursorRect:[self bounds] cursor:c];
|
|
||||||
|
|
||||||
|
[self addCursorRect:[self bounds] cursor:c];
|
||||||
qunlock(&win.cursorl);
|
qunlock(&win.cursorl);
|
||||||
}
|
}
|
||||||
- (BOOL)isFlipped
|
- (BOOL)isFlipped
|
||||||
|
|
@ -1128,7 +1144,16 @@ kicklabel(char *label)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setcursor(Cursor *c)
|
setcursor(Cursor *cursor)
|
||||||
|
{
|
||||||
|
[appdelegate
|
||||||
|
performSelectorOnMainThread:@selector(callsetcursor0:)
|
||||||
|
withObject:[[NSValue valueWithPointer:cursor] retain]
|
||||||
|
waitUntilDone:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setcursor0(Cursor *c)
|
||||||
{
|
{
|
||||||
NSBitmapImageRep *r;
|
NSBitmapImageRep *r;
|
||||||
NSImage *i;
|
NSImage *i;
|
||||||
|
|
@ -1142,6 +1167,10 @@ setcursor(Cursor *c)
|
||||||
[win.cursor release];
|
[win.cursor release];
|
||||||
win.cursor = nil;
|
win.cursor = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(c == nil && usebigarrow)
|
||||||
|
c = &bigarrow;
|
||||||
|
|
||||||
if(c){
|
if(c){
|
||||||
r = [[NSBitmapImageRep alloc]
|
r = [[NSBitmapImageRep alloc]
|
||||||
initWithBitmapDataPlanes:nil
|
initWithBitmapDataPlanes:nil
|
||||||
|
|
@ -1167,9 +1196,11 @@ setcursor(Cursor *c)
|
||||||
|
|
||||||
win.cursor = [[NSCursor alloc] initWithImage:i hotSpot:p];
|
win.cursor = [[NSCursor alloc] initWithImage:i hotSpot:p];
|
||||||
|
|
||||||
|
[win.cursor set];
|
||||||
[i release];
|
[i release];
|
||||||
[r release];
|
[r release];
|
||||||
}
|
}
|
||||||
|
|
||||||
qunlock(&win.cursorl);
|
qunlock(&win.cursorl);
|
||||||
[WIN invalidateCursorRectsForView:win.content];
|
[WIN invalidateCursorRectsForView:win.content];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
src/cmd/devdraw/cursor.c
Normal file
16
src/cmd/devdraw/cursor.c
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#include <u.h>
|
||||||
|
#include <libc.h>
|
||||||
|
#include <draw.h>
|
||||||
|
#include <cursor.h>
|
||||||
|
|
||||||
|
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},
|
||||||
|
};
|
||||||
|
|
@ -59,7 +59,7 @@ elif [ $WSYSTYPE = osx ]; then
|
||||||
echo 'WSYSOFILES=$WSYSOFILES osx-screen-carbon-objc.o osx-draw.o osx-srv.o'
|
echo 'WSYSOFILES=$WSYSOFILES osx-screen-carbon-objc.o osx-draw.o osx-srv.o'
|
||||||
echo 'MACARGV=macargv.o'
|
echo 'MACARGV=macargv.o'
|
||||||
elif [ $WSYSTYPE = osx-cocoa ]; then
|
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'
|
echo 'MACARGV=macargv-objc.o'
|
||||||
elif [ $WSYSTYPE = nowsys ]; then
|
elif [ $WSYSTYPE = nowsys ]; then
|
||||||
echo 'WSYSOFILES=nowsys.o'
|
echo 'WSYSOFILES=nowsys.o'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue