-
Notifications
You must be signed in to change notification settings - Fork 16.5k
feat: add 'resized' and 'moved' events to BrowserWindow #26216
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
Conversation
|
||
Emitted once when the window is moved to a new position. | ||
|
||
__Note__: On macOS this event is an alias of `move`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the Note into 'moved' since now the behavior only differs on this event. On Windows, 'moved' will only emit after the user has stopped moving the window. On macOS, it will always emit along with 'move'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After moving the note, it reads to me like this: the moved
event is not really implemented on macOS, it is just an alias of move
event. But I think the actual behavior is reverse?
The original note was confusing too, so I think maybe we should clearly describe the behavior in the note.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's how I see it as well. You had left a comment mentioning needing to figure out a proper way to dispatch move.
electron/shell/browser/ui/cocoa/electron_ns_window_delegate.mm
Lines 171 to 177 in d3f32c7
- (void)windowDidMove:(NSNotification*)notification { | |
[super windowDidMove:notification]; | |
// TODO(zcbenz): Remove the alias after figuring out a proper | |
// way to dispatch move. | |
shell_->NotifyWindowMove(); | |
shell_->NotifyWindowMoved(); | |
} |
For me, I assume move
should follow similar behavior to how mousemove
works. It should be emitted at each change of the position of the window.
moved
should be emitted after moving is finished and should follow after the last move
event. However, macOS doesn't have this behavior and will instead always emit after move
.
Does this make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah you are right.
I thought windowDidMove
would emit when moving is finished, but after testing I found it actually keeps emitting during the moving. So moving the note does make the doc more clear 👍 .
Also adds 'moved' event to BrowserWindow on Windows.
2f0a708
to
6782327
Compare
@samuelmaddock Can you update the PR title / release notes to include a reference to the addition of the "moved" event on Windows |
The releases WG approved this PR for backport to 10-x-y and 11-x-y at the Oct 28, 2020 meeting |
@MarshallOfSound I tried my best 😅 |
The API WG approved this PR at our Nov 9, 2020 meeting. |
Release Notes Persisted
|
I was unable to backport this PR to "10-x-y" cleanly; |
I have automatically backported this PR to "11-x-y", please check out #26454 |
@jkleinsc @codebytere Hi, will this PR not be included in version 10? |
@electron/wg-api
@electron/wg-releases I'd like to target 10-x-y if possible.
Description of Change
Emits a
resized
event after the user has finished manually resizing a window.Similarly, a
moved
event now emits on Windows when the window has finished being moved.I'm not quite sure whether it's possible to test this manual method of resizing the window. For now, I've added tests for macOS' animated resizing.
resolves #24934
Checklist
npm test
passesRelease Notes
Notes: Added 'resized' (Windows/macOS) and 'moved' (Windows) events to BrowserWindow.