Commit 2398e74d authored by Dominik Laskowski's avatar Dominik Laskowski Committed by Commit Bot

exo: Move ignore_window_bounds_changes_ to ShellSurface

ClientControlledShellSurface does not use it.

Bug: b:77972398
Test: exo_unittests
Change-Id: I42a5be08d94b12a2fa2d15792d297bae236a76b1
Reviewed-on: https://chromium-review.googlesource.com/1176655Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Dominik Laskowski <domlaskowski@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583820}
parent c0f77ef6
......@@ -255,6 +255,44 @@ void ShellSurface::StartResize(int component) {
AttemptToStartDrag(component);
}
////////////////////////////////////////////////////////////////////////////////
// SurfaceDelegate overrides:
void ShellSurface::OnSetParent(Surface* parent, const gfx::Point& position) {
views::Widget* parent_widget =
parent ? views::Widget::GetTopLevelWidgetForNativeView(parent->window())
: nullptr;
if (parent_widget) {
// Set parent window if using default container and the container itself
// is not the parent.
if (container_ == ash::kShellWindowId_DefaultContainer)
SetParentWindow(parent_widget->GetNativeWindow());
origin_ = position;
views::View::ConvertPointToScreen(
parent_widget->widget_delegate()->GetContentsView(), &origin_);
if (!widget_)
return;
ash::wm::WindowState* window_state =
ash::wm::GetWindowState(widget_->GetNativeWindow());
if (window_state->is_dragged())
return;
gfx::Rect widget_bounds = widget_->GetWindowBoundsInScreen();
gfx::Rect new_widget_bounds(origin_, widget_bounds.size());
if (new_widget_bounds != widget_bounds) {
base::AutoReset<bool> auto_ignore_window_bounds_changes(
&ignore_window_bounds_changes_, true);
widget_->SetBounds(new_widget_bounds);
UpdateSurfaceBounds();
}
} else {
SetParentWindow(nullptr);
}
}
////////////////////////////////////////////////////////////////////////////////
// ShellSurfaceBase overrides:
......@@ -413,6 +451,18 @@ void ShellSurface::OnPostWindowStateTypeChange(
////////////////////////////////////////////////////////////////////////////////
// ShellSurfaceBase overrides:
void ShellSurface::SetWidgetBounds(const gfx::Rect& bounds) {
// Set |ignore_window_bounds_changes_| as this change to window bounds
// should not result in a configure request.
DCHECK(!ignore_window_bounds_changes_);
ignore_window_bounds_changes_ = true;
widget_->SetBounds(bounds);
UpdateSurfaceBounds();
ignore_window_bounds_changes_ = false;
}
void ShellSurface::OnPreWidgetCommit() {
if (!widget_ && enabled()) {
// Defer widget creation until surface contains some contents.
......
......@@ -82,6 +82,9 @@ class ShellSurface : public ShellSurfaceBase,
// Start an interactive move of surface.
void StartMove();
// Overridden from SurfaceDelegate:
void OnSetParent(Surface* parent, const gfx::Point& position) override;
// Overridden from ShellSurfaceBase:
void InitializeWindowState(ash::wm::WindowState* window_state) override;
base::Optional<gfx::Rect> GetWidgetBounds() const override;
......@@ -132,6 +135,7 @@ class ShellSurface : public ShellSurfaceBase,
};
// Overridden from ShellSurfaceBase:
void SetWidgetBounds(const gfx::Rect& bounds) override;
void OnPreWidgetCommit() override;
void OnPostWidgetCommit() override;
......@@ -155,6 +159,8 @@ class ShellSurface : public ShellSurfaceBase,
int resize_component_ = HTCAPTION; // HT constant (see ui/base/hit_test.h)
int pending_resize_component_ = HTCAPTION;
bool ignore_window_bounds_changes_ = false;
DISALLOW_COPY_AND_ASSIGN(ShellSurface);
};
......
......@@ -725,42 +725,6 @@ void ShellSurfaceBase::OnSetFrameColors(SkColor active_color,
}
}
void ShellSurfaceBase::OnSetParent(Surface* parent,
const gfx::Point& position) {
views::Widget* parent_widget =
parent ? views::Widget::GetTopLevelWidgetForNativeView(parent->window())
: nullptr;
if (parent_widget) {
// Set parent window if using default container and the container itself
// is not the parent.
if (container_ == ash::kShellWindowId_DefaultContainer)
SetParentWindow(parent_widget->GetNativeWindow());
origin_ = position;
views::View::ConvertPointToScreen(
parent_widget->widget_delegate()->GetContentsView(), &origin_);
if (!widget_)
return;
ash::wm::WindowState* window_state =
ash::wm::GetWindowState(widget_->GetNativeWindow());
if (window_state->is_dragged())
return;
gfx::Rect widget_bounds = widget_->GetWindowBoundsInScreen();
gfx::Rect new_widget_bounds(origin_, widget_bounds.size());
if (new_widget_bounds != widget_bounds) {
base::AutoReset<bool> auto_ignore_window_bounds_changes(
&ignore_window_bounds_changes_, true);
widget_->SetBounds(new_widget_bounds);
UpdateSurfaceBounds();
}
} else {
SetParentWindow(nullptr);
}
}
void ShellSurfaceBase::OnSetStartupId(const char* startup_id) {
SetStartupId(startup_id);
}
......@@ -1092,18 +1056,8 @@ void ShellSurfaceBase::UpdateWidgetBounds() {
if (!new_widget_bounds)
return;
// Set |ignore_window_bounds_changes_| as this change to window bounds
// should not result in a configure request.
DCHECK(!ignore_window_bounds_changes_);
ignore_window_bounds_changes_ = true;
if (*new_widget_bounds != widget_->GetWindowBoundsInScreen())
SetWidgetBounds(*new_widget_bounds);
ignore_window_bounds_changes_ = false;
}
void ShellSurfaceBase::SetWidgetBounds(const gfx::Rect& bounds) {
widget_->SetBounds(bounds);
UpdateSurfaceBounds();
}
void ShellSurfaceBase::UpdateSurfaceBounds() {
......
......@@ -155,7 +155,6 @@ class ShellSurfaceBase : public SurfaceTreeHost,
bool IsInputEnabled(Surface* surface) const override;
void OnSetFrame(SurfaceFrameType type) override;
void OnSetFrameColors(SkColor active_color, SkColor inactive_color) override;
void OnSetParent(Surface* parent, const gfx::Point& position) override;
void OnSetStartupId(const char* startup_id) override;
void OnSetApplicationId(const char* application_id) override;
......@@ -218,7 +217,7 @@ class ShellSurfaceBase : public SurfaceTreeHost,
void UpdateWidgetBounds();
// Called by UpdateWidgetBounds to set widget bounds.
virtual void SetWidgetBounds(const gfx::Rect& bounds);
virtual void SetWidgetBounds(const gfx::Rect& bounds) = 0;
// Updates the bounds of surface to match the current widget bounds.
void UpdateSurfaceBounds();
......@@ -257,7 +256,6 @@ class ShellSurfaceBase : public SurfaceTreeHost,
// Container Window Id (see ash/public/cpp/shell_window_ids.h)
int container_;
bool ignore_window_bounds_changes_ = false;
gfx::Rect geometry_;
gfx::Rect pending_geometry_;
base::Optional<gfx::Rect> shadow_bounds_;
......
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