Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: components/mus/ws/window_tree_impl.cc

Issue 1605773004: mus: Implement Window Server Capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_impl.h" 5 #include "components/mus/ws/window_tree_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 if (!host || !host->GetWindowTree() || 583 if (!host || !host->GetWindowTree() ||
584 !host->GetWindowTree()->window_manager_internal_) { 584 !host->GetWindowTree()->window_manager_internal_) {
585 return false; 585 return false;
586 } 586 }
587 587
588 // Requests coming from the WM should not be routed through the WM again. 588 // Requests coming from the WM should not be routed through the WM again.
589 const bool is_wm = host->GetWindowTree() == this; 589 const bool is_wm = host->GetWindowTree() == this;
590 return is_wm ? false : true; 590 return is_wm ? false : true;
591 } 591 }
592 592
593 void WindowTreeImpl::ProcessLostCapture(const ServerWindow* old_capture_window,
594 bool originated_change) {
595 if ((originated_change &&
596 connection_manager_->current_operation_type() ==
597 OperationType::RELEASE_CAPTURE) ||
598 !IsWindowKnown(old_capture_window)) {
599 return;
600 }
601 client()->OnLostCapture(WindowIdToTransportId(old_capture_window->id()));
602 }
603
593 ClientWindowId WindowTreeImpl::ClientWindowIdForWindow( 604 ClientWindowId WindowTreeImpl::ClientWindowIdForWindow(
594 const ServerWindow* window) const { 605 const ServerWindow* window) const {
595 auto iter = window_id_to_client_id_map_.find(window->id()); 606 auto iter = window_id_to_client_id_map_.find(window->id());
596 DCHECK(iter != window_id_to_client_id_map_.end()); 607 DCHECK(iter != window_id_to_client_id_map_.end());
597 return iter->second; 608 return iter->second;
598 } 609 }
599 610
600 bool WindowTreeImpl::IsValidIdForNewWindow(const ClientWindowId& id) const { 611 bool WindowTreeImpl::IsValidIdForNewWindow(const ClientWindowId& id) const {
601 if (is_embed_root_ && WindowIdFromTransportId(id.id).connection_id != id_) { 612 if (is_embed_root_ && WindowIdFromTransportId(id.id).connection_id != id_) {
602 // Embed roots see windows created from other connections. If they don't 613 // Embed roots see windows created from other connections. If they don't
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 } 982 }
972 983
973 void WindowTreeImpl::GetWindowTree( 984 void WindowTreeImpl::GetWindowTree(
974 Id window_id, 985 Id window_id,
975 const Callback<void(Array<mojom::WindowDataPtr>)>& callback) { 986 const Callback<void(Array<mojom::WindowDataPtr>)>& callback) {
976 std::vector<const ServerWindow*> windows( 987 std::vector<const ServerWindow*> windows(
977 GetWindowTree(ClientWindowId(window_id))); 988 GetWindowTree(ClientWindowId(window_id)));
978 callback.Run(WindowsToWindowDatas(windows)); 989 callback.Run(WindowsToWindowDatas(windows));
979 } 990 }
980 991
992 void WindowTreeImpl::SetCapture(uint32_t change_id, Id window_id) {
993 ServerWindow* window = GetWindow(WindowIdFromTransportId(window_id));
sky 2016/01/29 20:47:00 Sorry, I've changed things around. You want: wind
jonross 2016/02/01 18:52:22 Done.
994 WindowTreeHostImpl* host = GetHost(window);
995 ServerWindow* current_capture_window =
996 host ? host->GetCaptureWindow() : nullptr;
997 bool success = window && access_policy_->CanSetCapture(window) && host &&
998 (!current_capture_window ||
999 access_policy_->CanSetCapture(current_capture_window)) &&
sky 2016/01/29 20:47:00 Can the condition in () ever hit? Why do we need i
jonross 2016/02/01 18:52:22 Yes this can be hit. When a window tree has been
1000 event_ack_id_;
1001 if (success) {
1002 Operation op(this, connection_manager_, OperationType::SET_CAPTURE);
1003 host->SetCapture(window, !HasRoot(window));
1004 }
1005 client_->OnChangeCompleted(change_id, success);
1006 }
1007
1008 void WindowTreeImpl::ReleaseCapture(uint32_t change_id, Id window_id) {
1009 ServerWindow* window = GetWindow(WindowIdFromTransportId(window_id));
sky 2016/01/29 20:47:00 Same comment about ids.
jonross 2016/02/01 18:52:22 Done.
1010 WindowTreeHostImpl* host = GetHost(window);
1011 ServerWindow* capture_window = host ? host->GetCaptureWindow() : nullptr;
1012 bool success = window && host &&
1013 access_policy_->CanSetCapture(capture_window) &&
1014 window == capture_window;
1015 if (success) {
1016 Operation op(this, connection_manager_, OperationType::RELEASE_CAPTURE);
1017 host->SetCapture(nullptr, false);
1018 }
1019 client_->OnChangeCompleted(change_id, success);
1020 }
1021
981 void WindowTreeImpl::SetWindowBounds(uint32_t change_id, 1022 void WindowTreeImpl::SetWindowBounds(uint32_t change_id,
982 Id window_id, 1023 Id window_id,
983 mojo::RectPtr bounds) { 1024 mojo::RectPtr bounds) {
984 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1025 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
985 if (window && ShouldRouteToWindowManager(window)) { 1026 if (window && ShouldRouteToWindowManager(window)) {
986 const uint32_t wm_change_id = 1027 const uint32_t wm_change_id =
987 connection_manager_->GenerateWindowManagerChangeId(this, change_id); 1028 connection_manager_->GenerateWindowManagerChangeId(this, change_id);
988 // |window_id| may be a client id, use the id from the window to ensure 1029 // |window_id| may be a client id, use the id from the window to ensure
989 // the windowmanager doesn't get an id it doesn't know about. 1030 // the windowmanager doesn't get an id it doesn't know about.
990 WindowTreeImpl* wm_window_tree = GetHost(window)->GetWindowTree(); 1031 WindowTreeImpl* wm_window_tree = GetHost(window)->GetWindowTree();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 host->SetImeVisibility(window, visible); 1118 host->SetImeVisibility(window, visible);
1078 } 1119 }
1079 } 1120 }
1080 1121
1081 void WindowTreeImpl::OnWindowInputEventAck(uint32_t event_id) { 1122 void WindowTreeImpl::OnWindowInputEventAck(uint32_t event_id) {
1082 if (event_ack_id_ == 0 || event_id != event_ack_id_) { 1123 if (event_ack_id_ == 0 || event_id != event_ack_id_) {
1083 // TODO(sad): Something bad happened. Kill the client? 1124 // TODO(sad): Something bad happened. Kill the client?
1084 NOTIMPLEMENTED() << "Wrong event acked."; 1125 NOTIMPLEMENTED() << "Wrong event acked.";
1085 } 1126 }
1086 event_ack_id_ = 0; 1127 event_ack_id_ = 0;
1087
1088 WindowTreeHostImpl* event_source_host = event_source_host_; 1128 WindowTreeHostImpl* event_source_host = event_source_host_;
1089 event_source_host_ = nullptr; 1129 event_source_host_ = nullptr;
1090 if (event_source_host) 1130 if (event_source_host)
1091 event_source_host->OnEventAck(this); 1131 event_source_host->OnEventAck(this);
1092 1132
1093 if (!event_queue_.empty()) { 1133 if (!event_queue_.empty()) {
1094 DCHECK(!event_ack_id_); 1134 DCHECK(!event_ack_id_);
1095 ServerWindow* target = nullptr; 1135 ServerWindow* target = nullptr;
1096 mojom::EventPtr event; 1136 mojom::EventPtr event;
1097 do { 1137 do {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 1289
1250 for (const auto* root : roots_) { 1290 for (const auto* root : roots_) {
1251 if (root->Contains(window)) 1291 if (root->Contains(window))
1252 return true; 1292 return true;
1253 } 1293 }
1254 return false; 1294 return false;
1255 } 1295 }
1256 1296
1257 } // namespace ws 1297 } // namespace ws
1258 } // namespace mus 1298 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698