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 "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "ui/gfx/display.h" | 13 #include "ui/gfx/display.h" |
| 14 | 14 |
| 15 namespace ui { | 15 namespace ui { |
| 16 class EventHandler; | 16 class EventHandler; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace ash { | 19 namespace ash { |
| 20 | 20 |
| 21 class MaximizeModeControllerTest; | 21 class MaximizeModeControllerTest; |
| 22 class MaximizeModeEventBlocker; | 22 class MaximizeModeEventBlocker; |
| 23 class MaximizeModeWindowManager; | |
| 24 class MaximizeModeWindowManagerTest; | |
| 23 | 25 |
| 24 // MaximizeModeController listens to accelerometer events and automatically | 26 // MaximizeModeController listens to accelerometer events and automatically |
| 25 // enters and exits maximize mode when the lid is opened beyond the triggering | 27 // enters and exits maximize mode when the lid is opened beyond the triggering |
| 26 // angle and rotates the display to match the device when in maximize mode. | 28 // angle and rotates the display to match the device when in maximize mode. |
| 27 class ASH_EXPORT MaximizeModeController : public AccelerometerObserver { | 29 class ASH_EXPORT MaximizeModeController : public AccelerometerObserver { |
| 28 public: | 30 public: |
| 29 MaximizeModeController(); | 31 MaximizeModeController(); |
| 30 virtual ~MaximizeModeController(); | 32 virtual ~MaximizeModeController(); |
| 31 | 33 |
| 32 bool in_set_screen_rotation() const { | 34 bool in_set_screen_rotation() const { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 43 // change the display rotation. | 45 // change the display rotation. |
| 44 void set_rotation_locked(bool rotation_locked) { | 46 void set_rotation_locked(bool rotation_locked) { |
| 45 rotation_locked_ = rotation_locked; | 47 rotation_locked_ = rotation_locked; |
| 46 } | 48 } |
| 47 | 49 |
| 48 // True if it is possible to enter maximize mode in the current | 50 // True if it is possible to enter maximize mode in the current |
| 49 // configuration. If this returns false, it should never be the case that | 51 // configuration. If this returns false, it should never be the case that |
| 50 // maximize mode becomes enabled. | 52 // maximize mode becomes enabled. |
| 51 bool CanEnterMaximizeMode(); | 53 bool CanEnterMaximizeMode(); |
| 52 | 54 |
| 55 // Turn the always maximize mode window manager on or off. | |
| 56 void EnableMaximizeModeWindowManager(bool enable); | |
|
flackr
2014/05/29 16:10:06
I realize this is currently separate from EnableMa
jonross
2014/05/29 17:40:00
Done.
| |
| 57 | |
| 58 // Test if the MaximizeModeWindowManager is enabled or not. | |
| 59 bool IsMaximizeModeWindowManagerEnabled() const; | |
| 60 | |
| 53 // AccelerometerObserver: | 61 // AccelerometerObserver: |
| 54 virtual void OnAccelerometerUpdated(const gfx::Vector3dF& base, | 62 virtual void OnAccelerometerUpdated(const gfx::Vector3dF& base, |
| 55 const gfx::Vector3dF& lid) OVERRIDE; | 63 const gfx::Vector3dF& lid) OVERRIDE; |
| 56 | 64 |
| 57 private: | 65 private: |
| 58 friend class MaximizeModeControllerTest; | 66 friend class MaximizeModeControllerTest; |
| 67 friend class MaximizeModeWindowManagerTest; | |
| 59 | 68 |
| 60 // Detect hinge rotation from |base| and |lid| accelerometers and | 69 // Detect hinge rotation from |base| and |lid| accelerometers and |
| 61 // automatically start / stop maximize mode. | 70 // automatically start / stop maximize mode. |
| 62 void HandleHingeRotation(const gfx::Vector3dF& base, | 71 void HandleHingeRotation(const gfx::Vector3dF& base, |
| 63 const gfx::Vector3dF& lid); | 72 const gfx::Vector3dF& lid); |
| 64 | 73 |
| 65 // Detect screen rotation from |lid| accelerometer and automatically rotate | 74 // Detect screen rotation from |lid| accelerometer and automatically rotate |
| 66 // screen. | 75 // screen. |
| 67 void HandleScreenRotation(const gfx::Vector3dF& lid); | 76 void HandleScreenRotation(const gfx::Vector3dF& lid); |
| 68 | 77 |
| 69 // Sets the display rotation and suppresses display notifications. | 78 // Sets the display rotation and suppresses display notifications. |
| 70 void SetDisplayRotation(DisplayManager* display_manager, | 79 void SetDisplayRotation(DisplayManager* display_manager, |
| 71 gfx::Display::Rotation rotation); | 80 gfx::Display::Rotation rotation); |
| 72 | 81 |
| 73 // Enables MaximizeModeWindowManager, and determines the current state of | 82 // Enables MaximizeModeWindowManager, and determines the current state of |
| 74 // rotation lock. | 83 // rotation lock. |
| 75 void EnterMaximizeMode(); | 84 void EnterMaximizeMode(); |
| 76 | 85 |
| 77 // Removes MaximizeModeWindowManager and resets the display rotation if there | 86 // Removes MaximizeModeWindowManager and resets the display rotation if there |
| 78 // is no rotation lock. | 87 // is no rotation lock. |
| 79 void LeaveMaximizeMode(); | 88 void LeaveMaximizeMode(); |
| 80 | 89 |
| 90 // The maximized window manager (if enabled). | |
| 91 scoped_ptr<MaximizeModeWindowManager> maximize_mode_window_manager_; | |
| 92 | |
| 81 // An event targeter controller which traps mouse and keyboard events while | 93 // An event targeter controller which traps mouse and keyboard events while |
| 82 // maximize mode is engaged. | 94 // maximize mode is engaged. |
| 83 scoped_ptr<MaximizeModeEventBlocker> event_blocker_; | 95 scoped_ptr<MaximizeModeEventBlocker> event_blocker_; |
| 84 | 96 |
| 85 // An event handler used to detect screenshot actions while in maximize mode. | 97 // An event handler used to detect screenshot actions while in maximize mode. |
| 86 scoped_ptr<ui::EventHandler> event_handler_; | 98 scoped_ptr<ui::EventHandler> event_handler_; |
| 87 | 99 |
| 88 // When true calls to OnAccelerometerUpdated will not rotate the display. | 100 // When true calls to OnAccelerometerUpdated will not rotate the display. |
| 89 bool rotation_locked_; | 101 bool rotation_locked_; |
| 90 | 102 |
| 91 // Whether we have ever seen accelerometer data. | 103 // Whether we have ever seen accelerometer data. |
| 92 bool have_seen_accelerometer_data_; | 104 bool have_seen_accelerometer_data_; |
| 93 | 105 |
| 94 // True when the screen's orientation is being changed. | 106 // True when the screen's orientation is being changed. |
| 95 bool in_set_screen_rotation_; | 107 bool in_set_screen_rotation_; |
| 96 | 108 |
| 97 // The rotation of the display set by the user. This rotation will be | 109 // The rotation of the display set by the user. This rotation will be |
| 98 // restored upon exiting maximize mode. | 110 // restored upon exiting maximize mode. |
| 99 gfx::Display::Rotation user_rotation_; | 111 gfx::Display::Rotation user_rotation_; |
| 100 | 112 |
| 101 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); | 113 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); |
| 102 }; | 114 }; |
| 103 | 115 |
| 104 } // namespace ash | 116 } // namespace ash |
| 105 | 117 |
| 106 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ | 118 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ |
| OLD | NEW |