Commit 0d98fb2d authored by mohsen@chromium.org's avatar mohsen@chromium.org

Update window region after widget resizes not changing HWND size

When width or height of a widget is changed to a value less than 64
pixels, it is rounded up to 64 pixels (see crbug.com/286609). This might
cause the actual HWND size remain the same while changing size of the
widget. In this case, we need to force message handler to update window
region since we are not receiving resize messages form the OS.

BUG=376329

Review URL: https://codereview.chromium.org/300163002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273081 0039d316-1c4b-4281-b951-d872f2087c98
parent 3fc652e6
...@@ -486,12 +486,7 @@ void DesktopWindowTreeHostWin::SetBounds(const gfx::Rect& bounds) { ...@@ -486,12 +486,7 @@ void DesktopWindowTreeHostWin::SetBounds(const gfx::Rect& bounds) {
window_enlargement_ = window_enlargement_ =
gfx::Vector2d(new_expanded.width() - expanded.width(), gfx::Vector2d(new_expanded.width() - expanded.width(),
new_expanded.height() - expanded.height()); new_expanded.height() - expanded.height());
message_handler_->SetBounds(new_expanded); message_handler_->SetBounds(new_expanded, old_content_size != bounds.size());
// The client area size may have changed even though the window bounds have
// not, if the window bounds were expanded to 64 pixels both times.
if (old_hwnd_size == new_expanded.size() && old_content_size != bounds.size())
HandleClientSizeChanged(new_expanded.size());
} }
gfx::Point DesktopWindowTreeHostWin::GetLocationOnNativeScreen() const { gfx::Point DesktopWindowTreeHostWin::GetLocationOnNativeScreen() const {
......
...@@ -525,13 +525,24 @@ void HWNDMessageHandler::GetWindowPlacement( ...@@ -525,13 +525,24 @@ void HWNDMessageHandler::GetWindowPlacement(
} }
} }
void HWNDMessageHandler::SetBounds(const gfx::Rect& bounds_in_pixels) { void HWNDMessageHandler::SetBounds(const gfx::Rect& bounds_in_pixels,
bool force_size_changed) {
LONG style = GetWindowLong(hwnd(), GWL_STYLE); LONG style = GetWindowLong(hwnd(), GWL_STYLE);
if (style & WS_MAXIMIZE) if (style & WS_MAXIMIZE)
SetWindowLong(hwnd(), GWL_STYLE, style & ~WS_MAXIMIZE); SetWindowLong(hwnd(), GWL_STYLE, style & ~WS_MAXIMIZE);
gfx::Size old_size = GetClientAreaBounds().size();
SetWindowPos(hwnd(), NULL, bounds_in_pixels.x(), bounds_in_pixels.y(), SetWindowPos(hwnd(), NULL, bounds_in_pixels.x(), bounds_in_pixels.y(),
bounds_in_pixels.width(), bounds_in_pixels.height(), bounds_in_pixels.width(), bounds_in_pixels.height(),
SWP_NOACTIVATE | SWP_NOZORDER); SWP_NOACTIVATE | SWP_NOZORDER);
// If HWND size is not changed, we will not receive standard size change
// notifications. If |force_size_changed| is |true|, we should pretend size is
// changed.
if (old_size == bounds_in_pixels.size() && force_size_changed) {
delegate_->HandleClientSizeChanged(GetClientAreaBounds().size());
ResetWindowRegion(false, true);
}
} }
void HWNDMessageHandler::SetSize(const gfx::Size& size) { void HWNDMessageHandler::SetSize(const gfx::Size& size) {
......
...@@ -132,7 +132,10 @@ class VIEWS_EXPORT HWNDMessageHandler : ...@@ -132,7 +132,10 @@ class VIEWS_EXPORT HWNDMessageHandler :
void GetWindowPlacement(gfx::Rect* bounds, void GetWindowPlacement(gfx::Rect* bounds,
ui::WindowShowState* show_state) const; ui::WindowShowState* show_state) const;
void SetBounds(const gfx::Rect& bounds_in_pixels); // Sets the bounds of the HWND to |bounds_in_pixels|. If the HWND size is not
// changed, |force_size_changed| determines if we should pretend it is.
void SetBounds(const gfx::Rect& bounds_in_pixels, bool force_size_changed);
void SetSize(const gfx::Size& size); void SetSize(const gfx::Size& size);
void CenterWindow(const gfx::Size& size); void CenterWindow(const gfx::Size& size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment