Index: components/mus/ws/window_tree_host_impl.cc |
diff --git a/components/mus/ws/window_tree_host_impl.cc b/components/mus/ws/window_tree_host_impl.cc |
index 6f84e0e7ce9a551682956f3cc26a1a966f61c071..a14b962244b2b9a527deee59329f782778975b9f 100644 |
--- a/components/mus/ws/window_tree_host_impl.cc |
+++ b/components/mus/ws/window_tree_host_impl.cc |
@@ -83,6 +83,21 @@ const mojom::ViewportMetrics& WindowTreeHostImpl::GetViewportMetrics() const { |
return display_manager_->GetViewportMetrics(); |
} |
+void WindowTreeHostImpl::SetCapture(ServerWindow* window) { |
+ ServerWindow* capture_window = event_dispatcher_.capture_window(); |
+ if (capture_window) { |
+ WindowTreeImpl* connection = |
+ connection_manager_->GetConnection(capture_window->id().connection_id); |
+ if (connection) |
+ connection->ProcessLostCapture(capture_window); |
+ } |
+ event_dispatcher_.SetCaptureWindow(window); |
+ if (window) |
+ display_manager_->SetCapture(); |
+ else |
+ display_manager_->ReleaseCapture(); |
+} |
+ |
void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) { |
ServerWindow* old_focused_window = focus_controller_->GetFocusedWindow(); |
if (old_focused_window == new_focused_window) |
@@ -150,6 +165,10 @@ void WindowTreeHostImpl::OnEvent(mojom::EventPtr event) { |
event_dispatcher_.OnEvent(event.Pass()); |
} |
+void WindowTreeHostImpl::OnLostCapture() { |
+ SetCapture(nullptr); |
+} |
+ |
void WindowTreeHostImpl::OnDisplayClosed() { |
if (delegate_) |
delegate_->OnDisplayClosed(); |
@@ -261,6 +280,14 @@ ServerWindow* WindowTreeHostImpl::GetFocusedWindowForEventDispatcher() { |
return GetFocusedWindow(); |
} |
+void WindowTreeHostImpl::OnLostCapture(ServerWindow* window) { |
+ DCHECK(window); |
+ WindowTreeImpl* connection = |
+ connection_manager_->GetConnection(window->id().connection_id); |
+ if (connection) |
+ connection->ProcessLostCapture(window); |
+} |
+ |
void WindowTreeHostImpl::DispatchInputEventToWindow(ServerWindow* target, |
bool in_nonclient_area, |
mojom::EventPtr event) { |