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

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: Address Original Review Comments Created 4 years, 11 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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 if (!host || !host->GetWindowTree() || 543 if (!host || !host->GetWindowTree() ||
544 !host->GetWindowTree()->window_manager_internal_) { 544 !host->GetWindowTree()->window_manager_internal_) {
545 return false; 545 return false;
546 } 546 }
547 547
548 // Requests coming from the WM should not be routed through the WM again. 548 // Requests coming from the WM should not be routed through the WM again.
549 const bool is_wm = host->GetWindowTree() == this; 549 const bool is_wm = host->GetWindowTree() == this;
550 return is_wm ? false : true; 550 return is_wm ? false : true;
551 } 551 }
552 552
553 void WindowTreeImpl::ProcessLostCapture(
554 const ServerWindow* old_capture_window) {
555 client()->OnLostCapture(WindowIdToTransportId(old_capture_window->id()));
sky 2016/01/22 00:55:00 You should only send this if it was not initiated
jonross 2016/01/26 18:38:50 Done.
556 }
557
553 bool WindowTreeImpl::IsWindowKnown(const ServerWindow* window) const { 558 bool WindowTreeImpl::IsWindowKnown(const ServerWindow* window) const {
554 return known_windows_.count(WindowIdToTransportId(window->id())) > 0; 559 return known_windows_.count(WindowIdToTransportId(window->id())) > 0;
555 } 560 }
556 561
557 bool WindowTreeImpl::IsValidIdForNewWindow(const WindowId& id) const { 562 bool WindowTreeImpl::IsValidIdForNewWindow(const WindowId& id) const {
558 return id.connection_id == id_ && embed_to_real_id_map_.count(id) == 0 && 563 return id.connection_id == id_ && embed_to_real_id_map_.count(id) == 0 &&
559 window_map_.count(id.window_id) == 0; 564 window_map_.count(id.window_id) == 0;
560 } 565 }
561 566
562 bool WindowTreeImpl::CanReorderWindow(const ServerWindow* window, 567 bool WindowTreeImpl::CanReorderWindow(const ServerWindow* window,
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 } 908 }
904 909
905 void WindowTreeImpl::GetWindowTree( 910 void WindowTreeImpl::GetWindowTree(
906 Id window_id, 911 Id window_id,
907 const Callback<void(Array<mojom::WindowDataPtr>)>& callback) { 912 const Callback<void(Array<mojom::WindowDataPtr>)>& callback) {
908 std::vector<const ServerWindow*> windows( 913 std::vector<const ServerWindow*> windows(
909 GetWindowTree(MapWindowIdFromClient(window_id))); 914 GetWindowTree(MapWindowIdFromClient(window_id)));
910 callback.Run(WindowsToWindowDatas(windows)); 915 callback.Run(WindowsToWindowDatas(windows));
911 } 916 }
912 917
918 void WindowTreeImpl::SetCapture(uint32_t change_id, Id window_id) {
919 ServerWindow* window = GetWindow(WindowIdFromTransportId(window_id));
920 WindowTreeHostImpl* host = GetHost(window);
921 bool success = window && access_policy_->CanSetCapture(window) && host &&
922 access_policy_->CanSetCapture(host->GetCaptureWindow());
sky 2016/01/22 00:55:00 I am worried about letting any application capture
jonross 2016/01/22 20:31:28 I would also believe that touch events would also
sky 2016/01/22 22:15:37 Agreed.
jonross 2016/01/26 18:38:50 Yes: MenuController::Run eventually triggers
sky 2016/01/26 22:11:14 While the windows are different, it's the same cli
jonross 2016/01/26 22:35:15 It should always be the same client which has proc
jonross 2016/01/27 21:15:13 sadrul@ did raise a concern that we could have sit
923 if (success) {
924 Operation op(this, connection_manager_, OperationType::SET_CAPTURE);
925 host->SetCapture(window);
926 }
927 client_->OnChangeCompleted(change_id, success);
928 }
929
930 void WindowTreeImpl::ReleaseCapture(uint32_t change_id, Id window_id) {
931 ServerWindow* window = GetWindow(WindowIdFromTransportId(window_id));
932 WindowTreeHostImpl* host = GetHost(window);
933 bool success =
934 window && host && access_policy_->CanSetCapture(host->GetCaptureWindow());
935 if (success) {
936 Operation op(this, connection_manager_, OperationType::RELEASE_CAPTURE);
937 host->SetCapture(nullptr);
sky 2016/01/22 00:55:00 They way you have this now is set capture to null
jonross 2016/01/26 18:38:50 Done.
938 }
939 client_->OnChangeCompleted(change_id, success);
940 }
941
913 void WindowTreeImpl::SetWindowBounds(uint32_t change_id, 942 void WindowTreeImpl::SetWindowBounds(uint32_t change_id,
914 Id window_id, 943 Id window_id,
915 mojo::RectPtr bounds) { 944 mojo::RectPtr bounds) {
916 ServerWindow* window = GetWindow(MapWindowIdFromClient(window_id)); 945 ServerWindow* window = GetWindow(MapWindowIdFromClient(window_id));
917 if (window && ShouldRouteToWindowManager(window)) { 946 if (window && ShouldRouteToWindowManager(window)) {
918 const uint32_t wm_change_id = 947 const uint32_t wm_change_id =
919 connection_manager_->GenerateWindowManagerChangeId(this, change_id); 948 connection_manager_->GenerateWindowManagerChangeId(this, change_id);
920 // |window_id| may be a client id, use the id from the window to ensure 949 // |window_id| may be a client id, use the id from the window to ensure
921 // the windowmanager doesn't get an id it doesn't know about. 950 // the windowmanager doesn't get an id it doesn't know about.
922 GetHost(window)->GetWindowTree()->window_manager_internal_->WmSetBounds( 951 GetHost(window)->GetWindowTree()->window_manager_internal_->WmSetBounds(
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 1187
1159 for (const auto* root : roots_) { 1188 for (const auto* root : roots_) {
1160 if (root->Contains(window)) 1189 if (root->Contains(window))
1161 return true; 1190 return true;
1162 } 1191 }
1163 return false; 1192 return false;
1164 } 1193 }
1165 1194
1166 } // namespace ws 1195 } // namespace ws
1167 } // namespace mus 1196 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698