Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/screen/public/screen_manager.h" | 5 #include "athena/screen/public/screen_manager.h" |
| 6 | 6 |
| 7 #include "athena/input/public/accelerator_manager.h" | 7 #include "athena/input/public/accelerator_manager.h" |
| 8 #include "athena/screen/background_controller.h" | 8 #include "athena/screen/background_controller.h" |
| 9 #include "athena/screen/screen_accelerator_handler.h" | 9 #include "athena/screen/screen_accelerator_handler.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "ui/aura/client/screen_position_client.h" | |
| 12 #include "ui/aura/client/window_tree_client.h" | 13 #include "ui/aura/client/window_tree_client.h" |
| 13 #include "ui/aura/layout_manager.h" | 14 #include "ui/aura/layout_manager.h" |
| 14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 16 #include "ui/aura/window_tree_host.h" | |
| 15 #include "ui/wm/core/capture_controller.h" | 17 #include "ui/wm/core/capture_controller.h" |
| 16 | 18 |
| 17 namespace athena { | 19 namespace athena { |
| 18 namespace { | 20 namespace { |
| 19 | 21 |
| 20 ScreenManager* instance = NULL; | 22 ScreenManager* instance = NULL; |
| 21 | 23 |
| 22 // TODO(oshima): There seems to be a couple of private implementation which does | 24 // TODO(oshima): There seems to be a couple of private implementation which does |
| 23 // the same. | 25 // the same. |
| 24 // Consider consolidating and reuse it. | 26 // Consider consolidating and reuse it. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 aura::Window* window, | 71 aura::Window* window, |
| 70 const gfx::Rect& bounds) OVERRIDE { | 72 const gfx::Rect& bounds) OVERRIDE { |
| 71 return container_; | 73 return container_; |
| 72 } | 74 } |
| 73 | 75 |
| 74 aura::Window* container_; | 76 aura::Window* container_; |
| 75 | 77 |
| 76 DISALLOW_COPY_AND_ASSIGN(AthenaWindowTreeClient); | 78 DISALLOW_COPY_AND_ASSIGN(AthenaWindowTreeClient); |
| 77 }; | 79 }; |
| 78 | 80 |
| 81 class AthenaScreenPositionClient : public aura::client::ScreenPositionClient { | |
| 82 public: | |
| 83 AthenaScreenPositionClient() { | |
| 84 } | |
| 85 virtual ~AthenaScreenPositionClient() { | |
| 86 } | |
| 87 | |
| 88 private: | |
| 89 // aura::client::ScreenPositionClient: | |
| 90 virtual void ConvertPointToScreen(const aura::Window* window, | |
| 91 gfx::Point* point) OVERRIDE { | |
| 92 const aura::Window* root = window->GetRootWindow(); | |
| 93 aura::Window::ConvertPointToTarget(window, root, point); | |
| 94 } | |
| 95 | |
| 96 virtual void ConvertPointFromScreen(const aura::Window* window, | |
| 97 gfx::Point* point) OVERRIDE { | |
| 98 const aura::Window* root = window->GetRootWindow(); | |
| 99 aura::Window::ConvertPointToTarget(root, window, point); | |
| 100 } | |
| 101 | |
| 102 virtual void ConvertHostPointToScreen(aura::Window* window, | |
| 103 gfx::Point* point) OVERRIDE { | |
| 104 aura::Window* root = window->GetRootWindow(); | |
| 105 ConvertPointToScreen(root, point); | |
|
oshima
2014/06/19 18:22:46
can you leave this to NOTREACHED() and add
// TOD
sadrul
2014/06/19 22:24:52
Done.
| |
| 106 } | |
| 107 | |
| 108 virtual void SetBounds(aura::Window* window, | |
| 109 const gfx::Rect& bounds, | |
| 110 const gfx::Display& display) OVERRIDE { | |
| 111 window->SetBounds(bounds); | |
| 112 } | |
| 113 | |
| 114 DISALLOW_COPY_AND_ASSIGN(AthenaScreenPositionClient); | |
| 115 }; | |
| 116 | |
| 79 aura::Window* CreateContainerInternal(aura::Window* parent, | 117 aura::Window* CreateContainerInternal(aura::Window* parent, |
| 80 const std::string& name) { | 118 const std::string& name) { |
| 81 aura::Window* container = new aura::Window(NULL); | 119 aura::Window* container = new aura::Window(NULL); |
| 82 container->Init(aura::WINDOW_LAYER_NOT_DRAWN); | 120 container->Init(aura::WINDOW_LAYER_NOT_DRAWN); |
| 83 container->SetName(name); | 121 container->SetName(name); |
| 84 parent->AddChild(container); | 122 parent->AddChild(container); |
| 85 container->Show(); | 123 container->Show(); |
| 86 return container; | 124 return container; |
| 87 } | 125 } |
| 88 | 126 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 101 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } | 139 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } |
| 102 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE; | 140 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE; |
| 103 | 141 |
| 104 aura::Window* root_window_; | 142 aura::Window* root_window_; |
| 105 aura::Window* background_window_; | 143 aura::Window* background_window_; |
| 106 | 144 |
| 107 scoped_ptr<BackgroundController> background_controller_; | 145 scoped_ptr<BackgroundController> background_controller_; |
| 108 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; | 146 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; |
| 109 scoped_ptr<AcceleratorHandler> accelerator_handler_; | 147 scoped_ptr<AcceleratorHandler> accelerator_handler_; |
| 110 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; | 148 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; |
| 149 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; | |
| 111 | 150 |
| 112 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); | 151 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); |
| 113 }; | 152 }; |
| 114 | 153 |
| 115 void ScreenManagerImpl::Init() { | 154 void ScreenManagerImpl::Init() { |
| 116 root_window_->SetLayoutManager(new FillLayoutManager(root_window_)); | 155 root_window_->SetLayoutManager(new FillLayoutManager(root_window_)); |
| 117 background_window_ = | 156 background_window_ = |
| 118 CreateContainerInternal(root_window_, "AthenaBackground"); | 157 CreateContainerInternal(root_window_, "AthenaBackground"); |
| 119 background_window_->SetLayoutManager( | 158 background_window_->SetLayoutManager( |
| 120 new FillLayoutManager(background_window_)); | 159 new FillLayoutManager(background_window_)); |
| 121 background_controller_.reset(new BackgroundController(background_window_)); | 160 background_controller_.reset(new BackgroundController(background_window_)); |
| 122 | 161 |
| 123 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_)); | 162 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_)); |
| 124 accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_)); | 163 accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_)); |
| 125 } | 164 } |
| 126 | 165 |
| 127 aura::Window* ScreenManagerImpl::CreateDefaultContainer( | 166 aura::Window* ScreenManagerImpl::CreateDefaultContainer( |
| 128 const std::string& name) { | 167 const std::string& name) { |
| 129 aura::Window* container = CreateContainerInternal(root_window_, name); | 168 aura::Window* container = CreateContainerInternal(root_window_, name); |
| 130 window_tree_client_.reset(new AthenaWindowTreeClient(container)); | 169 window_tree_client_.reset(new AthenaWindowTreeClient(container)); |
| 131 aura::client::SetWindowTreeClient(root_window_, window_tree_client_.get()); | 170 aura::client::SetWindowTreeClient(root_window_, window_tree_client_.get()); |
| 171 | |
| 172 screen_position_client_.reset(new AthenaScreenPositionClient()); | |
| 173 aura::client::SetScreenPositionClient(root_window_, | |
| 174 screen_position_client_.get()); | |
| 175 | |
| 132 return container; | 176 return container; |
| 133 } | 177 } |
| 134 | 178 |
| 135 aura::Window* ScreenManagerImpl::CreateContainer(const std::string& name) { | 179 aura::Window* ScreenManagerImpl::CreateContainer(const std::string& name) { |
| 136 return CreateContainerInternal(root_window_, name); | 180 return CreateContainerInternal(root_window_, name); |
| 137 } | 181 } |
| 138 | 182 |
| 139 void ScreenManagerImpl::SetBackgroundImage(const gfx::ImageSkia& image) { | 183 void ScreenManagerImpl::SetBackgroundImage(const gfx::ImageSkia& image) { |
| 140 background_controller_->SetImage(image); | 184 background_controller_->SetImage(image); |
| 141 } | 185 } |
| 142 | 186 |
| 143 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) | 187 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) |
| 144 : root_window_(root_window) { | 188 : root_window_(root_window) { |
| 145 DCHECK(root_window_); | 189 DCHECK(root_window_); |
| 146 DCHECK(!instance); | 190 DCHECK(!instance); |
| 147 instance = this; | 191 instance = this; |
| 148 } | 192 } |
| 149 | 193 |
| 150 ScreenManagerImpl::~ScreenManagerImpl() { | 194 ScreenManagerImpl::~ScreenManagerImpl() { |
| 195 aura::client::SetScreenPositionClient(root_window_, NULL); | |
| 151 aura::client::SetWindowTreeClient(root_window_, NULL); | 196 aura::client::SetWindowTreeClient(root_window_, NULL); |
| 152 instance = NULL; | 197 instance = NULL; |
| 153 } | 198 } |
| 154 | 199 |
| 155 } // namespace | 200 } // namespace |
| 156 | 201 |
| 157 // static | 202 // static |
| 158 ScreenManager* ScreenManager::Create(aura::Window* root_window) { | 203 ScreenManager* ScreenManager::Create(aura::Window* root_window) { |
| 159 (new ScreenManagerImpl(root_window))->Init(); | 204 (new ScreenManagerImpl(root_window))->Init(); |
| 160 DCHECK(instance); | 205 DCHECK(instance); |
| 161 return instance; | 206 return instance; |
| 162 } | 207 } |
| 163 | 208 |
| 164 // static | 209 // static |
| 165 ScreenManager* ScreenManager::Get() { | 210 ScreenManager* ScreenManager::Get() { |
| 166 DCHECK(instance); | 211 DCHECK(instance); |
| 167 return instance; | 212 return instance; |
| 168 } | 213 } |
| 169 | 214 |
| 170 // static | 215 // static |
| 171 void ScreenManager::Shutdown() { | 216 void ScreenManager::Shutdown() { |
| 172 DCHECK(instance); | 217 DCHECK(instance); |
| 173 delete instance; | 218 delete instance; |
| 174 DCHECK(!instance); | 219 DCHECK(!instance); |
| 175 } | 220 } |
| 176 | 221 |
| 177 } // namespace athena | 222 } // namespace athena |
| OLD | NEW |