Index: components/mus/ws/window_tree_impl.cc |
diff --git a/components/mus/ws/window_tree_impl.cc b/components/mus/ws/window_tree_impl.cc |
index 4cdce9d6db16c866092bb502d92b33cf36e8e820..df73c46fbc683ac2ef8f7fb5b828a34bf57b2363 100644 |
--- a/components/mus/ws/window_tree_impl.cc |
+++ b/components/mus/ws/window_tree_impl.cc |
@@ -607,6 +607,17 @@ bool WindowTreeImpl::ShouldRouteToWindowManager( |
return is_wm ? false : true; |
} |
+void WindowTreeImpl::ProcessLostCapture(const ServerWindow* old_capture_window, |
+ bool originated_change) { |
+ if ((originated_change && |
+ connection_manager_->current_operation_type() == |
+ OperationType::RELEASE_CAPTURE) || |
+ !IsWindowKnown(old_capture_window)) { |
+ return; |
+ } |
+ client()->OnLostCapture(WindowIdToTransportId(old_capture_window->id())); |
+} |
+ |
ClientWindowId WindowTreeImpl::ClientWindowIdForWindow( |
const ServerWindow* window) const { |
auto iter = window_id_to_client_id_map_.find(window->id()); |
@@ -995,6 +1006,38 @@ void WindowTreeImpl::GetWindowTree( |
callback.Run(WindowsToWindowDatas(windows)); |
} |
+void WindowTreeImpl::SetCapture(uint32_t change_id, Id window_id) { |
+ ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
+ WindowTreeHostImpl* host = GetHost(window); |
+ ServerWindow* current_capture_window = |
+ host ? host->GetCaptureWindow() : nullptr; |
+ bool success = window && access_policy_->CanSetCapture(window) && host && |
+ (!current_capture_window || |
+ access_policy_->CanSetCapture(current_capture_window)) && |
+ event_ack_id_; |
+ if (success) { |
+ Operation op(this, connection_manager_, OperationType::SET_CAPTURE); |
+ host->SetCapture(window, !HasRoot(window)); |
+ } |
+ client_->OnChangeCompleted(change_id, success); |
+} |
+ |
+void WindowTreeImpl::ReleaseCapture(uint32_t change_id, Id window_id) { |
+ ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
+ WindowTreeHostImpl* host = GetHost(window); |
+ ServerWindow* current_capture_window = |
+ host ? host->GetCaptureWindow() : nullptr; |
+ bool success = window && host && |
+ (!current_capture_window || |
+ access_policy_->CanSetCapture(current_capture_window)) && |
+ window == current_capture_window; |
+ if (success) { |
+ Operation op(this, connection_manager_, OperationType::RELEASE_CAPTURE); |
+ host->SetCapture(nullptr, false); |
+ } |
+ client_->OnChangeCompleted(change_id, success); |
+} |
+ |
void WindowTreeImpl::SetWindowBounds(uint32_t change_id, |
Id window_id, |
mojo::RectPtr bounds) { |