Skip to content

Commit

Permalink
Maximize number of desktops shown in popup window
Browse files Browse the repository at this point in the history
  • Loading branch information
dado3212 committed Sep 23, 2020
1 parent 838f61d commit 5e913d6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions SpacesRenamer/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class ViewController: NSViewController {

var monitorPairings: [[NSScrollView: [DesktopSnippet]]] = []

let widthInDesktops = 6
var widthInDesktops = 6
let desktopWidth = 140.0

override func viewDidLoad() {
super.viewDidLoad()
Expand Down Expand Up @@ -63,6 +64,14 @@ class ViewController: NSViewController {

// Get the # of spaces in the maximum monitor
let maxSpacesPerMonitor = allMonitors.reduce(Int.min, { max($0, (($1 as? NSDictionary)?.value(forKey: "Spaces") as! NSArray).count) })


guard let mainScreen = NSScreen.main else {
fatalError("Bugged")
}
// Maximize the number of desktops
let screenWidth = Double(mainScreen.visibleFrame.width)
widthInDesktops = Int(screenWidth / desktopWidth) - 1

// For each monitor
for j in 1...allMonitors.count {
Expand Down Expand Up @@ -202,7 +211,7 @@ class ViewController: NSViewController {
maxSpacesPerMonitor == 1 ? 2 : 1, // minimum width of two spaces so the buttons render correctly
allSpaces.count
))
) * 140.0 + 10.0
) * desktopWidth + 10.0
))
constraints.append(widthConstraint)
self.view.addConstraints([widthConstraint])
Expand Down

0 comments on commit 5e913d6

Please sign in to comment.