Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 called_initialize_cursor_location_(false), | |
| 136 cursor_location_memory_(nullptr), | |
| 137 weak_factory_(this) { | |
| 135 // Allow for a null request in tests. | 138 // Allow for a null request in tests. |
| 136 if (request.is_pending()) | 139 if (request.is_pending()) |
| 137 binding_.Bind(std::move(request)); | 140 binding_.Bind(std::move(request)); |
| 138 if (window_manager_delegate) | 141 if (window_manager_delegate) |
| 139 window_manager_delegate->SetWindowManagerClient(this); | 142 window_manager_delegate->SetWindowManagerClient(this); |
| 140 } | 143 } |
| 141 | 144 |
| 142 WindowTreeClientImpl::~WindowTreeClientImpl() { | 145 WindowTreeClientImpl::~WindowTreeClientImpl() { |
| 143 in_destructor_ = true; | 146 in_destructor_ = true; |
| 144 | 147 |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 WindowPrivate(root).LocalSetParentDrawn(drawn); | 525 WindowPrivate(root).LocalSetParentDrawn(drawn); |
| 523 | 526 |
| 524 delegate_->OnEmbed(root); | 527 delegate_->OnEmbed(root); |
| 525 | 528 |
| 526 if (focused_window_) { | 529 if (focused_window_) { |
| 527 FOR_EACH_OBSERVER(WindowTreeConnectionObserver, observers_, | 530 FOR_EACH_OBSERVER(WindowTreeConnectionObserver, observers_, |
| 528 OnWindowTreeFocusChanged(focused_window_, nullptr)); | 531 OnWindowTreeFocusChanged(focused_window_, nullptr)); |
| 529 } | 532 } |
| 530 } | 533 } |
| 531 | 534 |
| 535 void WindowTreeClientImpl::OnReceivedCursorLocationMemory( | |
| 536 mojo::ScopedSharedBufferHandle handle) { | |
| 537 cursor_location_handle_ = std::move(handle); | |
| 538 MojoResult result = mojo::MapBuffer( | |
| 539 cursor_location_handle_.get(), 0, | |
| 540 sizeof(base::subtle::Atomic32), | |
| 541 reinterpret_cast<void**>(&cursor_location_memory_), | |
| 542 MOJO_MAP_BUFFER_FLAG_NONE); | |
| 543 if (result != MOJO_RESULT_OK) { | |
| 544 NOTREACHED(); | |
| 545 return; | |
| 546 } | |
| 547 DCHECK(cursor_location_memory_); | |
| 548 } | |
| 549 | |
| 532 //////////////////////////////////////////////////////////////////////////////// | 550 //////////////////////////////////////////////////////////////////////////////// |
| 533 // WindowTreeClientImpl, WindowTreeConnection implementation: | 551 // WindowTreeClientImpl, WindowTreeConnection implementation: |
| 534 | 552 |
| 535 void WindowTreeClientImpl::SetDeleteOnNoRoots(bool value) { | 553 void WindowTreeClientImpl::SetDeleteOnNoRoots(bool value) { |
| 536 delete_on_no_roots_ = value; | 554 delete_on_no_roots_ = value; |
| 537 } | 555 } |
| 538 | 556 |
| 539 const std::set<Window*>& WindowTreeClientImpl::GetRoots() { | 557 const std::set<Window*>& WindowTreeClientImpl::GetRoots() { |
| 540 return roots_; | 558 return roots_; |
| 541 } | 559 } |
| 542 | 560 |
| 543 Window* WindowTreeClientImpl::GetFocusedWindow() { | 561 Window* WindowTreeClientImpl::GetFocusedWindow() { |
| 544 return focused_window_; | 562 return focused_window_; |
| 545 } | 563 } |
| 546 | 564 |
| 547 void WindowTreeClientImpl::ClearFocus() { | 565 void WindowTreeClientImpl::ClearFocus() { |
| 548 if (!focused_window_) | 566 if (!focused_window_) |
| 549 return; | 567 return; |
| 550 | 568 |
| 551 SetFocus(nullptr); | 569 SetFocus(nullptr); |
| 552 } | 570 } |
| 553 | 571 |
| 572 void WindowTreeClientImpl::InitializeCursorLocation() { | |
| 573 called_initialize_cursor_location_ = true; | |
|
sky
2016/04/27 20:10:28
DCHECK(!called...?
| |
| 574 tree_ptr_->GetCursorLocationMemory( | |
| 575 base::Bind(&WindowTreeClientImpl::OnReceivedCursorLocationMemory, | |
| 576 weak_factory_.GetWeakPtr())); | |
| 577 } | |
| 578 | |
| 579 gfx::Point WindowTreeClientImpl::GetCursorScreenPoint() { | |
| 580 CHECK(called_initialize_cursor_location_); | |
| 581 | |
| 582 // We raced initialization. Return (0, 0). | |
| 583 if (!cursor_location_memory_) | |
| 584 return gfx::Point(); | |
| 585 | |
| 586 base::subtle::Atomic32 location = | |
| 587 base::subtle::NoBarrier_Load(cursor_location_memory_); | |
| 588 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'
| |
| 589 } | |
| 590 | |
| 554 Window* WindowTreeClientImpl::NewWindow( | 591 Window* WindowTreeClientImpl::NewWindow( |
| 555 const Window::SharedProperties* properties) { | 592 const Window::SharedProperties* properties) { |
| 556 return NewWindowImpl(NewWindowType::CHILD, properties); | 593 return NewWindowImpl(NewWindowType::CHILD, properties); |
| 557 } | 594 } |
| 558 | 595 |
| 559 Window* WindowTreeClientImpl::NewTopLevelWindow( | 596 Window* WindowTreeClientImpl::NewTopLevelWindow( |
| 560 const Window::SharedProperties* properties) { | 597 const Window::SharedProperties* properties) { |
| 561 Window* window = NewWindowImpl(NewWindowType::TOP_LEVEL, properties); | 598 Window* window = NewWindowImpl(NewWindowType::TOP_LEVEL, properties); |
| 562 // Assume newly created top level windows are drawn by default, otherwise | 599 // Assume newly created top level windows are drawn by default, otherwise |
| 563 // requests to focus will fail. We will get the real value in | 600 // requests to focus will fail. We will get the real value in |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1041 | 1078 |
| 1042 void WindowTreeClientImpl::SetUnderlaySurfaceOffsetAndExtendedHitArea( | 1079 void WindowTreeClientImpl::SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| 1043 Window* window, | 1080 Window* window, |
| 1044 const gfx::Vector2d& offset, | 1081 const gfx::Vector2d& offset, |
| 1045 const gfx::Insets& hit_area) { | 1082 const gfx::Insets& hit_area) { |
| 1046 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( | 1083 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| 1047 server_id(window), offset.x(), offset.y(), mojo::Insets::From(hit_area)); | 1084 server_id(window), offset.x(), offset.y(), mojo::Insets::From(hit_area)); |
| 1048 } | 1085 } |
| 1049 | 1086 |
| 1050 } // namespace mus | 1087 } // namespace mus |
| OLD | NEW |