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" | |
11 #include "athena/screen/screen_accelerator_handler.h" | 10 #include "athena/screen/screen_accelerator_handler.h" |
12 #include "base/logging.h" | 11 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
14 #include "ui/aura/client/screen_position_client.h" | 13 #include "ui/aura/client/screen_position_client.h" |
15 #include "ui/aura/client/window_tree_client.h" | 14 #include "ui/aura/client/window_tree_client.h" |
16 #include "ui/aura/layout_manager.h" | 15 #include "ui/aura/layout_manager.h" |
17 #include "ui/aura/test/test_screen.h" | 16 #include "ui/aura/test/test_screen.h" |
18 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
19 #include "ui/aura/window_property.h" | 18 #include "ui/aura/window_property.h" |
20 #include "ui/aura/window_targeter.h" | 19 #include "ui/aura/window_targeter.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 virtual ~ScreenManagerImpl(); | 194 virtual ~ScreenManagerImpl(); |
196 | 195 |
197 void Init(); | 196 void Init(); |
198 | 197 |
199 private: | 198 private: |
200 // ScreenManager: | 199 // ScreenManager: |
201 virtual aura::Window* CreateDefaultContainer( | 200 virtual aura::Window* CreateDefaultContainer( |
202 const ContainerParams& params) OVERRIDE; | 201 const ContainerParams& params) OVERRIDE; |
203 virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE; | 202 virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE; |
204 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } | 203 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } |
205 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE; | |
206 virtual void SetRotation(gfx::Display::Rotation rotation) OVERRIDE; | 204 virtual void SetRotation(gfx::Display::Rotation rotation) OVERRIDE; |
207 virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE; | 205 virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE; |
208 | 206 |
209 aura::Window* root_window_; | 207 aura::Window* root_window_; |
210 aura::Window* background_window_; | |
211 | 208 |
212 scoped_ptr<BackgroundController> background_controller_; | |
213 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; | 209 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; |
214 scoped_ptr<AcceleratorHandler> accelerator_handler_; | 210 scoped_ptr<AcceleratorHandler> accelerator_handler_; |
215 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; | 211 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; |
216 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; | 212 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; |
217 | 213 |
218 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); | 214 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); |
219 }; | 215 }; |
220 | 216 |
221 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) | 217 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) |
222 : root_window_(root_window) { | 218 : root_window_(root_window) { |
223 DCHECK(root_window_); | 219 DCHECK(root_window_); |
224 DCHECK(!instance); | 220 DCHECK(!instance); |
225 instance = this; | 221 instance = this; |
226 } | 222 } |
227 | 223 |
228 ScreenManagerImpl::~ScreenManagerImpl() { | 224 ScreenManagerImpl::~ScreenManagerImpl() { |
229 aura::client::SetScreenPositionClient(root_window_, NULL); | 225 aura::client::SetScreenPositionClient(root_window_, NULL); |
230 aura::client::SetWindowTreeClient(root_window_, NULL); | 226 aura::client::SetWindowTreeClient(root_window_, NULL); |
231 instance = NULL; | 227 instance = NULL; |
232 } | 228 } |
233 | 229 |
234 void ScreenManagerImpl::Init() { | 230 void ScreenManagerImpl::Init() { |
235 // TODO(oshima): Move the background out from ScreenManager. | 231 // TODO(oshima): Move the background out from ScreenManager. |
236 root_window_->SetLayoutManager(new FillLayoutManager(root_window_)); | 232 root_window_->SetLayoutManager(new FillLayoutManager(root_window_)); |
237 background_window_ = | |
238 CreateContainer(ContainerParams("AthenaBackground", CP_BACKGROUND)); | |
239 | |
240 background_window_->SetLayoutManager( | |
241 new FillLayoutManager(background_window_)); | |
242 background_controller_.reset(new BackgroundController(background_window_)); | |
243 | |
244 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_)); | 233 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_)); |
245 accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_)); | 234 accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_)); |
246 } | 235 } |
247 | 236 |
248 aura::Window* ScreenManagerImpl::CreateDefaultContainer( | 237 aura::Window* ScreenManagerImpl::CreateDefaultContainer( |
249 const ContainerParams& params) { | 238 const ContainerParams& params) { |
250 aura::Window* container = CreateContainer(params); | 239 aura::Window* container = CreateContainer(params); |
251 window_tree_client_.reset(new AthenaWindowTreeClient(container)); | 240 window_tree_client_.reset(new AthenaWindowTreeClient(container)); |
252 aura::client::SetWindowTreeClient(root_window_, window_tree_client_.get()); | 241 aura::client::SetWindowTreeClient(root_window_, window_tree_client_.get()); |
253 | 242 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 std::find_if(children.begin(), | 306 std::find_if(children.begin(), |
318 children.end(), | 307 children.end(), |
319 HigherPriorityFinder(params.z_order_priority)); | 308 HigherPriorityFinder(params.z_order_priority)); |
320 if (iter != children.end()) | 309 if (iter != children.end()) |
321 root_window_->StackChildBelow(container, *iter); | 310 root_window_->StackChildBelow(container, *iter); |
322 | 311 |
323 container->Show(); | 312 container->Show(); |
324 return container; | 313 return container; |
325 } | 314 } |
326 | 315 |
327 void ScreenManagerImpl::SetBackgroundImage(const gfx::ImageSkia& image) { | |
328 background_controller_->SetImage(image); | |
329 } | |
330 | |
331 void ScreenManagerImpl::SetRotation(gfx::Display::Rotation rotation) { | 316 void ScreenManagerImpl::SetRotation(gfx::Display::Rotation rotation) { |
332 if (rotation == | 317 if (rotation == |
333 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation()) { | 318 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation()) { |
334 return; | 319 return; |
335 } | 320 } |
336 | 321 |
337 // TODO(flackr): Use display manager to update display rotation: | 322 // TODO(flackr): Use display manager to update display rotation: |
338 // http://crbug.com/401044. | 323 // http://crbug.com/401044. |
339 static_cast<aura::TestScreen*>(gfx::Screen::GetNativeScreen())-> | 324 static_cast<aura::TestScreen*>(gfx::Screen::GetNativeScreen())-> |
340 SetDisplayRotation(rotation); | 325 SetDisplayRotation(rotation); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 delete instance; | 358 delete instance; |
374 DCHECK(!instance); | 359 DCHECK(!instance); |
375 } | 360 } |
376 | 361 |
377 // static | 362 // static |
378 wm::FocusRules* ScreenManager::CreateFocusRules() { | 363 wm::FocusRules* ScreenManager::CreateFocusRules() { |
379 return new AthenaFocusRules(); | 364 return new AthenaFocusRules(); |
380 } | 365 } |
381 | 366 |
382 } // namespace athena | 367 } // namespace athena |
OLD | NEW |