diff options
-rw-r--r-- | ui/aura/window.h | 5 | ||||
-rw-r--r-- | ui/aura_shell/default_container_layout_manager.cc | 5 | ||||
-rw-r--r-- | ui/aura_shell/default_container_layout_manager_unittest.cc | 21 | ||||
-rw-r--r-- | views/widget/native_widget_aura.cc | 4 |
4 files changed, 31 insertions, 4 deletions
diff --git a/ui/aura/window.h b/ui/aura/window.h index 2554716..8a9b030 100644 --- a/ui/aura/window.h +++ b/ui/aura/window.h @@ -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); diff --git a/ui/aura_shell/default_container_layout_manager.cc b/ui/aura_shell/default_container_layout_manager.cc index 98d3dc3..5fd34bd 100644 --- a/ui/aura_shell/default_container_layout_manager.cc +++ b/ui/aura_shell/default_container_layout_manager.cc @@ -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 diff --git a/ui/aura_shell/default_container_layout_manager_unittest.cc b/ui/aura_shell/default_container_layout_manager_unittest.cc index deefc5a..d3dcd05 100644 --- a/ui/aura_shell/default_container_layout_manager_unittest.cc +++ b/ui/aura_shell/default_container_layout_manager_unittest.cc @@ -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 diff --git a/views/widget/native_widget_aura.cc b/views/widget/native_widget_aura.cc index a9c88e7..5e01212 100644 --- a/views/widget/native_widget_aura.cc +++ b/views/widget/native_widget_aura.cc @@ -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()); |