cocoa: clamp mouse position to window.

Prevents out-of-window coordinates being reported for mouse coordinates.
Previously they could be out-of-window coordinates on init or on resize.
This commit is contained in:
torque 2015-02-21 19:12:31 -08:00 committed by Stefano Pigozzi
parent bce753060e
commit 39537f6474
1 changed files with 2 additions and 0 deletions

View File

@ -209,6 +209,8 @@
- (void)signalMousePosition
{
NSPoint p = [self convertPointToPixels:[self mouseLocation]];
p.x = MIN(MAX(p.x, 0), self.bounds.size.width-1);
p.y = MIN(MAX(p.y, 0), self.bounds.size.height-1);
[self.adapter signalMouseMovement:p];
}