From c398d3d16e41728f2d1f3d7d9495de256e00dc86 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 8 Sep 2019 09:16:07 +0530 Subject: [PATCH] Cocoa: Fix glfwSetWindowSize anchor point This makes glfwSetWindowSize use the top-left corner as anchor point instead of the bottom-left corner. Upstream: https://github.com/glfw/glfw/commit/7f02898264d6077738f0e8032f027eb7e252c90e --- glfw/cocoa_window.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index d576ce222..2550a3b43 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1638,7 +1638,14 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) acquireMonitor(window); } else - [window->ns.object setContentSize:NSMakeSize(width, height)]; + { + NSRect contentRect = + [window->ns.object contentRectForFrameRect:[window->ns.object frame]]; + contentRect.origin.y += contentRect.size.height - height; + contentRect.size = NSMakeSize(width, height); + [window->ns.object setFrame:[window->ns.object frameRectForContentRect:contentRect] + display:YES]; + } } void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,