| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 const AddAcceleratorCallback& callback) { | 242 const AddAcceleratorCallback& callback) { |
| 243 bool success = event_dispatcher_.AddAccelerator(id, std::move(event_matcher)); | 243 bool success = event_dispatcher_.AddAccelerator(id, std::move(event_matcher)); |
| 244 callback.Run(success); | 244 callback.Run(success); |
| 245 } | 245 } |
| 246 | 246 |
| 247 void WindowTreeHostImpl::RemoveAccelerator(uint32_t id) { | 247 void WindowTreeHostImpl::RemoveAccelerator(uint32_t id) { |
| 248 event_dispatcher_.RemoveAccelerator(id); | 248 event_dispatcher_.RemoveAccelerator(id); |
| 249 } | 249 } |
| 250 | 250 |
| 251 void WindowTreeHostImpl::AddActivationParent(Id transport_window_id) { | 251 void WindowTreeHostImpl::AddActivationParent(Id transport_window_id) { |
| 252 ServerWindow* window = connection_manager_->GetWindow( | 252 ServerWindow* window = GetWindowFromWindowTreeHost(transport_window_id); |
| 253 MapWindowIdFromClient(transport_window_id)); | |
| 254 if (window) | 253 if (window) |
| 255 activation_parents_.insert(window->id()); | 254 activation_parents_.insert(window->id()); |
| 256 } | 255 } |
| 257 | 256 |
| 258 void WindowTreeHostImpl::RemoveActivationParent(Id transport_window_id) { | 257 void WindowTreeHostImpl::RemoveActivationParent(Id transport_window_id) { |
| 259 ServerWindow* window = connection_manager_->GetWindow( | 258 ServerWindow* window = GetWindowFromWindowTreeHost(transport_window_id); |
| 260 MapWindowIdFromClient(transport_window_id)); | |
| 261 if (window) | 259 if (window) |
| 262 activation_parents_.erase(window->id()); | 260 activation_parents_.erase(window->id()); |
| 263 } | 261 } |
| 264 | 262 |
| 265 void WindowTreeHostImpl::ActivateNextWindow() { | 263 void WindowTreeHostImpl::ActivateNextWindow() { |
| 266 focus_controller_->ActivateNextWindow(); | 264 focus_controller_->ActivateNextWindow(); |
| 267 } | 265 } |
| 268 | 266 |
| 269 void WindowTreeHostImpl::SetUnderlaySurfaceOffsetAndExtendedHitArea( | 267 void WindowTreeHostImpl::SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| 270 Id window_id, | 268 Id window_id, |
| 271 int32_t x_offset, | 269 int32_t x_offset, |
| 272 int32_t y_offset, | 270 int32_t y_offset, |
| 273 mojo::InsetsPtr hit_area) { | 271 mojo::InsetsPtr hit_area) { |
| 274 ServerWindow* window = | 272 ServerWindow* window = GetWindowFromWindowTreeHost(window_id); |
| 275 connection_manager_->GetWindow(WindowIdFromTransportId(window_id)); | |
| 276 if (!window) | 273 if (!window) |
| 277 return; | 274 return; |
| 278 | 275 |
| 279 window->SetUnderlayOffset(gfx::Vector2d(x_offset, y_offset)); | 276 window->SetUnderlayOffset(gfx::Vector2d(x_offset, y_offset)); |
| 280 window->set_extended_hit_test_region(hit_area.To<gfx::Insets>()); | 277 window->set_extended_hit_test_region(hit_area.To<gfx::Insets>()); |
| 281 } | 278 } |
| 282 | 279 |
| 283 WindowId WindowTreeHostImpl::MapWindowIdFromClient( | 280 ServerWindow* WindowTreeHostImpl::GetWindowFromWindowTreeHost( |
| 284 Id transport_window_id) const { | 281 Id transport_window_id) { |
| 285 const WindowTreeImpl* connection = GetWindowTree(); | 282 WindowTreeImpl* connection = GetWindowTree(); |
| 286 return connection ? connection->MapWindowIdFromClient(transport_window_id) | 283 if (!connection) |
| 287 : WindowIdFromTransportId(transport_window_id); | 284 return nullptr; |
| 285 return connection->GetWindowByClientId(ClientWindowId(transport_window_id)); |
| 288 } | 286 } |
| 289 | 287 |
| 290 void WindowTreeHostImpl::OnClientClosed() { | 288 void WindowTreeHostImpl::OnClientClosed() { |
| 291 // |display_manager_.reset()| destroys the display-manager first, and then | 289 // |display_manager_.reset()| destroys the display-manager first, and then |
| 292 // sets |display_manager_| to nullptr. However, destroying |display_manager_| | 290 // sets |display_manager_| to nullptr. However, destroying |display_manager_| |
| 293 // can destroy the corresponding WindowTreeHostConnection, and |this|. So | 291 // can destroy the corresponding WindowTreeHostConnection, and |this|. So |
| 294 // setting it to nullptr afterwards in reset() ends up writing on free'd | 292 // setting it to nullptr afterwards in reset() ends up writing on free'd |
| 295 // memory. So transfer over to a local scoped_ptr<> before destroying it. | 293 // memory. So transfer over to a local scoped_ptr<> before destroying it. |
| 296 scoped_ptr<DisplayManager> temp = std::move(display_manager_); | 294 scoped_ptr<DisplayManager> temp = std::move(display_manager_); |
| 297 } | 295 } |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 DispatchInputEventToWindowImpl(target, in_nonclient_area, std::move(event)); | 545 DispatchInputEventToWindowImpl(target, in_nonclient_area, std::move(event)); |
| 548 } | 546 } |
| 549 | 547 |
| 550 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { | 548 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { |
| 551 windows_needing_frame_destruction_.erase(window); | 549 windows_needing_frame_destruction_.erase(window); |
| 552 window->RemoveObserver(this); | 550 window->RemoveObserver(this); |
| 553 } | 551 } |
| 554 | 552 |
| 555 } // namespace ws | 553 } // namespace ws |
| 556 } // namespace mus | 554 } // namespace mus |
| OLD | NEW |