Window snapping on Windows does not persist the window position/size after hide/show
Preflight Checklist
- [x] I have read the Contributing Guidelines for this project.
- [x] I agree to follow the Code of Conduct that this project adheres to.
- [x] I have searched the issue tracker for an issue that matches the one I want to file, without success.
Issue Details
-
Electron Version:
9.3.x - Operating System: Windows 10 & Windows 7
- Last Known Working Electron version: Never to my knowledge
Expected Behavior
Hiding/showing a window that's snapped to a screen edge should not affect the window's position/size.
Actual Behavior
Showing a window after hiding restores the window position/size to the settings from prior to the window snapping.
To Reproduce
I saw this issue #1304, but it's very old. If it's still relevant, I don't understand why restoring the window to the same coordinates isn't possible, since the Electron window is aware of its coordinate and size, and only loses them upon calling show().
@sofianguy @zcbenz is there any way this can be achieved? It's really all but impossible to work around and I don't know why the behavior is what it is?
I understand there's a special "Aero Snap" state, but that shouldn't make it impossible for developers to restore their application window to its last location.
In our app the user uses a global hotkey to bring it up in its last location. The last location after an Aero Snap though, is not the actual location of the window - but its last non-snapped location - even though the BrowserWindow reports the correct coordinates right before we call win.show()
That means a user can never use a global hotkey to make the app appear in the snapped position - it always reverts itself. We've gotten a number of complaints about this and tried hard to find a workaround. Can anyone comment on why things can't work this way? The current behavior is very strange and unexpected both for developers and end users.

Anybody?
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
Still repros in Electron 21. Updated gist
This one really drives me nuts!
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
Not stale. I really think this should be addressed. Otherwise showing the window with a global hotkey while it's Aero-Snapped will reset the window to its previous position, or some new position which may be partially off the screen.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
repros in v24
+1 on this
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
Not stale.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
Not stale.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
Not stale.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
Not stale.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
Not stale.
@MarshallOfSound I wonder if you might be willing to comment on this issue?
It makes global hotkey apps feel a lot less polished, among other things.
Friendly bump. It would be great if this could be supported.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
Bump. Would really love to see this addressed.
Still repros in Electron 28.
Repros in 34 too.
@codebytere sorry to ping - I just wonder if this might ever be addressed?
This really makes it hard to make the app feel native because Windows continues to place more and more emphasis on its snapping system. It's a big problem when users expect the global hotkey to bring an app back up to where they left it and it doesn't and can't behave as they expect no matter how they try.
@Nantris i think i figured out a solution here actually, after reviewing it for a bit - will let you know soon :)
@Nantris i submitted a CL upstream: https://chromium-review.googlesource.com/c/chromium/src/+/6330848 that should address this! Once it's accepted I'll open some backports to Electron.
Thank you so much @codebytere!