| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_DISPLAY_DISPLAY_MANAGER_H_ | 5 #ifndef ASH_DISPLAY_DISPLAY_MANAGER_H_ |
| 6 #define ASH_DISPLAY_DISPLAY_MANAGER_H_ | 6 #define ASH_DISPLAY_DISPLAY_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 namespace test { | 26 namespace test { |
| 27 class DisplayManagerTestApi; | 27 class DisplayManagerTestApi; |
| 28 class SystemGestureEventFilterTest; | 28 class SystemGestureEventFilterTest; |
| 29 } | 29 } |
| 30 namespace internal { | 30 namespace internal { |
| 31 | 31 |
| 32 // DisplayManager maintains the current display configurations, | 32 // DisplayManager maintains the current display configurations, |
| 33 // and notifies observers when configuration changes. | 33 // and notifies observers when configuration changes. |
| 34 // This is exported for unittest. | 34 // This is exported for unittest. |
| 35 // | 35 // |
| 36 // TODO(oshima): gfx::Screen needs to return translated coordinates | 36 // TODO(oshima): Make this non internal. |
| 37 // if the root window is translated. crbug.com/119268. | |
| 38 class ASH_EXPORT DisplayManager : public aura::RootWindowObserver { | 37 class ASH_EXPORT DisplayManager : public aura::RootWindowObserver { |
| 39 public: | 38 public: |
| 40 DisplayManager(); | 39 DisplayManager(); |
| 41 virtual ~DisplayManager(); | 40 virtual ~DisplayManager(); |
| 42 | 41 |
| 43 // Used to emulate display change when run in a desktop environment instead | 42 // Used to emulate display change when run in a desktop environment instead |
| 44 // of on a device. | 43 // of on a device. |
| 45 static void CycleDisplay(); | 44 static void CycleDisplay(); |
| 46 static void ToggleDisplayScaleFactor(); | 45 static void ToggleDisplayScaleFactor(); |
| 47 | 46 |
| 47 // Returns next valud ui scales. |
| 48 static float GetNextUIScale(float scale, bool up); |
| 49 |
| 48 // When set to true, the MonitorManager calls OnDisplayBoundsChanged | 50 // When set to true, the MonitorManager calls OnDisplayBoundsChanged |
| 49 // even if the display's bounds didn't change. Used to swap primary | 51 // even if the display's bounds didn't change. Used to swap primary |
| 50 // display. | 52 // display. |
| 51 void set_force_bounds_changed(bool force_bounds_changed) { | 53 void set_force_bounds_changed(bool force_bounds_changed) { |
| 52 force_bounds_changed_ = force_bounds_changed; | 54 force_bounds_changed_ = force_bounds_changed; |
| 53 } | 55 } |
| 54 | 56 |
| 55 // Returns the display id of the first display in the outupt list. | 57 // Returns the display id of the first display in the outupt list. |
| 56 int64 first_display_id() const { return first_display_id_; } | 58 int64 first_display_id() const { return first_display_id_; } |
| 57 | 59 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 82 | 84 |
| 83 // Clears the overscan insets | 85 // Clears the overscan insets |
| 84 void ClearCustomOverscanInsets(int64 display_id); | 86 void ClearCustomOverscanInsets(int64 display_id); |
| 85 | 87 |
| 86 // Sets the display's rotation. | 88 // Sets the display's rotation. |
| 87 void SetDisplayRotation(int64 display_id, gfx::Display::Rotation rotation); | 89 void SetDisplayRotation(int64 display_id, gfx::Display::Rotation rotation); |
| 88 | 90 |
| 89 // Sets the display's ui scale. | 91 // Sets the display's ui scale. |
| 90 void SetDisplayUIScale(int64 display_id, float ui_scale); | 92 void SetDisplayUIScale(int64 display_id, float ui_scale); |
| 91 | 93 |
| 94 // Register per display properties. |overscan_insets| is NULL if |
| 95 // the display has no custom overscan insets. |
| 96 void RegisterDisplayProperty(int64 display_id, |
| 97 gfx::Display::Rotation rotation, |
| 98 float ui_scale, |
| 99 const gfx::Insets* overscan_insets); |
| 100 |
| 92 // Tells if display rotation/ui scaling features are enabled. | 101 // Tells if display rotation/ui scaling features are enabled. |
| 93 bool IsDisplayRotationEnabled() const; | 102 bool IsDisplayRotationEnabled() const; |
| 94 bool IsDisplayUIScalingEnabled() const; | 103 bool IsDisplayUIScalingEnabled() const; |
| 95 | 104 |
| 96 // Returns the current overscan insets for the specified |display_id|. | 105 // Returns the current overscan insets for the specified |display_id|. |
| 97 // Returns an empty insets (0, 0, 0, 0) if no insets are specified for | 106 // Returns an empty insets (0, 0, 0, 0) if no insets are specified for |
| 98 // the display. | 107 // the display. |
| 99 gfx::Insets GetOverscanInsets(int64 display_id) const; | 108 gfx::Insets GetOverscanInsets(int64 display_id) const; |
| 100 | 109 |
| 101 // Called when display configuration has changed. The new display | 110 // Called when display configuration has changed. The new display |
| 102 // configurations is passed as a vector of Display object, which | 111 // configurations is passed as a vector of Display object, which |
| 103 // contains each display's new infomration. | 112 // contains each display's new infomration. |
| 104 void OnNativeDisplaysChanged( | 113 void OnNativeDisplaysChanged( |
| 105 const std::vector<DisplayInfo>& display_info_list); | 114 const std::vector<DisplayInfo>& display_info_list); |
| 106 | 115 |
| 107 // Updates the internal display data and notifies observers about the changes. | 116 // Updates the internal display data and notifies observers about the changes. |
| 108 void UpdateDisplays(const std::vector<DisplayInfo>& display_info_list); | 117 void UpdateDisplays(const std::vector<DisplayInfo>& display_info_list); |
| 109 | 118 |
| 119 // Updates current displays using current |display_info_|. |
| 120 void UpdateDisplays(); |
| 121 |
| 110 // Obsoleted: Do not use in new code. | 122 // Obsoleted: Do not use in new code. |
| 111 // Returns the display at |index|. The display at 0 is | 123 // Returns the display at |index|. The display at 0 is |
| 112 // no longer considered "primary". | 124 // no longer considered "primary". |
| 113 gfx::Display* GetDisplayAt(size_t index); | 125 gfx::Display* GetDisplayAt(size_t index); |
| 114 | 126 |
| 115 const gfx::Display* GetPrimaryDisplayCandidate() const; | 127 const gfx::Display* GetPrimaryDisplayCandidate() const; |
| 116 | 128 |
| 117 // Returns the logical number of displays. This returns 1 | 129 // Returns the logical number of displays. This returns 1 |
| 118 // when displays are mirrored. | 130 // when displays are mirrored. |
| 119 size_t GetNumDisplays() const; | 131 size_t GetNumDisplays() const; |
| 120 | 132 |
| 121 // Returns the number of connected displays. This returns 2 | 133 // Returns the number of connected displays. This returns 2 |
| 122 // when displays are mirrored. | 134 // when displays are mirrored. |
| 123 size_t num_connected_displays() const { return num_connected_displays_; } | 135 size_t num_connected_displays() const { return num_connected_displays_; } |
| 124 | 136 |
| 125 int64 mirrored_display_id() const { return mirrored_display_id_; } | 137 int64 mirrored_display_id() const { return mirrored_display_id_; } |
| 126 | 138 |
| 127 // Returns the display object nearest given |window|. | 139 // Returns the display object nearest given |window|. |
| 128 const gfx::Display& GetDisplayNearestPoint( | 140 const gfx::Display& GetDisplayNearestPoint( |
| 129 const gfx::Point& point) const; | 141 const gfx::Point& point) const; |
| 130 | 142 |
| 131 // Returns the display object nearest given |point|. | 143 // Returns the display object nearest given |point|. |
| 132 const gfx::Display& GetDisplayNearestWindow( | 144 const gfx::Display& GetDisplayNearestWindow( |
| 133 const aura::Window* window) const; | 145 const aura::Window* window) const; |
| 134 | 146 |
| 135 // Returns the display that most closely intersects |match_rect|. | 147 // Returns the display that most closely intersects |match_rect|. |
| 136 const gfx::Display& GetDisplayMatching( | 148 const gfx::Display& GetDisplayMatching( |
| 137 const gfx::Rect& match_rect)const; | 149 const gfx::Rect& match_rect)const; |
| 138 | 150 |
| 139 // Retuns the display info associated with |display|. | 151 // Retuns the display info associated with |display_id|. |
| 140 const DisplayInfo& GetDisplayInfo(const gfx::Display& display) const; | 152 const DisplayInfo& GetDisplayInfo(int64 display_id) const; |
| 141 | 153 |
| 142 // Returns the human-readable name for the display |id|. | 154 // Returns the human-readable name for the display |id|. |
| 143 std::string GetDisplayNameForId(int64 id); | 155 std::string GetDisplayNameForId(int64 id); |
| 144 | 156 |
| 145 // RootWindowObserver overrides: | 157 // RootWindowObserver overrides: |
| 146 virtual void OnRootWindowResized(const aura::RootWindow* root, | 158 virtual void OnRootWindowResized(const aura::RootWindow* root, |
| 147 const gfx::Size& new_size) OVERRIDE; | 159 const gfx::Size& new_size) OVERRIDE; |
| 148 | 160 |
| 149 private: | 161 private: |
| 150 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, ConvertPoint); | 162 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, ConvertPoint); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 226 |
| 215 DISALLOW_COPY_AND_ASSIGN(DisplayManager); | 227 DISALLOW_COPY_AND_ASSIGN(DisplayManager); |
| 216 }; | 228 }; |
| 217 | 229 |
| 218 extern const aura::WindowProperty<int64>* const kDisplayIdKey; | 230 extern const aura::WindowProperty<int64>* const kDisplayIdKey; |
| 219 | 231 |
| 220 } // namespace internal | 232 } // namespace internal |
| 221 } // namespace ash | 233 } // namespace ash |
| 222 | 234 |
| 223 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ | 235 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ |
| OLD | NEW |