From 41a7e3dab8193d8c19aa43eac344eb274deef5a8 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 30 Mar 2014 17:52:27 -0400 Subject: Implemented Area mouse events on Mac OS X. Also fixed a few other things left behind in the previous commits. Also more TODOs. --- bleh_darwin.m | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'bleh_darwin.m') diff --git a/bleh_darwin.m b/bleh_darwin.m index e373be8..48f0ae7 100644 --- a/bleh_darwin.m +++ b/bleh_darwin.m @@ -241,7 +241,7 @@ static SEL s_drawInRect; static SEL s_release; static BOOL drawImage_init = NO; -id drawImage(void *pixels, int64_t width, int64_t height, int64_t stride, int64_t xdest, int64_t ydest) +void drawImage(void *pixels, int64_t width, int64_t height, int64_t stride, int64_t xdest, int64_t ydest) { unsigned char *planes[1]; /* NSBitmapImageRep wants an array of planes; we have one plane */ id bitmap; @@ -278,3 +278,33 @@ id drawImage(void *pixels, int64_t width, int64_t height, int64_t stride, int64_ nil); /* hints: */ objc_msgSend(bitmap, s_release); } + +/* +more NSPoint fumbling +*/ + +static SEL s_locationInWindow; +static SEL s_convertPointFromView; +static BOOL getTranslatedEventPoint_init = NO; + +static NSPoint (*objc_msgSend_stret_point)(id, SEL, ...) = + (NSPoint (*)(id, SEL, ...)) objc_msgSend; + +struct xpoint getTranslatedEventPoint(id self, id event) +{ + NSPoint p; + struct xpoint ret; + + if (getTranslatedEventPoint_init == NO) { + s_locationInWindow = sel_getUid("locationInWindow"); + s_convertPointFromView = sel_getUid("convertPoint:fromView:"); + getTranslatedEventPoint_init = YES; + } + p = objc_msgSend_stret_point(event, s_locationInWindow); + p = objc_msgSend_stret_point(self, s_convertPointFromView, + p, /* convertPoint: */ + nil); /* fromView: */ + ret.x = (int64_t) p.x; + ret.y = (int64_t) p.y; + return ret; +} -- cgit v1.2.3