diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc index 5a6dba781a213..076df1edf83db 100644 --- a/ash/accelerators/accelerator_controller.cc +++ b/ash/accelerators/accelerator_controller.cc @@ -295,8 +295,7 @@ void HandleRotateScreen() { const DisplayInfo& display_info = Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); ash::ScreenRotationAnimator(display.id()) - .Rotate(GetNextRotation(display_info.GetActiveRotation()), - gfx::Display::ROTATION_SOURCE_USER); + .Rotate(GetNextRotation(display_info.rotation())); } // Rotate the active window. diff --git a/ash/content/display/screen_orientation_controller_chromeos.cc b/ash/content/display/screen_orientation_controller_chromeos.cc index 859c6f8f9ed81..dbd44652a2e6b 100644 --- a/ash/content/display/screen_orientation_controller_chromeos.cc +++ b/ash/content/display/screen_orientation_controller_chromeos.cc @@ -45,7 +45,7 @@ blink::WebScreenOrientationLockType GetDisplayNaturalOrientation() { ash::DisplayInfo info = display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId()); gfx::Size size = info.size_in_pixel(); - switch (info.GetActiveRotation()) { + switch (info.rotation()) { case gfx::Display::ROTATE_0: case gfx::Display::ROTATE_180: return size.height() >= size.width() @@ -112,8 +112,7 @@ void ScreenOrientationController::SetRotationLocked(bool rotation_locked) { } void ScreenOrientationController::SetDisplayRotation( - gfx::Display::Rotation rotation, - gfx::Display::RotationSource source) { + gfx::Display::Rotation rotation) { DisplayManager* display_manager = Shell::GetInstance()->display_manager(); if (!display_manager->HasInternalDisplay()) return; @@ -121,7 +120,7 @@ void ScreenOrientationController::SetDisplayRotation( base::AutoReset auto_ignore_display_configuration_updates( &ignore_display_configuration_updates_, true); ash::ScreenRotationAnimator(gfx::Display::InternalDisplayId()) - .Rotate(rotation, source); + .Rotate(rotation); } void ScreenOrientationController::OnWindowActivated(aura::Window* gained_active, @@ -202,7 +201,7 @@ void ScreenOrientationController::OnDisplayConfigurationChanged() { return; gfx::Display::Rotation user_rotation = display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId()) - .GetActiveRotation(); + .rotation(); if (user_rotation != current_rotation_) { // A user may change other display configuration settings. When the user // does change the rotation setting, then lock rotation to prevent the @@ -220,7 +219,7 @@ void ScreenOrientationController::OnMaximizeModeStarted() { if (display_manager->HasInternalDisplay()) { current_rotation_ = user_rotation_ = display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId()) - .GetActiveRotation(); + .rotation(); } if (!rotation_locked_) LoadDisplayRotationProperties(); @@ -232,14 +231,13 @@ void ScreenOrientationController::OnMaximizeModeEnded() { chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this); Shell::GetInstance()->display_controller()->RemoveObserver(this); if (current_rotation_ != user_rotation_) - SetDisplayRotation(user_rotation_, gfx::Display::ROTATION_SOURCE_USER); + SetDisplayRotation(user_rotation_); } void ScreenOrientationController::LockRotation( - gfx::Display::Rotation rotation, - gfx::Display::RotationSource source) { + gfx::Display::Rotation rotation) { SetRotationLocked(true); - SetDisplayRotation(rotation, source); + SetDisplayRotation(rotation); } void ScreenOrientationController::LockRotationToOrientation( @@ -272,8 +270,7 @@ void ScreenOrientationController::LockRotationToOrientation( blink::WebScreenOrientationLockLandscape); break; case blink::WebScreenOrientationLockNatural: - LockRotation(gfx::Display::ROTATE_0, - gfx::Display::ROTATION_SOURCE_ACTIVE); + LockRotation(gfx::Display::ROTATE_0); break; default: NOTREACHED(); @@ -285,16 +282,14 @@ void ScreenOrientationController::LockRotationToPrimaryOrientation( blink::WebScreenOrientationLockType lock_orientation) { LockRotation(natural_orientation_ == lock_orientation ? gfx::Display::ROTATE_0 - : gfx::Display::ROTATE_90, - gfx::Display::ROTATION_SOURCE_ACTIVE); + : gfx::Display::ROTATE_90); } void ScreenOrientationController::LockRotationToSecondaryOrientation( blink::WebScreenOrientationLockType lock_orientation) { LockRotation(natural_orientation_ == lock_orientation ? gfx::Display::ROTATE_180 - : gfx::Display::ROTATE_270, - gfx::Display::ROTATION_SOURCE_ACTIVE); + : gfx::Display::ROTATE_270); } void ScreenOrientationController::LockToRotationMatchingOrientation( @@ -305,22 +300,20 @@ void ScreenOrientationController::LockToRotationMatchingOrientation( gfx::Display::Rotation rotation = display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId()) - .GetActiveRotation(); + .rotation(); if (natural_orientation_ == lock_orientation) { if (rotation == gfx::Display::ROTATE_0 || rotation == gfx::Display::ROTATE_180) { SetRotationLocked(true); } else { - LockRotation(gfx::Display::ROTATE_0, - gfx::Display::ROTATION_SOURCE_ACTIVE); + LockRotation(gfx::Display::ROTATE_0); } } else { if (rotation == gfx::Display::ROTATE_90 || rotation == gfx::Display::ROTATE_270) { SetRotationLocked(true); } else { - LockRotation(gfx::Display::ROTATE_90, - gfx::Display::ROTATION_SOURCE_ACTIVE); + LockRotation(gfx::Display::ROTATE_90); } } } @@ -372,16 +365,14 @@ void ScreenOrientationController::HandleScreenRotation( if (new_rotation != current_rotation_ && IsRotationAllowedInLockedState(new_rotation)) - SetDisplayRotation(new_rotation, - gfx::Display::ROTATION_SOURCE_ACCELEROMETER); + SetDisplayRotation(new_rotation); } void ScreenOrientationController::LoadDisplayRotationProperties() { DisplayManager* display_manager = Shell::GetInstance()->display_manager(); if (!display_manager->registered_internal_display_rotation_lock()) return; - SetDisplayRotation(display_manager->registered_internal_display_rotation(), - gfx::Display::ROTATION_SOURCE_ACCELEROMETER); + SetDisplayRotation(display_manager->registered_internal_display_rotation()); SetRotationLocked(true); } diff --git a/ash/content/display/screen_orientation_controller_chromeos.h b/ash/content/display/screen_orientation_controller_chromeos.h index 0a84b8cd29640..aa45734a24d31 100644 --- a/ash/content/display/screen_orientation_controller_chromeos.h +++ b/ash/content/display/screen_orientation_controller_chromeos.h @@ -69,11 +69,8 @@ class ASH_EXPORT ScreenOrientationController // display rotation. void SetRotationLocked(bool rotation_locked); - // Sets the display rotation for the given |source|. The new |rotation| will - // also become active. Display changed notifications are surpressed for this - // change. - void SetDisplayRotation(gfx::Display::Rotation rotation, - gfx::Display::RotationSource source); + // Sets the display rotation and suppresses display notifications. + void SetDisplayRotation(gfx::Display::Rotation rotation); // aura::client::ActivationChangeObserver: void OnWindowActivated(aura::Window* gained_active, @@ -105,8 +102,7 @@ class ASH_EXPORT ScreenOrientationController // Sets the display rotation to |rotation|. Future accelerometer updates // should not be used to change the rotation. SetRotationLocked(false) removes // the rotation lock. - void LockRotation(gfx::Display::Rotation rotation, - gfx::Display::RotationSource source); + void LockRotation(gfx::Display::Rotation rotation); // Sets the display rotation based on |lock_orientation|. Future accelerometer // updates should not be used to change the rotation. SetRotationLocked(false) diff --git a/ash/content/display/screen_orientation_controller_chromeos_unittest.cc b/ash/content/display/screen_orientation_controller_chromeos_unittest.cc index 27ec3d609a0ea..342e9585b8e2a 100644 --- a/ash/content/display/screen_orientation_controller_chromeos_unittest.cc +++ b/ash/content/display/screen_orientation_controller_chromeos_unittest.cc @@ -41,6 +41,20 @@ void EnableMaximizeMode(bool enable) { ->EnableMaximizeModeWindowManager(enable); } +gfx::Display::Rotation GetInternalDisplayRotation() { + return Shell::GetInstance() + ->display_manager() + ->GetDisplayInfo(gfx::Display::InternalDisplayId()) + .rotation(); +} + +gfx::Display::Rotation Rotation() { + return Shell::GetInstance() + ->display_manager() + ->GetDisplayInfo(gfx::Display::InternalDisplayId()) + .rotation(); +} + bool RotationLocked() { return Shell::GetInstance() ->screen_orientation_controller() @@ -49,8 +63,7 @@ bool RotationLocked() { void SetInternalDisplayRotation(gfx::Display::Rotation rotation) { Shell::GetInstance()->display_manager()->SetDisplayRotation( - gfx::Display::InternalDisplayId(), rotation, - gfx::Display::ROTATION_SOURCE_USER); + gfx::Display::InternalDisplayId(), rotation); } void SetRotationLocked(bool rotation_locked) { @@ -153,12 +166,12 @@ TEST_F(ScreenOrientationControllerTest, LockOrientation) { scoped_ptr content(CreateWebContents()); scoped_ptr focus_window(CreateTestWindowInShellWithId(0)); ASSERT_NE(nullptr, content->GetNativeView()); - ASSERT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + ASSERT_EQ(gfx::Display::ROTATE_0, Rotation()); ASSERT_FALSE(RotationLocked()); AttachAndActivateWebContents(content.get(), focus_window.get()); delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, Rotation()); EXPECT_TRUE(RotationLocked()); } @@ -167,12 +180,12 @@ TEST_F(ScreenOrientationControllerTest, Unlock) { scoped_ptr content(CreateWebContents()); scoped_ptr focus_window(CreateTestWindowInShellWithId(0)); ASSERT_NE(nullptr, content->GetNativeView()); - ASSERT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + ASSERT_EQ(gfx::Display::ROTATE_0, Rotation()); ASSERT_FALSE(RotationLocked()); AttachAndActivateWebContents(content.get(), focus_window.get()); delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, Rotation()); EXPECT_TRUE(RotationLocked()); delegate()->Unlock(content.get()); @@ -185,16 +198,16 @@ TEST_F(ScreenOrientationControllerTest, OrientationChanges) { scoped_ptr content(CreateWebContents()); scoped_ptr focus_window(CreateTestWindowInShellWithId(0)); ASSERT_NE(nullptr, content->GetNativeView()); - ASSERT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + ASSERT_EQ(gfx::Display::ROTATE_0, Rotation()); ASSERT_FALSE(RotationLocked()); AttachAndActivateWebContents(content.get(), focus_window.get()); delegate()->Lock(content.get(), blink::WebScreenOrientationLockPortrait); - EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_90, Rotation()); EXPECT_TRUE(RotationLocked()); delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, Rotation()); } // Tests that orientation can only be set by the first content::WebContents that @@ -210,7 +223,7 @@ TEST_F(ScreenOrientationControllerTest, SecondContentCannotChangeOrientation) { AttachWebContents(content2.get(), focus_window2.get()); delegate()->Lock(content1.get(), blink::WebScreenOrientationLockLandscape); delegate()->Lock(content2.get(), blink::WebScreenOrientationLockPortrait); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, Rotation()); } // Tests that only the content::WebContents that set a rotation lock can perform @@ -261,17 +274,17 @@ TEST_F(ScreenOrientationControllerTest, ActiveWindowChangesUpdateOrientation) { delegate()->Lock(content1.get(), blink::WebScreenOrientationLockLandscape); delegate()->Lock(content2.get(), blink::WebScreenOrientationLockPortrait); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); aura::client::ActivationClient* activation_client = Shell::GetInstance()->activation_client(); activation_client->ActivateWindow(focus_window2.get()); EXPECT_TRUE(RotationLocked()); - EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); activation_client->ActivateWindow(focus_window1.get()); EXPECT_TRUE(RotationLocked()); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); } // Tests that a rotation lock is removed when the setting window is hidden, and @@ -321,13 +334,13 @@ TEST_F(ScreenOrientationControllerTest, DisplayRotation) { EnableMaximizeMode(true); // Now test rotating in all directions. TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f)); - EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); - EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); - EXPECT_EQ(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); } // Tests that low angles are ignored by the accelerometer (i.e. when the device @@ -335,15 +348,15 @@ TEST_F(ScreenOrientationControllerTest, DisplayRotation) { TEST_F(ScreenOrientationControllerTest, RotationIgnoresLowAngles) { EnableMaximizeMode(true); TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, -kMeanGravity)); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); TriggerLidUpdate(gfx::Vector3dF(-2.0f, 0.0f, -kMeanGravity)); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); TriggerLidUpdate(gfx::Vector3dF(0.0f, 2.0f, -kMeanGravity)); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); TriggerLidUpdate(gfx::Vector3dF(2.0f, 0.0f, -kMeanGravity)); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); TriggerLidUpdate(gfx::Vector3dF(0.0f, -2.0f, -kMeanGravity)); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); } // Tests that the display will stick to the current orientation beyond the @@ -352,7 +365,7 @@ TEST_F(ScreenOrientationControllerTest, RotationSticky) { EnableMaximizeMode(true); gfx::Vector3dF gravity(0.0f, -kMeanGravity, 0.0f); TriggerLidUpdate(gravity); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); // Turn past half-way point to next direction and rotation should remain // the same. @@ -360,14 +373,14 @@ TEST_F(ScreenOrientationControllerTest, RotationSticky) { gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity); gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity); TriggerLidUpdate(gravity); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); // Turn more and the screen should rotate. degrees = 70.0; gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity); gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity); TriggerLidUpdate(gravity); - EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); // Turn back just beyond the half-way point and the new rotation should // still be in effect. @@ -375,7 +388,7 @@ TEST_F(ScreenOrientationControllerTest, RotationSticky) { gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity); gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity); TriggerLidUpdate(gravity); - EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); } // Tests that the display will stick to its current orientation when the @@ -390,11 +403,11 @@ TEST_F(ScreenOrientationControllerTest, RotationLockPreventsRotation) { -cos(degrees * kDegreesToRadians) * kMeanGravity, 0.0f); TriggerLidUpdate(gravity); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); SetRotationLocked(false); TriggerLidUpdate(gravity); - EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); } // The TrayDisplay class that is responsible for adding/updating MessageCenter @@ -416,10 +429,10 @@ TEST_F(ScreenOrientationControllerTest, BlockRotationNotifications) { // Make sure notifications are still displayed when // adjusting the screen rotation directly when in maximize mode - ASSERT_NE(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); + ASSERT_NE(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); SetInternalDisplayRotation(gfx::Display::ROTATE_270); SetRotationLocked(false); - EXPECT_EQ(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); EXPECT_EQ(1u, message_center->NotificationCount()); EXPECT_TRUE(message_center->HasPopupNotifications()); @@ -431,9 +444,9 @@ TEST_F(ScreenOrientationControllerTest, BlockRotationNotifications) { // Make sure notifications are blocked when adjusting the screen rotation // via the accelerometer while in maximize mode // Rotate the screen 90 degrees - ASSERT_NE(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); + ASSERT_NE(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f)); - ASSERT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); + ASSERT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); EXPECT_EQ(0u, message_center->NotificationCount()); EXPECT_FALSE(message_center->HasPopupNotifications()); @@ -444,11 +457,11 @@ TEST_F(ScreenOrientationControllerTest, BlockRotationNotifications) { SetInternalDisplayRotation(gfx::Display::ROTATE_0); // Clear all notifications message_center->RemoveAllNotifications(false); - ASSERT_NE(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); + ASSERT_NE(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); ASSERT_EQ(0u, message_center->NotificationCount()); ASSERT_FALSE(message_center->HasPopupNotifications()); SetInternalDisplayRotation(gfx::Display::ROTATE_180); - EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); EXPECT_EQ(1u, message_center->NotificationCount()); EXPECT_TRUE(message_center->HasPopupNotifications()); } @@ -460,10 +473,10 @@ TEST_F(ScreenOrientationControllerTest, ResetUserRotationUponExit) { EnableMaximizeMode(true); TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); - EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); EnableMaximizeMode(false); - EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); } // Tests that if a user sets a display rotation that accelerometer rotation @@ -486,7 +499,7 @@ TEST_F(ScreenOrientationControllerTest, UpdateUserRotationWhileRotationLocked) { // maximize mode was activated. SetInternalDisplayRotation(gfx::Display::ROTATE_0); EnableMaximizeMode(false); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); } // Tests that when the orientation lock is set to Landscape, that rotation can @@ -498,18 +511,18 @@ TEST_F(ScreenOrientationControllerTest, LandscapeOrientationAllowsRotation) { AttachAndActivateWebContents(content.get(), focus_window.get()); delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, Rotation()); EXPECT_TRUE(RotationLocked()); // Inverse of orientation is allowed TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); - EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); // Display rotations between are not allowed TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); - EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f)); - EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); } // Tests that when the orientation lock is set to Portrait, that rotaiton can be @@ -521,18 +534,18 @@ TEST_F(ScreenOrientationControllerTest, PortraitOrientationAllowsRotation) { AttachAndActivateWebContents(content.get(), focus_window.get()); delegate()->Lock(content.get(), blink::WebScreenOrientationLockPortrait); - EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_90, Rotation()); EXPECT_TRUE(RotationLocked()); // Inverse of orientation is allowed TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); - EXPECT_EQ(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); // Display rotations between are not allowed TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); - EXPECT_EQ(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); - EXPECT_EQ(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); } // Tests that for an orientation lock which does not allow rotation, that the @@ -545,16 +558,16 @@ TEST_F(ScreenOrientationControllerTest, OrientationLockDisallowsRotation) { AttachAndActivateWebContents(content.get(), focus_window.get()); delegate()->Lock(content.get(), blink::WebScreenOrientationLockPortraitPrimary); - EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_90, Rotation()); EXPECT_TRUE(RotationLocked()); // Rotation does not change. TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); - EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); - EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); - EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); } // Tests that after a content::WebContents has applied an orientation lock which @@ -570,10 +583,10 @@ TEST_F(ScreenOrientationControllerTest, UserRotationLockDisallowsRotation) { SetRotationLocked(true); EXPECT_TRUE(RotationLocked()); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, Rotation()); TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); - EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); } // Tests that when MaximizeMode is triggered before the internal display is diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc index da51923c8e146..166a76f0cdc26 100644 --- a/ash/display/display_controller.cc +++ b/ash/display/display_controller.cc @@ -109,7 +109,7 @@ void SetDisplayPropertiesOnHost(AshWindowTreeHost* ash_host, const char kInternalProp[] = "_CHROME_DISPLAY_INTERNAL"; const char kCARDINAL[] = "CARDINAL"; int xrandr_rotation = RR_Rotate_0; - switch (info.GetActiveRotation()) { + switch (info.rotation()) { case gfx::Display::ROTATE_0: xrandr_rotation = RR_Rotate_0; break; @@ -140,7 +140,7 @@ void SetDisplayPropertiesOnHost(AshWindowTreeHost* ash_host, scale *= kCursorMultiplierForExternalDisplays; ui::CursorController::GetInstance()->SetCursorConfigForWindow( - host->GetAcceleratedWidget(), info.GetActiveRotation(), scale); + host->GetAcceleratedWidget(), info.rotation(), scale); #endif #endif scoped_ptr transformer( diff --git a/ash/display/display_controller_unittest.cc b/ash/display/display_controller_unittest.cc index 6f38a3e64e87c..6945fac2c30fc 100644 --- a/ash/display/display_controller_unittest.cc +++ b/ash/display/display_controller_unittest.cc @@ -352,6 +352,10 @@ class TestEventHandler : public ui::EventHandler { DISALLOW_COPY_AND_ASSIGN(TestEventHandler); }; +gfx::Display::Rotation GetStoredRotation(int64 id) { + return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).rotation(); +} + float GetStoredUIScale(int64 id) { return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). GetEffectiveUIScale(); @@ -553,7 +557,7 @@ DisplayInfo CreateDisplayInfo(int64 id, gfx::Display::Rotation rotation) { DisplayInfo info(id, "", false); info.SetBounds(gfx::Rect(0, y, 500, 500)); - info.SetRotation(rotation, gfx::Display::ROTATION_SOURCE_ACTIVE); + info.set_rotation(rotation); return info; } @@ -682,14 +686,12 @@ TEST_F(DisplayControllerTest, BoundsUpdated) { // Rotation observer.GetRotationChangedCountAndReset(); // we only want to reset. int64 primary_id = GetPrimaryDisplay().id(); - display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90, - gfx::Display::ROTATION_SOURCE_ACTIVE); + display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90); EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); EXPECT_EQ(1, observer.CountAndReset()); EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); - display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90, - gfx::Display::ROTATION_SOURCE_ACTIVE); + display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90); EXPECT_EQ(0, observer.GetRotationChangedCountAndReset()); EXPECT_EQ(0, observer.CountAndReset()); EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); @@ -1044,20 +1046,20 @@ TEST_F(DisplayControllerTest, Rotate) { ScreenUtil::GetSecondaryDisplay().bounds().ToString()); generator1.MoveMouseToInHost(50, 40); EXPECT_EQ("50,40", event_handler.GetLocationAndReset()); - EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display1.id())); - EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); + EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); + EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); EXPECT_EQ(0, observer.GetRotationChangedCountAndReset()); - display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_90, - gfx::Display::ROTATION_SOURCE_ACTIVE); + display_manager->SetDisplayRotation(display1.id(), + gfx::Display::ROTATE_90); EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); EXPECT_EQ("200,0 150x200", ScreenUtil::GetSecondaryDisplay().bounds().ToString()); generator1.MoveMouseToInHost(50, 40); EXPECT_EQ("40,69", event_handler.GetLocationAndReset()); - EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); - EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); + EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); + EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); @@ -1065,30 +1067,30 @@ TEST_F(DisplayControllerTest, Rotate) { EXPECT_EQ("50,120 150x200", ScreenUtil::GetSecondaryDisplay().bounds().ToString()); - display_manager->SetDisplayRotation(display2_id, gfx::Display::ROTATE_270, - gfx::Display::ROTATION_SOURCE_ACTIVE); + display_manager->SetDisplayRotation(display2_id, + gfx::Display::ROTATE_270); EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); EXPECT_EQ("50,120 200x150", ScreenUtil::GetSecondaryDisplay().bounds().ToString()); - EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); - EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); + EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); + EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); #if !defined(OS_WIN) ui::test::EventGenerator generator2(root_windows[1]); generator2.MoveMouseToInHost(50, 40); EXPECT_EQ("179,25", event_handler.GetLocationAndReset()); - display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_180, - gfx::Display::ROTATION_SOURCE_ACTIVE); + display_manager->SetDisplayRotation(display1.id(), + gfx::Display::ROTATE_180); EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); // Dislay must share at least 100, so the x's offset becomes 20. EXPECT_EQ("20,200 200x150", ScreenUtil::GetSecondaryDisplay().bounds().ToString()); - EXPECT_EQ(gfx::Display::ROTATE_180, GetActiveDisplayRotation(display1.id())); - EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); + EXPECT_EQ(gfx::Display::ROTATE_180, GetStoredRotation(display1.id())); + EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); generator1.MoveMouseToInHost(50, 40); diff --git a/ash/display/display_info.cc b/ash/display/display_info.cc index e58b51a0e6ac4..e812633bc2a6e 100644 --- a/ash/display/display_info.cc +++ b/ash/display/display_info.cc @@ -207,7 +207,7 @@ DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, DisplayInfo display_info( id, base::StringPrintf("Display-%d", static_cast(id)), has_overscan); display_info.set_device_scale_factor(device_scale_factor); - display_info.SetRotation(rotation, gfx::Display::ROTATION_SOURCE_ACTIVE); + display_info.set_rotation(rotation); display_info.set_configured_ui_scale(ui_scale); display_info.SetBounds(bounds_in_native); display_info.SetDisplayModes(display_modes); @@ -228,6 +228,7 @@ DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, DisplayInfo::DisplayInfo() : id_(gfx::Display::kInvalidDisplayID), has_overscan_(false), + rotation_(gfx::Display::ROTATE_0), touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), touch_device_id_(0), device_scale_factor_(1.0f), @@ -245,6 +246,7 @@ DisplayInfo::DisplayInfo(int64 id, : id_(id), name_(name), has_overscan_(has_overscan), + rotation_(gfx::Display::ROTATE_0), touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), touch_device_id_(0), device_scale_factor_(1.0f), @@ -259,23 +261,6 @@ DisplayInfo::DisplayInfo(int64 id, DisplayInfo::~DisplayInfo() { } -void DisplayInfo::SetRotation(gfx::Display::Rotation rotation, - gfx::Display::RotationSource source) { - rotations_[source] = rotation; - rotations_[gfx::Display::ROTATION_SOURCE_ACTIVE] = rotation; -} - -gfx::Display::Rotation DisplayInfo::GetActiveRotation() const { - return GetRotation(gfx::Display::ROTATION_SOURCE_ACTIVE); -} - -gfx::Display::Rotation DisplayInfo::GetRotation( - gfx::Display::RotationSource source) const { - if (rotations_.find(source) == rotations_.end()) - return gfx::Display::ROTATE_0; - return rotations_.at(source); -} - void DisplayInfo::Copy(const DisplayInfo& native_info) { DCHECK(id_ == native_info.id_); name_ = native_info.name_; @@ -302,7 +287,7 @@ void DisplayInfo::Copy(const DisplayInfo& native_info) { else if (!native_info.overscan_insets_in_dip_.empty()) overscan_insets_in_dip_ = native_info.overscan_insets_in_dip_; - rotations_ = native_info.rotations_; + rotation_ = native_info.rotation_; configured_ui_scale_ = native_info.configured_ui_scale_; color_profile_ = native_info.color_profile(); } @@ -340,10 +325,9 @@ void DisplayInfo::UpdateDisplaySize() { overscan_insets_in_dip_.Set(0, 0, 0, 0); } - if (GetActiveRotation() == gfx::Display::ROTATE_90 || - GetActiveRotation() == gfx::Display::ROTATE_270) { + if (rotation_ == gfx::Display::ROTATE_90 || + rotation_ == gfx::Display::ROTATE_270) size_in_pixel_.SetSize(size_in_pixel_.height(), size_in_pixel_.width()); - } gfx::SizeF size_f(size_in_pixel_); size_f.Scale(GetEffectiveUIScale()); size_in_pixel_ = gfx::ToFlooredSize(size_f); @@ -374,7 +358,7 @@ gfx::Size DisplayInfo::GetNativeModeSize() const { } std::string DisplayInfo::ToString() const { - int rotation_degree = static_cast(GetActiveRotation()) * 90; + int rotation_degree = static_cast(rotation_) * 90; return base::StringPrintf( "DisplayInfo[%lld] native bounds=%s, size=%s, scale=%f, " "overscan=%s, rotation=%d, ui-scale=%f, touchscreen=%s, " diff --git a/ash/display/display_info.h b/ash/display/display_info.h index 34f229927c170..427355b801296 100644 --- a/ash/display/display_info.h +++ b/ash/display/display_info.h @@ -5,7 +5,6 @@ #ifndef ASH_DISPLAY_DISPLAY_INFO_H_ #define ASH_DISPLAY_DISPLAY_INFO_H_ -#include #include #include @@ -104,6 +103,9 @@ class ASH_EXPORT DisplayInfo { // actual overscan automatically, but used in the message. bool has_overscan() const { return has_overscan_; } + void set_rotation(gfx::Display::Rotation rotation) { rotation_ = rotation; } + gfx::Display::Rotation rotation() const { return rotation_; } + void set_touch_support(gfx::Display::TouchSupport support) { touch_support_ = support; } @@ -137,17 +139,6 @@ class ASH_EXPORT DisplayInfo { float configured_ui_scale() const { return configured_ui_scale_; } void set_configured_ui_scale(float scale) { configured_ui_scale_ = scale; } - // Sets the rotation for the given |source|. Setting a new rotation will also - // have it become the active rotation. - void SetRotation(gfx::Display::Rotation rotation, - gfx::Display::RotationSource source); - - // Returns the currently active rotation for this display. - gfx::Display::Rotation GetActiveRotation() const; - - // Returns the rotation set by a given |source|. - gfx::Display::Rotation GetRotation(gfx::Display::RotationSource source) const; - // Returns the ui scale and device scale factor actually used to create // display that chrome sees. This can be different from one obtained // from dispaly or one specified by a user in following situation. @@ -240,7 +231,7 @@ class ASH_EXPORT DisplayInfo { int64 id_; std::string name_; bool has_overscan_; - std::map rotations_; + gfx::Display::Rotation rotation_; gfx::Display::TouchSupport touch_support_; // If the display is also a touch device, it will have a positive diff --git a/ash/display/display_info_unittest.cc b/ash/display/display_info_unittest.cc index 7c5da69f402c3..01362b43ceaa6 100644 --- a/ash/display/display_info_unittest.cc +++ b/ash/display/display_info_unittest.cc @@ -29,32 +29,32 @@ TEST_F(DisplayInfoTest, CreateFromSpec) { EXPECT_EQ(10, info.id()); EXPECT_EQ("0,0 200x100", info.bounds_in_native().ToString()); EXPECT_EQ("200x100", info.size_in_pixel().ToString()); - EXPECT_EQ(gfx::Display::ROTATE_0, info.GetActiveRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, info.rotation()); EXPECT_EQ("0,0,0,0", info.overscan_insets_in_dip().ToString()); EXPECT_EQ(1.0f, info.configured_ui_scale()); info = DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/o", 10); EXPECT_EQ("10,20 300x400", info.bounds_in_native().ToString()); EXPECT_EQ("288x380", info.size_in_pixel().ToString()); - EXPECT_EQ(gfx::Display::ROTATE_0, info.GetActiveRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, info.rotation()); EXPECT_EQ("5,3,5,3", info.overscan_insets_in_dip().ToString()); info = DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/ob", 10); EXPECT_EQ("10,20 300x400", info.bounds_in_native().ToString()); EXPECT_EQ("288x380", info.size_in_pixel().ToString()); - EXPECT_EQ(gfx::Display::ROTATE_0, info.GetActiveRotation()); + EXPECT_EQ(gfx::Display::ROTATE_0, info.rotation()); EXPECT_EQ("5,3,5,3", info.overscan_insets_in_dip().ToString()); info = DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/or", 10); EXPECT_EQ("10,20 300x400", info.bounds_in_native().ToString()); EXPECT_EQ("380x288", info.size_in_pixel().ToString()); - EXPECT_EQ(gfx::Display::ROTATE_90, info.GetActiveRotation()); + EXPECT_EQ(gfx::Display::ROTATE_90, info.rotation()); // TODO(oshima): This should be rotated too. Fix this. EXPECT_EQ("5,3,5,3", info.overscan_insets_in_dip().ToString()); info = DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/l@1.5", 10); EXPECT_EQ("10,20 300x400", info.bounds_in_native().ToString()); - EXPECT_EQ(gfx::Display::ROTATE_270, info.GetActiveRotation()); + EXPECT_EQ(gfx::Display::ROTATE_270, info.rotation()); EXPECT_EQ(1.5f, info.configured_ui_scale()); info = DisplayInfo::CreateFromSpecWithID( diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc index e1b6551e8e958..b731ded75629b 100644 --- a/ash/display/display_manager.cc +++ b/ash/display/display_manager.cc @@ -343,18 +343,15 @@ void DisplayManager::SetOverscanInsets(int64 display_id, } void DisplayManager::SetDisplayRotation(int64 display_id, - gfx::Display::Rotation rotation, - gfx::Display::RotationSource source) { + gfx::Display::Rotation rotation) { DisplayInfoList display_info_list; for (DisplayList::const_iterator iter = displays_.begin(); iter != displays_.end(); ++iter) { DisplayInfo info = GetDisplayInfo(iter->id()); if (info.id() == display_id) { - if (info.GetRotation(source) == rotation && - info.GetActiveRotation() == rotation) { + if (info.rotation() == rotation) return; - } - info.SetRotation(rotation, source); + info.set_rotation(rotation); } display_info_list.push_back(info); } @@ -472,8 +469,7 @@ void DisplayManager::RegisterDisplayProperty( if (display_info_.find(display_id) == display_info_.end()) display_info_[display_id] = DisplayInfo(display_id, std::string(), false); - display_info_[display_id].SetRotation(rotation, - gfx::Display::ROTATION_SOURCE_ACTIVE); + display_info_[display_id].set_rotation(rotation); display_info_[display_id].SetColorProfile(color_profile); // Just in case the preference file was corrupted. // TODO(mukai): register |display_modes_| here as well, so the lookup for the @@ -1156,7 +1152,7 @@ gfx::Display DisplayManager::CreateDisplayFromDisplayInfoById(int64 id) { // in |UpdateNonPrimaryDisplayBoundsForLayout| called in |UpdateDisplay|. new_display.SetScaleAndBounds( device_scale_factor, gfx::Rect(bounds_in_native.size())); - new_display.set_rotation(display_info.GetActiveRotation()); + new_display.set_rotation(display_info.rotation()); new_display.set_touch_support(display_info.touch_support()); return new_display; } diff --git a/ash/display/display_manager.h b/ash/display/display_manager.h index dc7f15258ee2e..092d2b0029612 100644 --- a/ash/display/display_manager.h +++ b/ash/display/display_manager.h @@ -151,11 +151,8 @@ class ASH_EXPORT DisplayManager // display's bounds change. void SetOverscanInsets(int64 display_id, const gfx::Insets& insets_in_dip); - // Sets the display's rotation for the given |source|. The new |rotation| will - // also become active. - void SetDisplayRotation(int64 display_id, - gfx::Display::Rotation rotation, - gfx::Display::RotationSource source); + // Sets the display's rotation. + void SetDisplayRotation(int64 display_id, gfx::Display::Rotation rotation); // Sets the display's ui scale. Returns true if it's successful, or // false otherwise. TODO(mukai): remove this and merge into diff --git a/ash/display/root_window_transformers.cc b/ash/display/root_window_transformers.cc index 8a028b37a1061..509bb8e215e64 100644 --- a/ash/display/root_window_transformers.cc +++ b/ash/display/root_window_transformers.cc @@ -62,18 +62,16 @@ gfx::Transform CreateRotationTransform(aura::Window* root_window, // updating the transform results in incorrectly resizing // the root window. Don't apply the transform unless // necessary so that unit tests pass on win8 bots. - if (info.GetActiveRotation() == - root_window->GetProperty(kRotationPropertyKey)) { + if (info.rotation() == root_window->GetProperty(kRotationPropertyKey)) return gfx::Transform(); - } - root_window->SetProperty(kRotationPropertyKey, info.GetActiveRotation()); + root_window->SetProperty(kRotationPropertyKey, info.rotation()); #endif gfx::Transform rotate; // The origin is (0, 0), so the translate width/height must be reduced by // 1 pixel. float one_pixel = 1.0f / display.device_scale_factor(); - switch (info.GetActiveRotation()) { + switch (info.rotation()) { case gfx::Display::ROTATE_0: break; case gfx::Display::ROTATE_90: diff --git a/ash/display/root_window_transformers_unittest.cc b/ash/display/root_window_transformers_unittest.cc index 6639ec943add2..17c8b36310e3d 100644 --- a/ash/display/root_window_transformers_unittest.cc +++ b/ash/display/root_window_transformers_unittest.cc @@ -107,6 +107,10 @@ class TestEventHandler : public ui::EventHandler { DISALLOW_COPY_AND_ASSIGN(TestEventHandler); }; +gfx::Display::Rotation GetStoredRotation(int64 id) { + return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).rotation(); +} + float GetStoredUIScale(int64 id) { return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). GetEffectiveUIScale(); @@ -154,12 +158,12 @@ TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { EXPECT_EQ("50,90", event_handler.GetLocationAndReset()); EXPECT_EQ("50,90", aura::Env::GetInstance()->last_mouse_location().ToString()); - EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display1.id())); - EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); + EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); + EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); magnifier->SetEnabled(false); - display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_90, - gfx::Display::ROTATION_SOURCE_ACTIVE); + display_manager->SetDisplayRotation(display1.id(), + gfx::Display::ROTATE_90); // Move the cursor to the center of the first root window. generator1.MoveMouseToInHost(59, 100); @@ -173,8 +177,8 @@ TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { EXPECT_EQ("110,70", event_handler.GetLocationAndReset()); EXPECT_EQ("110,70", aura::Env::GetInstance()->last_mouse_location().ToString()); - EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); - EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); + EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); + EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); magnifier->SetEnabled(false); DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); @@ -182,8 +186,8 @@ TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { EXPECT_EQ("50,120 150x200", ScreenUtil::GetSecondaryDisplay().bounds().ToString()); - display_manager->SetDisplayRotation(display2_id, gfx::Display::ROTATE_270, - gfx::Display::ROTATION_SOURCE_ACTIVE); + display_manager->SetDisplayRotation(display2_id, + gfx::Display::ROTATE_270); // Move the cursor to the center of the second root window. generator2.MoveMouseToInHost(151, 199); @@ -196,12 +200,12 @@ TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { EXPECT_EQ("95,80", event_handler.GetLocationAndReset()); EXPECT_EQ("145,200", aura::Env::GetInstance()->last_mouse_location().ToString()); - EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); - EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); + EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); + EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); magnifier->SetEnabled(false); - display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_180, - gfx::Display::ROTATION_SOURCE_ACTIVE); + display_manager->SetDisplayRotation(display1.id(), + gfx::Display::ROTATE_180); // Move the cursor to the center of the first root window. generator1.MoveMouseToInHost(59, 99); @@ -213,8 +217,8 @@ TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { ScreenUtil::GetSecondaryDisplay().bounds().ToString()); generator1.MoveMouseToInHost(39, 59); EXPECT_EQ("70,120", event_handler.GetLocationAndReset()); - EXPECT_EQ(gfx::Display::ROTATE_180, GetActiveDisplayRotation(display1.id())); - EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); + EXPECT_EQ(gfx::Display::ROTATE_180, GetStoredRotation(display1.id())); + EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); magnifier->SetEnabled(false); Shell::GetInstance()->RemovePreTargetHandler(&event_handler); diff --git a/ash/rotator/screen_rotation_animator.cc b/ash/rotator/screen_rotation_animator.cc index 87562191ae5e1..ed37b7f1da31b 100644 --- a/ash/rotator/screen_rotation_animator.cc +++ b/ash/rotator/screen_rotation_animator.cc @@ -67,7 +67,7 @@ gfx::Display::Rotation GetCurrentRotation(int64 display_id) { return Shell::GetInstance() ->display_manager() ->GetDisplayInfo(display_id) - .GetActiveRotation(); + .rotation(); } // Returns true if the rotation between |initial_rotation| and |new_rotation| is @@ -154,7 +154,6 @@ void LayerCleanupObserver::OnDetachedFromSequence( // animate the change. void RotateScreen(int64 display_id, gfx::Display::Rotation new_rotation, - gfx::Display::RotationSource source, base::TimeDelta duration, int rotation_degrees, int rotation_degree_offset, @@ -182,8 +181,8 @@ void RotateScreen(int64 display_id, scoped_ptr layer_cleanup_observer( new LayerCleanupObserver(old_layer_tree.Pass())); - Shell::GetInstance()->display_manager()->SetDisplayRotation( - display_id, new_rotation, source); + Shell::GetInstance()->display_manager()->SetDisplayRotation(display_id, + new_rotation); const gfx::RectF rotated_screen_bounds = root_window->GetTargetBounds(); const gfx::Point pivot = gfx::Point(rotated_screen_bounds.width() / 2, @@ -268,8 +267,7 @@ ScreenRotationAnimator::ScreenRotationAnimator(int64 display_id) ScreenRotationAnimator::~ScreenRotationAnimator() { } -void ScreenRotationAnimator::Rotate(gfx::Display::Rotation new_rotation, - gfx::Display::RotationSource source) { +void ScreenRotationAnimator::Rotate(gfx::Display::Rotation new_rotation) { const gfx::Display::Rotation current_rotation = GetCurrentRotation(display_id_); @@ -281,8 +279,8 @@ void ScreenRotationAnimator::Rotate(gfx::Display::Rotation new_rotation, switches::kAshEnableScreenRotationAnimation); if (switch_value == kRotationAnimation_None) { - Shell::GetInstance()->display_manager()->SetDisplayRotation( - display_id_, new_rotation, source); + Shell::GetInstance()->display_manager()->SetDisplayRotation(display_id_, + new_rotation); } else if (kRotationAnimation_Default == switch_value || kRotationAnimation_Partial == switch_value) { const int rotation_degree_offset = @@ -290,7 +288,7 @@ void ScreenRotationAnimator::Rotate(gfx::Display::Rotation new_rotation, ? 180 - kPartialRotationDegrees : 90 - kPartialRotationDegrees; - RotateScreen(display_id_, new_rotation, source, + RotateScreen(display_id_, new_rotation, base::TimeDelta::FromMilliseconds(kRotationDurationInMs), kPartialRotationDegrees, rotation_degree_offset, gfx::Tween::FAST_OUT_LINEAR_IN, false /* should_scale */); @@ -298,7 +296,7 @@ void ScreenRotationAnimator::Rotate(gfx::Display::Rotation new_rotation, const int rotation_degrees = Is180DegreeFlip(current_rotation, new_rotation) ? 180 : 90; - RotateScreen(display_id_, new_rotation, source, + RotateScreen(display_id_, new_rotation, base::TimeDelta::FromMilliseconds(kRotationDurationInMs), rotation_degrees, 0 /* rotation_degree_offset */, gfx::Tween::FAST_OUT_LINEAR_IN, true /* should_scale */); diff --git a/ash/rotator/screen_rotation_animator.h b/ash/rotator/screen_rotation_animator.h index 89c17848f4612..055e755906dc4 100644 --- a/ash/rotator/screen_rotation_animator.h +++ b/ash/rotator/screen_rotation_animator.h @@ -17,10 +17,8 @@ class ASH_EXPORT ScreenRotationAnimator { explicit ScreenRotationAnimator(int64 display_id); ~ScreenRotationAnimator(); - // Rotates |display_| to the |new_rotation| orientation, for the given - // |source|. The rotation will also become active. - void Rotate(gfx::Display::Rotation new_rotation, - gfx::Display::RotationSource source); + // Rotates |display_| to the |new_rotation| orientation. + void Rotate(gfx::Display::Rotation new_rotation); private: // The id of the display to rotate. diff --git a/ash/system/audio/tray_audio.cc b/ash/system/audio/tray_audio.cc index 7260fc01fe82e..21c2163c4d560 100644 --- a/ash/system/audio/tray_audio.cc +++ b/ash/system/audio/tray_audio.cc @@ -167,7 +167,7 @@ void TrayAudio::ChangeInternalSpeakerChannelMode() { const DisplayInfo& display_info = Shell::GetInstance()->display_manager()->GetDisplayInfo( gfx::Display::InternalDisplayId()); - if (display_info.GetActiveRotation() == gfx::Display::ROTATE_180) + if (display_info.rotation() == gfx::Display::ROTATE_180) channel_mode = system::TrayAudioDelegate::LEFT_RIGHT_SWAPPED; } diff --git a/ash/system/chromeos/tray_display.cc b/ash/system/chromeos/tray_display.cc index c964645800f32..10f9ede1839ad 100644 --- a/ash/system/chromeos/tray_display.cc +++ b/ash/system/chromeos/tray_display.cc @@ -207,7 +207,7 @@ class DisplayView : public ActionableView { base::string16 name = GetDisplayName(external_id); const DisplayInfo& display_info = display_manager->GetDisplayInfo(external_id); - if (display_info.GetActiveRotation() != gfx::Display::ROTATE_0 || + if (display_info.rotation() != gfx::Display::ROTATE_0 || display_info.configured_ui_scale() != 1.0f || !display_info.overscan_insets_in_dip().empty()) { name = l10n_util::GetStringFUTF16( @@ -263,10 +263,10 @@ class DisplayView : public ActionableView { bool ShouldShowFirstDisplayInfo() const { const DisplayInfo& display_info = GetDisplayManager()->GetDisplayInfo( GetDisplayManager()->first_display_id()); - return display_info.GetActiveRotation() != gfx::Display::ROTATE_0 || - display_info.configured_ui_scale() != 1.0f || - !display_info.overscan_insets_in_dip().empty() || - display_info.has_overscan(); + return display_info.rotation() != gfx::Display::ROTATE_0 || + display_info.configured_ui_scale() != 1.0f || + !display_info.overscan_insets_in_dip().empty() || + display_info.has_overscan(); } // Overridden from ActionableView. @@ -340,10 +340,9 @@ bool TrayDisplay::GetDisplayMessageForNotification( GetDisplaySize(iter->first)); return true; } - if (iter->second.GetActiveRotation() != - old_iter->second.GetActiveRotation()) { + if (iter->second.rotation() != old_iter->second.rotation()) { int rotation_text_id = 0; - switch (iter->second.GetActiveRotation()) { + switch (iter->second.rotation()) { case gfx::Display::ROTATE_0: rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_STANDARD_ORIENTATION; break; diff --git a/ash/system/overview/overview_button_tray_unittest.cc b/ash/system/overview/overview_button_tray_unittest.cc index 3268b7b068989..516a5ba37f7d9 100644 --- a/ash/system/overview/overview_button_tray_unittest.cc +++ b/ash/system/overview/overview_button_tray_unittest.cc @@ -189,7 +189,7 @@ TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletes) { new ui::ScopedAnimationDurationScaleMode( ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); ash::ScreenRotationAnimator(gfx::Display::InternalDisplayId()) - .Rotate(gfx::Display::ROTATE_270, gfx::Display::ROTATION_SOURCE_ACTIVE); + .Rotate(gfx::Display::ROTATE_270); RunAllPendingInMessageLoop(); EXPECT_FALSE(GetTray()->visible()); diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc index 153eea5cae6a6..ef7fba32473c0 100644 --- a/ash/test/ash_test_base.cc +++ b/ash/test/ash_test_base.cc @@ -202,17 +202,6 @@ ui::test::EventGenerator& AshTestBase::GetEventGenerator() { return *event_generator_.get(); } -gfx::Display::Rotation AshTestBase::GetActiveDisplayRotation(int64 id) { - return Shell::GetInstance() - ->display_manager() - ->GetDisplayInfo(id) - .GetActiveRotation(); -} - -gfx::Display::Rotation AshTestBase::GetCurrentInternalDisplayRotation() { - return GetActiveDisplayRotation(gfx::Display::InternalDisplayId()); -} - bool AshTestBase::SupportsMultipleDisplays() { return AshTestHelper::SupportsMultipleDisplays(); } diff --git a/ash/test/ash_test_base.h b/ash/test/ash_test_base.h index bc59cbc9fb390..e877eec5e9698 100644 --- a/ash/test/ash_test_base.h +++ b/ash/test/ash_test_base.h @@ -13,7 +13,6 @@ #include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkColor.h" -#include "ui/gfx/display.h" #include "ui/wm/public/window_types.h" #if defined(OS_WIN) @@ -100,12 +99,6 @@ class AshTestBase : public testing::Test { NUMBER_OF_BLOCK_REASONS }; - // Returns the rotation currentl active for the display |id|. - static gfx::Display::Rotation GetActiveDisplayRotation(int64 id); - - // Returns the rotation currently active for the internal display. - static gfx::Display::Rotation GetCurrentInternalDisplayRotation(); - // Proxy to AshTestHelper::SupportsMultipleDisplays(). static bool SupportsMultipleDisplays(); diff --git a/ash/wm/lock_layout_manager_unittest.cc b/ash/wm/lock_layout_manager_unittest.cc index 17994161281d3..fc097fb303cd6 100644 --- a/ash/wm/lock_layout_manager_unittest.cc +++ b/ash/wm/lock_layout_manager_unittest.cc @@ -212,14 +212,12 @@ TEST_F(LockLayoutManagerTest, KeyboardBounds) { ash::DisplayManager* display_manager = Shell::GetInstance()->display_manager(); display_manager->SetDisplayRotation(primary_display.id(), - gfx::Display::ROTATE_90, - gfx::Display::ROTATION_SOURCE_ACTIVE); + gfx::Display::ROTATE_90); primary_display = Shell::GetScreen()->GetPrimaryDisplay(); screen_bounds = primary_display.bounds(); EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); display_manager->SetDisplayRotation(primary_display.id(), - gfx::Display::ROTATE_0, - gfx::Display::ROTATION_SOURCE_ACTIVE); + gfx::Display::ROTATE_0); // When virtual keyboard overscroll is disabled keyboard bounds do // affect window bounds. diff --git a/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc b/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc index 847e71a27d05e..d4096f492c3fa 100644 --- a/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc +++ b/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc @@ -162,6 +162,16 @@ class MaximizeModeControllerTest : public test::AshTestBase { return maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled(); } + gfx::Display::Rotation GetInternalDisplayRotation() const { + return Shell::GetInstance()->display_manager()->GetDisplayInfo( + gfx::Display::InternalDisplayId()).rotation(); + } + + void SetInternalDisplayRotation(gfx::Display::Rotation rotation) const { + Shell::GetInstance()->display_manager()-> + SetDisplayRotation(gfx::Display::InternalDisplayId(), rotation); + } + // Attaches a SimpleTestTickClock to the MaximizeModeController with a non // null value initial value. void AttachTickClockForTest() { diff --git a/chrome/browser/chromeos/display/display_preferences.cc b/chrome/browser/chromeos/display/display_preferences.cc index 067d582e533c4..a71342ddcd4b3 100644 --- a/chrome/browser/chromeos/display/display_preferences.cc +++ b/chrome/browser/chromeos/display/display_preferences.cc @@ -251,9 +251,7 @@ void StoreCurrentDisplayProperties() { scoped_ptr property_value( new base::DictionaryValue()); - property_value->SetInteger( - "rotation", - static_cast(info.GetRotation(gfx::Display::ROTATION_SOURCE_USER))); + property_value->SetInteger("rotation", static_cast(info.rotation())); property_value->SetInteger( "ui-scale", static_cast(info.configured_ui_scale() * 1000)); @@ -358,9 +356,8 @@ void StoreDisplayRotationPrefs(bool rotation_lock) { DictionaryPrefUpdate update(local_state, prefs::kDisplayRotationLock); base::DictionaryValue* pref_data = update.Get(); pref_data->SetBoolean("lock", rotation_lock); - gfx::Display::Rotation rotation = - display_manager->->GetDisplayInfo(gfx::Display::InternalDisplayId()) - .GetRotation(gfx::Display::ROTATION_SOURCE_ACCELEROMETER); + gfx::Display::Rotation rotation = display_manager-> + GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); pref_data->SetInteger("orientation", static_cast(rotation)); } diff --git a/chrome/browser/chromeos/display/display_preferences_unittest.cc b/chrome/browser/chromeos/display/display_preferences_unittest.cc index 96c08ad7371f9..d38e5723c070c 100644 --- a/chrome/browser/chromeos/display/display_preferences_unittest.cc +++ b/chrome/browser/chromeos/display/display_preferences_unittest.cc @@ -245,8 +245,7 @@ TEST_F(DisplayPreferencesTest, BasicStores) { EXPECT_NE(dummy_id, ash::Shell::GetScreen()->GetPrimaryDisplay().id()); display_controller->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13)); - display_manager->SetDisplayRotation(id1, gfx::Display::ROTATE_90, - gfx::Display::ROTATION_SOURCE_USER); + display_manager->SetDisplayRotation(id1, gfx::Display::ROTATE_90); EXPECT_TRUE(display_manager->SetDisplayUIScale(id1, 1.25f)); EXPECT_FALSE(display_manager->SetDisplayUIScale(id2, 1.25f)); @@ -577,8 +576,7 @@ TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { display_controller->SetOverscanInsets( new_primary, gfx::Insets(10, 11, 12, 13)); - display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90, - gfx::Display::ROTATION_SOURCE_USER); + display_manager->SetDisplayRotation(new_primary, gfx::Display::ROTATE_90); // Does not store the preferences locally. EXPECT_FALSE(local_state()->FindPreference( @@ -601,7 +599,7 @@ TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { const ash::DisplayInfo& info_primary = display_manager->GetDisplayInfo(new_primary); - EXPECT_EQ(gfx::Display::ROTATE_90, info_primary.GetActiveRotation()); + EXPECT_EQ(gfx::Display::ROTATE_90, info_primary.rotation()); EXPECT_EQ(1.0f, info_primary.configured_ui_scale()); } @@ -671,12 +669,10 @@ TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) { LoggedInAsUser(); // Populate the properties. display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), - gfx::Display::ROTATE_180, - gfx::Display::ROTATION_SOURCE_USER); + gfx::Display::ROTATE_180); // Reset property to avoid rotation lock display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), - gfx::Display::ROTATE_0, - gfx::Display::ROTATION_SOURCE_USER); + gfx::Display::ROTATE_0); // Open up 270 degrees to trigger maximize mode scoped_refptr update( @@ -694,7 +690,8 @@ TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) { update->Set(chromeos::ACCELEROMETER_SOURCE_SCREEN, -kMeanGravity, 0.0f, 0.0f); controller->OnAccelerometerUpdated(update); shell->screen_orientation_controller()->OnAccelerometerUpdated(update); - EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); + EXPECT_EQ(gfx::Display::ROTATE_90, display_manager-> + GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation()); const base::DictionaryValue* properties = local_state()->GetDictionary(prefs::kDisplayProperties); @@ -704,17 +701,6 @@ TEST_F(DisplayPreferencesTest, DontSaveMaximizeModeControllerRotations) { int rotation = -1; EXPECT_TRUE(property->GetInteger("rotation", &rotation)); EXPECT_EQ(gfx::Display::ROTATE_0, rotation); - - // Trigger a save, the acceleration rotation should not be saved as the user - // rotation. - StoreDisplayPrefs(); - properties = local_state()->GetDictionary(prefs::kDisplayProperties); - property = NULL; - EXPECT_TRUE(properties->GetDictionary( - base::Int64ToString(gfx::Display::InternalDisplayId()), &property)); - rotation = -1; - EXPECT_TRUE(property->GetInteger("rotation", &rotation)); - EXPECT_EQ(gfx::Display::ROTATE_0, rotation); } // Tests that the rotation state is saved without a user being logged in. @@ -734,7 +720,9 @@ TEST_F(DisplayPreferencesTest, StoreRotationStateNoLogin) { EXPECT_EQ(current_rotation_lock, rotation_lock); int orientation; - gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); + gfx::Display::Rotation current_rotation = ash::Shell::GetInstance()-> + display_manager()-> + GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); EXPECT_EQ(current_rotation, orientation); } @@ -757,7 +745,9 @@ TEST_F(DisplayPreferencesTest, StoreRotationStateGuest) { EXPECT_EQ(current_rotation_lock, rotation_lock); int orientation; - gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); + gfx::Display::Rotation current_rotation = ash::Shell::GetInstance()-> + display_manager()-> + GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); EXPECT_EQ(current_rotation, orientation); } @@ -780,7 +770,9 @@ TEST_F(DisplayPreferencesTest, StoreRotationStateNormalUser) { EXPECT_EQ(current_rotation_lock, rotation_lock); int orientation; - gfx::Display::Rotation current_rotation = GetCurrentInternalDisplayRotation(); + gfx::Display::Rotation current_rotation = ash::Shell::GetInstance()-> + display_manager()-> + GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); EXPECT_TRUE(properties->GetInteger("orientation", &orientation)); EXPECT_EQ(current_rotation, orientation); } @@ -796,7 +788,8 @@ TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) { bool initial_rotation_lock = IsRotationLocked(); ASSERT_FALSE(initial_rotation_lock); ash::DisplayManager* display_manager = shell->display_manager(); - gfx::Display::Rotation initial_rotation = GetCurrentInternalDisplayRotation(); + gfx::Display::Rotation initial_rotation = display_manager-> + GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); ASSERT_EQ(gfx::Display::ROTATE_0, initial_rotation); StoreDisplayRotationPrefs(initial_rotation_lock); @@ -813,8 +806,8 @@ TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) { EXPECT_EQ(gfx::Display::ROTATE_90, display_rotation); bool rotation_lock = IsRotationLocked(); - gfx::Display::Rotation before_maximize_mode_rotation = - GetCurrentInternalDisplayRotation(); + gfx::Display::Rotation before_maximize_mode_rotation = display_manager-> + GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); // Settings should not be applied until maximize mode activates EXPECT_FALSE(rotation_lock); @@ -831,8 +824,8 @@ TEST_F(DisplayPreferencesTest, LoadRotationNoLogin) { maximize_mode_controller->OnAccelerometerUpdated(update); EXPECT_TRUE(maximize_mode_controller->IsMaximizeModeWindowManagerEnabled()); bool screen_orientation_rotation_lock = IsRotationLocked(); - gfx::Display::Rotation maximize_mode_rotation = - GetCurrentInternalDisplayRotation(); + gfx::Display::Rotation maximize_mode_rotation = display_manager-> + GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); EXPECT_TRUE(screen_orientation_rotation_lock); EXPECT_EQ(gfx::Display::ROTATE_90, maximize_mode_rotation); } diff --git a/chrome/browser/extensions/display_info_provider_chromeos.cc b/chrome/browser/extensions/display_info_provider_chromeos.cc index b9d083de48046..60c6e6cc3d813 100644 --- a/chrome/browser/extensions/display_info_provider_chromeos.cc +++ b/chrome/browser/extensions/display_info_provider_chromeos.cc @@ -334,8 +334,7 @@ bool DisplayInfoProviderChromeOS::SetInfo(const std::string& display_id_str, // Process 'rotation' parameter. if (info.rotation) { display_manager->SetDisplayRotation(display_id, - DegreesToRotation(*info.rotation), - gfx::Display::ROTATION_SOURCE_ACTIVE); + DegreesToRotation(*info.rotation)); } // Process new display origin parameters. diff --git a/chrome/browser/extensions/display_info_provider_chromeos_unittest.cc b/chrome/browser/extensions/display_info_provider_chromeos_unittest.cc index caef15fbb5df5..493e54c4ac7ca 100644 --- a/chrome/browser/extensions/display_info_provider_chromeos_unittest.cc +++ b/chrome/browser/extensions/display_info_provider_chromeos_unittest.cc @@ -121,8 +121,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetRotation) { EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0]->bounds)); EXPECT_EQ(90, result[0]->rotation); - GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_270, - gfx::Display::ROTATION_SOURCE_ACTIVE); + GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_270); result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); @@ -132,8 +131,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetRotation) { EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0]->bounds)); EXPECT_EQ(270, result[0]->rotation); - GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_180, - gfx::Display::ROTATION_SOURCE_ACTIVE); + GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_180); result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); @@ -143,8 +141,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetRotation) { EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); EXPECT_EQ(180, result[0]->rotation); - GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_0, - gfx::Display::ROTATION_SOURCE_ACTIVE); + GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_0); result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); diff --git a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc index db256f162a739..d354743822091 100644 --- a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc @@ -279,7 +279,7 @@ void DisplayOptionsHandler::SendDisplayInfo( js_display->SetBoolean("isPrimary", display.id() == primary_id); js_display->SetBoolean("isInternal", display.IsInternal()); js_display->SetInteger("orientation", - static_cast(display_info.GetActiveRotation())); + static_cast(display_info.rotation())); base::ListValue* js_resolutions = new base::ListValue(); for (const ash::DisplayMode& display_mode : display_info.display_modes()) { @@ -438,8 +438,7 @@ void DisplayOptionsHandler::HandleSetOrientation(const base::ListValue* args) { content::RecordAction( base::UserMetricsAction("Options_DisplaySetOrientation")); - ash::ScreenRotationAnimator(display_id) - .Rotate(new_rotation, gfx::Display::ROTATION_SOURCE_USER); + ash::ScreenRotationAnimator(display_id).Rotate(new_rotation); } void DisplayOptionsHandler::HandleSetColorProfile(const base::ListValue* args) { diff --git a/ui/gfx/display.h b/ui/gfx/display.h index f6c23c1fbbac8..fe2a40cf632b6 100644 --- a/ui/gfx/display.h +++ b/ui/gfx/display.h @@ -30,18 +30,6 @@ class GFX_EXPORT Display { ROTATE_270, }; - // The display rotation can have multiple causes for change. A user can set a - // preference. On devices with accelerometers, they can change the rotation. - // RotationSource allows for the tracking of a Rotation per source of the - // change. ROTATION_SOURCE_ACTIVE is the current rotation of the display. - // Rotation changes not due to an accelerometer, nor the user, are to use this - // source directly. - enum RotationSource { - ROTATION_SOURCE_ACCELEROMETER = 0, - ROTATION_SOURCE_ACTIVE, - ROTATION_SOURCE_USER, - }; - // Touch support for the display. enum TouchSupport { TOUCH_SUPPORT_UNKNOWN,