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 #include "ui/gfx/geometry/point.h" |
| 8 |
| 9 namespace ui { |
| 10 namespace ws { |
| 11 |
| 12 CursorLocationManager::CursorLocationManager() {} |
| 13 |
| 14 CursorLocationManager::~CursorLocationManager() {} |
| 15 |
| 16 void CursorLocationManager::OnMouseCursorLocationChanged( |
| 17 const gfx::Point& point) { |
| 18 current_cursor_location_ = static_cast<base::subtle::Atomic32>( |
| 19 (point.x() & 0xFFFF) << 16 | (point.y() & 0xFFFF)); |
| 20 if (cursor_location_memory()) { |
| 21 base::subtle::NoBarrier_Store(cursor_location_memory(), |
| 22 current_cursor_location_); |
| 23 } |
| 24 } |
| 25 |
| 26 mojo::ScopedSharedBufferHandle |
| 27 CursorLocationManager::GetCursorLocationMemory() { |
| 28 if (!cursor_location_handle_.is_valid()) { |
| 29 // Create our shared memory segment to share the cursor state with our |
| 30 // window clients. |
| 31 cursor_location_handle_ = |
| 32 mojo::SharedBufferHandle::Create(sizeof(base::subtle::Atomic32)); |
| 33 |
| 34 if (!cursor_location_handle_.is_valid()) |
| 35 return mojo::ScopedSharedBufferHandle(); |
| 36 |
| 37 cursor_location_mapping_ = |
| 38 cursor_location_handle_->Map(sizeof(base::subtle::Atomic32)); |
| 39 if (!cursor_location_mapping_) |
| 40 return mojo::ScopedSharedBufferHandle(); |
| 41 base::subtle::NoBarrier_Store(cursor_location_memory(), |
| 42 current_cursor_location_); |
| 43 } |
| 44 |
| 45 return cursor_location_handle_->Clone( |
| 46 mojo::SharedBufferHandle::AccessMode::READ_ONLY); |
| 47 } |
| 48 |
| 49 } // namespace ws |
| 50 } // namespace ui |
OLD | NEW |