diff options
| author | Pietro Gagliardi <[email protected]> | 2014-03-30 17:52:27 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-03-30 17:52:27 -0400 |
| commit | 41a7e3dab8193d8c19aa43eac344eb274deef5a8 (patch) | |
| tree | 2817244b71d3f8ed26d2b2336b0828811a54412f /bleh_darwin.m | |
| parent | 8c18adcfdb1b0ce034c692204c49a1e57e4abe83 (diff) | |
Implemented Area mouse events on Mac OS X. Also fixed a few other things left behind in the previous commits. Also more TODOs.
Diffstat (limited to 'bleh_darwin.m')
| -rw-r--r-- | bleh_darwin.m | 32 |
1 files changed, 31 insertions, 1 deletions
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; +} |
