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 #include "services/ui/ws/user_display_manager.h" | 5 #include "services/ui/ws/user_display_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
| 9 #include "services/ui/display/screen_manager.h" |
9 #include "services/ui/ws/user_display_manager_delegate.h" | 10 #include "services/ui/ws/user_display_manager_delegate.h" |
10 #include "ui/display/display.h" | 11 #include "ui/display/display.h" |
11 #include "ui/display/screen.h" | 12 #include "ui/display/screen_base.h" |
12 #include "ui/display/types/display_constants.h" | 13 #include "ui/display/types/display_constants.h" |
13 | 14 |
14 namespace ui { | 15 namespace ui { |
15 namespace ws { | 16 namespace ws { |
16 namespace { | 17 namespace { |
17 | 18 |
18 int64_t GetInternalDisplayId() { | 19 int64_t GetInternalDisplayId() { |
19 if (!display::Display::HasInternalDisplay()) | 20 if (!display::Display::HasInternalDisplay()) |
20 return display::kInvalidDisplayId; | 21 return display::kInvalidDisplayId; |
21 | 22 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 mojom::WsDisplayPtr UserDisplayManager::ToWsDisplayPtr( | 89 mojom::WsDisplayPtr UserDisplayManager::ToWsDisplayPtr( |
89 const display::Display& display) { | 90 const display::Display& display) { |
90 mojom::WsDisplayPtr ws_display = mojom::WsDisplay::New(); | 91 mojom::WsDisplayPtr ws_display = mojom::WsDisplay::New(); |
91 ws_display->display = display; | 92 ws_display->display = display; |
92 delegate_->GetFrameDecorationsForUser(user_id_, | 93 delegate_->GetFrameDecorationsForUser(user_id_, |
93 &ws_display->frame_decoration_values); | 94 &ws_display->frame_decoration_values); |
94 return ws_display; | 95 return ws_display; |
95 } | 96 } |
96 | 97 |
97 std::vector<mojom::WsDisplayPtr> UserDisplayManager::GetAllDisplays() { | 98 std::vector<mojom::WsDisplayPtr> UserDisplayManager::GetAllDisplays() { |
98 const auto& displays = display::Screen::GetScreen()->GetAllDisplays(); | 99 const auto& displays = |
| 100 display::ScreenManager::GetInstance()->GetScreen()->GetAllDisplays(); |
99 | 101 |
100 std::vector<mojom::WsDisplayPtr> ws_display; | 102 std::vector<mojom::WsDisplayPtr> ws_display; |
101 ws_display.reserve(displays.size()); | 103 ws_display.reserve(displays.size()); |
102 | 104 |
103 for (const auto& display : displays) | 105 for (const auto& display : displays) |
104 ws_display.push_back(ToWsDisplayPtr(display)); | 106 ws_display.push_back(ToWsDisplayPtr(display)); |
105 | 107 |
106 return ws_display; | 108 return ws_display; |
107 } | 109 } |
108 | 110 |
109 bool UserDisplayManager::ShouldCallOnDisplaysChanged() const { | 111 bool UserDisplayManager::ShouldCallOnDisplaysChanged() const { |
110 return got_valid_frame_decorations_ && | 112 return got_valid_frame_decorations_ && !display::ScreenManager::GetInstance() |
111 !display::Screen::GetScreen()->GetAllDisplays().empty(); | 113 ->GetScreen() |
| 114 ->GetAllDisplays() |
| 115 .empty(); |
112 } | 116 } |
113 | 117 |
114 void UserDisplayManager::CallOnDisplaysChangedIfNecessary() { | 118 void UserDisplayManager::CallOnDisplaysChangedIfNecessary() { |
115 if (!notify_automatically_ || !ShouldCallOnDisplaysChanged()) | 119 if (!notify_automatically_ || !ShouldCallOnDisplaysChanged()) |
116 return; | 120 return; |
117 | 121 |
118 CallOnDisplaysChanged(); | 122 CallOnDisplaysChanged(); |
119 } | 123 } |
120 | 124 |
121 void UserDisplayManager::CallOnDisplaysChanged( | 125 void UserDisplayManager::CallOnDisplaysChanged( |
122 mojom::DisplayManagerObserver* observer) { | 126 mojom::DisplayManagerObserver* observer) { |
123 observer->OnDisplaysChanged( | 127 observer->OnDisplaysChanged(GetAllDisplays(), |
124 GetAllDisplays(), display::Screen::GetScreen()->GetPrimaryDisplay().id(), | 128 display::ScreenManager::GetInstance() |
125 GetInternalDisplayId()); | 129 ->GetScreen() |
| 130 ->GetPrimaryDisplay() |
| 131 .id(), |
| 132 GetInternalDisplayId()); |
126 } | 133 } |
127 | 134 |
128 } // namespace ws | 135 } // namespace ws |
129 } // namespace ui | 136 } // namespace ui |
OLD | NEW |