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

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

Issue 2060513002: Tab dragging as implemented as a mus API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Thread move loop source through api. Created 4 years, 5 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
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 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 ::mus::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_server_->GetCurrentMoveLoopInitiator() != this)
1462 return;
1463
1464 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(window);
1465 if (!display_root)
1466 return;
1467
1468 WindowManagerState* wms = display_root->window_manager_state();
1469 wms->window_tree()->window_manager_internal_->WmCancelMoveLoop(
1470 wms->window_tree()->ClientWindowIdForWindow(window).id);
1471 }
1472
1411 void WindowTree::AddAccelerator(uint32_t id, 1473 void WindowTree::AddAccelerator(uint32_t id,
1412 mojom::EventMatcherPtr event_matcher, 1474 mojom::EventMatcherPtr event_matcher,
1413 const AddAcceleratorCallback& callback) { 1475 const AddAcceleratorCallback& callback) {
1414 DCHECK(window_manager_state_); 1476 DCHECK(window_manager_state_);
1415 const bool success = 1477 const bool success =
1416 window_manager_state_->event_dispatcher()->AddAccelerator( 1478 window_manager_state_->event_dispatcher()->AddAccelerator(
1417 id, std::move(event_matcher)); 1479 id, std::move(event_matcher));
1418 callback.Run(success); 1480 callback.Run(success);
1419 } 1481 }
1420 1482
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 ServerWindow* window = 1575 ServerWindow* window =
1514 GetWindowByClientId(ClientWindowId(transport_window_id)); 1576 GetWindowByClientId(ClientWindowId(transport_window_id));
1515 if (window && window->id().client_id != id_) { 1577 if (window && window->id().client_id != id_) {
1516 DVLOG(1) << "OnWmCreatedTopLevelWindow supplied invalid window id"; 1578 DVLOG(1) << "OnWmCreatedTopLevelWindow supplied invalid window id";
1517 window_server_->WindowManagerSentBogusMessage(); 1579 window_server_->WindowManagerSentBogusMessage();
1518 window = nullptr; 1580 window = nullptr;
1519 } 1581 }
1520 window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window); 1582 window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window);
1521 } 1583 }
1522 1584
1585 void WindowTree::OnWmMoveLoopCompleted(uint32_t change_id, bool succeeded) {
1586 ServerWindow* window = nullptr;
1587 if (!window_server_->in_move_loop() ||
1588 window_server_->GetCurrentMoveLoopChangeId() != change_id) {
1589 window_server_->WindowManagerSentBogusMessage();
1590 } else {
1591 window = window_server_->GetCurrentMoveLoopWindow();
1592 }
1593
1594 if (window) {
1595 if (window->id().client_id != id_) {
1596 window_server_->WindowManagerSentBogusMessage();
1597 window = nullptr;
1598 } else {
1599 WindowManagerDisplayRoot* display_root =
1600 GetWindowManagerDisplayRoot(window);
1601 if (display_root) {
1602 WindowManagerState* wms = display_root->window_manager_state();
1603 // Clear the implicit capture.
1604 wms->SetCapture(nullptr, false);
1605 }
1606 }
1607 }
1608
1609 if (!succeeded && window && window_server_->in_move_loop()) {
1610 // Our move loop didn't succeed, which means that we must restore the
1611 // original bounds of the window.
1612 window->SetBounds(window_server_->GetCurrentMoveLoopRevertBounds());
1613 }
1614
1615 window_server_->EndMoveLoop();
1616 window_server_->WindowManagerCompletedMoveLoop(change_id, window, succeeded);
1617 }
1618
1523 bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const { 1619 bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const {
1524 return HasRoot(window); 1620 return HasRoot(window);
1525 } 1621 }
1526 1622
1527 bool WindowTree::IsWindowKnownForAccessPolicy( 1623 bool WindowTree::IsWindowKnownForAccessPolicy(
1528 const ServerWindow* window) const { 1624 const ServerWindow* window) const {
1529 return IsWindowKnown(window); 1625 return IsWindowKnown(window);
1530 } 1626 }
1531 1627
1532 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( 1628 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy(
1533 const ServerWindow* window) const { 1629 const ServerWindow* window) const {
1534 WindowTree* tree = window_server_->GetTreeWithRoot(window); 1630 WindowTree* tree = window_server_->GetTreeWithRoot(window);
1535 return tree && tree != this; 1631 return tree && tree != this;
1536 } 1632 }
1537 1633
1538 } // namespace ws 1634 } // namespace ws
1539 } // namespace mus 1635 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698