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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/accelerators/accelerator_controller.h" | 9 #include "ash/accelerators/accelerator_controller.h" |
10 #include "ash/accelerators/accelerator_table.h" | 10 #include "ash/accelerators/accelerator_table.h" |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 // Clear the last_lid_open_time_ for a stable reading so that there is less | 283 // Clear the last_lid_open_time_ for a stable reading so that there is less |
284 // chance of a delay if the lid is moved from the close state to the fully | 284 // chance of a delay if the lid is moved from the close state to the fully |
285 // open state very quickly. | 285 // open state very quickly. |
286 if (is_angle_stable) | 286 if (is_angle_stable) |
287 last_lid_open_time_ = base::TimeTicks(); | 287 last_lid_open_time_ = base::TimeTicks(); |
288 | 288 |
289 // Toggle maximize mode on or off when corresponding thresholds are passed. | 289 // Toggle maximize mode on or off when corresponding thresholds are passed. |
290 if (lid_open_past_180_ && is_angle_stable && | 290 if (lid_open_past_180_ && is_angle_stable && |
291 lid_angle <= kExitMaximizeModeAngle) { | 291 lid_angle <= kExitMaximizeModeAngle) { |
292 lid_open_past_180_ = false; | 292 lid_open_past_180_ = false; |
293 if (!base::CommandLine::ForCurrentProcess()-> | 293 LeaveMaximizeMode(); |
294 HasSwitch(switches::kAshEnableTouchViewTesting)) { | |
295 LeaveMaximizeMode(); | |
296 } | |
297 event_blocker_.reset(); | |
298 } else if (!lid_open_past_180_ && !lid_is_closed_ && | 294 } else if (!lid_open_past_180_ && !lid_is_closed_ && |
299 lid_angle >= kEnterMaximizeModeAngle && | 295 lid_angle >= kEnterMaximizeModeAngle && |
300 (is_angle_stable || !WasLidOpenedRecently())) { | 296 (is_angle_stable || !WasLidOpenedRecently())) { |
301 lid_open_past_180_ = true; | 297 lid_open_past_180_ = true; |
302 if (!base::CommandLine::ForCurrentProcess()-> | 298 EnterMaximizeMode(); |
303 HasSwitch(switches::kAshEnableTouchViewTesting)) { | |
304 EnterMaximizeMode(); | |
305 } | |
306 // Always reset first to avoid creation before destruction of a previous | |
307 // object. | |
308 event_blocker_.reset(); | |
309 #if defined(USE_X11) | |
310 event_blocker_.reset(new ScopedDisableInternalMouseAndKeyboardX11); | |
311 #elif defined(USE_OZONE) | |
312 event_blocker_.reset(new ScopedDisableInternalMouseAndKeyboardOzone); | |
313 #endif | |
314 } | 299 } |
315 } | 300 } |
316 #endif // OS_CHROMEOS | 301 #endif // OS_CHROMEOS |
317 | 302 |
318 void MaximizeModeController::EnterMaximizeMode() { | 303 void MaximizeModeController::EnterMaximizeMode() { |
| 304 // Always reset first to avoid creation before destruction of a previous |
| 305 // object. |
| 306 event_blocker_.reset(); |
| 307 #if defined(USE_X11) |
| 308 event_blocker_.reset(new ScopedDisableInternalMouseAndKeyboardX11); |
| 309 #elif defined(USE_OZONE) |
| 310 event_blocker_.reset(new ScopedDisableInternalMouseAndKeyboardOzone); |
| 311 #endif |
| 312 |
| 313 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 314 switches::kAshEnableTouchViewTesting)) { |
| 315 // We don't let accelerometer updates interfere with the maximize mode |
| 316 // status as set by the touch-view-testing keyboard shortcut. |
| 317 return; |
| 318 } |
| 319 |
319 if (IsMaximizeModeWindowManagerEnabled()) | 320 if (IsMaximizeModeWindowManagerEnabled()) |
320 return; | 321 return; |
321 EnableMaximizeModeWindowManager(true); | 322 EnableMaximizeModeWindowManager(true); |
322 } | 323 } |
323 | 324 |
324 void MaximizeModeController::LeaveMaximizeMode() { | 325 void MaximizeModeController::LeaveMaximizeMode() { |
| 326 event_blocker_.reset(); |
| 327 |
| 328 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 329 switches::kAshEnableTouchViewTesting)) { |
| 330 // We don't let accelerometer updates interfere with the maximize mode |
| 331 // status as set by the touch-view-testing keyboard shortcut. |
| 332 return; |
| 333 } |
| 334 |
325 if (!IsMaximizeModeWindowManagerEnabled()) | 335 if (!IsMaximizeModeWindowManagerEnabled()) |
326 return; | 336 return; |
327 EnableMaximizeModeWindowManager(false); | 337 EnableMaximizeModeWindowManager(false); |
328 } | 338 } |
329 | 339 |
330 // Called after maximize mode has started, windows might still animate though. | 340 // Called after maximize mode has started, windows might still animate though. |
331 void MaximizeModeController::OnMaximizeModeStarted() { | 341 void MaximizeModeController::OnMaximizeModeStarted() { |
332 RecordTouchViewUsageInterval(TOUCH_VIEW_INTERVAL_INACTIVE); | 342 RecordTouchViewUsageInterval(TOUCH_VIEW_INTERVAL_INACTIVE); |
333 } | 343 } |
334 | 344 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 return elapsed_time.InSeconds() <= kLidRecentlyOpenedDurationSeconds; | 415 return elapsed_time.InSeconds() <= kLidRecentlyOpenedDurationSeconds; |
406 } | 416 } |
407 | 417 |
408 void MaximizeModeController::SetTickClockForTest( | 418 void MaximizeModeController::SetTickClockForTest( |
409 scoped_ptr<base::TickClock> tick_clock) { | 419 scoped_ptr<base::TickClock> tick_clock) { |
410 DCHECK(tick_clock_); | 420 DCHECK(tick_clock_); |
411 tick_clock_ = std::move(tick_clock); | 421 tick_clock_ = std::move(tick_clock); |
412 } | 422 } |
413 | 423 |
414 } // namespace ash | 424 } // namespace ash |
OLD | NEW |