| Index: ash/mus/frame/move_event_handler.cc
|
| diff --git a/ash/mus/frame/move_event_handler.cc b/ash/mus/frame/move_event_handler.cc
|
| index b903dce5d7465a89418e7ed88a6cf6e7d0ca7f4b..d186cdc0a00847a38bfcee8ca740b459847d272a 100644
|
| --- a/ash/mus/frame/move_event_handler.cc
|
| +++ b/ash/mus/frame/move_event_handler.cc
|
| @@ -5,6 +5,7 @@
|
| #include "ash/mus/frame/move_event_handler.h"
|
|
|
| #include "ash/mus/bridge/wm_window_mus.h"
|
| +#include "base/lazy_instance.h"
|
| #include "components/mus/public/cpp/window.h"
|
| #include "components/mus/public/cpp/window_manager_delegate.h"
|
| #include "components/mus/public/interfaces/cursor.mojom.h"
|
| @@ -16,6 +17,9 @@ namespace ash {
|
| namespace mus {
|
| namespace {
|
|
|
| +base::LazyInstance<std::map<WmWindow*, MoveEventHandler*>> g_live_handlers =
|
| + LAZY_INSTANCE_INITIALIZER;
|
| +
|
| ::mus::mojom::Cursor CursorForWindowComponent(int window_component) {
|
| switch (window_component) {
|
| case HTBOTTOM:
|
| @@ -39,6 +43,12 @@ namespace {
|
| }
|
| }
|
|
|
| +void OnMoveLoopCompleted(const base::Callback<void(bool success)>& end_closure,
|
| + wm::WmToplevelWindowEventHandler::DragResult result) {
|
| + end_closure.Run(result ==
|
| + wm::WmToplevelWindowEventHandler::DragResult::SUCCESS);
|
| +}
|
| +
|
| } // namespace
|
|
|
| MoveEventHandler::MoveEventHandler(
|
| @@ -51,12 +61,37 @@ MoveEventHandler::MoveEventHandler(
|
| toplevel_window_event_handler_(wm_window_->GetShell()) {
|
| root_window_->AddObserver(this);
|
| root_window_->AddPreTargetHandler(this);
|
| +
|
| + DCHECK(g_live_handlers.Get().find(wm_window_) == g_live_handlers.Get().end());
|
| + g_live_handlers.Get()[wm_window_] = this;
|
| }
|
|
|
| MoveEventHandler::~MoveEventHandler() {
|
| Detach();
|
| }
|
|
|
| +// static
|
| +MoveEventHandler* MoveEventHandler::GetForWindow(WmWindow* wm_window) {
|
| + auto it = g_live_handlers.Get().find(wm_window);
|
| + if (it != g_live_handlers.Get().end())
|
| + return it->second;
|
| + return nullptr;
|
| +}
|
| +
|
| +void MoveEventHandler::AttemptToStartDrag(
|
| + const gfx::Point& point_in_parent,
|
| + int window_component,
|
| + const base::Callback<void(bool success)>& end_closure) {
|
| + toplevel_window_event_handler_.AttemptToStartDrag(
|
| + wm_window_, point_in_parent, window_component,
|
| + aura::client::WINDOW_MOVE_SOURCE_MOUSE,
|
| + base::Bind(&OnMoveLoopCompleted, end_closure));
|
| +}
|
| +
|
| +void MoveEventHandler::RevertDrag() {
|
| + toplevel_window_event_handler_.RevertDrag();
|
| +}
|
| +
|
| void MoveEventHandler::Detach() {
|
| if (!root_window_)
|
| return;
|
| @@ -64,6 +99,8 @@ void MoveEventHandler::Detach() {
|
| root_window_->RemoveObserver(this);
|
| root_window_->RemovePreTargetHandler(this);
|
| root_window_ = nullptr;
|
| +
|
| + g_live_handlers.Get().erase(wm_window_);
|
| }
|
|
|
| void MoveEventHandler::OnMouseEvent(ui::MouseEvent* event) {
|
|
|