summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-05-15 21:45:42 -0400
committerPietro Gagliardi <[email protected]>2014-05-15 21:45:42 -0400
commit31fc77a99df84e334e97cb6718a3f45fa097d2b4 (patch)
tree1b61f0d52dc25869b253cab5f5da1f5b2a2e502a
parent82101036b8b2686ec0394908434629ab6a0b9903 (diff)
Removed the event point translation from bleh_darwin.m and rewrote it in Objective-C in area_darwin.m.
-rw-r--r--area_darwin.m12
-rw-r--r--bleh_darwin.m21
-rw-r--r--objc_darwin.h1
3 files changed, 11 insertions, 23 deletions
diff --git a/area_darwin.m b/area_darwin.m
index f283b5e..c45aa40 100644
--- a/area_darwin.m
+++ b/area_darwin.m
@@ -10,6 +10,7 @@
#define to(T, x) ((T *) (x))
#define toNSEvent(x) to(NSEvent, (x))
+#define toAreaView(x) to(areaView, (x))
#define toNSInteger(x) ((NSInteger) (x))
#define fromNSInteger(x) ((intptr_t) (x))
@@ -110,7 +111,16 @@ uintptr_t modifierFlags(id e)
return fromNSUInteger([toNSEvent(e) modifierFlags]);
}
-// TODO move getTranslatedEventPoint() here
+struct xpoint getTranslatedEventPoint(id area, id e)
+{
+ NSPoint p;
+ struct xpoint q;
+
+ p = [toAreaView(area) convertPoint:[toNSEvent(e) locationInWindow] fromView:nil];
+ q.x = (intptr_t) p.x;
+ q.y = (intptr_t) p.y;
+ return q;
+}
intptr_t buttonNumber(id e)
{
diff --git a/bleh_darwin.m b/bleh_darwin.m
index ca98ffd..331e2ca 100644
--- a/bleh_darwin.m
+++ b/bleh_darwin.m
@@ -151,24 +151,3 @@ void drawImage(void *pixels, int64_t width, int64_t height, int64_t stride, int6
nil); /* hints: */
objc_msgSend(bitmap, s_release);
}
-
-/*
-more NSPoint fumbling
-*/
-
-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;
-
- 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;
-}
diff --git a/objc_darwin.h b/objc_darwin.h
index 5eb9b6c..4417b02 100644
--- a/objc_darwin.h
+++ b/objc_darwin.h
@@ -57,7 +57,6 @@ extern id makeDummyEvent();
/* TODO apparently ISO C forbids casting a function pointer to a non-function pointer; this will need to change???? */
extern void *_areaView_drawRect;
extern void drawImage(void *, int64_t, int64_t, int64_t, int64_t, int64_t);
-extern struct xpoint getTranslatedEventPoint(id, id);
/* for objc_darwin.go */
extern char *encodedNSRect;