Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Unified Diff: components/mus/public/cpp/lib/window_tree_client_impl.cc

Issue 1881253002: mus: Implement ScreenMus::GetCursorScreenPoint(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with tot Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 ec57bf62712b12a29a7b5c0129bbaaffb38e4ac9..5c5f5a3febef544dbbff08cca954f80f7ac308b6 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,9 @@ WindowTreeClientImpl::WindowTreeClientImpl(
binding_(this),
tree_(nullptr),
delete_on_no_roots_(true),
- in_destructor_(false) {
+ in_destructor_(false),
+ cursor_location_memory_(nullptr),
+ weak_factory_(this) {
// Allow for a null request in tests.
if (request.is_pending())
binding_.Bind(std::move(request));
@@ -177,6 +179,10 @@ void WindowTreeClientImpl::ConnectViaWindowTreeFactory(
factory->CreateWindowTree(GetProxy(&tree_ptr_),
binding_.CreateInterfacePtrAndBind());
tree_ = tree_ptr_.get();
+
+ tree_ptr_->GetCursorLocationMemory(
+ base::Bind(&WindowTreeClientImpl::OnReceivedCursorLocationMemory,
+ weak_factory_.GetWeakPtr()));
}
void WindowTreeClientImpl::WaitForEmbed() {
@@ -529,6 +535,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::Atomic32),
+ 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 +572,17 @@ void WindowTreeClientImpl::ClearFocus() {
SetFocus(nullptr);
}
+gfx::Point WindowTreeClientImpl::GetCursorScreenPoint() {
+ // We raced initialization. Return (0, 0).
+ if (!cursor_location_memory_)
+ return gfx::Point();
+
+ base::subtle::Atomic32 location =
+ base::subtle::NoBarrier_Load(cursor_location_memory_);
+ return gfx::Point(static_cast<int16_t>(location >> 16),
+ static_cast<int16_t>(location & 0xFFFF));
+}
+
void WindowTreeClientImpl::SetEventObserver(mojom::EventMatcherPtr matcher) {
if (matcher.is_null()) {
has_event_observer_ = false;
« no previous file with comments | « components/mus/public/cpp/lib/window_tree_client_impl.h ('k') | components/mus/public/cpp/tests/test_window_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698