Closed Mortennn closed 5 years ago
@Mortennn Any thoughts on this approach vs https://github.com/sindresorhus/touch-bar-simulator/blob/23f7c1ca46a99afa532253564c006c03e1448c1f/Touch%20Bar%20Simulator/TouchBarWindow.swift#L121-L125 ?
I've change the code according to your approach.
setFrameOrigin(CGPoint(x: frame.origin.x, y: 100))
In my opinion, it is better to calculate the coordinates based on the screen the preferences window is located on than relying on a hard-coded value for the y-axis in case anything changes later on.
In my tests, this worked great! Thanks @Mortennn
Does this work still work under macOS 11? It's not restoring to the position I drag it to on next launch.
Should this be using NSWindowRestoration
instead of the frame autosave name?
I just tried the bundled example app on macOS 11.5.2 and it correctly preserves its position between launches.
Should this be using NSWindowRestoration instead of the frame autosave name?
It's not clear to me which of these solutions that are the most correct solution.
Maybe try switching the order of these to ensure it's not some kind of race issue: https://github.com/sindresorhus/Preferences/blob/main/Sources/Preferences/PreferencesWindowController.swift#L98-L99
I have modified @DivineDominion's code a bit to get centering and restoring the preferences window to work.
showWindow()
.window.center()
does not work. I don't know why.