changeset 20683:877105840549 draft

-Fix [FS#4392]: [OSX] The mouse cursor would sometimes jump near the window borders. (Matthieu)
author Michael Lutz <michi@icosahedron.de>
date Tue, 26 Feb 2013 02:45:46 +0100
parents 47e080672367
children 06da686976cc
files src/video/cocoa/wnd_quartz.mm
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/cocoa/wnd_quartz.mm
+++ b/src/video/cocoa/wnd_quartz.mm
@@ -514,8 +514,21 @@
 
 NSPoint WindowQuartzSubdriver::GetMouseLocation(NSEvent *event)
 {
-	NSPoint pt = [ event locationInWindow ];
-	pt = [ this->cocoaview convertPoint:pt fromView:nil ];
+	NSPoint pt;
+
+	if (event.window == nil) {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+		if ([ this->cocoaview respondsToSelector:@selector(convertRectFromScreen:) ]) {
+			pt = [ this->cocoaview convertPoint:[ [ this->cocoaview window ] convertRectFromScreen:NSMakeRect([ event locationInWindow ].x, [ event locationInWindow ].y, 0, 0) ].origin fromView:nil ];
+		}
+		else
+#endif
+		{
+			pt = [ this->cocoaview convertPoint:[ [ this->cocoaview window ] convertScreenToBase:[ event locationInWindow ] ] fromView:nil ];
+		}
+	} else {
+		pt = [ event locationInWindow ];
+	}
 
 	pt.y = this->window_height - pt.y;