| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 COMPONENTS_MUS_WS_DISPLAY_MANAGER_H_ | 5 #ifndef COMPONENTS_MUS_WS_DISPLAY_MANAGER_H_ |
| 6 #define COMPONENTS_MUS_WS_DISPLAY_MANAGER_H_ | 6 #define COMPONENTS_MUS_WS_DISPLAY_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> |
| 8 #include <set> | 9 #include <set> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 11 #include "components/mus/ws/ids.h" | 13 #include "components/mus/ws/ids.h" |
| 14 #include "components/mus/ws/user_id.h" |
| 12 | 15 |
| 13 namespace mus { | 16 namespace mus { |
| 14 namespace ws { | 17 namespace ws { |
| 15 | 18 |
| 16 class Display; | 19 class Display; |
| 17 class DisplayManagerDelegate; | 20 class DisplayManagerDelegate; |
| 18 class ServerWindow; | 21 class ServerWindow; |
| 22 class UserDisplayManager; |
| 19 class WindowManagerState; | 23 class WindowManagerState; |
| 20 | 24 |
| 21 struct WindowManagerAndDisplay { | 25 struct WindowManagerAndDisplay { |
| 22 WindowManagerAndDisplay() : window_manager_state(nullptr), display(nullptr) {} | 26 WindowManagerAndDisplay() : window_manager_state(nullptr), display(nullptr) {} |
| 23 | 27 |
| 24 WindowManagerState* window_manager_state; | 28 WindowManagerState* window_manager_state; |
| 25 Display* display; | 29 Display* display; |
| 26 }; | 30 }; |
| 27 | 31 |
| 28 struct WindowManagerAndDisplayConst { | 32 struct WindowManagerAndDisplayConst { |
| 29 WindowManagerAndDisplayConst() | 33 WindowManagerAndDisplayConst() |
| 30 : window_manager_state(nullptr), display(nullptr) {} | 34 : window_manager_state(nullptr), display(nullptr) {} |
| 31 const WindowManagerState* window_manager_state; | 35 const WindowManagerState* window_manager_state; |
| 32 const Display* display; | 36 const Display* display; |
| 33 }; | 37 }; |
| 34 | 38 |
| 35 class DisplayManager { | 39 class DisplayManager { |
| 36 public: | 40 public: |
| 37 explicit DisplayManager(DisplayManagerDelegate* delegate); | 41 explicit DisplayManager(DisplayManagerDelegate* delegate); |
| 38 ~DisplayManager(); | 42 ~DisplayManager(); |
| 39 | 43 |
| 44 // Returns the UserDisplayManager for |user_id|. DisplayManager owns the |
| 45 // return value. |
| 46 UserDisplayManager* GetUserDisplayManager(const UserId& user_id); |
| 47 |
| 40 // Adds/removes a Display. DisplayManager owns the Displays. | 48 // Adds/removes a Display. DisplayManager owns the Displays. |
| 41 // TODO(sky): make add take a scoped_ptr. | 49 // TODO(sky): make add take a scoped_ptr. |
| 42 void AddDisplay(Display* display); | 50 void AddDisplay(Display* display); |
| 43 void DestroyDisplay(Display* display); | 51 void DestroyDisplay(Display* display); |
| 44 void DestroyAllDisplays(); | 52 void DestroyAllDisplays(); |
| 45 const std::set<Display*>& displays() { return displays_; } | 53 const std::set<Display*>& displays() { return displays_; } |
| 46 std::set<const Display*> displays() const; | 54 std::set<const Display*> displays() const; |
| 47 | 55 |
| 48 // Returns the Display that contains |window|, or null if |window| is not | 56 // Returns the Display that contains |window|, or null if |window| is not |
| 49 // attached to a display. | 57 // attached to a display. |
| 50 Display* GetDisplayContaining(ServerWindow* window); | 58 Display* GetDisplayContaining(ServerWindow* window); |
| 51 const Display* GetDisplayContaining(const ServerWindow* window) const; | 59 const Display* GetDisplayContaining(const ServerWindow* window) const; |
| 52 | 60 |
| 53 Display* GetActiveDisplay(); | 61 Display* GetActiveDisplay(); |
| 54 | 62 |
| 55 WindowManagerAndDisplayConst GetWindowManagerAndDisplay( | 63 WindowManagerAndDisplayConst GetWindowManagerAndDisplay( |
| 56 const ServerWindow* window) const; | 64 const ServerWindow* window) const; |
| 57 WindowManagerAndDisplay GetWindowManagerAndDisplay( | 65 WindowManagerAndDisplay GetWindowManagerAndDisplay( |
| 58 const ServerWindow* window); | 66 const ServerWindow* window); |
| 59 | 67 |
| 60 bool has_displays() const { return !displays_.empty(); } | 68 bool has_displays() const { return !displays_.empty(); } |
| 61 bool has_active_or_pending_displays() const { | 69 bool has_active_or_pending_displays() const { |
| 62 return !displays_.empty() || !pending_displays_.empty(); | 70 return !displays_.empty() || !pending_displays_.empty(); |
| 63 } | 71 } |
| 64 | 72 |
| 65 // Returns the id for the next root window (both for the root of a Display | 73 // Returns the id for the next root window (both for the root of a Display |
| 66 // as well as the root of WindowManagers). | 74 // as well as the root of WindowManagers). |
| 67 WindowId GetAndAdvanceNextRootId(); | 75 WindowId GetAndAdvanceNextRootId(); |
| 68 | 76 |
| 77 uint32_t GetAndAdvanceNextDisplayId(); |
| 78 |
| 69 // Called when the AcceleratedWidget is available for |display|. | 79 // Called when the AcceleratedWidget is available for |display|. |
| 70 void OnDisplayAcceleratedWidgetAvailable(Display* display); | 80 void OnDisplayAcceleratedWidgetAvailable(Display* display); |
| 71 | 81 |
| 72 private: | 82 private: |
| 73 DisplayManagerDelegate* delegate_; | 83 DisplayManagerDelegate* delegate_; |
| 74 | 84 |
| 75 // Displays are initially added to |pending_displays_|. When the display is | 85 // Displays are initially added to |pending_displays_|. When the display is |
| 76 // initialized it is moved to |displays_|. ConnectionManager owns the | 86 // initialized it is moved to |displays_|. ConnectionManager owns the |
| 77 // Displays. | 87 // Displays. |
| 78 std::set<Display*> pending_displays_; | 88 std::set<Display*> pending_displays_; |
| 79 std::set<Display*> displays_; | 89 std::set<Display*> displays_; |
| 80 | 90 |
| 91 std::map<UserId, scoped_ptr<UserDisplayManager>> user_display_managers_; |
| 92 |
| 81 // ID to use for next root node. | 93 // ID to use for next root node. |
| 82 ConnectionSpecificId next_root_id_; | 94 ConnectionSpecificId next_root_id_; |
| 83 | 95 |
| 96 uint32_t next_display_id_; |
| 97 |
| 84 DISALLOW_COPY_AND_ASSIGN(DisplayManager); | 98 DISALLOW_COPY_AND_ASSIGN(DisplayManager); |
| 85 }; | 99 }; |
| 86 | 100 |
| 87 } // namespace ws | 101 } // namespace ws |
| 88 } // namespace mus | 102 } // namespace mus |
| 89 | 103 |
| 90 #endif // COMPONENTS_MUS_WS_DISPLAY_MANAGER_H_ | 104 #endif // COMPONENTS_MUS_WS_DISPLAY_MANAGER_H_ |
| OLD | NEW |