From 74aa713a8e2153b0927b418017fbbfe494dea826 Mon Sep 17 00:00:00 2001 From: Ryan Hanson Date: Thu, 16 Jan 2020 09:59:02 +0100 Subject: [PATCH] Fixed bug with non-resizable windows and directional move Also made centering of windows on directional move configurable --- Rectangle.xcodeproj/project.pbxproj | 32 +++++++++++-------- Rectangle/Defaults.swift | 1 + Rectangle/RectangleRelease.entitlements | 5 +++ Rectangle/WindowAction.swift | 7 ++++ .../MoveDownCalculation.swift | 2 +- .../MoveLeftRightCalculation.swift | 4 +-- .../WindowCalculation/MoveUpCalculation.swift | 2 +- Rectangle/WindowManager.swift | 7 ++-- .../RectangleLauncherRelease.entitlements | 8 +++++ 9 files changed, 47 insertions(+), 21 deletions(-) create mode 100644 Rectangle/RectangleRelease.entitlements create mode 100644 RectangleLauncher/RectangleLauncherRelease.entitlements diff --git a/Rectangle.xcodeproj/project.pbxproj b/Rectangle.xcodeproj/project.pbxproj index 12743472a..a7ad5a944 100644 --- a/Rectangle.xcodeproj/project.pbxproj +++ b/Rectangle.xcodeproj/project.pbxproj @@ -104,6 +104,8 @@ 53A6B6ACF05CD88EB34E0D00 /* Pods-Rectangle.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Rectangle.debug.xcconfig"; path = "Target Support Files/Pods-Rectangle/Pods-Rectangle.debug.xcconfig"; sourceTree = ""; }; 80B094EEF6AE857D468B639A /* Pods-RectangleLauncher.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RectangleLauncher.debug.xcconfig"; path = "Target Support Files/Pods-RectangleLauncher/Pods-RectangleLauncher.debug.xcconfig"; sourceTree = ""; }; 81D6E6EACB077B1A204F3A62 /* Pods_RectangleTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RectangleTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 9808018523D05C0B0077774A /* RectangleRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RectangleRelease.entitlements; sourceTree = ""; }; + 9808018623D05C1F0077774A /* RectangleLauncherRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RectangleLauncherRelease.entitlements; sourceTree = ""; }; 981F27D02340E3E1006CD263 /* InternetAccessPolicy.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = InternetAccessPolicy.plist; sourceTree = ""; }; 9821402022B3884600ABFB3F /* BottomHalfCalculation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomHalfCalculation.swift; sourceTree = ""; }; 9821402222B3886100ABFB3F /* CenterCalculation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CenterCalculation.swift; sourceTree = ""; }; @@ -254,6 +256,7 @@ 9821403D22B3EBD900ABFB3F /* RectangleLauncher */ = { isa = PBXGroup; children = ( + 9808018623D05C1F0077774A /* RectangleLauncherRelease.entitlements */, 9821403E22B3EBD900ABFB3F /* AppDelegate.swift */, 9821404222B3EBDA00ABFB3F /* Assets.xcassets */, 9821404422B3EBDA00ABFB3F /* Main.storyboard */, @@ -365,6 +368,7 @@ 9824701222AF9B7E0037B409 /* Main.storyboard */, 9824701522AF9B7E0037B409 /* Info.plist */, 981F27D02340E3E1006CD263 /* InternetAccessPolicy.plist */, + 9808018523D05C0B0077774A /* RectangleRelease.entitlements */, 9824701622AF9B7E0037B409 /* Rectangle.entitlements */, 9821405F22B3EFB200ABFB3F /* Defaults.swift */, 98C1008B2305F1FA006E5344 /* SubsequentExecutionMode.swift */, @@ -843,12 +847,12 @@ baseConfigurationReference = 0796D218CC3C7CD563827A8D /* Pods-RectangleLauncher.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_ENTITLEMENTS = RectangleLauncher/RectangleLauncher.entitlements; - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_ENTITLEMENTS = RectangleLauncher/RectangleLauncherRelease.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = ""; - ENABLE_HARDENED_RUNTIME = NO; + DEVELOPMENT_TEAM = XSYZ3E4B7D; + ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = RectangleLauncher/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -989,7 +993,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 21; + CURRENT_PROJECT_VERSION = 22; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = NO; INFOPLIST_FILE = Rectangle/Info.plist; @@ -998,7 +1002,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.11; - MARKETING_VERSION = 0.17; + MARKETING_VERSION = 0.18; PRODUCT_BUNDLE_IDENTIFIER = com.knollsoft.Rectangle; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1011,20 +1015,20 @@ baseConfigurationReference = BFFF93EBEA6E2FF7245A7CF5 /* Pods-Rectangle.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_ENTITLEMENTS = Rectangle/Rectangle.entitlements; - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_ENTITLEMENTS = Rectangle/RectangleRelease.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 21; - DEVELOPMENT_TEAM = ""; - ENABLE_HARDENED_RUNTIME = NO; + CURRENT_PROJECT_VERSION = 22; + DEVELOPMENT_TEAM = XSYZ3E4B7D; + ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = Rectangle/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.11; - MARKETING_VERSION = 0.17; + MARKETING_VERSION = 0.18; PRODUCT_BUNDLE_IDENTIFIER = com.knollsoft.Rectangle; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1062,10 +1066,10 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = XSYZ3E4B7D; INFOPLIST_FILE = RectangleTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/Rectangle/Defaults.swift b/Rectangle/Defaults.swift index 8374b1c29..4fc9e34a2 100644 --- a/Rectangle/Defaults.swift +++ b/Rectangle/Defaults.swift @@ -19,6 +19,7 @@ class Defaults { static let almostMaximizeHeight = FloatDefault(key: "almostMaximizeHeight") static let almostMaximizeWidth = FloatDefault(key: "almostMaximizeWidth") static let gapSize = FloatDefault(key: "gapSize") + static let centeredDirectionalMove = OptionalBoolDefault(key: "centeredDirectionalMove") } class BoolDefault { diff --git a/Rectangle/RectangleRelease.entitlements b/Rectangle/RectangleRelease.entitlements new file mode 100644 index 000000000..0c67376eb --- /dev/null +++ b/Rectangle/RectangleRelease.entitlements @@ -0,0 +1,5 @@ + + + + + diff --git a/Rectangle/WindowAction.swift b/Rectangle/WindowAction.swift index a1e394fe0..4aa6deccb 100644 --- a/Rectangle/WindowAction.swift +++ b/Rectangle/WindowAction.swift @@ -199,6 +199,13 @@ enum WindowAction: Int { } } + var isDirectionalMove: Bool { + switch self { + case .moveUp, .moveDown, .moveLeft, .moveRight: return true + default: return false + } + } + var spectacleDefault: Shortcut? { switch self { case .leftHalf: return Shortcut( cmd|alt, kVK_LeftArrow ) diff --git a/Rectangle/WindowCalculation/MoveDownCalculation.swift b/Rectangle/WindowCalculation/MoveDownCalculation.swift index 002b867ef..c88128897 100644 --- a/Rectangle/WindowCalculation/MoveDownCalculation.swift +++ b/Rectangle/WindowCalculation/MoveDownCalculation.swift @@ -18,7 +18,7 @@ class MoveDownCalculation: WindowCalculation { if windowRect.width >= visibleFrameOfScreen.width { calculatedWindowRect.size.width = visibleFrameOfScreen.width calculatedWindowRect.origin.x = visibleFrameOfScreen.minX - } else { + } else if Defaults.centeredDirectionalMove.enabled != false { calculatedWindowRect.origin.x = round((visibleFrameOfScreen.width - windowRect.width) / 2.0) + visibleFrameOfScreen.minX } return RectResult(calculatedWindowRect) diff --git a/Rectangle/WindowCalculation/MoveLeftRightCalculation.swift b/Rectangle/WindowCalculation/MoveLeftRightCalculation.swift index 5c5ab726e..e970e19fa 100644 --- a/Rectangle/WindowCalculation/MoveLeftRightCalculation.swift +++ b/Rectangle/WindowCalculation/MoveLeftRightCalculation.swift @@ -43,7 +43,7 @@ class MoveLeftRightCalculation: WindowCalculation { if windowRect.height >= visibleFrameOfScreen.height { calculatedWindowRect.size.height = visibleFrameOfScreen.height calculatedWindowRect.origin.y = visibleFrameOfScreen.minY - } else { + } else if Defaults.centeredDirectionalMove.enabled != false { calculatedWindowRect.origin.y = round((visibleFrameOfScreen.height - windowRect.height) / 2.0) + visibleFrameOfScreen.minY } return WindowCalculationResult(rect: calculatedWindowRect, screen: screen, resultingAction: .moveLeft) @@ -73,7 +73,7 @@ class MoveLeftRightCalculation: WindowCalculation { if windowRect.height >= visibleFrameOfScreen.height { calculatedWindowRect.size.height = visibleFrameOfScreen.height calculatedWindowRect.origin.y = visibleFrameOfScreen.minY - } else { + } else if Defaults.centeredDirectionalMove.enabled != false { calculatedWindowRect.origin.y = round((visibleFrameOfScreen.height - windowRect.height) / 2.0) + visibleFrameOfScreen.minY } return WindowCalculationResult(rect: calculatedWindowRect, screen: screen, resultingAction: .moveRight) diff --git a/Rectangle/WindowCalculation/MoveUpCalculation.swift b/Rectangle/WindowCalculation/MoveUpCalculation.swift index 3852aa4ba..da7c72f18 100644 --- a/Rectangle/WindowCalculation/MoveUpCalculation.swift +++ b/Rectangle/WindowCalculation/MoveUpCalculation.swift @@ -18,7 +18,7 @@ class MoveUpCalculation: WindowCalculation { if windowRect.width >= visibleFrameOfScreen.width { calculatedWindowRect.size.width = visibleFrameOfScreen.width calculatedWindowRect.origin.x = visibleFrameOfScreen.minX - } else { + } else if Defaults.centeredDirectionalMove.enabled != false { calculatedWindowRect.origin.x = round((visibleFrameOfScreen.width - windowRect.width) / 2.0) + visibleFrameOfScreen.minX } return RectResult(calculatedWindowRect) diff --git a/Rectangle/WindowManager.swift b/Rectangle/WindowManager.swift index a8781bfea..204fce702 100644 --- a/Rectangle/WindowManager.swift +++ b/Rectangle/WindowManager.swift @@ -106,9 +106,10 @@ class WindowManager { let visibleFrameOfDestinationScreen = NSRectToCGRect(calcResult.screen.visibleFrame) - let windowMoverChain = frontmostWindowElement.isResizable() - ? standardWindowMoverChain - : fixedSizeWindowMoverChain + let useFixedSizeMover = !frontmostWindowElement.isResizable() && !action.isDirectionalMove + let windowMoverChain = useFixedSizeMover + ? fixedSizeWindowMoverChain + : standardWindowMoverChain for windowMover in windowMoverChain { windowMover.moveWindowRect(newNormalizedRect, frameOfScreen: usableScreens.frameOfCurrentScreen, visibleFrameOfScreen: visibleFrameOfDestinationScreen, frontmostWindowElement: frontmostWindowElement, action: action) diff --git a/RectangleLauncher/RectangleLauncherRelease.entitlements b/RectangleLauncher/RectangleLauncherRelease.entitlements new file mode 100644 index 000000000..852fa1a47 --- /dev/null +++ b/RectangleLauncher/RectangleLauncherRelease.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + +