New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request]: Enable Application Window Restoration #37494
Comments
Hey @ericdrobinson , |
My proposed solution is to add a new option in Electron's API which allows the developers to specify that they want the windows of their application to be restored on next start. This option should handle window Virtual Desktop/Space reassignment. To implement this, we will need to add new APIs to allow applications to "rehydrate" the restored windows with serialized application state. We will also need to modify the codebase to tap into Chromium's window restoration capabilities, which are already implemented in Chromium for both Windows and macOS. By leveraging Chromium's existing implementation, we can ensure that our solution is robust and reliable. Additionally, by adding this new feature to Electron's API, we can make it easy for developers to implement session restoration with Virtual Desktop / Space assignments in their applications. |
@coderdeadpool Are you planning on doing the legwork to develop out a solution to this issue? Or was your goal rather to outline a proposal and leave it at that? I fear that it may be a bit ambiguous and I want to make sure that the status is clear for anyone encountering this issue (especially maintainers). |
I'd love to be proven wrong, but I think @ShivamPandey00 has abandoned any effort to implement this. While that account does have an Electron Repo fork, there doesn't appear to be any work done to it ( |
@codebytere Any chance that this feature request could get some attention? No Electron-based application can properly hook into Virtual Desktop/Spaces settings/assignments unless it's supported within Electron itself 😕 |
I didn’t see it mentioned, so: on Linux distributions, at least GNOME has a virtual desktop feature available (called “workspaces”). I would like to see the restoration also supported there. |
Preflight Checklist
Problem Description
Electron based applications fail to restore their windows to their user-assigned Virtual Desktop [Windows 10/11] or Space [macOS].
Unfortunately, this isn't something that Electron users can address in their application implementations. This is due to the fact that OS APIs do not [universally] exist to enable such direct management:
VirtualDesktopManager
which supports a very limited set of APIs (so limited, in fact, that there does not appear to be a way to enumerate the user's current set of available Desktops).NSWindow
state will be saved on application shutdown/restored on application startup".(I haven't looked into Linux window manager APIs...)
Regardless, Microsoft and Apple provide enough APIs for applications to save and restore their "Virtual Desktop"/"Space" assignment on application restart. While Microsoft's APIs appear to be usable at any point in the application's life cycle, Apple's APIs are very much tied to the implementation of the
NSWindow
.Electron's upstream Chromium does properly support session restoration with Virtual Desktop / Space assignments for its windows. The bugs that tracked these features are as follows:
The implementations of these features can be seen in the following change lists:
These are clearly implemented in drastically different ways. The macOS implementation is most directly (and clearly) tied to Chromium's concept of "session restoration".
Current versions of Electron do not provide any ability to tap into Chromium's window restoration capabilities (or provide their own mechanism). Applications currently have to rely on APIs provided by the
BrowserWindow
class and that class does not (and cannot) provide the APIs necessary to support this feature.Proposed Solution
I would like Electron to provide an option wherein an Electron application developer can specify that they would like the windows of an application to be restored on next start. This option should handle window Virtual Desktop/Space reassignment. I expect that APIs may be necessary to enable applications to "rehydrate" the restored windows with serialized application state.
Unfortunately, my personal experience with Electron application session restoration is insufficient to propose anything more than the high level ask above. Perhaps @bpasero might chime in - he seems like someone who may be sufficiently steeped in the complexities of window/state restoration to be able to suggest a solution or improved list of requirements for a solution.
Alternatives Considered
The alternatives considered are as follows:
BrowserWindow
APIs. The APIs do not provide any way to control Virtual Desktop/Space assignment.These approaches are both at the level of "we can pass this off to Electron application developers". Unfortunately, due to the nature of how Virtual Desktop/Space systems work this needs to be something that is handled internally.
Additional Information
I should also explain that there are several scenarios that end users expect this feature:
Notably, Apple only explains that they support restoration when the computer restarts and applications are reopened. The other two scenarios aren't officially handled. That said, the Chromium developers were able to identify an approach that enables Chromium itself to restart (e.g. during an update) and restore windows to their previously assigned Spaces. This feature mostly works when quitting/starting Chrome normally (case 3 above), though this may require setting a custom preference.
It appears that the Windows APIs also operate on a "best effort" basis wherein if the ID of the Virtual Desktop targeted for restoration doesn't exist anymore, the window is moved instead to the active Virtual Desktop.
Related issues:
The text was updated successfully, but these errors were encountered: