From c1e49399271f4d0729a2ac2ed0a60f9980bd2133 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 21 Jul 2019 10:09:55 +0200 Subject: Fix tracking area implementation on MacOS I am not sure why updateTrackingAreas was being spammed before, but that caused the event loop to constantly tick when the mouse was hovered over the window despite nothing else happening. Everything seems to work fine without it, and this seems to match other code, so remove it. Also call super in updateTrackingAreas as suggested by the documentation. --- pugl/pugl_osx.m | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'pugl/pugl_osx.m') diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m index 1870207..80938f2 100644 --- a/pugl/pugl_osx.m +++ b/pugl/pugl_osx.m @@ -301,11 +301,12 @@ keySymToSpecial(PuglView* view, NSEvent* ev) const int opts = (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveAlways); - trackingArea = [ [NSTrackingArea alloc] initWithRect:[self bounds] - options:opts - owner:self - userInfo:nil]; + trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds] + options:opts + owner:self + userInfo:nil]; [self addTrackingArea:trackingArea]; + [super updateTrackingAreas]; } - (NSPoint) eventLocation:(NSEvent*)event @@ -315,7 +316,6 @@ keySymToSpecial(PuglView* view, NSEvent* ev) - (void)mouseEntered:(NSEvent*)theEvent { - [self updateTrackingAreas]; } - (void)mouseExited:(NSEvent*)theEvent @@ -393,7 +393,6 @@ keySymToSpecial(PuglView* view, NSEvent* ev) (uint32_t)[event buttonNumber] + 1 }; puglDispatchEvent(puglview, (const PuglEvent*)&ev); - [self updateTrackingAreas]; } - (void) rightMouseDown:(NSEvent*)event @@ -418,8 +417,6 @@ keySymToSpecial(PuglView* view, NSEvent* ev) - (void) scrollWheel:(NSEvent*)event { - [self updateTrackingAreas]; - const NSPoint wloc = [self eventLocation:event]; const NSPoint rloc = [NSEvent mouseLocation]; const PuglEventScroll ev = { @@ -436,7 +433,6 @@ keySymToSpecial(PuglView* view, NSEvent* ev) [event deltaY] }; puglDispatchEvent(puglview, (const PuglEvent*)&ev); - [self updateTrackingAreas]; } - (void) keyDown:(NSEvent*)event -- cgit v1.2.1