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 #ifndef ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ | 5 #ifndef ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ |
| 6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ | 6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "ash/accelerometer/accelerometer_observer.h" | 8 #include "ash/accelerometer/accelerometer_observer.h" |
| 9 #include "ash/ash_export.h" | 9 #include "ash/ash_export.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "ui/gfx/display.h" | |
| 12 | 13 |
| 13 namespace ui { | 14 namespace ui { |
| 14 class EventHandler; | 15 class EventHandler; |
| 15 } | 16 } |
| 16 | 17 |
| 17 namespace ash { | 18 namespace ash { |
| 18 | 19 |
| 19 class MaximizeModeEventBlocker; | 20 class MaximizeModeEventBlocker; |
| 20 | 21 |
| 21 // MaximizeModeController listens to accelerometer events and automatically | 22 // MaximizeModeController listens to accelerometer events and automatically |
| 22 // enters and exits maximize mode when the lid is opened beyond the triggering | 23 // enters and exits maximize mode when the lid is opened beyond the triggering |
| 23 // angle and rotates the display to match the device when in maximize mode. | 24 // angle and rotates the display to match the device when in maximize mode. |
| 24 class ASH_EXPORT MaximizeModeController : public AccelerometerObserver { | 25 class ASH_EXPORT MaximizeModeController : public AccelerometerObserver { |
| 25 public: | 26 public: |
| 26 MaximizeModeController(); | 27 MaximizeModeController(); |
| 27 virtual ~MaximizeModeController(); | 28 virtual ~MaximizeModeController(); |
| 28 | 29 |
| 30 // True if OnAccelerometerUpdated has led to a call to | |
| 31 // DisplayManager::SetDisplayRotation. If true display configuration changes | |
| 32 // should not be saved to user preferences. | |
| 33 bool accelerometer_setting_rotation() { | |
|
oshima
2014/05/22 17:14:29
vconst
| |
| 34 return accelerometer_setting_rotation_; | |
| 35 } | |
| 36 | |
| 29 // True if |rotation_lock_| has been set, and OnAccelerometerUpdated will not | 37 // True if |rotation_lock_| has been set, and OnAccelerometerUpdated will not |
| 30 // change the display rotation. | 38 // change the display rotation. |
| 31 bool rotation_locked() { | 39 bool rotation_locked() { |
| 32 return rotation_locked_; | 40 return rotation_locked_; |
| 33 } | 41 } |
| 34 | 42 |
| 35 // If |rotation_locked| future calls to OnAccelerometerUpdated will not | 43 // If |rotation_locked| future calls to OnAccelerometerUpdated will not |
| 36 // change the display rotation. | 44 // change the display rotation. |
| 37 void set_rotation_locked(bool rotation_locked) { | 45 void set_rotation_locked(bool rotation_locked) { |
| 38 rotation_locked_ = rotation_locked; | 46 rotation_locked_ = rotation_locked; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 50 private: | 58 private: |
| 51 // Detect hinge rotation from |base| and |lid| accelerometers and | 59 // Detect hinge rotation from |base| and |lid| accelerometers and |
| 52 // automatically start / stop maximize mode. | 60 // automatically start / stop maximize mode. |
| 53 void HandleHingeRotation(const gfx::Vector3dF& base, | 61 void HandleHingeRotation(const gfx::Vector3dF& base, |
| 54 const gfx::Vector3dF& lid); | 62 const gfx::Vector3dF& lid); |
| 55 | 63 |
| 56 // Detect screen rotation from |lid| accelerometer and automatically rotate | 64 // Detect screen rotation from |lid| accelerometer and automatically rotate |
| 57 // screen. | 65 // screen. |
| 58 void HandleScreenRotation(const gfx::Vector3dF& lid); | 66 void HandleScreenRotation(const gfx::Vector3dF& lid); |
| 59 | 67 |
| 68 // Enables MaximizeModeWindowManager, and determines the current state of | |
| 69 // rotation lock. | |
| 70 void EnterMaximizeMode(); | |
| 71 | |
| 72 // Removes MaximizeModeWindowManager and resets the display rotation if there | |
| 73 // is no rotation lock. | |
| 74 void LeaveMaximizeMode(); | |
| 75 | |
| 60 // An event targeter controller which traps mouse and keyboard events while | 76 // An event targeter controller which traps mouse and keyboard events while |
| 61 // maximize mode is engaged. | 77 // maximize mode is engaged. |
| 62 scoped_ptr<MaximizeModeEventBlocker> event_blocker_; | 78 scoped_ptr<MaximizeModeEventBlocker> event_blocker_; |
| 63 | 79 |
| 64 // An event handler used to detect screenshot actions while in maximize mode. | 80 // An event handler used to detect screenshot actions while in maximize mode. |
| 65 scoped_ptr<ui::EventHandler> event_handler_; | 81 scoped_ptr<ui::EventHandler> event_handler_; |
| 66 | 82 |
| 83 // True when OnAccelerometerUpdated leads to changes to the display rotation. | |
| 84 bool accelerometer_setting_rotation_; | |
|
oshima
2014/05/22 17:14:29
optional: how about is_rotated_by_accelerometer? (
jonross
2014/05/23 19:07:20
No longer necessary. A lock around rotation has be
| |
| 85 | |
| 67 // When true calls to OnAccelerometerUpdated will not rotate the display. | 86 // When true calls to OnAccelerometerUpdated will not rotate the display. |
| 68 bool rotation_locked_; | 87 bool rotation_locked_; |
| 69 | 88 |
| 70 // Whether we have ever seen accelerometer data. | 89 // Whether we have ever seen accelerometer data. |
| 71 bool have_seen_accelerometer_data_; | 90 bool have_seen_accelerometer_data_; |
| 72 | 91 |
| 92 // The rotation of the display set by the user. This rotation will be | |
| 93 // restored upon exiting maximize mode. | |
| 94 gfx::Display::Rotation user_rotation_; | |
| 95 | |
| 73 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); | 96 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); |
| 74 }; | 97 }; |
| 75 | 98 |
| 76 } // namespace ash | 99 } // namespace ash |
| 77 | 100 |
| 78 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ | 101 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ |
| OLD | NEW |