| Index: athena/screen/screen_manager_impl.cc
|
| diff --git a/athena/screen/screen_manager_impl.cc b/athena/screen/screen_manager_impl.cc
|
| index 8522acfc7acd30404c8b2ce8aa0d88fad5963769..404996e688ea0f7ae21ab5e310045d3b452f7849 100644
|
| --- a/athena/screen/screen_manager_impl.cc
|
| +++ b/athena/screen/screen_manager_impl.cc
|
| @@ -36,6 +36,11 @@ bool GrabsInput(aura::Window* container) {
|
| return params && params->grab_inputs;
|
| }
|
|
|
| +bool IsRotationPortrait(gfx::Display::Rotation rotation) {
|
| + return rotation == gfx::Display::ROTATE_90 ||
|
| + rotation == gfx::Display::ROTATE_270;
|
| +}
|
| +
|
| // Returns the container which contains |window|.
|
| aura::Window* GetContainer(aura::Window* window) {
|
| // No containers for NULL or the root window itself.
|
| @@ -199,9 +204,12 @@ class ScreenManagerImpl : public ScreenManager {
|
| virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE;
|
| virtual aura::Window* GetContext() OVERRIDE { return root_window_; }
|
| virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE;
|
| + virtual gfx::Display::Rotation GetRotation() OVERRIDE;
|
| + virtual void SetRotation(gfx::Display::Rotation rotation) OVERRIDE;
|
|
|
| aura::Window* root_window_;
|
| aura::Window* background_window_;
|
| + gfx::Display::Rotation rotation_;
|
|
|
| scoped_ptr<BackgroundController> background_controller_;
|
| scoped_ptr<aura::client::WindowTreeClient> window_tree_client_;
|
| @@ -213,7 +221,8 @@ class ScreenManagerImpl : public ScreenManager {
|
| };
|
|
|
| ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window)
|
| - : root_window_(root_window) {
|
| + : root_window_(root_window),
|
| + rotation_(gfx::Display::ROTATE_0) {
|
| DCHECK(root_window_);
|
| DCHECK(!instance);
|
| instance = this;
|
| @@ -322,6 +331,44 @@ void ScreenManagerImpl::SetBackgroundImage(const gfx::ImageSkia& image) {
|
| background_controller_->SetImage(image);
|
| }
|
|
|
| +gfx::Display::Rotation ScreenManagerImpl::GetRotation() {
|
| + return rotation_;
|
| +}
|
| +
|
| +void ScreenManagerImpl::SetRotation(gfx::Display::Rotation rotation) {
|
| + if (rotation == rotation_)
|
| + return;
|
| +
|
| + gfx::Rect bounds(root_window_->bounds());
|
| + if (IsRotationPortrait(rotation) != IsRotationPortrait(rotation_)) {
|
| + bounds.set_size(gfx::Size(bounds.height(), bounds.width()));
|
| + }
|
| +
|
| + rotation_ = rotation;
|
| + root_window_->SetBounds(bounds);
|
| + gfx::Transform transform;
|
| + switch (rotation) {
|
| + case gfx::Display::ROTATE_90:
|
| + transform.Translate(bounds.height(), 0);
|
| + transform.RotateAboutZAxis(90);
|
| + break;
|
| + case gfx::Display::ROTATE_180:
|
| + transform.Translate(bounds.width(), bounds.height());
|
| + transform.RotateAboutZAxis(180);
|
| + break;
|
| + case gfx::Display::ROTATE_270:
|
| + transform.Translate(0, bounds.width());
|
| + transform.RotateAboutZAxis(270);
|
| + break;
|
| + case gfx::Display::ROTATE_0:
|
| + default:
|
| + break;
|
| + }
|
| + // Note: This does not update the gfx::Display object. Code which relies
|
| + // on that may misbehave.
|
| + root_window_->layer()->SetTransform(transform);
|
| +}
|
| +
|
| } // namespace
|
|
|
| ScreenManager::ContainerParams::ContainerParams(const std::string& n,
|
|
|