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

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

Issue 2833163002: Change ui cursor identifiers to an enum class. (Closed)
Patch Set: OK, it can't be explicit for mac. 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/display.cc ('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/cursor.mojom.h" 10 #include "services/ui/public/interfaces/cursor/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::CursorType::NO_DROP), 55 current_cursor_(ui::mojom::CursorType::kNoDrop),
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::CursorType 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 ? ui::mojom::CursorType::NO_DROP 193 return combined == ui::mojom::kDropEffectNone ? ui::mojom::CursorType::kNoDrop
194 : ui::mojom::CursorType::COPY; 194 : ui::mojom::CursorType::kCopy;
195 } 195 }
196 196
197 void DragController::SetCurrentTargetWindow(ServerWindow* current_target) { 197 void DragController::SetCurrentTargetWindow(ServerWindow* current_target) {
198 current_target_window_ = current_target; 198 current_target_window_ = current_target;
199 199
200 if (current_target_window_) { 200 if (current_target_window_) {
201 // 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
202 // could be none). 202 // could be none).
203 WindowState& state = window_state_[current_target_window_]; 203 WindowState& state = window_state_[current_target_window_];
204 current_cursor_ = CursorForEffectBitmask(state.bitmask); 204 current_cursor_ = CursorForEffectBitmask(state.bitmask);
205 } else { 205 } else {
206 // Can't drop in empty areas. 206 // Can't drop in empty areas.
207 current_cursor_ = ui::mojom::CursorType::NO_DROP; 207 current_cursor_ = ui::mojom::CursorType::kNoDrop;
208 } 208 }
209 209
210 cursor_updater_->OnDragCursorUpdated(); 210 cursor_updater_->OnDragCursorUpdated();
211 } 211 }
212 212
213 void DragController::EnsureWindowObserved(ServerWindow* window) { 213 void DragController::EnsureWindowObserved(ServerWindow* window) {
214 if (!window) 214 if (!window)
215 return; 215 return;
216 216
217 WindowState& state = window_state_[window]; 217 WindowState& state = window_state_[window];
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 return "LEAVE"; 357 return "LEAVE";
358 case OperationType::DROP: 358 case OperationType::DROP:
359 return "DROP"; 359 return "DROP";
360 } 360 }
361 NOTREACHED(); 361 NOTREACHED();
362 return std::string(); 362 return std::string();
363 } 363 }
364 364
365 } // namespace ws 365 } // namespace ws
366 } // namespace ui 366 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/display.cc ('k') | services/ui/ws/drag_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698