| 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 21 matching lines...) Expand all Loading... |
| 32 class Screen; | 32 class Screen; |
| 33 } | 33 } |
| 34 | 34 |
| 35 namespace ash { | 35 namespace ash { |
| 36 class AcceleratorControllerTest; | 36 class AcceleratorControllerTest; |
| 37 class DisplayController; | 37 class DisplayController; |
| 38 class DisplayLayoutStore; | 38 class DisplayLayoutStore; |
| 39 class MouseWarpController; | 39 class MouseWarpController; |
| 40 class ScreenAsh; | 40 class ScreenAsh; |
| 41 | 41 |
| 42 typedef std::vector<DisplayInfo> DisplayInfoList; |
| 43 |
| 42 namespace test { | 44 namespace test { |
| 43 class AshTestBase; | 45 class AshTestBase; |
| 44 class DisplayManagerTestApi; | 46 class DisplayManagerTestApi; |
| 45 class SystemGestureEventFilterTest; | 47 class SystemGestureEventFilterTest; |
| 46 } | 48 } |
| 47 | 49 |
| 48 // DisplayManager maintains the current display configurations, | 50 // DisplayManager maintains the current display configurations, |
| 49 // and notifies observers when configuration changes. | 51 // and notifies observers when configuration changes. |
| 50 // | 52 // |
| 51 // TODO(oshima): Make this non internal. | 53 // TODO(oshima): Make this non internal. |
| 52 class ASH_EXPORT DisplayManager | 54 class ASH_EXPORT DisplayManager |
| 53 #if defined(OS_CHROMEOS) | 55 #if defined(OS_CHROMEOS) |
| 54 : public ui::DisplayConfigurator::SoftwareMirroringController | 56 : public ui::DisplayConfigurator::SoftwareMirroringController |
| 55 #endif | 57 #endif |
| 56 { | 58 { |
| 57 public: | 59 public: |
| 58 class ASH_EXPORT Delegate { | 60 class ASH_EXPORT Delegate { |
| 59 public: | 61 public: |
| 60 virtual ~Delegate() {} | 62 virtual ~Delegate() {} |
| 61 | 63 |
| 62 // Create or updates the mirroring window with |display_info|. | 64 // Create or updates the mirroring window with |display_info_list|. |
| 63 virtual void CreateOrUpdateMirroringDisplay( | 65 virtual void CreateOrUpdateMirroringDisplay( |
| 64 const DisplayInfo& display_info) = 0; | 66 const DisplayInfoList& display_info_list) = 0; |
| 65 | 67 |
| 66 // Closes the mirror window if exists. | 68 // Closes the mirror window if exists. |
| 67 virtual void CloseMirroringDisplay() = 0; | 69 virtual void CloseMirroringDisplay() = 0; |
| 68 | 70 |
| 69 // Called before and after the display configuration changes. | 71 // Called before and after the display configuration changes. |
| 70 // When |clear_focus| is true, the implementation should | 72 // When |clear_focus| is true, the implementation should |
| 71 // deactivate the active window and set the focus window to NULL. | 73 // deactivate the active window and set the focus window to NULL. |
| 72 virtual void PreDisplayConfigurationChange(bool clear_focus) = 0; | 74 virtual void PreDisplayConfigurationChange(bool clear_focus) = 0; |
| 73 virtual void PostDisplayConfigurationChange() = 0; | 75 virtual void PostDisplayConfigurationChange() = 0; |
| 74 }; | 76 }; |
| 75 | 77 |
| 76 typedef std::vector<gfx::Display> DisplayList; | 78 typedef std::vector<gfx::Display> DisplayList; |
| 77 | 79 |
| 78 // How the second display will be used. | 80 // How the second display will be used. |
| 79 // 1) EXTENDED mode extends the desktop to the second dislpay. | 81 // 1) EXTENDED mode extends the desktop to the second dislpay. |
| 80 // 2) MIRRORING mode copies the content of the primary display to | 82 // 2) MIRRORING mode copies the content of the primary display to |
| 81 // the 2nd display. (Software Mirroring). | 83 // the 2nd display. (Software Mirroring). |
| 82 enum SecondDisplayMode { | 84 // 3) UNIFIED mode. |
| 85 enum MultiDisplayMode { |
| 83 EXTENDED, | 86 EXTENDED, |
| 84 MIRRORING | 87 MIRRORING, |
| 88 UNIFIED, |
| 85 }; | 89 }; |
| 86 | 90 |
| 91 static int64 kUnifiedDisplayId; |
| 92 |
| 87 DisplayManager(); | 93 DisplayManager(); |
| 88 #if defined(OS_CHROMEOS) | 94 #if defined(OS_CHROMEOS) |
| 89 ~DisplayManager() override; | 95 ~DisplayManager() override; |
| 90 #else | 96 #else |
| 91 virtual ~DisplayManager(); | 97 virtual ~DisplayManager(); |
| 92 #endif | 98 #endif |
| 93 | 99 |
| 94 DisplayLayoutStore* layout_store() { | 100 DisplayLayoutStore* layout_store() { |
| 95 return layout_store_.get(); | 101 return layout_store_.get(); |
| 96 } | 102 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 246 } |
| 241 | 247 |
| 242 // Returns the number of connected displays. This returns 2 | 248 // Returns the number of connected displays. This returns 2 |
| 243 // when displays are mirrored. | 249 // when displays are mirrored. |
| 244 size_t num_connected_displays() const { return num_connected_displays_; } | 250 size_t num_connected_displays() const { return num_connected_displays_; } |
| 245 | 251 |
| 246 // Returns the mirroring status. | 252 // Returns the mirroring status. |
| 247 bool IsInMirrorMode() const; | 253 bool IsInMirrorMode() const; |
| 248 int64 mirroring_display_id() const { return mirroring_display_id_; } | 254 int64 mirroring_display_id() const { return mirroring_display_id_; } |
| 249 | 255 |
| 250 // Returns the display used for software mirrroring. | 256 bool IsInUnifiedMode() const; |
| 251 const gfx::Display& software_mirroring_display() const { | 257 |
| 252 return software_mirroring_display_; | 258 // Returns the display used for software mirrroring. Returns invalid |
| 253 } | 259 // display if not found. |
| 260 const gfx::Display GetMirroringDisplayById(int64 id) const; |
| 254 | 261 |
| 255 // Retuns the display info associated with |display_id|. | 262 // Retuns the display info associated with |display_id|. |
| 256 const DisplayInfo& GetDisplayInfo(int64 display_id) const; | 263 const DisplayInfo& GetDisplayInfo(int64 display_id) const; |
| 257 | 264 |
| 258 // Returns the human-readable name for the display |id|. | 265 // Returns the human-readable name for the display |id|. |
| 259 std::string GetDisplayNameForId(int64 id); | 266 std::string GetDisplayNameForId(int64 id); |
| 260 | 267 |
| 261 // Returns the display id that is capable of UI scaling. On device, | 268 // Returns the display id that is capable of UI scaling. On device, |
| 262 // this returns internal display's ID if its device scale factor is 2, | 269 // this returns internal display's ID if its device scale factor is 2, |
| 263 // or invalid ID if such internal display doesn't exist. On linux | 270 // or invalid ID if such internal display doesn't exist. On linux |
| 264 // desktop, this returns the first display ID. | 271 // desktop, this returns the first display ID. |
| 265 int64 GetDisplayIdForUIScaling() const; | 272 int64 GetDisplayIdForUIScaling() const; |
| 266 | 273 |
| 267 // Change the mirror mode. | 274 // Change the mirror mode. |
| 268 void SetMirrorMode(bool mirrored); | 275 void SetMirrorMode(bool mirrored); |
| 269 | 276 |
| 270 // Used to emulate display change when run in a desktop environment instead | 277 // Used to emulate display change when run in a desktop environment instead |
| 271 // of on a device. | 278 // of on a device. |
| 272 void AddRemoveDisplay(); | 279 void AddRemoveDisplay(); |
| 273 void ToggleDisplayScaleFactor(); | 280 void ToggleDisplayScaleFactor(); |
| 274 | 281 |
| 275 // SoftwareMirroringController override: | 282 // SoftwareMirroringController override: |
| 276 #if defined(OS_CHROMEOS) | 283 #if defined(OS_CHROMEOS) |
| 277 void SetSoftwareMirroring(bool enabled) override; | 284 void SetSoftwareMirroring(bool enabled) override; |
| 278 bool SoftwareMirroringEnabled() const override; | 285 bool SoftwareMirroringEnabled() const override; |
| 279 #endif | 286 #endif |
| 280 bool software_mirroring_enabled() const { | 287 bool software_mirroring_enabled() const { |
| 281 return second_display_mode_ == MIRRORING; | 288 return multi_display_mode_ == MIRRORING; |
| 282 }; | 289 }; |
| 283 | 290 |
| 284 // Sets/gets second display mode. | 291 // Sets/gets multi display mode. |
| 285 void SetSecondDisplayMode(SecondDisplayMode mode); | 292 void SetMultiDisplayMode(MultiDisplayMode mode); |
| 286 SecondDisplayMode second_display_mode() const { | 293 MultiDisplayMode multi_display_mode() const { return multi_display_mode_; } |
| 287 return second_display_mode_; | 294 |
| 295 // Sets/gets default multi display mode. |
| 296 void SetDefaultMultiDisplayMode(MultiDisplayMode mode); |
| 297 MultiDisplayMode default_multi_display_mode() const { |
| 298 return default_multi_display_mode_; |
| 288 } | 299 } |
| 289 | 300 |
| 290 // Update the bounds of the display given by |display_id|. | 301 // Update the bounds of the display given by |display_id|. |
| 291 bool UpdateDisplayBounds(int64 display_id, | 302 bool UpdateDisplayBounds(int64 display_id, |
| 292 const gfx::Rect& new_bounds); | 303 const gfx::Rect& new_bounds); |
| 293 | 304 |
| 294 // Creates mirror window asynchronously if the software mirror mode | 305 // Creates mirror window asynchronously if the software mirror mode |
| 295 // is enabled. | 306 // is enabled. |
| 296 void CreateMirrorWindowAsyncIfAny(); | 307 void CreateMirrorWindowAsyncIfAny(); |
| 297 | 308 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 // Selected display modes for displays. Key is the displays' ID. | 401 // Selected display modes for displays. Key is the displays' ID. |
| 391 std::map<int64, DisplayMode> display_modes_; | 402 std::map<int64, DisplayMode> display_modes_; |
| 392 | 403 |
| 393 // When set to true, the host window's resize event updates | 404 // When set to true, the host window's resize event updates |
| 394 // the display's size. This is set to true when running on | 405 // the display's size. This is set to true when running on |
| 395 // desktop environment (for debugging) so that resizing the host | 406 // desktop environment (for debugging) so that resizing the host |
| 396 // window will update the display properly. This is set to false | 407 // window will update the display properly. This is set to false |
| 397 // on device as well as during the unit tests. | 408 // on device as well as during the unit tests. |
| 398 bool change_display_upon_host_resize_; | 409 bool change_display_upon_host_resize_; |
| 399 | 410 |
| 400 SecondDisplayMode second_display_mode_; | 411 MultiDisplayMode multi_display_mode_; |
| 412 MultiDisplayMode default_multi_display_mode_; |
| 413 |
| 401 int64 mirroring_display_id_; | 414 int64 mirroring_display_id_; |
| 402 gfx::Display software_mirroring_display_; | 415 DisplayList software_mirroring_display_list_; |
| 403 | 416 |
| 404 // User preference for rotation lock of the internal display. | 417 // User preference for rotation lock of the internal display. |
| 405 bool registered_internal_display_rotation_lock_; | 418 bool registered_internal_display_rotation_lock_; |
| 406 | 419 |
| 407 // User preference for the rotation of the internal display. | 420 // User preference for the rotation of the internal display. |
| 408 gfx::Display::Rotation registered_internal_display_rotation_; | 421 gfx::Display::Rotation registered_internal_display_rotation_; |
| 409 | 422 |
| 410 base::WeakPtrFactory<DisplayManager> weak_ptr_factory_; | 423 base::WeakPtrFactory<DisplayManager> weak_ptr_factory_; |
| 411 | 424 |
| 412 DISALLOW_COPY_AND_ASSIGN(DisplayManager); | 425 DISALLOW_COPY_AND_ASSIGN(DisplayManager); |
| 413 }; | 426 }; |
| 414 | 427 |
| 415 } // namespace ash | 428 } // namespace ash |
| 416 | 429 |
| 417 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ | 430 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ |
| OLD | NEW |