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 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 Display* display = GetDisplay(window); | 1289 Display* display = GetDisplay(window); |
1290 if (display) | 1290 if (display) |
1291 display->SetImeVisibility(window, visible); | 1291 display->SetImeVisibility(window, visible); |
1292 } | 1292 } |
1293 } | 1293 } |
1294 | 1294 |
1295 void WindowTree::OnWindowInputEventAck(uint32_t event_id, | 1295 void WindowTree::OnWindowInputEventAck(uint32_t event_id, |
1296 mojom::EventResult result) { | 1296 mojom::EventResult result) { |
1297 if (event_ack_id_ == 0 || event_id != event_ack_id_) { | 1297 if (event_ack_id_ == 0 || event_id != event_ack_id_) { |
1298 // TODO(sad): Something bad happened. Kill the client? | 1298 // TODO(sad): Something bad happened. Kill the client? |
1299 NOTIMPLEMENTED() << "Wrong event acked."; | 1299 NOTIMPLEMENTED() << ": Wrong event acked. event_id=" << event_id |
| 1300 << ", event_ack_id_=" << event_ack_id_; |
1300 } | 1301 } |
1301 event_ack_id_ = 0; | 1302 event_ack_id_ = 0; |
1302 | 1303 |
1303 if (janky_) | 1304 if (janky_) |
1304 event_source_wms_->window_tree()->ClientJankinessChanged(this); | 1305 event_source_wms_->window_tree()->ClientJankinessChanged(this); |
1305 | 1306 |
1306 WindowManagerState* event_source_wms = event_source_wms_; | 1307 WindowManagerState* event_source_wms = event_source_wms_; |
1307 event_source_wms_ = nullptr; | 1308 event_source_wms_ = nullptr; |
1308 if (event_source_wms) | 1309 if (event_source_wms) |
1309 event_source_wms->OnEventAck(this, result); | 1310 event_source_wms->OnEventAck(this, result); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 this, std::move(internal))); | 1402 this, std::move(internal))); |
1402 } | 1403 } |
1403 | 1404 |
1404 void WindowTree::GetCursorLocationMemory( | 1405 void WindowTree::GetCursorLocationMemory( |
1405 const GetCursorLocationMemoryCallback& callback) { | 1406 const GetCursorLocationMemoryCallback& callback) { |
1406 callback.Run( | 1407 callback.Run( |
1407 window_server_->display_manager()->GetUserDisplayManager(user_id_)-> | 1408 window_server_->display_manager()->GetUserDisplayManager(user_id_)-> |
1408 GetCursorLocationMemory()); | 1409 GetCursorLocationMemory()); |
1409 } | 1410 } |
1410 | 1411 |
| 1412 void WindowTree::PerformWindowMove(uint32_t change_id, |
| 1413 Id window_id, |
| 1414 ui::mojom::MoveLoopSource source, |
| 1415 const gfx::Point& cursor) { |
| 1416 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 1417 bool success = window && access_policy_->CanInitiateMoveLoop(window); |
| 1418 if (!success || !ShouldRouteToWindowManager(window)) { |
| 1419 // We need to fail this move loop change, otherwise the client will just be |
| 1420 // waiting for |change_id|. |
| 1421 OnChangeCompleted(change_id, false); |
| 1422 return; |
| 1423 } |
| 1424 |
| 1425 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(window); |
| 1426 if (!display_root) { |
| 1427 // The window isn't parented. There's nothing to do. |
| 1428 OnChangeCompleted(change_id, false); |
| 1429 return; |
| 1430 } |
| 1431 |
| 1432 if (window_server_->in_move_loop()) { |
| 1433 // A window manager is already servicing a move loop; we can't start a |
| 1434 // second one. |
| 1435 OnChangeCompleted(change_id, false); |
| 1436 return; |
| 1437 } |
| 1438 |
| 1439 // When we perform a window move loop, we give the window manager non client |
| 1440 // capture. Because of how the capture public interface currently works, |
| 1441 // SetCapture() will check whether the mouse cursor is currently in the |
| 1442 // non-client area and if so, will redirect messages to the window |
| 1443 // manager. (And normal window movement relies on this behaviour.) |
| 1444 WindowManagerState* wms = display_root->window_manager_state(); |
| 1445 wms->SetCapture(window, wms->window_tree()->id()); |
| 1446 |
| 1447 const uint32_t wm_change_id = |
| 1448 window_server_->GenerateWindowManagerChangeId(this, change_id); |
| 1449 window_server_->StartMoveLoop(wm_change_id, window, this, window->bounds()); |
| 1450 wms->window_tree()->window_manager_internal_->WmPerformMoveLoop( |
| 1451 wm_change_id, wms->window_tree()->ClientWindowIdForWindow(window).id, |
| 1452 source, cursor); |
| 1453 } |
| 1454 |
| 1455 void WindowTree::CancelWindowMove(Id window_id) { |
| 1456 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 1457 bool success = window && access_policy_->CanInitiateMoveLoop(window); |
| 1458 if (!success) |
| 1459 return; |
| 1460 |
| 1461 if (window != window_server_->GetCurrentMoveLoopWindow()) |
| 1462 return; |
| 1463 |
| 1464 if (window_server_->GetCurrentMoveLoopInitiator() != this) |
| 1465 return; |
| 1466 |
| 1467 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(window); |
| 1468 if (!display_root) |
| 1469 return; |
| 1470 |
| 1471 WindowManagerState* wms = display_root->window_manager_state(); |
| 1472 wms->window_tree()->window_manager_internal_->WmCancelMoveLoop( |
| 1473 window_server_->GetCurrentMoveLoopChangeId()); |
| 1474 } |
| 1475 |
1411 void WindowTree::AddAccelerator(uint32_t id, | 1476 void WindowTree::AddAccelerator(uint32_t id, |
1412 mojom::EventMatcherPtr event_matcher, | 1477 mojom::EventMatcherPtr event_matcher, |
1413 const AddAcceleratorCallback& callback) { | 1478 const AddAcceleratorCallback& callback) { |
1414 DCHECK(window_manager_state_); | 1479 DCHECK(window_manager_state_); |
1415 const bool success = | 1480 const bool success = |
1416 window_manager_state_->event_dispatcher()->AddAccelerator( | 1481 window_manager_state_->event_dispatcher()->AddAccelerator( |
1417 id, std::move(event_matcher)); | 1482 id, std::move(event_matcher)); |
1418 callback.Run(success); | 1483 callback.Run(success); |
1419 } | 1484 } |
1420 | 1485 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1471 const gfx::Insets& hit_area) { | 1536 const gfx::Insets& hit_area) { |
1472 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 1537 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
1473 if (!window) | 1538 if (!window) |
1474 return; | 1539 return; |
1475 | 1540 |
1476 window->SetUnderlayOffset(gfx::Vector2d(x_offset, y_offset)); | 1541 window->SetUnderlayOffset(gfx::Vector2d(x_offset, y_offset)); |
1477 window->set_extended_hit_test_region(hit_area); | 1542 window->set_extended_hit_test_region(hit_area); |
1478 } | 1543 } |
1479 | 1544 |
1480 void WindowTree::WmResponse(uint32_t change_id, bool response) { | 1545 void WindowTree::WmResponse(uint32_t change_id, bool response) { |
| 1546 if (window_server_->in_move_loop() && |
| 1547 window_server_->GetCurrentMoveLoopChangeId() == change_id) { |
| 1548 ServerWindow* window = window_server_->GetCurrentMoveLoopWindow(); |
| 1549 |
| 1550 if (window->id().client_id != id_) { |
| 1551 window_server_->WindowManagerSentBogusMessage(); |
| 1552 window = nullptr; |
| 1553 } else { |
| 1554 WindowManagerDisplayRoot* display_root = |
| 1555 GetWindowManagerDisplayRoot(window); |
| 1556 if (display_root) { |
| 1557 WindowManagerState* wms = display_root->window_manager_state(); |
| 1558 // Clear the implicit capture. |
| 1559 wms->SetCapture(nullptr, false); |
| 1560 } |
| 1561 } |
| 1562 |
| 1563 if (!response && window) { |
| 1564 // Our move loop didn't succeed, which means that we must restore the |
| 1565 // original bounds of the window. |
| 1566 window->SetBounds(window_server_->GetCurrentMoveLoopRevertBounds()); |
| 1567 } |
| 1568 |
| 1569 window_server_->EndMoveLoop(); |
| 1570 } |
| 1571 |
1481 window_server_->WindowManagerChangeCompleted(change_id, response); | 1572 window_server_->WindowManagerChangeCompleted(change_id, response); |
1482 } | 1573 } |
1483 | 1574 |
1484 void WindowTree::WmRequestClose(Id transport_window_id) { | 1575 void WindowTree::WmRequestClose(Id transport_window_id) { |
1485 ServerWindow* window = | 1576 ServerWindow* window = |
1486 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1577 GetWindowByClientId(ClientWindowId(transport_window_id)); |
1487 WindowTree* tree = window_server_->GetTreeWithRoot(window); | 1578 WindowTree* tree = window_server_->GetTreeWithRoot(window); |
1488 if (tree && tree != this) { | 1579 if (tree && tree != this) { |
1489 tree->client()->RequestClose(tree->ClientWindowIdForWindow(window).id); | 1580 tree->client()->RequestClose(tree->ClientWindowIdForWindow(window).id); |
1490 } | 1581 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 } | 1621 } |
1531 | 1622 |
1532 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( | 1623 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( |
1533 const ServerWindow* window) const { | 1624 const ServerWindow* window) const { |
1534 WindowTree* tree = window_server_->GetTreeWithRoot(window); | 1625 WindowTree* tree = window_server_->GetTreeWithRoot(window); |
1535 return tree && tree != this; | 1626 return tree && tree != this; |
1536 } | 1627 } |
1537 | 1628 |
1538 } // namespace ws | 1629 } // namespace ws |
1539 } // namespace ui | 1630 } // namespace ui |
OLD | NEW |