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:
parent
9af9634f7d
commit
c8dc2d3730
8 changed files with 56 additions and 2 deletions
|
@ -187,6 +187,16 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
|
|||
if (HIWORD(w_param) == THBN_CLICKED)
|
||||
return taskbar_host_.HandleThumbarButtonEvent(LOWORD(w_param));
|
||||
return false;
|
||||
case WM_SIZING: {
|
||||
bool prevent_default = false;
|
||||
NotifyWindowWillResize(gfx::Rect(*reinterpret_cast<RECT*>(l_param)),
|
||||
&prevent_default);
|
||||
if (prevent_default) {
|
||||
::GetWindowRect(GetAcceleratedWidget(),
|
||||
reinterpret_cast<RECT*>(l_param));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case WM_SIZE: {
|
||||
// Handle window state change.
|
||||
HandleSizeEvent(w_param, l_param);
|
||||
|
@ -198,7 +208,8 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
|
|||
}
|
||||
case WM_MOVING: {
|
||||
if (!movable_)
|
||||
::GetWindowRect(GetAcceleratedWidget(), (LPRECT)l_param);
|
||||
::GetWindowRect(GetAcceleratedWidget(),
|
||||
reinterpret_cast<RECT*>(l_param));
|
||||
return false;
|
||||
}
|
||||
case WM_MOVE: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue