Skip to content

Commit

Permalink
Add separate gap for notched display
Browse files Browse the repository at this point in the history
  • Loading branch information
Tmate6 committed May 9, 2024
1 parent 62880cc commit 2328623
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Rectangle/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Defaults {
static let screenEdgeGapLeft = FloatDefault(key: "screenEdgeGapLeft", defaultValue: 0)
static let screenEdgeGapRight = FloatDefault(key: "screenEdgeGapRight", defaultValue: 0)
static let screenEdgeGapsOnMainScreenOnly = BoolDefault(key: "screenEdgeGapsOnMainScreenOnly")
static let screenEdgeGapTopNotch = FloatDefault(key: "screenEdgeGapTopNotch", defaultValue: 0)
static let lastVersion = StringDefault(key: "lastVersion")
static let showAllActionsInMenu = OptionalBoolDefault(key: "showAllActionsInMenu")
static var SUHasLaunchedBefore: Bool { UserDefaults.standard.bool(forKey: "SUHasLaunchedBefore") }
Expand Down Expand Up @@ -118,6 +119,7 @@ class Defaults {
screenEdgeGapLeft,
screenEdgeGapRight,
screenEdgeGapsOnMainScreenOnly,
screenEdgeGapTopNotch,
showAllActionsInMenu,
footprintAlpha,
footprintBorderWidth,
Expand Down
14 changes: 12 additions & 2 deletions Rectangle/ScreenDetection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,18 @@ extension NSScreen {
newFrame.origin.x += Defaults.screenEdgeGapLeft.cgFloat
newFrame.origin.y += Defaults.screenEdgeGapBottom.cgFloat
newFrame.size.width -= (Defaults.screenEdgeGapLeft.cgFloat + Defaults.screenEdgeGapRight.cgFloat)
newFrame.size.height -= (Defaults.screenEdgeGapTop.cgFloat + Defaults.screenEdgeGapBottom.cgFloat)


if #available(macOS 12.0, *) {
if self.safeAreaInsets.top > 0, Defaults.screenEdgeGapTopNotch.value != 0 {
newFrame.size.height -= (Defaults.screenEdgeGapTopNotch.cgFloat + Defaults.screenEdgeGapBottom.cgFloat)
} else {
newFrame.size.height -= (Defaults.screenEdgeGapTop.cgFloat + Defaults.screenEdgeGapBottom.cgFloat)
}

} else {
newFrame.size.height -= (Defaults.screenEdgeGapTop.cgFloat + Defaults.screenEdgeGapBottom.cgFloat)
}

return newFrame
}

Expand Down
6 changes: 6 additions & 0 deletions TerminalCommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,12 @@ defaults write com.knollsoft.Rectangle screenEdgeGapLeft -int 10
defaults write com.knollsoft.Rectangle screenEdgeGapRight -int 10
```

You can also seperately specify the gap for a screen with a notch. Useful for multi display setups if you are using a menubar replacement.

```bash
defaults write com.knollsoft.Rectangle screenEdgeGapTopNotch -int 5
```

If you want these gaps to be applied on your main screen only you can set screenEdgeGapsOnMainScreenOnly. Useful for multi display setups where only one screen has some dock replacement.

```bash
Expand Down

0 comments on commit 2328623

Please sign in to comment.