| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ws/window_tree_host_impl.h" | 5 #include "components/mus/ws/window_tree_host_impl.h" |
| 6 | 6 |
| 7 #include "base/debug/debugger.h" | 7 #include "base/debug/debugger.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "components/mus/common/types.h" | 9 #include "components/mus/common/types.h" |
| 10 #include "components/mus/public/interfaces/input_event_constants.mojom.h" | 10 #include "components/mus/public/interfaces/input_event_constants.mojom.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 WindowTreeHostImpl::QueuedEvent::QueuedEvent() {} | 85 WindowTreeHostImpl::QueuedEvent::QueuedEvent() {} |
| 86 WindowTreeHostImpl::QueuedEvent::~QueuedEvent() {} | 86 WindowTreeHostImpl::QueuedEvent::~QueuedEvent() {} |
| 87 | 87 |
| 88 WindowTreeHostImpl::WindowTreeHostImpl( | 88 WindowTreeHostImpl::WindowTreeHostImpl( |
| 89 mojom::WindowTreeHostClientPtr client, | 89 mojom::WindowTreeHostClientPtr client, |
| 90 ConnectionManager* connection_manager, | 90 ConnectionManager* connection_manager, |
| 91 mojo::ApplicationImpl* app_impl, | 91 mojo::ApplicationImpl* app_impl, |
| 92 const scoped_refptr<GpuState>& gpu_state, | 92 const scoped_refptr<GpuState>& gpu_state, |
| 93 const scoped_refptr<SurfacesState>& surfaces_state, | 93 const scoped_refptr<SurfacesState>& surfaces_state, |
| 94 mojom::WindowManagerPtr window_manager) | 94 mojom::WindowManagerPtr window_manager) |
| 95 : delegate_(nullptr), | 95 : id_(next_id++), |
| 96 delegate_(nullptr), |
| 96 connection_manager_(connection_manager), | 97 connection_manager_(connection_manager), |
| 97 client_(std::move(client)), | 98 client_(std::move(client)), |
| 98 event_dispatcher_(this), | 99 event_dispatcher_(this), |
| 99 display_manager_( | 100 display_manager_( |
| 100 DisplayManager::Create(app_impl, gpu_state, surfaces_state)), | 101 DisplayManager::Create(app_impl, gpu_state, surfaces_state)), |
| 101 window_manager_(std::move(window_manager)), | 102 window_manager_(std::move(window_manager)), |
| 102 tree_awaiting_input_ack_(nullptr), | 103 tree_awaiting_input_ack_(nullptr), |
| 103 last_cursor_(0), | 104 last_cursor_(0) { |
| 104 id_(next_id) { | 105 frame_decoration_values_ = mojom::FrameDecorationValues::New(); |
| 106 frame_decoration_values_->normal_client_area_insets = mojo::Insets::New(); |
| 107 frame_decoration_values_->maximized_client_area_insets = mojo::Insets::New(); |
| 108 frame_decoration_values_->max_title_bar_button_width = 0u; |
| 109 |
| 105 display_manager_->Init(this); | 110 display_manager_->Init(this); |
| 106 if (client_) { | 111 if (client_) { |
| 107 client_.set_connection_error_handler(base::Bind( | 112 client_.set_connection_error_handler(base::Bind( |
| 108 &WindowTreeHostImpl::OnClientClosed, base::Unretained(this))); | 113 &WindowTreeHostImpl::OnClientClosed, base::Unretained(this))); |
| 109 } | 114 } |
| 110 } | 115 } |
| 111 | 116 |
| 112 WindowTreeHostImpl::~WindowTreeHostImpl() { | 117 WindowTreeHostImpl::~WindowTreeHostImpl() { |
| 113 DestroyFocusController(); | 118 DestroyFocusController(); |
| 114 for (ServerWindow* window : windows_needing_frame_destruction_) | 119 for (ServerWindow* window : windows_needing_frame_destruction_) |
| 115 window->RemoveObserver(this); | 120 window->RemoveObserver(this); |
| 116 } | 121 } |
| 117 | 122 |
| 118 void WindowTreeHostImpl::Init(WindowTreeHostDelegate* delegate) { | 123 void WindowTreeHostImpl::Init(WindowTreeHostDelegate* delegate) { |
| 119 delegate_ = delegate; | 124 delegate_ = delegate; |
| 120 if (delegate_ && root_) | 125 if (delegate_ && root_) |
| 121 delegate_->OnDisplayInitialized(); | 126 delegate_->OnDisplayInitialized(); |
| 122 } | 127 } |
| 123 | 128 |
| 124 const WindowTreeImpl* WindowTreeHostImpl::GetWindowTree() const { | 129 const WindowTreeImpl* WindowTreeHostImpl::GetWindowTree() const { |
| 125 return delegate_ ? delegate_->GetWindowTree() : nullptr; | 130 return delegate_ ? delegate_->GetWindowTree() : nullptr; |
| 126 } | 131 } |
| 127 | 132 |
| 128 WindowTreeImpl* WindowTreeHostImpl::GetWindowTree() { | 133 WindowTreeImpl* WindowTreeHostImpl::GetWindowTree() { |
| 129 return delegate_ ? delegate_->GetWindowTree() : nullptr; | 134 return delegate_ ? delegate_->GetWindowTree() : nullptr; |
| 130 } | 135 } |
| 131 | 136 |
| 137 void WindowTreeHostImpl::SetFrameDecorationValues( |
| 138 mojom::FrameDecorationValuesPtr values) { |
| 139 frame_decoration_values_ = values.Clone(); |
| 140 connection_manager_->ProcessFrameDecorationValuesChanged(this); |
| 141 } |
| 142 |
| 132 bool WindowTreeHostImpl::IsWindowAttachedToRoot( | 143 bool WindowTreeHostImpl::IsWindowAttachedToRoot( |
| 133 const ServerWindow* window) const { | 144 const ServerWindow* window) const { |
| 134 return root_->Contains(window) && window != root_.get(); | 145 return root_->Contains(window) && window != root_.get(); |
| 135 } | 146 } |
| 136 | 147 |
| 137 bool WindowTreeHostImpl::SchedulePaintIfInViewport(const ServerWindow* window, | 148 bool WindowTreeHostImpl::SchedulePaintIfInViewport(const ServerWindow* window, |
| 138 const gfx::Rect& bounds) { | 149 const gfx::Rect& bounds) { |
| 139 if (root_->Contains(window)) { | 150 if (root_->Contains(window)) { |
| 140 display_manager_->SchedulePaint(window, bounds); | 151 display_manager_->SchedulePaint(window, bounds); |
| 141 return true; | 152 return true; |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 DispatchInputEventToWindowImpl(target, in_nonclient_area, std::move(event)); | 547 DispatchInputEventToWindowImpl(target, in_nonclient_area, std::move(event)); |
| 537 } | 548 } |
| 538 | 549 |
| 539 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { | 550 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { |
| 540 windows_needing_frame_destruction_.erase(window); | 551 windows_needing_frame_destruction_.erase(window); |
| 541 window->RemoveObserver(this); | 552 window->RemoveObserver(this); |
| 542 } | 553 } |
| 543 | 554 |
| 544 } // namespace ws | 555 } // namespace ws |
| 545 } // namespace mus | 556 } // namespace mus |
| OLD | NEW |