Skip to content

Commit 19ea0d6

Browse files
committed
Refactor DocumentWindowController initializer
1 parent 58f03f9 commit 19ea0d6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

CotEditor/Sources/Document Window/DocumentWindowController.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ final class DocumentWindowController: NSWindowController, NSWindowDelegate {
9797
// if multiple window instances have the same name (2024-10, macOS 15).
9898
self.windowAutosaveName = self.isDirectoryDocument ? "DirectoryDocument": "Document"
9999

100-
let window = DocumentWindow(contentViewController: WindowContentViewController(document: document, directoryDocument: directoryDocument))
100+
let viewController = WindowContentViewController(document: document, directoryDocument: directoryDocument)
101+
let window = DocumentWindow(contentViewController: viewController)
101102
window.styleMask.update(with: .fullSizeContentView)
102103
window.animationBehavior = .documentWindow
103104
window.setFrameAutosaveName(self.windowAutosaveName)
@@ -106,14 +107,16 @@ final class DocumentWindowController: NSWindowController, NSWindowDelegate {
106107
window.tabbingMode = .disallowed
107108
}
108109

109-
// set window frame
110+
// set window size
110111
let width = UserDefaults.standard[.windowWidth] ?? 0
111112
let height = UserDefaults.standard[.windowHeight] ?? 0
112113
if width > 0 || height > 0 {
113114
let frameSize = NSSize(width: width > window.minSize.width ? width : window.frame.width,
114115
height: height > window.minSize.height ? height : window.frame.height)
115116
window.setFrame(NSRect(origin: window.frame.origin, size: frameSize), display: false)
116117
}
118+
119+
// cascade window position
117120
if let mainWindow = NSApp.mainWindow {
118121
let frame = if #available(macOS 15, *) {
119122
mainWindow.cascadingReferenceFrame

0 commit comments

Comments
 (0)