From a54ecfade3696380020d47632b91596ab22b24a5 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 6 May 2018 22:05:33 +0200 Subject: Fix Apple being annoying --- Source/SPConnectionController.m | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index 8380f827..b9db12ad 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -86,6 +86,8 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; */ static BOOL FindLinesInFile(NSData *fileData,const void *first,size_t first_len,const void *second,size_t second_len); +static BOOL isOSAtLeast10_7; + @interface SPConnectionController () // Privately redeclare as read/write to get the synthesized setter @@ -178,6 +180,10 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, @synthesize isConnecting; @synthesize isEditingConnection; ++ (void)initialize { + isOSAtLeast10_7 = [SPOSInfo isOSVersionAtLeastMajor:10 minor:7 patch:0]; +} + - (NSString *)keychainPassword { NSString *kcItemName = [self connectionKeychainItemName]; @@ -2981,10 +2987,15 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, // the division may lead to values that are not valid for the current screen size (e.g. non-integer values on a // @1x non-retina screen). The OS works something out when not using layer-backed views, but in the latter // case the result will look like garbage if we don't fix this. - // This code is taken from Apple's "BlurryView" example code. - connectionDetailsFrame = [[connectionDetailsScrollView superview] convertRectToBase:connectionDetailsFrame]; - connectionDetailsFrame.origin.y = round(connectionDetailsFrame.origin.y); - connectionDetailsFrame = [[connectionDetailsScrollView superview] convertRectFromBase:connectionDetailsFrame]; + if(isOSAtLeast10_7) { + connectionDetailsFrame = [connectionDetailsScrollView backingAlignedRect:connectionDetailsFrame options:NSAlignAllEdgesNearest]; + } + else { + // This code is taken from Apple's "BlurryView" example code. + connectionDetailsFrame = [[connectionDetailsScrollView superview] convertRectToBase:connectionDetailsFrame]; + connectionDetailsFrame.origin.y = round(connectionDetailsFrame.origin.y); + connectionDetailsFrame = [[connectionDetailsScrollView superview] convertRectFromBase:connectionDetailsFrame]; + } [connectionResizeContainer setFrame:connectionDetailsFrame]; scrollDocumentFrame.size.height = scrollViewFrame.size.height; [[connectionDetailsScrollView documentView] setFrame:scrollDocumentFrame]; -- cgit v1.2.3