Fixed mouse tracking in fullscreen on OS X

This commit is contained in:
Marco Antognini 2014-04-21 18:05:28 +02:00
parent 2eb4f69e41
commit 2c96d49a03

View File

@ -254,8 +254,9 @@ BOOL isValidTextUnicode(NSEvent* event);
{ {
NSPoint relativeToWindow = [[self window] mouseLocationOutsideOfEventStream]; NSPoint relativeToWindow = [[self window] mouseLocationOutsideOfEventStream];
NSPoint relativeToView = [self convertPoint:relativeToWindow fromView:nil]; NSPoint relativeToView = [self convertPoint:relativeToWindow fromView:nil];
NSLog(@"relativeToWindow %@\trelativeToView %@\trect %@", NSStringFromPoint(relativeToWindow), NSStringFromPoint(relativeToView), NSStringFromRect([self frame]));
return NSPointInRect(relativeToView, [self frame]); return NSPointInRect(relativeToView, [self bounds]);
} }
@ -265,11 +266,14 @@ BOOL isValidTextUnicode(NSEvent* event);
BOOL mouseWasIn = m_mouseIsIn; BOOL mouseWasIn = m_mouseIsIn;
m_mouseIsIn = [self isMouseInside]; m_mouseIsIn = [self isMouseInside];
if (m_requester == 0)
return;
// Send event if needed. // Send event if needed.
if (mouseWasIn && !m_mouseIsIn) if (mouseWasIn && !m_mouseIsIn)
[self mouseExited:nil]; m_requester->mouseMovedOut();
else if (!mouseWasIn && m_mouseIsIn) else if (!mouseWasIn && m_mouseIsIn)
[self mouseEntered:nil]; m_requester->mouseMovedIn();
} }
@ -361,39 +365,16 @@ BOOL isValidTextUnicode(NSEvent* event);
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
-(void)mouseEntered:(NSEvent*)theEvent -(void)mouseEntered:(NSEvent*)theEvent
{ {
// There are two cases when we need to fire an event: (void)theEvent;
// a) the event is nil, meaning that the method was [self updateMouseState];
// called from our code (e.g. updateMouseState)
// b) the mouse was outside the view.
BOOL shouldFire = ((theEvent == nil) || (m_mouseIsIn == NO));
// Update status
m_mouseIsIn = YES;
if (m_requester == 0)
return;
// Fire (or not) an event
if (shouldFire)
m_requester->mouseMovedIn();
} }
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
-(void)mouseExited:(NSEvent*)theEvent -(void)mouseExited:(NSEvent*)theEvent
{ {
// Similarly to mouseEntered: (void)theEvent;
BOOL shouldFire = ((theEvent == nil) || (m_mouseIsIn == YES)); [self updateMouseState];
// Update status
m_mouseIsIn = NO;
if (m_requester == 0)
return;
// Fire (or not) an event
if (shouldFire)
m_requester->mouseMovedOut();
} }