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

Side by Side 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, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/mus/public/cpp/lib/window_tree_client_impl.h" 5 #include "components/mus/public/cpp/lib/window_tree_client_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 : connection_id_(0), 124 : connection_id_(0),
125 next_window_id_(1), 125 next_window_id_(1),
126 next_change_id_(1), 126 next_change_id_(1),
127 delegate_(delegate), 127 delegate_(delegate),
128 window_manager_delegate_(window_manager_delegate), 128 window_manager_delegate_(window_manager_delegate),
129 capture_window_(nullptr), 129 capture_window_(nullptr),
130 focused_window_(nullptr), 130 focused_window_(nullptr),
131 binding_(this), 131 binding_(this),
132 tree_(nullptr), 132 tree_(nullptr),
133 delete_on_no_roots_(true), 133 delete_on_no_roots_(true),
134 in_destructor_(false) { 134 in_destructor_(false),
135 cursor_location_memory_(nullptr),
136 weak_factory_(this) {
135 // Allow for a null request in tests. 137 // Allow for a null request in tests.
136 if (request.is_pending()) 138 if (request.is_pending())
137 binding_.Bind(std::move(request)); 139 binding_.Bind(std::move(request));
138 if (window_manager_delegate) 140 if (window_manager_delegate)
139 window_manager_delegate->SetWindowManagerClient(this); 141 window_manager_delegate->SetWindowManagerClient(this);
140 } 142 }
141 143
142 WindowTreeClientImpl::~WindowTreeClientImpl() { 144 WindowTreeClientImpl::~WindowTreeClientImpl() {
143 in_destructor_ = true; 145 in_destructor_ = true;
144 146
(...skipping 25 matching lines...) Expand all
170 delete_on_no_roots_ = false; 172 delete_on_no_roots_ = false;
171 173
172 // The connection id doesn't really matter, we use 101 purely for debugging. 174 // The connection id doesn't really matter, we use 101 purely for debugging.
173 connection_id_ = 101; 175 connection_id_ = 101;
174 176
175 mojom::WindowTreeFactoryPtr factory; 177 mojom::WindowTreeFactoryPtr factory;
176 connector->ConnectToInterface("mojo:mus", &factory); 178 connector->ConnectToInterface("mojo:mus", &factory);
177 factory->CreateWindowTree(GetProxy(&tree_ptr_), 179 factory->CreateWindowTree(GetProxy(&tree_ptr_),
178 binding_.CreateInterfacePtrAndBind()); 180 binding_.CreateInterfacePtrAndBind());
179 tree_ = tree_ptr_.get(); 181 tree_ = tree_ptr_.get();
182
183 tree_ptr_->GetCursorLocationMemory(
184 base::Bind(&WindowTreeClientImpl::OnReceivedCursorLocationMemory,
185 weak_factory_.GetWeakPtr()));
180 } 186 }
181 187
182 void WindowTreeClientImpl::WaitForEmbed() { 188 void WindowTreeClientImpl::WaitForEmbed() {
183 DCHECK(roots_.empty()); 189 DCHECK(roots_.empty());
184 // OnEmbed() is the first function called. 190 // OnEmbed() is the first function called.
185 binding_.WaitForIncomingMethodCall(); 191 binding_.WaitForIncomingMethodCall();
186 // TODO(sky): deal with pipe being closed before we get OnEmbed(). 192 // TODO(sky): deal with pipe being closed before we get OnEmbed().
187 } 193 }
188 194
189 void WindowTreeClientImpl::DestroyWindow(Window* window) { 195 void WindowTreeClientImpl::DestroyWindow(Window* window) {
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 WindowPrivate(root).LocalSetParentDrawn(drawn); 528 WindowPrivate(root).LocalSetParentDrawn(drawn);
523 529
524 delegate_->OnEmbed(root); 530 delegate_->OnEmbed(root);
525 531
526 if (focused_window_) { 532 if (focused_window_) {
527 FOR_EACH_OBSERVER(WindowTreeConnectionObserver, observers_, 533 FOR_EACH_OBSERVER(WindowTreeConnectionObserver, observers_,
528 OnWindowTreeFocusChanged(focused_window_, nullptr)); 534 OnWindowTreeFocusChanged(focused_window_, nullptr));
529 } 535 }
530 } 536 }
531 537
538 void WindowTreeClientImpl::OnReceivedCursorLocationMemory(
539 mojo::ScopedSharedBufferHandle handle) {
540 cursor_location_handle_ = std::move(handle);
541 MojoResult result = mojo::MapBuffer(
542 cursor_location_handle_.get(), 0,
543 sizeof(base::subtle::Atomic32),
544 reinterpret_cast<void**>(&cursor_location_memory_),
545 MOJO_MAP_BUFFER_FLAG_NONE);
546 if (result != MOJO_RESULT_OK) {
547 NOTREACHED();
548 return;
549 }
550 DCHECK(cursor_location_memory_);
551 }
552
532 //////////////////////////////////////////////////////////////////////////////// 553 ////////////////////////////////////////////////////////////////////////////////
533 // WindowTreeClientImpl, WindowTreeConnection implementation: 554 // WindowTreeClientImpl, WindowTreeConnection implementation:
534 555
535 void WindowTreeClientImpl::SetDeleteOnNoRoots(bool value) { 556 void WindowTreeClientImpl::SetDeleteOnNoRoots(bool value) {
536 delete_on_no_roots_ = value; 557 delete_on_no_roots_ = value;
537 } 558 }
538 559
539 const std::set<Window*>& WindowTreeClientImpl::GetRoots() { 560 const std::set<Window*>& WindowTreeClientImpl::GetRoots() {
540 return roots_; 561 return roots_;
541 } 562 }
542 563
543 Window* WindowTreeClientImpl::GetFocusedWindow() { 564 Window* WindowTreeClientImpl::GetFocusedWindow() {
544 return focused_window_; 565 return focused_window_;
545 } 566 }
546 567
547 void WindowTreeClientImpl::ClearFocus() { 568 void WindowTreeClientImpl::ClearFocus() {
548 if (!focused_window_) 569 if (!focused_window_)
549 return; 570 return;
550 571
551 SetFocus(nullptr); 572 SetFocus(nullptr);
552 } 573 }
553 574
575 gfx::Point WindowTreeClientImpl::GetCursorScreenPoint() {
576 // We raced initialization. Return (0, 0).
577 if (!cursor_location_memory_)
578 return gfx::Point();
579
580 base::subtle::Atomic32 location =
581 base::subtle::NoBarrier_Load(cursor_location_memory_);
582 return gfx::Point(static_cast<int16_t>(location >> 16),
583 static_cast<int16_t>(location & 0xFFFF));
584 }
585
554 void WindowTreeClientImpl::SetEventObserver(mojom::EventMatcherPtr matcher) { 586 void WindowTreeClientImpl::SetEventObserver(mojom::EventMatcherPtr matcher) {
555 if (matcher.is_null()) { 587 if (matcher.is_null()) {
556 has_event_observer_ = false; 588 has_event_observer_ = false;
557 tree_->SetEventObserver(nullptr, 0u); 589 tree_->SetEventObserver(nullptr, 0u);
558 } else { 590 } else {
559 has_event_observer_ = true; 591 has_event_observer_ = true;
560 event_observer_id_++; 592 event_observer_id_++;
561 tree_->SetEventObserver(std::move(matcher), event_observer_id_); 593 tree_->SetEventObserver(std::move(matcher), event_observer_id_);
562 } 594 }
563 } 595 }
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 1093
1062 void WindowTreeClientImpl::SetUnderlaySurfaceOffsetAndExtendedHitArea( 1094 void WindowTreeClientImpl::SetUnderlaySurfaceOffsetAndExtendedHitArea(
1063 Window* window, 1095 Window* window,
1064 const gfx::Vector2d& offset, 1096 const gfx::Vector2d& offset,
1065 const gfx::Insets& hit_area) { 1097 const gfx::Insets& hit_area) {
1066 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( 1098 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea(
1067 server_id(window), offset.x(), offset.y(), mojo::Insets::From(hit_area)); 1099 server_id(window), offset.x(), offset.y(), mojo::Insets::From(hit_area));
1068 } 1100 }
1069 1101
1070 } // namespace mus 1102 } // namespace mus
OLDNEW
« 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