Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: ash/wm/maximize_mode/maximize_mode_controller.cc

Issue 2020553003: Hook up TABLET_MODE switch to maximize_mode_controller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/wm/maximize_mode/maximize_mode_controller.cc
diff --git a/ash/wm/maximize_mode/maximize_mode_controller.cc b/ash/wm/maximize_mode/maximize_mode_controller.cc
index 9d8b18dae29de82390b61d4e439eca666dfd59db..0b5417903402816aacd16644d2350b6122b968b9 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller.cc
+++ b/ash/wm/maximize_mode/maximize_mode_controller.cc
@@ -100,9 +100,11 @@ bool IsAngleBetweenAccelerometerReadingsStable(
MaximizeModeController::MaximizeModeController()
: have_seen_accelerometer_data_(false),
- lid_open_past_180_(false),
touchview_usage_interval_start_time_(base::Time::Now()),
tick_clock_(new base::DefaultTickClock()),
+#if defined(OS_CHROMEOS)
+ tablet_mode_switch_is_on_(false),
+#endif
lid_is_closed_(false) {
Shell* shell = Shell::GetInstance();
shell->AddShellObserver(this);
@@ -208,6 +210,8 @@ void MaximizeModeController::OnAccelerometerUpdated(
ui::IsAccelerometerReadingStable(
*update, chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD) &&
IsAngleBetweenAccelerometerReadingsStable(*update)) {
+ if (tablet_mode_switch_is_on_)
+ return;
Daniel Erat 2016/06/06 17:23:07 i'm wondering if this early return can cause probl
jcliang 2016/06/06 18:19:25 I think the {base|lid}_smoothed_ essentially act l
jonross 2016/06/07 15:27:15 We continuously compute them as the motion from fl
jcliang 2016/06/07 16:57:23 Should I remove the early return here? The smoothe
jonross 2016/06/07 22:04:42 I think I would like to see this check after the s
jcliang 2016/06/08 04:12:38 Done.
// update.has(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD)
// Ignore the reading if it appears unstable. The reading is considered
// unstable if it deviates too much from gravity and/or the magnitude of the
@@ -224,6 +228,18 @@ void MaximizeModeController::LidEventReceived(bool open,
LeaveMaximizeMode();
}
+void MaximizeModeController::TabletModeEventReceived(
+ bool on,
+ const base::TimeTicks& time) {
+ if (on) {
+ tablet_mode_switch_is_on_ = true;
+ if (!IsMaximizeModeWindowManagerEnabled())
+ EnterMaximizeMode();
+ } else {
+ tablet_mode_switch_is_on_ = false;
+ }
+}
+
void MaximizeModeController::SuspendImminent() {
// The system is about to suspend, so record TouchView usage interval metrics
// based on whether TouchView mode is currently active.
@@ -255,6 +271,8 @@ void MaximizeModeController::HandleHingeRotation(
kHingeVerticalSmoothingStart) /
(kHingeVerticalSmoothingMaximum -
kHingeVerticalSmoothingStart)));
+ bool is_base_vertical =
+ std::abs(base_reading.x()) > kHingeVerticalSmoothingMaximum;
base_smoothed_.Scale(smoothing_ratio);
base_reading.Scale(1.0f - smoothing_ratio);
@@ -277,7 +295,7 @@ void MaximizeModeController::HandleHingeRotation(
if (lid_angle < 0.0f)
lid_angle += 360.0f;
- bool is_angle_stable = lid_angle >= kMinStableAngle &&
+ bool is_angle_stable = !is_base_vertical && lid_angle >= kMinStableAngle &&
lid_angle <= kMaxStableAngle;
// Clear the last_lid_open_time_ for a stable reading so that there is less
@@ -287,14 +305,12 @@ void MaximizeModeController::HandleHingeRotation(
last_lid_open_time_ = base::TimeTicks();
// Toggle maximize mode on or off when corresponding thresholds are passed.
- if (lid_open_past_180_ && is_angle_stable &&
+ if (IsMaximizeModeWindowManagerEnabled() && is_angle_stable &&
lid_angle <= kExitMaximizeModeAngle) {
- lid_open_past_180_ = false;
LeaveMaximizeMode();
- } else if (!lid_open_past_180_ && !lid_is_closed_ &&
+ } else if (!IsMaximizeModeWindowManagerEnabled() && !lid_is_closed_ &&
lid_angle >= kEnterMaximizeModeAngle &&
(is_angle_stable || !WasLidOpenedRecently())) {
- lid_open_past_180_ = true;
EnterMaximizeMode();
}
}

Powered by Google App Engine
This is Rietveld 408576698