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" |
(...skipping 18 matching lines...) Expand all Loading... | |
29 NULL); | 29 NULL); |
30 | 30 |
31 ScreenManager* instance = NULL; | 31 ScreenManager* instance = NULL; |
32 | 32 |
33 bool GrabsInput(aura::Window* container) { | 33 bool GrabsInput(aura::Window* container) { |
34 ScreenManager::ContainerParams* params = | 34 ScreenManager::ContainerParams* params = |
35 container->GetProperty(kContainerParamsKey); | 35 container->GetProperty(kContainerParamsKey); |
36 return params && params->grab_inputs; | 36 return params && params->grab_inputs; |
37 } | 37 } |
38 | 38 |
39 bool IsRotationPortrait(gfx::Display::Rotation rotation) { | |
40 return rotation == gfx::Display::ROTATE_90 || | |
41 rotation == gfx::Display::ROTATE_270; | |
42 } | |
43 | |
39 // Returns the container which contains |window|. | 44 // Returns the container which contains |window|. |
40 aura::Window* GetContainer(aura::Window* window) { | 45 aura::Window* GetContainer(aura::Window* window) { |
41 // No containers for NULL or the root window itself. | 46 // No containers for NULL or the root window itself. |
42 if (!window || !window->parent()) | 47 if (!window || !window->parent()) |
43 return NULL; | 48 return NULL; |
44 if (window->parent()->IsRootWindow()) | 49 if (window->parent()->IsRootWindow()) |
45 return window; | 50 return window; |
46 return GetContainer(window->parent()); | 51 return GetContainer(window->parent()); |
47 } | 52 } |
48 | 53 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 | 197 |
193 void Init(); | 198 void Init(); |
194 | 199 |
195 private: | 200 private: |
196 // ScreenManager: | 201 // ScreenManager: |
197 virtual aura::Window* CreateDefaultContainer( | 202 virtual aura::Window* CreateDefaultContainer( |
198 const ContainerParams& params) OVERRIDE; | 203 const ContainerParams& params) OVERRIDE; |
199 virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE; | 204 virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE; |
200 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } | 205 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } |
201 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE; | 206 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE; |
207 virtual gfx::Display::Rotation GetRotation() OVERRIDE; | |
208 virtual void SetRotation(gfx::Display::Rotation rotation) OVERRIDE; | |
202 | 209 |
203 aura::Window* root_window_; | 210 aura::Window* root_window_; |
204 aura::Window* background_window_; | 211 aura::Window* background_window_; |
212 gfx::Display::Rotation rotation_; | |
205 | 213 |
206 scoped_ptr<BackgroundController> background_controller_; | 214 scoped_ptr<BackgroundController> background_controller_; |
207 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; | 215 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; |
208 scoped_ptr<AcceleratorHandler> accelerator_handler_; | 216 scoped_ptr<AcceleratorHandler> accelerator_handler_; |
209 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; | 217 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; |
210 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; | 218 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; |
211 | 219 |
212 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); | 220 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); |
213 }; | 221 }; |
214 | 222 |
215 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) | 223 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) |
216 : root_window_(root_window) { | 224 : root_window_(root_window), |
225 rotation_(gfx::Display::ROTATE_0) { | |
217 DCHECK(root_window_); | 226 DCHECK(root_window_); |
218 DCHECK(!instance); | 227 DCHECK(!instance); |
219 instance = this; | 228 instance = this; |
220 } | 229 } |
221 | 230 |
222 ScreenManagerImpl::~ScreenManagerImpl() { | 231 ScreenManagerImpl::~ScreenManagerImpl() { |
223 aura::client::SetScreenPositionClient(root_window_, NULL); | 232 aura::client::SetScreenPositionClient(root_window_, NULL); |
224 aura::client::SetWindowTreeClient(root_window_, NULL); | 233 aura::client::SetWindowTreeClient(root_window_, NULL); |
225 instance = NULL; | 234 instance = NULL; |
226 } | 235 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 root_window_->StackChildBelow(container, *iter); | 324 root_window_->StackChildBelow(container, *iter); |
316 | 325 |
317 container->Show(); | 326 container->Show(); |
318 return container; | 327 return container; |
319 } | 328 } |
320 | 329 |
321 void ScreenManagerImpl::SetBackgroundImage(const gfx::ImageSkia& image) { | 330 void ScreenManagerImpl::SetBackgroundImage(const gfx::ImageSkia& image) { |
322 background_controller_->SetImage(image); | 331 background_controller_->SetImage(image); |
323 } | 332 } |
324 | 333 |
334 gfx::Display::Rotation ScreenManagerImpl::GetRotation() { | |
335 return rotation_; | |
336 } | |
337 | |
338 void ScreenManagerImpl::SetRotation(gfx::Display::Rotation rotation) { | |
339 if (rotation == rotation_) | |
340 return; | |
341 | |
342 gfx::Rect bounds(root_window_->bounds()); | |
343 if (IsRotationPortrait(rotation) != IsRotationPortrait(rotation_)) { | |
344 bounds.set_size(gfx::Size(bounds.height(), bounds.width())); | |
345 } | |
346 | |
347 rotation_ = rotation; | |
348 root_window_->SetBounds(bounds); | |
349 gfx::Transform transform; | |
350 switch (rotation) { | |
351 case gfx::Display::ROTATE_90: | |
352 transform.Translate(bounds.height(), 0); | |
353 transform.RotateAboutZAxis(90); | |
354 break; | |
355 case gfx::Display::ROTATE_180: | |
356 transform.Translate(bounds.width(), bounds.height()); | |
357 transform.RotateAboutZAxis(180); | |
358 break; | |
359 case gfx::Display::ROTATE_270: | |
360 transform.Translate(0, bounds.width()); | |
361 transform.RotateAboutZAxis(270); | |
362 break; | |
363 case gfx::Display::ROTATE_0: | |
364 default: | |
365 break; | |
366 } | |
367 root_window_->layer()->SetTransform(transform); | |
oshima
2014/08/01 17:15:11
Note: this won't update gfx::Display objects. A co
flackr
2014/08/06 14:13:51
Noted.
| |
368 } | |
369 | |
325 } // namespace | 370 } // namespace |
326 | 371 |
327 ScreenManager::ContainerParams::ContainerParams(const std::string& n, | 372 ScreenManager::ContainerParams::ContainerParams(const std::string& n, |
328 int priority) | 373 int priority) |
329 : name(n), | 374 : name(n), |
330 can_activate_children(false), | 375 can_activate_children(false), |
331 grab_inputs(false), | 376 grab_inputs(false), |
332 z_order_priority(priority) { | 377 z_order_priority(priority) { |
333 } | 378 } |
334 | 379 |
(...skipping 16 matching lines...) Expand all Loading... | |
351 delete instance; | 396 delete instance; |
352 DCHECK(!instance); | 397 DCHECK(!instance); |
353 } | 398 } |
354 | 399 |
355 // static | 400 // static |
356 wm::FocusRules* ScreenManager::CreateFocusRules() { | 401 wm::FocusRules* ScreenManager::CreateFocusRules() { |
357 return new AthenaFocusRules(); | 402 return new AthenaFocusRules(); |
358 } | 403 } |
359 | 404 |
360 } // namespace athena | 405 } // namespace athena |
OLD | NEW |