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