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 |
11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
12 #include "ash/display/display_info.h" | 12 #include "ash/display/display_info.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "ui/aura/root_window_observer.h" | 15 #include "ui/aura/root_window_observer.h" |
16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/gfx/display.h" |
17 | 18 |
18 namespace gfx { | 19 namespace gfx { |
19 class Display; | 20 class Display; |
20 class Insets; | 21 class Insets; |
21 class Rect; | 22 class Rect; |
22 } | 23 } |
23 | 24 |
24 namespace ash { | 25 namespace ash { |
25 class AcceleratorControllerTest; | 26 class AcceleratorControllerTest; |
26 namespace test { | 27 namespace test { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // Returns the logical number of displays. This returns 1 | 125 // Returns the logical number of displays. This returns 1 |
125 // when displays are mirrored. | 126 // when displays are mirrored. |
126 size_t GetNumDisplays() const; | 127 size_t GetNumDisplays() const; |
127 | 128 |
128 // Returns the number of connected displays. This returns 2 | 129 // Returns the number of connected displays. This returns 2 |
129 // when displays are mirrored. | 130 // when displays are mirrored. |
130 size_t num_connected_displays() const { return num_connected_displays_; } | 131 size_t num_connected_displays() const { return num_connected_displays_; } |
131 | 132 |
132 // Returns the mirroring status. | 133 // Returns the mirroring status. |
133 bool IsMirrored() const; | 134 bool IsMirrored() const; |
134 int64 mirrored_display_id() const { return mirrored_display_id_; } | 135 int64 mirrored_display_id() const { return mirrored_display_.id(); } |
135 | 136 |
136 // Returns the display object nearest given |window|. | 137 // Returns the display object nearest given |window|. |
137 const gfx::Display& GetDisplayNearestPoint( | 138 const gfx::Display& GetDisplayNearestPoint( |
138 const gfx::Point& point) const; | 139 const gfx::Point& point) const; |
139 | 140 |
140 // Returns the display object nearest given |point|. | 141 // Returns the display object nearest given |point|. |
141 const gfx::Display& GetDisplayNearestWindow( | 142 const gfx::Display& GetDisplayNearestWindow( |
142 const aura::Window* window) const; | 143 const aura::Window* window) const; |
143 | 144 |
144 // Returns the display that most closely intersects |match_rect|. | 145 // Returns the display that most closely intersects |match_rect|. |
145 const gfx::Display& GetDisplayMatching( | 146 const gfx::Display& GetDisplayMatching( |
146 const gfx::Rect& match_rect)const; | 147 const gfx::Rect& match_rect)const; |
147 | 148 |
148 // Retuns the display info associated with |display_id|. | 149 // Retuns the display info associated with |display_id|. |
149 const DisplayInfo& GetDisplayInfo(int64 display_id) const; | 150 const DisplayInfo& GetDisplayInfo(int64 display_id) const; |
150 | 151 |
151 // Returns the human-readable name for the display |id|. | 152 // Returns the human-readable name for the display |id|. |
152 std::string GetDisplayNameForId(int64 id); | 153 std::string GetDisplayNameForId(int64 id); |
153 | 154 |
154 // Returns the display id that is capable of UI scaling. On device, | 155 // Returns the display id that is capable of UI scaling. On device, |
155 // this returns internal display's ID if its device scale factor is 2, | 156 // this returns internal display's ID if its device scale factor is 2, |
156 // or invalid ID if such internal display doesn't exist. On linux | 157 // or invalid ID if such internal display doesn't exist. On linux |
157 // desktop, this returns the first display ID. | 158 // desktop, this returns the first display ID. |
158 int64 GetDisplayIdForUIScaling() const; | 159 int64 GetDisplayIdForUIScaling() const; |
159 | 160 |
160 // RootWindowObserver overrides: | |
161 virtual void OnRootWindowResized(const aura::RootWindow* root, | |
162 const gfx::Size& new_size) OVERRIDE; | |
163 | |
164 // Change the mirror mode. | 161 // Change the mirror mode. |
165 void SetMirrorMode(bool mirrored); | 162 void SetMirrorMode(bool mirrored); |
166 | 163 |
167 // Used to emulate display change when run in a desktop environment instead | 164 // Used to emulate display change when run in a desktop environment instead |
168 // of on a device. | 165 // of on a device. |
169 void AddRemoveDisplay(); | 166 void AddRemoveDisplay(); |
170 void ToggleDisplayScaleFactor(); | 167 void ToggleDisplayScaleFactor(); |
171 | 168 |
| 169 // RootWindowObserver overrides: |
| 170 virtual void OnRootWindowResized(const aura::RootWindow* root, |
| 171 const gfx::Size& new_size) OVERRIDE; |
| 172 |
| 173 // TODO(oshima): This will be SoftwareMirroringController override: |
| 174 void SetSoftwareMirroring(bool enabled); |
| 175 |
172 private: | 176 private: |
173 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, ConvertPoint); | 177 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, ConvertPoint); |
174 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, TestNativeDisplaysChanged); | 178 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, TestNativeDisplaysChanged); |
175 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, | 179 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, |
176 NativeDisplaysChangedAfterPrimaryChange); | 180 NativeDisplaysChangedAfterPrimaryChange); |
177 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, AutomaticOverscanInsets); | 181 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, AutomaticOverscanInsets); |
178 friend class ash::AcceleratorControllerTest; | 182 friend class ash::AcceleratorControllerTest; |
179 friend class test::DisplayManagerTestApi; | 183 friend class test::DisplayManagerTestApi; |
180 friend class DisplayManagerTest; | 184 friend class DisplayManagerTest; |
181 friend class test::SystemGestureEventFilterTest; | 185 friend class test::SystemGestureEventFilterTest; |
(...skipping 17 matching lines...) Expand all Loading... |
199 // can be different from |new_info| (due to overscan state), so | 203 // can be different from |new_info| (due to overscan state), so |
200 // you must use |GetDisplayInfo| to get the correct DisplayInfo for | 204 // you must use |GetDisplayInfo| to get the correct DisplayInfo for |
201 // a display. | 205 // a display. |
202 void InsertAndUpdateDisplayInfo(const DisplayInfo& new_info); | 206 void InsertAndUpdateDisplayInfo(const DisplayInfo& new_info); |
203 | 207 |
204 // Creates a display object from the DisplayInfo for |display_id|. | 208 // Creates a display object from the DisplayInfo for |display_id|. |
205 gfx::Display CreateDisplayFromDisplayInfoById(int64 display_id); | 209 gfx::Display CreateDisplayFromDisplayInfoById(int64 display_id); |
206 | 210 |
207 int64 first_display_id_; | 211 int64 first_display_id_; |
208 | 212 |
209 int64 mirrored_display_id_; | 213 gfx::Display mirrored_display_; |
210 | 214 |
211 // List of current active dispays. | 215 // List of current active dispays. |
212 DisplayList displays_; | 216 DisplayList displays_; |
213 | 217 |
214 int num_connected_displays_; | 218 int num_connected_displays_; |
215 | 219 |
216 bool force_bounds_changed_; | 220 bool force_bounds_changed_; |
217 | 221 |
218 // The mapping from the display ID to its internal data. | 222 // The mapping from the display ID to its internal data. |
219 std::map<int64, DisplayInfo> display_info_; | 223 std::map<int64, DisplayInfo> display_info_; |
220 | 224 |
221 // When set to true, the host window's resize event updates | 225 // When set to true, the host window's resize event updates |
222 // the display's size. This is set to true when running on | 226 // the display's size. This is set to true when running on |
223 // desktop environment (for debugging) so that resizing the host | 227 // desktop environment (for debugging) so that resizing the host |
224 // window wil update the display properly. This is set to false | 228 // window wil update the display properly. This is set to false |
225 // on device as well as during the unit tests. | 229 // on device as well as during the unit tests. |
226 bool change_display_upon_host_resize_; | 230 bool change_display_upon_host_resize_; |
227 | 231 |
| 232 bool software_mirroring_enabled_; |
| 233 |
228 DISALLOW_COPY_AND_ASSIGN(DisplayManager); | 234 DISALLOW_COPY_AND_ASSIGN(DisplayManager); |
229 }; | 235 }; |
230 | 236 |
231 extern const aura::WindowProperty<int64>* const kDisplayIdKey; | 237 extern const aura::WindowProperty<int64>* const kDisplayIdKey; |
232 | 238 |
233 } // namespace internal | 239 } // namespace internal |
234 } // namespace ash | 240 } // namespace ash |
235 | 241 |
236 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ | 242 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ |
OLD | NEW |