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/wm_window_mus.h" | 7 #include "ash/mus/bridge/wm_window_mus.h" |
| 8 #include "ash/mus/bridge/workspace_event_handler_mus.h" |
8 #include "services/ui/public/cpp/window.h" | 9 #include "services/ui/public/cpp/window.h" |
9 #include "services/ui/public/cpp/window_manager_delegate.h" | 10 #include "services/ui/public/cpp/window_manager_delegate.h" |
10 #include "services/ui/public/cpp/window_property.h" | 11 #include "services/ui/public/cpp/window_property.h" |
11 #include "services/ui/public/interfaces/cursor.mojom.h" | 12 #include "services/ui/public/interfaces/cursor.mojom.h" |
12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.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 MUS_DECLARE_WINDOW_PROPERTY_TYPE(ash::mus::MoveEventHandler*) | 17 MUS_DECLARE_WINDOW_PROPERTY_TYPE(ash::mus::MoveEventHandler*) |
17 | 18 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 104 |
104 void MoveEventHandler::Detach() { | 105 void MoveEventHandler::Detach() { |
105 if (!root_window_) | 106 if (!root_window_) |
106 return; | 107 return; |
107 | 108 |
108 root_window_->RemoveObserver(this); | 109 root_window_->RemoveObserver(this); |
109 root_window_->RemovePreTargetHandler(this); | 110 root_window_->RemovePreTargetHandler(this); |
110 root_window_ = nullptr; | 111 root_window_ = nullptr; |
111 } | 112 } |
112 | 113 |
| 114 WorkspaceEventHandlerMus* MoveEventHandler::GetWorkspaceEventHandlerMus() { |
| 115 if (!wm_window_->GetParent()) |
| 116 return nullptr; |
| 117 |
| 118 return WorkspaceEventHandlerMus::Get(wm_window_->mus_window()->parent()); |
| 119 } |
| 120 |
113 void MoveEventHandler::OnMouseEvent(ui::MouseEvent* event) { | 121 void MoveEventHandler::OnMouseEvent(ui::MouseEvent* event) { |
114 toplevel_window_event_handler_.OnMouseEvent(event, wm_window_); | 122 toplevel_window_event_handler_.OnMouseEvent(event, wm_window_); |
115 if (!toplevel_window_event_handler_.is_drag_in_progress() && | 123 if (!toplevel_window_event_handler_.is_drag_in_progress() && |
116 (event->type() == ui::ET_POINTER_MOVED || | 124 (event->type() == ui::ET_POINTER_MOVED || |
117 event->type() == ui::ET_MOUSE_MOVED)) { | 125 event->type() == ui::ET_MOUSE_MOVED)) { |
118 const int hit_test_location = | 126 const int hit_test_location = |
119 wm_window_->GetNonClientComponent(event->location()); | 127 wm_window_->GetNonClientComponent(event->location()); |
120 window_manager_client_->SetNonClientCursor( | 128 window_manager_client_->SetNonClientCursor( |
121 wm_window_->mus_window(), CursorForWindowComponent(hit_test_location)); | 129 wm_window_->mus_window(), CursorForWindowComponent(hit_test_location)); |
122 } | 130 } |
| 131 |
| 132 WorkspaceEventHandlerMus* workspace_event_handler = |
| 133 GetWorkspaceEventHandlerMus(); |
| 134 if (workspace_event_handler) |
| 135 workspace_event_handler->OnMouseEvent(event, wm_window_); |
123 } | 136 } |
124 | 137 |
125 void MoveEventHandler::OnGestureEvent(ui::GestureEvent* event) { | 138 void MoveEventHandler::OnGestureEvent(ui::GestureEvent* event) { |
126 toplevel_window_event_handler_.OnGestureEvent(event, wm_window_); | 139 toplevel_window_event_handler_.OnGestureEvent(event, wm_window_); |
| 140 |
| 141 WorkspaceEventHandlerMus* workspace_event_handler = |
| 142 GetWorkspaceEventHandlerMus(); |
| 143 if (workspace_event_handler) |
| 144 workspace_event_handler->OnGestureEvent(event, wm_window_); |
127 } | 145 } |
128 | 146 |
129 void MoveEventHandler::OnCancelMode(ui::CancelModeEvent* event) { | 147 void MoveEventHandler::OnCancelMode(ui::CancelModeEvent* event) { |
130 toplevel_window_event_handler_.RevertDrag(); | 148 toplevel_window_event_handler_.RevertDrag(); |
131 } | 149 } |
132 | 150 |
133 void MoveEventHandler::OnWindowDestroying(aura::Window* window) { | 151 void MoveEventHandler::OnWindowDestroying(aura::Window* window) { |
134 DCHECK_EQ(root_window_, window); | 152 DCHECK_EQ(root_window_, window); |
135 Detach(); | 153 Detach(); |
136 } | 154 } |
137 | 155 |
138 } // namespace mus | 156 } // namespace mus |
139 } // namespace ash | 157 } // namespace ash |
OLD | NEW |