Skip to content

Commit

Permalink
Merge pull request #1387 from Tmate6/main
Browse files Browse the repository at this point in the history
Add separate gap for notched display
  • Loading branch information
rxhanson authored May 10, 2024
2 parents 62880cc + 54d73b3 commit f4a40d0
Show file tree
Hide file tree
Showing 3 changed files with 15 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
9 changes: 7 additions & 2 deletions Rectangle/ScreenDetection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,13 @@ 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, *), 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)
}

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 f4a40d0

Please sign in to comment.