8000 Simplify macosx handling of mousemove events · matplotlib/matplotlib@53bd4b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 53bd4b8

Browse files
committed
Simplify macosx handling of mousemove events
We can just request these events from the tracking area rather than manually enabling/disabling mouse move/checking inside.
1 parent a3f0999 commit 53bd4b8

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

src/_macosx.m

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ - (void)close;
204204
@interface View : NSView <NSWindowDelegate>
205205
{ PyObject* canvas;
206206
NSRect rubberband;
207-
BOOL inside;
208207
NSTrackingRectTag tracking;
209208
@public double device_scale;
210209
}
@@ -338,7 +337,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
338337
NSRect rect = NSMakeRect(0.0, 0.0, width, height);
339338
self->view = [self->view initWithFrame: rect];
340339
self->view.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
341-
int opts = (NSTrackingMouseEnteredAndExited |
340+
int opts = (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved |
342341
NSTrackingActiveInKeyWindow | NSTrackingInVisibleRect);
343342
[self->view addTrackingArea: [
344343
[NSTrackingArea alloc] initWithRect: rect
@@ -712,7 +711,6 @@ static CGFloat _get_device_scale(CGContextRef cr)
712711
[window setTitle: [NSString stringWithCString: title
713712
encoding: NSASCIIStringEncoding]];
714713

715-
[window setAcceptsMouseMovedEvents: YES];
716714
[window setDelegate: view];
717715
[window makeFirstResponder: view];
718716
[[window contentView] addSubview: view];
@@ -1572,7 +1570,6 @@ - (View*)initWithFrame:(NSRect)rect
15721570
{
15731571
self = [super initWithFrame: rect];
15741572
rubberband = NSZeroRect;
1575-
inside = false;
15761573
device_scale = 1;
15771574
return self;
15781575
}
@@ -1759,8 +1756,6 @@ - (void)mouseEntered:(NSEvent *)event
17591756
{
17601757
PyGILState_STATE gstate;
17611758
PyObject* result;
1762-
NSWindow* window = [self window];
1763-
if ([window isKeyWindow]==false) return;
17641759

17651760
int x, y;
17661761
NSPoint location = [event locationInWindow];
@@ -1777,29 +1772,20 @@ - (void)mouseEntered:(NSEvent *)event
17771772
else
17781773
PyErr_Print();
17791774
PyGILState_Release(gstate);
1780-
1781-
[window setAcceptsMouseMovedEvents: YES];
1782-
inside = true;
17831775
}
17841776

17851777
- (void)mouseExited:(NSEvent *)event
17861778
{
17871779
PyGILState_STATE gstate;
17881780
PyObject* result;
1789-
NSWindow* window = [self window];
1790-
if ([window isKeyWindow]==false) return;
17911781

1792-
if (inside==false) return;
17931782
gstate = PyGILState_Ensure();
17941783
result = PyObject_CallMethod(canvas, "leave_notify_event", "");
17951784
if(result)
17961785
Py_DECREF(result);
17971786
else
17981787
PyErr_Print();
17991788
PyGILState_Release(gstate);
1800-
1801-
[[self window] setAcceptsMouseMovedEvents: NO];
1802-
inside = false;
18031789
}
18041790

18051791
- (void)mouseDown:(NSEvent *)event

0 commit comments

Comments
 (0)
0