| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 if (windows_needing_frame_destruction_.count(window)) | 160 if (windows_needing_frame_destruction_.count(window)) |
| 161 return; | 161 return; |
| 162 windows_needing_frame_destruction_.insert(window); | 162 windows_needing_frame_destruction_.insert(window); |
| 163 window->AddObserver(this); | 163 window->AddObserver(this); |
| 164 } | 164 } |
| 165 | 165 |
| 166 const mojom::ViewportMetrics& WindowTreeHostImpl::GetViewportMetrics() const { | 166 const mojom::ViewportMetrics& WindowTreeHostImpl::GetViewportMetrics() const { |
| 167 return display_manager_->GetViewportMetrics(); | 167 return display_manager_->GetViewportMetrics(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void WindowTreeHostImpl::SetCapture(ServerWindow* window, |
| 171 bool in_nonclient_area) { |
| 172 ServerWindow* capture_window = event_dispatcher_.capture_window(); |
| 173 if (capture_window == window) |
| 174 return; |
| 175 event_dispatcher_.SetCaptureWindow(window, in_nonclient_area); |
| 176 if (window) |
| 177 display_manager_->SetCapture(); |
| 178 else |
| 179 display_manager_->ReleaseCapture(); |
| 180 } |
| 181 |
| 170 mojom::Rotation WindowTreeHostImpl::GetRotation() const { | 182 mojom::Rotation WindowTreeHostImpl::GetRotation() const { |
| 171 return display_manager_->GetRotation(); | 183 return display_manager_->GetRotation(); |
| 172 } | 184 } |
| 173 | 185 |
| 174 void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) { | 186 void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) { |
| 175 ServerWindow* old_focused_window = focus_controller_->GetFocusedWindow(); | 187 ServerWindow* old_focused_window = focus_controller_->GetFocusedWindow(); |
| 176 if (old_focused_window == new_focused_window) | 188 if (old_focused_window == new_focused_window) |
| 177 return; | 189 return; |
| 178 DCHECK(root_window()->Contains(new_focused_window)); | 190 DCHECK(root_window()->Contains(new_focused_window)); |
| 179 focus_controller_->SetFocusedWindow(new_focused_window); | 191 focus_controller_->SetFocusedWindow(new_focused_window); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 void WindowTreeHostImpl::DispatchInputEventToWindowImpl(ServerWindow* target, | 353 void WindowTreeHostImpl::DispatchInputEventToWindowImpl(ServerWindow* target, |
| 342 bool in_nonclient_area, | 354 bool in_nonclient_area, |
| 343 mojom::EventPtr event) { | 355 mojom::EventPtr event) { |
| 344 if (event->pointer_data && | 356 if (event->pointer_data && |
| 345 event->pointer_data->kind == mojom::PointerKind::MOUSE) { | 357 event->pointer_data->kind == mojom::PointerKind::MOUSE) { |
| 346 DCHECK(event_dispatcher_.mouse_cursor_source_window()); | 358 DCHECK(event_dispatcher_.mouse_cursor_source_window()); |
| 347 UpdateNativeCursor( | 359 UpdateNativeCursor( |
| 348 event_dispatcher_.mouse_cursor_source_window()->cursor()); | 360 event_dispatcher_.mouse_cursor_source_window()->cursor()); |
| 349 } | 361 } |
| 350 | 362 |
| 351 // If the event is in the non-client area the event goes to the owner of | |
| 352 // the window. Otherwise if the window is an embed root, forward to the | |
| 353 // embedded window. | 363 // embedded window. |
| 354 WindowTreeImpl* connection = | 364 WindowTreeImpl* connection = |
| 355 in_nonclient_area | 365 in_nonclient_area |
| 356 ? connection_manager_->GetConnection(target->id().connection_id) | 366 ? connection_manager_->GetConnection(target->id().connection_id) |
| 357 : connection_manager_->GetConnectionWithRoot(target); | 367 : connection_manager_->GetConnectionWithRoot(target); |
| 358 if (!connection) { | 368 if (!connection) { |
| 359 DCHECK(!in_nonclient_area); | 369 DCHECK(!in_nonclient_area); |
| 360 connection = connection_manager_->GetConnection(target->id().connection_id); | 370 connection = connection_manager_->GetConnection(target->id().connection_id); |
| 361 } | 371 } |
| 362 | 372 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 392 event_queue_.back()->event = CoalesceEvents( | 402 event_queue_.back()->event = CoalesceEvents( |
| 393 std::move(event_queue_.back()->event), std::move(mojo_event)); | 403 std::move(event_queue_.back()->event), std::move(mojo_event)); |
| 394 return; | 404 return; |
| 395 } | 405 } |
| 396 QueueEvent(std::move(mojo_event), nullptr); | 406 QueueEvent(std::move(mojo_event), nullptr); |
| 397 return; | 407 return; |
| 398 } | 408 } |
| 399 event_dispatcher_.ProcessEvent(std::move(mojo_event)); | 409 event_dispatcher_.ProcessEvent(std::move(mojo_event)); |
| 400 } | 410 } |
| 401 | 411 |
| 412 void WindowTreeHostImpl::OnLostCapture() { |
| 413 SetCapture(nullptr, false); |
| 414 } |
| 415 |
| 402 void WindowTreeHostImpl::OnDisplayClosed() { | 416 void WindowTreeHostImpl::OnDisplayClosed() { |
| 403 if (delegate_) | 417 if (delegate_) |
| 404 delegate_->OnDisplayClosed(); | 418 delegate_->OnDisplayClosed(); |
| 405 } | 419 } |
| 406 | 420 |
| 407 void WindowTreeHostImpl::OnViewportMetricsChanged( | 421 void WindowTreeHostImpl::OnViewportMetricsChanged( |
| 408 const mojom::ViewportMetrics& old_metrics, | 422 const mojom::ViewportMetrics& old_metrics, |
| 409 const mojom::ViewportMetrics& new_metrics) { | 423 const mojom::ViewportMetrics& new_metrics) { |
| 410 if (!root_) { | 424 if (!root_) { |
| 411 root_.reset(connection_manager_->CreateServerWindow( | 425 root_.reset(connection_manager_->CreateServerWindow( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 537 |
| 524 void WindowTreeHostImpl::SetFocusedWindowFromEventDispatcher( | 538 void WindowTreeHostImpl::SetFocusedWindowFromEventDispatcher( |
| 525 ServerWindow* new_focused_window) { | 539 ServerWindow* new_focused_window) { |
| 526 SetFocusedWindow(new_focused_window); | 540 SetFocusedWindow(new_focused_window); |
| 527 } | 541 } |
| 528 | 542 |
| 529 ServerWindow* WindowTreeHostImpl::GetFocusedWindowForEventDispatcher() { | 543 ServerWindow* WindowTreeHostImpl::GetFocusedWindowForEventDispatcher() { |
| 530 return GetFocusedWindow(); | 544 return GetFocusedWindow(); |
| 531 } | 545 } |
| 532 | 546 |
| 547 void WindowTreeHostImpl::OnLostCapture(ServerWindow* window) { |
| 548 DCHECK(window); |
| 549 connection_manager_->ProcessLostCapture(window); |
| 550 } |
| 551 |
| 533 void WindowTreeHostImpl::DispatchInputEventToWindow(ServerWindow* target, | 552 void WindowTreeHostImpl::DispatchInputEventToWindow(ServerWindow* target, |
| 534 bool in_nonclient_area, | 553 bool in_nonclient_area, |
| 535 mojom::EventPtr event) { | 554 mojom::EventPtr event) { |
| 536 if (event_ack_timer_.IsRunning()) { | 555 if (event_ack_timer_.IsRunning()) { |
| 537 scoped_ptr<ProcessedEventTarget> processed_event_target( | 556 scoped_ptr<ProcessedEventTarget> processed_event_target( |
| 538 new ProcessedEventTarget(target, in_nonclient_area)); | 557 new ProcessedEventTarget(target, in_nonclient_area)); |
| 539 QueueEvent(std::move(event), std::move(processed_event_target)); | 558 QueueEvent(std::move(event), std::move(processed_event_target)); |
| 540 return; | 559 return; |
| 541 } | 560 } |
| 542 | 561 |
| 543 DispatchInputEventToWindowImpl(target, in_nonclient_area, std::move(event)); | 562 DispatchInputEventToWindowImpl(target, in_nonclient_area, std::move(event)); |
| 544 } | 563 } |
| 545 | 564 |
| 546 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { | 565 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { |
| 547 windows_needing_frame_destruction_.erase(window); | 566 windows_needing_frame_destruction_.erase(window); |
| 548 window->RemoveObserver(this); | 567 window->RemoveObserver(this); |
| 549 } | 568 } |
| 550 | 569 |
| 551 } // namespace ws | 570 } // namespace ws |
| 552 } // namespace mus | 571 } // namespace mus |
| OLD | NEW |