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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>()); | 184 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>()); |
186 } | 185 } |
187 | 186 |
188 aura::Window* container_; | 187 aura::Window* container_; |
189 | 188 |
190 DISALLOW_COPY_AND_ASSIGN(AthenaEventTargeter); | 189 DISALLOW_COPY_AND_ASSIGN(AthenaEventTargeter); |
191 }; | 190 }; |
192 | 191 |
193 class ScreenManagerImpl : public ScreenManager { | 192 class ScreenManagerImpl : public ScreenManager { |
194 public: | 193 public: |
195 ScreenManagerImpl(aura::Window* root_window); | 194 explicit ScreenManagerImpl(aura::Window* root_window); |
196 virtual ~ScreenManagerImpl(); | 195 virtual ~ScreenManagerImpl(); |
197 | 196 |
198 void Init(); | 197 void Init(); |
199 | 198 |
200 private: | 199 private: |
201 // ScreenManager: | 200 // ScreenManager: |
202 virtual aura::Window* CreateDefaultContainer( | 201 virtual aura::Window* CreateDefaultContainer( |
203 const ContainerParams& params) OVERRIDE; | 202 const ContainerParams& params) OVERRIDE; |
204 virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE; | 203 virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE; |
205 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } | 204 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } |
206 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE; | |
207 virtual void SetRotation(gfx::Display::Rotation rotation) OVERRIDE; | 205 virtual void SetRotation(gfx::Display::Rotation rotation) OVERRIDE; |
208 virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE; | 206 virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE; |
209 | 207 |
210 // Not owned. | 208 // Not owned. |
211 aura::Window* root_window_; | 209 aura::Window* root_window_; |
212 aura::Window* background_window_; | |
213 | 210 |
214 scoped_ptr<aura::client::FocusClient> focus_client_; | 211 scoped_ptr<aura::client::FocusClient> focus_client_; |
215 scoped_ptr<BackgroundController> background_controller_; | |
216 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; | 212 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; |
217 scoped_ptr<AcceleratorHandler> accelerator_handler_; | 213 scoped_ptr<AcceleratorHandler> accelerator_handler_; |
218 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; | 214 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; |
219 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; | 215 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; |
220 | 216 |
221 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); | 217 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); |
222 }; | 218 }; |
223 | 219 |
224 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) | 220 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) |
225 : root_window_(root_window) { | 221 : root_window_(root_window) { |
(...skipping 15 matching lines...) Expand all Loading... |
241 | 237 |
242 void ScreenManagerImpl::Init() { | 238 void ScreenManagerImpl::Init() { |
243 wm::FocusController* focus_controller = | 239 wm::FocusController* focus_controller = |
244 new wm::FocusController(new AthenaFocusRules()); | 240 new wm::FocusController(new AthenaFocusRules()); |
245 | 241 |
246 aura::client::SetFocusClient(root_window_, focus_controller); | 242 aura::client::SetFocusClient(root_window_, focus_controller); |
247 root_window_->AddPreTargetHandler(focus_controller); | 243 root_window_->AddPreTargetHandler(focus_controller); |
248 aura::client::SetActivationClient(root_window_, focus_controller); | 244 aura::client::SetActivationClient(root_window_, focus_controller); |
249 focus_client_.reset(focus_controller); | 245 focus_client_.reset(focus_controller); |
250 | 246 |
251 // TODO(oshima): Move the background out from ScreenManager. | |
252 root_window_->SetLayoutManager(new FillLayoutManager(root_window_)); | 247 root_window_->SetLayoutManager(new FillLayoutManager(root_window_)); |
253 background_window_ = | |
254 CreateContainer(ContainerParams("AthenaBackground", CP_BACKGROUND)); | |
255 | |
256 background_window_->SetLayoutManager( | |
257 new FillLayoutManager(background_window_)); | |
258 background_controller_.reset(new BackgroundController(background_window_)); | |
259 | |
260 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_)); | 248 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_)); |
261 accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_)); | 249 accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_)); |
262 } | 250 } |
263 | 251 |
264 aura::Window* ScreenManagerImpl::CreateDefaultContainer( | 252 aura::Window* ScreenManagerImpl::CreateDefaultContainer( |
265 const ContainerParams& params) { | 253 const ContainerParams& params) { |
266 aura::Window* container = CreateContainer(params); | 254 aura::Window* container = CreateContainer(params); |
267 window_tree_client_.reset(new AthenaWindowTreeClient(container)); | 255 window_tree_client_.reset(new AthenaWindowTreeClient(container)); |
268 aura::client::SetWindowTreeClient(root_window_, window_tree_client_.get()); | 256 aura::client::SetWindowTreeClient(root_window_, window_tree_client_.get()); |
269 | 257 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 std::find_if(children.begin(), | 321 std::find_if(children.begin(), |
334 children.end(), | 322 children.end(), |
335 HigherPriorityFinder(params.z_order_priority)); | 323 HigherPriorityFinder(params.z_order_priority)); |
336 if (iter != children.end()) | 324 if (iter != children.end()) |
337 root_window_->StackChildBelow(container, *iter); | 325 root_window_->StackChildBelow(container, *iter); |
338 | 326 |
339 container->Show(); | 327 container->Show(); |
340 return container; | 328 return container; |
341 } | 329 } |
342 | 330 |
343 void ScreenManagerImpl::SetBackgroundImage(const gfx::ImageSkia& image) { | |
344 background_controller_->SetImage(image); | |
345 } | |
346 | |
347 void ScreenManagerImpl::SetRotation(gfx::Display::Rotation rotation) { | 331 void ScreenManagerImpl::SetRotation(gfx::Display::Rotation rotation) { |
348 if (rotation == | 332 if (rotation == |
349 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation()) { | 333 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation()) { |
350 return; | 334 return; |
351 } | 335 } |
352 | 336 |
353 // TODO(flackr): Use display manager to update display rotation: | 337 // TODO(flackr): Use display manager to update display rotation: |
354 // http://crbug.com/401044. | 338 // http://crbug.com/401044. |
355 static_cast<aura::TestScreen*>(gfx::Screen::GetNativeScreen())-> | 339 static_cast<aura::TestScreen*>(gfx::Screen::GetNativeScreen())-> |
356 SetDisplayRotation(rotation); | 340 SetDisplayRotation(rotation); |
(...skipping 27 matching lines...) Expand all Loading... |
384 } | 368 } |
385 | 369 |
386 // static | 370 // static |
387 void ScreenManager::Shutdown() { | 371 void ScreenManager::Shutdown() { |
388 DCHECK(instance); | 372 DCHECK(instance); |
389 delete instance; | 373 delete instance; |
390 DCHECK(!instance); | 374 DCHECK(!instance); |
391 } | 375 } |
392 | 376 |
393 } // namespace athena | 377 } // namespace athena |
OLD | NEW |