Skip to content

Commit

Permalink
Fixed bug with non-resizable windows and directional move
Browse files Browse the repository at this point in the history
Also made centering of windows on directional move configurable
  • Loading branch information
Ryan Hanson committed Jan 16, 2020
1 parent bd9f3d8 commit 74aa713
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 21 deletions.
32 changes: 18 additions & 14 deletions Rectangle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
9808018623D05C1F0077774A /* RectangleLauncherRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RectangleLauncherRelease.entitlements; sourceTree = "<group>"; };
981F27D02340E3E1006CD263 /* InternetAccessPolicy.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = InternetAccessPolicy.plist; sourceTree = "<group>"; };
9821402022B3884600ABFB3F /* BottomHalfCalculation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomHalfCalculation.swift; sourceTree = "<group>"; };
9821402222B3886100ABFB3F /* CenterCalculation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CenterCalculation.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -254,6 +256,7 @@
9821403D22B3EBD900ABFB3F /* RectangleLauncher */ = {
isa = PBXGroup;
children = (
9808018623D05C1F0077774A /* RectangleLauncherRelease.entitlements */,
9821403E22B3EBD900ABFB3F /* AppDelegate.swift */,
9821404222B3EBDA00ABFB3F /* Assets.xcassets */,
9821404422B3EBDA00ABFB3F /* Main.storyboard */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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;
Expand All @@ -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 = "";
Expand All @@ -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 = "";
Expand Down Expand Up @@ -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)",
Expand Down
1 change: 1 addition & 0 deletions Rectangle/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions Rectangle/RectangleRelease.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
7 changes: 7 additions & 0 deletions Rectangle/WindowAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion Rectangle/WindowCalculation/MoveDownCalculation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Rectangle/WindowCalculation/MoveLeftRightCalculation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Rectangle/WindowCalculation/MoveUpCalculation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions Rectangle/WindowManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions RectangleLauncher/RectangleLauncherRelease.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
</dict>
</plist>

0 comments on commit 74aa713

Please sign in to comment.