| 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 SERVICES_UI_WS_DISPLAY_MANAGER_H_ | 5 #ifndef SERVICES_UI_WS_DISPLAY_MANAGER_H_ |
| 6 #define SERVICES_UI_WS_DISPLAY_MANAGER_H_ | 6 #define SERVICES_UI_WS_DISPLAY_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "services/ui/display/platform_screen_delegate.h" |
| 13 #include "services/ui/ws/ids.h" | 14 #include "services/ui/ws/ids.h" |
| 14 #include "services/ui/ws/user_id.h" | 15 #include "services/ui/ws/user_id.h" |
| 15 #include "services/ui/ws/user_id_tracker_observer.h" | 16 #include "services/ui/ws/user_id_tracker_observer.h" |
| 16 | 17 |
| 17 namespace ui { | 18 namespace ui { |
| 18 namespace ws { | 19 namespace ws { |
| 19 | 20 |
| 20 class Display; | 21 class Display; |
| 21 class DisplayManagerDelegate; | |
| 22 class ServerWindow; | 22 class ServerWindow; |
| 23 class UserDisplayManager; | 23 class UserDisplayManager; |
| 24 class UserIdTracker; | 24 class UserIdTracker; |
| 25 class WindowManagerDisplayRoot; | 25 class WindowManagerDisplayRoot; |
| 26 class WindowServer; |
| 26 | 27 |
| 27 // DisplayManager manages the set of Displays. DisplayManager distinguishes | 28 // DisplayManager manages the set of Displays. DisplayManager distinguishes |
| 28 // between displays that do yet have an accelerated widget (pending), vs | 29 // between displays that do yet have an accelerated widget (pending), vs |
| 29 // those that do. | 30 // those that do. |
| 30 class DisplayManager : public UserIdTrackerObserver { | 31 class DisplayManager : public UserIdTrackerObserver, |
| 32 public display::PlatformScreenDelegate { |
| 31 public: | 33 public: |
| 32 DisplayManager(DisplayManagerDelegate* delegate, | 34 DisplayManager(WindowServer* window_server, UserIdTracker* user_id_tracker); |
| 33 UserIdTracker* user_id_tracker); | |
| 34 ~DisplayManager() override; | 35 ~DisplayManager() override; |
| 35 | 36 |
| 36 // Returns the UserDisplayManager for |user_id|. DisplayManager owns the | 37 // Returns the UserDisplayManager for |user_id|. DisplayManager owns the |
| 37 // return value. | 38 // return value. |
| 38 UserDisplayManager* GetUserDisplayManager(const UserId& user_id); | 39 UserDisplayManager* GetUserDisplayManager(const UserId& user_id); |
| 39 | 40 |
| 40 // Adds/removes a Display. DisplayManager owns the Displays. | 41 // Adds/removes a Display. DisplayManager owns the Displays. |
| 41 // TODO(sky): make add take a scoped_ptr. | 42 // TODO(sky): make add take a scoped_ptr. |
| 42 void AddDisplay(Display* display); | 43 void AddDisplay(Display* display); |
| 43 void DestroyDisplay(Display* display); | 44 void DestroyDisplay(Display* display); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 69 WindowId GetAndAdvanceNextRootId(); | 70 WindowId GetAndAdvanceNextRootId(); |
| 70 | 71 |
| 71 // Called when the AcceleratedWidget is available for |display|. | 72 // Called when the AcceleratedWidget is available for |display|. |
| 72 void OnDisplayAcceleratedWidgetAvailable(Display* display); | 73 void OnDisplayAcceleratedWidgetAvailable(Display* display); |
| 73 | 74 |
| 74 private: | 75 private: |
| 75 // UserIdTrackerObserver: | 76 // UserIdTrackerObserver: |
| 76 void OnActiveUserIdChanged(const UserId& previously_active_id, | 77 void OnActiveUserIdChanged(const UserId& previously_active_id, |
| 77 const UserId& active_id) override; | 78 const UserId& active_id) override; |
| 78 | 79 |
| 79 DisplayManagerDelegate* delegate_; | 80 // display::PlatformScreenDelegate: |
| 81 void OnDisplayAdded(display::PlatformScreen* platform_screen_, |
| 82 int64_t id, |
| 83 const gfx::Rect& bounds) override; |
| 84 void OnDisplayRemoved(int64_t id) override; |
| 85 void OnDisplayModified(int64_t id, const gfx::Rect& bounds) override; |
| 86 |
| 87 WindowServer* window_server_; |
| 80 UserIdTracker* user_id_tracker_; | 88 UserIdTracker* user_id_tracker_; |
| 81 | 89 |
| 82 // Displays are initially added to |pending_displays_|. When the display is | 90 // Displays are initially added to |pending_displays_|. When the display is |
| 83 // initialized it is moved to |displays_|. WindowServer owns the Displays. | 91 // initialized it is moved to |displays_|. WindowServer owns the Displays. |
| 84 std::set<Display*> pending_displays_; | 92 std::set<Display*> pending_displays_; |
| 85 std::set<Display*> displays_; | 93 std::set<Display*> displays_; |
| 86 | 94 |
| 87 std::map<UserId, std::unique_ptr<UserDisplayManager>> user_display_managers_; | 95 std::map<UserId, std::unique_ptr<UserDisplayManager>> user_display_managers_; |
| 88 | 96 |
| 89 // ID to use for next root node. | 97 // ID to use for next root node. |
| 90 ClientSpecificId next_root_id_; | 98 ClientSpecificId next_root_id_; |
| 91 | 99 |
| 92 DISALLOW_COPY_AND_ASSIGN(DisplayManager); | 100 DISALLOW_COPY_AND_ASSIGN(DisplayManager); |
| 93 }; | 101 }; |
| 94 | 102 |
| 95 } // namespace ws | 103 } // namespace ws |
| 96 } // namespace ui | 104 } // namespace ui |
| 97 | 105 |
| 98 #endif // SERVICES_UI_WS_DISPLAY_MANAGER_H_ | 106 #endif // SERVICES_UI_WS_DISPLAY_MANAGER_H_ |
| OLD | NEW |