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" | |
11 #include "base/macros.h" | 10 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
13 | 12 |
14 namespace ui { | 13 namespace ui { |
15 class EventHandler; | 14 class EventHandler; |
16 } | 15 } |
17 | 16 |
18 namespace ash { | 17 namespace ash { |
19 | 18 |
20 class MaximizeModeEventBlocker; | 19 class MaximizeModeEventBlocker; |
21 | 20 |
22 // MaximizeModeController listens to accelerometer events and automatically | 21 // MaximizeModeController listens to accelerometer events and automatically |
23 // enters and exits maximize mode when the lid is opened beyond the triggering | 22 // enters and exits maximize mode when the lid is opened beyond the triggering |
24 // angle and rotates the display to match the device when in maximize mode. | 23 // angle and rotates the display to match the device when in maximize mode. |
25 class ASH_EXPORT MaximizeModeController : public AccelerometerObserver { | 24 class ASH_EXPORT MaximizeModeController : public AccelerometerObserver { |
26 public: | 25 public: |
27 MaximizeModeController(); | 26 MaximizeModeController(); |
28 virtual ~MaximizeModeController(); | 27 virtual ~MaximizeModeController(); |
29 | 28 |
30 bool in_set_screen_rotation() const { | |
31 return in_set_screen_rotation_; | |
32 } | |
33 | |
34 // True if |rotation_lock_| has been set, and OnAccelerometerUpdated will not | 29 // True if |rotation_lock_| has been set, and OnAccelerometerUpdated will not |
35 // change the display rotation. | 30 // change the display rotation. |
36 bool rotation_locked() { | 31 bool rotation_locked() { |
37 return rotation_locked_; | 32 return rotation_locked_; |
38 } | 33 } |
39 | 34 |
40 // If |rotation_locked| future calls to OnAccelerometerUpdated will not | 35 // If |rotation_locked| future calls to OnAccelerometerUpdated will not |
41 // change the display rotation. | 36 // change the display rotation. |
42 void set_rotation_locked(bool rotation_locked) { | 37 void set_rotation_locked(bool rotation_locked) { |
43 rotation_locked_ = rotation_locked; | 38 rotation_locked_ = rotation_locked; |
(...skipping 11 matching lines...) Expand all Loading... |
55 private: | 50 private: |
56 // Detect hinge rotation from |base| and |lid| accelerometers and | 51 // Detect hinge rotation from |base| and |lid| accelerometers and |
57 // automatically start / stop maximize mode. | 52 // automatically start / stop maximize mode. |
58 void HandleHingeRotation(const gfx::Vector3dF& base, | 53 void HandleHingeRotation(const gfx::Vector3dF& base, |
59 const gfx::Vector3dF& lid); | 54 const gfx::Vector3dF& lid); |
60 | 55 |
61 // Detect screen rotation from |lid| accelerometer and automatically rotate | 56 // Detect screen rotation from |lid| accelerometer and automatically rotate |
62 // screen. | 57 // screen. |
63 void HandleScreenRotation(const gfx::Vector3dF& lid); | 58 void HandleScreenRotation(const gfx::Vector3dF& lid); |
64 | 59 |
65 // Sets the display rotation and suppresses display notifications. | |
66 void SetDisplayRotation(DisplayManager* display_manager, | |
67 gfx::Display::Rotation rotation); | |
68 | |
69 // An event targeter controller which traps mouse and keyboard events while | 60 // An event targeter controller which traps mouse and keyboard events while |
70 // maximize mode is engaged. | 61 // maximize mode is engaged. |
71 scoped_ptr<MaximizeModeEventBlocker> event_blocker_; | 62 scoped_ptr<MaximizeModeEventBlocker> event_blocker_; |
72 | 63 |
73 // An event handler used to detect screenshot actions while in maximize mode. | 64 // An event handler used to detect screenshot actions while in maximize mode. |
74 scoped_ptr<ui::EventHandler> event_handler_; | 65 scoped_ptr<ui::EventHandler> event_handler_; |
75 | 66 |
76 // When true calls to OnAccelerometerUpdated will not rotate the display. | 67 // When true calls to OnAccelerometerUpdated will not rotate the display. |
77 bool rotation_locked_; | 68 bool rotation_locked_; |
78 | 69 |
79 // Whether we have ever seen accelerometer data. | 70 // Whether we have ever seen accelerometer data. |
80 bool have_seen_accelerometer_data_; | 71 bool have_seen_accelerometer_data_; |
81 | 72 |
82 // True when the screen's orientation is being changed. | |
83 bool in_set_screen_rotation_; | |
84 | |
85 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); | 73 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); |
86 }; | 74 }; |
87 | 75 |
88 } // namespace ash | 76 } // namespace ash |
89 | 77 |
90 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ | 78 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ |
OLD | NEW |