You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remember Desktop No. on app restart in macOS #15211
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.
This is something apps can implement (by saving window location on quit and restoring on start)
How certain of this are you? If you're certain that it's something apps can implement themselves, then do you have any pointers for enabling this?
My understanding is that it requires implementation at the NSWindow level. From the Mac App Programming Guide:
You must do the following to preserve the state of your user interface:
For each window, you must set whether the window should be preserved using the setRestorable: method.
For each preserved window, you must specify an object whose job is to re-create that window at launch time.
Any objects involved in your user interface must write out the data they require to restore their state later.
At launch time, you must use the provided data to restore your objects to their previous state.
I haven't done any development with Electron myself - I've just used many Electron apps over the years and had to deal with Space reassignment after every app update/restart and would rejoice at no longer having to do that. That said, it sounds as though the main Electron user facing API would be too high level to allow app developers to hook in and implement this on their own without modifying Electron source code.
Do you know of an Electron-based app that has successfully implemented this?
@MarshallOfSound I dug a bit more into this and my guess is that you're equating this issue with the concept of "Saving and Restoring Window State" as expressed in solutions provided in #526 (using win.setBounds). Unfortunately, "Desktop Number" (or, in macOS parlance, "Spaces") cannot be addressed in this manner: Apple does not provide APIs for assigning windows to particular Spaces so it isn't something that Electron could even provide an API for anyway.
Apple expects Spaces to work as follows:
Space Assignment: User moves a window directly to a target Space within the macOS UI. There are a number of ways to do this.
Space Restoration: On computer restart (and, apparently, on forced app restart?), Apple requests that NSWindow instances save their state on shutdown and then restore that state on startup.
As "simple" as that. Indeed, that second item is exactly what the changelist I linked in my previous comment implements.
Unfortunately, this isn't something that applications built on top of Electron can handle without modifying Electron's source code.
Activity
welcome commentedon Oct 17, 2018
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.
MarshallOfSound commentedon Oct 17, 2018
This is something apps can implement (by saving window location on quit and restoring on start)
ericdrobinson commentedon Mar 3, 2023
@MarshallOfSound With respect to this:
How certain of this are you? If you're certain that it's something apps can implement themselves, then do you have any pointers for enabling this?
My understanding is that it requires implementation at the
NSWindowlevel. From the Mac App Programming Guide:I haven't done any development with Electron myself - I've just used many Electron apps over the years and had to deal with Space reassignment after every app update/restart and would rejoice at no longer having to do that. That said, it sounds as though the main Electron user facing API would be too high level to allow app developers to hook in and implement this on their own without modifying Electron source code.
Do you know of an Electron-based app that has successfully implemented this?
Additionally, the best resource I've found for how Google implemented this to be in this initial changelist (found in this comment).
ericdrobinson commentedon Mar 4, 2023
@MarshallOfSound I dug a bit more into this and my guess is that you're equating this issue with the concept of "Saving and Restoring Window State" as expressed in solutions provided in #526 (using
win.setBounds). Unfortunately, "Desktop Number" (or, in macOS parlance, "Spaces") cannot be addressed in this manner: Apple does not provide APIs for assigning windows to particular Spaces so it isn't something that Electron could even provide an API for anyway.Apple expects Spaces to work as follows:
NSWindowinstances save their state on shutdown and then restore that state on startup.As "simple" as that. Indeed, that second item is exactly what the changelist I linked in my previous comment implements.
Unfortunately, this isn't something that applications built on top of Electron can handle without modifying Electron's source code.