| 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/common/wm/maximize_mode/maximize_mode_controller.h" | 5 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/ash_switches.h" | 9 #include "ash/common/ash_switches.h" |
| 10 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" | 10 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 *update, chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD) && | 199 *update, chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD) && |
| 200 IsAngleBetweenAccelerometerReadingsStable(*update)) { | 200 IsAngleBetweenAccelerometerReadingsStable(*update)) { |
| 201 // update.has(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD) | 201 // update.has(chromeos::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD) |
| 202 // Ignore the reading if it appears unstable. The reading is considered | 202 // Ignore the reading if it appears unstable. The reading is considered |
| 203 // unstable if it deviates too much from gravity and/or the magnitude of the | 203 // unstable if it deviates too much from gravity and/or the magnitude of the |
| 204 // reading from the lid differs too much from the reading from the base. | 204 // reading from the lid differs too much from the reading from the base. |
| 205 HandleHingeRotation(update); | 205 HandleHingeRotation(update); |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 | 208 |
| 209 void MaximizeModeController::LidEventReceived(bool open, | 209 void MaximizeModeController::LidEventReceived( |
| 210 const base::TimeTicks& time) { | 210 chromeos::PowerManagerClient::LidState state, |
| 211 const base::TimeTicks& time) { |
| 212 const bool open = state == chromeos::PowerManagerClient::LidState::OPEN; |
| 211 if (open) | 213 if (open) |
| 212 last_lid_open_time_ = time; | 214 last_lid_open_time_ = time; |
| 213 lid_is_closed_ = !open; | 215 lid_is_closed_ = !open; |
| 214 LeaveMaximizeMode(); | 216 LeaveMaximizeMode(); |
| 215 } | 217 } |
| 216 | 218 |
| 217 void MaximizeModeController::TabletModeEventReceived( | 219 void MaximizeModeController::TabletModeEventReceived( |
| 218 bool on, | 220 chromeos::PowerManagerClient::TabletMode mode, |
| 219 const base::TimeTicks& time) { | 221 const base::TimeTicks& time) { |
| 222 const bool on = mode == chromeos::PowerManagerClient::TabletMode::ON; |
| 220 tablet_mode_switch_is_on_ = on; | 223 tablet_mode_switch_is_on_ = on; |
| 221 // Do not change if docked. | 224 // Do not change if docked. |
| 222 if (!display::Display::HasInternalDisplay() || | 225 if (!display::Display::HasInternalDisplay() || |
| 223 !WmShell::Get()->IsActiveDisplayId( | 226 !WmShell::Get()->IsActiveDisplayId( |
| 224 display::Display::InternalDisplayId())) { | 227 display::Display::InternalDisplayId())) { |
| 225 return; | 228 return; |
| 226 } | 229 } |
| 227 // The tablet mode switch activates at 300 degrees, so it is always reliable | 230 // The tablet mode switch activates at 300 degrees, so it is always reliable |
| 228 // when |on|. However we wish to exit maximize mode at a smaller angle, so | 231 // when |on|. However we wish to exit maximize mode at a smaller angle, so |
| 229 // when |on| is false we ignore if it is possible to calculate the lid angle. | 232 // when |on| is false we ignore if it is possible to calculate the lid angle. |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 return elapsed_time.InSeconds() <= kLidRecentlyOpenedDurationSeconds; | 429 return elapsed_time.InSeconds() <= kLidRecentlyOpenedDurationSeconds; |
| 427 } | 430 } |
| 428 | 431 |
| 429 void MaximizeModeController::SetTickClockForTest( | 432 void MaximizeModeController::SetTickClockForTest( |
| 430 std::unique_ptr<base::TickClock> tick_clock) { | 433 std::unique_ptr<base::TickClock> tick_clock) { |
| 431 DCHECK(tick_clock_); | 434 DCHECK(tick_clock_); |
| 432 tick_clock_ = std::move(tick_clock); | 435 tick_clock_ = std::move(tick_clock); |
| 433 } | 436 } |
| 434 | 437 |
| 435 } // namespace ash | 438 } // namespace ash |
| OLD | NEW |