From ee66e5fa10a36063320f76bb7be20779c0f2fc32 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 2 Jul 2012 00:36:20 +0200 Subject: [PATCH] Merged fix for bug #3528964. --- readme.html | 2 +- src/cocoa_window.m | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/readme.html b/readme.html index 8982eaeb..97a314dd 100644 --- a/readme.html +++ b/readme.html @@ -917,7 +917,7 @@ their skills. Special thanks go out to:

  • Steve Sexton, for reporting an input bug in the Carbon port
  • -
  • Dmitri Shuralyov, for support, bug reports and testing
  • +
  • Dmitri Shuralyov, for support, bug reports, bug fixes and testing
  • Daniel Skorupski, for reporting a bug in the Win32 DEF file
  • diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 2c7b8425..781bfd32 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -357,12 +357,13 @@ static int convertMacKeyCode(unsigned int macKeyCode) _glfwInputCursorMotion(window, [event deltaX], [event deltaY]); else { - NSPoint p = [event locationInWindow]; + const NSPoint p = [event locationInWindow]; // Cocoa coordinate system has origin at lower left - p.y = [[window->NS.object contentView] bounds].size.height - p.y; + const int x = lround(floor(p.x)); + const int y = window->height - lround(ceil(p.y)); - _glfwInputCursorMotion(window, p.x, p.y); + _glfwInputCursorMotion(window, x, y); } } @@ -1168,7 +1169,7 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y) // calculating the maximum y coordinate of all screens, since Cocoa's // "global coordinates" are upside down from CG's... - NSPoint localPoint = NSMakePoint(x, window->height - y); + NSPoint localPoint = NSMakePoint(x, window->height - y - 1); NSPoint globalPoint = [window->NS.object convertBaseToScreen:localPoint]; CGPoint mainScreenOrigin = CGDisplayBounds(CGMainDisplayID()).origin; double mainScreenHeight = CGDisplayBounds(CGMainDisplayID()).size.height;