From 1677f82580db36a3ee9208a8deaeec2bdb1968ca Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 30 Sep 2019 21:32:13 +1000 Subject: [PATCH] Fix resizing from bottom left instead of top left corner with /client resolution on cocoa backend --- src/Window.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Window.c b/src/Window.c index 310902aca..8eb604cc1 100644 --- a/src/Window.c +++ b/src/Window.c @@ -3808,10 +3808,13 @@ void Window_ExitFullscreen(void) { } void Window_SetSize(int width, int height) { - CGSize size; - size.width = width; size.height = height; - // TODO: resize from top of window instead - objc_msgSend(winHandle, sel_registerName("setContentSize:"), size); + /* Can't use setContentSize:, because that resizes from the bottom left corner. */ + CGRect rect = ((CGRect(*)(id, SEL))(void *)objc_msgSend_stret)(winHandle, sel_registerName("frame")); + + rect.origin.y += Window_Height - height; + rect.size.width += width - Window_Width; + rect.size.height += height - Window_Height; + objc_msgSend(winHandle, sel_registerName("setFrame:display:"), rect, true); } void Window_Close(void) {