8000 Update how tracking for macosx mouse enter/exit is handled · matplotlib/matplotlib@b659641 · GitHub
[go: up one dir, main page]

Skip to content

Commit b659641

Browse files
committed
Update how tracking for macosx mouse enter/exit is handled
Instead of manually adding tracking rectangles and updating for resize (older API), use a "newer" API (added OSX 10.5) for tracking areas. With the right flags, these areas are automatically updated for resize.
1 parent 1fad1d2 commit b659641

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/_macosx.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,13 @@ static CGFloat _get_device_scale(CGContextRef cr)
337337

338338
NSRect rect = NSMakeRect(0.0, 0.0, width, height);
339339
self->view = [self->view initWithFrame: rect];
340+
int opts = (NSTrackingMouseEnteredAndExited |
341+
NSTrackingActiveInKeyWindow | NSTrackingInVisibleRect);
342+
[self->view addTrackingArea: [
343+
[NSTrackingArea alloc] initWithRect: rect
344+
options: opts
345+
owner: self->view
346+
userInfo: nil]];
340347
[self->view setCanvas: (PyObject*)self];
341348
return 0;
342349
}
@@ -1565,7 +1572,6 @@ - (View*)initWithFrame:(NSRect)rect
15651572
self = [super initWithFrame: rect];
15661573
rubberband = NSZeroRect;
15671574
inside = false;
1568-
tracking = 0;
15691575
device_scale = 1;
15701576
return self;
15711577
}
@@ -1574,7 +1580,6 @@ - (void)dealloc
15741580
{
15751581
FigureCanvas* fc = (FigureCanvas*)canvas;
15761582
if (fc) fc->view = NULL;
1577-
[self removeTrackingRect: tracking];
15781583
[super dealloc];
15791584
}
15801585

@@ -1713,11 +1718,6 @@ - (void)windowDidResize: (NSNotification*)notification
17131718
else
17141719
PyErr_Print();
17151720
PyGILState_Release(gstate);
1716-
if (tracking) [self removeTrackingRect: tracking];
1717-
tracking = [self addTrackingRect: [self bounds]
1718-
owner: self
1719-
userData: nil
1720-
assumeInside: NO];
17211721
[self setNeedsDisplay: YES];
17221722
}
17231723

0 commit comments

Comments
 (0)
0