From 7645f459e7b346137898c132baf401adb71004ec Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 15 May 2014 20:42:29 -0400 Subject: [PATCH] Removed bleh_darwin.m's tracking area logic and rewrote it in Objective-C in area_darwin.m. --- area_darwin.m | 7 ++++++- bleh_darwin.m | 24 ------------------------ objc_darwin.h | 1 - 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/area_darwin.m b/area_darwin.m index 041841d..f283b5e 100644 --- a/area_darwin.m +++ b/area_darwin.m @@ -55,7 +55,12 @@ - (void)retrack { - trackingArea = makeTrackingArea(self); // TODO make inline + trackingArea = [[NSTrackingArea alloc] + initWithRect:[self bounds] + // this bit mask (except for NSTrackingInVisibleRect, which was added later to prevent events from being triggered outside the visible area of the Area) comes from https://github.com/andlabs/misctestprogs/blob/master/cocoaviewmousetest.m (and I wrote this bit mask on 25 april 2014) and yes I know it includes enter/exit even though we don't watch those events; it probably won't really matter anyway but if it does I can change it easily + options:(NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveAlways | NSTrackingEnabledDuringMouseDrag | NSTrackingInVisibleRect) + owner:self + userInfo:nil]; [self addTrackingArea:trackingArea]; } diff --git a/bleh_darwin.m b/bleh_darwin.m index b3fe85f..2d179fd 100644 --- a/bleh_darwin.m +++ b/bleh_darwin.m @@ -205,30 +205,6 @@ void *_appDelegate_applicationShouldTerminate = (void *) __appDelegate_applicati char *encodedTerminateReply = @encode(NSApplicationTerminateReply); -/* -tracking areas; also here for convenience only -*/ - -/* IDK if this is needed; just to be safe */ -static id (*objc_msgSend_initTrackingArea)(id, SEL, NSRect, NSTrackingAreaOptions, id, id) = - (id (*)(id, SEL, NSRect, NSTrackingAreaOptions, id, id)) objc_msgSend; -#include -id makeTrackingArea(id area) -{ - id trackingArea; - - trackingArea = objc_msgSend(c_NSTrackingArea, s_alloc); -NSView *v; -v = (NSView *) area; - trackingArea = (*objc_msgSend_initTrackingArea)(trackingArea, s_initTrackingArea, - [v bounds], /* initWithRect: */ - /* this bit mask (except for NSTrackingInVisibleRect, which was added later to prevent events from being triggered outside the visible area of the Area) comes from https://github.com/andlabs/misctestprogs/blob/master/cocoaviewmousetest.m (and I wrote this bit mask on 25 april 2014) and yes I know it includes enter/exit even though we don't watch those events; it probably won't really matter anyway but if it does I can change it easily */ - (NSTrackingAreaOptions) (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveAlways | NSTrackingEnabledDuringMouseDrag | NSTrackingInVisibleRect), /* options: */ - area, /* owner: */ - nil); /* userData: */ - return trackingArea; -} - /* Objective-C 1.0 has the class field of struct objc_super field as class Objective-C 2.0 has it as super_class diff --git a/objc_darwin.h b/objc_darwin.h index e3ca56f..c99d619 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 id makeTrackingArea(id); extern struct xpoint getTranslatedEventPoint(id, id); /* for objc_darwin.go */