mirror of
https://github.com/glfw/glfw.git
synced 2025-10-04 21:56:36 +00:00
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:
parent
3229ae91b2
commit
c7c9b54459
@ -938,13 +938,32 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title)
|
|||||||
|
|
||||||
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
||||||
{
|
{
|
||||||
const NSRect contentRect =
|
// Code from Matt Reagan on the Cocoa-dev mailing list.
|
||||||
[window->ns.object contentRectForFrameRect:[window->ns.object frame]];
|
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)
|
if (xpos)
|
||||||
*xpos = contentRect.origin.x;
|
*xpos = rect.origin.x;
|
||||||
if (ypos)
|
if (ypos)
|
||||||
*ypos = transformY(contentRect.origin.y + contentRect.size.height);
|
*ypos = rect.origin.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
||||||
|
Loading…
Reference in New Issue
Block a user