Position the window on first-run exactly once. Opening a second window should not place it in the same position as the first.

This commit is contained in:
Brent Simmons 2017-12-21 14:47:12 -08:00
parent a4c82739b6
commit 9c249ef6b2
1 changed files with 5 additions and 1 deletions

View File

@ -25,6 +25,8 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
} }
} }
static var didPositionWindowOnFirstRun = false
override func windowDidLoad() { override func windowDidLoad() {
super.windowDidLoad() super.windowDidLoad()
@ -34,7 +36,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
} }
window?.setFrameUsingName(windowAutosaveName, force: true) window?.setFrameUsingName(windowAutosaveName, force: true)
if AppDefaults.shared.isFirstRun { if AppDefaults.shared.isFirstRun && !MainWindowController.didPositionWindowOnFirstRun {
if let window = window, let screen = window.screen { if let window = window, let screen = window.screen {
let width: CGFloat = 1280.0 let width: CGFloat = 1280.0
@ -44,6 +46,8 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
window.setContentSize(NSSize(width: width, height: height)) window.setContentSize(NSSize(width: width, height: height))
window.setFrameTopLeftPoint(NSPoint(x: insetX, y: screen.visibleFrame.maxY - insetY)) window.setFrameTopLeftPoint(NSPoint(x: insetX, y: screen.visibleFrame.maxY - insetY))
MainWindowController.didPositionWindowOnFirstRun = true
} }
} }