Commit 33340706 authored by sky@chromium.org's avatar sky@chromium.org

Makes DefaultContainerLayoutManager ignore windows with transient

parents. This is needed otherwise the worskpace code tries to place
and position bubbles and other transient type windows.

BUG=none
TEST=none
R=ben@chromium.org,oshima@chromium.org

Review URL: http://codereview.chromium.org/8414035

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108006 0039d316-1c4b-4281-b951-d872f2087c98
parent 6328bea8
......@@ -182,6 +182,11 @@ class AURA_EXPORT Window : public ui::LayerDelegate {
void AddTransientChild(Window* child);
void RemoveTransientChild(Window* child);
const Windows& transient_children() const { return transient_children_; }
Window* transient_parent() { return transient_parent_; }
const Window* transient_parent() const { return transient_parent_; }
// Retrieves the first-level child with the specified id, or NULL if no first-
// level child is found matching |id|.
Window* GetChildById(int id);
......
......@@ -102,7 +102,8 @@ void DefaultContainerLayoutManager::OnWindowResized() {
void DefaultContainerLayoutManager::OnWindowAdded(aura::Window* child) {
intptr_t type = reinterpret_cast<intptr_t>(
ui::ViewProp::GetValue(child, views::NativeWidgetAura::kWindowTypeKey));
if (type != views::Widget::InitParams::TYPE_WINDOW)
if (type != views::Widget::InitParams::TYPE_WINDOW ||
child->transient_parent())
return;
AutoReset<bool> reset(&ignore_calculate_bounds_, true);
......@@ -144,7 +145,7 @@ void DefaultContainerLayoutManager::CalculateBoundsForChild(
intptr_t type = reinterpret_cast<intptr_t>(
ui::ViewProp::GetValue(child, views::NativeWidgetAura::kWindowTypeKey));
if (type != views::Widget::InitParams::TYPE_WINDOW ||
ignore_calculate_bounds_)
ignore_calculate_bounds_ || child->transient_parent())
return;
// If a drag window is requesting bounds, make sure its attached to
......
......@@ -67,11 +67,12 @@ class DefaultContainerLayoutManagerTest : public aura::test::AuraTestBase {
return workspace_controller_->layout_manager();
}
private:
protected:
scoped_ptr<aura::Window> container_;
ScopedVector<ui::ViewProp> props_;
scoped_ptr<aura_shell::internal::WorkspaceController> workspace_controller_;
private:
DISALLOW_COPY_AND_ASSIGN(DefaultContainerLayoutManagerTest);
};
......@@ -136,5 +137,23 @@ TEST_F(DefaultContainerLayoutManagerTest, Popup) {
EXPECT_EQ("0,0 1000x1000", popup->bounds().ToString());
}
// Make sure a window with a transient parent isn't resized by the layout
// manager.
TEST_F(DefaultContainerLayoutManagerTest, IgnoreTransient) {
scoped_ptr<aura::Window> window(new aura::Window(NULL));
props_.push_back(
new ui::ViewProp(
window.get(), views::NativeWidgetAura::kWindowTypeKey,
reinterpret_cast<void*>(Widget::InitParams::TYPE_WINDOW)));
window->SetType(Widget::InitParams::TYPE_WINDOW);
window->Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
aura::Desktop::GetInstance()->AddTransientChild(window.get());
window->SetBounds(gfx::Rect(0, 0, 200, 200));
window->Show();
window->SetParent(container());
EXPECT_EQ("0,0 200x200", window->bounds().ToString());
}
} // namespace test
} // namespace aura_shell
......@@ -86,10 +86,12 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) {
if (params.type == Widget::InitParams::TYPE_CONTROL) {
window_->SetParent(params.GetParent());
} else {
window_->SetParent(NULL);
// Set up the transient child before the window is added. This way the
// LayoutManager knows the window has a transient parent.
gfx::NativeView parent = params.GetParent();
if (parent)
parent->AddTransientChild(window_);
window_->SetParent(NULL);
}
// TODO(beng): do this some other way.
delegate_->OnNativeWidgetSizeChanged(params.bounds.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