From 3ff2a38fcfa70dc23f90849e5c83ecd30c963cf5 Mon Sep 17 00:00:00 2001 From: Florian Schliep Date: Sun, 20 Aug 2017 12:55:11 +0200 Subject: [PATCH 1/2] Fix Issue #5 Fix window growing vertically at every launch when using frame autosaving. --- WAYWindow/WAYWindow.m | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/WAYWindow/WAYWindow.m b/WAYWindow/WAYWindow.m index 8421030..9078728 100644 --- a/WAYWindow/WAYWindow.m +++ b/WAYWindow/WAYWindow.m @@ -223,10 +223,15 @@ - (void) setTitleBarHeight:(CGFloat)titleBarHeight { _dummyTitlebarAccessoryViewController.fullScreenMinHeight = titleBarHeight; [self addTitlebarAccessoryViewController:_dummyTitlebarAccessoryViewController]; - NSRect frame = self.frame; - frame.size.height += delta; - frame.origin.y -= delta; - + if (self.frameAutosaveName) { + [self setFrameUsingName:self.frameAutosaveName]; + } + NSRect frame = self.frame; + frame.size.height += delta; + frame.size.height -= titleBarHeight; // prevent increasing the window height after every launch + frame.origin.y -= delta; + frame.origin.y += titleBarHeight; // prevent changing the window position after every launch + [self _setNeedsLayout]; [self setFrame:frame display:NO]; // NO is important. } From 1611ee1024b8ab4f819ec6478bc8e96e20bbb003 Mon Sep 17 00:00:00 2001 From: Florian Schliep Date: Sun, 20 Aug 2017 12:59:07 +0200 Subject: [PATCH 2/2] Add Support for RTL Layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Position the traffic lights at either the left or right side of the window, depending on the user’s preference. --- WAYWindow/WAYWindow.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/WAYWindow/WAYWindow.m b/WAYWindow/WAYWindow.m index 9078728..195b769 100644 --- a/WAYWindow/WAYWindow.m +++ b/WAYWindow/WAYWindow.m @@ -341,8 +341,14 @@ - (void) _setNeedsLayout { else frame.origin.y = NSHeight(standardButton.superview.frame)-NSHeight(standardButton.frame)-_trafficLightButtonsTopMargin; - frame.origin.x = _trafficLightButtonsLeftMargin +idx*(NSWidth(frame) + 6); - [standardButton setFrame:frame]; + CGFloat buttonMargin= 6; + if (NSApp.userInterfaceLayoutDirection == NSUserInterfaceLayoutDirectionLeftToRight) { + frame.origin.x = _trafficLightButtonsLeftMargin + idx*(NSWidth(frame) + buttonMargin); + } else { + frame.origin.x = NSMaxX(standardButton.superview.bounds) - _trafficLightButtonsLeftMargin - (idx+1)*NSWidth(frame) - idx*buttonMargin; + } + + [standardButton setFrame:frame]; }]; }