| 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/test/test_screen.h" | 18 #include "ui/aura/test/test_screen.h" |
| 18 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
| 19 #include "ui/aura/window_property.h" | 20 #include "ui/aura/window_property.h" |
| 20 #include "ui/aura/window_targeter.h" | 21 #include "ui/aura/window_targeter.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>()); | 185 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>()); |
| 185 } | 186 } |
| 186 | 187 |
| 187 aura::Window* container_; | 188 aura::Window* container_; |
| 188 | 189 |
| 189 DISALLOW_COPY_AND_ASSIGN(AthenaEventTargeter); | 190 DISALLOW_COPY_AND_ASSIGN(AthenaEventTargeter); |
| 190 }; | 191 }; |
| 191 | 192 |
| 192 class ScreenManagerImpl : public ScreenManager { | 193 class ScreenManagerImpl : public ScreenManager { |
| 193 public: | 194 public: |
| 194 explicit ScreenManagerImpl(aura::Window* root_window); | 195 ScreenManagerImpl(ScreenManagerDelegate* delegate, aura::Window* root_window); |
| 195 virtual ~ScreenManagerImpl(); | 196 virtual ~ScreenManagerImpl(); |
| 196 | 197 |
| 197 void Init(); | 198 void Init(); |
| 198 | 199 |
| 199 private: | 200 private: |
| 200 // ScreenManager: | 201 // ScreenManager: |
| 202 virtual void SetWorkAreaInsets(const gfx::Insets& insets) OVERRIDE; |
| 201 virtual aura::Window* CreateDefaultContainer( | 203 virtual aura::Window* CreateDefaultContainer( |
| 202 const ContainerParams& params) OVERRIDE; | 204 const ContainerParams& params) OVERRIDE; |
| 203 virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE; | 205 virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE; |
| 204 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } | 206 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } |
| 205 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE; | 207 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE; |
| 206 virtual void SetRotation(gfx::Display::Rotation rotation) OVERRIDE; | 208 virtual void SetRotation(gfx::Display::Rotation rotation) OVERRIDE; |
| 207 virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE; | 209 virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE; |
| 208 | 210 |
| 211 // Not owned. |
| 212 ScreenManagerDelegate* delegate_; |
| 209 aura::Window* root_window_; | 213 aura::Window* root_window_; |
| 210 aura::Window* background_window_; | 214 aura::Window* background_window_; |
| 211 | 215 |
| 212 scoped_ptr<BackgroundController> background_controller_; | 216 scoped_ptr<BackgroundController> background_controller_; |
| 213 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; | 217 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; |
| 214 scoped_ptr<AcceleratorHandler> accelerator_handler_; | 218 scoped_ptr<AcceleratorHandler> accelerator_handler_; |
| 215 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; | 219 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; |
| 216 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; | 220 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; |
| 217 | 221 |
| 218 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); | 222 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); |
| 219 }; | 223 }; |
| 220 | 224 |
| 221 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) | 225 ScreenManagerImpl::ScreenManagerImpl(ScreenManagerDelegate* delegate, |
| 222 : root_window_(root_window) { | 226 aura::Window* root_window) |
| 227 : delegate_(delegate), |
| 228 root_window_(root_window) { |
| 223 DCHECK(root_window_); | 229 DCHECK(root_window_); |
| 224 DCHECK(!instance); | 230 DCHECK(!instance); |
| 225 instance = this; | 231 instance = this; |
| 226 } | 232 } |
| 227 | 233 |
| 228 ScreenManagerImpl::~ScreenManagerImpl() { | 234 ScreenManagerImpl::~ScreenManagerImpl() { |
| 229 aura::client::SetScreenPositionClient(root_window_, NULL); | 235 aura::client::SetScreenPositionClient(root_window_, NULL); |
| 230 aura::client::SetWindowTreeClient(root_window_, NULL); | 236 aura::client::SetWindowTreeClient(root_window_, NULL); |
| 231 instance = NULL; | 237 instance = NULL; |
| 232 } | 238 } |
| 233 | 239 |
| 234 void ScreenManagerImpl::Init() { | 240 void ScreenManagerImpl::Init() { |
| 235 // TODO(oshima): Move the background out from ScreenManager. | 241 // TODO(oshima): Move the background out from ScreenManager. |
| 236 root_window_->SetLayoutManager(new FillLayoutManager(root_window_)); | 242 root_window_->SetLayoutManager(new FillLayoutManager(root_window_)); |
| 237 background_window_ = | 243 background_window_ = |
| 238 CreateContainer(ContainerParams("AthenaBackground", CP_BACKGROUND)); | 244 CreateContainer(ContainerParams("AthenaBackground", CP_BACKGROUND)); |
| 239 | 245 |
| 240 background_window_->SetLayoutManager( | 246 background_window_->SetLayoutManager( |
| 241 new FillLayoutManager(background_window_)); | 247 new FillLayoutManager(background_window_)); |
| 242 background_controller_.reset(new BackgroundController(background_window_)); | 248 background_controller_.reset(new BackgroundController(background_window_)); |
| 243 | 249 |
| 244 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_)); | 250 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_)); |
| 245 accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_)); | 251 accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_)); |
| 246 } | 252 } |
| 247 | 253 |
| 254 void ScreenManagerImpl::SetWorkAreaInsets(const gfx::Insets& insets) { |
| 255 delegate_->SetWorkAreaInsets(insets); |
| 256 } |
| 257 |
| 248 aura::Window* ScreenManagerImpl::CreateDefaultContainer( | 258 aura::Window* ScreenManagerImpl::CreateDefaultContainer( |
| 249 const ContainerParams& params) { | 259 const ContainerParams& params) { |
| 250 aura::Window* container = CreateContainer(params); | 260 aura::Window* container = CreateContainer(params); |
| 251 window_tree_client_.reset(new AthenaWindowTreeClient(container)); | 261 window_tree_client_.reset(new AthenaWindowTreeClient(container)); |
| 252 aura::client::SetWindowTreeClient(root_window_, window_tree_client_.get()); | 262 aura::client::SetWindowTreeClient(root_window_, window_tree_client_.get()); |
| 253 | 263 |
| 254 screen_position_client_.reset(new AthenaScreenPositionClient()); | 264 screen_position_client_.reset(new AthenaScreenPositionClient()); |
| 255 aura::client::SetScreenPositionClient(root_window_, | 265 aura::client::SetScreenPositionClient(root_window_, |
| 256 screen_position_client_.get()); | 266 screen_position_client_.get()); |
| 257 | 267 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 | 358 |
| 349 ScreenManager::ContainerParams::ContainerParams(const std::string& n, | 359 ScreenManager::ContainerParams::ContainerParams(const std::string& n, |
| 350 int priority) | 360 int priority) |
| 351 : name(n), | 361 : name(n), |
| 352 can_activate_children(false), | 362 can_activate_children(false), |
| 353 grab_inputs(false), | 363 grab_inputs(false), |
| 354 z_order_priority(priority) { | 364 z_order_priority(priority) { |
| 355 } | 365 } |
| 356 | 366 |
| 357 // static | 367 // static |
| 358 ScreenManager* ScreenManager::Create(aura::Window* root_window) { | 368 ScreenManager* ScreenManager::Create(ScreenManagerDelegate* delegate, |
| 359 (new ScreenManagerImpl(root_window))->Init(); | 369 aura::Window* root_window) { |
| 370 (new ScreenManagerImpl(delegate, root_window))->Init(); |
| 360 DCHECK(instance); | 371 DCHECK(instance); |
| 361 return instance; | 372 return instance; |
| 362 } | 373 } |
| 363 | 374 |
| 364 // static | 375 // static |
| 365 ScreenManager* ScreenManager::Get() { | 376 ScreenManager* ScreenManager::Get() { |
| 366 DCHECK(instance); | 377 DCHECK(instance); |
| 367 return instance; | 378 return instance; |
| 368 } | 379 } |
| 369 | 380 |
| 370 // static | 381 // static |
| 371 void ScreenManager::Shutdown() { | 382 void ScreenManager::Shutdown() { |
| 372 DCHECK(instance); | 383 DCHECK(instance); |
| 373 delete instance; | 384 delete instance; |
| 374 DCHECK(!instance); | 385 DCHECK(!instance); |
| 375 } | 386 } |
| 376 | 387 |
| 377 // static | 388 // static |
| 378 wm::FocusRules* ScreenManager::CreateFocusRules() { | 389 wm::FocusRules* ScreenManager::CreateFocusRules() { |
| 379 return new AthenaFocusRules(); | 390 return new AthenaFocusRules(); |
| 380 } | 391 } |
| 381 | 392 |
| 382 } // namespace athena | 393 } // namespace athena |
| OLD | NEW |