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

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: Use not not pattern to fix win compile 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 waiting_for_top_level_window_info->client_window_id; 405 waiting_for_top_level_window_info->client_window_id;
406 roots_.insert(window); 406 roots_.insert(window);
407 Display* display = GetDisplay(window); 407 Display* display = GetDisplay(window);
408 int64_t display_id = 408 int64_t display_id =
409 display ? display->id() : display::Display::kInvalidDisplayID; 409 display ? display->id() : display::Display::kInvalidDisplayID;
410 const bool drawn = window->parent() && window->parent()->IsDrawn(); 410 const bool drawn = window->parent() && window->parent()->IsDrawn();
411 client()->OnTopLevelCreated(client_change_id, WindowToWindowData(window), 411 client()->OnTopLevelCreated(client_change_id, WindowToWindowData(window),
412 display_id, drawn); 412 display_id, drawn);
413 } 413 }
414 414
415 void WindowTree::OnMoveLoopCompleted(uint32_t client_change_id,
416 bool completed) {
417 client()->OnMoveLoopCompleted(client_change_id, completed);
418 }
419
415 void WindowTree::AddActivationParent(const ClientWindowId& window_id) { 420 void WindowTree::AddActivationParent(const ClientWindowId& window_id) {
416 ServerWindow* window = GetWindowByClientId(window_id); 421 ServerWindow* window = GetWindowByClientId(window_id);
417 if (window) { 422 if (window) {
418 Display* display = GetDisplay(window); 423 Display* display = GetDisplay(window);
419 if (display) 424 if (display)
420 display->AddActivationParent(window); 425 display->AddActivationParent(window);
421 else 426 else
422 DVLOG(1) << "AddActivationParent window not associated with display"; 427 DVLOG(1) << "AddActivationParent window not associated with display";
423 } else { 428 } else {
424 DVLOG(1) << "AddActivationParent supplied invalid window id"; 429 DVLOG(1) << "AddActivationParent supplied invalid window id";
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_->window_tree()->ClientJankinessChanged(this); 1309 event_source_wms_->window_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
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 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1418 bool success = window && access_policy_->CanInitiateMoveLoop(window);
1419 if (!success || !ShouldRouteToWindowManager(window)) {
1420 // We need to fail this move loop change, otherwise the client will just be
1421 // waiting for |change_id|.
1422 OnMoveLoopCompleted(change_id, false);
1423 return;
1424 }
1425
1426 WindowManagerDisplayRoot* display_root =
1427 GetWindowManagerDisplayRoot(window);
1428 WindowManagerState* wms = display_root->window_manager_state();
sky 2016/06/24 19:59:01 Make sure you deal with a null display_root. This
1429
1430 if (wms->in_move_loop()) {
1431 // The window manager is already servicing a move loop; we can't start a
1432 // second one.
1433 OnMoveLoopCompleted(change_id, false);
1434 return;
1435 }
1436
1437 // When we perform a window move loop, we give the window manager non client
1438 // capture. Because of how the capture public interface currently works,
1439 // SetCapture() will check whether the mouse cursor is currently in the
1440 // non-client area and if so, will redirect messages to the window
1441 // manager. (And normal window movement relies on this behaviour.)
1442 wms->SetCapture(window, wms->window_tree()->id());
1443
1444 const uint32_t wm_change_id =
1445 window_server_->GenerateWindowManagerChangeId(this, change_id);
1446 wms->StartMoveLoop(wm_change_id, window->id(), window->bounds());
sky 2016/06/24 19:59:01 I tend think this code should call WMS::StartMoveL
Elliot Glaysher 2016/06/28 22:32:37 I went through trying to move it, but it would req
1447 wms->window_tree()->window_manager_internal_->WmPerformMoveLoop(
1448 wm_change_id, wms->window_tree()->ClientWindowIdForWindow(window).id,
1449 cursor);
1450 }
1451
1452 void WindowTree::CancelWindowMove(Id window_id) {
1453 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1454 bool success = window && access_policy_->CanInitiateMoveLoop(window);
1455 if (!success)
sky 2016/06/24 19:59:01 This should also fail if this client didn't initia
1456 return;
1457
1458 WindowManagerDisplayRoot* display_root =
1459 GetWindowManagerDisplayRoot(window);
1460 WindowManagerState* wms = display_root->window_manager_state();
sky 2016/06/24 19:59:01 Similar comment about display_root.
1461
1462 wms->window_tree()->window_manager_internal_->WmCancelMoveLoop(
1463 wms->window_tree()->ClientWindowIdForWindow(window).id);
1464 }
1465
1408 void WindowTree::AddAccelerator(uint32_t id, 1466 void WindowTree::AddAccelerator(uint32_t id,
1409 mojom::EventMatcherPtr event_matcher, 1467 mojom::EventMatcherPtr event_matcher,
1410 const AddAcceleratorCallback& callback) { 1468 const AddAcceleratorCallback& callback) {
1411 DCHECK(window_manager_state_); 1469 DCHECK(window_manager_state_);
1412 const bool success = 1470 const bool success =
1413 window_manager_state_->event_dispatcher()->AddAccelerator( 1471 window_manager_state_->event_dispatcher()->AddAccelerator(
1414 id, std::move(event_matcher)); 1472 id, std::move(event_matcher));
1415 callback.Run(success); 1473 callback.Run(success);
1416 } 1474 }
1417 1475
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 ServerWindow* window = 1568 ServerWindow* window =
1511 GetWindowByClientId(ClientWindowId(transport_window_id)); 1569 GetWindowByClientId(ClientWindowId(transport_window_id));
1512 if (window && window->id().client_id != id_) { 1570 if (window && window->id().client_id != id_) {
1513 DVLOG(1) << "OnWmCreatedTopLevelWindow supplied invalid window id"; 1571 DVLOG(1) << "OnWmCreatedTopLevelWindow supplied invalid window id";
1514 window_server_->WindowManagerSentBogusMessage(); 1572 window_server_->WindowManagerSentBogusMessage();
1515 window = nullptr; 1573 window = nullptr;
1516 } 1574 }
1517 window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window); 1575 window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window);
1518 } 1576 }
1519 1577
1578 void WindowTree::OnWmMoveLoopCompleted(uint32_t change_id,
1579 bool succeeded) {
1580 if (window_manager_state_) {
sky 2016/06/24 19:59:01 nit: early return.
1581 ServerWindow* window = nullptr;
1582 if (!window_manager_state_->in_move_loop() ||
1583 window_manager_state_->GetCurrentMoveLoopChangeId() != change_id) {
1584 window_server_->WindowManagerSentBogusMessage();
1585 } else {
1586 window = GetWindow(window_manager_state_->GetCurrentMoveLoopWindowId());
1587 }
1588
1589 if (window && window->id().client_id != id_) {
1590 window_server_->WindowManagerSentBogusMessage();
1591 window = nullptr;
1592 } else {
1593 // Clear the implicit capture.
1594 window_manager_state_->SetCapture(nullptr, false);
sky 2016/06/24 19:59:01 Similar comment about having WMS handle all the de
1595 }
1596
1597 if (!succeeded && window && window_manager_state_->in_move_loop()) {
1598 // Our move loop didn't succeed, which means that we must restore the
1599 // original bounds of the window.
1600 window->SetBounds(
1601 window_manager_state_->GetCurrentMoveLoopRevertBounds());
1602 }
1603
1604 window_manager_state_->EndMoveLoop();
1605 window_server_->WindowManagerCompletedMoveLoop(change_id, window,
1606 succeeded);
1607 }
1608 }
1609
1520 bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const { 1610 bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const {
1521 return HasRoot(window); 1611 return HasRoot(window);
1522 } 1612 }
1523 1613
1524 bool WindowTree::IsWindowKnownForAccessPolicy( 1614 bool WindowTree::IsWindowKnownForAccessPolicy(
1525 const ServerWindow* window) const { 1615 const ServerWindow* window) const {
1526 return IsWindowKnown(window); 1616 return IsWindowKnown(window);
1527 } 1617 }
1528 1618
1529 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( 1619 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy(
1530 const ServerWindow* window) const { 1620 const ServerWindow* window) const {
1531 WindowTree* tree = window_server_->GetTreeWithRoot(window); 1621 WindowTree* tree = window_server_->GetTreeWithRoot(window);
1532 return tree && tree != this; 1622 return tree && tree != this;
1533 } 1623 }
1534 1624
1535 } // namespace ws 1625 } // namespace ws
1536 } // namespace mus 1626 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698