-
Notifications
You must be signed in to change notification settings - Fork 16.2k
feat: Add will-resize event to TopLevelWindow #13649
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
a8d2d55
to
a91e6e4
Compare
d097aab
to
651f4ab
Compare
@zcbenz Could you review this? If you want to test this, I used:
|
Capturing what I talked with @poiru about on Slack, I think this API should support this feature on Linux too. |
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.
Need a minor change, other parts look good to me.
@@ -194,6 +194,18 @@ void TopLevelWindow::OnWindowRestore() { | |||
Emit("restore"); | |||
} | |||
|
|||
void HandleWillResizeCallback(gfx::Rect* new_bounds, | |||
gfx::Rect overridden_bounds) { |
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.
Should use const gfx::Rect&
The new `will-resize` event can be used to prevent the resize from happening before the native window is actually resized. This is in contrast to the existing the `resize` event, which is sent *after* the native window has already been resized. For apps with e.g. custom window snapping logic, the `resize` event is not sufficient because it will result in flickering between the dragged size and the snapped size. `will-resize` is only emitted on macOS and Windows.
The new
will-resize
event can be used to prevent the resize fromhappening before the native window is actually resized. This is in
contrast to the existing the
resize
event, which is sent after thenative window has already been resized. For apps with e.g. custom window
snapping logic, the
resize
event is not sufficient because it willresult in flickering between the dragged size and the snapped size.
will-resize
is only emitted on macOS and Windows. It may bepossible to implement for Linux/X11 as well.
Unfortunately it is not possible to test this because the event is only
emitted when the window is being resized manually. Resizing the window
with
setBounds
/setSize
will not emit this event.