Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: services/ui/ws/drag_controller.cc

Issue 2784663003: mus: Rename mojom::Cursor to mojom::CursorType. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/ws/drag_controller.h ('k') | services/ui/ws/drag_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/ui/ws/drag_controller.h" 5 #include "services/ui/ws/drag_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "services/ui/public/interfaces/cursor.mojom.h" 10 #include "services/ui/public/interfaces/cursor.mojom.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 DragSource* source, 45 DragSource* source,
46 ServerWindow* source_window, 46 ServerWindow* source_window,
47 DragTargetConnection* source_connection, 47 DragTargetConnection* source_connection,
48 int32_t drag_pointer, 48 int32_t drag_pointer,
49 const std::unordered_map<std::string, std::vector<uint8_t>>& mime_data, 49 const std::unordered_map<std::string, std::vector<uint8_t>>& mime_data,
50 DropEffectBitmask drag_operations) 50 DropEffectBitmask drag_operations)
51 : source_(source), 51 : source_(source),
52 cursor_updater_(cursor_updater), 52 cursor_updater_(cursor_updater),
53 drag_operations_(drag_operations), 53 drag_operations_(drag_operations),
54 drag_pointer_id_(drag_pointer), 54 drag_pointer_id_(drag_pointer),
55 current_cursor_(ui::mojom::Cursor::NO_DROP), 55 current_cursor_(ui::mojom::CursorType::NO_DROP),
56 source_window_(source_window), 56 source_window_(source_window),
57 source_connection_(source_connection), 57 source_connection_(source_connection),
58 mime_data_(mime_data), 58 mime_data_(mime_data),
59 weak_factory_(this) { 59 weak_factory_(this) {
60 SetCurrentTargetWindow(nullptr); 60 SetCurrentTargetWindow(nullptr);
61 EnsureWindowObserved(source_window_); 61 EnsureWindowObserved(source_window_);
62 } 62 }
63 63
64 DragController::~DragController() { 64 DragController::~DragController() {
65 for (auto& pair : window_state_) { 65 for (auto& pair : window_state_) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 DropEffectBitmask bitmask) { 180 DropEffectBitmask bitmask) {
181 WindowState& state = window_state_[window]; 181 WindowState& state = window_state_[window];
182 state.bitmask = bitmask; 182 state.bitmask = bitmask;
183 183
184 if (current_target_window_ == window) { 184 if (current_target_window_ == window) {
185 current_cursor_ = CursorForEffectBitmask(bitmask); 185 current_cursor_ = CursorForEffectBitmask(bitmask);
186 cursor_updater_->OnDragCursorUpdated(); 186 cursor_updater_->OnDragCursorUpdated();
187 } 187 }
188 } 188 }
189 189
190 ui::mojom::Cursor DragController::CursorForEffectBitmask( 190 ui::mojom::CursorType DragController::CursorForEffectBitmask(
191 DropEffectBitmask bitmask) { 191 DropEffectBitmask bitmask) {
192 DropEffectBitmask combined = bitmask & drag_operations_; 192 DropEffectBitmask combined = bitmask & drag_operations_;
193 return combined == ui::mojom::kDropEffectNone 193 return combined == ui::mojom::kDropEffectNone ? ui::mojom::CursorType::NO_DROP
194 ? ui::mojom::Cursor::NO_DROP 194 : ui::mojom::CursorType::COPY;
195 : ui::mojom::Cursor::COPY;
196 } 195 }
197 196
198 void DragController::SetCurrentTargetWindow(ServerWindow* current_target) { 197 void DragController::SetCurrentTargetWindow(ServerWindow* current_target) {
199 current_target_window_ = current_target; 198 current_target_window_ = current_target;
200 199
201 if (current_target_window_) { 200 if (current_target_window_) {
202 // Immediately set the cursor to the last known set of operations (which 201 // Immediately set the cursor to the last known set of operations (which
203 // could be none). 202 // could be none).
204 WindowState& state = window_state_[current_target_window_]; 203 WindowState& state = window_state_[current_target_window_];
205 current_cursor_ = CursorForEffectBitmask(state.bitmask); 204 current_cursor_ = CursorForEffectBitmask(state.bitmask);
206 } else { 205 } else {
207 // Can't drop in empty areas. 206 // Can't drop in empty areas.
208 current_cursor_ = ui::mojom::Cursor::NO_DROP; 207 current_cursor_ = ui::mojom::CursorType::NO_DROP;
209 } 208 }
210 209
211 cursor_updater_->OnDragCursorUpdated(); 210 cursor_updater_->OnDragCursorUpdated();
212 } 211 }
213 212
214 void DragController::EnsureWindowObserved(ServerWindow* window) { 213 void DragController::EnsureWindowObserved(ServerWindow* window) {
215 if (!window) 214 if (!window)
216 return; 215 return;
217 216
218 WindowState& state = window_state_[window]; 217 WindowState& state = window_state_[window];
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 return "LEAVE"; 357 return "LEAVE";
359 case OperationType::DROP: 358 case OperationType::DROP:
360 return "DROP"; 359 return "DROP";
361 } 360 }
362 NOTREACHED(); 361 NOTREACHED();
363 return std::string(); 362 return std::string();
364 } 363 }
365 364
366 } // namespace ws 365 } // namespace ws
367 } // namespace ui 366 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/drag_controller.h ('k') | services/ui/ws/drag_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698