feat: Add will-resize event to TopLevelWindow (#13649)

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.
This commit is contained in:
Birunthan Mohanathas 2018-07-27 11:53:01 +02:00 committed by Cheng Zhao
parent 9af9634f7d
commit c8dc2d3730
8 changed files with 56 additions and 2 deletions

View file

@ -458,6 +458,12 @@ void NativeWindow::NotifyWindowRestore() {
observer.OnWindowRestore();
}
void NativeWindow::NotifyWindowWillResize(const gfx::Rect& new_bounds,
bool* prevent_default) {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowWillResize(new_bounds, prevent_default);
}
void NativeWindow::NotifyWindowResize() {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowResize();