Chromium Code Reviews| Index: components/mus/ws/window_tree.cc |
| diff --git a/components/mus/ws/window_tree.cc b/components/mus/ws/window_tree.cc |
| index f1dc0c89db7b249f99514aadae43252bfc10b238..51a6d21525a8ede16b420c528e689a1f5c5383a2 100644 |
| --- a/components/mus/ws/window_tree.cc |
| +++ b/components/mus/ws/window_tree.cc |
| @@ -412,6 +412,11 @@ void WindowTree::OnWindowManagerCreatedTopLevelWindow( |
| display_id, drawn); |
| } |
| +void WindowTree::OnMoveLoopCompleted(uint32_t client_change_id, |
| + bool completed) { |
| + client()->OnMoveLoopCompleted(client_change_id, completed); |
| +} |
| + |
| void WindowTree::AddActivationParent(const ClientWindowId& window_id) { |
| ServerWindow* window = GetWindowByClientId(window_id); |
| if (window) { |
| @@ -1295,7 +1300,8 @@ void WindowTree::OnWindowInputEventAck(uint32_t event_id, |
| mojom::EventResult result) { |
| if (event_ack_id_ == 0 || event_id != event_ack_id_) { |
| // TODO(sad): Something bad happened. Kill the client? |
| - NOTIMPLEMENTED() << "Wrong event acked."; |
| + NOTIMPLEMENTED() << ": Wrong event acked. event_id=" << event_id |
| + << ", event_ack_id_=" << event_ack_id_; |
| } |
| event_ack_id_ = 0; |
| @@ -1405,6 +1411,58 @@ void WindowTree::GetCursorLocationMemory( |
| GetCursorLocationMemory()); |
| } |
| +void WindowTree::PerformWindowMove(uint32_t change_id, |
| + Id window_id, |
| + const gfx::Point& cursor) { |
| + ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| + bool success = window && access_policy_->CanInitiateMoveLoop(window); |
| + if (!success || !ShouldRouteToWindowManager(window)) { |
| + // We need to fail this move loop change, otherwise the client will just be |
| + // waiting for |change_id|. |
| + OnMoveLoopCompleted(change_id, false); |
| + return; |
| + } |
| + |
| + WindowManagerDisplayRoot* display_root = |
| + GetWindowManagerDisplayRoot(window); |
| + WindowManagerState* wms = display_root->window_manager_state(); |
|
sky
2016/06/24 19:59:01
Make sure you deal with a null display_root. This
|
| + |
| + if (wms->in_move_loop()) { |
| + // The window manager is already servicing a move loop; we can't start a |
| + // second one. |
| + OnMoveLoopCompleted(change_id, false); |
| + return; |
| + } |
| + |
| + // When we perform a window move loop, we give the window manager non client |
| + // capture. Because of how the capture public interface currently works, |
| + // SetCapture() will check whether the mouse cursor is currently in the |
| + // non-client area and if so, will redirect messages to the window |
| + // manager. (And normal window movement relies on this behaviour.) |
| + wms->SetCapture(window, wms->window_tree()->id()); |
| + |
| + const uint32_t wm_change_id = |
| + window_server_->GenerateWindowManagerChangeId(this, change_id); |
| + 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
|
| + wms->window_tree()->window_manager_internal_->WmPerformMoveLoop( |
| + wm_change_id, wms->window_tree()->ClientWindowIdForWindow(window).id, |
| + cursor); |
| +} |
| + |
| +void WindowTree::CancelWindowMove(Id window_id) { |
| + ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
| + bool success = window && access_policy_->CanInitiateMoveLoop(window); |
| + if (!success) |
|
sky
2016/06/24 19:59:01
This should also fail if this client didn't initia
|
| + return; |
| + |
| + WindowManagerDisplayRoot* display_root = |
| + GetWindowManagerDisplayRoot(window); |
| + WindowManagerState* wms = display_root->window_manager_state(); |
|
sky
2016/06/24 19:59:01
Similar comment about display_root.
|
| + |
| + wms->window_tree()->window_manager_internal_->WmCancelMoveLoop( |
| + wms->window_tree()->ClientWindowIdForWindow(window).id); |
| +} |
| + |
| void WindowTree::AddAccelerator(uint32_t id, |
| mojom::EventMatcherPtr event_matcher, |
| const AddAcceleratorCallback& callback) { |
| @@ -1517,6 +1575,38 @@ void WindowTree::OnWmCreatedTopLevelWindow(uint32_t change_id, |
| window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window); |
| } |
| +void WindowTree::OnWmMoveLoopCompleted(uint32_t change_id, |
| + bool succeeded) { |
| + if (window_manager_state_) { |
|
sky
2016/06/24 19:59:01
nit: early return.
|
| + ServerWindow* window = nullptr; |
| + if (!window_manager_state_->in_move_loop() || |
| + window_manager_state_->GetCurrentMoveLoopChangeId() != change_id) { |
| + window_server_->WindowManagerSentBogusMessage(); |
| + } else { |
| + window = GetWindow(window_manager_state_->GetCurrentMoveLoopWindowId()); |
| + } |
| + |
| + if (window && window->id().client_id != id_) { |
| + window_server_->WindowManagerSentBogusMessage(); |
| + window = nullptr; |
| + } else { |
| + // Clear the implicit capture. |
| + window_manager_state_->SetCapture(nullptr, false); |
|
sky
2016/06/24 19:59:01
Similar comment about having WMS handle all the de
|
| + } |
| + |
| + if (!succeeded && window && window_manager_state_->in_move_loop()) { |
| + // Our move loop didn't succeed, which means that we must restore the |
| + // original bounds of the window. |
| + window->SetBounds( |
| + window_manager_state_->GetCurrentMoveLoopRevertBounds()); |
| + } |
| + |
| + window_manager_state_->EndMoveLoop(); |
| + window_server_->WindowManagerCompletedMoveLoop(change_id, window, |
| + succeeded); |
| + } |
| +} |
| + |
| bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const { |
| return HasRoot(window); |
| } |