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/screen_accelerator_handler.h" | 10 #include "athena/screen/screen_accelerator_handler.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 196 |
197 void Init(); | 197 void Init(); |
198 | 198 |
199 private: | 199 private: |
200 // ScreenManager: | 200 // ScreenManager: |
201 virtual aura::Window* CreateDefaultContainer( | 201 virtual aura::Window* CreateDefaultContainer( |
202 const ContainerParams& params) OVERRIDE; | 202 const ContainerParams& params) OVERRIDE; |
203 virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE; | 203 virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE; |
204 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } | 204 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } |
205 virtual void SetRotation(gfx::Display::Rotation rotation) OVERRIDE; | 205 virtual void SetRotation(gfx::Display::Rotation rotation) OVERRIDE; |
| 206 virtual void SetRotationLocked(bool rotation_locked) OVERRIDE; |
206 virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE; | 207 virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE; |
207 | 208 |
208 // Not owned. | 209 // Not owned. |
209 aura::Window* root_window_; | 210 aura::Window* root_window_; |
210 | 211 |
211 scoped_ptr<aura::client::FocusClient> focus_client_; | 212 scoped_ptr<aura::client::FocusClient> focus_client_; |
212 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; | 213 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; |
213 scoped_ptr<AcceleratorHandler> accelerator_handler_; | 214 scoped_ptr<AcceleratorHandler> accelerator_handler_; |
214 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; | 215 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; |
215 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; | 216 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; |
216 | 217 |
| 218 gfx::Display::Rotation last_requested_rotation_; |
| 219 bool rotation_locked_; |
| 220 |
217 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); | 221 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); |
218 }; | 222 }; |
219 | 223 |
220 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) | 224 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) |
221 : root_window_(root_window) { | 225 : root_window_(root_window), |
| 226 last_requested_rotation_(gfx::Display::ROTATE_0), |
| 227 rotation_locked_(false) { |
222 DCHECK(root_window_); | 228 DCHECK(root_window_); |
223 DCHECK(!instance); | 229 DCHECK(!instance); |
224 instance = this; | 230 instance = this; |
225 } | 231 } |
226 | 232 |
227 ScreenManagerImpl::~ScreenManagerImpl() { | 233 ScreenManagerImpl::~ScreenManagerImpl() { |
228 aura::client::SetScreenPositionClient(root_window_, NULL); | 234 aura::client::SetScreenPositionClient(root_window_, NULL); |
229 aura::client::SetWindowTreeClient(root_window_, NULL); | 235 aura::client::SetWindowTreeClient(root_window_, NULL); |
230 wm::FocusController* focus_controller = | 236 wm::FocusController* focus_controller = |
231 static_cast<wm::FocusController*>(focus_client_.get()); | 237 static_cast<wm::FocusController*>(focus_client_.get()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 children.end(), | 328 children.end(), |
323 HigherPriorityFinder(params.z_order_priority)); | 329 HigherPriorityFinder(params.z_order_priority)); |
324 if (iter != children.end()) | 330 if (iter != children.end()) |
325 root_window_->StackChildBelow(container, *iter); | 331 root_window_->StackChildBelow(container, *iter); |
326 | 332 |
327 container->Show(); | 333 container->Show(); |
328 return container; | 334 return container; |
329 } | 335 } |
330 | 336 |
331 void ScreenManagerImpl::SetRotation(gfx::Display::Rotation rotation) { | 337 void ScreenManagerImpl::SetRotation(gfx::Display::Rotation rotation) { |
332 if (rotation == | 338 last_requested_rotation_ = rotation; |
| 339 if (rotation_locked_ || rotation == |
333 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation()) { | 340 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation()) { |
334 return; | 341 return; |
335 } | 342 } |
336 | 343 |
337 // TODO(flackr): Use display manager to update display rotation: | 344 // TODO(flackr): Use display manager to update display rotation: |
338 // http://crbug.com/401044. | 345 // http://crbug.com/401044. |
339 static_cast<aura::TestScreen*>(gfx::Screen::GetNativeScreen())-> | 346 static_cast<aura::TestScreen*>(gfx::Screen::GetNativeScreen())-> |
340 SetDisplayRotation(rotation); | 347 SetDisplayRotation(rotation); |
341 } | 348 } |
342 | 349 |
| 350 void ScreenManagerImpl::SetRotationLocked(bool rotation_locked) { |
| 351 rotation_locked_ = rotation_locked; |
| 352 if (!rotation_locked_) |
| 353 SetRotation(last_requested_rotation_); |
| 354 } |
| 355 |
343 ui::LayerAnimator* ScreenManagerImpl::GetScreenAnimator() { | 356 ui::LayerAnimator* ScreenManagerImpl::GetScreenAnimator() { |
344 return root_window_->layer()->GetAnimator(); | 357 return root_window_->layer()->GetAnimator(); |
345 } | 358 } |
346 | 359 |
347 } // namespace | 360 } // namespace |
348 | 361 |
349 ScreenManager::ContainerParams::ContainerParams(const std::string& n, | 362 ScreenManager::ContainerParams::ContainerParams(const std::string& n, |
350 int priority) | 363 int priority) |
351 : name(n), | 364 : name(n), |
352 can_activate_children(false), | 365 can_activate_children(false), |
(...skipping 15 matching lines...) Expand all Loading... |
368 } | 381 } |
369 | 382 |
370 // static | 383 // static |
371 void ScreenManager::Shutdown() { | 384 void ScreenManager::Shutdown() { |
372 DCHECK(instance); | 385 DCHECK(instance); |
373 delete instance; | 386 delete instance; |
374 DCHECK(!instance); | 387 DCHECK(!instance); |
375 } | 388 } |
376 | 389 |
377 } // namespace athena | 390 } // namespace athena |
OLD | NEW |