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

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

Issue 2378883002: mus ws: Consistently use mojom::Cursor instead of int32_t. (Closed)
Patch Set: Created 4 years, 2 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/event_dispatcher.h » ('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 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data, 49 mojo::Map<mojo::String, mojo::Array<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_(static_cast<int32_t>(ui::mojom::Cursor::NO_DROP)), 55 current_cursor_(ui::mojom::Cursor::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_(std::move(mime_data)), 58 mime_data_(std::move(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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 DropEffectBitmask bitmask) { 166 DropEffectBitmask bitmask) {
167 WindowState& state = window_state_[window]; 167 WindowState& state = window_state_[window];
168 state.bitmask = bitmask; 168 state.bitmask = bitmask;
169 169
170 if (current_target_window_ == window) { 170 if (current_target_window_ == window) {
171 current_cursor_ = CursorForEffectBitmask(bitmask); 171 current_cursor_ = CursorForEffectBitmask(bitmask);
172 cursor_updater_->OnDragCursorUpdated(); 172 cursor_updater_->OnDragCursorUpdated();
173 } 173 }
174 } 174 }
175 175
176 int32_t DragController::CursorForEffectBitmask(DropEffectBitmask bitmask) { 176 ui::mojom::Cursor DragController::CursorForEffectBitmask(
177 DropEffectBitmask bitmask) {
177 DropEffectBitmask combined = bitmask & drag_operations_; 178 DropEffectBitmask combined = bitmask & drag_operations_;
178 return combined == ui::mojom::kDropEffectNone 179 return combined == ui::mojom::kDropEffectNone
179 ? static_cast<int32_t>(ui::mojom::Cursor::NO_DROP) 180 ? ui::mojom::Cursor::NO_DROP
180 : static_cast<int32_t>(ui::mojom::Cursor::COPY); 181 : ui::mojom::Cursor::COPY;
181 } 182 }
182 183
183 void DragController::SetCurrentTargetWindow(ServerWindow* current_target) { 184 void DragController::SetCurrentTargetWindow(ServerWindow* current_target) {
184 current_target_window_ = current_target; 185 current_target_window_ = current_target;
185 186
186 if (current_target_window_) { 187 if (current_target_window_) {
187 // Immediately set the cursor to the last known set of operations (which 188 // Immediately set the cursor to the last known set of operations (which
188 // could be none). 189 // could be none).
189 WindowState& state = window_state_[current_target_window_]; 190 WindowState& state = window_state_[current_target_window_];
190 current_cursor_ = CursorForEffectBitmask(state.bitmask); 191 current_cursor_ = CursorForEffectBitmask(state.bitmask);
191 } else { 192 } else {
192 // Can't drop in empty areas. 193 // Can't drop in empty areas.
193 current_cursor_ = static_cast<int32_t>(ui::mojom::Cursor::NO_DROP); 194 current_cursor_ = ui::mojom::Cursor::NO_DROP;
194 } 195 }
195 196
196 cursor_updater_->OnDragCursorUpdated(); 197 cursor_updater_->OnDragCursorUpdated();
197 } 198 }
198 199
199 void DragController::EnsureWindowObserved(ServerWindow* window) { 200 void DragController::EnsureWindowObserved(ServerWindow* window) {
200 if (!window) 201 if (!window)
201 return; 202 return;
202 203
203 WindowState& state = window_state_[window]; 204 WindowState& state = window_state_[window];
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 324
324 if (source_window_ == window) { 325 if (source_window_ == window) {
325 source_window_ = nullptr; 326 source_window_ = nullptr;
326 // Our source window is being deleted, fail the drag. 327 // Our source window is being deleted, fail the drag.
327 MessageDragCompleted(false, ui::mojom::kDropEffectNone); 328 MessageDragCompleted(false, ui::mojom::kDropEffectNone);
328 } 329 }
329 } 330 }
330 331
331 } // namespace ws 332 } // namespace ws
332 } // namespace ui 333 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/drag_controller.h ('k') | services/ui/ws/event_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698