mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-26 20:28:49 -05:00
parent
a43d1a4937
commit
4b20fb705b
|
@ -422,7 +422,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = frameRect.origin.x;
|
*xpos = frameRect.origin.x;
|
||||||
if (ypos)
|
if (ypos)
|
||||||
*ypos = frameRect.origin.y;
|
*ypos = _glfwTransformYNS(frameRect.origin.y + frameRect.size.height);
|
||||||
if (width)
|
if (width)
|
||||||
*width = frameRect.size.width;
|
*width = frameRect.size.width;
|
||||||
if (height)
|
if (height)
|
||||||
|
|
|
@ -168,3 +168,5 @@ void _glfwPollMonitorsNS(void);
|
||||||
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||||
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);
|
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);
|
||||||
|
|
||||||
|
float _glfwTransformYNS(float y);
|
||||||
|
|
||||||
|
|
|
@ -140,14 +140,6 @@ static void updateCursorMode(_GLFWwindow* window)
|
||||||
updateCursorImage(window);
|
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
|
// Make the specified window and its video mode active on its monitor
|
||||||
//
|
//
|
||||||
static void acquireMonitor(_GLFWwindow* window)
|
static void acquireMonitor(_GLFWwindow* window)
|
||||||
|
@ -155,7 +147,7 @@ static void acquireMonitor(_GLFWwindow* window)
|
||||||
_glfwSetVideoModeNS(window->monitor, &window->videoMode);
|
_glfwSetVideoModeNS(window->monitor, &window->videoMode);
|
||||||
const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID);
|
const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID);
|
||||||
const NSRect frame = NSMakeRect(bounds.origin.x,
|
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.width,
|
||||||
bounds.size.height);
|
bounds.size.height);
|
||||||
|
|
||||||
|
@ -743,7 +735,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||||
int xpos, ypos;
|
int xpos, ypos;
|
||||||
_glfwPlatformGetWindowPos(window, &xpos, &ypos);
|
_glfwPlatformGetWindowPos(window, &xpos, &ypos);
|
||||||
const NSRect contentRect = [window->ns.view frame];
|
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
|
- (void)insertText:(id)string replacementRange:(NSRange)replacementRange
|
||||||
|
@ -896,6 +888,18 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// 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 //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -998,13 +1002,13 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = contentRect.origin.x;
|
*xpos = contentRect.origin.x;
|
||||||
if (ypos)
|
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)
|
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
||||||
{
|
{
|
||||||
const NSRect contentRect = [window->ns.view frame];
|
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];
|
const NSRect frameRect = [window->ns.object frameRectForContentRect:dummyRect];
|
||||||
[window->ns.object setFrameOrigin:frameRect.origin];
|
[window->ns.object setFrameOrigin:frameRect.origin];
|
||||||
}
|
}
|
||||||
|
@ -1156,7 +1160,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const NSRect contentRect =
|
const NSRect contentRect =
|
||||||
NSMakeRect(xpos, transformY(ypos + height), width, height);
|
NSMakeRect(xpos, _glfwTransformYNS(ypos + height), width, height);
|
||||||
const NSRect frameRect =
|
const NSRect frameRect =
|
||||||
[window->ns.object frameRectForContentRect:contentRect
|
[window->ns.object frameRectForContentRect:contentRect
|
||||||
styleMask:getStyleMask(window)];
|
styleMask:getStyleMask(window)];
|
||||||
|
@ -1190,7 +1194,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSRect contentRect = NSMakeRect(xpos, transformY(ypos + height),
|
NSRect contentRect = NSMakeRect(xpos, _glfwTransformYNS(ypos + height),
|
||||||
width, height);
|
width, height);
|
||||||
NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect
|
NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect
|
||||||
styleMask:styleMask];
|
styleMask:styleMask];
|
||||||
|
@ -1400,7 +1404,7 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||||
const NSPoint globalPoint = globalRect.origin;
|
const NSPoint globalPoint = globalRect.origin;
|
||||||
|
|
||||||
CGWarpMouseCursorPosition(CGPointMake(globalPoint.x,
|
CGWarpMouseCursorPosition(CGPointMake(globalPoint.x,
|
||||||
transformY(globalPoint.y)));
|
_glfwTransformYNS(globalPoint.y)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user