Incorporated code from Matt Reagan on the Cocoa-dev mailing list for fast window position updates.

This is a direct copy of Matt's code, which is able to determine the current
position of a window while it's being dragged.
This commit is contained in:
Cem Karan 2015-12-18 09:53:14 -05:00
parent 3229ae91b2
commit c7c9b54459

View File

@ -938,13 +938,32 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title)
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
{
const NSRect contentRect =
[window->ns.object contentRectForFrameRect:[window->ns.object frame]];
// Code from Matt Reagan on the Cocoa-dev mailing list.
CGRect rect;
CGWindowID windowID = (CGWindowID)[window->ns.object windowNumber];
CFArrayRef windowArray = CGWindowListCopyWindowInfo(kCGWindowListOptionIncludingWindow, windowID);
if (CFArrayGetCount(windowArray))
{
CFDictionaryRef windowInfoDictionary = (CFDictionaryRef)CFArrayGetValueAtIndex ((CFArrayRef)windowArray, 0);
if (CFDictionaryContainsKey(windowInfoDictionary, kCGWindowBounds))
{
CFDictionaryRef bounds = (CFDictionaryRef)CFDictionaryGetValue(windowInfoDictionary, kCGWindowBounds);
if (bounds)
{
CGRectMakeWithDictionaryRepresentation(bounds, &rect);
}
}
}
CFRelease(windowArray);
if (xpos)
*xpos = contentRect.origin.x;
*xpos = rect.origin.x;
if (ypos)
*ypos = transformY(contentRect.origin.y + contentRect.size.height);
*ypos = rect.origin.y;
}
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)