| Index: ui/aura/window.cc
|
| ===================================================================
|
| --- ui/aura/window.cc (revision 104542)
|
| +++ ui/aura/window.cc (working copy)
|
| @@ -8,10 +8,12 @@
|
|
|
| #include "base/logging.h"
|
| #include "ui/aura/desktop.h"
|
| +#include "ui/aura/desktop_delegate.h"
|
| #include "ui/aura/event.h"
|
| #include "ui/aura/event_filter.h"
|
| #include "ui/aura/layout_manager.h"
|
| #include "ui/aura/window_delegate.h"
|
| +#include "ui/aura/window_types.h"
|
| #include "ui/base/animation/multi_animation.h"
|
| #include "ui/gfx/canvas_skia.h"
|
| #include "ui/gfx/compositor/compositor.h"
|
| @@ -23,7 +25,8 @@
|
| using internal::RootWindow;
|
|
|
| Window::Window(WindowDelegate* delegate)
|
| - : delegate_(delegate),
|
| + : type_(kWindowType_Toplevel),
|
| + delegate_(delegate),
|
| show_state_(ui::SHOW_STATE_NORMAL),
|
| parent_(NULL),
|
| id_(-1),
|
| @@ -68,6 +71,12 @@
|
| layer_->set_delegate(this);
|
| }
|
|
|
| +void Window::SetType(int type) {
|
| + // Cannot change type after the window is initialized.
|
| + DCHECK(!layer());
|
| + type_ = type;
|
| +}
|
| +
|
| void Window::Show() {
|
| SetVisible(true);
|
| }
|
| @@ -126,8 +135,10 @@
|
| void Window::SetParent(Window* parent) {
|
| if (parent)
|
| parent->AddChild(this);
|
| + else if (Desktop::GetInstance()->delegate())
|
| + Desktop::GetInstance()->delegate()->AddChildToDefaultParent(this);
|
| else
|
| - Desktop::GetInstance()->default_parent()->AddChild(this);
|
| + NOTREACHED();
|
| }
|
|
|
| void Window::Restore() {
|
| @@ -148,10 +159,14 @@
|
| SetBounds(gfx::Screen::GetMonitorAreaNearestWindow(this));
|
| }
|
|
|
| -bool Window::IsToplevelWindowContainer() const {
|
| - return false;
|
| +ToplevelWindowContainer* Window::AsToplevelWindowContainer() {
|
| + return NULL;
|
| }
|
|
|
| +const ToplevelWindowContainer* Window::AsToplevelWindowContainer() const {
|
| + return NULL;
|
| +}
|
| +
|
| void Window::MoveChildToFront(Window* child) {
|
| DCHECK_EQ(child->parent(), this);
|
| const Windows::iterator i(std::find(children_.begin(), children_.end(),
|
| @@ -166,6 +181,10 @@
|
| child->layer()->parent()->MoveToFront(child->layer());
|
| }
|
|
|
| +bool Window::CanActivate() const {
|
| + return IsVisible() && delegate_ && delegate_->ShouldActivate(NULL);
|
| +}
|
| +
|
| void Window::AddChild(Window* child) {
|
| DCHECK(std::find(children_.begin(), children_.end(), child) ==
|
| children_.end());
|
| @@ -185,11 +204,15 @@
|
| }
|
|
|
| Window* Window::GetChildById(int id) {
|
| + return const_cast<Window*>(const_cast<const Window*>(this)->GetChildById(id));
|
| +}
|
| +
|
| +const Window* Window::GetChildById(int id) const {
|
| Windows::const_iterator i;
|
| for (i = children_.begin(); i != children_.end(); ++i) {
|
| if ((*i)->id() == id)
|
| return *i;
|
| - Window* result = (*i)->GetChildById(id);
|
| + const Window* result = (*i)->GetChildById(id);
|
| if (result)
|
| return result;
|
| }
|
|
|