| OLD | NEW |
| 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 "services/ui/ws/window_tree.h" | 5 #include "services/ui/ws/window_tree.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 return display_root->window_manager_state()->SetCapture(nullptr, | 377 return display_root->window_manager_state()->SetCapture(nullptr, |
| 378 kInvalidClientId); | 378 kInvalidClientId); |
| 379 } | 379 } |
| 380 | 380 |
| 381 bool WindowTree::NewWindow( | 381 bool WindowTree::NewWindow( |
| 382 const ClientWindowId& client_window_id, | 382 const ClientWindowId& client_window_id, |
| 383 const std::map<std::string, std::vector<uint8_t>>& properties) { | 383 const std::map<std::string, std::vector<uint8_t>>& properties) { |
| 384 DVLOG(3) << "new window client=" << id_ | 384 DVLOG(3) << "new window client=" << id_ |
| 385 << " window_id=" << client_window_id.id; | 385 << " window_id=" << client_window_id.id; |
| 386 if (!IsValidIdForNewWindow(client_window_id)) { | 386 if (!IsValidIdForNewWindow(client_window_id)) { |
| 387 DVLOG(1) << "new window failed, id is not valid for client"; | 387 DVLOG(1) << "NewWindow failed (id is not valid for client)"; |
| 388 return false; | 388 return false; |
| 389 } | 389 } |
| 390 const WindowId window_id = GenerateNewWindowId(); | 390 const WindowId window_id = GenerateNewWindowId(); |
| 391 DCHECK(!GetWindow(window_id)); | 391 DCHECK(!GetWindow(window_id)); |
| 392 ServerWindow* window = | 392 ServerWindow* window = |
| 393 window_server_->CreateServerWindow(window_id, properties); | 393 window_server_->CreateServerWindow(window_id, properties); |
| 394 created_window_map_[window_id] = window; | 394 created_window_map_[window_id] = window; |
| 395 client_id_to_window_id_map_[client_window_id] = window_id; | 395 client_id_to_window_id_map_[client_window_id] = window_id; |
| 396 window_id_to_client_id_map_[window_id] = client_window_id; | 396 window_id_to_client_id_map_[window_id] = client_window_id; |
| 397 return true; | 397 return true; |
| 398 } | 398 } |
| 399 | 399 |
| 400 bool WindowTree::AddWindow(const ClientWindowId& parent_id, | 400 bool WindowTree::AddWindow(const ClientWindowId& parent_id, |
| 401 const ClientWindowId& child_id) { | 401 const ClientWindowId& child_id) { |
| 402 ServerWindow* parent = GetWindowByClientId(parent_id); | 402 ServerWindow* parent = GetWindowByClientId(parent_id); |
| 403 ServerWindow* child = GetWindowByClientId(child_id); | 403 ServerWindow* child = GetWindowByClientId(child_id); |
| 404 DVLOG(3) << "add window client=" << id_ | 404 DVLOG(3) << "add window client=" << id_ |
| 405 << " client parent window_id=" << parent_id.id | 405 << " client parent window_id=" << parent_id.id |
| 406 << " global window_id=" | 406 << " global window_id=" |
| 407 << (parent ? WindowIdToTransportId(parent->id()) : 0) | 407 << (parent ? WindowIdToTransportId(parent->id()) : 0) |
| 408 << " client child window_id= " << child_id.id << " global window_id=" | 408 << " client child window_id= " << child_id.id << " global window_id=" |
| 409 << (child ? WindowIdToTransportId(child->id()) : 0); | 409 << (child ? WindowIdToTransportId(child->id()) : 0); |
| 410 if (!parent) { | 410 if (!parent) { |
| 411 DVLOG(1) << "add failed, no parent"; | 411 DVLOG(1) << "AddWindow failed (no parent)"; |
| 412 return false; | 412 return false; |
| 413 } | 413 } |
| 414 if (!child) { | 414 if (!child) { |
| 415 DVLOG(1) << "add failed, no child"; | 415 DVLOG(1) << "AddWindow failed (no child)"; |
| 416 return false; | 416 return false; |
| 417 } | 417 } |
| 418 if (child->parent() == parent) { | 418 if (child->parent() == parent) { |
| 419 DVLOG(1) << "add failed, already has parent"; | 419 DVLOG(1) << "AddWindow failed (already has parent)"; |
| 420 return false; | 420 return false; |
| 421 } | 421 } |
| 422 if (child->Contains(parent)) { | 422 if (child->Contains(parent)) { |
| 423 DVLOG(1) << "add failed, child contains parent"; | 423 DVLOG(1) << "AddWindow failed (child contains parent)"; |
| 424 return false; | 424 return false; |
| 425 } | 425 } |
| 426 if (!access_policy_->CanAddWindow(parent, child)) { | 426 if (!access_policy_->CanAddWindow(parent, child)) { |
| 427 DVLOG(1) << "add failed, access policy denied add"; | 427 DVLOG(1) << "AddWindow failed (access denied)"; |
| 428 return false; | 428 return false; |
| 429 } | 429 } |
| 430 Operation op(this, window_server_, OperationType::ADD_WINDOW); | 430 Operation op(this, window_server_, OperationType::ADD_WINDOW); |
| 431 parent->Add(child); | 431 parent->Add(child); |
| 432 return true; | 432 return true; |
| 433 } | 433 } |
| 434 | 434 |
| 435 bool WindowTree::AddTransientWindow(const ClientWindowId& window_id, | 435 bool WindowTree::AddTransientWindow(const ClientWindowId& window_id, |
| 436 const ClientWindowId& transient_window_id) { | 436 const ClientWindowId& transient_window_id) { |
| 437 ServerWindow* window = GetWindowByClientId(window_id); | 437 ServerWindow* window = GetWindowByClientId(window_id); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 return windows; | 532 return windows; |
| 533 } | 533 } |
| 534 | 534 |
| 535 bool WindowTree::SetWindowVisibility(const ClientWindowId& window_id, | 535 bool WindowTree::SetWindowVisibility(const ClientWindowId& window_id, |
| 536 bool visible) { | 536 bool visible) { |
| 537 ServerWindow* window = GetWindowByClientId(window_id); | 537 ServerWindow* window = GetWindowByClientId(window_id); |
| 538 DVLOG(3) << "SetWindowVisibility client=" << id_ | 538 DVLOG(3) << "SetWindowVisibility client=" << id_ |
| 539 << " client window_id= " << window_id.id << " global window_id=" | 539 << " client window_id= " << window_id.id << " global window_id=" |
| 540 << (window ? WindowIdToTransportId(window->id()) : 0); | 540 << (window ? WindowIdToTransportId(window->id()) : 0); |
| 541 if (!window) { | 541 if (!window) { |
| 542 DVLOG(1) << "SetWindowVisibility failure, no window"; | 542 DVLOG(1) << "SetWindowVisibility failed (no window)"; |
| 543 return false; | 543 return false; |
| 544 } | 544 } |
| 545 if (!access_policy_->CanChangeWindowVisibility(window)) { | 545 if (!access_policy_->CanChangeWindowVisibility(window)) { |
| 546 DVLOG(1) << "SetWindowVisibility failure, access policy denied change"; | 546 DVLOG(1) << "SetWindowVisibility failed (access policy denied change)"; |
| 547 return false; | 547 return false; |
| 548 } | 548 } |
| 549 if (window->visible() == visible) | 549 if (window->visible() == visible) |
| 550 return true; | 550 return true; |
| 551 Operation op(this, window_server_, OperationType::SET_WINDOW_VISIBILITY); | 551 Operation op(this, window_server_, OperationType::SET_WINDOW_VISIBILITY); |
| 552 window->SetVisible(visible); | 552 window->SetVisible(visible); |
| 553 return true; | 553 return true; |
| 554 } | 554 } |
| 555 | 555 |
| 556 bool WindowTree::SetWindowOpacity(const ClientWindowId& window_id, | 556 bool WindowTree::SetWindowOpacity(const ClientWindowId& window_id, |
| 557 float opacity) { | 557 float opacity) { |
| 558 ServerWindow* window = GetWindowByClientId(window_id); | 558 ServerWindow* window = GetWindowByClientId(window_id); |
| 559 if (!window || !access_policy_->CanChangeWindowOpacity(window)) | 559 if (!window || !access_policy_->CanChangeWindowOpacity(window)) |
| 560 return false; | 560 return false; |
| 561 if (window->opacity() == opacity) | 561 if (window->opacity() == opacity) |
| 562 return true; | 562 return true; |
| 563 Operation op(this, window_server_, OperationType::SET_WINDOW_OPACITY); | 563 Operation op(this, window_server_, OperationType::SET_WINDOW_OPACITY); |
| 564 window->SetOpacity(opacity); | 564 window->SetOpacity(opacity); |
| 565 return true; | 565 return true; |
| 566 } | 566 } |
| 567 | 567 |
| 568 bool WindowTree::SetFocus(const ClientWindowId& window_id) { | 568 bool WindowTree::SetFocus(const ClientWindowId& window_id) { |
| 569 ServerWindow* window = GetWindowByClientId(window_id); | 569 ServerWindow* window = GetWindowByClientId(window_id); |
| 570 ServerWindow* currently_focused = window_server_->GetFocusedWindow(); | 570 ServerWindow* currently_focused = window_server_->GetFocusedWindow(); |
| 571 if (!currently_focused && !window) { | 571 if (!currently_focused && !window) { |
| 572 DVLOG(1) << "SetFocus failure, no focused window to clear."; | 572 DVLOG(1) << "SetFocus failed (no focused window to clear)"; |
| 573 return false; | 573 return false; |
| 574 } | 574 } |
| 575 | 575 |
| 576 Display* display = GetDisplay(window); | 576 Display* display = GetDisplay(window); |
| 577 if (window && (!display || !window->can_focus() || !window->IsDrawn())) { | 577 if (window && (!display || !window->can_focus() || !window->IsDrawn())) { |
| 578 DVLOG(1) << "SetFocus failure, window cannot be focused."; | 578 DVLOG(1) << "SetFocus failed (window cannot be focused)"; |
| 579 return false; | 579 return false; |
| 580 } | 580 } |
| 581 | 581 |
| 582 if (!access_policy_->CanSetFocus(window)) { | 582 if (!access_policy_->CanSetFocus(window)) { |
| 583 DVLOG(1) << "SetFocus failure, blocked by access policy."; | 583 DVLOG(1) << "SetFocus failed (blocked by access policy)"; |
| 584 return false; | 584 return false; |
| 585 } | 585 } |
| 586 | 586 |
| 587 Operation op(this, window_server_, OperationType::SET_FOCUS); | 587 Operation op(this, window_server_, OperationType::SET_FOCUS); |
| 588 bool success = window_server_->SetFocusedWindow(window); | 588 bool success = window_server_->SetFocusedWindow(window); |
| 589 if (!success) { | 589 if (!success) { |
| 590 DVLOG(1) << "SetFocus failure, could not SetFocusedWindow."; | 590 DVLOG(1) << "SetFocus failed (could not SetFocusedWindow)"; |
| 591 } | 591 } |
| 592 return success; | 592 return success; |
| 593 } | 593 } |
| 594 | 594 |
| 595 bool WindowTree::Embed(const ClientWindowId& window_id, | 595 bool WindowTree::Embed(const ClientWindowId& window_id, |
| 596 mojom::WindowTreeClientPtr window_tree_client, | 596 mojom::WindowTreeClientPtr window_tree_client, |
| 597 uint32_t flags) { | 597 uint32_t flags) { |
| 598 if (!window_tree_client || !CanEmbed(window_id)) | 598 if (!window_tree_client || !CanEmbed(window_id)) |
| 599 return false; | 599 return false; |
| 600 ServerWindow* window = GetWindowByClientId(window_id); | 600 ServerWindow* window = GetWindowByClientId(window_id); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 const bool drawn = window->parent() && window->parent()->IsDrawn(); | 663 const bool drawn = window->parent() && window->parent()->IsDrawn(); |
| 664 client()->OnTopLevelCreated(client_change_id, WindowToWindowData(window), | 664 client()->OnTopLevelCreated(client_change_id, WindowToWindowData(window), |
| 665 display_id, drawn, window->frame_sink_id(), | 665 display_id, drawn, window->frame_sink_id(), |
| 666 window->current_local_surface_id()); | 666 window->current_local_surface_id()); |
| 667 } | 667 } |
| 668 | 668 |
| 669 void WindowTree::AddActivationParent(const ClientWindowId& window_id) { | 669 void WindowTree::AddActivationParent(const ClientWindowId& window_id) { |
| 670 ServerWindow* window = GetWindowByClientId(window_id); | 670 ServerWindow* window = GetWindowByClientId(window_id); |
| 671 if (window) { | 671 if (window) { |
| 672 Display* display = GetDisplay(window); | 672 Display* display = GetDisplay(window); |
| 673 if (display) | 673 if (display) { |
| 674 display->AddActivationParent(window); | 674 display->AddActivationParent(window); |
| 675 else | 675 } else { |
| 676 DVLOG(1) << "AddActivationParent window not associated with display"; | 676 DVLOG(1) << "AddActivationParent failed " |
| 677 << "(window not associated with display)"; |
| 678 } |
| 677 } else { | 679 } else { |
| 678 DVLOG(1) << "AddActivationParent supplied invalid window id"; | 680 DVLOG(1) << "AddActivationParent failed (invalid window id)"; |
| 679 } | 681 } |
| 680 } | 682 } |
| 681 | 683 |
| 682 void WindowTree::OnChangeCompleted(uint32_t change_id, bool success) { | 684 void WindowTree::OnChangeCompleted(uint32_t change_id, bool success) { |
| 683 client()->OnChangeCompleted(change_id, success); | 685 client()->OnChangeCompleted(change_id, success); |
| 684 } | 686 } |
| 685 | 687 |
| 686 void WindowTree::OnAccelerator(uint32_t accelerator_id, | 688 void WindowTree::OnAccelerator(uint32_t accelerator_id, |
| 687 const ui::Event& event, | 689 const ui::Event& event, |
| 688 AcceleratorCallback callback) { | 690 AcceleratorCallback callback) { |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 | 1042 |
| 1041 WindowId WindowTree::GenerateNewWindowId() { | 1043 WindowId WindowTree::GenerateNewWindowId() { |
| 1042 // TODO(sky): deal with wrapping and uniqueness. | 1044 // TODO(sky): deal with wrapping and uniqueness. |
| 1043 return WindowId(id_, next_window_id_++); | 1045 return WindowId(id_, next_window_id_++); |
| 1044 } | 1046 } |
| 1045 | 1047 |
| 1046 bool WindowTree::CanReorderWindow(const ServerWindow* window, | 1048 bool WindowTree::CanReorderWindow(const ServerWindow* window, |
| 1047 const ServerWindow* relative_window, | 1049 const ServerWindow* relative_window, |
| 1048 mojom::OrderDirection direction) const { | 1050 mojom::OrderDirection direction) const { |
| 1049 if (!window) { | 1051 if (!window) { |
| 1050 DVLOG(1) << "reorder failing: invalid window"; | 1052 DVLOG(1) << "CanReorderWindow failed (invalid window)"; |
| 1051 return false; | 1053 return false; |
| 1052 } | 1054 } |
| 1053 if (!relative_window) { | 1055 if (!relative_window) { |
| 1054 DVLOG(1) << "reorder failing: invalid relative window"; | 1056 DVLOG(1) << "CanReorderWindow failed (invalid relative window)"; |
| 1055 return false; | 1057 return false; |
| 1056 } | 1058 } |
| 1057 | 1059 |
| 1058 if (!window->parent()) { | 1060 if (!window->parent()) { |
| 1059 DVLOG(1) << "reorder failing: no parent"; | 1061 DVLOG(1) << "CanReorderWindow failed (no parent)"; |
| 1060 return false; | 1062 return false; |
| 1061 } | 1063 } |
| 1062 | 1064 |
| 1063 if (window->parent() != relative_window->parent()) { | 1065 if (window->parent() != relative_window->parent()) { |
| 1064 DVLOG(1) << "reorder failing: parents differ"; | 1066 DVLOG(1) << "CanReorderWindow failed (parents differ)"; |
| 1065 return false; | 1067 return false; |
| 1066 } | 1068 } |
| 1067 | 1069 |
| 1068 if (!access_policy_->CanReorderWindow(window, relative_window, direction)) { | 1070 if (!access_policy_->CanReorderWindow(window, relative_window, direction)) { |
| 1069 DVLOG(1) << "reorder failing: access policy denied"; | 1071 DVLOG(1) << "CanReorderWindow failed (access policy denied)"; |
| 1070 return false; | 1072 return false; |
| 1071 } | 1073 } |
| 1072 | 1074 |
| 1073 const ServerWindow::Windows& children = window->parent()->children(); | 1075 const ServerWindow::Windows& children = window->parent()->children(); |
| 1074 const size_t child_i = | 1076 const size_t child_i = |
| 1075 std::find(children.begin(), children.end(), window) - children.begin(); | 1077 std::find(children.begin(), children.end(), window) - children.begin(); |
| 1076 const size_t target_i = | 1078 const size_t target_i = |
| 1077 std::find(children.begin(), children.end(), relative_window) - | 1079 std::find(children.begin(), children.end(), relative_window) - |
| 1078 children.begin(); | 1080 children.begin(); |
| 1079 if ((direction == mojom::OrderDirection::ABOVE && child_i == target_i + 1) || | 1081 if ((direction == mojom::OrderDirection::ABOVE && child_i == target_i + 1) || |
| 1080 (direction == mojom::OrderDirection::BELOW && child_i + 1 == target_i)) { | 1082 (direction == mojom::OrderDirection::BELOW && child_i + 1 == target_i)) { |
| 1081 DVLOG(1) << "reorder failing: already in position"; | 1083 DVLOG(1) << "CanReorderWindow failed (already in position)"; |
| 1082 return false; | 1084 return false; |
| 1083 } | 1085 } |
| 1084 | 1086 |
| 1085 return true; | 1087 return true; |
| 1086 } | 1088 } |
| 1087 | 1089 |
| 1088 bool WindowTree::DeleteWindowImpl(WindowTree* source, ServerWindow* window) { | 1090 bool WindowTree::DeleteWindowImpl(WindowTree* source, ServerWindow* window) { |
| 1089 DCHECK(window); | 1091 DCHECK(window); |
| 1090 DCHECK_EQ(window->id().client_id, id_); | 1092 DCHECK_EQ(window->id().client_id, id_); |
| 1091 Operation op(source, window_server_, OperationType::DELETE_WINDOW); | 1093 Operation op(source, window_server_, OperationType::DELETE_WINDOW); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 ClientWindowId(child_id))); | 1419 ClientWindowId(child_id))); |
| 1418 } | 1420 } |
| 1419 | 1421 |
| 1420 void WindowTree::RemoveWindowFromParent(uint32_t change_id, Id window_id) { | 1422 void WindowTree::RemoveWindowFromParent(uint32_t change_id, Id window_id) { |
| 1421 bool success = false; | 1423 bool success = false; |
| 1422 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 1424 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 1423 DVLOG(3) << "removing window from parent client=" << id_ | 1425 DVLOG(3) << "removing window from parent client=" << id_ |
| 1424 << " client window_id= " << window_id << " global window_id=" | 1426 << " client window_id= " << window_id << " global window_id=" |
| 1425 << (window ? WindowIdToTransportId(window->id()) : 0); | 1427 << (window ? WindowIdToTransportId(window->id()) : 0); |
| 1426 if (!window) { | 1428 if (!window) { |
| 1427 DVLOG(1) << "remove failing, invalid window id=" << change_id; | 1429 DVLOG(1) << "RemoveWindowFromParent failed (invalid window id=" << change_id |
| 1430 << ")"; |
| 1428 } else if (!window->parent()) { | 1431 } else if (!window->parent()) { |
| 1429 DVLOG(1) << "remove failing, no parent id=" << change_id; | 1432 DVLOG(1) << "RemoveWindowFromParent failed (no parent id=" << change_id |
| 1433 << ")"; |
| 1430 } else if (!access_policy_->CanRemoveWindowFromParent(window)) { | 1434 } else if (!access_policy_->CanRemoveWindowFromParent(window)) { |
| 1431 DVLOG(1) << "remove failing, access policy disallowed id=" << change_id; | 1435 DVLOG(1) << "RemoveWindowFromParent failed (access policy disallowed id=" |
| 1436 << change_id << ")"; |
| 1432 } else { | 1437 } else { |
| 1433 success = true; | 1438 success = true; |
| 1434 Operation op(this, window_server_, | 1439 Operation op(this, window_server_, |
| 1435 OperationType::REMOVE_WINDOW_FROM_PARENT); | 1440 OperationType::REMOVE_WINDOW_FROM_PARENT); |
| 1436 window->parent()->Remove(window); | 1441 window->parent()->Remove(window); |
| 1437 } | 1442 } |
| 1438 client()->OnChangeCompleted(change_id, success); | 1443 client()->OnChangeCompleted(change_id, success); |
| 1439 } | 1444 } |
| 1440 | 1445 |
| 1441 void WindowTree::AddTransientWindow(uint32_t change_id, | 1446 void WindowTree::AddTransientWindow(uint32_t change_id, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1543 wm_tree->window_manager_internal_->WmSetBounds( | 1548 wm_tree->window_manager_internal_->WmSetBounds( |
| 1544 wm_change_id, wm_tree->ClientWindowIdForWindow(window).id, | 1549 wm_change_id, wm_tree->ClientWindowIdForWindow(window).id, |
| 1545 std::move(bounds)); | 1550 std::move(bounds)); |
| 1546 return; | 1551 return; |
| 1547 } | 1552 } |
| 1548 | 1553 |
| 1549 DVLOG(3) << "set window bounds client window_id=" << window_id | 1554 DVLOG(3) << "set window bounds client window_id=" << window_id |
| 1550 << " global window_id=" | 1555 << " global window_id=" |
| 1551 << (window ? WindowIdToTransportId(window->id()) : 0) | 1556 << (window ? WindowIdToTransportId(window->id()) : 0) |
| 1552 << " bounds=" << bounds.ToString(); | 1557 << " bounds=" << bounds.ToString(); |
| 1558 |
| 1559 if (!window) { |
| 1560 DVLOG(1) << "SetWindowBounds failed (invalid window id)"; |
| 1561 client()->OnChangeCompleted(change_id, false); |
| 1562 return; |
| 1563 } |
| 1564 |
| 1553 // Only the owner of the window can change the bounds. | 1565 // Only the owner of the window can change the bounds. |
| 1554 bool success = window && access_policy_->CanSetWindowBounds(window); | 1566 bool success = access_policy_->CanSetWindowBounds(window); |
| 1555 if (success) { | 1567 if (success) { |
| 1556 Operation op(this, window_server_, OperationType::SET_WINDOW_BOUNDS); | 1568 Operation op(this, window_server_, OperationType::SET_WINDOW_BOUNDS); |
| 1557 window->SetBounds(bounds, local_surface_id); | 1569 window->SetBounds(bounds, local_surface_id); |
| 1558 } else { | 1570 } else { |
| 1559 DVLOG(1) << "Failed to set bounds on window."; | 1571 DVLOG(1) << "SetWindowBounds failed (access denied)"; |
| 1560 } | 1572 } |
| 1561 client()->OnChangeCompleted(change_id, success); | 1573 client()->OnChangeCompleted(change_id, success); |
| 1562 } | 1574 } |
| 1563 | 1575 |
| 1564 void WindowTree::SetWindowVisibility(uint32_t change_id, | 1576 void WindowTree::SetWindowVisibility(uint32_t change_id, |
| 1565 Id transport_window_id, | 1577 Id transport_window_id, |
| 1566 bool visible) { | 1578 bool visible) { |
| 1567 client()->OnChangeCompleted( | 1579 client()->OnChangeCompleted( |
| 1568 change_id, | 1580 change_id, |
| 1569 SetWindowVisibility(ClientWindowId(transport_window_id), visible)); | 1581 SetWindowVisibility(ClientWindowId(transport_window_id), visible)); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 client()->OnChangeCompleted( | 1616 client()->OnChangeCompleted( |
| 1605 change_id, SetWindowOpacity(ClientWindowId(window_id), opacity)); | 1617 change_id, SetWindowOpacity(ClientWindowId(window_id), opacity)); |
| 1606 } | 1618 } |
| 1607 | 1619 |
| 1608 void WindowTree::AttachCompositorFrameSink( | 1620 void WindowTree::AttachCompositorFrameSink( |
| 1609 Id transport_window_id, | 1621 Id transport_window_id, |
| 1610 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink, | 1622 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink, |
| 1611 cc::mojom::MojoCompositorFrameSinkClientPtr client) { | 1623 cc::mojom::MojoCompositorFrameSinkClientPtr client) { |
| 1612 ServerWindow* window = | 1624 ServerWindow* window = |
| 1613 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1625 GetWindowByClientId(ClientWindowId(transport_window_id)); |
| 1614 const bool success = | 1626 if (!window) { |
| 1615 window && access_policy_->CanSetWindowCompositorFrameSink(window); | 1627 DVLOG(1) << "AttachCompositorFrameSink failed (invalid window id)"; |
| 1628 return; |
| 1629 } |
| 1630 |
| 1631 const bool success = access_policy_->CanSetWindowCompositorFrameSink(window); |
| 1616 if (!success) { | 1632 if (!success) { |
| 1617 DVLOG(1) << "request to AttachCompositorFrameSink failed"; | 1633 DVLOG(1) << "AttachCompositorFrameSink failed (access denied)"; |
| 1618 return; | 1634 return; |
| 1619 } | 1635 } |
| 1620 window->CreateCompositorFrameSink(std::move(compositor_frame_sink), | 1636 window->CreateCompositorFrameSink(std::move(compositor_frame_sink), |
| 1621 std::move(client)); | 1637 std::move(client)); |
| 1622 } | 1638 } |
| 1623 | 1639 |
| 1624 void WindowTree::SetWindowTextInputState(Id transport_window_id, | 1640 void WindowTree::SetWindowTextInputState(Id transport_window_id, |
| 1625 mojo::TextInputStatePtr state) { | 1641 mojo::TextInputStatePtr state) { |
| 1626 ServerWindow* window = | 1642 ServerWindow* window = |
| 1627 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1643 GetWindowByClientId(ClientWindowId(transport_window_id)); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1688 const base::Optional<std::vector<gfx::Rect>>& | 1704 const base::Optional<std::vector<gfx::Rect>>& |
| 1689 transport_additional_client_areas) { | 1705 transport_additional_client_areas) { |
| 1690 ServerWindow* window = | 1706 ServerWindow* window = |
| 1691 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1707 GetWindowByClientId(ClientWindowId(transport_window_id)); |
| 1692 DVLOG(3) << "SetClientArea client window_id=" << transport_window_id | 1708 DVLOG(3) << "SetClientArea client window_id=" << transport_window_id |
| 1693 << " global window_id=" | 1709 << " global window_id=" |
| 1694 << (window ? WindowIdToTransportId(window->id()) : 0) | 1710 << (window ? WindowIdToTransportId(window->id()) : 0) |
| 1695 << " insets=" << insets.top() << " " << insets.left() << " " | 1711 << " insets=" << insets.top() << " " << insets.left() << " " |
| 1696 << insets.bottom() << " " << insets.right(); | 1712 << insets.bottom() << " " << insets.right(); |
| 1697 if (!window) { | 1713 if (!window) { |
| 1698 DVLOG(1) << "SetClientArea failed, no window"; | 1714 DVLOG(1) << "SetClientArea failed (invalid window id)"; |
| 1699 return; | 1715 return; |
| 1700 } | 1716 } |
| 1701 if (!access_policy_->CanSetClientArea(window)) { | 1717 if (!access_policy_->CanSetClientArea(window)) { |
| 1702 DVLOG(1) << "SetClientArea failed, access denied"; | 1718 DVLOG(1) << "SetClientArea failed (access denied)"; |
| 1703 return; | 1719 return; |
| 1704 } | 1720 } |
| 1705 | 1721 |
| 1706 Operation op(this, window_server_, OperationType::SET_CLIENT_AREA); | 1722 Operation op(this, window_server_, OperationType::SET_CLIENT_AREA); |
| 1707 window->SetClientArea(insets, transport_additional_client_areas.value_or( | 1723 window->SetClientArea(insets, transport_additional_client_areas.value_or( |
| 1708 std::vector<gfx::Rect>())); | 1724 std::vector<gfx::Rect>())); |
| 1709 } | 1725 } |
| 1710 | 1726 |
| 1711 void WindowTree::SetHitTestMask(Id transport_window_id, | 1727 void WindowTree::SetHitTestMask(Id transport_window_id, |
| 1712 const base::Optional<gfx::Rect>& mask) { | 1728 const base::Optional<gfx::Rect>& mask) { |
| 1713 ServerWindow* window = | 1729 ServerWindow* window = |
| 1714 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1730 GetWindowByClientId(ClientWindowId(transport_window_id)); |
| 1715 if (!window || !access_policy_->CanSetHitTestMask(window)) { | 1731 if (!window) { |
| 1716 DVLOG(1) << "SetHitTestMask failed"; | 1732 DVLOG(1) << "SetHitTestMask failed (invalid window id)"; |
| 1717 return; | 1733 return; |
| 1718 } | 1734 } |
| 1719 | 1735 |
| 1736 if (!access_policy_->CanSetHitTestMask(window)) { |
| 1737 DVLOG(1) << "SetHitTestMask failed (access denied)"; |
| 1738 return; |
| 1739 } |
| 1740 |
| 1720 if (mask) | 1741 if (mask) |
| 1721 window->SetHitTestMask(*mask); | 1742 window->SetHitTestMask(*mask); |
| 1722 else | 1743 else |
| 1723 window->ClearHitTestMask(); | 1744 window->ClearHitTestMask(); |
| 1724 } | 1745 } |
| 1725 | 1746 |
| 1726 void WindowTree::SetCanAcceptDrops(Id window_id, bool accepts_drops) { | 1747 void WindowTree::SetCanAcceptDrops(Id window_id, bool accepts_drops) { |
| 1727 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 1748 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 1728 if (!window || !access_policy_->CanSetAcceptDrops(window)) { | 1749 if (!window) { |
| 1729 DVLOG(1) << "SetAcceptsDrops failed"; | 1750 DVLOG(1) << "SetCanAcceptDrops failed (invalid window id)"; |
| 1730 return; | 1751 return; |
| 1731 } | 1752 } |
| 1732 | 1753 |
| 1754 if (!access_policy_->CanSetAcceptDrops(window)) { |
| 1755 DVLOG(1) << "SetAcceptsDrops failed (access denied)"; |
| 1756 return; |
| 1757 } |
| 1758 |
| 1733 window->SetCanAcceptDrops(accepts_drops); | 1759 window->SetCanAcceptDrops(accepts_drops); |
| 1734 } | 1760 } |
| 1735 | 1761 |
| 1736 void WindowTree::Embed(Id transport_window_id, | 1762 void WindowTree::Embed(Id transport_window_id, |
| 1737 mojom::WindowTreeClientPtr client, | 1763 mojom::WindowTreeClientPtr client, |
| 1738 uint32_t flags, | 1764 uint32_t flags, |
| 1739 const EmbedCallback& callback) { | 1765 const EmbedCallback& callback) { |
| 1740 callback.Run( | 1766 callback.Run( |
| 1741 Embed(ClientWindowId(transport_window_id), std::move(client), flags)); | 1767 Embed(ClientWindowId(transport_window_id), std::move(client), flags)); |
| 1742 } | 1768 } |
| 1743 | 1769 |
| 1744 void WindowTree::SetFocus(uint32_t change_id, Id transport_window_id) { | 1770 void WindowTree::SetFocus(uint32_t change_id, Id transport_window_id) { |
| 1745 client()->OnChangeCompleted(change_id, | 1771 client()->OnChangeCompleted(change_id, |
| 1746 SetFocus(ClientWindowId(transport_window_id))); | 1772 SetFocus(ClientWindowId(transport_window_id))); |
| 1747 } | 1773 } |
| 1748 | 1774 |
| 1749 void WindowTree::SetCanFocus(Id transport_window_id, bool can_focus) { | 1775 void WindowTree::SetCanFocus(Id transport_window_id, bool can_focus) { |
| 1750 ServerWindow* window = | 1776 ServerWindow* window = |
| 1751 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1777 GetWindowByClientId(ClientWindowId(transport_window_id)); |
| 1752 if (!window) { | 1778 if (!window) { |
| 1753 DVLOG(1) << "SetCanFocus failed (invalid id)"; | 1779 DVLOG(1) << "SetCanFocus failed (invalid window id)"; |
| 1754 return; | 1780 return; |
| 1755 } | 1781 } |
| 1756 | 1782 |
| 1757 if (ShouldRouteToWindowManager(window)) { | 1783 if (ShouldRouteToWindowManager(window)) { |
| 1758 WindowManagerDisplayRoot* display_root = | 1784 WindowManagerDisplayRoot* display_root = |
| 1759 GetWindowManagerDisplayRoot(window); | 1785 GetWindowManagerDisplayRoot(window); |
| 1760 WindowTree* wm_tree = display_root->window_manager_state()->window_tree(); | 1786 WindowTree* wm_tree = display_root->window_manager_state()->window_tree(); |
| 1761 wm_tree->window_manager_internal_->WmSetCanFocus(transport_window_id, | 1787 wm_tree->window_manager_internal_->WmSetCanFocus(transport_window_id, |
| 1762 can_focus); | 1788 can_focus); |
| 1763 } else if (access_policy_->CanSetFocus(window)) { | 1789 } else if (access_policy_->CanSetFocus(window)) { |
| 1764 window->set_can_focus(can_focus); | 1790 window->set_can_focus(can_focus); |
| 1791 } else { |
| 1792 DVLOG(1) << "SetCanFocus failed (access denied)"; |
| 1765 } | 1793 } |
| 1766 } | 1794 } |
| 1767 | 1795 |
| 1768 void WindowTree::SetEventTargetingPolicy(Id transport_window_id, | 1796 void WindowTree::SetEventTargetingPolicy(Id transport_window_id, |
| 1769 mojom::EventTargetingPolicy policy) { | 1797 mojom::EventTargetingPolicy policy) { |
| 1770 ServerWindow* window = | 1798 ServerWindow* window = |
| 1771 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1799 GetWindowByClientId(ClientWindowId(transport_window_id)); |
| 1772 // TODO(riajiang): check |event_queue_| is empty for |window|. | 1800 // TODO(riajiang): check |event_queue_| is empty for |window|. |
| 1773 if (window && access_policy_->CanSetEventTargetingPolicy(window)) | 1801 if (window && access_policy_->CanSetEventTargetingPolicy(window)) |
| 1774 window->set_event_targeting_policy(policy); | 1802 window->set_event_targeting_policy(policy); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1968 uint32_t drag_operation, | 1996 uint32_t drag_operation, |
| 1969 ui::mojom::PointerKind source) { | 1997 ui::mojom::PointerKind source) { |
| 1970 // TODO(erg): SkBitmap is the wrong data type for the drag image; we should | 1998 // TODO(erg): SkBitmap is the wrong data type for the drag image; we should |
| 1971 // be passing ImageSkias once http://crbug.com/655874 is implemented. | 1999 // be passing ImageSkias once http://crbug.com/655874 is implemented. |
| 1972 | 2000 |
| 1973 ServerWindow* window = GetWindowByClientId(ClientWindowId(source_window_id)); | 2001 ServerWindow* window = GetWindowByClientId(ClientWindowId(source_window_id)); |
| 1974 bool success = window && access_policy_->CanInitiateDragLoop(window); | 2002 bool success = window && access_policy_->CanInitiateDragLoop(window); |
| 1975 if (!success || !ShouldRouteToWindowManager(window)) { | 2003 if (!success || !ShouldRouteToWindowManager(window)) { |
| 1976 // We need to fail this move loop change, otherwise the client will just be | 2004 // We need to fail this move loop change, otherwise the client will just be |
| 1977 // waiting for |change_id|. | 2005 // waiting for |change_id|. |
| 1978 DVLOG(1) << "PerformDragDrop failed (access denied)."; | 2006 DVLOG(1) << "PerformDragDrop failed (access denied)"; |
| 1979 client()->OnPerformDragDropCompleted(change_id, false, | 2007 client()->OnPerformDragDropCompleted(change_id, false, |
| 1980 mojom::kDropEffectNone); | 2008 mojom::kDropEffectNone); |
| 1981 return; | 2009 return; |
| 1982 } | 2010 } |
| 1983 | 2011 |
| 1984 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(window); | 2012 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(window); |
| 1985 if (!display_root) { | 2013 if (!display_root) { |
| 1986 // The window isn't parented. There's nothing to do. | 2014 // The window isn't parented. There's nothing to do. |
| 1987 DVLOG(1) << "PerformDragDrop failed (window unparented)."; | 2015 DVLOG(1) << "PerformDragDrop failed (window unparented)"; |
| 1988 client()->OnPerformDragDropCompleted(change_id, false, | 2016 client()->OnPerformDragDropCompleted(change_id, false, |
| 1989 mojom::kDropEffectNone); | 2017 mojom::kDropEffectNone); |
| 1990 return; | 2018 return; |
| 1991 } | 2019 } |
| 1992 | 2020 |
| 1993 if (window_server_->in_move_loop() || window_server_->in_drag_loop()) { | 2021 if (window_server_->in_move_loop() || window_server_->in_drag_loop()) { |
| 1994 // Either the window manager is servicing a window drag or we're servicing | 2022 // Either the window manager is servicing a window drag or we're servicing |
| 1995 // a drag and drop operation. We can't start a second drag. | 2023 // a drag and drop operation. We can't start a second drag. |
| 1996 DVLOG(1) << "PerformDragDrop failed (already performing a drag)."; | 2024 DVLOG(1) << "PerformDragDrop failed (already performing a drag)"; |
| 1997 client()->OnPerformDragDropCompleted(change_id, false, | 2025 client()->OnPerformDragDropCompleted(change_id, false, |
| 1998 mojom::kDropEffectNone); | 2026 mojom::kDropEffectNone); |
| 1999 return; | 2027 return; |
| 2000 } | 2028 } |
| 2001 | 2029 |
| 2002 WindowManagerState* wms = display_root->window_manager_state(); | 2030 WindowManagerState* wms = display_root->window_manager_state(); |
| 2003 | 2031 |
| 2004 // Send the drag representation to the window manager. | 2032 // Send the drag representation to the window manager. |
| 2005 wms->window_tree()->window_manager_internal_->WmBuildDragImage( | 2033 wms->window_tree()->window_manager_internal_->WmBuildDragImage( |
| 2006 screen_location, drag_image, drag_image_offset, source); | 2034 screen_location, drag_image, drag_image_offset, source); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2041 | 2069 |
| 2042 void WindowTree::PerformWindowMove(uint32_t change_id, | 2070 void WindowTree::PerformWindowMove(uint32_t change_id, |
| 2043 Id window_id, | 2071 Id window_id, |
| 2044 ui::mojom::MoveLoopSource source, | 2072 ui::mojom::MoveLoopSource source, |
| 2045 const gfx::Point& cursor) { | 2073 const gfx::Point& cursor) { |
| 2046 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 2074 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 2047 bool success = window && access_policy_->CanInitiateMoveLoop(window); | 2075 bool success = window && access_policy_->CanInitiateMoveLoop(window); |
| 2048 if (!success || !ShouldRouteToWindowManager(window)) { | 2076 if (!success || !ShouldRouteToWindowManager(window)) { |
| 2049 // We need to fail this move loop change, otherwise the client will just be | 2077 // We need to fail this move loop change, otherwise the client will just be |
| 2050 // waiting for |change_id|. | 2078 // waiting for |change_id|. |
| 2051 DVLOG(1) << "PerformWindowMove failed (access denied)."; | 2079 DVLOG(1) << "PerformWindowMove failed (access denied)"; |
| 2052 OnChangeCompleted(change_id, false); | 2080 OnChangeCompleted(change_id, false); |
| 2053 return; | 2081 return; |
| 2054 } | 2082 } |
| 2055 | 2083 |
| 2056 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(window); | 2084 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(window); |
| 2057 if (!display_root) { | 2085 if (!display_root) { |
| 2058 // The window isn't parented. There's nothing to do. | 2086 // The window isn't parented. There's nothing to do. |
| 2059 DVLOG(1) << "PerformWindowMove failed (window unparented)."; | 2087 DVLOG(1) << "PerformWindowMove failed (window unparented)"; |
| 2060 OnChangeCompleted(change_id, false); | 2088 OnChangeCompleted(change_id, false); |
| 2061 return; | 2089 return; |
| 2062 } | 2090 } |
| 2063 | 2091 |
| 2064 if (window_server_->in_move_loop() || window_server_->in_drag_loop()) { | 2092 if (window_server_->in_move_loop() || window_server_->in_drag_loop()) { |
| 2065 // Either the window manager is servicing a window drag or we're servicing | 2093 // Either the window manager is servicing a window drag or we're servicing |
| 2066 // a drag and drop operation. We can't start a second drag. | 2094 // a drag and drop operation. We can't start a second drag. |
| 2067 DVLOG(1) << "PerformWindowMove failed (already performing a drag)."; | 2095 DVLOG(1) << "PerformWindowMove failed (already performing a drag)"; |
| 2068 OnChangeCompleted(change_id, false); | 2096 OnChangeCompleted(change_id, false); |
| 2069 return; | 2097 return; |
| 2070 } | 2098 } |
| 2071 | 2099 |
| 2072 // When we perform a window move loop, we give the window manager non client | 2100 // When we perform a window move loop, we give the window manager non client |
| 2073 // capture. Because of how the capture public interface currently works, | 2101 // capture. Because of how the capture public interface currently works, |
| 2074 // SetCapture() will check whether the mouse cursor is currently in the | 2102 // SetCapture() will check whether the mouse cursor is currently in the |
| 2075 // non-client area and if so, will redirect messages to the window | 2103 // non-client area and if so, will redirect messages to the window |
| 2076 // manager. (And normal window movement relies on this behaviour.) | 2104 // manager. (And normal window movement relies on this behaviour.) |
| 2077 WindowManagerState* wms = display_root->window_manager_state(); | 2105 WindowManagerState* wms = display_root->window_manager_state(); |
| 2078 wms->SetCapture(window, wms->window_tree()->id()); | 2106 wms->SetCapture(window, wms->window_tree()->id()); |
| 2079 | 2107 |
| 2080 const uint32_t wm_change_id = | 2108 const uint32_t wm_change_id = |
| 2081 window_server_->GenerateWindowManagerChangeId(this, change_id); | 2109 window_server_->GenerateWindowManagerChangeId(this, change_id); |
| 2082 window_server_->StartMoveLoop(wm_change_id, window, this, window->bounds()); | 2110 window_server_->StartMoveLoop(wm_change_id, window, this, window->bounds()); |
| 2083 wms->window_tree()->window_manager_internal_->WmPerformMoveLoop( | 2111 wms->window_tree()->window_manager_internal_->WmPerformMoveLoop( |
| 2084 wm_change_id, wms->window_tree()->ClientWindowIdForWindow(window).id, | 2112 wm_change_id, wms->window_tree()->ClientWindowIdForWindow(window).id, |
| 2085 source, cursor); | 2113 source, cursor); |
| 2086 } | 2114 } |
| 2087 | 2115 |
| 2088 void WindowTree::CancelWindowMove(Id window_id) { | 2116 void WindowTree::CancelWindowMove(Id window_id) { |
| 2089 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 2117 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 2090 bool success = window && access_policy_->CanInitiateMoveLoop(window); | 2118 if (!window) { |
| 2091 if (!success) { | 2119 DVLOG(1) << "CancelWindowMove failed (invalid window id)"; |
| 2092 DVLOG(1) << "CancelWindowMove failed (no window / access denied)"; | |
| 2093 return; | 2120 return; |
| 2094 } | 2121 } |
| 2095 | 2122 |
| 2123 bool success = access_policy_->CanInitiateMoveLoop(window); |
| 2124 if (!success) { |
| 2125 DVLOG(1) << "CancelWindowMove failed (access denied)"; |
| 2126 return; |
| 2127 } |
| 2128 |
| 2096 if (window != window_server_->GetCurrentMoveLoopWindow()) { | 2129 if (window != window_server_->GetCurrentMoveLoopWindow()) { |
| 2097 DVLOG(1) << "CancelWindowMove failed (not the move loop window)"; | 2130 DVLOG(1) << "CancelWindowMove failed (not the move loop window)"; |
| 2098 return; | 2131 return; |
| 2099 } | 2132 } |
| 2100 | 2133 |
| 2101 if (window_server_->GetCurrentMoveLoopInitiator() != this) { | 2134 if (window_server_->GetCurrentMoveLoopInitiator() != this) { |
| 2102 DVLOG(1) << "CancelWindowMove failed (not the move loop initiator)"; | 2135 DVLOG(1) << "CancelWindowMove failed (not the move loop initiator)"; |
| 2103 return; | 2136 return; |
| 2104 } | 2137 } |
| 2105 | 2138 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2132 window_manager_state_->event_dispatcher()->RemoveAccelerator(id); | 2165 window_manager_state_->event_dispatcher()->RemoveAccelerator(id); |
| 2133 } | 2166 } |
| 2134 | 2167 |
| 2135 void WindowTree::AddActivationParent(Id transport_window_id) { | 2168 void WindowTree::AddActivationParent(Id transport_window_id) { |
| 2136 AddActivationParent(ClientWindowId(transport_window_id)); | 2169 AddActivationParent(ClientWindowId(transport_window_id)); |
| 2137 } | 2170 } |
| 2138 | 2171 |
| 2139 void WindowTree::RemoveActivationParent(Id transport_window_id) { | 2172 void WindowTree::RemoveActivationParent(Id transport_window_id) { |
| 2140 ServerWindow* window = | 2173 ServerWindow* window = |
| 2141 GetWindowByClientId(ClientWindowId(transport_window_id)); | 2174 GetWindowByClientId(ClientWindowId(transport_window_id)); |
| 2142 if (window) { | 2175 if (!window) { |
| 2143 Display* display = GetDisplay(window); | 2176 DVLOG(1) << "RemoveActivationParent failed (invalid window id)"; |
| 2144 if (display) | 2177 return; |
| 2145 display->RemoveActivationParent(window); | |
| 2146 else | |
| 2147 DVLOG(1) << "RemoveActivationParent window not associated with display"; | |
| 2148 } else { | |
| 2149 DVLOG(1) << "RemoveActivationParent supplied invalid window id"; | |
| 2150 } | 2178 } |
| 2179 |
| 2180 Display* display = GetDisplay(window); |
| 2181 if (!display) { |
| 2182 DVLOG(1) << "RemoveActivationParent window not associated with display"; |
| 2183 return; |
| 2184 } |
| 2185 |
| 2186 display->RemoveActivationParent(window); |
| 2151 } | 2187 } |
| 2152 | 2188 |
| 2153 void WindowTree::ActivateNextWindow() { | 2189 void WindowTree::ActivateNextWindow() { |
| 2154 DCHECK(window_manager_state_); | 2190 DCHECK(window_manager_state_); |
| 2155 if (window_server_->user_id_tracker()->active_id() != user_id_) | 2191 if (window_server_->user_id_tracker()->active_id() != user_id_) |
| 2156 return; | 2192 return; |
| 2157 | 2193 |
| 2158 ServerWindow* focused_window = window_server_->GetFocusedWindow(); | 2194 ServerWindow* focused_window = window_server_->GetFocusedWindow(); |
| 2159 if (focused_window) { | 2195 if (focused_window) { |
| 2160 WindowManagerDisplayRoot* display_root = | 2196 WindowManagerDisplayRoot* display_root = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2171 if (displays.empty()) | 2207 if (displays.empty()) |
| 2172 return; | 2208 return; |
| 2173 | 2209 |
| 2174 (*displays.begin())->ActivateNextWindow(); | 2210 (*displays.begin())->ActivateNextWindow(); |
| 2175 } | 2211 } |
| 2176 | 2212 |
| 2177 void WindowTree::SetExtendedHitArea(Id window_id, const gfx::Insets& hit_area) { | 2213 void WindowTree::SetExtendedHitArea(Id window_id, const gfx::Insets& hit_area) { |
| 2178 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 2214 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 2179 // Extended hit test region should only be set by the owner of the window. | 2215 // Extended hit test region should only be set by the owner of the window. |
| 2180 if (!window) { | 2216 if (!window) { |
| 2181 DVLOG(1) << "SetExtendedHitArea supplied unknown window"; | 2217 DVLOG(1) << "SetExtendedHitArea failed (invalid window id)"; |
| 2182 return; | 2218 return; |
| 2183 } | 2219 } |
| 2184 if (window->id().client_id != id_) { | 2220 if (window->id().client_id != id_) { |
| 2185 DVLOG(1) << "SetExtendedHitArea supplied window that client does not own"; | 2221 DVLOG(1) << "SetExtendedHitArea failed (supplied window that client does " |
| 2222 << "not own)"; |
| 2186 return; | 2223 return; |
| 2187 } | 2224 } |
| 2188 window->set_extended_hit_test_region(hit_area); | 2225 window->set_extended_hit_test_region(hit_area); |
| 2189 } | 2226 } |
| 2190 | 2227 |
| 2191 void WindowTree::SetDisplayRoot(const display::Display& display, | 2228 void WindowTree::SetDisplayRoot(const display::Display& display, |
| 2192 mojom::WmViewportMetricsPtr viewport_metrics, | 2229 mojom::WmViewportMetricsPtr viewport_metrics, |
| 2193 bool is_primary_display, | 2230 bool is_primary_display, |
| 2194 Id window_id, | 2231 Id window_id, |
| 2195 const SetDisplayRootCallback& callback) { | 2232 const SetDisplayRootCallback& callback) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2255 void WindowTree::WmSetFrameDecorationValues( | 2292 void WindowTree::WmSetFrameDecorationValues( |
| 2256 mojom::FrameDecorationValuesPtr values) { | 2293 mojom::FrameDecorationValuesPtr values) { |
| 2257 DCHECK(window_manager_state_); | 2294 DCHECK(window_manager_state_); |
| 2258 window_manager_state_->SetFrameDecorationValues(std::move(values)); | 2295 window_manager_state_->SetFrameDecorationValues(std::move(values)); |
| 2259 } | 2296 } |
| 2260 | 2297 |
| 2261 void WindowTree::WmSetNonClientCursor(uint32_t window_id, | 2298 void WindowTree::WmSetNonClientCursor(uint32_t window_id, |
| 2262 ui::CursorData cursor) { | 2299 ui::CursorData cursor) { |
| 2263 DCHECK(window_manager_state_); | 2300 DCHECK(window_manager_state_); |
| 2264 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 2301 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 2265 if (window) { | 2302 if (!window) { |
| 2266 window->SetNonClientCursor(std::move(cursor)); | 2303 DVLOG(1) << "WmSetNonClientCursor failed (invalid window id)"; |
| 2267 } else { | 2304 return; |
| 2268 DVLOG(1) << "trying to update non-client cursor of invalid window"; | |
| 2269 } | 2305 } |
| 2306 |
| 2307 window->SetNonClientCursor(std::move(cursor)); |
| 2270 } | 2308 } |
| 2271 | 2309 |
| 2272 void WindowTree::OnWmCreatedTopLevelWindow(uint32_t change_id, | 2310 void WindowTree::OnWmCreatedTopLevelWindow(uint32_t change_id, |
| 2273 Id transport_window_id) { | 2311 Id transport_window_id) { |
| 2274 ServerWindow* window = | 2312 ServerWindow* window = |
| 2275 GetWindowByClientId(ClientWindowId(transport_window_id)); | 2313 GetWindowByClientId(ClientWindowId(transport_window_id)); |
| 2276 if (window && window->id().client_id != id_) { | 2314 if (window && window->id().client_id != id_) { |
| 2277 DVLOG(1) << "OnWmCreatedTopLevelWindow supplied invalid window id"; | 2315 DVLOG(1) << "OnWmCreatedTopLevelWindow failed (invalid window id)"; |
| 2278 window_server_->WindowManagerSentBogusMessage(); | 2316 window_server_->WindowManagerSentBogusMessage(); |
| 2279 window = nullptr; | 2317 window = nullptr; |
| 2280 } | 2318 } |
| 2281 if (window) { | 2319 if (window) { |
| 2282 client()->OnFrameSinkIdAllocated(transport_window_id, | 2320 client()->OnFrameSinkIdAllocated(transport_window_id, |
| 2283 window->frame_sink_id()); | 2321 window->frame_sink_id()); |
| 2284 } | 2322 } |
| 2285 window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window); | 2323 window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window); |
| 2286 } | 2324 } |
| 2287 | 2325 |
| 2288 void WindowTree::OnAcceleratorAck(uint32_t event_id, | 2326 void WindowTree::OnAcceleratorAck(uint32_t event_id, |
| 2289 mojom::EventResult result, | 2327 mojom::EventResult result, |
| 2290 const EventProperties& properties) { | 2328 const EventProperties& properties) { |
| 2291 DVLOG(3) << "OnAcceleratorAck client=" << id_; | 2329 DVLOG(3) << "OnAcceleratorAck client=" << id_; |
| 2292 if (event_ack_id_ == 0 || event_id != event_ack_id_ || | 2330 if (event_ack_id_ == 0 || event_id != event_ack_id_ || |
| 2293 !accelerator_ack_callback_) { | 2331 !accelerator_ack_callback_) { |
| 2294 DVLOG(1) << "OnAcceleratorAck supplied invalid event_id"; | 2332 DVLOG(1) << "OnAcceleratorAck failed (invalid event id)"; |
| 2295 window_server_->WindowManagerSentBogusMessage(); | 2333 window_server_->WindowManagerSentBogusMessage(); |
| 2296 return; | 2334 return; |
| 2297 } | 2335 } |
| 2298 event_ack_id_ = 0; | 2336 event_ack_id_ = 0; |
| 2299 DCHECK(window_manager_state_); | 2337 DCHECK(window_manager_state_); |
| 2300 base::ResetAndReturn(&accelerator_ack_callback_).Run(result, properties); | 2338 base::ResetAndReturn(&accelerator_ack_callback_).Run(result, properties); |
| 2301 } | 2339 } |
| 2302 | 2340 |
| 2303 bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const { | 2341 bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const { |
| 2304 return HasRoot(window); | 2342 return HasRoot(window); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2445 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, | 2483 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, |
| 2446 effect_bitmask, callback); | 2484 effect_bitmask, callback); |
| 2447 } | 2485 } |
| 2448 | 2486 |
| 2449 void WindowTree::PerformOnDragDropDone() { | 2487 void WindowTree::PerformOnDragDropDone() { |
| 2450 client()->OnDragDropDone(); | 2488 client()->OnDragDropDone(); |
| 2451 } | 2489 } |
| 2452 | 2490 |
| 2453 } // namespace ws | 2491 } // namespace ws |
| 2454 } // namespace ui | 2492 } // namespace ui |
| OLD | NEW |