Cocoa: Fix work area using NS screen coordinates

Related to #1322.
diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m
index 804e8e3..37e8fd1 100644
--- a/src/cocoa_monitor.m
+++ b/src/cocoa_monitor.m
@@ -422,7 +422,7 @@
     if (xpos)
         *xpos = frameRect.origin.x;
     if (ypos)
-        *ypos = frameRect.origin.y;
+        *ypos = _glfwTransformYNS(frameRect.origin.y + frameRect.size.height);
     if (width)
         *width = frameRect.size.width;
     if (height)
diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h
index cf7ead5..4f3cebc 100644
--- a/src/cocoa_platform.h
+++ b/src/cocoa_platform.h
@@ -168,3 +168,5 @@
 void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
 void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);
 
+float _glfwTransformYNS(float y);
+
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 9bea2f2..4f3756b 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -140,14 +140,6 @@
         updateCursorImage(window);
 }
 
-// Transforms the specified y-coordinate between the CG display and NS screen
-// coordinate systems
-//
-static float transformY(float y)
-{
-    return CGDisplayBounds(CGMainDisplayID()).size.height - y;
-}
-
 // Make the specified window and its video mode active on its monitor
 //
 static void acquireMonitor(_GLFWwindow* window)
@@ -155,7 +147,7 @@
     _glfwSetVideoModeNS(window->monitor, &window->videoMode);
     const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID);
     const NSRect frame = NSMakeRect(bounds.origin.x,
-                                    transformY(bounds.origin.y + bounds.size.height),
+                                    _glfwTransformYNS(bounds.origin.y + bounds.size.height),
                                     bounds.size.width,
                                     bounds.size.height);
 
@@ -743,7 +735,7 @@
     int xpos, ypos;
     _glfwPlatformGetWindowPos(window, &xpos, &ypos);
     const NSRect contentRect = [window->ns.view frame];
-    return NSMakeRect(xpos, transformY(ypos + contentRect.size.height), 0.0, 0.0);
+    return NSMakeRect(xpos, _glfwTransformYNS(ypos + contentRect.size.height), 0.0, 0.0);
 }
 
 - (void)insertText:(id)string replacementRange:(NSRange)replacementRange
@@ -897,6 +889,18 @@
 
 
 //////////////////////////////////////////////////////////////////////////
+//////                       GLFW internal API                      //////
+//////////////////////////////////////////////////////////////////////////
+
+// Transforms a y-coordinate between the CG display and NS screen spaces
+//
+float _glfwTransformYNS(float y)
+{
+    return CGDisplayBounds(CGMainDisplayID()).size.height - y;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
 //////                       GLFW platform API                      //////
 //////////////////////////////////////////////////////////////////////////
 
@@ -998,13 +1002,13 @@
     if (xpos)
         *xpos = contentRect.origin.x;
     if (ypos)
-        *ypos = transformY(contentRect.origin.y + contentRect.size.height);
+        *ypos = _glfwTransformYNS(contentRect.origin.y + contentRect.size.height);
 }
 
 void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
 {
     const NSRect contentRect = [window->ns.view frame];
-    const NSRect dummyRect = NSMakeRect(x, transformY(y + contentRect.size.height), 0, 0);
+    const NSRect dummyRect = NSMakeRect(x, _glfwTransformYNS(y + contentRect.size.height), 0, 0);
     const NSRect frameRect = [window->ns.object frameRectForContentRect:dummyRect];
     [window->ns.object setFrameOrigin:frameRect.origin];
 }
@@ -1156,7 +1160,7 @@
         else
         {
             const NSRect contentRect =
-                NSMakeRect(xpos, transformY(ypos + height), width, height);
+                NSMakeRect(xpos, _glfwTransformYNS(ypos + height), width, height);
             const NSRect frameRect =
                 [window->ns.object frameRectForContentRect:contentRect
                                                  styleMask:getStyleMask(window)];
@@ -1190,7 +1194,7 @@
     }
     else
     {
-        NSRect contentRect = NSMakeRect(xpos, transformY(ypos + height),
+        NSRect contentRect = NSMakeRect(xpos, _glfwTransformYNS(ypos + height),
                                         width, height);
         NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect
                                                             styleMask:styleMask];
@@ -1400,7 +1404,7 @@
         const NSPoint globalPoint = globalRect.origin;
 
         CGWarpMouseCursorPosition(CGPointMake(globalPoint.x,
-                                              transformY(globalPoint.y)));
+                                              _glfwTransformYNS(globalPoint.y)));
     }
 }