| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/aura/desktop.h" | 5 #include "ui/aura/desktop.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "ui/aura/desktop_host.h" | 9 #include "ui/aura/desktop_host.h" |
| 10 #include "ui/aura/focus_manager.h" | 10 #include "ui/aura/focus_manager.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 Desktop::~Desktop() { | 45 Desktop::~Desktop() { |
| 46 in_destructor_ = true; | 46 in_destructor_ = true; |
| 47 if (instance_ == this) | 47 if (instance_ == this) |
| 48 instance_ = NULL; | 48 instance_ = NULL; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void Desktop::Init() { | 51 void Desktop::Init() { |
| 52 window_->Init(); | 52 window_->Init(); |
| 53 window_->Show(); |
| 53 compositor()->SetRootLayer(window_->layer()); | 54 compositor()->SetRootLayer(window_->layer()); |
| 54 } | 55 } |
| 55 | 56 |
| 56 void Desktop::CreateDefaultParentForTesting() { | 57 void Desktop::CreateDefaultParentForTesting() { |
| 57 Window* default_parent = new internal::ToplevelWindowContainer; | 58 Window* default_parent = new internal::ToplevelWindowContainer; |
| 58 default_parent->Init(); | 59 default_parent->Init(); |
| 59 default_parent->SetBounds(window_->bounds()); | 60 default_parent->SetBounds(window_->bounds()); |
| 60 default_parent->Show(); | 61 default_parent->Show(); |
| 61 window_->AddChild(default_parent); | 62 window_->AddChild(default_parent); |
| 62 set_default_parent(default_parent); | 63 set_default_parent(default_parent); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // Reset active_window_ before invoking SetActiveWindow so that we don't | 130 // Reset active_window_ before invoking SetActiveWindow so that we don't |
| 130 // attempt to notify it while running its destructor. | 131 // attempt to notify it while running its destructor. |
| 131 active_window_ = NULL; | 132 active_window_ = NULL; |
| 132 SetActiveWindow(GetTopmostWindowToActivate(window), NULL); | 133 SetActiveWindow(GetTopmostWindowToActivate(window), NULL); |
| 133 } | 134 } |
| 134 | 135 |
| 135 Window* Desktop::GetTopmostWindowToActivate(Window* ignore) { | 136 Window* Desktop::GetTopmostWindowToActivate(Window* ignore) { |
| 136 Window::Windows windows(default_parent_->children()); | 137 Window::Windows windows(default_parent_->children()); |
| 137 for (Window::Windows::const_reverse_iterator i = windows.rbegin(); | 138 for (Window::Windows::const_reverse_iterator i = windows.rbegin(); |
| 138 i != windows.rend(); ++i) { | 139 i != windows.rend(); ++i) { |
| 139 if (*i != ignore && (*i)->visible() && | 140 if (*i != ignore && (*i)->IsVisible() && |
| 140 (*i)->delegate()->ShouldActivate(NULL)) | 141 (*i)->delegate()->ShouldActivate(NULL)) |
| 141 return *i; | 142 return *i; |
| 142 } | 143 } |
| 143 return NULL; | 144 return NULL; |
| 144 } | 145 } |
| 145 | 146 |
| 146 // static | 147 // static |
| 147 Desktop* Desktop::GetInstance() { | 148 Desktop* Desktop::GetInstance() { |
| 148 if (!instance_) { | 149 if (!instance_) { |
| 149 instance_ = new Desktop; | 150 instance_ = new Desktop; |
| 150 instance_->Init(); | 151 instance_->Init(); |
| 151 } | 152 } |
| 152 return instance_; | 153 return instance_; |
| 153 } | 154 } |
| 154 | 155 |
| 155 } // namespace aura | 156 } // namespace aura |
| OLD | NEW |