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

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

Issue 1759523002: mus: Server-side implementation of modal windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SetAsModal -> SetModal + Other review comments addressed Created 4 years, 9 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
« no previous file with comments | « components/mus/ws/window_tree.h ('k') | components/mus/ws/window_tree_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h" 5 #include "components/mus/ws/window_tree.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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 bool WindowTree::SetCapture(const ClientWindowId& client_window_id) { 190 bool WindowTree::SetCapture(const ClientWindowId& client_window_id) {
191 ServerWindow* window = GetWindowByClientId(client_window_id); 191 ServerWindow* window = GetWindowByClientId(client_window_id);
192 WindowManagerState* wms = GetWindowManagerState(window); 192 WindowManagerState* wms = GetWindowManagerState(window);
193 ServerWindow* current_capture_window = wms ? wms->capture_window() : nullptr; 193 ServerWindow* current_capture_window = wms ? wms->capture_window() : nullptr;
194 if (window && wms && wms->IsActive() && 194 if (window && wms && wms->IsActive() &&
195 access_policy_->CanSetCapture(window) && 195 access_policy_->CanSetCapture(window) &&
196 (!current_capture_window || 196 (!current_capture_window ||
197 access_policy_->CanSetCapture(current_capture_window)) && 197 access_policy_->CanSetCapture(current_capture_window)) &&
198 event_ack_id_) { 198 event_ack_id_) {
199 wms->SetCapture(window, !HasRoot(window)); 199 return wms->SetCapture(window, !HasRoot(window));
200 return true;
201 } 200 }
202 return false; 201 return false;
203 } 202 }
204 203
205 bool WindowTree::NewWindow( 204 bool WindowTree::NewWindow(
206 const ClientWindowId& client_window_id, 205 const ClientWindowId& client_window_id,
207 const std::map<std::string, std::vector<uint8_t>>& properties) { 206 const std::map<std::string, std::vector<uint8_t>>& properties) {
208 if (!IsValidIdForNewWindow(client_window_id)) 207 if (!IsValidIdForNewWindow(client_window_id))
209 return false; 208 return false;
210 const WindowId window_id = GenerateNewWindowId(); 209 const WindowId window_id = GenerateNewWindowId();
(...skipping 26 matching lines...) Expand all
237 if (window && transient_window && !transient_window->Contains(window) && 236 if (window && transient_window && !transient_window->Contains(window) &&
238 access_policy_->CanAddTransientWindow(window, transient_window)) { 237 access_policy_->CanAddTransientWindow(window, transient_window)) {
239 Operation op(this, connection_manager_, 238 Operation op(this, connection_manager_,
240 OperationType::ADD_TRANSIENT_WINDOW); 239 OperationType::ADD_TRANSIENT_WINDOW);
241 window->AddTransientWindow(transient_window); 240 window->AddTransientWindow(transient_window);
242 return true; 241 return true;
243 } 242 }
244 return false; 243 return false;
245 } 244 }
246 245
246 bool WindowTree::SetModal(const ClientWindowId& window_id) {
247 ServerWindow* window = GetWindowByClientId(window_id);
248 if (window && access_policy_->CanSetModal(window)) {
249 window->SetModal();
250 WindowManagerState* wms = GetWindowManagerState(window);
251 if (wms)
252 wms->ReleaseCaptureBlockedByModalWindow(window);
253 return true;
254 }
255 return false;
256 }
257
247 std::vector<const ServerWindow*> WindowTree::GetWindowTree( 258 std::vector<const ServerWindow*> WindowTree::GetWindowTree(
248 const ClientWindowId& window_id) const { 259 const ClientWindowId& window_id) const {
249 const ServerWindow* window = GetWindowByClientId(window_id); 260 const ServerWindow* window = GetWindowByClientId(window_id);
250 std::vector<const ServerWindow*> windows; 261 std::vector<const ServerWindow*> windows;
251 if (window) 262 if (window)
252 GetWindowTreeImpl(window, &windows); 263 GetWindowTreeImpl(window, &windows);
253 return windows; 264 return windows;
254 } 265 }
255 266
256 bool WindowTree::SetWindowVisibility(const ClientWindowId& window_id, 267 bool WindowTree::SetWindowVisibility(const ClientWindowId& window_id,
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 access_policy_->CanRemoveTransientWindowFromParent(transient_window)) { 1012 access_policy_->CanRemoveTransientWindowFromParent(transient_window)) {
1002 success = true; 1013 success = true;
1003 Operation op(this, connection_manager_, 1014 Operation op(this, connection_manager_,
1004 OperationType::REMOVE_TRANSIENT_WINDOW_FROM_PARENT); 1015 OperationType::REMOVE_TRANSIENT_WINDOW_FROM_PARENT);
1005 transient_window->transient_parent()->RemoveTransientWindow( 1016 transient_window->transient_parent()->RemoveTransientWindow(
1006 transient_window); 1017 transient_window);
1007 } 1018 }
1008 client()->OnChangeCompleted(change_id, success); 1019 client()->OnChangeCompleted(change_id, success);
1009 } 1020 }
1010 1021
1022 void WindowTree::SetModal(uint32_t change_id, Id window_id) {
1023 client()->OnChangeCompleted(change_id, SetModal(ClientWindowId(window_id)));
1024 }
1025
1011 void WindowTree::ReorderWindow(uint32_t change_id, 1026 void WindowTree::ReorderWindow(uint32_t change_id,
1012 Id window_id, 1027 Id window_id,
1013 Id relative_window_id, 1028 Id relative_window_id,
1014 mojom::OrderDirection direction) { 1029 mojom::OrderDirection direction) {
1015 bool success = false; 1030 bool success = false;
1016 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1031 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1017 ServerWindow* relative_window = 1032 ServerWindow* relative_window =
1018 GetWindowByClientId(ClientWindowId(relative_window_id)); 1033 GetWindowByClientId(ClientWindowId(relative_window_id));
1019 if (CanReorderWindow(window, relative_window, direction)) { 1034 if (CanReorderWindow(window, relative_window, direction)) {
1020 success = true; 1035 success = true;
(...skipping 20 matching lines...) Expand all
1041 void WindowTree::ReleaseCapture(uint32_t change_id, Id window_id) { 1056 void WindowTree::ReleaseCapture(uint32_t change_id, Id window_id) {
1042 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1057 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1043 WindowManagerState* wms = GetWindowManagerState(window); 1058 WindowManagerState* wms = GetWindowManagerState(window);
1044 ServerWindow* current_capture_window = wms ? wms->capture_window() : nullptr; 1059 ServerWindow* current_capture_window = wms ? wms->capture_window() : nullptr;
1045 bool success = window && wms && wms->IsActive() && 1060 bool success = window && wms && wms->IsActive() &&
1046 (!current_capture_window || 1061 (!current_capture_window ||
1047 access_policy_->CanSetCapture(current_capture_window)) && 1062 access_policy_->CanSetCapture(current_capture_window)) &&
1048 window == current_capture_window; 1063 window == current_capture_window;
1049 if (success) { 1064 if (success) {
1050 Operation op(this, connection_manager_, OperationType::RELEASE_CAPTURE); 1065 Operation op(this, connection_manager_, OperationType::RELEASE_CAPTURE);
1051 wms->SetCapture(nullptr, false); 1066 success = wms->SetCapture(nullptr, false);
1052 } 1067 }
1053 client()->OnChangeCompleted(change_id, success); 1068 client()->OnChangeCompleted(change_id, success);
1054 } 1069 }
1055 1070
1056 void WindowTree::SetWindowBounds(uint32_t change_id, 1071 void WindowTree::SetWindowBounds(uint32_t change_id,
1057 Id window_id, 1072 Id window_id,
1058 mojo::RectPtr bounds) { 1073 mojo::RectPtr bounds) {
1059 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1074 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1060 if (window && ShouldRouteToWindowManager(window)) { 1075 if (window && ShouldRouteToWindowManager(window)) {
1061 const uint32_t wm_change_id = 1076 const uint32_t wm_change_id =
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 1394
1380 for (const auto* root : roots_) { 1395 for (const auto* root : roots_) {
1381 if (root->Contains(window)) 1396 if (root->Contains(window))
1382 return true; 1397 return true;
1383 } 1398 }
1384 return false; 1399 return false;
1385 } 1400 }
1386 1401
1387 } // namespace ws 1402 } // namespace ws
1388 } // namespace mus 1403 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_tree.h ('k') | components/mus/ws/window_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698