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

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: Actually apply the 32bit patch now that the delegate crash was fixed. 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 c377a8ffc75064da17b0fb218d69447c3c597d40..b09f7c8d62839aed85850a2d9cb74568ca2e4071 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::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 +569,25 @@ void WindowTreeClientImpl::ClearFocus() {
SetFocus(nullptr);
}
+void WindowTreeClientImpl::InitializeCursorLocation() {
+ called_initialize_cursor_location_ = true;
sky 2016/04/27 20:10:28 DCHECK(!called...?
+ 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::Atomic32 location =
+ base::subtle::NoBarrier_Load(cursor_location_memory_);
+ return gfx::Point(location >> 16, location & 0xFFFF);
sky 2016/04/27 20:10:28 I believe the way you have this code means we can'
+}
+
Window* WindowTreeClientImpl::NewWindow(
const Window::SharedProperties* properties) {
return NewWindowImpl(NewWindowType::CHILD, properties);

Powered by Google App Engine
This is Rietveld 408576698