Skip to content

Instantly share code, notes, and snippets.

@jeromenerf
Last active November 8, 2017 15:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeromenerf/c7630ac1c74415f13338 to your computer and use it in GitHub Desktop.
Save jeromenerf/c7630ac1c74415f13338 to your computer and use it in GitHub Desktop.
uselessgaps
diff --git a/Spectacle/SpectacleConstants.h b/Spectacle/SpectacleConstants.h
index 7ffec1d..b605b83 100644
--- a/Spectacle/SpectacleConstants.h
+++ b/Spectacle/SpectacleConstants.h
@@ -59,7 +59,7 @@ extern const NSInteger SpectacleEscapeKey;
#pragma mark -
extern const CGFloat SpectacleWindowSizeOffset;
-
+extern const CGFloat SpectacleUselessGap;
extern const CGFloat SpectacleMinimumWindowSizeRatio;
#pragma mark -
diff --git a/Spectacle/SpectacleConstants.m b/Spectacle/SpectacleConstants.m
index f10a72d..af568c4 100644
--- a/Spectacle/SpectacleConstants.m
+++ b/Spectacle/SpectacleConstants.m
@@ -61,7 +61,7 @@ const NSInteger SpectacleEscapeKey = 53;
#pragma mark -
const CGFloat SpectacleWindowSizeOffset = 30.0f;
-
+const CGFloat SpectacleUselessGap = 10.0f;
const CGFloat SpectacleMinimumWindowSizeRatio = 4.0f;
#pragma mark -
diff --git a/Spectacle/SpectacleWindowPositionCalculator.m b/Spectacle/SpectacleWindowPositionCalculator.m
index 4cb1065..5094e20 100644
--- a/Spectacle/SpectacleWindowPositionCalculator.m
+++ b/Spectacle/SpectacleWindowPositionCalculator.m
@@ -47,11 +47,16 @@
if (MovingToThirdOfDisplay(action)) {
calculatedWindowRect = [SpectacleWindowPositionCalculator findThirdForWindowRect: calculatedWindowRect visibleFrameOfScreen: visibleFrameOfScreen withAction: action];
}
-
+ calculatedWindowRect.origin.x += SpectacleUselessGap;
+ calculatedWindowRect.origin.y += SpectacleUselessGap;
+ calculatedWindowRect.size.width -= 2*SpectacleUselessGap;
+ calculatedWindowRect.size.height -= 2*SpectacleUselessGap;
+
return [SpectacleCalculationResult resultWithAction: action windowRect: calculatedWindowRect];
}
+ (SpectacleCalculationResult *)calculateResizedWindowRect: (CGRect)windowRect visibleFrameOfScreen: (CGRect)visibleFrameOfScreen sizeOffset: (CGFloat)sizeOffset action: (SpectacleWindowAction)action {
+
CGRect calculatedWindowRect = windowRect;
calculatedWindowRect.size.width = calculatedWindowRect.size.width + sizeOffset;
@@ -105,6 +110,11 @@
calculatedWindowRect = windowRect;
}
+ calculatedWindowRect.size.height -= 2*SpectacleUselessGap;
+ calculatedWindowRect.size.width -= 2*SpectacleUselessGap;
+ calculatedWindowRect.origin.x -= SpectacleUselessGap;
+ calculatedWindowRect.origin.y -= SpectacleUselessGap;
+
return [SpectacleCalculationResult resultWithAction: action windowRect: calculatedWindowRect];
}
@@ -162,6 +172,11 @@
}
}
+ result.origin.x += SpectacleUselessGap;
+ result.origin.y += SpectacleUselessGap;
+ result.size.width -= 2*SpectacleUselessGap;
+ result.size.height -= 2*SpectacleUselessGap;
+
return result;
}
@@ -210,6 +225,11 @@
return [SpectacleCalculationResult resultWithAction: SpectacleWindowActionNextThird windowRect: twoThirdRect];
}
}
+
+ oneHalfRect.origin.x += SpectacleUselessGap;
+ oneHalfRect.origin.y += SpectacleUselessGap;
+ oneHalfRect.size.width -= 2*SpectacleUselessGap;
+ oneHalfRect.size.height -= 2*SpectacleUselessGap;
return [SpectacleCalculationResult resultWithAction: action windowRect: oneHalfRect];
}
@@ -251,6 +271,11 @@
}
}
+ oneHalfRect.origin.x += SpectacleUselessGap;
+ oneHalfRect.origin.y += SpectacleUselessGap;
+ oneHalfRect.size.width -= 2*SpectacleUselessGap;
+ oneHalfRect.size.height -= 2*SpectacleUselessGap;
+
return [SpectacleCalculationResult resultWithAction: action windowRect: oneHalfRect];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment