Restore the window position of the Inspector when it’s first opened.

This commit is contained in:
Brent Simmons 2018-01-21 13:36:02 -08:00
parent 8a2973de36
commit 03af72bf2d
1 changed files with 15 additions and 1 deletions

View File

@ -74,7 +74,12 @@ final class InspectorWindowController: NSWindowController {
inspectors = [feedInspector, folderInspector, builtinSmartFeedInspector, nothingInspector] inspectors = [feedInspector, folderInspector, builtinSmartFeedInspector, nothingInspector]
currentInspector = nothingInspector currentInspector = nothingInspector
window?.flippedOrigin = NSPoint(x: 256, y: 256) if let savedOrigin = originFromDefaults() {
window?.setFlippedOriginAdjustingForScreen(savedOrigin)
}
else {
window?.flippedOrigin = NSPoint(x: 256, y: 256)
}
} }
func inspector(for objects: [Any]?) -> InspectorViewController { func inspector(for objects: [Any]?) -> InspectorViewController {
@ -121,4 +126,13 @@ private extension InspectorWindowController {
window.setFlippedOriginAdjustingForScreen(flippedOrigin) window.setFlippedOriginAdjustingForScreen(flippedOrigin)
} }
} }
func originFromDefaults() -> NSPoint? {
guard let originString = UserDefaults.standard.string(forKey: DefaultsKey.windowOrigin) else {
return nil
}
let point = NSPointFromString(originString)
return point == NSPoint.zero ? nil : point
}
} }