| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ash/mus/move_event_handler.h" | 5 #include "ash/mus/move_event_handler.h" |
| 6 | 6 |
| 7 #include "ash/mus/bridge/workspace_event_handler_mus.h" | 7 #include "ash/mus/bridge/workspace_event_handler_mus.h" |
| 8 #include "ash/wm_window.h" | 8 #include "ash/wm_window.h" |
| 9 #include "services/ui/public/interfaces/cursor/cursor.mojom.h" | 9 #include "services/ui/public/interfaces/cursor/cursor.mojom.h" |
| 10 #include "ui/aura/mus/window_manager_delegate.h" | 10 #include "ui/aura/mus/window_manager_delegate.h" |
| 11 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
| 12 #include "ui/base/class_property.h" | 12 #include "ui/base/class_property.h" |
| 13 #include "ui/base/cursor/cursor.h" |
| 13 #include "ui/base/hit_test.h" | 14 #include "ui/base/hit_test.h" |
| 14 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
| 15 | 16 |
| 16 DECLARE_UI_CLASS_PROPERTY_TYPE(ash::mus::MoveEventHandler*); | 17 DECLARE_UI_CLASS_PROPERTY_TYPE(ash::mus::MoveEventHandler*); |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 // Key used for storing identifier sent to clients for windows. | 21 // Key used for storing identifier sent to clients for windows. |
| 21 DEFINE_UI_CLASS_PROPERTY_KEY(ash::mus::MoveEventHandler*, | 22 DEFINE_UI_CLASS_PROPERTY_KEY(ash::mus::MoveEventHandler*, |
| 22 kWmMoveEventHandler, | 23 kWmMoveEventHandler, |
| 23 nullptr); | 24 nullptr); |
| 24 | 25 |
| 25 } // namespace | 26 } // namespace |
| 26 | 27 |
| 27 namespace ash { | 28 namespace ash { |
| 28 namespace mus { | 29 namespace mus { |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 ui::mojom::CursorType CursorForWindowComponent(int window_component) { | 32 ui::CursorType CursorForWindowComponent(int window_component) { |
| 32 switch (window_component) { | 33 switch (window_component) { |
| 33 case HTBOTTOM: | 34 case HTBOTTOM: |
| 34 return ui::mojom::CursorType::kSouthResize; | 35 return ui::CursorType::kSouthResize; |
| 35 case HTBOTTOMLEFT: | 36 case HTBOTTOMLEFT: |
| 36 return ui::mojom::CursorType::kSouthWestResize; | 37 return ui::CursorType::kSouthWestResize; |
| 37 case HTBOTTOMRIGHT: | 38 case HTBOTTOMRIGHT: |
| 38 return ui::mojom::CursorType::kSouthEastResize; | 39 return ui::CursorType::kSouthEastResize; |
| 39 case HTLEFT: | 40 case HTLEFT: |
| 40 return ui::mojom::CursorType::kWestResize; | 41 return ui::CursorType::kWestResize; |
| 41 case HTRIGHT: | 42 case HTRIGHT: |
| 42 return ui::mojom::CursorType::kEastResize; | 43 return ui::CursorType::kEastResize; |
| 43 case HTTOP: | 44 case HTTOP: |
| 44 return ui::mojom::CursorType::kNorthResize; | 45 return ui::CursorType::kNorthResize; |
| 45 case HTTOPLEFT: | 46 case HTTOPLEFT: |
| 46 return ui::mojom::CursorType::kNorthWestResize; | 47 return ui::CursorType::kNorthWestResize; |
| 47 case HTTOPRIGHT: | 48 case HTTOPRIGHT: |
| 48 return ui::mojom::CursorType::kNorthEastResize; | 49 return ui::CursorType::kNorthEastResize; |
| 49 default: | 50 default: |
| 50 return ui::mojom::CursorType::kNull; | 51 return ui::CursorType::kNull; |
| 51 } | 52 } |
| 52 } | 53 } |
| 53 | 54 |
| 54 void OnMoveLoopCompleted(const base::Callback<void(bool success)>& end_closure, | 55 void OnMoveLoopCompleted(const base::Callback<void(bool success)>& end_closure, |
| 55 wm::WmToplevelWindowEventHandler::DragResult result) { | 56 wm::WmToplevelWindowEventHandler::DragResult result) { |
| 56 end_closure.Run(result == | 57 end_closure.Run(result == |
| 57 wm::WmToplevelWindowEventHandler::DragResult::SUCCESS); | 58 wm::WmToplevelWindowEventHandler::DragResult::SUCCESS); |
| 58 } | 59 } |
| 59 | 60 |
| 60 } // namespace | 61 } // namespace |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 116 } |
| 116 | 117 |
| 117 void MoveEventHandler::OnMouseEvent(ui::MouseEvent* event) { | 118 void MoveEventHandler::OnMouseEvent(ui::MouseEvent* event) { |
| 118 toplevel_window_event_handler_.OnMouseEvent(event, wm_window_); | 119 toplevel_window_event_handler_.OnMouseEvent(event, wm_window_); |
| 119 if (!toplevel_window_event_handler_.is_drag_in_progress() && | 120 if (!toplevel_window_event_handler_.is_drag_in_progress() && |
| 120 (event->type() == ui::ET_POINTER_MOVED || | 121 (event->type() == ui::ET_POINTER_MOVED || |
| 121 event->type() == ui::ET_MOUSE_MOVED)) { | 122 event->type() == ui::ET_MOUSE_MOVED)) { |
| 122 const int hit_test_location = | 123 const int hit_test_location = |
| 123 wm_window_->GetNonClientComponent(event->location()); | 124 wm_window_->GetNonClientComponent(event->location()); |
| 124 window_manager_client_->SetNonClientCursor( | 125 window_manager_client_->SetNonClientCursor( |
| 125 wm_window_->aura_window(), CursorForWindowComponent(hit_test_location)); | 126 wm_window_->aura_window(), |
| 127 ui::CursorData(CursorForWindowComponent(hit_test_location))); |
| 126 } | 128 } |
| 127 | 129 |
| 128 WorkspaceEventHandlerMus* workspace_event_handler = | 130 WorkspaceEventHandlerMus* workspace_event_handler = |
| 129 GetWorkspaceEventHandlerMus(); | 131 GetWorkspaceEventHandlerMus(); |
| 130 if (workspace_event_handler) | 132 if (workspace_event_handler) |
| 131 workspace_event_handler->OnMouseEvent(event, wm_window_); | 133 workspace_event_handler->OnMouseEvent(event, wm_window_); |
| 132 } | 134 } |
| 133 | 135 |
| 134 void MoveEventHandler::OnGestureEvent(ui::GestureEvent* event) { | 136 void MoveEventHandler::OnGestureEvent(ui::GestureEvent* event) { |
| 135 toplevel_window_event_handler_.OnGestureEvent(event, wm_window_); | 137 toplevel_window_event_handler_.OnGestureEvent(event, wm_window_); |
| 136 | 138 |
| 137 WorkspaceEventHandlerMus* workspace_event_handler = | 139 WorkspaceEventHandlerMus* workspace_event_handler = |
| 138 GetWorkspaceEventHandlerMus(); | 140 GetWorkspaceEventHandlerMus(); |
| 139 if (workspace_event_handler) | 141 if (workspace_event_handler) |
| 140 workspace_event_handler->OnGestureEvent(event, wm_window_); | 142 workspace_event_handler->OnGestureEvent(event, wm_window_); |
| 141 } | 143 } |
| 142 | 144 |
| 143 void MoveEventHandler::OnCancelMode(ui::CancelModeEvent* event) { | 145 void MoveEventHandler::OnCancelMode(ui::CancelModeEvent* event) { |
| 144 toplevel_window_event_handler_.RevertDrag(); | 146 toplevel_window_event_handler_.RevertDrag(); |
| 145 } | 147 } |
| 146 | 148 |
| 147 void MoveEventHandler::OnWindowDestroying(aura::Window* window) { | 149 void MoveEventHandler::OnWindowDestroying(aura::Window* window) { |
| 148 DCHECK_EQ(wm_window_->aura_window(), window); | 150 DCHECK_EQ(wm_window_->aura_window(), window); |
| 149 Detach(); | 151 Detach(); |
| 150 } | 152 } |
| 151 | 153 |
| 152 } // namespace mus | 154 } // namespace mus |
| 153 } // namespace ash | 155 } // namespace ash |
| OLD | NEW |