Skip to content

Commit

Permalink
Save window position on move (#1719)
Browse files Browse the repository at this point in the history
  • Loading branch information
1024jp committed Oct 15, 2024
1 parent eac2d84 commit b0c6050
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
5.0.4 (unreleased)
--------------------------

### Fixes

- Fix an issue that the document window position was not saved in some cases.



5.0.3 (682)
Expand Down
20 changes: 17 additions & 3 deletions CotEditor/Sources/Document Window/DocumentWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,13 @@ final class DocumentWindowController: NSWindowController, NSWindowDelegate {

func windowDidResize(_ notification: Notification) {

guard self.isWindowLoaded, let window = self.window else { return }
self.saveWindowFrame()
}


func windowDidMove(_ notification: Notification) {

// workaround issue that window frame is not saved automatically (2022-08 macOS 12.5, FB11082729)
window.saveFrame(usingName: self.windowAutosaveName)
self.saveWindowFrame()
}


Expand Down Expand Up @@ -287,6 +290,17 @@ final class DocumentWindowController: NSWindowController, NSWindowDelegate {
}


/// Saves the current window frame.
///
/// Workaround the issue that window frame is not saved automatically.
private func saveWindowFrame() {

assert(self.isWindowLoaded)

self.window?.saveFrame(usingName: self.windowAutosaveName)
}


/// Restores the window opacity.
private func restoreWindowOpacity() {

Expand Down

0 comments on commit b0c6050

Please sign in to comment.