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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 if (windows_needing_frame_destruction_.count(window)) | 148 if (windows_needing_frame_destruction_.count(window)) |
149 return; | 149 return; |
150 windows_needing_frame_destruction_.insert(window); | 150 windows_needing_frame_destruction_.insert(window); |
151 window->AddObserver(this); | 151 window->AddObserver(this); |
152 } | 152 } |
153 | 153 |
154 const mojom::ViewportMetrics& WindowTreeHostImpl::GetViewportMetrics() const { | 154 const mojom::ViewportMetrics& WindowTreeHostImpl::GetViewportMetrics() const { |
155 return display_manager_->GetViewportMetrics(); | 155 return display_manager_->GetViewportMetrics(); |
156 } | 156 } |
157 | 157 |
158 void WindowTreeHostImpl::SetCapture(ServerWindow* window) { | |
159 ServerWindow* capture_window = event_dispatcher_.capture_window(); | |
sky
2016/01/22 00:55:00
Early out if window == capture_window?
jonross
2016/01/26 18:38:50
Done.
| |
160 if (capture_window) { | |
161 WindowTreeImpl* connection = | |
162 connection_manager_->GetConnection(capture_window->id().connection_id); | |
163 if (connection) | |
164 connection->ProcessLostCapture(capture_window); | |
jonross
2016/01/26 18:38:50
With EventDispatcher now calling EventDispatcherDe
| |
165 } | |
166 event_dispatcher_.SetCaptureWindow(window); | |
167 if (window) | |
168 display_manager_->SetCapture(); | |
169 else | |
170 display_manager_->ReleaseCapture(); | |
171 } | |
172 | |
158 void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) { | 173 void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) { |
159 ServerWindow* old_focused_window = focus_controller_->GetFocusedWindow(); | 174 ServerWindow* old_focused_window = focus_controller_->GetFocusedWindow(); |
160 if (old_focused_window == new_focused_window) | 175 if (old_focused_window == new_focused_window) |
161 return; | 176 return; |
162 DCHECK(root_window()->Contains(new_focused_window)); | 177 DCHECK(root_window()->Contains(new_focused_window)); |
163 focus_controller_->SetFocusedWindow(new_focused_window); | 178 focus_controller_->SetFocusedWindow(new_focused_window); |
164 } | 179 } |
165 | 180 |
166 ServerWindow* WindowTreeHostImpl::GetFocusedWindow() { | 181 ServerWindow* WindowTreeHostImpl::GetFocusedWindow() { |
167 return focus_controller_->GetFocusedWindow(); | 182 return focus_controller_->GetFocusedWindow(); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 event_queue_.back()->event = CoalesceEvents( | 393 event_queue_.back()->event = CoalesceEvents( |
379 std::move(event_queue_.back()->event), std::move(mojo_event)); | 394 std::move(event_queue_.back()->event), std::move(mojo_event)); |
380 return; | 395 return; |
381 } | 396 } |
382 QueueEvent(std::move(mojo_event), nullptr); | 397 QueueEvent(std::move(mojo_event), nullptr); |
383 return; | 398 return; |
384 } | 399 } |
385 event_dispatcher_.ProcessEvent(std::move(mojo_event)); | 400 event_dispatcher_.ProcessEvent(std::move(mojo_event)); |
386 } | 401 } |
387 | 402 |
403 void WindowTreeHostImpl::OnLostCapture() { | |
404 SetCapture(nullptr); | |
405 } | |
406 | |
388 void WindowTreeHostImpl::OnDisplayClosed() { | 407 void WindowTreeHostImpl::OnDisplayClosed() { |
389 if (delegate_) | 408 if (delegate_) |
390 delegate_->OnDisplayClosed(); | 409 delegate_->OnDisplayClosed(); |
391 } | 410 } |
392 | 411 |
393 void WindowTreeHostImpl::OnViewportMetricsChanged( | 412 void WindowTreeHostImpl::OnViewportMetricsChanged( |
394 const mojom::ViewportMetrics& old_metrics, | 413 const mojom::ViewportMetrics& old_metrics, |
395 const mojom::ViewportMetrics& new_metrics) { | 414 const mojom::ViewportMetrics& new_metrics) { |
396 if (!root_) { | 415 if (!root_) { |
397 root_.reset(connection_manager_->CreateServerWindow( | 416 root_.reset(connection_manager_->CreateServerWindow( |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 | 528 |
510 void WindowTreeHostImpl::SetFocusedWindowFromEventDispatcher( | 529 void WindowTreeHostImpl::SetFocusedWindowFromEventDispatcher( |
511 ServerWindow* new_focused_window) { | 530 ServerWindow* new_focused_window) { |
512 SetFocusedWindow(new_focused_window); | 531 SetFocusedWindow(new_focused_window); |
513 } | 532 } |
514 | 533 |
515 ServerWindow* WindowTreeHostImpl::GetFocusedWindowForEventDispatcher() { | 534 ServerWindow* WindowTreeHostImpl::GetFocusedWindowForEventDispatcher() { |
516 return GetFocusedWindow(); | 535 return GetFocusedWindow(); |
517 } | 536 } |
518 | 537 |
538 void WindowTreeHostImpl::OnLostCapture(ServerWindow* window) { | |
539 DCHECK(window); | |
540 WindowTreeImpl* connection = | |
541 connection_manager_->GetConnection(window->id().connection_id); | |
542 if (connection) | |
543 connection->ProcessLostCapture(window); | |
544 } | |
545 | |
519 void WindowTreeHostImpl::DispatchInputEventToWindow(ServerWindow* target, | 546 void WindowTreeHostImpl::DispatchInputEventToWindow(ServerWindow* target, |
520 bool in_nonclient_area, | 547 bool in_nonclient_area, |
521 mojom::EventPtr event) { | 548 mojom::EventPtr event) { |
522 if (event_ack_timer_.IsRunning()) { | 549 if (event_ack_timer_.IsRunning()) { |
523 scoped_ptr<ProcessedEventTarget> processed_event_target( | 550 scoped_ptr<ProcessedEventTarget> processed_event_target( |
524 new ProcessedEventTarget(target, in_nonclient_area)); | 551 new ProcessedEventTarget(target, in_nonclient_area)); |
525 QueueEvent(std::move(event), std::move(processed_event_target)); | 552 QueueEvent(std::move(event), std::move(processed_event_target)); |
526 return; | 553 return; |
527 } | 554 } |
528 | 555 |
529 DispatchInputEventToWindowImpl(target, in_nonclient_area, std::move(event)); | 556 DispatchInputEventToWindowImpl(target, in_nonclient_area, std::move(event)); |
530 } | 557 } |
531 | 558 |
532 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { | 559 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { |
533 windows_needing_frame_destruction_.erase(window); | 560 windows_needing_frame_destruction_.erase(window); |
534 window->RemoveObserver(this); | 561 window->RemoveObserver(this); |
535 } | 562 } |
536 | 563 |
537 } // namespace ws | 564 } // namespace ws |
538 } // namespace mus | 565 } // namespace mus |
OLD | NEW |