Add Commands for smaller/larger height only (#1607)
Some checks failed
Build / build (push) Has been cancelled

This commit is contained in:
Raz 2025-06-10 13:30:36 +08:00 committed by GitHub
parent 3f65edde13
commit 80e9330b14
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 8 deletions

View file

@ -94,13 +94,15 @@ enum WindowAction: Int, Codable {
halveWidthLeft = 78,
halveWidthRight = 79,
largerWidth = 80,
smallerWidth = 81
smallerWidth = 81,
largerHeight = 82,
smallerHeight = 83
// Order matters here - it's used in the menu
static let active = [leftHalf, rightHalf, centerHalf, topHalf, bottomHalf,
topLeft, topRight, bottomLeft, bottomRight,
firstThird, centerThird, lastThird, firstTwoThirds, lastTwoThirds,
maximize, almostMaximize, maximizeHeight, larger, smaller, largerWidth, smallerWidth,
maximize, almostMaximize, maximizeHeight, larger, smaller, largerWidth, smallerWidth, largerHeight, smallerHeight,
center, centerProminently, restore,
nextDisplay, previousDisplay,
moveLeft, moveRight, moveUp, moveDown,
@ -230,6 +232,8 @@ enum WindowAction: Int, Codable {
case .centerProminently: return "centerProminently"
case .largerWidth: return "largerWidth"
case .smallerWidth: return "smallerWidth"
case .largerHeight: return "largerHeight"
case .smallerHeight: return "smallerHeight"
}
}
@ -366,7 +370,7 @@ enum WindowAction: Int, Codable {
return nil
case .specified, .reverseAll, .tileAll, .cascadeAll, .leftTodo, .rightTodo, .cascadeActiveApp:
return nil
case .centerProminently, .largerWidth, .smallerWidth:
case .centerProminently, .largerWidth, .smallerWidth, .largerHeight, .smallerHeight:
return nil
}
@ -544,6 +548,8 @@ enum WindowAction: Int, Codable {
case .centerProminently: return NSImage()
case .largerWidth: return NSImage()
case .smallerWidth: return NSImage()
case .largerHeight: return NSImage()
case .smallerHeight: return NSImage()
}
}
@ -586,7 +592,7 @@ enum WindowAction: Int, Codable {
return Defaults.applyGapsToMaximize.userDisabled ? .none : .both;
case .maximizeHeight:
return Defaults.applyGapsToMaximizeHeight.userDisabled ? .none : .vertical;
case .almostMaximize, .previousDisplay, .nextDisplay, .larger, .smaller, .largerWidth, .smallerWidth, .center, .centerProminently, .restore, .specified, .reverseAll, .tileAll, .cascadeAll, .cascadeActiveApp:
case .almostMaximize, .previousDisplay, .nextDisplay, .larger, .smaller, .largerWidth, .smallerWidth, .largerHeight, .smallerHeight, .center, .centerProminently, .restore, .specified, .reverseAll, .tileAll, .cascadeAll, .cascadeActiveApp:
return .none
}
}

View file

@ -28,9 +28,9 @@ class ChangeSizeCalculation: WindowCalculation, ChangeWindowDimensionCalculation
let sizeOffset: CGFloat
switch params.action {
case .larger, .largerWidth:
case .larger, .largerWidth, .largerHeight:
sizeOffset = sizeOffsetAbs
case .smaller, .smallerWidth:
case .smaller, .smallerWidth, .smallerHeight:
sizeOffset = -sizeOffsetAbs
default:
sizeOffset = 0
@ -62,7 +62,7 @@ class ChangeSizeCalculation: WindowCalculation, ChangeWindowDimensionCalculation
// Calculate Height
if [.larger, .smaller].contains(params.action) {
if [.larger, .smaller, .largerHeight, .smallerHeight].contains(params.action) {
resizedWindowRect.size.height = resizedWindowRect.height + sizeOffset
resizedWindowRect.origin.y = resizedWindowRect.minY - floor(sizeOffset / 2.0)
@ -88,7 +88,7 @@ class ChangeSizeCalculation: WindowCalculation, ChangeWindowDimensionCalculation
resizedWindowRect.origin.y = params.window.rect.origin.y - floor(sizeOffset / 2.0)
}
if [.smaller, .smallerWidth].contains(params.action), resizedWindowRectIsTooSmall(windowRect: resizedWindowRect, visibleFrameOfScreen: visibleFrameOfScreen) {
if [.smaller, .smallerWidth, .smallerHeight].contains(params.action), resizedWindowRectIsTooSmall(windowRect: resizedWindowRect, visibleFrameOfScreen: visibleFrameOfScreen) {
resizedWindowRect = window.rect
}

View file

@ -195,6 +195,8 @@ class WindowCalculationFactory {
.smaller: changeSizeCalculation,
.largerWidth: changeSizeCalculation,
.smallerWidth: changeSizeCalculation,
.largerHeight: changeSizeCalculation,
.smallerHeight: changeSizeCalculation,
.bottomHalf: bottomHalfCalculation,
.topHalf: topHalfCalculation,
.center: centerCalculation,

View file

@ -24,6 +24,7 @@ The preferences window is purposefully slim, but there's a lot that can be modif
- [Make Smaller/Make Larger size increments](#make-smallermake-larger-size-increments)
- [Make Smaller/Make Larger "curtain resize" with gaps](#make-smallermake-larger-curtain-resize-with-gaps)
- [Make Smaller/Make Larger width only](#make-smallermake-larger-width-only)
- [Make Smaller/Make Larger height only](#make-smallermake-larger-height-only)
- [Disabling window restore when moving windows](#disabling-window-restore-when-moving-windows)
- [Changing the margin for the snap areas](#changing-the-margin-for-the-snap-areas)
- [Setting gaps at the screen edges](#setting-gaps-at-the-screen-edges)
@ -345,6 +346,17 @@ defaults write com.knollsoft.Rectangle largerWidth -dict-add keyCode -float 30 m
defaults write com.knollsoft.Rectangle smallerWidth -dict-add keyCode -float 33 modifierFlags -float 786432
```
## Make Smaller/Make Larger height only
Similarly, if you only want to change the window height without changing window width, configure shortcuts for the _largerHeight_ and _smallerHeight_ commands.
For example, if you want to assign `ctrl option shift ]` to _largerHeight_ and `ctrl option shift [` to _smallerHeight_, the commands would be:
```bash
defaults write com.knollsoft.Rectangle largerHeight -dict-add keyCode -float 30 modifierFlags -float 917504
defaults write com.knollsoft.Rectangle smallerHeight -dict-add keyCode -float 33 modifierFlags -float 917504
```
## Disabling window restore when moving windows
```bash