Index: components/mus/ws/window_tree.cc |
diff --git a/components/mus/ws/window_tree.cc b/components/mus/ws/window_tree.cc |
index 2189fdb92da6212e94132d697ee46b935ed9c34b..eed01e4192adf97217eb3ca41a45d75e0077c83c 100644 |
--- a/components/mus/ws/window_tree.cc |
+++ b/components/mus/ws/window_tree.cc |
@@ -407,6 +407,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,52 @@ void WindowTree::GetCursorLocationMemory( |
GetCursorLocationMemory()); |
} |
+void WindowTree::PerformWindowMove(uint32_t change_id, |
+ Id window_id, |
+ const gfx::Point& cursor) { |
+ // 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.
|
+ // a move while another move is in progress? |
+ |
+ ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); |
+ bool success = window && access_policy_->CanInitiateMoveLoop(window); |
+ if (!success) { |
sky
2016/06/22 23:47:57
You should also fail if ShouldRouteToWindowManager
|
+ // We need to fail this move loop change, otherwise the client will just be |
+ // waiting for |change_id|. |
+ OnMoveLoopCompleted(change_id, false); |
+ return; |
+ } |
+ |
+ WindowManagerState* wms = display_manager() |
+ ->GetWindowManagerAndDisplay(window) |
+ .window_manager_state; |
sky
2016/06/22 23:47:57
Sorry, I changed this around. You'll want:
Wi
|
+ |
+ // 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, true); |
sky
2016/06/22 23:47:57
true should be the id() of the WindowTree from Win
|
+ |
+ const uint32_t wm_change_id = |
+ window_server_->GenerateWindowManagerChangeId(this, change_id); |
+ wms->tree()->window_manager_internal_->WmPerformMoveLoop( |
+ wm_change_id, wms->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) |
+ return; |
+ |
+ WindowManagerState* wms = display_manager() |
+ ->GetWindowManagerAndDisplay(window) |
+ .window_manager_state; |
+ |
+ wms->tree()->window_manager_internal_->WmCancelMoveLoop( |
+ wms->tree()->ClientWindowIdForWindow(window).id); |
+} |
+ |
void WindowTree::AddAccelerator(uint32_t id, |
mojom::EventMatcherPtr event_matcher, |
const AddAcceleratorCallback& callback) { |
@@ -1497,6 +1549,27 @@ void WindowTree::OnWmCreatedTopLevelWindow(uint32_t change_id, |
window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window); |
} |
+void WindowTree::OnWmMoveLoopCompleted(uint32_t change_id, |
+ Id transport_window_id, |
+ bool succeeded) { |
+ WindowManagerState* wms = GetWindowManagerStateForWindowManager(); |
+ if (wms) { |
+ ServerWindow* window = |
+ GetWindowByClientId(ClientWindowId(transport_window_id)); |
+ |
+ if (window && window->id().client_id != id_) { |
+ window_server_->WindowManagerSentBogusMessage(); |
+ window = nullptr; |
+ } else { |
+ // Clear the implicit capture. |
+ wms->SetCapture(nullptr, false); |
+ } |
+ |
+ window_server_->WindowManagerCompletedMoveLoop(change_id, window, |
+ succeeded); |
+ } |
+} |
+ |
bool WindowTree::HasRootForAccessPolicy(const ServerWindow* window) const { |
return HasRoot(window); |
} |