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

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

Issue 1868783003: Makes SetFocus() notify callback correctly on failure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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') | no next file » | 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 return false; 276 return false;
277 277
278 Display* display = GetDisplay(window); 278 Display* display = GetDisplay(window);
279 if (window && (!display || !window->can_focus() || !window->IsDrawn())) 279 if (window && (!display || !window->can_focus() || !window->IsDrawn()))
280 return false; 280 return false;
281 281
282 if (!access_policy_->CanSetFocus(window)) 282 if (!access_policy_->CanSetFocus(window))
283 return false; 283 return false;
284 284
285 Operation op(this, window_server_, OperationType::SET_FOCUS); 285 Operation op(this, window_server_, OperationType::SET_FOCUS);
286 window_server_->SetFocusedWindow(window); 286 return window_server_->SetFocusedWindow(window);
287 return true;
288 } 287 }
289 288
290 bool WindowTree::Embed(const ClientWindowId& window_id, 289 bool WindowTree::Embed(const ClientWindowId& window_id,
291 mojom::WindowTreeClientPtr client) { 290 mojom::WindowTreeClientPtr client) {
292 if (!client || !CanEmbed(window_id)) 291 if (!client || !CanEmbed(window_id))
293 return false; 292 return false;
294 ServerWindow* window = GetWindowByClientId(window_id); 293 ServerWindow* window = GetWindowByClientId(window_id);
295 PrepareForEmbed(window); 294 PrepareForEmbed(window);
296 // When embedding we don't know the user id of where the TreeClient came 295 // When embedding we don't know the user id of where the TreeClient came
297 // from. Use an invalid id, which limits what the client is able to do. 296 // from. Use an invalid id, which limits what the client is able to do.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 client_id_to_window_id_map_[waiting_for_top_level_window_info 339 client_id_to_window_id_map_[waiting_for_top_level_window_info
341 ->client_window_id] = window->id(); 340 ->client_window_id] = window->id();
342 window_id_to_client_id_map_[window->id()] = 341 window_id_to_client_id_map_[window->id()] =
343 waiting_for_top_level_window_info->client_window_id; 342 waiting_for_top_level_window_info->client_window_id;
344 roots_.insert(window); 343 roots_.insert(window);
345 const bool drawn = window->parent() && window->parent()->IsDrawn(); 344 const bool drawn = window->parent() && window->parent()->IsDrawn();
346 client()->OnTopLevelCreated(client_change_id, WindowToWindowData(window), 345 client()->OnTopLevelCreated(client_change_id, WindowToWindowData(window),
347 drawn); 346 drawn);
348 } 347 }
349 348
349 void WindowTree::AddActivationParent(const ClientWindowId& window_id) {
350 Display* host = GetDisplayForWindowManager();
351 if (!host)
352 return;
353 ServerWindow* window = GetWindowByClientId(window_id);
354 if (window)
355 host->AddActivationParent(window);
356 }
357
350 void WindowTree::OnChangeCompleted(uint32_t change_id, bool success) { 358 void WindowTree::OnChangeCompleted(uint32_t change_id, bool success) {
351 client()->OnChangeCompleted(change_id, success); 359 client()->OnChangeCompleted(change_id, success);
352 } 360 }
353 361
354 void WindowTree::OnAccelerator(uint32_t accelerator_id, 362 void WindowTree::OnAccelerator(uint32_t accelerator_id,
355 const ui::Event& event) { 363 const ui::Event& event) {
356 DCHECK(window_manager_internal_); 364 DCHECK(window_manager_internal_);
357 window_manager_internal_->OnAccelerator(accelerator_id, 365 window_manager_internal_->OnAccelerator(accelerator_id,
358 mojom::Event::From(event)); 366 mojom::Event::From(event));
359 } 367 }
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 wms->event_dispatcher()->AddAccelerator(id, std::move(event_matcher)); 1283 wms->event_dispatcher()->AddAccelerator(id, std::move(event_matcher));
1276 callback.Run(success); 1284 callback.Run(success);
1277 } 1285 }
1278 1286
1279 void WindowTree::RemoveAccelerator(uint32_t id) { 1287 void WindowTree::RemoveAccelerator(uint32_t id) {
1280 WindowManagerState* wms = GetWindowManagerStateForWindowManager(); 1288 WindowManagerState* wms = GetWindowManagerStateForWindowManager();
1281 wms->event_dispatcher()->RemoveAccelerator(id); 1289 wms->event_dispatcher()->RemoveAccelerator(id);
1282 } 1290 }
1283 1291
1284 void WindowTree::AddActivationParent(Id transport_window_id) { 1292 void WindowTree::AddActivationParent(Id transport_window_id) {
1285 Display* host = GetDisplayForWindowManager(); 1293 AddActivationParent(ClientWindowId(transport_window_id));
1286 if (!host)
1287 return;
1288 ServerWindow* window =
1289 GetWindowByClientId(ClientWindowId(transport_window_id));
1290 if (window)
1291 host->AddActivationParent(window);
1292 } 1294 }
1293 1295
1294 void WindowTree::RemoveActivationParent(Id transport_window_id) { 1296 void WindowTree::RemoveActivationParent(Id transport_window_id) {
1295 Display* host = GetDisplayForWindowManager(); 1297 Display* host = GetDisplayForWindowManager();
1296 if (!host) 1298 if (!host)
1297 return; 1299 return;
1298 ServerWindow* window = 1300 ServerWindow* window =
1299 GetWindowByClientId(ClientWindowId(transport_window_id)); 1301 GetWindowByClientId(ClientWindowId(transport_window_id));
1300 if (window) 1302 if (window)
1301 host->RemoveActivationParent(window); 1303 host->RemoveActivationParent(window);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 } 1375 }
1374 1376
1375 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( 1377 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy(
1376 const ServerWindow* window) const { 1378 const ServerWindow* window) const {
1377 WindowTree* tree = window_server_->GetTreeWithRoot(window); 1379 WindowTree* tree = window_server_->GetTreeWithRoot(window);
1378 return tree && tree != this; 1380 return tree && tree != this;
1379 } 1381 }
1380 1382
1381 } // namespace ws 1383 } // namespace ws
1382 } // namespace mus 1384 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_tree.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698