summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/aura/aura.gyp37
-rw-r--r--ui/aura/layout_manager.cc22
-rw-r--r--ui/aura/layout_manager.h32
-rw-r--r--ui/aura/test/aura_test_base.h3
-rw-r--r--ui/aura/test/event_generator.h3
-rw-r--r--ui/aura/test/test_desktop_delegate.h3
-rw-r--r--ui/aura/window.cc16
-rw-r--r--ui/aura/window.h6
-rw-r--r--ui/aura/window_types.h10
-rw-r--r--ui/aura_shell/aura_shell.gyp5
-rw-r--r--ui/aura_shell/default_container_layout_manager.cc72
-rw-r--r--ui/aura_shell/default_container_layout_manager.h48
-rw-r--r--ui/aura_shell/default_container_layout_manager_unittest.cc118
-rw-r--r--ui/aura_shell/desktop_layout_manager.cc15
-rw-r--r--ui/aura_shell/desktop_layout_manager.h9
-rw-r--r--ui/aura_shell/shell.cc22
-rw-r--r--views/widget/native_widget_aura.cc32
-rw-r--r--views/widget/native_widget_aura.h4
18 files changed, 403 insertions, 54 deletions
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index 57fcccb..cdb9b4b 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -39,6 +39,7 @@
'event_filter.h',
'focus_manager.h',
'hit_test.h',
+ 'layout_manager.cc',
'layout_manager.h',
'screen_aura.cc',
'screen_aura.h',
@@ -54,6 +55,31 @@
],
},
{
+ 'target_name': 'test_support_aura',
+ 'type': 'static_library',
+ 'dependencies': [
+ '../../skia/skia.gyp:skia',
+ '../../testing/gtest.gyp:gtest',
+ '../ui.gyp:ui',
+ 'aura',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ 'sources': [
+ 'test/aura_test_base.cc',
+ 'test/aura_test_base.h',
+ 'test/event_generator.cc',
+ 'test/event_generator.h',
+ 'test/test_desktop_delegate.cc',
+ 'test/test_desktop_delegate.h',
+ '../gfx/compositor/test_compositor.cc',
+ '../gfx/compositor/test_compositor.h',
+ '../gfx/compositor/test_texture.cc',
+ '../gfx/compositor/test_texture.h',
+ ],
+ },
+ {
'target_name': 'aura_demo',
'type': 'executable',
'dependencies': [
@@ -89,29 +115,20 @@
'../ui.gyp:gfx_resources',
'../ui.gyp:ui',
'../ui.gyp:ui_resources',
+ 'test_support_aura',
'aura',
],
'include_dirs': [
'..',
],
'sources': [
- 'test/aura_test_base.cc',
- 'test/aura_test_base.h',
- 'test/event_generator.cc',
- 'test/event_generator.h',
'test/run_all_unittests.cc',
- 'test/test_desktop_delegate.cc',
- 'test/test_desktop_delegate.h',
'test/test_suite.cc',
'test/test_suite.h',
'test/test_window_delegate.cc',
'test/test_window_delegate.h',
'toplevel_window_event_filter_unittest.cc',
'window_unittest.cc',
- '../gfx/compositor/test_compositor.cc',
- '../gfx/compositor/test_compositor.h',
- '../gfx/compositor/test_texture.cc',
- '../gfx/compositor/test_texture.h',
'<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources.rc',
],
diff --git a/ui/aura/layout_manager.cc b/ui/aura/layout_manager.cc
new file mode 100644
index 0000000..4780ae0
--- /dev/null
+++ b/ui/aura/layout_manager.cc
@@ -0,0 +1,22 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura/layout_manager.h"
+
+#include "ui/aura/window.h"
+
+namespace aura {
+
+LayoutManager::LayoutManager() {
+}
+
+LayoutManager::~LayoutManager() {
+}
+
+void LayoutManager::SetChildBounds(aura::Window* child,
+ const gfx::Rect& bounds) {
+ child->SetBoundsInternal(bounds);
+}
+
+} // namespace aura
diff --git a/ui/aura/layout_manager.h b/ui/aura/layout_manager.h
index be4e856..5ff905b 100644
--- a/ui/aura/layout_manager.h
+++ b/ui/aura/layout_manager.h
@@ -6,17 +6,45 @@
#define UI_AURA_LAYOUT_MANAGER_H_
#pragma once
+#include "base/basictypes.h"
#include "ui/aura/aura_export.h"
+namespace gfx {
+class Rect;
+}
+
namespace aura {
+class Window;
// An interface implemented by an object that places child windows.
class AURA_EXPORT LayoutManager {
public:
- virtual ~LayoutManager() {}
+ LayoutManager();
+ virtual ~LayoutManager();
- // Called when the window is resized.
+ // Invoked when the window is resized.
virtual void OnWindowResized() = 0;
+
+ // Invoked when the window |child| has been added.
+ virtual void OnWindowAdded(Window* child) = 0;
+
+ // Invoked prior to removing |window|.
+ virtual void OnWillRemoveWindow(Window* child) = 0;
+
+ // Invoked when the |SetVisible()| is invoked on the window |child|.
+ // |visible| is the value supplied to |SetVisible()|. If |visible| is true,
+ // window->IsVisible() may still return false. See description in
+ // Window::IsVisible() for details.
+ virtual void OnChildWindowVisibilityChanged(Window* child, bool visibile) = 0;
+
+ // Calculates the bounds for the |child| based on |requsted_bounds|.
+ virtual void CalculateBoundsForChild(Window* child,
+ gfx::Rect* requested_bounds) = 0;
+ protected:
+ // Sets the child's bounds forcibly. LayoutManager is responsible
+ // for checking the state and make sure the bounds are correctly
+ // adjusted.
+ void SetChildBounds(aura::Window* child, const gfx::Rect& bounds);
};
} // namespace aura
diff --git a/ui/aura/test/aura_test_base.h b/ui/aura/test/aura_test_base.h
index 4aafa0f..1d2551a 100644
--- a/ui/aura/test/aura_test_base.h
+++ b/ui/aura/test/aura_test_base.h
@@ -6,6 +6,7 @@
#define UI_AURA_TEST_AURA_TEST_BASE_H_
#pragma once
+#include "ui/aura/aura_export.h"
#include "base/compiler_specific.h"
#include "base/basictypes.h"
#include "base/message_loop.h"
@@ -15,7 +16,7 @@ namespace aura {
namespace test {
// A base class for aura unit tests.
-class AuraTestBase : public testing::Test {
+class AURA_EXPORT AuraTestBase : public testing::Test {
public:
AuraTestBase();
virtual ~AuraTestBase();
diff --git a/ui/aura/test/event_generator.h b/ui/aura/test/event_generator.h
index f375f9d..a50c2ef 100644
--- a/ui/aura/test/event_generator.h
+++ b/ui/aura/test/event_generator.h
@@ -6,6 +6,7 @@
#define UI_AURA_TEST_EVENT_GENERATOR_H_
#pragma once
+#include "ui/aura/aura_export.h"
#include "base/basictypes.h"
#include "ui/gfx/point.h"
@@ -17,7 +18,7 @@ namespace test {
// EventGenerator is a tool that generates and dispatch events.
// TODO(oshima): Support key events.
-class EventGenerator {
+class AURA_EXPORT EventGenerator {
public:
// Creates an EventGenerator with the mouse location (0,0).
EventGenerator();
diff --git a/ui/aura/test/test_desktop_delegate.h b/ui/aura/test/test_desktop_delegate.h
index 09bfc31e..2be7fe9 100644
--- a/ui/aura/test/test_desktop_delegate.h
+++ b/ui/aura/test/test_desktop_delegate.h
@@ -6,6 +6,7 @@
#define UI_AURA_TEST_TEST_DESKTOP_DELEGATE_H_
#pragma once
+#include "ui/aura/aura_export.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
@@ -17,7 +18,7 @@ class ToplevelWindowContainer;
namespace test {
-class TestDesktopDelegate : public DesktopDelegate {
+class AURA_EXPORT TestDesktopDelegate : public DesktopDelegate {
public:
// Callers should allocate a TestDesktopDelegate on the heap and then forget
// about it -- the c'tor passes ownership of the TestDesktopDelegate to the
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index 8ded1d2..67fbdba 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -24,7 +24,7 @@
namespace aura {
Window::Window(WindowDelegate* delegate)
- : type_(kWindowType_Toplevel),
+ : type_(kWindowType_None),
delegate_(delegate),
show_state_(ui::SHOW_STATE_NORMAL),
parent_(NULL),
@@ -140,12 +140,16 @@ void Window::SetLayoutManager(LayoutManager* layout_manager) {
}
void Window::SetBounds(const gfx::Rect& new_bounds) {
+ gfx::Rect adjusted_bounds = new_bounds;
+ if (parent_ && parent_->layout_manager())
+ parent_->layout_manager()->CalculateBoundsForChild(this, &adjusted_bounds);
+
if (show_state_ == ui::SHOW_STATE_MAXIMIZED ||
show_state_ == ui::SHOW_STATE_FULLSCREEN) {
- restore_bounds_ = new_bounds;
+ restore_bounds_ = adjusted_bounds;
return;
}
- SetBoundsInternal(new_bounds);
+ SetBoundsInternal(adjusted_bounds);
}
gfx::Rect Window::GetTargetBounds() const {
@@ -202,12 +206,16 @@ void Window::AddChild(Window* child) {
child->parent_ = this;
layer_->Add(child->layer_.get());
children_.push_back(child);
+ if (layout_manager_.get())
+ layout_manager_->OnWindowAdded(child);
FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowAdded(child));
}
void Window::RemoveChild(Window* child) {
Windows::iterator i = std::find(children_.begin(), children_.end(), child);
DCHECK(i != children_.end());
+ if (layout_manager_.get())
+ layout_manager_->OnWillRemoveWindow(child);
FOR_EACH_OBSERVER(WindowObserver, observers_, OnWillRemoveWindow(child));
child->parent_ = NULL;
layer_->Remove(child->layer_.get());
@@ -426,6 +434,8 @@ void Window::SetVisible(bool visible) {
if (delegate_)
delegate_->OnWindowVisibilityChanged(is_visible);
}
+ if (parent_ && parent_->layout_manager_.get())
+ parent_->layout_manager_->OnChildWindowVisibilityChanged(this, visible);
FOR_EACH_OBSERVER(WindowObserver, observers_,
OnWindowVisibilityChanged(this, visible));
}
diff --git a/ui/aura/window.h b/ui/aura/window.h
index 676cfdb..5084169 100644
--- a/ui/aura/window.h
+++ b/ui/aura/window.h
@@ -121,8 +121,10 @@ class AURA_EXPORT Window : public ui::LayerDelegate {
// Assigns a LayoutManager to size and place child windows.
// The Window takes ownership of the LayoutManager.
void SetLayoutManager(LayoutManager* layout_manager);
+ LayoutManager* layout_manager() { return layout_manager_.get(); }
- // Changes the bounds of the window.
+ // Changes the bounds of the window. If present, the window's parent's
+ // LayoutManager may adjust the bounds.
void SetBounds(const gfx::Rect& new_bounds);
// Returns the target bounds of the window. If the window's layer is
@@ -256,6 +258,8 @@ class AURA_EXPORT Window : public ui::LayerDelegate {
virtual Desktop* GetDesktop();
private:
+ friend class LayoutManager;
+
// Changes the bounds of the window without condition.
void SetBoundsInternal(const gfx::Rect& new_bounds);
diff --git a/ui/aura/window_types.h b/ui/aura/window_types.h
index 8b14184..9fa3ce6 100644
--- a/ui/aura/window_types.h
+++ b/ui/aura/window_types.h
@@ -8,12 +8,14 @@
namespace aura {
-const int kWindowType_Toplevel = 0;
+// This file is obsolete. Please do not add any new types.
+// This still exists as Window::Init uses Type_Control.
+// TODO(ben|oshima): Figure out how to clean this up.
+
+const int kWindowType_None = 0;
const int kWindowType_Control = 1;
-const int kWindowType_Menu = 2;
-const int kWindowType_Tooltip = 3;
-const int kWindowType_Max = 4;
+const int kWindowType_Max = 2;
} // namespace aura
diff --git a/ui/aura_shell/aura_shell.gyp b/ui/aura_shell/aura_shell.gyp
index 03efcca..2c2f354 100644
--- a/ui/aura_shell/aura_shell.gyp
+++ b/ui/aura_shell/aura_shell.gyp
@@ -33,6 +33,8 @@
],
'sources': [
# All .cc, .h under views, except unittests
+ 'default_container_layout_manager.cc',
+ 'default_container_layout_manager.h',
'desktop_background_view.cc',
'desktop_background_view.h',
'desktop_layout_manager.cc',
@@ -81,9 +83,12 @@
'../ui.gyp:ui',
'../ui.gyp:ui_resources',
'../ui.gyp:ui_resources_standard',
+ '../aura/aura.gyp:aura',
+ '../aura/aura.gyp:test_support_aura',
'aura_shell',
],
'sources': [
+ 'default_container_layout_manager_unittest.cc',
'launcher/launcher_model_unittest.cc',
'launcher/view_model_unittest.cc',
'launcher/view_model_utils_unittest.cc',
diff --git a/ui/aura_shell/default_container_layout_manager.cc b/ui/aura_shell/default_container_layout_manager.cc
new file mode 100644
index 0000000..0d312f1
--- /dev/null
+++ b/ui/aura_shell/default_container_layout_manager.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura_shell/default_container_layout_manager.h"
+
+#include "ui/aura/desktop.h"
+#include "ui/aura/window.h"
+#include "ui/aura/screen_aura.h"
+#include "ui/aura/window_types.h"
+#include "ui/base/view_prop.h"
+#include "ui/gfx/rect.h"
+#include "views/widget/native_widget_aura.h"
+
+namespace aura_shell {
+namespace internal {
+
+////////////////////////////////////////////////////////////////////////////////
+// DefaultContainerLayoutManager, public:
+
+DefaultContainerLayoutManager::DefaultContainerLayoutManager(
+ aura::Window* owner)
+ : owner_(owner) {
+}
+
+DefaultContainerLayoutManager::~DefaultContainerLayoutManager() {}
+
+////////////////////////////////////////////////////////////////////////////////
+// DefaultContainerLayoutManager, aura::LayoutManager implementation:
+
+void DefaultContainerLayoutManager::OnWindowResized() {
+ aura::Window::Windows::const_iterator i = owner_->children().begin();
+ // Use SetBounds because window may be maximized or fullscreen.
+ for (; i != owner_->children().end(); ++i)
+ (*i)->SetBounds((*i)->bounds());
+ NOTIMPLEMENTED();
+}
+
+void DefaultContainerLayoutManager::OnWindowAdded(aura::Window* child) {
+ child->SetBounds(child->bounds());
+ NOTIMPLEMENTED();
+}
+
+void DefaultContainerLayoutManager::OnWillRemoveWindow(aura::Window* child) {
+ NOTIMPLEMENTED();
+}
+
+void DefaultContainerLayoutManager::OnChildWindowVisibilityChanged(
+ aura::Window* window, bool visibile) {
+ NOTIMPLEMENTED();
+}
+
+void DefaultContainerLayoutManager::CalculateBoundsForChild(
+ aura::Window* child, gfx::Rect* requested_bounds) {
+ intptr_t type = reinterpret_cast<intptr_t>(
+ ui::ViewProp::GetValue(child, views::NativeWidgetAura::kWindowTypeKey));
+ // DCLM controls windows with a frame.
+ if (type != views::Widget::InitParams::TYPE_WINDOW)
+ return;
+ // TODO(oshima): Figure out bounds for default windows.
+ gfx::Rect viewport_bounds = owner_->bounds();
+
+ // A window can still be placed outside of the screen.
+ requested_bounds->SetRect(
+ requested_bounds->x(),
+ viewport_bounds.y(),
+ std::min(requested_bounds->width(), viewport_bounds.width()),
+ std::min(requested_bounds->height(), viewport_bounds.height()));
+}
+
+} // namespace internal
+} // namespace aura_shell
diff --git a/ui/aura_shell/default_container_layout_manager.h b/ui/aura_shell/default_container_layout_manager.h
new file mode 100644
index 0000000..3ea8946
--- /dev/null
+++ b/ui/aura_shell/default_container_layout_manager.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_AURA_SHELL_DEFAULT_CONTAINER_LAYOUT_MANAGER_H_
+#define UI_AURA_SHELL_DEFAULT_CONTAINER_LAYOUT_MANAGER_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ui/aura/layout_manager.h"
+
+namespace aura {
+class Window;
+}
+
+namespace gfx {
+class Rect;
+}
+
+namespace aura_shell {
+namespace internal {
+
+// LayoutManager for the default window container.
+class DefaultContainerLayoutManager : public aura::LayoutManager {
+ public:
+ explicit DefaultContainerLayoutManager(aura::Window* owner);
+ virtual ~DefaultContainerLayoutManager();
+
+ // Overridden from aura::LayoutManager:
+ virtual void OnWindowResized() OVERRIDE;
+ virtual void OnWindowAdded(aura::Window* child) OVERRIDE;
+ virtual void OnWillRemoveWindow(aura::Window* child) OVERRIDE;
+ virtual void OnChildWindowVisibilityChanged(aura::Window* child,
+ bool visibile) OVERRIDE;
+ virtual void CalculateBoundsForChild(aura::Window* child,
+ gfx::Rect* requested_bounds) OVERRIDE;
+
+ private:
+ aura::Window* owner_;
+
+ DISALLOW_COPY_AND_ASSIGN(DefaultContainerLayoutManager);
+};
+
+} // namespace internal
+} // namespace aura_shell
+
+#endif // UI_AURA_SHELL_DEFAULT_CONTAINER_LAYOUT_MANAGER_H_
diff --git a/ui/aura_shell/default_container_layout_manager_unittest.cc b/ui/aura_shell/default_container_layout_manager_unittest.cc
new file mode 100644
index 0000000..5caa1d8
--- /dev/null
+++ b/ui/aura_shell/default_container_layout_manager_unittest.cc
@@ -0,0 +1,118 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura_shell/default_container_layout_manager.h"
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_vector.h"
+#include "ui/aura/test/aura_test_base.h"
+#include "ui/aura/desktop.h"
+#include "ui/aura/screen_aura.h"
+#include "ui/aura/window.h"
+#include "ui/base/view_prop.h"
+#include "views/widget/native_widget_aura.h"
+
+namespace aura_shell {
+namespace test {
+
+namespace {
+
+using views::Widget;
+
+class DefaultContainerLayoutManagerTest : public aura::test::AuraTestBase {
+ public:
+ DefaultContainerLayoutManagerTest() {}
+ virtual ~DefaultContainerLayoutManagerTest() {}
+
+ virtual void SetUp() OVERRIDE {
+ aura::test::AuraTestBase::SetUp();
+ aura::Desktop* desktop = aura::Desktop::GetInstance();
+ container_.reset(
+ CreateTestWindow(gfx::Rect(0, 0, 500, 400), desktop));
+ // draggable area is 0,0 500x400.
+ container_->SetLayoutManager(
+ new aura_shell::internal::DefaultContainerLayoutManager(
+ container_.get()));
+ }
+
+ aura::Window* CreateTestWindowWithType(const gfx::Rect& bounds,
+ aura::Window* parent,
+ Widget::InitParams::Type type) {
+ aura::Window* window = new aura::Window(NULL);
+ props_.push_back(new ui::ViewProp(
+ window, views::NativeWidgetAura::kWindowTypeKey,
+ reinterpret_cast<void*>(type)));
+ window->SetType(type);
+ window->Init();
+ window->SetBounds(bounds);
+ window->Show();
+ window->SetParent(parent);
+ return window;
+ }
+
+ aura::Window* CreateTestWindow(const gfx::Rect& bounds,
+ aura::Window* parent) {
+ return CreateTestWindowWithType(bounds,
+ parent,
+ Widget::InitParams::TYPE_WINDOW);
+ }
+
+ aura::Window* container() { return container_.get(); }
+
+ private:
+ scoped_ptr<aura::Window> container_;
+ ScopedVector<ui::ViewProp> props_;
+
+ DISALLOW_COPY_AND_ASSIGN(DefaultContainerLayoutManagerTest);
+};
+
+} // namespace
+
+TEST_F(DefaultContainerLayoutManagerTest, SetBounds) {
+ // Layout Manager moves the window to (0,0) to fit to draggable area.
+ scoped_ptr<aura::Window> child(
+ CreateTestWindow(gfx::Rect(0, -1000, 100, 100), container()));
+ EXPECT_EQ("0,0 100x100", child->bounds().ToString());
+
+ // DCLM enforces the window height can't be taller than its owner's height.
+ child->SetBounds(gfx::Rect(0, 0, 100, 500));
+ EXPECT_EQ("0,0 100x400", child->bounds().ToString());
+
+ // DCLM enforces the window width can't be wider than its owner's width.
+ child->SetBounds(gfx::Rect(0, 0, 900, 500));
+ EXPECT_EQ("0,0 500x400", child->bounds().ToString());
+
+ // Y origin must always be the top of drag area.
+ child->SetBounds(gfx::Rect(0, 500, 900, 500));
+ EXPECT_EQ("0,0 500x400", child->bounds().ToString());
+ child->SetBounds(gfx::Rect(0, -500, 900, 500));
+ EXPECT_EQ("0,0 500x400", child->bounds().ToString());
+
+ // X origin can be anywhere.
+ child->SetBounds(gfx::Rect(-100, 500, 900, 500));
+ EXPECT_EQ("-100,0 500x400", child->bounds().ToString());
+ child->SetBounds(gfx::Rect(1000, 500, 900, 500));
+ EXPECT_EQ("1000,0 500x400", child->bounds().ToString());
+}
+
+TEST_F(DefaultContainerLayoutManagerTest, Popup) {
+ scoped_ptr<aura::Window> popup(
+ CreateTestWindowWithType(gfx::Rect(0, -1000, 100, 100),
+ container(),
+ Widget::InitParams::TYPE_POPUP));
+ // A popup window can be placed outside of draggable area.
+ EXPECT_EQ("0,-1000 100x100", popup->bounds().ToString());
+
+ // A popup window can be moved to outside of draggable area.
+ popup->SetBounds(gfx::Rect(-100, 0, 100, 100));
+ EXPECT_EQ("-100,0 100x100", popup->bounds().ToString());
+
+ // A popup window can be resized to the size bigger than draggable area.
+ popup->SetBounds(gfx::Rect(0, 0, 1000, 1000));
+ EXPECT_EQ("0,0 1000x1000", popup->bounds().ToString());
+}
+
+} // namespace test
+} // namespace aura_shell
diff --git a/ui/aura_shell/desktop_layout_manager.cc b/ui/aura_shell/desktop_layout_manager.cc
index a638b3b..b70cf8a 100644
--- a/ui/aura_shell/desktop_layout_manager.cc
+++ b/ui/aura_shell/desktop_layout_manager.cc
@@ -50,5 +50,20 @@ void DesktopLayoutManager::OnWindowResized() {
status_area_bounds.height()));
}
+void DesktopLayoutManager::OnWindowAdded(aura::Window* child) {
+}
+
+void DesktopLayoutManager::OnWillRemoveWindow(aura::Window* child) {
+}
+
+void DesktopLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child,
+ bool visibile) {
+}
+
+void DesktopLayoutManager::CalculateBoundsForChild(
+ aura::Window* child, gfx::Rect* requested_bounds) {
+}
+
+
} // namespace internal
} // namespace aura_shell
diff --git a/ui/aura_shell/desktop_layout_manager.h b/ui/aura_shell/desktop_layout_manager.h
index d46a923..e28a66e 100644
--- a/ui/aura_shell/desktop_layout_manager.h
+++ b/ui/aura_shell/desktop_layout_manager.h
@@ -13,6 +13,9 @@
namespace aura {
class Window;
}
+namespace gfx {
+class Rect;
+}
namespace views {
class Widget;
}
@@ -41,6 +44,12 @@ class DesktopLayoutManager : public aura::LayoutManager {
// Overridden from aura::LayoutManager:
virtual void OnWindowResized() OVERRIDE;
+ virtual void OnWindowAdded(aura::Window* child) OVERRIDE;
+ virtual void OnWillRemoveWindow(aura::Window* child) OVERRIDE;
+ virtual void OnChildWindowVisibilityChanged(aura::Window* child,
+ bool visibile) OVERRIDE;
+ virtual void CalculateBoundsForChild(aura::Window* child,
+ gfx::Rect* requested_bounds) OVERRIDE;
private:
aura::Window* owner_;
diff --git a/ui/aura_shell/shell.cc b/ui/aura_shell/shell.cc
index 69023b1..aa2798d 100644
--- a/ui/aura_shell/shell.cc
+++ b/ui/aura_shell/shell.cc
@@ -10,18 +10,23 @@
#include "ui/aura/toplevel_window_container.h"
#include "ui/aura/window.h"
#include "ui/aura/window_types.h"
+#include "ui/aura_shell/default_container_layout_manager.h"
#include "ui/aura_shell/desktop_layout_manager.h"
#include "ui/aura_shell/launcher/launcher.h"
#include "ui/aura_shell/shell_delegate.h"
#include "ui/aura_shell/shell_factory.h"
#include "ui/aura_shell/shell_window_ids.h"
+#include "ui/base/view_prop.h"
#include "ui/gfx/compositor/layer.h"
+#include "views/widget/native_widget_aura.h"
#include "views/widget/widget.h"
namespace aura_shell {
namespace {
+using views::Widget;
+
// Creates each of the special window containers that holds windows of various
// types in the shell UI. They are added to |containers| from back to front in
// the z-index.
@@ -33,6 +38,8 @@ void CreateSpecialContainers(aura::Window::Windows* containers) {
aura::Window* default_container = new aura::ToplevelWindowContainer;
default_container->set_id(internal::kShellWindowId_DefaultContainer);
+ default_container->SetLayoutManager(
+ new internal::DefaultContainerLayoutManager(default_container));
containers->push_back(default_container);
aura::Window* always_on_top_container = new aura::ToplevelWindowContainer;
@@ -232,13 +239,18 @@ void Shell::RestoreTiledWindows() {
void Shell::AddChildToDefaultParent(aura::Window* window) {
aura::Window* parent = NULL;
- switch (window->type()) {
- case aura::kWindowType_Toplevel:
- case aura::kWindowType_Control:
+ intptr_t type = reinterpret_cast<intptr_t>(
+ ui::ViewProp::GetValue(window, views::NativeWidgetAura::kWindowTypeKey));
+ switch (static_cast<Widget::InitParams::Type>(type)) {
+ case Widget::InitParams::TYPE_WINDOW:
+ case Widget::InitParams::TYPE_WINDOW_FRAMELESS:
+ case Widget::InitParams::TYPE_CONTROL:
+ case Widget::InitParams::TYPE_BUBBLE:
+ case Widget::InitParams::TYPE_POPUP:
parent = GetContainer(internal::kShellWindowId_DefaultContainer);
break;
- case aura::kWindowType_Menu:
- case aura::kWindowType_Tooltip:
+ case Widget::InitParams::TYPE_MENU:
+ case Widget::InitParams::TYPE_TOOLTIP:
parent = GetContainer(internal::kShellWindowId_MenusAndTooltipsContainer);
break;
default:
diff --git a/views/widget/native_widget_aura.cc b/views/widget/native_widget_aura.cc
index 5e97cff..cc1baa1 100644
--- a/views/widget/native_widget_aura.cc
+++ b/views/widget/native_widget_aura.cc
@@ -33,31 +33,7 @@ using ui::ViewProp;
namespace views {
-namespace {
-
-int GetAuraWindowTypeFromInitParams(const Widget::InitParams& params) {
- if (params.child)
- return aura::kWindowType_Control;
- switch (params.type) {
- case Widget::InitParams::TYPE_WINDOW:
- case Widget::InitParams::TYPE_WINDOW_FRAMELESS:
- case Widget::InitParams::TYPE_POPUP:
- case Widget::InitParams::TYPE_BUBBLE:
- return aura::kWindowType_Toplevel;
- case Widget::InitParams::TYPE_CONTROL:
- return aura::kWindowType_Control;
- case Widget::InitParams::TYPE_MENU:
- return aura::kWindowType_Menu;
- case Widget::InitParams::TYPE_TOOLTIP:
- return aura::kWindowType_Tooltip;
- default:
- NOTREACHED();
- break;
- }
- return aura::kWindowType_Toplevel;
-}
-
-} // namespace
+const char* const NativeWidgetAura::kWindowTypeKey = "WindowType";
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetAura, public:
@@ -97,7 +73,11 @@ gfx::Font NativeWidgetAura::GetWindowTitleFont() {
void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) {
ownership_ = params.ownership;
window_->set_user_data(this);
- window_->SetType(GetAuraWindowTypeFromInitParams(params));
+ Widget::InitParams::Type window_type =
+ params.child ? Widget::InitParams::TYPE_CONTROL : params.type;
+ SetNativeWindowProperty(kWindowTypeKey, reinterpret_cast<void*>(window_type));
+ window_->SetType(window_type == Widget::InitParams::TYPE_CONTROL ?
+ aura::kWindowType_Control : aura::kWindowType_None);
window_->Init();
// TODO(beng): respect |params| authoritah wrt transparency.
window_->layer()->SetFillsBoundsOpaquely(false);
diff --git a/views/widget/native_widget_aura.h b/views/widget/native_widget_aura.h
index 9ba5f86..255b123 100644
--- a/views/widget/native_widget_aura.h
+++ b/views/widget/native_widget_aura.h
@@ -142,6 +142,10 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate,
virtual void OnWindowDestroyed() OVERRIDE;
virtual void OnWindowVisibilityChanged(bool visible) OVERRIDE;
+ // ViewProp key for window type. The prop value is one of
+ // Widget::InitParams::Type.
+ static const char* const kWindowTypeKey;
+
private:
typedef ScopedVector<ui::ViewProp> ViewProps;