Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit dde12b2

Browse files
jonrossCommit bot
authored andcommitted
Revert of Merge Prevent DisplayPreferences from saving incorrect rotations. (patchset #1 id:1 of https://codereview.chromium.org/1107383002/)
Reason for revert: Merge issue broke cros build https://uberchromegw.corp.google.com/i/chrome/builders/cros%20beta/builds/8333 Original issue's description: > Merge Prevent DisplayPreferences from saving incorrect rotations. > Refactor DisplayInfo::rotation_ to track different sources of rotations > > Currently DisplayInfo only tracks the active rotation for the given display. > DisplayPreferences however saves a user rotation, as well as an accelerometer > rotation. DisplayController::Observer::OnDisplayConfigurationChanged triggers > the saving of display preferences. > > This has been leading to active accelerometer rotations being saved as user > preferences, and being re-applied upon reboot. > > This change refactors DisplayInfo to track one rotation per source of rotation > changes. DisplayPreferences has been updated to save based on these states. > > TEST=DisplayPreferencesTest.DontSaveMaximizeModeControllerRotations, also ran > ash_unittests, and unit_tests > BUG=chrome-os-partner:37555, 469752, 466861 > [email protected], [email protected], [email protected] > NOTRY=true > NOPRESUBMIT=true > > Review URL: https://codereview.chromium.org/1071353003 > > Cr-Commit-Position: refs/heads/master@{#326614} > (cherry picked from commit d01de7f) [email protected],[email protected],[email protected] NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=chrome-os-partner:37555, 469752, 466861 Review URL: https://codereview.chromium.org/1108343002 Cr-Commit-Position: refs/branch-heads/2357@{#249} Cr-Branched-From: 59d4494-refs/heads/master@{#323860}
1 parent bb34612 commit dde12b2

28 files changed

+213
-284
lines changed

ash/accelerators/accelerator_controller.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ void HandleRotateScreen() {
295295
const DisplayInfo& display_info =
296296
Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id());
297297
ash::ScreenRotationAnimator(display.id())
298-
.Rotate(GetNextRotation(display_info.GetActiveRotation()),
299-
gfx::Display::ROTATION_SOURCE_USER);
298+
.Rotate(GetNextRotation(display_info.rotation()));
300299
}
301300

302301
// Rotate the active window.

ash/content/display/screen_orientation_controller_chromeos.cc

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ blink::WebScreenOrientationLockType GetDisplayNaturalOrientation() {
4545
ash::DisplayInfo info =
4646
display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId());
4747
gfx::Size size = info.size_in_pixel();
48-
switch (info.GetActiveRotation()) {
48+
switch (info.rotation()) {
4949
case gfx::Display::ROTATE_0:
5050
case gfx::Display::ROTATE_180:
5151
return size.height() >= size.width()
@@ -112,16 +112,15 @@ void ScreenOrientationController::SetRotationLocked(bool rotation_locked) {
112112
}
113113

114114
void ScreenOrientationController::SetDisplayRotation(
115-
gfx::Display::Rotation rotation,
116-
gfx::Display::RotationSource source) {
115+
gfx::Display::Rotation rotation) {
117116
DisplayManager* display_manager = Shell::GetInstance()->display_manager();
118117
if (!display_manager->HasInternalDisplay())
119118
return;
120119
current_rotation_ = rotation;
121120
base::AutoReset<bool> auto_ignore_display_configuration_updates(
122121
&ignore_display_configuration_updates_, true);
123122
ash::ScreenRotationAnimator(gfx::Display::InternalDisplayId())
124-
.Rotate(rotation, source);
123+
.Rotate(rotation);
125124
}
126125

127126
void ScreenOrientationController::OnWindowActivated(aura::Window* gained_active,
@@ -202,7 +201,7 @@ void ScreenOrientationController::OnDisplayConfigurationChanged() {
202201
return;
203202
gfx::Display::Rotation user_rotation =
204203
display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId())
205-
.GetActiveRotation();
204+
.rotation();
206205
if (user_rotation != current_rotation_) {
207206
// A user may change other display configuration settings. When the user
208207
// does change the rotation setting, then lock rotation to prevent the
@@ -220,7 +219,7 @@ void ScreenOrientationController::OnMaximizeModeStarted() {
220219
if (display_manager->HasInternalDisplay()) {
221220
current_rotation_ = user_rotation_ =
222221
display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId())
223-
.GetActiveRotation();
222+
.rotation();
224223
}
225224
if (!rotation_locked_)
226225
LoadDisplayRotationProperties();
@@ -232,14 +231,13 @@ void ScreenOrientationController::OnMaximizeModeEnded() {
232231
chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this);
233232
Shell::GetInstance()->display_controller()->RemoveObserver(this);
234233
if (current_rotation_ != user_rotation_)
235-
SetDisplayRotation(user_rotation_, gfx::Display::ROTATION_SOURCE_USER);
234+
SetDisplayRotation(user_rotation_);
236235
}
237236

238237
void ScreenOrientationController::LockRotation(
239-
gfx::Display::Rotation rotation,
240-
gfx::Display::RotationSource source) {
238+
gfx::Display::Rotation rotation) {
241239
SetRotationLocked(true);
242-
SetDisplayRotation(rotation, source);
240+
SetDisplayRotation(rotation);
243241
}
244242

245243
void ScreenOrientationController::LockRotationToOrientation(
@@ -272,8 +270,7 @@ void ScreenOrientationController::LockRotationToOrientation(
272270
blink::WebScreenOrientationLockLandscape);
273271
break;
274272
case blink::WebScreenOrientationLockNatural:
275-
LockRotation(gfx::Display::ROTATE_0,
276-
gfx::Display::ROTATION_SOURCE_ACTIVE);
273+
LockRotation(gfx::Display::ROTATE_0);
277274
break;
278275
default:
279276
NOTREACHED();
@@ -285,16 +282,14 @@ void ScreenOrientationController::LockRotationToPrimaryOrientation(
285282
blink::WebScreenOrientationLockType lock_orientation) {
286283
LockRotation(natural_orientation_ == lock_orientation
287284
? gfx::Display::ROTATE_0
288-
: gfx::Display::ROTATE_90,
289-
gfx::Display::ROTATION_SOURCE_ACTIVE);
285+
: gfx::Display::ROTATE_90);
290286
}
291287

292288
void ScreenOrientationController::LockRotationToSecondaryOrientation(
293289
blink::WebScreenOrientationLockType lock_orientation) {
294290
LockRotation(natural_orientation_ == lock_orientation
295291
? gfx::Display::ROTATE_180
296-
: gfx::Display::ROTATE_270,
297-
gfx::Display::ROTATION_SOURCE_ACTIVE);
292+
: gfx::Display::ROTATE_270);
298293
}
299294

300295
void ScreenOrientationController::LockToRotationMatchingOrientation(
@@ -305,22 +300,20 @@ void ScreenOrientationController::LockToRotationMatchingOrientation(
305300

306301
gfx::Display::Rotation rotation =
307302
display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId())
308-
.GetActiveRotation();
303+
.rotation();
309304
if (natural_orientation_ == lock_orientation) {
310305
if (rotation == gfx::Display::ROTATE_0 ||
311306
rotation == gfx::Display::ROTATE_180) {
312307
SetRotationLocked(true);
313308
} else {
314-
LockRotation(gfx::Display::ROTATE_0,
315-
gfx::Display::ROTATION_SOURCE_ACTIVE);
309+
LockRotation(gfx::Display::ROTATE_0);
316310
}
317311
} else {
318312
if (rotation == gfx::Display::ROTATE_90 ||
319313
rotation == gfx::Display::ROTATE_270) {
320314
SetRotationLocked(true);
321315
} else {
322-
LockRotation(gfx::Display::ROTATE_90,
323-
gfx::Display::ROTATION_SOURCE_ACTIVE);
316+
LockRotation(gfx::Display::ROTATE_90);
324317
}
325318
}
326319
}
@@ -372,16 +365,14 @@ void ScreenOrientationController::HandleScreenRotation(
372365

373366
if (new_rotation != current_rotation_ &&
374367
IsRotationAllowedInLockedState(new_rotation))
375-
SetDisplayRotation(new_rotation,
376-
gfx::Display::ROTATION_SOURCE_ACCELEROMETER);
368+
SetDisplayRotation(new_rotation);
377369
}
378370

379371
void ScreenOrientationController::LoadDisplayRotationProperties() {
380372
DisplayManager* display_manager = Shell::GetInstance()->display_manager();
381373
if (!display_manager->registered_internal_display_rotation_lock())
382374
return;
383-
SetDisplayRotation(display_manager->registered_internal_display_rotation(),
384-
gfx::Display::ROTATION_SOURCE_ACCELEROMETER);
375+
SetDisplayRotation(display_manager->registered_internal_display_rotation());
385376
SetRotationLocked(true);
386377
}
387378

ash/content/display/screen_orientation_controller_chromeos.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,8 @@ class ASH_EXPORT ScreenOrientationController
6969
// display rotation.
7070
void SetRotationLocked(bool rotation_locked);
7171

72-
// Sets the display rotation for the given |source|. The new |rotation| will
73-
// also become active. Display changed notifications are surpressed for this
74-
// change.
75-
void SetDisplayRotation(gfx::Display::Rotation rotation,
76-
gfx::Display::RotationSource source);
72+
// Sets the display rotation and suppresses display notifications.
73+
void SetDisplayRotation(gfx::Display::Rotation rotation);
7774

7875
// aura::client::ActivationChangeObserver:
7976
void OnWindowActivated(aura::Window* gained_active,
@@ -105,8 +102,7 @@ class ASH_EXPORT ScreenOrientationController
105102
// Sets the display rotation to |rotation|. Future accelerometer updates
106103
// should not be used to change the rotation. SetRotationLocked(false) removes
107104
// the rotation lock.
108-
void LockRotation(gfx::Display::Rotation rotation,
109-
gfx::Display::RotationSource source);
105+
void LockRotation(gfx::Display::Rotation rotation);
110106

111107
// Sets the display rotation based on |lock_orientation|. Future accelerometer
112108
// updates should not be used to change the rotation. SetRotationLocked(false)

0 commit comments

Comments
 (0)