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 f9d145bfcbcde4ae756d28c4222967dc89842e70..4ffb76280516cff075acf14fff119a62bb0eb941 100644 |
--- a/components/mus/ws/window_tree_impl.cc |
+++ b/components/mus/ws/window_tree_impl.cc |
@@ -600,6 +600,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()); |
@@ -988,6 +999,36 @@ 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* capture_window = host ? host->GetCaptureWindow() : nullptr; |
+ bool success = window && host && |
+ access_policy_->CanSetCapture(capture_window) && |
+ window == 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) { |