feat: include resize edge with will-resize event (#29199)

* feat: emit resize edge with will-resize event

fix: wparam type

fix: private member usage on mac

docs: will-resize event edge option

refactor: 'info' -> 'details' for better type gen

* Update docs/api/browser-window.md

Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>

* Update docs/api/browser-window.md

Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
This commit is contained in:
Samuel Maddock 2021-06-01 22:37:10 -04:00 committed by GitHub
parent 750a762bf0
commit f9d2a7077e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 104 additions and 4 deletions

View file

@ -14,6 +14,7 @@
#include "ui/display/display.h"
#include "ui/display/win/screen_win.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/resize_utils.h"
#include "ui/views/widget/native_widget_private.h"
// Must be included after other Windows headers.
@ -137,6 +138,31 @@ const char* AppCommandToString(int command_id) {
}
}
// Copied from ui/views/win/hwnd_message_handler.cc
gfx::ResizeEdge GetWindowResizeEdge(WPARAM param) {
switch (param) {
case WMSZ_BOTTOM:
return gfx::ResizeEdge::kBottom;
case WMSZ_TOP:
return gfx::ResizeEdge::kTop;
case WMSZ_LEFT:
return gfx::ResizeEdge::kLeft;
case WMSZ_RIGHT:
return gfx::ResizeEdge::kRight;
case WMSZ_TOPLEFT:
return gfx::ResizeEdge::kTopLeft;
case WMSZ_TOPRIGHT:
return gfx::ResizeEdge::kTopRight;
case WMSZ_BOTTOMLEFT:
return gfx::ResizeEdge::kBottomLeft;
case WMSZ_BOTTOMRIGHT:
return gfx::ResizeEdge::kBottomRight;
default:
NOTREACHED();
return gfx::ResizeEdge::kBottomRight;
}
}
bool IsScreenReaderActive() {
UINT screenReader = 0;
SystemParametersInfo(SPI_GETSCREENREADER, 0, &screenReader, 0);
@ -263,7 +289,8 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
gfx::Rect bounds = gfx::Rect(*reinterpret_cast<RECT*>(l_param));
HWND hwnd = GetAcceleratedWidget();
gfx::Rect dpi_bounds = ScreenToDIPRect(hwnd, bounds);
NotifyWindowWillResize(dpi_bounds, &prevent_default);
NotifyWindowWillResize(dpi_bounds, GetWindowResizeEdge(w_param),
&prevent_default);
if (prevent_default) {
::GetWindowRect(hwnd, reinterpret_cast<RECT*>(l_param));
return true; // Tells Windows that the Sizing is handled.