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 "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 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 waiting_for_top_level_window_info->client_window_id; | 400 waiting_for_top_level_window_info->client_window_id; |
401 roots_.insert(window); | 401 roots_.insert(window); |
402 Display* display = GetDisplay(window); | 402 Display* display = GetDisplay(window); |
403 int64_t display_id = | 403 int64_t display_id = |
404 display ? display->id() : display::Display::kInvalidDisplayID; | 404 display ? display->id() : display::Display::kInvalidDisplayID; |
405 const bool drawn = window->parent() && window->parent()->IsDrawn(); | 405 const bool drawn = window->parent() && window->parent()->IsDrawn(); |
406 client()->OnTopLevelCreated(client_change_id, WindowToWindowData(window), | 406 client()->OnTopLevelCreated(client_change_id, WindowToWindowData(window), |
407 display_id, drawn); | 407 display_id, drawn); |
408 } | 408 } |
409 | 409 |
410 void WindowTree::OnMoveLoopCompleted(uint32_t client_change_id, | |
411 bool completed) { | |
412 client()->OnMoveLoopCompleted(client_change_id, completed); | |
413 } | |
414 | |
410 void WindowTree::AddActivationParent(const ClientWindowId& window_id) { | 415 void WindowTree::AddActivationParent(const ClientWindowId& window_id) { |
411 ServerWindow* window = GetWindowByClientId(window_id); | 416 ServerWindow* window = GetWindowByClientId(window_id); |
412 if (window) { | 417 if (window) { |
413 Display* display = GetDisplay(window); | 418 Display* display = GetDisplay(window); |
414 if (display) | 419 if (display) |
415 display->AddActivationParent(window); | 420 display->AddActivationParent(window); |
416 else | 421 else |
417 DVLOG(1) << "AddActivationParent window not associated with display"; | 422 DVLOG(1) << "AddActivationParent window not associated with display"; |
418 } else { | 423 } else { |
419 DVLOG(1) << "AddActivationParent supplied invalid window id"; | 424 DVLOG(1) << "AddActivationParent supplied invalid window id"; |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1288 Display* display = GetDisplay(window); | 1293 Display* display = GetDisplay(window); |
1289 if (display) | 1294 if (display) |
1290 display->SetImeVisibility(window, visible); | 1295 display->SetImeVisibility(window, visible); |
1291 } | 1296 } |
1292 } | 1297 } |
1293 | 1298 |
1294 void WindowTree::OnWindowInputEventAck(uint32_t event_id, | 1299 void WindowTree::OnWindowInputEventAck(uint32_t event_id, |
1295 mojom::EventResult result) { | 1300 mojom::EventResult result) { |
1296 if (event_ack_id_ == 0 || event_id != event_ack_id_) { | 1301 if (event_ack_id_ == 0 || event_id != event_ack_id_) { |
1297 // TODO(sad): Something bad happened. Kill the client? | 1302 // TODO(sad): Something bad happened. Kill the client? |
1298 NOTIMPLEMENTED() << "Wrong event acked."; | 1303 NOTIMPLEMENTED() << ": Wrong event acked. event_id=" << event_id |
1304 << ", event_ack_id_=" << event_ack_id_; | |
1299 } | 1305 } |
1300 event_ack_id_ = 0; | 1306 event_ack_id_ = 0; |
1301 | 1307 |
1302 if (janky_) | 1308 if (janky_) |
1303 event_source_wms_->tree()->ClientJankinessChanged(this); | 1309 event_source_wms_->tree()->ClientJankinessChanged(this); |
1304 | 1310 |
1305 WindowManagerState* event_source_wms = event_source_wms_; | 1311 WindowManagerState* event_source_wms = event_source_wms_; |
1306 event_source_wms_ = nullptr; | 1312 event_source_wms_ = nullptr; |
1307 if (event_source_wms) | 1313 if (event_source_wms) |
1308 event_source_wms->OnEventAck(this, result); | 1314 event_source_wms->OnEventAck(this, result); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1398 this, std::move(internal))); | 1404 this, std::move(internal))); |
1399 } | 1405 } |
1400 | 1406 |
1401 void WindowTree::GetCursorLocationMemory( | 1407 void WindowTree::GetCursorLocationMemory( |
1402 const GetCursorLocationMemoryCallback& callback) { | 1408 const GetCursorLocationMemoryCallback& callback) { |
1403 callback.Run( | 1409 callback.Run( |
1404 window_server_->display_manager()->GetUserDisplayManager(user_id_)-> | 1410 window_server_->display_manager()->GetUserDisplayManager(user_id_)-> |
1405 GetCursorLocationMemory()); | 1411 GetCursorLocationMemory()); |
1406 } | 1412 } |
1407 | 1413 |
1414 void WindowTree::PerformWindowMove(uint32_t change_id, | |
1415 Id window_id, | |
1416 const gfx::Point& cursor) { | |
1417 // TODO(erg): Should we also ensure that no second client can try to perform | |
sky
2016/06/22 23:47:57
Yes, as mash won't support it.
| |
1418 // a move while another move is in progress? | |
1419 | |
1420 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | |
1421 bool success = window && access_policy_->CanInitiateMoveLoop(window); | |
1422 if (!success) { | |
sky
2016/06/22 23:47:57
You should also fail if ShouldRouteToWindowManager
| |
1423 // We need to fail this move loop change, otherwise the client will just be | |
1424 // waiting for |change_id|. | |
1425 OnMoveLoopCompleted(change_id, false); | |
1426 return; | |
1427 } | |
1428 | |
1429 WindowManagerState* wms = display_manager() | |
1430 ->GetWindowManagerAndDisplay(window) | |
1431 .window_manager_state; | |
sky
2016/06/22 23:47:57
Sorry, I changed this around. You'll want:
Wi
| |
1432 | |
1433 // When we perform a window move loop, we give the window manager non client | |
1434 // capture. Because of how the capture public interface currently works, | |
1435 // SetCapture() will check whether the mouse cursor is currently in the | |
1436 // non-client area and if so, will redirect messages to the window | |
1437 // manager. (And normal window movement relies on this behaviour.) | |
1438 wms->SetCapture(window, true); | |
sky
2016/06/22 23:47:57
true should be the id() of the WindowTree from Win
| |
1439 | |
1440 const uint32_t wm_change_id = | |
1441 window_server_->GenerateWindowManagerChangeId(this, change_id); | |
1442 wms->tree()->window_manager_internal_->WmPerformMoveLoop( | |
1443 wm_change_id, wms->tree()->ClientWindowIdForWindow(window).id, cursor); | |
1444 } | |
1445 | |
1446 void WindowTree::CancelWindowMove(Id window_id) { | |
1447 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | |
1448 bool success = window && access_policy_->CanInitiateMoveLoop(window); | |
1449 if (!success) | |
1450 return; | |
1451 | |
1452 WindowManagerState* wms = display_manager() | |
1453 ->GetWindowManagerAndDisplay(window) | |
1454 .window_manager_state; | |
1455 | |
1456 wms->tree()->window_manager_internal_->WmCancelMoveLoop( | |
1457 wms->tree()->ClientWindowIdForWindow(window).id); | |
1458 } | |
1459 | |
1408 void WindowTree::AddAccelerator(uint32_t id, | 1460 void WindowTree::AddAccelerator(uint32_t id, |
1409 mojom::EventMatcherPtr event_matcher, | 1461 mojom::EventMatcherPtr event_matcher, |
1410 const AddAcceleratorCallback& callback) { | 1462 const AddAcceleratorCallback& callback) { |
1411 WindowManagerState* wms = GetWindowManagerStateForWindowManager(); | 1463 WindowManagerState* wms = GetWindowManagerStateForWindowManager(); |
1412 const bool success = | 1464 const bool success = |
1413 wms->event_dispatcher()->AddAccelerator(id, std::move(event_matcher)); | 1465 wms->event_dispatcher()->AddAccelerator(id, std::move(event_matcher)); |
1414 callback.Run(success); | 1466 callback.Run(success); |
1415 } | 1467 } |
1416 | 1468 |
1417 void WindowTree::RemoveAccelerator(uint32_t id) { | 1469 void WindowTree::RemoveAccelerator(uint32_t id) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1490 ServerWindow* window = | 1542 ServerWindow* window = |
1491 GetWindowByClientId(ClientWindowId(transport_window_id)); | 1543 GetWindowByClientId(ClientWindowId(transport_window_id)); |
1492 if (window && window->id().client_id != id_) { | 1544 if (window && window->id().client_id != id_) { |
1493 DVLOG(1) << "OnWmCreatedTopLevelWindow supplied invalid window id"; | 1545 DVLOG(1) << "OnWmCreatedTopLevelWindow supplied invalid window id"; |
1494 window_server_->WindowManagerSentBogusMessage(); | 1546 window_server_->WindowManagerSentBogusMessage(); |
1495 window = nullptr; | 1547 window = nullptr; |
1496 } | 1548 } |
1497 window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window); | 1549 window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window); |
1498 } | 1550 } |
1499 | 1551 |
1552 void WindowTree::OnWmMoveLoopCompleted(uint32_t change_id, | |
1553 Id transport_window_id, | |
1554 bool succeeded) { | |
1555 WindowManagerState* wms = GetWindowManagerStateForWindowManager(); | |
1556 if (wms) { | |
1557 ServerWindow* window = | |
1558 GetWindowByClientId(ClientWindowId(transport_window_id)); | |
1559 | |
1560 if (window && window->id().client_id != id_) { | |
1561 window_server_->WindowManagerSentBogusMessage(); | |
1562 window = nullptr; | |
1563 } else { | |
1564 // Clear the implicit capture. | |
1565 wms->SetCapture(nullptr, false); | |
1566 } | |
1567 | |
1568 window_server_->WindowManagerCompletedMoveLoop(change_id, window, | |
1569 succeeded); | |
1570 } | |
1571 } | |
1572 | |
1500 bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const { | 1573 bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const { |
1501 return HasRoot(window); | 1574 return HasRoot(window); |
1502 } | 1575 } |
1503 | 1576 |
1504 bool WindowTree::IsWindowKnownForAccessPolicy( | 1577 bool WindowTree::IsWindowKnownForAccessPolicy( |
1505 const ServerWindow* window) const { | 1578 const ServerWindow* window) const { |
1506 return IsWindowKnown(window); | 1579 return IsWindowKnown(window); |
1507 } | 1580 } |
1508 | 1581 |
1509 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( | 1582 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( |
1510 const ServerWindow* window) const { | 1583 const ServerWindow* window) const { |
1511 WindowTree* tree = window_server_->GetTreeWithRoot(window); | 1584 WindowTree* tree = window_server_->GetTreeWithRoot(window); |
1512 return tree && tree != this; | 1585 return tree && tree != this; |
1513 } | 1586 } |
1514 | 1587 |
1515 } // namespace ws | 1588 } // namespace ws |
1516 } // namespace mus | 1589 } // namespace mus |
OLD | NEW |