summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorflackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-22 19:20:35 +0000
committerflackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-22 19:20:35 +0000
commit3b639bcefe133191bd99813d2568647d605381f1 (patch)
treea90d31e0ddfb8a2dcc123def166bf684f71f266e /ash
parent92483ea87f4955d282747489ba2c526dd33c31db (diff)
downloadchromium_src-3b639bcefe133191bd99813d2568647d605381f1.zip
chromium_src-3b639bcefe133191bd99813d2568647d605381f1.tar.gz
chromium_src-3b639bcefe133191bd99813d2568647d605381f1.tar.bz2
Fix hinge angle calculations while device is rotated.
This did not affect maximize mode changes very much as with the incorrect calculation the hinge angle tends towards 0 or 360 (depending on whether it is past 180 or not) which would preserve the current mode. BUG=None TEST=Manual, verified with logging that angle is consistent as device is rotated towards near vertical angle. Review URL: https://codereview.chromium.org/246013005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265324 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/wm/maximize_mode/maximize_mode_controller.cc20
1 files changed, 13 insertions, 7 deletions
diff --git a/ash/wm/maximize_mode/maximize_mode_controller.cc b/ash/wm/maximize_mode/maximize_mode_controller.cc
index ac018bb..0b9ee53 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller.cc
+++ b/ash/wm/maximize_mode/maximize_mode_controller.cc
@@ -31,9 +31,9 @@ const float kFullyOpenAngleErrorTolerance = 20.0f;
// the accelerometers for the base and lid approach the same values (i.e.
// gravity pointing in the direction of the hinge). When this happens we cannot
// compute the hinge angle reliably and must turn ignore accelerometer readings.
-// This is the angle from vertical under which we will not compute a hinge
-// angle.
-const float kHingeAxisAlignedThreshold = 15.0f;
+// This is the minimum acceleration perpendicular to the hinge under which to
+// detect hinge angle.
+const float kHingeAngleDetectionThreshold = 0.25f;
// The maximum deviation from the acceleration expected due to gravity under
// which to detect hinge angle and screen rotation.
@@ -115,18 +115,24 @@ void MaximizeModeController::HandleHingeRotation(const gfx::Vector3dF& base,
static const gfx::Vector3dF hinge_vector(0.0f, 1.0f, 0.0f);
bool maximize_mode_engaged =
Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled();
+ // Ignore the component of acceleration parallel to the hinge for the purposes
+ // of hinge angle calculation.
+ gfx::Vector3dF base_flattened(base);
+ gfx::Vector3dF lid_flattened(lid);
+ base_flattened.set_y(0.0f);
+ lid_flattened.set_y(0.0f);
// As the hinge approaches a vertical angle, the base and lid accelerometers
// approach the same values making any angle calculations highly inaccurate.
// Bail out early when it is too close.
- float hinge_angle = AngleBetweenVectorsInDegrees(base, hinge_vector);
- if (hinge_angle < kHingeAxisAlignedThreshold ||
- hinge_angle > 180.0f - kHingeAxisAlignedThreshold) {
+ if (base_flattened.Length() < kHingeAngleDetectionThreshold ||
+ lid_flattened.Length() < kHingeAngleDetectionThreshold) {
return;
}
// Compute the angle between the base and the lid.
- float angle = ClockwiseAngleBetweenVectorsInDegrees(base, lid, hinge_vector);
+ float angle = ClockwiseAngleBetweenVectorsInDegrees(base_flattened,
+ lid_flattened, hinge_vector);
// Toggle maximize mode on or off when corresponding thresholds are passed.
// TODO(flackr): Make MaximizeModeController own the MaximizeModeWindowManager