| 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 "components/mus/ws/display_manager.h" | 5 #include "components/mus/ws/display_manager.h" |
| 6 | 6 |
| 7 #include "components/mus/ws/display.h" | 7 #include "components/mus/ws/display.h" |
| 8 #include "components/mus/ws/display_manager_delegate.h" | 8 #include "components/mus/ws/display_manager_delegate.h" |
| 9 #include "components/mus/ws/server_window.h" | 9 #include "components/mus/ws/server_window.h" |
| 10 #include "components/mus/ws/user_display_manager.h" | 10 #include "components/mus/ws/user_display_manager.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 return user_display_managers_[user_id].get(); | 33 return user_display_managers_[user_id].get(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void DisplayManager::AddDisplay(Display* display) { | 36 void DisplayManager::AddDisplay(Display* display) { |
| 37 DCHECK_EQ(0u, pending_displays_.count(display)); | 37 DCHECK_EQ(0u, pending_displays_.count(display)); |
| 38 pending_displays_.insert(display); | 38 pending_displays_.insert(display); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void DisplayManager::DestroyDisplay(Display* display) { | 41 void DisplayManager::DestroyDisplay(Display* display) { |
| 42 delegate_->OnWillDestroyDisplay(display); | |
| 43 | |
| 44 if (pending_displays_.count(display)) { | 42 if (pending_displays_.count(display)) { |
| 45 pending_displays_.erase(display); | 43 pending_displays_.erase(display); |
| 46 } else { | 44 } else { |
| 47 for (const auto& pair : user_display_managers_) | 45 for (const auto& pair : user_display_managers_) |
| 48 pair.second->OnWillDestroyDisplay(display); | 46 pair.second->OnWillDestroyDisplay(display); |
| 49 | 47 |
| 50 DCHECK(displays_.count(display)); | 48 DCHECK(displays_.count(display)); |
| 51 displays_.erase(display); | 49 displays_.erase(display); |
| 52 } | 50 } |
| 53 delete display; | 51 delete display; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 82 const ServerWindow* window) const { | 80 const ServerWindow* window) const { |
| 83 while (window && window->parent()) | 81 while (window && window->parent()) |
| 84 window = window->parent(); | 82 window = window->parent(); |
| 85 for (Display* display : displays_) { | 83 for (Display* display : displays_) { |
| 86 if (window == display->root_window()) | 84 if (window == display->root_window()) |
| 87 return display; | 85 return display; |
| 88 } | 86 } |
| 89 return nullptr; | 87 return nullptr; |
| 90 } | 88 } |
| 91 | 89 |
| 92 Display* DisplayManager::GetActiveDisplay() { | |
| 93 // TODO(sky): this isn't active, but first. Make it active. | |
| 94 return displays_.size() ? *displays_.begin() : nullptr; | |
| 95 } | |
| 96 | |
| 97 WindowManagerAndDisplayConst DisplayManager::GetWindowManagerAndDisplay( | 90 WindowManagerAndDisplayConst DisplayManager::GetWindowManagerAndDisplay( |
| 98 const ServerWindow* window) const { | 91 const ServerWindow* window) const { |
| 99 const ServerWindow* last = window; | 92 const ServerWindow* last = window; |
| 100 while (window && window->parent()) { | 93 while (window && window->parent()) { |
| 101 last = window; | 94 last = window; |
| 102 window = window->parent(); | 95 window = window->parent(); |
| 103 } | 96 } |
| 104 for (Display* display : displays_) { | 97 for (Display* display : displays_) { |
| 105 if (window == display->root_window()) { | 98 if (window == display->root_window()) { |
| 106 WindowManagerAndDisplayConst result; | 99 WindowManagerAndDisplayConst result; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 DCHECK_EQ(0u, displays_.count(display)); | 137 DCHECK_EQ(0u, displays_.count(display)); |
| 145 const bool is_first_display = displays_.empty(); | 138 const bool is_first_display = displays_.empty(); |
| 146 displays_.insert(display); | 139 displays_.insert(display); |
| 147 pending_displays_.erase(display); | 140 pending_displays_.erase(display); |
| 148 if (is_first_display) | 141 if (is_first_display) |
| 149 delegate_->OnFirstDisplayReady(); | 142 delegate_->OnFirstDisplayReady(); |
| 150 } | 143 } |
| 151 | 144 |
| 152 } // namespace ws | 145 } // namespace ws |
| 153 } // namespace mus | 146 } // namespace mus |
| OLD | NEW |