Commit 9f185605 authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Refactored GetWidgetOrigin() and repalced with GetWidgetBounds()

The geometry in client controlled uses only for client area, while it is
for the entire widget for other cases. This allows each case to implement
their own logic to compute the widget bounds.

Bug: b/33693796
Test: no functional change.
Change-Id: Ie9bb5272d4c4cbf2b86f8f428a3fa8c774490d67
Reviewed-on: https://chromium-review.googlesource.com/990072
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547518}
parent f1ca26a8
...@@ -750,15 +750,20 @@ bool ClientControlledShellSurface::OnMouseDragged(const ui::MouseEvent&) { ...@@ -750,15 +750,20 @@ bool ClientControlledShellSurface::OnMouseDragged(const ui::MouseEvent&) {
return false; return false;
} }
gfx::Point ClientControlledShellSurface::GetWidgetOrigin() const { gfx::Rect ClientControlledShellSurface::GetWidgetBounds() const {
return GetVisibleBounds().origin() - origin_offset_; gfx::Rect bounds(GetVisibleBounds());
bounds.Offset(-origin_offset_.x(), -origin_offset_.y());
return bounds;
} }
gfx::Point ClientControlledShellSurface::GetSurfaceOrigin() const { gfx::Point ClientControlledShellSurface::GetSurfaceOrigin() const {
DCHECK(resize_component_ == HTCAPTION); DCHECK(resize_component_ == HTCAPTION);
if (!geometry_changed_callback_.is_null()) if (!geometry_changed_callback_.is_null())
return gfx::Point(); return gfx::Point();
return gfx::Point() - GetWidgetOrigin().OffsetFromOrigin(); // TODO(oshima): geometry_changed_callback_ must be always set by now, so
// this is not necessary any more. Remove this.
return gfx::Point() -
(GetVisibleBounds().origin() - origin_offset_).OffsetFromOrigin();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
......
...@@ -212,7 +212,7 @@ class ClientControlledShellSurface ...@@ -212,7 +212,7 @@ class ClientControlledShellSurface
aura::Window* window, aura::Window* window,
int component) override; int component) override;
bool OnMouseDragged(const ui::MouseEvent& event) override; bool OnMouseDragged(const ui::MouseEvent& event) override;
gfx::Point GetWidgetOrigin() const override; gfx::Rect GetWidgetBounds() const override;
gfx::Point GetSurfaceOrigin() const override; gfx::Point GetSurfaceOrigin() const override;
void UpdateBackdrop(); void UpdateBackdrop();
......
...@@ -1230,11 +1230,7 @@ void ShellSurfaceBase::UpdateWidgetBounds() { ...@@ -1230,11 +1230,7 @@ void ShellSurfaceBase::UpdateWidgetBounds() {
if (!pending_configs_.empty() || scoped_configure_) if (!pending_configs_.empty() || scoped_configure_)
return; return;
gfx::Rect visible_bounds = GetVisibleBounds(); gfx::Rect new_widget_bounds = GetWidgetBounds();
gfx::Rect new_widget_bounds =
widget_->non_client_view()->GetWindowBoundsForClientBounds(
visible_bounds);
new_widget_bounds.set_origin(GetWidgetOrigin());
// Set |ignore_window_bounds_changes_| as this change to window bounds // Set |ignore_window_bounds_changes_| as this change to window bounds
// should not result in a configure request. // should not result in a configure request.
...@@ -1445,21 +1441,26 @@ void ShellSurfaceBase::EndDrag(bool revert) { ...@@ -1445,21 +1441,26 @@ void ShellSurfaceBase::EndDrag(bool revert) {
UpdateWidgetBounds(); UpdateWidgetBounds();
} }
gfx::Point ShellSurfaceBase::GetWidgetOrigin() const { gfx::Rect ShellSurfaceBase::GetWidgetBounds() const {
if (movement_disabled_)
return origin_;
// Preserve widget position.
if (resize_component_ == HTCAPTION)
return widget_->GetWindowBoundsInScreen().origin();
// Compute widget origin using surface origin if the current location of
// surface is being anchored to one side of the widget as a result of a
// resize operation.
gfx::Rect visible_bounds = GetVisibleBounds(); gfx::Rect visible_bounds = GetVisibleBounds();
gfx::Point origin = GetSurfaceOrigin() + visible_bounds.OffsetFromOrigin(); gfx::Rect new_widget_bounds =
wm::ConvertPointToScreen(widget_->GetNativeWindow(), &origin); widget_->non_client_view()->GetWindowBoundsForClientBounds(
return origin; visible_bounds);
if (movement_disabled_) {
new_widget_bounds.set_origin(origin_);
} else if (resize_component_ == HTCAPTION) {
// Preserve widget position.
new_widget_bounds.set_origin(widget_->GetWindowBoundsInScreen().origin());
} else {
// Compute widget origin using surface origin if the current location of
// surface is being anchored to one side of the widget as a result of a
// resize operation.
gfx::Rect visible_bounds = GetVisibleBounds();
gfx::Point origin = GetSurfaceOrigin() + visible_bounds.OffsetFromOrigin();
wm::ConvertPointToScreen(widget_->GetNativeWindow(), &origin);
new_widget_bounds.set_origin(origin);
}
return new_widget_bounds;
} }
gfx::Point ShellSurfaceBase::GetSurfaceOrigin() const { gfx::Point ShellSurfaceBase::GetSurfaceOrigin() const {
......
...@@ -325,9 +325,9 @@ class ShellSurfaceBase : public SurfaceTreeHost, ...@@ -325,9 +325,9 @@ class ShellSurfaceBase : public SurfaceTreeHost,
// End current drag operation. // End current drag operation.
void EndDrag(bool revert); void EndDrag(bool revert);
// Return the origin of the widget/surface taking visible bounds and current // Return the bounds of the widget/origin of surface taking visible
// resize direction into account. // bounds and current resize direction into account.
virtual gfx::Point GetWidgetOrigin() const; virtual gfx::Rect GetWidgetBounds() const;
virtual gfx::Point GetSurfaceOrigin() const; virtual gfx::Point GetSurfaceOrigin() const;
bool activatable_ = true; bool activatable_ = true;
......
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