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/common/container_priorities.h" | 7 #include "athena/common/container_priorities.h" |
| 8 #include "athena/common/fill_layout_manager.h" | 8 #include "athena/common/fill_layout_manager.h" |
| 9 #include "athena/input/public/accelerator_manager.h" | 9 #include "athena/input/public/accelerator_manager.h" |
| 10 #include "athena/screen/background_controller.h" | 10 #include "athena/screen/background_controller.h" |
| 11 #include "athena/screen/public/screen_manager_delegate.h" | |
| 11 #include "athena/screen/screen_accelerator_handler.h" | 12 #include "athena/screen/screen_accelerator_handler.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "ui/aura/client/screen_position_client.h" | 15 #include "ui/aura/client/screen_position_client.h" |
| 15 #include "ui/aura/client/window_tree_client.h" | 16 #include "ui/aura/client/window_tree_client.h" |
| 16 #include "ui/aura/layout_manager.h" | 17 #include "ui/aura/layout_manager.h" |
| 17 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 18 #include "ui/aura/window_property.h" | 19 #include "ui/aura/window_property.h" |
| 19 #include "ui/aura/window_targeter.h" | 20 #include "ui/aura/window_targeter.h" |
| 20 #include "ui/aura/window_tree_host.h" | 21 #include "ui/aura/window_tree_host.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>()); | 182 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>()); |
| 182 } | 183 } |
| 183 | 184 |
| 184 aura::Window* container_; | 185 aura::Window* container_; |
| 185 | 186 |
| 186 DISALLOW_COPY_AND_ASSIGN(AthenaEventTargeter); | 187 DISALLOW_COPY_AND_ASSIGN(AthenaEventTargeter); |
| 187 }; | 188 }; |
| 188 | 189 |
| 189 class ScreenManagerImpl : public ScreenManager { | 190 class ScreenManagerImpl : public ScreenManager { |
| 190 public: | 191 public: |
| 191 explicit ScreenManagerImpl(aura::Window* root_window); | 192 explicit ScreenManagerImpl(ScreenManagerDelegate* delegate, |
|
sadrul
2014/08/14 21:25:19
Remove explicit
| |
| 193 aura::Window* root_window); | |
| 192 virtual ~ScreenManagerImpl(); | 194 virtual ~ScreenManagerImpl(); |
| 193 | 195 |
| 194 void Init(); | 196 void Init(); |
| 195 | 197 |
| 196 private: | 198 private: |
| 197 // ScreenManager: | 199 // ScreenManager: |
| 200 virtual void SetWorkAreaInsets(const gfx::Insets& insets) OVERRIDE; | |
| 198 virtual aura::Window* CreateDefaultContainer( | 201 virtual aura::Window* CreateDefaultContainer( |
| 199 const ContainerParams& params) OVERRIDE; | 202 const ContainerParams& params) OVERRIDE; |
| 200 virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE; | 203 virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE; |
| 201 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } | 204 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } |
| 202 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE; | 205 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE; |
| 203 virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE; | 206 virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE; |
| 204 | 207 |
| 208 // Not owned. | |
| 209 ScreenManagerDelegate* delegate_; | |
| 205 aura::Window* root_window_; | 210 aura::Window* root_window_; |
| 206 aura::Window* background_window_; | 211 aura::Window* background_window_; |
| 207 | 212 |
| 208 scoped_ptr<BackgroundController> background_controller_; | 213 scoped_ptr<BackgroundController> background_controller_; |
| 209 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; | 214 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; |
| 210 scoped_ptr<AcceleratorHandler> accelerator_handler_; | 215 scoped_ptr<AcceleratorHandler> accelerator_handler_; |
| 211 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; | 216 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; |
| 212 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; | 217 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; |
| 213 | 218 |
| 214 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); | 219 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); |
| 215 }; | 220 }; |
| 216 | 221 |
| 217 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) | 222 ScreenManagerImpl::ScreenManagerImpl(ScreenManagerDelegate* delegate, |
| 218 : root_window_(root_window) { | 223 aura::Window* root_window) |
| 224 : delegate_(delegate), | |
| 225 root_window_(root_window) { | |
| 219 DCHECK(root_window_); | 226 DCHECK(root_window_); |
| 220 DCHECK(!instance); | 227 DCHECK(!instance); |
| 221 instance = this; | 228 instance = this; |
| 222 } | 229 } |
| 223 | 230 |
| 224 ScreenManagerImpl::~ScreenManagerImpl() { | 231 ScreenManagerImpl::~ScreenManagerImpl() { |
| 225 aura::client::SetScreenPositionClient(root_window_, NULL); | 232 aura::client::SetScreenPositionClient(root_window_, NULL); |
| 226 aura::client::SetWindowTreeClient(root_window_, NULL); | 233 aura::client::SetWindowTreeClient(root_window_, NULL); |
| 227 instance = NULL; | 234 instance = NULL; |
| 228 } | 235 } |
| 229 | 236 |
| 230 void ScreenManagerImpl::Init() { | 237 void ScreenManagerImpl::Init() { |
| 231 // TODO(oshima): Move the background out from ScreenManager. | 238 // TODO(oshima): Move the background out from ScreenManager. |
| 232 root_window_->SetLayoutManager(new FillLayoutManager(root_window_)); | 239 root_window_->SetLayoutManager(new FillLayoutManager(root_window_)); |
| 233 background_window_ = | 240 background_window_ = |
| 234 CreateContainer(ContainerParams("AthenaBackground", CP_BACKGROUND)); | 241 CreateContainer(ContainerParams("AthenaBackground", CP_BACKGROUND)); |
| 235 | 242 |
| 236 background_window_->SetLayoutManager( | 243 background_window_->SetLayoutManager( |
| 237 new FillLayoutManager(background_window_)); | 244 new FillLayoutManager(background_window_)); |
| 238 background_controller_.reset(new BackgroundController(background_window_)); | 245 background_controller_.reset(new BackgroundController(background_window_)); |
| 239 | 246 |
| 240 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_)); | 247 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_)); |
| 241 accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_)); | 248 accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_)); |
| 242 } | 249 } |
| 243 | 250 |
| 251 void ScreenManagerImpl::SetWorkAreaInsets(const gfx::Insets& insets) { | |
| 252 delegate_->SetWorkAreaInsets(insets); | |
| 253 } | |
| 254 | |
| 244 aura::Window* ScreenManagerImpl::CreateDefaultContainer( | 255 aura::Window* ScreenManagerImpl::CreateDefaultContainer( |
| 245 const ContainerParams& params) { | 256 const ContainerParams& params) { |
| 246 aura::Window* container = CreateContainer(params); | 257 aura::Window* container = CreateContainer(params); |
| 247 window_tree_client_.reset(new AthenaWindowTreeClient(container)); | 258 window_tree_client_.reset(new AthenaWindowTreeClient(container)); |
| 248 aura::client::SetWindowTreeClient(root_window_, window_tree_client_.get()); | 259 aura::client::SetWindowTreeClient(root_window_, window_tree_client_.get()); |
| 249 | 260 |
| 250 screen_position_client_.reset(new AthenaScreenPositionClient()); | 261 screen_position_client_.reset(new AthenaScreenPositionClient()); |
| 251 aura::client::SetScreenPositionClient(root_window_, | 262 aura::client::SetScreenPositionClient(root_window_, |
| 252 screen_position_client_.get()); | 263 screen_position_client_.get()); |
| 253 | 264 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 | 343 |
| 333 ScreenManager::ContainerParams::ContainerParams(const std::string& n, | 344 ScreenManager::ContainerParams::ContainerParams(const std::string& n, |
| 334 int priority) | 345 int priority) |
| 335 : name(n), | 346 : name(n), |
| 336 can_activate_children(false), | 347 can_activate_children(false), |
| 337 grab_inputs(false), | 348 grab_inputs(false), |
| 338 z_order_priority(priority) { | 349 z_order_priority(priority) { |
| 339 } | 350 } |
| 340 | 351 |
| 341 // static | 352 // static |
| 342 ScreenManager* ScreenManager::Create(aura::Window* root_window) { | 353 ScreenManager* ScreenManager::Create(ScreenManagerDelegate* delegate, |
| 343 (new ScreenManagerImpl(root_window))->Init(); | 354 aura::Window* root_window) { |
| 355 (new ScreenManagerImpl(delegate, root_window))->Init(); | |
| 344 DCHECK(instance); | 356 DCHECK(instance); |
| 345 return instance; | 357 return instance; |
| 346 } | 358 } |
| 347 | 359 |
| 348 // static | 360 // static |
| 349 ScreenManager* ScreenManager::Get() { | 361 ScreenManager* ScreenManager::Get() { |
| 350 DCHECK(instance); | 362 DCHECK(instance); |
| 351 return instance; | 363 return instance; |
| 352 } | 364 } |
| 353 | 365 |
| 354 // static | 366 // static |
| 355 void ScreenManager::Shutdown() { | 367 void ScreenManager::Shutdown() { |
| 356 DCHECK(instance); | 368 DCHECK(instance); |
| 357 delete instance; | 369 delete instance; |
| 358 DCHECK(!instance); | 370 DCHECK(!instance); |
| 359 } | 371 } |
| 360 | 372 |
| 361 // static | 373 // static |
| 362 wm::FocusRules* ScreenManager::CreateFocusRules() { | 374 wm::FocusRules* ScreenManager::CreateFocusRules() { |
| 363 return new AthenaFocusRules(); | 375 return new AthenaFocusRules(); |
| 364 } | 376 } |
| 365 | 377 |
| 366 } // namespace athena | 378 } // namespace athena |
| OLD | NEW |