| 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/display/screen_manager.h" |
| 10 #include "services/ui/ws/display.h" | 10 #include "services/ui/ws/display.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 } // namespace | 29 } // namespace |
| 30 | 30 |
| 31 UserDisplayManager::UserDisplayManager(ws::DisplayManager* display_manager, | 31 UserDisplayManager::UserDisplayManager(ws::DisplayManager* display_manager, |
| 32 UserDisplayManagerDelegate* delegate, | 32 UserDisplayManagerDelegate* delegate, |
| 33 const UserId& user_id) | 33 const UserId& user_id) |
| 34 : display_manager_(display_manager), | 34 : display_manager_(display_manager), |
| 35 delegate_(delegate), | 35 delegate_(delegate), |
| 36 user_id_(user_id), | 36 user_id_(user_id), |
| 37 got_valid_frame_decorations_( | 37 got_valid_frame_decorations_( |
| 38 delegate->GetFrameDecorationsForUser(user_id, nullptr)), | 38 delegate->GetFrameDecorationsForUser(user_id, nullptr)) {} |
| 39 current_cursor_location_(0) {} | |
| 40 | 39 |
| 41 UserDisplayManager::~UserDisplayManager() {} | 40 UserDisplayManager::~UserDisplayManager() {} |
| 42 | 41 |
| 43 void UserDisplayManager::OnFrameDecorationValuesChanged() { | 42 void UserDisplayManager::OnFrameDecorationValuesChanged() { |
| 44 if (!got_valid_frame_decorations_) { | 43 if (!got_valid_frame_decorations_) { |
| 45 got_valid_frame_decorations_ = true; | 44 got_valid_frame_decorations_ = true; |
| 46 display_manager_observers_.ForAllPtrs([this]( | 45 display_manager_observers_.ForAllPtrs([this]( |
| 47 mojom::DisplayManagerObserver* observer) { CallOnDisplays(observer); }); | 46 mojom::DisplayManagerObserver* observer) { CallOnDisplays(observer); }); |
| 48 return; | 47 return; |
| 49 } | 48 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 void UserDisplayManager::OnPrimaryDisplayChanged(int64_t primary_display_id) { | 85 void UserDisplayManager::OnPrimaryDisplayChanged(int64_t primary_display_id) { |
| 87 if (!got_valid_frame_decorations_) | 86 if (!got_valid_frame_decorations_) |
| 88 return; | 87 return; |
| 89 | 88 |
| 90 display_manager_observers_.ForAllPtrs( | 89 display_manager_observers_.ForAllPtrs( |
| 91 [primary_display_id](mojom::DisplayManagerObserver* observer) { | 90 [primary_display_id](mojom::DisplayManagerObserver* observer) { |
| 92 observer->OnPrimaryDisplayChanged(primary_display_id); | 91 observer->OnPrimaryDisplayChanged(primary_display_id); |
| 93 }); | 92 }); |
| 94 } | 93 } |
| 95 | 94 |
| 96 void UserDisplayManager::OnMouseCursorLocationChanged(const gfx::Point& point) { | |
| 97 current_cursor_location_ = | |
| 98 static_cast<base::subtle::Atomic32>( | |
| 99 (point.x() & 0xFFFF) << 16 | (point.y() & 0xFFFF)); | |
| 100 if (cursor_location_memory()) { | |
| 101 base::subtle::NoBarrier_Store(cursor_location_memory(), | |
| 102 current_cursor_location_); | |
| 103 } | |
| 104 } | |
| 105 | |
| 106 mojo::ScopedSharedBufferHandle UserDisplayManager::GetCursorLocationMemory() { | |
| 107 if (!cursor_location_handle_.is_valid()) { | |
| 108 // Create our shared memory segment to share the cursor state with our | |
| 109 // window clients. | |
| 110 cursor_location_handle_ = | |
| 111 mojo::SharedBufferHandle::Create(sizeof(base::subtle::Atomic32)); | |
| 112 | |
| 113 if (!cursor_location_handle_.is_valid()) | |
| 114 return mojo::ScopedSharedBufferHandle(); | |
| 115 | |
| 116 cursor_location_mapping_ = | |
| 117 cursor_location_handle_->Map(sizeof(base::subtle::Atomic32)); | |
| 118 if (!cursor_location_mapping_) | |
| 119 return mojo::ScopedSharedBufferHandle(); | |
| 120 base::subtle::NoBarrier_Store(cursor_location_memory(), | |
| 121 current_cursor_location_); | |
| 122 } | |
| 123 | |
| 124 return cursor_location_handle_->Clone( | |
| 125 mojo::SharedBufferHandle::AccessMode::READ_ONLY); | |
| 126 } | |
| 127 | |
| 128 void UserDisplayManager::AddObserver( | 95 void UserDisplayManager::AddObserver( |
| 129 mojom::DisplayManagerObserverPtr observer) { | 96 mojom::DisplayManagerObserverPtr observer) { |
| 130 mojom::DisplayManagerObserver* observer_impl = observer.get(); | 97 mojom::DisplayManagerObserver* observer_impl = observer.get(); |
| 131 display_manager_observers_.AddPtr(std::move(observer)); | 98 display_manager_observers_.AddPtr(std::move(observer)); |
| 132 OnObserverAdded(observer_impl); | 99 OnObserverAdded(observer_impl); |
| 133 } | 100 } |
| 134 | 101 |
| 135 void UserDisplayManager::OnObserverAdded( | 102 void UserDisplayManager::OnObserverAdded( |
| 136 mojom::DisplayManagerObserver* observer) { | 103 mojom::DisplayManagerObserver* observer) { |
| 137 // Many clients key off the frame decorations to size widgets. Wait for frame | 104 // Many clients key off the frame decorations to size widgets. Wait for frame |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 mojom::DisplayManagerObserver* observer) { | 136 mojom::DisplayManagerObserver* observer) { |
| 170 // TODO(kylechar): Pass internal display id to clients here. | 137 // TODO(kylechar): Pass internal display id to clients here. |
| 171 observer->OnDisplays( | 138 observer->OnDisplays( |
| 172 GetAllDisplays(), | 139 GetAllDisplays(), |
| 173 display::ScreenManager::GetInstance()->GetPrimaryDisplayId(), | 140 display::ScreenManager::GetInstance()->GetPrimaryDisplayId(), |
| 174 display::kInvalidDisplayId); | 141 display::kInvalidDisplayId); |
| 175 } | 142 } |
| 176 | 143 |
| 177 } // namespace ws | 144 } // namespace ws |
| 178 } // namespace ui | 145 } // namespace ui |
| OLD | NEW |