| 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 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1539 | 1539 |
| 1540 // Here, we need to dramatically change how the mouse pointer works. Once | 1540 // Here, we need to dramatically change how the mouse pointer works. Once |
| 1541 // we've started a drag drop operation, cursor events don't go to windows as | 1541 // we've started a drag drop operation, cursor events don't go to windows as |
| 1542 // normal. | 1542 // normal. |
| 1543 WindowManagerState* wms = display_root->window_manager_state(); | 1543 WindowManagerState* wms = display_root->window_manager_state(); |
| 1544 window_server_->StartDragLoop(change_id, window, this); | 1544 window_server_->StartDragLoop(change_id, window, this); |
| 1545 wms->SetDragDropSourceWindow(this, window, this, drag_pointer, | 1545 wms->SetDragDropSourceWindow(this, window, this, drag_pointer, |
| 1546 std::move(drag_data), drag_operation); | 1546 std::move(drag_data), drag_operation); |
| 1547 } | 1547 } |
| 1548 | 1548 |
| 1549 void WindowTree::CancelDragDrop(Id window_id) { |
| 1550 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 1551 if (!window) { |
| 1552 DVLOG(1) << "CancelDragDrop failed (no window)"; |
| 1553 return; |
| 1554 } |
| 1555 |
| 1556 if (window != window_server_->GetCurrentDragLoopWindow()) { |
| 1557 DVLOG(1) << "CancelDragDrop failed (not the drag loop window)"; |
| 1558 return; |
| 1559 } |
| 1560 |
| 1561 if (window_server_->GetCurrentDragLoopInitiator() != this) { |
| 1562 DVLOG(1) << "CancelDragDrop failed (not the drag initiator)"; |
| 1563 return; |
| 1564 } |
| 1565 |
| 1566 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(window); |
| 1567 if (!display_root) { |
| 1568 DVLOG(1) << "CancelDragDrop failed (no such window manager display root)"; |
| 1569 return; |
| 1570 } |
| 1571 |
| 1572 WindowManagerState* wms = display_root->window_manager_state(); |
| 1573 wms->CancelDragDrop(); |
| 1574 } |
| 1575 |
| 1549 void WindowTree::PerformWindowMove(uint32_t change_id, | 1576 void WindowTree::PerformWindowMove(uint32_t change_id, |
| 1550 Id window_id, | 1577 Id window_id, |
| 1551 ui::mojom::MoveLoopSource source, | 1578 ui::mojom::MoveLoopSource source, |
| 1552 const gfx::Point& cursor) { | 1579 const gfx::Point& cursor) { |
| 1553 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 1580 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 1554 bool success = window && access_policy_->CanInitiateMoveLoop(window); | 1581 bool success = window && access_policy_->CanInitiateMoveLoop(window); |
| 1555 if (!success || !ShouldRouteToWindowManager(window)) { | 1582 if (!success || !ShouldRouteToWindowManager(window)) { |
| 1556 // We need to fail this move loop change, otherwise the client will just be | 1583 // We need to fail this move loop change, otherwise the client will just be |
| 1557 // waiting for |change_id|. | 1584 // waiting for |change_id|. |
| 1558 DVLOG(1) << "PerformWindowMove failed (access denied)."; | 1585 DVLOG(1) << "PerformWindowMove failed (access denied)."; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1588 window_server_->GenerateWindowManagerChangeId(this, change_id); | 1615 window_server_->GenerateWindowManagerChangeId(this, change_id); |
| 1589 window_server_->StartMoveLoop(wm_change_id, window, this, window->bounds()); | 1616 window_server_->StartMoveLoop(wm_change_id, window, this, window->bounds()); |
| 1590 wms->window_tree()->window_manager_internal_->WmPerformMoveLoop( | 1617 wms->window_tree()->window_manager_internal_->WmPerformMoveLoop( |
| 1591 wm_change_id, wms->window_tree()->ClientWindowIdForWindow(window).id, | 1618 wm_change_id, wms->window_tree()->ClientWindowIdForWindow(window).id, |
| 1592 source, cursor); | 1619 source, cursor); |
| 1593 } | 1620 } |
| 1594 | 1621 |
| 1595 void WindowTree::CancelWindowMove(Id window_id) { | 1622 void WindowTree::CancelWindowMove(Id window_id) { |
| 1596 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); | 1623 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| 1597 bool success = window && access_policy_->CanInitiateMoveLoop(window); | 1624 bool success = window && access_policy_->CanInitiateMoveLoop(window); |
| 1598 if (!success) | 1625 if (!success) { |
| 1626 DVLOG(1) << "CancelWindowMove failed (no window / access denied)"; |
| 1599 return; | 1627 return; |
| 1628 } |
| 1600 | 1629 |
| 1601 if (window != window_server_->GetCurrentMoveLoopWindow()) | 1630 if (window != window_server_->GetCurrentMoveLoopWindow()) { |
| 1631 DVLOG(1) << "CancelWindowMove failed (not the move loop window)"; |
| 1602 return; | 1632 return; |
| 1633 } |
| 1603 | 1634 |
| 1604 if (window_server_->GetCurrentMoveLoopInitiator() != this) | 1635 if (window_server_->GetCurrentMoveLoopInitiator() != this) { |
| 1636 DVLOG(1) << "CancelWindowMove failed (not the move loop initiator)"; |
| 1605 return; | 1637 return; |
| 1638 } |
| 1606 | 1639 |
| 1607 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(window); | 1640 WindowManagerDisplayRoot* display_root = GetWindowManagerDisplayRoot(window); |
| 1608 if (!display_root) | 1641 if (!display_root) { |
| 1642 DVLOG(1) << "CancelWindowMove failed (no such window manager display root)"; |
| 1609 return; | 1643 return; |
| 1644 } |
| 1610 | 1645 |
| 1611 WindowManagerState* wms = display_root->window_manager_state(); | 1646 WindowManagerState* wms = display_root->window_manager_state(); |
| 1612 wms->window_tree()->window_manager_internal_->WmCancelMoveLoop( | 1647 wms->window_tree()->window_manager_internal_->WmCancelMoveLoop( |
| 1613 window_server_->GetCurrentMoveLoopChangeId()); | 1648 window_server_->GetCurrentMoveLoopChangeId()); |
| 1614 } | 1649 } |
| 1615 | 1650 |
| 1616 void WindowTree::AddAccelerator(uint32_t id, | 1651 void WindowTree::AddAccelerator(uint32_t id, |
| 1617 mojom::EventMatcherPtr event_matcher, | 1652 mojom::EventMatcherPtr event_matcher, |
| 1618 const AddAcceleratorCallback& callback) { | 1653 const AddAcceleratorCallback& callback) { |
| 1619 DCHECK(window_manager_state_); | 1654 DCHECK(window_manager_state_); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1872 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, | 1907 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, |
| 1873 effect_bitmask, callback); | 1908 effect_bitmask, callback); |
| 1874 } | 1909 } |
| 1875 | 1910 |
| 1876 void WindowTree::PerformOnDragDropDone() { | 1911 void WindowTree::PerformOnDragDropDone() { |
| 1877 client()->OnDragDropDone(); | 1912 client()->OnDragDropDone(); |
| 1878 } | 1913 } |
| 1879 | 1914 |
| 1880 } // namespace ws | 1915 } // namespace ws |
| 1881 } // namespace ui | 1916 } // namespace ui |
| OLD | NEW |