From 39537f64746d8e0ea0f828efee251fb84acdf11f Mon Sep 17 00:00:00 2001 From: torque Date: Sat, 21 Feb 2015 19:12:31 -0800 Subject: [PATCH] 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. --- video/out/cocoa/events_view.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/video/out/cocoa/events_view.m b/video/out/cocoa/events_view.m index 20d1307abf..7c8283ad72 100644 --- a/video/out/cocoa/events_view.m +++ b/video/out/cocoa/events_view.m @@ -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]; }