| 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/ws/user_display_manager_delegate.h" | 9 #include "services/ui/ws/user_display_manager_delegate.h" |
| 10 #include "ui/display/display.h" | 10 #include "ui/display/display.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 UserDisplayManager::UserDisplayManager(UserDisplayManagerDelegate* delegate, | 27 UserDisplayManager::UserDisplayManager(UserDisplayManagerDelegate* delegate, |
| 28 const UserId& user_id) | 28 const UserId& user_id) |
| 29 : delegate_(delegate), | 29 : delegate_(delegate), |
| 30 user_id_(user_id), | 30 user_id_(user_id), |
| 31 got_valid_frame_decorations_( | 31 got_valid_frame_decorations_( |
| 32 delegate->GetFrameDecorationsForUser(user_id, nullptr)) {} | 32 delegate->GetFrameDecorationsForUser(user_id, nullptr)) {} |
| 33 | 33 |
| 34 UserDisplayManager::~UserDisplayManager() {} | 34 UserDisplayManager::~UserDisplayManager() {} |
| 35 | 35 |
| 36 void UserDisplayManager::DisableAutomaticNotification() { |
| 37 DCHECK(notify_automatically_); |
| 38 notify_automatically_ = false; |
| 39 } |
| 40 |
| 41 void UserDisplayManager::CallOnDisplaysChanged() { |
| 42 display_manager_observers_.ForAllPtrs( |
| 43 [this](mojom::DisplayManagerObserver* observer) { |
| 44 CallOnDisplaysChanged(observer); |
| 45 }); |
| 46 } |
| 47 |
| 36 void UserDisplayManager::OnFrameDecorationValuesChanged() { | 48 void UserDisplayManager::OnFrameDecorationValuesChanged() { |
| 37 got_valid_frame_decorations_ = true; | 49 got_valid_frame_decorations_ = true; |
| 38 CallOnDisplaysChangedIfNecessary(); | 50 CallOnDisplaysChangedIfNecessary(); |
| 39 } | 51 } |
| 40 | 52 |
| 41 void UserDisplayManager::AddDisplayManagerBinding( | 53 void UserDisplayManager::AddDisplayManagerBinding( |
| 42 mojo::InterfaceRequest<mojom::DisplayManager> request) { | 54 mojo::InterfaceRequest<mojom::DisplayManager> request) { |
| 43 display_manager_bindings_.AddBinding(this, std::move(request)); | 55 display_manager_bindings_.AddBinding(this, std::move(request)); |
| 44 } | 56 } |
| 45 | 57 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 105 |
| 94 return ws_display; | 106 return ws_display; |
| 95 } | 107 } |
| 96 | 108 |
| 97 bool UserDisplayManager::ShouldCallOnDisplaysChanged() const { | 109 bool UserDisplayManager::ShouldCallOnDisplaysChanged() const { |
| 98 return got_valid_frame_decorations_ && | 110 return got_valid_frame_decorations_ && |
| 99 !display::Screen::GetScreen()->GetAllDisplays().empty(); | 111 !display::Screen::GetScreen()->GetAllDisplays().empty(); |
| 100 } | 112 } |
| 101 | 113 |
| 102 void UserDisplayManager::CallOnDisplaysChangedIfNecessary() { | 114 void UserDisplayManager::CallOnDisplaysChangedIfNecessary() { |
| 103 if (!ShouldCallOnDisplaysChanged()) | 115 if (!notify_automatically_ || !ShouldCallOnDisplaysChanged()) |
| 104 return; | 116 return; |
| 105 | 117 |
| 106 display_manager_observers_.ForAllPtrs( | 118 CallOnDisplaysChanged(); |
| 107 [this](mojom::DisplayManagerObserver* observer) { | |
| 108 CallOnDisplaysChanged(observer); | |
| 109 }); | |
| 110 } | 119 } |
| 111 | 120 |
| 112 void UserDisplayManager::CallOnDisplaysChanged( | 121 void UserDisplayManager::CallOnDisplaysChanged( |
| 113 mojom::DisplayManagerObserver* observer) { | 122 mojom::DisplayManagerObserver* observer) { |
| 114 observer->OnDisplaysChanged( | 123 observer->OnDisplaysChanged( |
| 115 GetAllDisplays(), display::Screen::GetScreen()->GetPrimaryDisplay().id(), | 124 GetAllDisplays(), display::Screen::GetScreen()->GetPrimaryDisplay().id(), |
| 116 GetInternalDisplayId()); | 125 GetInternalDisplayId()); |
| 117 } | 126 } |
| 118 | 127 |
| 119 } // namespace ws | 128 } // namespace ws |
| 120 } // namespace ui | 129 } // namespace ui |
| OLD | NEW |