parent
5c4462281e
commit
b3f1acd400
@ -477,7 +477,7 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos
|
|||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = frameRect.origin.x;
|
*xpos = frameRect.origin.x;
|
||||||
if (ypos)
|
if (ypos)
|
||||||
*ypos = _glfwTransformYNS(frameRect.origin.y + frameRect.size.height);
|
*ypos = _glfwTransformYNS(frameRect.origin.y + frameRect.size.height - 1);
|
||||||
if (width)
|
if (width)
|
||||||
*width = frameRect.size.width;
|
*width = frameRect.size.width;
|
||||||
if (height)
|
if (height)
|
||||||
|
|||||||
@ -133,7 +133,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,
|
||||||
_glfwTransformYNS(bounds.origin.y + bounds.size.height),
|
_glfwTransformYNS(bounds.origin.y + bounds.size.height - 1),
|
||||||
bounds.size.width,
|
bounds.size.width,
|
||||||
bounds.size.height);
|
bounds.size.height);
|
||||||
|
|
||||||
@ -655,6 +655,7 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL;
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const NSRect contentRect = [window->ns.view frame];
|
const NSRect contentRect = [window->ns.view frame];
|
||||||
|
// NOTE: The returned location uses base 0,1 not 0,0
|
||||||
const NSPoint pos = [event locationInWindow];
|
const NSPoint pos = [event locationInWindow];
|
||||||
|
|
||||||
_glfwInputCursorPos(window, pos.x, contentRect.size.height - pos.y - 1);
|
_glfwInputCursorPos(window, pos.x, contentRect.size.height - pos.y - 1);
|
||||||
@ -935,9 +936,9 @@ is_ascii_control_char(char x) {
|
|||||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
const NSRect contentRect = [window->ns.view frame];
|
const NSRect contentRect = [window->ns.view frame];
|
||||||
_glfwInputCursorPos(window,
|
// NOTE: The returned location uses base 0,1 not 0,0
|
||||||
[sender draggingLocation].x,
|
const NSPoint pos = [sender draggingLocation];
|
||||||
contentRect.size.height - [sender draggingLocation].y);
|
_glfwInputCursorPos(window, pos.x, contentRect.size.height - pos.y);
|
||||||
NSPasteboard* pasteboard = [sender draggingPasteboard];
|
NSPasteboard* pasteboard = [sender draggingPasteboard];
|
||||||
NSDictionary* options = @{NSPasteboardURLReadingFileURLsOnlyKey:@YES};
|
NSDictionary* options = @{NSPasteboardURLReadingFileURLsOnlyKey:@YES};
|
||||||
NSArray* urls = [pasteboard readObjectsForClasses:@[[NSURL class]]
|
NSArray* urls = [pasteboard readObjectsForClasses:@[[NSURL class]]
|
||||||
@ -1015,10 +1016,8 @@ is_ascii_control_char(char x) {
|
|||||||
- (NSRect)firstRectForCharacterRange:(NSRange)range
|
- (NSRect)firstRectForCharacterRange:(NSRange)range
|
||||||
actualRange:(NSRangePointer)actualRange
|
actualRange:(NSRangePointer)actualRange
|
||||||
{
|
{
|
||||||
int xpos, ypos;
|
const NSRect frame = [window->ns.view frame];
|
||||||
_glfwPlatformGetWindowPos(window, &xpos, &ypos);
|
return NSMakeRect(frame.origin.x, frame.origin.y, 0.0, 0.0);
|
||||||
const NSRect contentRect = [window->ns.view frame];
|
|
||||||
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
|
||||||
@ -1416,13 +1415,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 = _glfwTransformYNS(contentRect.origin.y + contentRect.size.height);
|
*ypos = _glfwTransformYNS(contentRect.origin.y + contentRect.size.height - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
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, _glfwTransformYNS(y + contentRect.size.height), 0, 0);
|
const NSRect dummyRect = NSMakeRect(x, _glfwTransformYNS(y + contentRect.size.height - 1), 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];
|
||||||
}
|
}
|
||||||
@ -1585,7 +1584,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const NSRect contentRect =
|
const NSRect contentRect =
|
||||||
NSMakeRect(xpos, _glfwTransformYNS(ypos + height), width, height);
|
NSMakeRect(xpos, _glfwTransformYNS(ypos + height - 1), width, height);
|
||||||
const NSRect frameRect =
|
const NSRect frameRect =
|
||||||
[window->ns.object frameRectForContentRect:contentRect
|
[window->ns.object frameRectForContentRect:contentRect
|
||||||
styleMask:getStyleMask(window)];
|
styleMask:getStyleMask(window)];
|
||||||
@ -1615,7 +1614,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSRect contentRect = NSMakeRect(xpos, _glfwTransformYNS(ypos + height),
|
NSRect contentRect = NSMakeRect(xpos, _glfwTransformYNS(ypos + height - 1),
|
||||||
width, height);
|
width, height);
|
||||||
NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect
|
NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect
|
||||||
styleMask:styleMask];
|
styleMask:styleMask];
|
||||||
@ -1796,12 +1795,13 @@ void _glfwPlatformPostEmptyEvent(void)
|
|||||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
||||||
{
|
{
|
||||||
const NSRect contentRect = [window->ns.view frame];
|
const NSRect contentRect = [window->ns.view frame];
|
||||||
|
// NOTE: The returned location uses base 0,1 not 0,0
|
||||||
const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
|
const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
|
||||||
|
|
||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = pos.x;
|
*xpos = pos.x;
|
||||||
if (ypos)
|
if (ypos)
|
||||||
*ypos = contentRect.size.height - pos.y - 1;
|
*ypos = contentRect.size.height - pos.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||||
@ -1809,6 +1809,7 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
|||||||
updateCursorImage(window);
|
updateCursorImage(window);
|
||||||
|
|
||||||
const NSRect contentRect = [window->ns.view frame];
|
const NSRect contentRect = [window->ns.view frame];
|
||||||
|
// NOTE: The returned location uses base 0,1 not 0,0
|
||||||
const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
|
const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
|
||||||
|
|
||||||
window->ns.cursorWarpDeltaX += x - pos.x;
|
window->ns.cursorWarpDeltaX += x - pos.x;
|
||||||
@ -2203,5 +2204,5 @@ GLFWAPI void glfwGetCocoaKeyEquivalent(int glfw_key, int glfw_mods, unsigned sho
|
|||||||
//
|
//
|
||||||
float _glfwTransformYNS(float y)
|
float _glfwTransformYNS(float y)
|
||||||
{
|
{
|
||||||
return CGDisplayBounds(CGMainDisplayID()).size.height - y;
|
return CGDisplayBounds(CGMainDisplayID()).size.height - y - 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user