From 8f7a04f9c3dbc70fa1f8854398fc1aaef1bf52c4 Mon Sep 17 00:00:00 2001 From: leethomas Date: Sun, 22 May 2016 15:43:47 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=8E=20=20let=20Cocoa=20handle=20keepin?= =?UTF-8?q?g=20the=20aspect=20ratio=20whenever=20the=20edges=20are=20dragg?= =?UTF-8?q?ed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- atom/browser/native_window_mac.mm | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index bfffc7a08d64..434919dde117 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -141,22 +141,11 @@ bool ScopedDisableResize::disable_resize_ = false; newSize.width = roundf((frameSize.height - extraHeightPlusFrame) * aspectRatio + extraWidthPlusFrame); + newSize.height = + roundf((newSize.width - extraWidthPlusFrame) / aspectRatio + + extraHeightPlusFrame); - // If the new width is less than the frame size use it as the primary - // constraint. This ensures that the value returned by this method will - // never be larger than the users requested window size. - if (newSize.width <= frameSize.width) { - newSize.height = - roundf((newSize.width - extraWidthPlusFrame) / aspectRatio + - extraHeightPlusFrame); - } else { - newSize.height = - roundf((frameSize.width - extraWidthPlusFrame) / aspectRatio + - extraHeightPlusFrame); - newSize.width = - roundf((newSize.height - extraHeightPlusFrame) * aspectRatio + - extraWidthPlusFrame); - } + [sender setAspectRatio:NSMakeSize(newSize.width, newSize.height)]; } return newSize;