From 03859c918c4c1c740291ca6e90ee2d9d6166b11b Mon Sep 17 00:00:00 2001 From: David Elliott Date: Tue, 14 Aug 2007 22:38:32 +0000 Subject: [PATCH] Fix the top-level window client size setting code such that the window position does not change as seen by wxWidgets. Copyright 2007 Software 2000 Ltd. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48074 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/cocoa/toplevel.mm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cocoa/toplevel.mm b/src/cocoa/toplevel.mm index 8cce120e00..3e73b00ceb 100644 --- a/src/cocoa/toplevel.mm +++ b/src/cocoa/toplevel.mm @@ -385,16 +385,22 @@ void wxTopLevelWindowCocoa::CocoaSetWxWindowSize(int width, int height) { // Set the NSView size by setting the frame size to enclose it unsigned int styleMask = [m_cocoaNSWindow styleMask]; - NSRect frameRect = [m_cocoaNSWindow frame]; + NSRect oldFrameRect = [m_cocoaNSWindow frame]; NSRect contentRect = [NSWindow - contentRectForFrameRect: frameRect + contentRectForFrameRect: oldFrameRect styleMask: styleMask]; contentRect.size.width = width; contentRect.size.height = height; - frameRect = [NSWindow + NSRect newFrameRect = [NSWindow frameRectForContentRect: contentRect styleMask: styleMask]; - [m_cocoaNSWindow setFrame: frameRect display: NO]; + + // Cocoa uses +y is up but wxWidgets uses +y is down. We want an increase/decrease in height + // to not effect where the top of the window is placed so we set the new y origin relative the + // old one taking the height change into account. + newFrameRect.origin.y = oldFrameRect.origin.y + oldFrameRect.size.height - newFrameRect.size.height; + + [m_cocoaNSWindow setFrame: newFrameRect display: NO]; } void wxTopLevelWindowCocoa::DoMoveWindow(int x, int y, int width, int height)