| Index: components/mus/public/cpp/lib/window_tree_client_impl.cc
|
| diff --git a/components/mus/public/cpp/lib/window_tree_client_impl.cc b/components/mus/public/cpp/lib/window_tree_client_impl.cc
|
| index 23cc50de852f8f286bb2f203dd2c3bc5f2442b9f..4fbe840f235df627e3ae330b3ed3290bd5b1faa2 100644
|
| --- a/components/mus/public/cpp/lib/window_tree_client_impl.cc
|
| +++ b/components/mus/public/cpp/lib/window_tree_client_impl.cc
|
| @@ -131,7 +131,10 @@ WindowTreeClientImpl::WindowTreeClientImpl(
|
| binding_(this),
|
| tree_(nullptr),
|
| delete_on_no_roots_(true),
|
| - in_destructor_(false) {
|
| + in_destructor_(false),
|
| + called_initialize_cursor_location_(false),
|
| + cursor_location_memory_(nullptr),
|
| + weak_factory_(this) {
|
| // Allow for a null request in tests.
|
| if (request.is_pending())
|
| binding_.Bind(std::move(request));
|
| @@ -529,6 +532,21 @@ void WindowTreeClientImpl::OnEmbedImpl(mojom::WindowTree* window_tree,
|
| }
|
| }
|
|
|
| +void WindowTreeClientImpl::OnReceivedCursorLocationMemory(
|
| + mojo::ScopedSharedBufferHandle handle) {
|
| + cursor_location_handle_ = std::move(handle);
|
| + MojoResult result = mojo::MapBuffer(
|
| + cursor_location_handle_.get(), 0,
|
| + sizeof(base::subtle::Atomic64),
|
| + reinterpret_cast<void**>(&cursor_location_memory_),
|
| + MOJO_MAP_BUFFER_FLAG_NONE);
|
| + if (result != MOJO_RESULT_OK) {
|
| + NOTREACHED();
|
| + return;
|
| + }
|
| + DCHECK(cursor_location_memory_);
|
| +}
|
| +
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // WindowTreeClientImpl, WindowTreeConnection implementation:
|
|
|
| @@ -551,6 +569,26 @@ void WindowTreeClientImpl::ClearFocus() {
|
| SetFocus(nullptr);
|
| }
|
|
|
| +void WindowTreeClientImpl::InitializeCursorLocation() {
|
| + called_initialize_cursor_location_ = true;
|
| + tree_ptr_->GetCursorLocationMemory(
|
| + base::Bind(&WindowTreeClientImpl::OnReceivedCursorLocationMemory,
|
| + weak_factory_.GetWeakPtr()));
|
| +}
|
| +
|
| +gfx::Point WindowTreeClientImpl::GetCursorScreenPoint() {
|
| + CHECK(called_initialize_cursor_location_);
|
| +
|
| + // We raced initialization. Return (0, 0).
|
| + if (!cursor_location_memory_)
|
| + return gfx::Point();
|
| +
|
| + base::subtle::Atomic64 location =
|
| + base::subtle::NoBarrier_Load(cursor_location_memory_);
|
| + return gfx::Point(location >> 32,
|
| + location & 0xFFFFFFFF);
|
| +}
|
| +
|
| Window* WindowTreeClientImpl::NewWindow(
|
| const Window::SharedProperties* properties) {
|
| return NewWindowImpl(NewWindowType::CHILD, properties);
|
|
|