From a1b65e8542fc99da7beab795e70dea14c3469331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 29 Aug 2019 22:08:29 +0200 Subject: [PATCH] Cocoa: Fix glfwSetWindowSize anchor point This makes glfwSetWindowSize use the top-left corner as anchor point instead of the bottom-left corner. Fixes #1553. (cherry picked from commit 7f02898264d6077738f0e8032f027eb7e252c90e) --- README.md | 2 ++ src/cocoa_window.m | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 26e9c1cc..85a1a2d7 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,7 @@ information on what to include when reporting a bug. event (#1490) - [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the window (#1499) + - [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553) - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) - [X11] Bugfix: Key names were not updated when the keyboard layout changed (#1462,#1528) @@ -226,6 +227,7 @@ skills. - Peter Knut - Christoph Kubisch - Yuri Kunde Schlesner + - Rokas Kupstys - Konstantin Käfer - Eric Larson - Robin Leffmann diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 5f7e0c3e..c8af3321 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1032,7 +1032,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]; + } } // autoreleasepool }