Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to apply gaps to the main screen only #798

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Rectangle/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Defaults {
static let screenEdgeGapBottom = FloatDefault(key: "screenEdgeGapBottom", defaultValue: 0)
static let screenEdgeGapLeft = FloatDefault(key: "screenEdgeGapLeft", defaultValue: 0)
static let screenEdgeGapRight = FloatDefault(key: "screenEdgeGapRight", defaultValue: 0)
static let screenEdgeGapsOnMainScreenOnly = BoolDefault(key: "screenEdgeGapsOnMainScreenOnly")
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 @@ -97,6 +98,7 @@ class Defaults {
screenEdgeGapBottom,
screenEdgeGapLeft,
screenEdgeGapRight,
screenEdgeGapsOnMainScreenOnly,
showAllActionsInMenu,
footprintAlpha,
footprintBorderWidth,
Expand Down
14 changes: 10 additions & 4 deletions Rectangle/ScreenDetection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ struct AdjacentScreens {
extension NSScreen {
var adjustedVisibleFrame: CGRect {
get {
let topGap = CGFloat(Defaults.screenEdgeGapTop.value)
let bottomGap = CGFloat(Defaults.screenEdgeGapBottom.value)
let leftGap = CGFloat(Defaults.screenEdgeGapLeft.value)
var rightGap = CGFloat(Defaults.screenEdgeGapRight.value)
let topGap = CGFloat(Defaults.screenEdgeGapsOnMainScreenOnly.enabled && isMainDisplay ? Defaults.screenEdgeGapTop.value : 0)
let bottomGap = CGFloat(Defaults.screenEdgeGapsOnMainScreenOnly.enabled && isMainDisplay ? Defaults.screenEdgeGapBottom.value : 0)
let leftGap = CGFloat(Defaults.screenEdgeGapsOnMainScreenOnly.enabled && isMainDisplay ? Defaults.screenEdgeGapLeft.value : 0)
var rightGap = CGFloat(Defaults.screenEdgeGapsOnMainScreenOnly.enabled && isMainDisplay ? Defaults.screenEdgeGapRight.value : 0)

if Defaults.todo.userEnabled, Defaults.todoMode.enabled, TodoManager.todoScreen == self {
rightGap += CGFloat(Defaults.todoSidebarWidth.value)
Expand All @@ -150,6 +150,12 @@ extension NSScreen {
return CGRect(origin: origin, size: size)
}
}
var displayID: CGDirectDisplayID {
return deviceDescription[NSDeviceDescriptionKey(rawValue: "NSScreenNumber")] as? CGDirectDisplayID ?? 0
}
var isMainDisplay: Bool {
return displayID == CGMainDisplayID()
}
}

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

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
defaults write com.knollsoft.Rectangle screenEdgeGapsOnMainScreenOnly -bool true
```

## Ignore specific drag to snap areas

Each drag to snap area on the edge of a screen can be ignored with a single Terminal command, but it's a bit field setting so you'll have to determine the bit field for which ones you want to disable.
Expand Down