Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 5 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 6 | 6 |
| 7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
| 8 #include "ash/accelerators/accelerator_table.h" | 8 #include "ash/accelerators/accelerator_table.h" |
| 9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 } | 125 } |
| 126 | 126 |
| 127 void MaximizeModeController::AddWindow(aura::Window* window) { | 127 void MaximizeModeController::AddWindow(aura::Window* window) { |
| 128 if (IsMaximizeModeWindowManagerEnabled()) | 128 if (IsMaximizeModeWindowManagerEnabled()) |
| 129 maximize_mode_window_manager_->AddWindow(window); | 129 maximize_mode_window_manager_->AddWindow(window); |
| 130 } | 130 } |
| 131 | 131 |
| 132 #if defined(OS_CHROMEOS) | 132 #if defined(OS_CHROMEOS) |
| 133 void MaximizeModeController::OnAccelerometerUpdated( | 133 void MaximizeModeController::OnAccelerometerUpdated( |
| 134 const ui::AccelerometerUpdate& update) { | 134 const ui::AccelerometerUpdate& update) { |
| 135 if (!update.has(ui::ACCELEROMETER_SOURCE_SCREEN)) | |
| 136 return; | |
| 137 | |
| 135 bool first_accelerometer_update = !have_seen_accelerometer_data_; | 138 bool first_accelerometer_update = !have_seen_accelerometer_data_; |
| 136 have_seen_accelerometer_data_ = true; | 139 have_seen_accelerometer_data_ = true; |
| 137 | 140 |
| 138 if (!update.has(ui::ACCELEROMETER_SOURCE_SCREEN)) | |
| 139 return; | |
| 140 | |
| 141 // Whether or not we enter maximize mode affects whether we handle screen | 141 // Whether or not we enter maximize mode affects whether we handle screen |
| 142 // rotation, so determine whether to enter maximize mode first. | 142 // rotation, so determine whether to enter maximize mode first. |
| 143 if (!update.has(ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD)) { | 143 if (!update.has(ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD)) { |
| 144 if (first_accelerometer_update) | 144 if (first_accelerometer_update) |
| 145 EnterMaximizeMode(); | 145 EnterMaximizeMode(); |
|
flackr
2015/02/03 22:32:11
Seems like this path (entering maximize mode when
jonross
2015/02/04 18:31:23
Done.
| |
| 146 } else if (chromeos::AccelerometerReader::IsReadingStable( | 146 } else if (chromeos::AccelerometerReader::IsReadingStable( |
| 147 update, ui::ACCELEROMETER_SOURCE_SCREEN) && | 147 update, ui::ACCELEROMETER_SOURCE_SCREEN) && |
| 148 chromeos::AccelerometerReader::IsReadingStable( | 148 chromeos::AccelerometerReader::IsReadingStable( |
| 149 update, ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD) && | 149 update, ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD) && |
| 150 std::abs(update.get(ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD) | 150 std::abs(update.get(ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD) |
| 151 .Length() - | 151 .Length() - |
| 152 update.get(ui::ACCELEROMETER_SOURCE_SCREEN).Length()) <= | 152 update.get(ui::ACCELEROMETER_SOURCE_SCREEN).Length()) <= |
| 153 kNoisyMagnitudeDeviation) { | 153 kNoisyMagnitudeDeviation) { |
| 154 // update.has(ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD) | 154 // update.has(ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD) |
| 155 // Ignore the reading if it appears unstable. The reading is considered | 155 // Ignore the reading if it appears unstable. The reading is considered |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 return elapsed_time <= kLidRecentlyOpenedDuration; | 302 return elapsed_time <= kLidRecentlyOpenedDuration; |
| 303 } | 303 } |
| 304 | 304 |
| 305 void MaximizeModeController::SetTickClockForTest( | 305 void MaximizeModeController::SetTickClockForTest( |
| 306 scoped_ptr<base::TickClock> tick_clock) { | 306 scoped_ptr<base::TickClock> tick_clock) { |
| 307 DCHECK(tick_clock_); | 307 DCHECK(tick_clock_); |
| 308 tick_clock_ = tick_clock.Pass(); | 308 tick_clock_ = tick_clock.Pass(); |
| 309 } | 309 } |
| 310 | 310 |
| 311 } // namespace ash | 311 } // namespace ash |
| OLD | NEW |