| 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 creates single desktop across multiple displays. |
| 85 enum MultiDisplayMode { |
| 83 EXTENDED, | 86 EXTENDED, |
| 84 MIRRORING | 87 MIRRORING, |
| 88 UNIFIED, |
| 85 }; | 89 }; |
| 86 | 90 |
| 91 // The display ID for a virtual display assigned to a unified desktop. |
| 92 static int64 kUnifiedDisplayId; |
| 93 |
| 87 DisplayManager(); | 94 DisplayManager(); |
| 88 #if defined(OS_CHROMEOS) | 95 #if defined(OS_CHROMEOS) |
| 89 ~DisplayManager() override; | 96 ~DisplayManager() override; |
| 90 #else | 97 #else |
| 91 virtual ~DisplayManager(); | 98 virtual ~DisplayManager(); |
| 92 #endif | 99 #endif |
| 93 | 100 |
| 94 DisplayLayoutStore* layout_store() { | 101 DisplayLayoutStore* layout_store() { |
| 95 return layout_store_.get(); | 102 return layout_store_.get(); |
| 96 } | 103 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 247 } |
| 241 | 248 |
| 242 // Returns the number of connected displays. This returns 2 | 249 // Returns the number of connected displays. This returns 2 |
| 243 // when displays are mirrored. | 250 // when displays are mirrored. |
| 244 size_t num_connected_displays() const { return num_connected_displays_; } | 251 size_t num_connected_displays() const { return num_connected_displays_; } |
| 245 | 252 |
| 246 // Returns the mirroring status. | 253 // Returns the mirroring status. |
| 247 bool IsInMirrorMode() const; | 254 bool IsInMirrorMode() const; |
| 248 int64 mirroring_display_id() const { return mirroring_display_id_; } | 255 int64 mirroring_display_id() const { return mirroring_display_id_; } |
| 249 | 256 |
| 250 // Returns the display used for software mirrroring. | 257 bool IsInUnifiedMode() const; |
| 251 const gfx::Display& software_mirroring_display() const { | 258 |
| 252 return software_mirroring_display_; | 259 // Returns the display used for software mirrroring. Returns invalid |
| 253 } | 260 // display if not found. |
| 261 const gfx::Display GetMirroringDisplayById(int64 id) const; |
| 254 | 262 |
| 255 // Retuns the display info associated with |display_id|. | 263 // Retuns the display info associated with |display_id|. |
| 256 const DisplayInfo& GetDisplayInfo(int64 display_id) const; | 264 const DisplayInfo& GetDisplayInfo(int64 display_id) const; |
| 257 | 265 |
| 258 // Returns the human-readable name for the display |id|. | 266 // Returns the human-readable name for the display |id|. |
| 259 std::string GetDisplayNameForId(int64 id); | 267 std::string GetDisplayNameForId(int64 id); |
| 260 | 268 |
| 261 // Returns the display id that is capable of UI scaling. On device, | 269 // 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, | 270 // 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 | 271 // or invalid ID if such internal display doesn't exist. On linux |
| 264 // desktop, this returns the first display ID. | 272 // desktop, this returns the first display ID. |
| 265 int64 GetDisplayIdForUIScaling() const; | 273 int64 GetDisplayIdForUIScaling() const; |
| 266 | 274 |
| 267 // Change the mirror mode. | 275 // Change the mirror mode. |
| 268 void SetMirrorMode(bool mirrored); | 276 void SetMirrorMode(bool mirrored); |
| 269 | 277 |
| 270 // Used to emulate display change when run in a desktop environment instead | 278 // Used to emulate display change when run in a desktop environment instead |
| 271 // of on a device. | 279 // of on a device. |
| 272 void AddRemoveDisplay(); | 280 void AddRemoveDisplay(); |
| 273 void ToggleDisplayScaleFactor(); | 281 void ToggleDisplayScaleFactor(); |
| 274 | 282 |
| 275 // SoftwareMirroringController override: | 283 // SoftwareMirroringController override: |
| 276 #if defined(OS_CHROMEOS) | 284 #if defined(OS_CHROMEOS) |
| 277 void SetSoftwareMirroring(bool enabled) override; | 285 void SetSoftwareMirroring(bool enabled) override; |
| 278 bool SoftwareMirroringEnabled() const override; | 286 bool SoftwareMirroringEnabled() const override; |
| 279 #endif | 287 #endif |
| 280 bool software_mirroring_enabled() const { | 288 bool software_mirroring_enabled() const { |
| 281 return second_display_mode_ == MIRRORING; | 289 return multi_display_mode_ == MIRRORING; |
| 282 }; | 290 }; |
| 283 | 291 |
| 284 // Sets/gets second display mode. | 292 // Sets/gets multi display mode. |
| 285 void SetSecondDisplayMode(SecondDisplayMode mode); | 293 void SetMultiDisplayMode(MultiDisplayMode mode); |
| 286 SecondDisplayMode second_display_mode() const { | 294 MultiDisplayMode multi_display_mode() const { return multi_display_mode_; } |
| 287 return second_display_mode_; | 295 |
| 296 // Sets/gets default multi display mode. |
| 297 void SetDefaultMultiDisplayMode(MultiDisplayMode mode); |
| 298 MultiDisplayMode default_multi_display_mode() const { |
| 299 return default_multi_display_mode_; |
| 288 } | 300 } |
| 289 | 301 |
| 290 // Update the bounds of the display given by |display_id|. | 302 // Update the bounds of the display given by |display_id|. |
| 291 bool UpdateDisplayBounds(int64 display_id, | 303 bool UpdateDisplayBounds(int64 display_id, |
| 292 const gfx::Rect& new_bounds); | 304 const gfx::Rect& new_bounds); |
| 293 | 305 |
| 294 // Creates mirror window asynchronously if the software mirror mode | 306 // Creates mirror window asynchronously if the software mirror mode |
| 295 // is enabled. | 307 // is enabled. |
| 296 void CreateMirrorWindowAsyncIfAny(); | 308 void CreateMirrorWindowAsyncIfAny(); |
| 297 | 309 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 // Selected display modes for displays. Key is the displays' ID. | 402 // Selected display modes for displays. Key is the displays' ID. |
| 391 std::map<int64, DisplayMode> display_modes_; | 403 std::map<int64, DisplayMode> display_modes_; |
| 392 | 404 |
| 393 // When set to true, the host window's resize event updates | 405 // When set to true, the host window's resize event updates |
| 394 // the display's size. This is set to true when running on | 406 // the display's size. This is set to true when running on |
| 395 // desktop environment (for debugging) so that resizing the host | 407 // desktop environment (for debugging) so that resizing the host |
| 396 // window will update the display properly. This is set to false | 408 // window will update the display properly. This is set to false |
| 397 // on device as well as during the unit tests. | 409 // on device as well as during the unit tests. |
| 398 bool change_display_upon_host_resize_; | 410 bool change_display_upon_host_resize_; |
| 399 | 411 |
| 400 SecondDisplayMode second_display_mode_; | 412 MultiDisplayMode multi_display_mode_; |
| 413 MultiDisplayMode default_multi_display_mode_; |
| 414 |
| 401 int64 mirroring_display_id_; | 415 int64 mirroring_display_id_; |
| 402 gfx::Display software_mirroring_display_; | 416 DisplayList software_mirroring_display_list_; |
| 403 | 417 |
| 404 // User preference for rotation lock of the internal display. | 418 // User preference for rotation lock of the internal display. |
| 405 bool registered_internal_display_rotation_lock_; | 419 bool registered_internal_display_rotation_lock_; |
| 406 | 420 |
| 407 // User preference for the rotation of the internal display. | 421 // User preference for the rotation of the internal display. |
| 408 gfx::Display::Rotation registered_internal_display_rotation_; | 422 gfx::Display::Rotation registered_internal_display_rotation_; |
| 409 | 423 |
| 410 base::WeakPtrFactory<DisplayManager> weak_ptr_factory_; | 424 base::WeakPtrFactory<DisplayManager> weak_ptr_factory_; |
| 411 | 425 |
| 412 DISALLOW_COPY_AND_ASSIGN(DisplayManager); | 426 DISALLOW_COPY_AND_ASSIGN(DisplayManager); |
| 413 }; | 427 }; |
| 414 | 428 |
| 415 } // namespace ash | 429 } // namespace ash |
| 416 | 430 |
| 417 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ | 431 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ |
| OLD | NEW |