OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "services/ui/ws/cursor_location_manager.h" |
| 6 |
| 7 namespace ui { |
| 8 namespace ws { |
| 9 |
| 10 CursorLocationManager::CursorLocationManager() {} |
| 11 |
| 12 CursorLocationManager::~CursorLocationManager() {} |
| 13 |
| 14 void CursorLocationManager::OnMouseCursorLocationChanged( |
| 15 const gfx::Point& point) { |
| 16 current_cursor_location_ = static_cast<base::subtle::Atomic32>( |
| 17 (point.x() & 0xFFFF) << 16 | (point.y() & 0xFFFF)); |
| 18 if (cursor_location_memory()) { |
| 19 base::subtle::NoBarrier_Store(cursor_location_memory(), |
| 20 current_cursor_location_); |
| 21 } |
| 22 } |
| 23 |
| 24 mojo::ScopedSharedBufferHandle |
| 25 CursorLocationManager::GetCursorLocationMemory() { |
| 26 if (!cursor_location_handle_.is_valid()) { |
| 27 // Create our shared memory segment to share the cursor state with our |
| 28 // window clients. |
| 29 cursor_location_handle_ = |
| 30 mojo::SharedBufferHandle::Create(sizeof(base::subtle::Atomic32)); |
| 31 |
| 32 if (!cursor_location_handle_.is_valid()) |
| 33 return mojo::ScopedSharedBufferHandle(); |
| 34 |
| 35 cursor_location_mapping_ = |
| 36 cursor_location_handle_->Map(sizeof(base::subtle::Atomic32)); |
| 37 if (!cursor_location_mapping_) |
| 38 return mojo::ScopedSharedBufferHandle(); |
| 39 base::subtle::NoBarrier_Store(cursor_location_memory(), |
| 40 current_cursor_location_); |
| 41 } |
| 42 |
| 43 return cursor_location_handle_->Clone( |
| 44 mojo::SharedBufferHandle::AccessMode::READ_ONLY); |
| 45 } |
| 46 |
| 47 } // namespace ws |
| 48 } // namespace ui |
OLD | NEW |