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